BUG-2300: A small fix for the undo/redo issue in the editor, where the moves are not merged.

This commit is contained in:
Robin 2018-06-19 10:33:57 +02:00
commit 18c41080a6
2 changed files with 16 additions and 11 deletions

View file

@ -42,7 +42,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Adorners
{ {
private NativeRectFloat _boundsAfterResize = NativeRectFloat.Empty; private NativeRectFloat _boundsAfterResize = NativeRectFloat.Empty;
private NativeRectFloat _boundsBeforeResize = NativeRectFloat.Empty; private NativeRectFloat _boundsBeforeResize = NativeRectFloat.Empty;
private bool _initialMoveAfterMouseDown = true;
public MoveAdorner(IDrawableContainer owner, Positions position) : base(owner) public MoveAdorner(IDrawableContainer owner, Positions position) : base(owner)
{ {
Position = position; Position = position;
@ -112,6 +112,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Adorners
EditStatus = EditStatus.RESIZING; EditStatus = EditStatus.RESIZING;
_boundsBeforeResize = new NativeRectFloat(Owner.Left, Owner.Top, Owner.Width, Owner.Height); _boundsBeforeResize = new NativeRectFloat(Owner.Left, Owner.Top, Owner.Width, Owner.Height);
_boundsAfterResize = _boundsBeforeResize; _boundsAfterResize = _boundsBeforeResize;
_initialMoveAfterMouseDown = true;
} }
/// <summary> /// <summary>
@ -126,10 +128,12 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Adorners
return; return;
} }
Owner.Invalidate(); 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 // reset "workbench" rectangle to current bounds
_boundsAfterResize = _boundsBeforeResize; _boundsAfterResize = _boundsBeforeResize;
// calculate scaled rectangle // calculate scaled rectangle
ScaleHelper.Scale(ref _boundsAfterResize, Position, new NativePointFloat(mouseEventArgs.X, mouseEventArgs.Y), ScaleHelper.GetScaleOptions()); ScaleHelper.Scale(ref _boundsAfterResize, Position, new NativePointFloat(mouseEventArgs.X, mouseEventArgs.Y), ScaleHelper.GetScaleOptions());

View file

@ -66,14 +66,15 @@ namespace Greenshot.Addon.LegacyEditor.Memento
public bool Merge(IMemento otherMemento) public bool Merge(IMemento otherMemento)
{ {
var other = otherMemento as DrawableContainerBoundsChangeMemento; if (!(otherMemento is DrawableContainerBoundsChangeMemento other))
if (other != null)
{ {
if (ObjectExtensions.CompareLists(_listOfdrawableContainer, other._listOfdrawableContainer)) return false;
{ }
// Lists are equal, as we have the state already we can ignore the new memento
return true; 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; return false;
} }