mirror of
https://github.com/greenshot/greenshot
synced 2025-07-30 11:40:40 -07:00
Fixed two issues with the adorner resize, sometime the initial value wasn't set and also there were some drawing artifacts. Still needs testing though.
This commit is contained in:
parent
f159a871ca
commit
63a9df5844
5 changed files with 42 additions and 35 deletions
|
@ -32,11 +32,12 @@ namespace Greenshot.Drawing.Adorners
|
|||
{
|
||||
public virtual EditStatus EditStatus { get; protected set; } = EditStatus.IDLE;
|
||||
|
||||
private static readonly Size defaultSize = new Size(6, 6);
|
||||
protected Size _size = defaultSize;
|
||||
private static readonly Size DefaultSize = new Size(6, 6);
|
||||
protected Size _size;
|
||||
|
||||
public AbstractAdorner(IDrawableContainer owner)
|
||||
{
|
||||
_size = DpiHelper.ScaleWithDpi(DefaultSize, 0);
|
||||
Owner = owner;
|
||||
}
|
||||
|
||||
|
@ -144,10 +145,10 @@ namespace Greenshot.Drawing.Adorners
|
|||
/// <summary>
|
||||
/// Adjust UI elements to the supplied DPI settings
|
||||
/// </summary>
|
||||
/// <param name="dpi"></param>
|
||||
/// <param name="dpi">uint</param>
|
||||
public void AdjustToDpi(uint dpi)
|
||||
{
|
||||
_size = DpiHelper.ScaleWithDpi(defaultSize, dpi);
|
||||
_size = DpiHelper.ScaleWithDpi(DefaultSize, dpi);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -32,6 +32,7 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using GreenshotPlugin.IniFile;
|
||||
using GreenshotPlugin.Interfaces;
|
||||
|
@ -205,9 +206,7 @@ namespace Greenshot.Drawing
|
|||
}
|
||||
|
||||
public Size Size {
|
||||
get {
|
||||
return new Size(width, height);
|
||||
}
|
||||
get => new Size(width, height);
|
||||
set {
|
||||
width = value.Width;
|
||||
height = value.Height;
|
||||
|
@ -219,13 +218,7 @@ namespace Greenshot.Drawing
|
|||
/// </summary>
|
||||
[NonSerialized]
|
||||
private IList<IAdorner> _adorners = new List<IAdorner>();
|
||||
public IList<IAdorner> Adorners
|
||||
{
|
||||
get
|
||||
{
|
||||
return _adorners;
|
||||
}
|
||||
}
|
||||
public IList<IAdorner> Adorners => _adorners;
|
||||
|
||||
[NonSerialized]
|
||||
// will store current bounds of this DrawableContainer before starting a resize
|
||||
|
@ -236,7 +229,7 @@ namespace Greenshot.Drawing
|
|||
protected RectangleF _boundsAfterResize = RectangleF.Empty;
|
||||
|
||||
public Rectangle Bounds {
|
||||
get { return GuiRectangle.GetGuiRectangle(Left, Top, Width, Height); }
|
||||
get => GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
|
||||
set {
|
||||
Left = Round(value.Left);
|
||||
Top = Round(value.Top);
|
||||
|
@ -279,8 +272,12 @@ namespace Greenshot.Drawing
|
|||
return new Rectangle(Point.Empty, _parent.Image.Size);
|
||||
}
|
||||
}
|
||||
// Take a base safetymargin
|
||||
// Take a base safety margin
|
||||
int lineThickness = 5;
|
||||
|
||||
// add adorner size
|
||||
lineThickness += Adorners.Max(adorner => Math.Max(adorner.Bounds.Width, adorner.Bounds.Height));
|
||||
|
||||
if (HasField(FieldType.LINE_THICKNESS)) {
|
||||
lineThickness += GetFieldValueAsInt(FieldType.LINE_THICKNESS);
|
||||
}
|
||||
|
@ -372,7 +369,7 @@ namespace Greenshot.Drawing
|
|||
/// <summary>
|
||||
/// Adjust UI elements to the supplied DPI settings
|
||||
/// </summary>
|
||||
/// <param name="dpi"></param>
|
||||
/// <param name="dpi">uint with dpi value</param>
|
||||
public void AdjustToDpi(uint dpi)
|
||||
{
|
||||
foreach(var adorner in Adorners)
|
||||
|
|
|
@ -35,6 +35,10 @@ namespace GreenshotPlugin.Core
|
|||
/// <returns>double</returns>
|
||||
public static float DpiScaleFactor(uint dpi)
|
||||
{
|
||||
if (dpi == 0)
|
||||
{
|
||||
dpi = Dpi;
|
||||
}
|
||||
return (float)dpi / DefaultScreenDpi;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,11 @@ namespace GreenshotPlugin.Interfaces.Drawing.Adorners
|
|||
/// </summary>
|
||||
bool IsActive { get; }
|
||||
|
||||
/// <summary>
|
||||
/// These are the bounds of the adorner
|
||||
/// </summary>
|
||||
Rectangle Bounds { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The current edit status, this is needed to locate the adorner to send events to
|
||||
/// </summary>
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace GreenshotPlugin.Interfaces.Drawing
|
|||
/// <summary>
|
||||
/// Adjust UI elements to the supplied DPI settings
|
||||
/// </summary>
|
||||
/// <param name="dpi"></param>
|
||||
/// <param name="dpi">uint</param>
|
||||
void AdjustToDpi(uint dpi);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue