Add toggle button for grid snapping.
This commit is contained in:
@@ -14,6 +14,7 @@ using FlaxEngine.Utilities;
|
|||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
using FlaxEditor.GUI;
|
using FlaxEditor.GUI;
|
||||||
using FlaxEditor.Options;
|
using FlaxEditor.Options;
|
||||||
|
using FlaxEngine.GUI;
|
||||||
|
|
||||||
namespace FlaxEditor.Surface
|
namespace FlaxEditor.Surface
|
||||||
{
|
{
|
||||||
@@ -535,9 +536,10 @@ namespace FlaxEditor.Surface
|
|||||||
return value;
|
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,
|
public static void VisjectCommonToolstripSetup(Editor editor, ToolStrip toolStrip, FlaxEditor.Undo undo,
|
||||||
Action save, Action showWholeGraph, InputActionsContainer actionsContainer,
|
Action save, Action showWholeGraph, Action toggleGridSnap, InputActionsContainer actionsContainer,
|
||||||
out ToolStripButton saveButton, out ToolStripButton undoButton, out ToolStripButton redoButton)
|
out ToolStripButton saveButton, out ToolStripButton undoButton, out ToolStripButton redoButton, out ToolStripButton gridSnapButton)
|
||||||
{
|
{
|
||||||
// Toolstrip
|
// Toolstrip
|
||||||
saveButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Save64, save).LinkTooltip("Save");
|
saveButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Save64, save).LinkTooltip("Save");
|
||||||
@@ -547,11 +549,26 @@ namespace FlaxEditor.Surface
|
|||||||
toolStrip.AddSeparator();
|
toolStrip.AddSeparator();
|
||||||
toolStrip.AddButton(editor.Icons.Search64, editor.ContentFinding.ShowSearch).LinkTooltip("Open content search tool (Ctrl+F)");
|
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");
|
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
|
// Setup input actions
|
||||||
actionsContainer.Add(options => options.Undo, undo.PerformUndo);
|
actionsContainer.Add(options => options.Undo, undo.PerformUndo);
|
||||||
actionsContainer.Add(options => options.Redo, undo.PerformRedo);
|
actionsContainer.Add(options => options.Redo, undo.PerformRedo);
|
||||||
actionsContainer.Add(options => options.Search, editor.ContentFinding.ShowSearch);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -669,6 +669,7 @@ namespace FlaxEditor.Surface
|
|||||||
private readonly ToolStripButton _saveButton;
|
private readonly ToolStripButton _saveButton;
|
||||||
private readonly ToolStripButton _undoButton;
|
private readonly ToolStripButton _undoButton;
|
||||||
private readonly ToolStripButton _redoButton;
|
private readonly ToolStripButton _redoButton;
|
||||||
|
private readonly ToolStripButton _gridSnapButton;
|
||||||
private bool _showWholeGraphOnLoad = true;
|
private bool _showWholeGraphOnLoad = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -772,8 +773,9 @@ namespace FlaxEditor.Surface
|
|||||||
}
|
}
|
||||||
_propertiesEditor.Modified += OnPropertyEdited;
|
_propertiesEditor.Modified += OnPropertyEdited;
|
||||||
|
|
||||||
SurfaceUtils.VisjectCommonToolstripSetup(editor, _toolstrip, _undo, Save, ShowWholeGraph, InputActions,
|
SurfaceUtils.VisjectCommonToolstripSetup(editor, _toolstrip, _undo,
|
||||||
out _saveButton, out _undoButton, out _redoButton);
|
Save, ShowWholeGraph, ToggleGridSnap, InputActions,
|
||||||
|
out _saveButton, out _undoButton, out _redoButton, out _gridSnapButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnUndoRedo(IUndoAction action)
|
private void OnUndoRedo(IUndoAction action)
|
||||||
@@ -812,6 +814,11 @@ namespace FlaxEditor.Surface
|
|||||||
_surface.ShowWholeGraph();
|
_surface.ShowWholeGraph();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ToggleGridSnap()
|
||||||
|
{
|
||||||
|
SurfaceUtils.ToggleSurfaceGridSnap(_surface, _gridSnapButton);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Refreshes temporary asset to see changes live when editing the surface.
|
/// Refreshes temporary asset to see changes live when editing the surface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
private readonly ToolStripButton _saveButton;
|
private readonly ToolStripButton _saveButton;
|
||||||
private readonly ToolStripButton _undoButton;
|
private readonly ToolStripButton _undoButton;
|
||||||
private readonly ToolStripButton _redoButton;
|
private readonly ToolStripButton _redoButton;
|
||||||
|
private readonly ToolStripButton _gridSnapButton;
|
||||||
private bool _showWholeGraphOnLoad = true;
|
private bool _showWholeGraphOnLoad = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -68,8 +69,9 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
_undo.ActionDone += OnUndoRedo;
|
_undo.ActionDone += OnUndoRedo;
|
||||||
|
|
||||||
// Toolstrip
|
// Toolstrip
|
||||||
SurfaceUtils.VisjectCommonToolstripSetup(editor, _toolstrip, _undo, Save, ShowWholeGraph, InputActions,
|
SurfaceUtils.VisjectCommonToolstripSetup(editor, _toolstrip, _undo,
|
||||||
out _saveButton, out _undoButton, out _redoButton);
|
Save, ShowWholeGraph, ToggleGridSnap, InputActions,
|
||||||
|
out _saveButton, out _undoButton, out _redoButton, out _gridSnapButton);
|
||||||
|
|
||||||
// Panel
|
// Panel
|
||||||
_panel = new Panel(ScrollBars.None)
|
_panel = new Panel(ScrollBars.None)
|
||||||
@@ -94,6 +96,11 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
_surface.ShowWholeGraph();
|
_surface.ShowWholeGraph();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ToggleGridSnap()
|
||||||
|
{
|
||||||
|
SurfaceUtils.ToggleSurfaceGridSnap(_surface, _gridSnapButton);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Refreshes temporary asset to see changes live when editing the surface.
|
/// Refreshes temporary asset to see changes live when editing the surface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -533,6 +533,7 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
private readonly ToolStripButton _saveButton;
|
private readonly ToolStripButton _saveButton;
|
||||||
private readonly ToolStripButton _undoButton;
|
private readonly ToolStripButton _undoButton;
|
||||||
private readonly ToolStripButton _redoButton;
|
private readonly ToolStripButton _redoButton;
|
||||||
|
private readonly ToolStripButton _gridSnapButton;
|
||||||
private Control[] _debugToolstripControls;
|
private Control[] _debugToolstripControls;
|
||||||
private bool _showWholeGraphOnLoad = true;
|
private bool _showWholeGraphOnLoad = true;
|
||||||
private bool _tmpAssetIsDirty;
|
private bool _tmpAssetIsDirty;
|
||||||
@@ -596,8 +597,11 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
_propertiesEditor.Select(_properties);
|
_propertiesEditor.Select(_properties);
|
||||||
|
|
||||||
// Toolstrip
|
// Toolstrip
|
||||||
SurfaceUtils.VisjectCommonToolstripSetup(editor, _toolstrip, _undo, Save, ShowWholeGraph, InputActions,
|
SurfaceUtils.VisjectCommonToolstripSetup(editor, _toolstrip, _undo,
|
||||||
out _saveButton, out _undoButton, out _redoButton);
|
Save, ShowWholeGraph, ToggleGridSnap, InputActions,
|
||||||
|
out _saveButton, out _undoButton, out _redoButton, out _gridSnapButton);
|
||||||
|
|
||||||
|
// The rest of the toolstrip
|
||||||
_toolstrip.AddSeparator();
|
_toolstrip.AddSeparator();
|
||||||
_toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/scripting/visual/index.html")).LinkTooltip("See documentation to learn more");
|
_toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/scripting/visual/index.html")).LinkTooltip("See documentation to learn more");
|
||||||
_debugToolstripControls = new[]
|
_debugToolstripControls = new[]
|
||||||
@@ -678,6 +682,11 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
_surface.ShowWholeGraph();
|
_surface.ShowWholeGraph();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ToggleGridSnap()
|
||||||
|
{
|
||||||
|
SurfaceUtils.ToggleSurfaceGridSnap(_surface, _gridSnapButton);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Refreshes temporary asset to see changes live when editing the surface.
|
/// Refreshes temporary asset to see changes live when editing the surface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user