Add toggle button for grid snapping.
This commit is contained in:
@@ -14,6 +14,7 @@ using FlaxEngine.Utilities;
|
||||
using FlaxEngine;
|
||||
using FlaxEditor.GUI;
|
||||
using FlaxEditor.Options;
|
||||
using FlaxEngine.GUI;
|
||||
|
||||
namespace FlaxEditor.Surface
|
||||
{
|
||||
@@ -535,9 +536,10 @@ namespace FlaxEditor.Surface
|
||||
return value;
|
||||
}
|
||||
|
||||
// This might not be the greatest place to put this but I couldn't find anything better yet.
|
||||
public static void VisjectCommonToolstripSetup(Editor editor, ToolStrip toolStrip, FlaxEditor.Undo undo,
|
||||
Action save, Action showWholeGraph, InputActionsContainer actionsContainer,
|
||||
out ToolStripButton saveButton, out ToolStripButton undoButton, out ToolStripButton redoButton)
|
||||
Action save, Action showWholeGraph, Action toggleGridSnap, InputActionsContainer actionsContainer,
|
||||
out ToolStripButton saveButton, out ToolStripButton undoButton, out ToolStripButton redoButton, out ToolStripButton gridSnapButton)
|
||||
{
|
||||
// Toolstrip
|
||||
saveButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Save64, save).LinkTooltip("Save");
|
||||
@@ -547,11 +549,26 @@ namespace FlaxEditor.Surface
|
||||
toolStrip.AddSeparator();
|
||||
toolStrip.AddButton(editor.Icons.Search64, editor.ContentFinding.ShowSearch).LinkTooltip("Open content search tool (Ctrl+F)");
|
||||
toolStrip.AddButton(editor.Icons.CenterView64, showWholeGraph).LinkTooltip("Show whole graph");
|
||||
gridSnapButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Stop64, toggleGridSnap).LinkTooltip("Toggle grid snapping for nodes.");
|
||||
gridSnapButton.BackgroundColor = Style.Current.Background; // Default color for grid snap button.
|
||||
|
||||
// Setup input actions
|
||||
actionsContainer.Add(options => options.Undo, undo.PerformUndo);
|
||||
actionsContainer.Add(options => options.Redo, undo.PerformRedo);
|
||||
actionsContainer.Add(options => options.Search, editor.ContentFinding.ShowSearch);
|
||||
}
|
||||
|
||||
public static void ToggleSurfaceGridSnap(VisjectSurface surface, ToolStripButton gridSnapButton)
|
||||
{
|
||||
surface.GridSnappingEnabled = !surface.GridSnappingEnabled;
|
||||
if (surface.GridSnappingEnabled)
|
||||
{
|
||||
gridSnapButton.BackgroundColor = Style.Current.BackgroundSelected;
|
||||
}
|
||||
else
|
||||
{
|
||||
gridSnapButton.BackgroundColor = Style.Current.Background;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user