From 9acee407469f45c474dcfee0eb7a8d3a38489326 Mon Sep 17 00:00:00 2001 From: Nils Hausfeld Date: Thu, 28 Sep 2023 20:53:47 +0200 Subject: [PATCH] - Added context sensitive toggle gui --- .../Editor/Surface/ContextMenu/VisjectCM.cs | 45 +++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/Source/Editor/Surface/ContextMenu/VisjectCM.cs b/Source/Editor/Surface/ContextMenu/VisjectCM.cs index 04130fc1e..0d4a35e51 100644 --- a/Source/Editor/Surface/ContextMenu/VisjectCM.cs +++ b/Source/Editor/Surface/ContextMenu/VisjectCM.cs @@ -40,6 +40,8 @@ namespace FlaxEditor.Surface.ContextMenu public delegate List ParameterGetterDelegate(); private readonly List _groups = new List(16); + private CheckBox _contextSensitiveToggle; + private bool _contextSensitiveSearchEnabled = true; private readonly TextBox _searchBox; private bool _waitingForInput; private VisjectCMGroup _surfaceParametersGroup; @@ -127,7 +129,7 @@ namespace FlaxEditor.Surface.ContextMenu _parameterSetNodeArchetype = info.ParameterSetNodeArchetype ?? Archetypes.Parameters.Nodes[3]; // Context menu dimensions - Size = new Float2(320, 248); + Size = new Float2(300, 400); var headerPanel = new Panel(ScrollBars.None) { @@ -139,17 +141,40 @@ namespace FlaxEditor.Surface.ContextMenu }; // Title bar + var titleFontReference = new FontReference(Style.Current.FontLarge.Asset, 10); var titleLabel = new Label { - Width = Width - 8, + Width = Width * 0.5f - 8f, Height = 20, X = 4, Parent = headerPanel, Text = "Select Node", - HorizontalAlignment = TextAlignment.Center, - Font = new FontReference(Style.Current.FontLarge.Asset, 10), + HorizontalAlignment = TextAlignment.Near, + Font = titleFontReference, }; + // Context sensitive toggle + var contextSensitiveLabel = new Label + { + Width = Width * 0.5f - 28, + Height = 20, + X = Width * 0.5f, + Parent = headerPanel, + Text = "Context Sensitive", + HorizontalAlignment = TextAlignment.Far, + Font = titleFontReference, + }; + + _contextSensitiveToggle = new CheckBox + { + Width = 20, + Height = 20, + X = Width - 24, + Parent = headerPanel, + Checked = _contextSensitiveSearchEnabled, + }; + _contextSensitiveToggle.StateChanged += OnContextSensitiveToggleStateChanged; + // Search box _searchBox = new SearchBox(false, 2, 22) { @@ -251,6 +276,11 @@ namespace FlaxEditor.Surface.ContextMenu } } + private void OnContextSensitiveToggleStateChanged(CheckBox checkBox) + { + _contextSensitiveSearchEnabled = checkBox.Checked; + } + /// /// Adds the group archetype to add to the menu. /// @@ -768,5 +798,12 @@ namespace FlaxEditor.Surface.ContextMenu { return GetPreviousSiblings(item).OfType(); } + + /// + public override void OnDestroy() + { + _contextSensitiveToggle.StateChanged -= OnContextSensitiveToggleStateChanged; + base.OnDestroy(); + } } }