mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-04 12:14:45 +13:00
commit
ec88a67703
1 changed files with 11 additions and 10 deletions
|
@ -78,7 +78,7 @@ public Color CurrentColor
|
|||
|
||||
public SimpleWindowInfo SelectedWindow { get; private set; }
|
||||
|
||||
public Vector2 CanvasCenterPoint { get; set; } = new Vector2(0.5f, 0.5f);
|
||||
public Vector2 CanvasCenterOffset { get; set; } = new Vector2(0f, 0f);
|
||||
|
||||
internal ShapeManager ShapeManager { get; private set; }
|
||||
internal List<DrawableObject> DrawableObjects { get; private set; }
|
||||
|
@ -372,12 +372,12 @@ private void Pan(Point delta)
|
|||
Pan(delta.X, delta.Y);
|
||||
}
|
||||
|
||||
private void AutomaticPan(Vector2 center)
|
||||
private void AutomaticPan(Vector2 centerOffset)
|
||||
{
|
||||
if (IsEditorMode)
|
||||
{
|
||||
int x = (int)Math.Round(ClientArea.Width * center.X);
|
||||
int y = (int)Math.Round(ToolbarHeight + (ClientArea.Height - ToolbarHeight) * center.Y);
|
||||
int x = (int)Math.Round(ClientArea.Width * 0.5f + centerOffset.X);
|
||||
int y = (int)Math.Round(ToolbarHeight + (ClientArea.Height - ToolbarHeight) * 0.5f + centerOffset.Y);
|
||||
int newX = x - CanvasRectangle.Width / 2;
|
||||
int newY = y - CanvasRectangle.Height / 2;
|
||||
int deltaX = newX - CanvasRectangle.X;
|
||||
|
@ -388,18 +388,19 @@ private void AutomaticPan(Vector2 center)
|
|||
|
||||
private void AutomaticPan()
|
||||
{
|
||||
AutomaticPan(CanvasCenterPoint);
|
||||
AutomaticPan(CanvasCenterOffset);
|
||||
}
|
||||
|
||||
private void UpdateCenterPoint()
|
||||
private void UpdateCenterOffset()
|
||||
{
|
||||
CanvasCenterPoint = new Vector2((CanvasRectangle.X + CanvasRectangle.Width / 2f) / ClientArea.Width,
|
||||
(CanvasRectangle.Y + CanvasRectangle.Height / 2f) / ClientArea.Height);
|
||||
CanvasCenterOffset = new Vector2(
|
||||
(CanvasRectangle.X + CanvasRectangle.Width / 2f) - ClientArea.Width / 2f,
|
||||
(CanvasRectangle.Y + CanvasRectangle.Height / 2f) - ClientArea.Height / 2f);
|
||||
}
|
||||
|
||||
public void CenterCanvas()
|
||||
{
|
||||
CanvasCenterPoint = new Vector2(0.5f, 0.5f);
|
||||
CanvasCenterOffset = new Vector2(0f, 0f);
|
||||
AutomaticPan();
|
||||
}
|
||||
|
||||
|
@ -621,7 +622,7 @@ private void UpdateCoordinates()
|
|||
if (ShapeManager.IsPanning)
|
||||
{
|
||||
Pan(InputManager.MouseVelocity);
|
||||
UpdateCenterPoint();
|
||||
UpdateCenterOffset();
|
||||
}
|
||||
|
||||
borderDotPen.DashOffset = (float)timerStart.Elapsed.TotalSeconds * -15;
|
||||
|
|
Loading…
Reference in a new issue