mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Propagate DPI Changes down to Drawable Containers and Adorners and Resize Grippers Accordingly (#200)
* Propagate DPI Changes down to Drawable Containers and Adorners and Resize Grippers Accordingly * Make Grippers Slightly Larger * Add White Border to Grippers for Better Contrast on Dark Backgrounds
This commit is contained in:
parent
926855cd70
commit
f159a871ca
10 changed files with 185 additions and 128 deletions
|
@ -22,6 +22,7 @@
|
|||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
using GreenshotPlugin.Core;
|
||||
using GreenshotPlugin.Interfaces.Drawing;
|
||||
using GreenshotPlugin.Interfaces.Drawing.Adorners;
|
||||
|
||||
|
@ -31,7 +32,8 @@ namespace Greenshot.Drawing.Adorners
|
|||
{
|
||||
public virtual EditStatus EditStatus { get; protected set; } = EditStatus.IDLE;
|
||||
|
||||
protected Size _size = new Size(4, 4);
|
||||
private static readonly Size defaultSize = new Size(6, 6);
|
||||
protected Size _size = defaultSize;
|
||||
|
||||
public AbstractAdorner(IDrawableContainer owner)
|
||||
{
|
||||
|
@ -139,6 +141,15 @@ namespace Greenshot.Drawing.Adorners
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjust UI elements to the supplied DPI settings
|
||||
/// </summary>
|
||||
/// <param name="dpi"></param>
|
||||
public void AdjustToDpi(uint dpi)
|
||||
{
|
||||
_size = DpiHelper.ScaleWithDpi(defaultSize, dpi);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw the adorner
|
||||
/// </summary>
|
||||
|
|
|
@ -145,14 +145,12 @@ namespace Greenshot.Drawing.Adorners
|
|||
var bounds = BoundsOnSurface;
|
||||
GraphicsState state = targetGraphics.Save();
|
||||
|
||||
targetGraphics.SmoothingMode = SmoothingMode.None;
|
||||
targetGraphics.CompositingMode = CompositingMode.SourceCopy;
|
||||
targetGraphics.PixelOffsetMode = PixelOffsetMode.Half;
|
||||
targetGraphics.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
|
||||
try
|
||||
{
|
||||
targetGraphics.FillRectangle(Brushes.Black, bounds.X, bounds.Y, bounds.Width, bounds.Height);
|
||||
targetGraphics.FillRectangle(Brushes.Black, bounds);
|
||||
targetGraphics.DrawRectangle(new Pen(Brushes.White), bounds);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
@ -172,12 +172,10 @@ namespace Greenshot.Drawing.Adorners
|
|||
var bounds = BoundsOnSurface;
|
||||
GraphicsState state = targetGraphics.Save();
|
||||
|
||||
targetGraphics.SmoothingMode = SmoothingMode.None;
|
||||
targetGraphics.CompositingMode = CompositingMode.SourceCopy;
|
||||
targetGraphics.PixelOffsetMode = PixelOffsetMode.Half;
|
||||
targetGraphics.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
|
||||
targetGraphics.FillRectangle(Brushes.Black, bounds.X, bounds.Y, bounds.Width , bounds.Height);
|
||||
targetGraphics.FillRectangle(Brushes.Black, bounds);
|
||||
targetGraphics.DrawRectangle(new Pen(Brushes.White), bounds);
|
||||
targetGraphics.Restore(state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,8 @@ namespace Greenshot.Drawing.Adorners
|
|||
Graphics targetGraphics = paintEventArgs.Graphics;
|
||||
|
||||
var bounds = BoundsOnSurface;
|
||||
targetGraphics.FillRectangle(Brushes.Green, bounds.X, bounds.Y, bounds.Width, bounds.Height);
|
||||
targetGraphics.FillRectangle(Brushes.Green, bounds);
|
||||
targetGraphics.DrawRectangle(new Pen(Brushes.White), bounds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -369,6 +369,18 @@ namespace Greenshot.Drawing
|
|||
Draw(graphics, renderMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjust UI elements to the supplied DPI settings
|
||||
/// </summary>
|
||||
/// <param name="dpi"></param>
|
||||
public void AdjustToDpi(uint dpi)
|
||||
{
|
||||
foreach(var adorner in Adorners)
|
||||
{
|
||||
adorner.AdjustToDpi(dpi);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool Contains(int x, int y) {
|
||||
return Bounds.Contains(x , y);
|
||||
}
|
||||
|
|
|
@ -604,5 +604,16 @@ namespace Greenshot.Drawing {
|
|||
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjust UI elements to the supplied DPI settings
|
||||
/// </summary>
|
||||
/// <param name="dpi"></param>
|
||||
public void AdjustToDpi(uint dpi)
|
||||
{
|
||||
foreach (var drawableContainer in this) {
|
||||
drawableContainer.AdjustToDpi(dpi);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -432,6 +432,17 @@ namespace Greenshot.Drawing
|
|||
/// </summary>
|
||||
public ICaptureDetails CaptureDetails { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Adjust UI elements to the supplied DPI settings
|
||||
/// </summary>
|
||||
/// <param name="dpi"></param>
|
||||
public void AdjustToDpi(uint dpi)
|
||||
{
|
||||
foreach (var element in this._elements) {
|
||||
element.AdjustToDpi(dpi);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base Surface constructor
|
||||
/// </summary>
|
||||
|
|
|
@ -101,6 +101,8 @@ namespace Greenshot {
|
|||
destinationsToolStrip.ImageScalingSize = newSize;
|
||||
propertiesToolStrip.ImageScalingSize = newSize;
|
||||
propertiesToolStrip.MinimumSize = new Size(150, newSize.Height + 10);
|
||||
|
||||
_surface.AdjustToDpi(dpi);
|
||||
}
|
||||
|
||||
public ImageEditorForm(ISurface iSurface, bool outputMade)
|
||||
|
|
|
@ -87,5 +87,11 @@ namespace GreenshotPlugin.Interfaces.Drawing.Adorners
|
|||
/// </summary>
|
||||
/// <param name="matrix">Matrix</param>
|
||||
void Transform(Matrix matrix);
|
||||
|
||||
/// <summary>
|
||||
/// Adjust UI elements to the supplied DPI settings
|
||||
/// </summary>
|
||||
/// <param name="dpi"></param>
|
||||
void AdjustToDpi(uint dpi);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,6 +120,12 @@ namespace GreenshotPlugin.Interfaces.Drawing
|
|||
/// Available adorners for the DrawableContainer
|
||||
/// </summary>
|
||||
IList<IAdorner> Adorners { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Adjust UI elements to the supplied DPI settings
|
||||
/// </summary>
|
||||
/// <param name="dpi"></param>
|
||||
void AdjustToDpi(uint dpi);
|
||||
}
|
||||
|
||||
public interface IDrawableContainerList : IList<IDrawableContainer>, IDisposable
|
||||
|
@ -167,6 +173,7 @@ namespace GreenshotPlugin.Interfaces.Drawing
|
|||
void PushElementsToBottom(IDrawableContainerList elements);
|
||||
void ShowContextMenu(MouseEventArgs e, ISurface surface);
|
||||
void HandleFieldChangedEvent(object sender, FieldChangedEventArgs e);
|
||||
void AdjustToDpi(uint dpi);
|
||||
}
|
||||
|
||||
public interface ITextContainer : IDrawableContainer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue