mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 22:34:27 -07:00
BUG-2300: A small fix for the undo/redo issue in the editor, where the moves are not merged.
This commit is contained in:
parent
5921cb77da
commit
18c41080a6
2 changed files with 16 additions and 11 deletions
|
@ -42,7 +42,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Adorners
|
|||
{
|
||||
private NativeRectFloat _boundsAfterResize = NativeRectFloat.Empty;
|
||||
private NativeRectFloat _boundsBeforeResize = NativeRectFloat.Empty;
|
||||
|
||||
private bool _initialMoveAfterMouseDown = true;
|
||||
public MoveAdorner(IDrawableContainer owner, Positions position) : base(owner)
|
||||
{
|
||||
Position = position;
|
||||
|
@ -112,6 +112,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Adorners
|
|||
EditStatus = EditStatus.RESIZING;
|
||||
_boundsBeforeResize = new NativeRectFloat(Owner.Left, Owner.Top, Owner.Width, Owner.Height);
|
||||
_boundsAfterResize = _boundsBeforeResize;
|
||||
_initialMoveAfterMouseDown = true;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -126,10 +128,12 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Adorners
|
|||
return;
|
||||
}
|
||||
Owner.Invalidate();
|
||||
Owner.MakeBoundsChangeUndoable(false);
|
||||
// Make merges in this drag, meaning as long as it's not the initial move we merge
|
||||
Owner.MakeBoundsChangeUndoable(!_initialMoveAfterMouseDown);
|
||||
_initialMoveAfterMouseDown = false;
|
||||
|
||||
// reset "workbench" rectangle to current bounds
|
||||
_boundsAfterResize = _boundsBeforeResize;
|
||||
// reset "workbench" rectangle to current bounds
|
||||
_boundsAfterResize = _boundsBeforeResize;
|
||||
|
||||
// calculate scaled rectangle
|
||||
ScaleHelper.Scale(ref _boundsAfterResize, Position, new NativePointFloat(mouseEventArgs.X, mouseEventArgs.Y), ScaleHelper.GetScaleOptions());
|
||||
|
|
|
@ -66,14 +66,15 @@ namespace Greenshot.Addon.LegacyEditor.Memento
|
|||
|
||||
public bool Merge(IMemento otherMemento)
|
||||
{
|
||||
var other = otherMemento as DrawableContainerBoundsChangeMemento;
|
||||
if (other != null)
|
||||
if (!(otherMemento is DrawableContainerBoundsChangeMemento other))
|
||||
{
|
||||
if (ObjectExtensions.CompareLists(_listOfdrawableContainer, other._listOfdrawableContainer))
|
||||
{
|
||||
// Lists are equal, as we have the state already we can ignore the new memento
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ObjectExtensions.CompareLists(_listOfdrawableContainer, other._listOfdrawableContainer))
|
||||
{
|
||||
// Lists are equal, as we have the state already we can ignore the new memento
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue