diff --git a/ShareX.HelpersLib/Extensions/Extensions.cs b/ShareX.HelpersLib/Extensions/Extensions.cs index 271a3f19a..19e7ef647 100644 --- a/ShareX.HelpersLib/Extensions/Extensions.cs +++ b/ShareX.HelpersLib/Extensions/Extensions.cs @@ -158,7 +158,12 @@ public static Point Add(this Point point, Point offset) public static Size Offset(this Size size, int offset) { - return new Size(size.Width + offset, size.Height + offset); + return size.Offset(offset, offset); + } + + public static Size Offset(this Size size, int width, int height) + { + return new Size(size.Width + width, size.Height + height); } public static Rectangle Offset(this Rectangle rect, int offset) diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs index b627444f7..f6772ec68 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/TextDrawingShape.cs @@ -93,18 +93,26 @@ private void UpdateText() Manager.ResumeForm(); } - public void SetTextWithAutoSize(string text) + public void SetTextWithAutoSize(string text, bool centerText) { - Point pos = InputManager.MousePosition0Based; - Size size; using (Font font = new Font(TextOptions.Font, TextOptions.Size, TextOptions.Style)) { - size = Helpers.MeasureText(text, font).Offset(30); + size = Helpers.MeasureText(text, font).Offset(10, 20); } - Point location = new Point(pos.X - size.Width / 2, pos.Y - size.Height / 2); + Point location; + + if (centerText) + { + Point pos = InputManager.MousePosition0Based; + location = new Point(pos.X - size.Width / 2, pos.Y - size.Height / 2); + } + else + { + location = Rectangle.Location; + } Rectangle = new Rectangle(location, size); Text = text; diff --git a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs index fd33721f4..bf25a6f72 100644 --- a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs +++ b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs @@ -1714,7 +1714,7 @@ private void PasteFromClipboard() { CurrentShapeType = ShapeType.DrawingText; TextDrawingShape shape = (TextDrawingShape)CreateShape(ShapeType.DrawingText); - shape.SetTextWithAutoSize(text.Trim()); + shape.SetTextWithAutoSize(text.Trim(), true); AddShape(shape); SelectCurrentShape(); }