mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-02 10:43:31 +00:00
Came up with an easy solution for rotation handles
This commit is contained in:
parent
4fc0dc12ab
commit
296a4f9d8b
@ -11,6 +11,36 @@
|
|||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance {x:Type local:EditToolViewModel}}">
|
d:DataContext="{d:DesignInstance {x:Type local:EditToolViewModel}}">
|
||||||
<Canvas UseLayoutRounding="False">
|
<Canvas UseLayoutRounding="False">
|
||||||
|
|
||||||
|
<!-- Render these first so that they are always behind the actual shape -->
|
||||||
|
<Ellipse Width="{Binding RotateSize}"
|
||||||
|
Height="{Binding RotateSize}"
|
||||||
|
Margin="{Binding RotateOffset}"
|
||||||
|
Canvas.Left="{Binding TopLeft.X}"
|
||||||
|
Canvas.Top="{Binding TopLeft.Y}"
|
||||||
|
Fill="Transparent"
|
||||||
|
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action TopLeftRotate}" Cursor="Cross" />
|
||||||
|
<Ellipse Width="{Binding RotateSize}"
|
||||||
|
Height="{Binding RotateSize}"
|
||||||
|
Margin="{Binding RotateOffset}"
|
||||||
|
Canvas.Left="{Binding TopRight.X}"
|
||||||
|
Canvas.Top="{Binding TopRight.Y}"
|
||||||
|
Fill="Transparent"
|
||||||
|
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action TopRightRotate}" Cursor="Cross" />
|
||||||
|
<Ellipse Width="{Binding RotateSize}"
|
||||||
|
Height="{Binding RotateSize}"
|
||||||
|
Margin="{Binding RotateOffset}"
|
||||||
|
Canvas.Left="{Binding BottomRight.X}"
|
||||||
|
Canvas.Top="{Binding BottomRight.Y}"
|
||||||
|
Fill="Transparent"
|
||||||
|
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action BottomRightRotate}" Cursor="Cross" />
|
||||||
|
<Ellipse Width="{Binding RotateSize}"
|
||||||
|
Height="{Binding RotateSize}"
|
||||||
|
Margin="{Binding RotateOffset}"
|
||||||
|
Canvas.Left="{Binding BottomLeft.X}"
|
||||||
|
Canvas.Top="{Binding BottomLeft.Y}"
|
||||||
|
Fill="Transparent"
|
||||||
|
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action BottomLeftRotate}" Cursor="Cross" />
|
||||||
<!-- The part of the layer's shape that is inside the layer -->
|
<!-- The part of the layer's shape that is inside the layer -->
|
||||||
<Path Data="{Binding ShapeGeometry, Mode=OneWay}"
|
<Path Data="{Binding ShapeGeometry, Mode=OneWay}"
|
||||||
Fill="Transparent"
|
Fill="Transparent"
|
||||||
@ -59,6 +89,7 @@
|
|||||||
Stroke="{DynamicResource SecondaryAccentBrush}"
|
Stroke="{DynamicResource SecondaryAccentBrush}"
|
||||||
StrokeThickness="0.5"
|
StrokeThickness="0.5"
|
||||||
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action LeftCenterResize}" />
|
MouseDown="{s:Action ShapeEditMouseDown}" MouseUp="{s:Action ShapeEditMouseUp}" MouseMove="{s:Action LeftCenterResize}" />
|
||||||
|
|
||||||
<Rectangle Width="{Binding ControlSize}"
|
<Rectangle Width="{Binding ControlSize}"
|
||||||
Height="{Binding ControlSize}"
|
Height="{Binding ControlSize}"
|
||||||
Margin="{Binding ControlOffset}"
|
Margin="{Binding ControlOffset}"
|
||||||
@ -109,8 +140,7 @@
|
|||||||
StrokeThickness="0.5"
|
StrokeThickness="0.5"
|
||||||
Canvas.Left="{Binding ShapeAnchor.X}"
|
Canvas.Left="{Binding ShapeAnchor.X}"
|
||||||
Canvas.Top="{Binding ShapeAnchor.Y}"
|
Canvas.Top="{Binding ShapeAnchor.Y}"
|
||||||
Cursor="SizeAll">
|
Cursor="SizeAll" />
|
||||||
</Ellipse>
|
|
||||||
</Canvas>
|
</Canvas>
|
||||||
|
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -39,7 +39,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
|
|
||||||
|
|
||||||
public double ControlSize { get; set; }
|
public double ControlSize { get; set; }
|
||||||
|
public double RotateSize { get; set; }
|
||||||
public Thickness ControlOffset { get; set; }
|
public Thickness ControlOffset { get; set; }
|
||||||
|
public Thickness RotateOffset { get; set; }
|
||||||
public double OutlineThickness { get; set; }
|
public double OutlineThickness { get; set; }
|
||||||
|
|
||||||
public SKRect ShapeRectangle { get; set; }
|
public SKRect ShapeRectangle { get; set; }
|
||||||
@ -91,12 +93,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
|
|
||||||
private void UpdateControls()
|
private void UpdateControls()
|
||||||
{
|
{
|
||||||
Execute.PostToUIThread(() =>
|
ControlSize = Math.Max(10 / ProfileViewModel.PanZoomViewModel.Zoom, 4);
|
||||||
{
|
RotateSize = ControlSize * 8;
|
||||||
ControlSize = Math.Max(10 / ProfileViewModel.PanZoomViewModel.Zoom, 4);
|
ControlOffset = new Thickness(ControlSize / 2 * -1, ControlSize / 2 * -1, 0, 0);
|
||||||
ControlOffset = new Thickness(ControlSize / 2 * -1, ControlSize / 2 * -1, 0, 0);
|
RotateOffset = new Thickness(RotateSize / 2 * -1, RotateSize / 2 * -1, 0, 0);
|
||||||
OutlineThickness = Math.Max(2 / ProfileViewModel.PanZoomViewModel.Zoom, 1);
|
OutlineThickness = Math.Max(2 / ProfileViewModel.PanZoomViewModel.Zoom, 1);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShapeEditMouseDown(object sender, MouseButtonEventArgs e)
|
public void ShapeEditMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
@ -351,18 +352,26 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
|
|
||||||
public void TopLeftRotate(object sender, MouseEventArgs e)
|
public void TopLeftRotate(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TopRightRotate(object sender, MouseEventArgs e)
|
public void TopRightRotate(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BottomRightRotate(object sender, MouseEventArgs e)
|
public void BottomRightRotate(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BottomLeftRotate(object sender, MouseEventArgs e)
|
public void BottomLeftRotate(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user