Browse Source

open picker with space wip

Krzysztof Krysiński 2 months ago
parent
commit
6a74632b40

+ 1 - 1
src/PixiEditor/Styles/Templates/NodeGraphView.axaml

@@ -12,7 +12,7 @@
                                IsVisible="False" ZIndex="100"
                                Fill="{DynamicResource SelectionFillBrush}" Opacity="1" />
                     <Grid.ContextFlyout>
-                        <Flyout>
+                        <Flyout Placement="Pointer" IsOpen="{Binding IsMenuOpen, RelativeSource={RelativeSource FindAncestor, AncestorType=nodes:NodeGraphView}, Mode=TwoWay}">
                             <nodes:NodePicker
                                 AllNodeTypeInfos="{Binding AllNodeTypeInfos, RelativeSource={RelativeSource TemplatedParent}}"
                                 SearchQuery="{Binding SearchQuery, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"

+ 16 - 0
src/PixiEditor/Views/Nodes/NodeGraphView.cs

@@ -182,6 +182,12 @@ internal class NodeGraphView : Zoombox.Zoombox
         set { SetValue(ActiveFrameProperty, value); }
     }
 
+    public bool IsMenuOpen
+    {
+        get { return (bool)GetValue(IsMenuOpenProperty); }
+        set { SetValue(IsMenuOpenProperty, value); }
+    }
+
     private bool isDraggingNodes;
     private bool isDraggingConnection;
     private VecD clickPointOffset;
@@ -208,6 +214,7 @@ internal class NodeGraphView : Zoombox.Zoombox
     private List<Control> nodeViewsCache = new();
 
     private bool isSelecting;
+    public static readonly StyledProperty<bool> IsMenuOpenProperty = AvaloniaProperty.Register<NodeGraphView, bool>("IsMenuOpen");
 
     public static readonly StyledProperty<int> ActiveFrameProperty =
         AvaloniaProperty.Register<NodeGraphView, int>("ActiveFrame");
@@ -255,6 +262,15 @@ internal class NodeGraphView : Zoombox.Zoombox
         }
     }
 
+    protected override void OnKeyDown(KeyEventArgs e)
+    {
+        base.OnKeyDown(e);
+        if (e.Key == Key.Space)
+        {
+            IsMenuOpen = true;
+        }
+    }
+
     private void NodeItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
     {
         if (e.Action == NotifyCollectionChangedAction.Add)