Partial work

This commit is contained in:
Nathan Brown 2022-08-28 20:40:25 -07:00
commit 2d0d158d22
3 changed files with 31 additions and 19 deletions

View file

@ -163,6 +163,7 @@ namespace Greenshot.Base.Interfaces
void SendMessageEvent(object source, SurfaceMessageTyp messageType, string message); void SendMessageEvent(object source, SurfaceMessageTyp messageType, string message);
void ResizeCanvas(int left, int right, int top, int bottom); void ResizeCanvas(int left, int right, int top, int bottom);
void RecordElementMoved();
void ApplyBitmapEffect(IEffect effect); void ApplyBitmapEffect(IEffect effect);
void RemoveCursor(); void RemoveCursor();
bool HasCursor { get; } bool HasCursor { get; }

View file

@ -598,53 +598,50 @@ namespace Greenshot.Editor.Drawing
}; };
menu.Items.Add(item); menu.Items.Add(item);
ToolStripMenuItem alignSubmenu = new ToolStripMenuItem("Align/Stack"); // Push out
ToolStripMenuItem alignSubmenu = new ToolStripMenuItem("Push Out");
// Align // Right
item = new ToolStripMenuItem("Align Right") item = new ToolStripMenuItem("Right")
{ {
Image = (Image)EditorFormResources.GetObject("removeObjectToolStripMenuItem.Image") Image = (Image)EditorFormResources.GetObject("copyToolStripMenuItem.Image")
}; };
// Action to perform on click.
item.Click += delegate item.Click += delegate
{ {
AlignOrStack("right", surface, this[0], this); PushOut("right", surface, this[0], this);
}; };
alignSubmenu.DropDownItems.Add(item); alignSubmenu.DropDownItems.Add(item);
// Left // Left
item = new ToolStripMenuItem("Align Left") item = new ToolStripMenuItem("Left")
{ {
Image = (Image)EditorFormResources.GetObject("removeObjectToolStripMenuItem.Image") Image = (Image)EditorFormResources.GetObject("copyToolStripMenuItem.Image")
}; };
// Action to perform on click.
item.Click += delegate item.Click += delegate
{ {
AlignOrStack("left", surface, this[0], this); PushOut("left", surface, this[0], this);
}; };
alignSubmenu.DropDownItems.Add(item); alignSubmenu.DropDownItems.Add(item);
// Top // Top
item = new ToolStripMenuItem("Stack on Top") item = new ToolStripMenuItem("Top")
{ {
Image = (Image)EditorFormResources.GetObject("removeObjectToolStripMenuItem.Image") Image = (Image)EditorFormResources.GetObject("copyToolStripMenuItem.Image")
}; };
// Action to perform on click.
item.Click += delegate item.Click += delegate
{ {
AlignOrStack("top", surface, this[0], this); PushOut("top", surface, this[0], this);
}; };
alignSubmenu.DropDownItems.Add(item); alignSubmenu.DropDownItems.Add(item);
// Bottom // Bottom
item = new ToolStripMenuItem("Stack on Bottom") item = new ToolStripMenuItem("Bottom")
{ {
Image = (Image)EditorFormResources.GetObject("removeObjectToolStripMenuItem.Image") Image = (Image)EditorFormResources.GetObject("copyToolStripMenuItem.Image")
}; };
// Action to perform on click.
item.Click += delegate item.Click += delegate
{ {
AlignOrStack("bottom", surface, this[0], this); PushOut("bottom", surface, this[0], this);
}; };
alignSubmenu.DropDownItems.Add(item); alignSubmenu.DropDownItems.Add(item);
menu.Items.Add(alignSubmenu); menu.Items.Add(alignSubmenu);
@ -661,9 +658,11 @@ namespace Greenshot.Editor.Drawing
{ {
foreach (var item in this) foreach (var item in this)
{ {
MakeBoundsChangeUndoable(false);
item.Width = surface.Image.Width; item.Width = surface.Image.Width;
} }
SnapAllToEdge("left", surface, this); SnapAllToEdge("left", surface, this);
surface.Invalidate(); // not sure if this belongs
}; };
fitSubmenu.DropDownItems.Add(item); fitSubmenu.DropDownItems.Add(item);
@ -676,9 +675,11 @@ namespace Greenshot.Editor.Drawing
{ {
foreach (var item in this) foreach (var item in this)
{ {
MakeBoundsChangeUndoable(false);
item.Height = surface.Image.Height; item.Height = surface.Image.Height;
} }
SnapAllToEdge("top", surface, this); SnapAllToEdge("top", surface, this);
surface.Invalidate(); // not sure if this belongs
}; };
fitSubmenu.DropDownItems.Add(item); fitSubmenu.DropDownItems.Add(item);
menu.Items.Add(fitSubmenu); menu.Items.Add(fitSubmenu);
@ -868,6 +869,7 @@ namespace Greenshot.Editor.Drawing
yMovement = -target.Location.Y; yMovement = -target.Location.Y;
else if (direction == "bottom") else if (direction == "bottom")
yMovement = surface.Image.Height - target.Location.Y - target.Height; yMovement = surface.Image.Height - target.Location.Y - target.Height;
target.MakeBoundsChangeUndoable(false);
target.MoveBy(xMovement, yMovement); target.MoveBy(xMovement, yMovement);
} }
@ -880,7 +882,7 @@ namespace Greenshot.Editor.Drawing
surface.DeselectAllElements(); surface.DeselectAllElements();
} }
public void AlignOrStack(string direction, ISurface surface, IDrawableContainer target, IDrawableContainerList parent) public void PushOut(string direction, ISurface surface, IDrawableContainer target, IDrawableContainerList parent)
{ {
// Make calculations // Make calculations
int left = 0, right = 0, top = 0, bottom = 0; int left = 0, right = 0, top = 0, bottom = 0;

View file

@ -1433,6 +1433,15 @@ namespace Greenshot.Editor.Drawing
} }
} }
public void RecordElementMoved()
{
if (!_isSurfaceMoveMadeUndoable)
{
_isSurfaceMoveMadeUndoable = true;
selectedElements.MakeBoundsChangeUndoable(false);
}
}
/// <summary> /// <summary>
/// This event handler is called when the surface is double clicked. /// This event handler is called when the surface is double clicked.
/// </summary> /// </summary>