Add don't auto-closing View -> View Flags menu to improve debug testing workflow in Editor viewport

This commit is contained in:
Wojtek Figat
2022-07-23 10:51:38 +02:00
parent 1633d8ebb6
commit 37fbc7600e
2 changed files with 16 additions and 5 deletions

View File

@@ -50,6 +50,11 @@ namespace FlaxEditor.GUI.ContextMenu
/// </summary>
public bool AutoCheck;
/// <summary>
/// Closes the context menu after clicking the button, otherwise menu will stay open.
/// </summary>
public bool CloseMenuOnClick = true;
/// <summary>
/// Initializes a new instance of the <see cref="ContextMenuButton"/> class.
/// </summary>
@@ -90,14 +95,15 @@ namespace FlaxEditor.GUI.ContextMenu
/// </summary>
public void Click()
{
// Close topmost context menu
ParentContextMenu?.TopmostCM.Hide();
if (CloseMenuOnClick)
{
// Close topmost context menu
ParentContextMenu?.TopmostCM.Hide();
}
// Auto check logic
if (AutoCheck)
{
Checked = !Checked;
}
// Fire event
Clicked?.Invoke();

View File

@@ -491,12 +491,17 @@ namespace FlaxEditor.Viewport
{
var v = EditorViewportViewFlagsValues[i];
var button = viewFlags.AddButton(v.Name);
button.CloseMenuOnClick = false;
button.Tag = v.Mode;
}
viewFlags.ButtonClicked += button =>
{
if (button.Tag != null)
Task.ViewFlags ^= (ViewFlags)button.Tag;
{
var v = (ViewFlags)button.Tag;
Task.ViewFlags ^= v;
button.Icon = (Task.View.Flags & v) != 0 ? Style.Current.CheckBoxTick : SpriteHandle.Invalid;
}
};
viewFlags.VisibleChanged += WidgetViewFlagsShowHide;
}