1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Fixed a crash when minimizing

Test brush respects opacity setting
This commit is contained in:
Robert 2020-01-23 19:52:15 +01:00
parent 780abf0fcd
commit 4fc0dc12ab
5 changed files with 50 additions and 31 deletions

View File

@ -189,7 +189,7 @@ namespace Artemis.Core.Models.Profile
}
var shader = SKShader.CreateSweepGradient(new SKPoint(LayerShape.RenderRectangle.MidX, LayerShape.RenderRectangle.MidY), testColors.ToArray());
canvas.DrawPath(LayerShape.RenderPath, new SKPaint {Shader = shader});
canvas.DrawPath(LayerShape.RenderPath, new SKPaint {Shader = shader, Color = new SKColor(0, 0, 0, (byte) (OpacityProperty.CurrentValue * 2.55f)) });
}
LayerBrush?.Render(canvas);

View File

@ -146,7 +146,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
protected override void OnActivate()
{
LoadWorkspaceSettings();
Task.Run(() => LoadProfiles());
Task.Run(LoadProfiles);
base.OnActivate();
}
@ -184,15 +184,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
profiles.Add(activeProfile);
// Populate the UI collection
Profiles.Clear();
Profiles.AddRange(profiles.OrderBy(p => p.Name));
Execute.PostToUIThread(() =>
{
Profiles.Clear();
Profiles.AddRange(profiles.OrderBy(p => p.Name));
SelectedProfile = activeProfile;
SelectedProfile = activeProfile;
_profileEditorService.ChangeSelectedProfile(SelectedProfile);
if (!activeProfile.IsActivated)
_profileService.ActivateProfile(Module, activeProfile);
});
_profileEditorService.ChangeSelectedProfile(SelectedProfile);
if (!activeProfile.IsActivated)
_profileService.ActivateProfile(Module, activeProfile);
}
}
}

View File

@ -28,76 +28,89 @@
Margin="{Binding ControlOffset}"
Canvas.Left="{Binding TopCenter.X}"
Canvas.Top="{Binding TopCenter.Y}"
Fill="{DynamicResource SecondaryAccentBrush}"
Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action TopCenterResize}" />
<Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}"
Canvas.Left="{Binding RightCenter.X}"
Canvas.Top="{Binding RightCenter.Y}"
Fill="{DynamicResource SecondaryAccentBrush}"
Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action RightCenterResize}" />
<Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}"
Canvas.Left="{Binding BottomCenter.X}"
Canvas.Top="{Binding BottomCenter.Y}"
Fill="{DynamicResource SecondaryAccentBrush}"
Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action BottomCenterResize}" />
<Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}"
Canvas.Left="{Binding LeftCenter.X}"
Canvas.Top="{Binding LeftCenter.Y}"
Fill="{DynamicResource SecondaryAccentBrush}"
Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action LeftCenterResize}" />
<Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}"
Canvas.Left="{Binding TopLeft.X}"
Canvas.Top="{Binding TopLeft.Y}"
Fill="{DynamicResource SecondaryAccentBrush}"
Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action TopLeftResize}" />
<Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}"
Canvas.Left="{Binding TopRight.X}"
Canvas.Top="{Binding TopRight.Y}"
Fill="{DynamicResource SecondaryAccentBrush}"
Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action TopRightResize}" />
<Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}"
Canvas.Left="{Binding BottomRight.X}"
Canvas.Top="{Binding BottomRight.Y}"
Fill="{DynamicResource SecondaryAccentBrush}"
Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action BottomRightResize}" />
<Rectangle Width="{Binding ControlSize}"
Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}"
Canvas.Left="{Binding BottomLeft.X}"
Canvas.Top="{Binding BottomLeft.Y}"
Fill="{DynamicResource SecondaryAccentBrush}"
Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action BottomLeftResize}" />
<!-- Anchor point -->
<materialDesign:PackIcon Kind="Crosshairs"
Width="8"
Height="8"
Foreground="{DynamicResource SecondaryAccentBrush}"
Canvas.Left="{Binding ShapeAnchor.X}"
Canvas.Top="{Binding ShapeAnchor.Y}"
Margin="-4,-4,0,0" />
<Ellipse MouseDown="{s:Action AnchorEditMouseDown}"
MouseUp="{s:Action ShapeEditMouseUp}"
MouseMove="{s:Action AnchorMove}"
Width="8"
Height="8"
Fill="Transparent"
Width="{Binding ControlSize}"
Height="{Binding ControlSize}"
Margin="{Binding ControlOffset}"
Fill="White"
Stroke="{DynamicResource SecondaryAccentBrush}"
StrokeThickness="0.5"
Canvas.Left="{Binding ShapeAnchor.X}"
Canvas.Top="{Binding ShapeAnchor.Y}"
Margin="-4,-4,0,0"
Cursor="SizeAll" />
Cursor="SizeAll">
</Ellipse>
</Canvas>
</UserControl>

View File

@ -32,6 +32,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
ProfileViewModel.PanZoomViewModel.PropertyChanged += (sender, args) => UpdateControls();
profileEditorService.SelectedProfileChanged += (sender, args) => Update();
profileEditorService.SelectedProfileElementChanged += (sender, args) => Update();
profileEditorService.SelectedProfileElementUpdated += (sender, args) => Update();
profileEditorService.ProfilePreviewUpdated += (sender, args) => Update();
}
@ -57,7 +58,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
private void Update()
{
if (!(ProfileEditorService.SelectedProfileElement is Layer layer) || layer.LayerShape == null)
if (!(ProfileEditorService.SelectedProfileElement is Layer layer))
return;
ShapeRectangle = _layerEditorService.GetShapeRenderRect(layer.LayerShape).ToSKRect();
@ -92,7 +93,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
Execute.PostToUIThread(() =>
{
ControlSize = Math.Max(8 / ProfileViewModel.PanZoomViewModel.Zoom, 4);
ControlSize = Math.Max(10 / ProfileViewModel.PanZoomViewModel.Zoom, 4);
ControlOffset = new Thickness(ControlSize / 2 * -1, ControlSize / 2 * -1, 0, 0);
OutlineThickness = Math.Max(2 / ProfileViewModel.PanZoomViewModel.Zoom, 1);
});

View File

@ -148,6 +148,9 @@ namespace Artemis.UI.Services
/// <inheritdoc />
public Rect GetShapeRenderRect(LayerShape layerShape)
{
if (layerShape == null)
return Rect.Empty;
// Adjust the render rectangle for the difference in render scale
var renderScale = _settingsService.GetSetting("Core.RenderScale", 1.0).Value;
return new Rect(