@@ -58,15 +58,21 @@ impl NodeTree {
58
58
DragDropPayload :: WithNode ( node_id) ,
59
59
on_action,
60
60
|ui| {
61
- ui. label ( "○" ) ;
62
- ui. label ( node_name)
61
+ Self :: node_frame ( ui, app. ui . selected_node == node_id) . show ( ui, |ui| {
62
+ ui. label ( "○" ) ;
63
+ ui. label ( node_name) ;
64
+ } ) ;
63
65
} ,
64
66
) ;
65
67
66
68
let response = ui. interact ( ui. min_rect ( ) , id2, egui:: Sense :: click ( ) ) ;
67
69
if response. clicked ( ) {
68
70
on_action ( GuiAction :: SelectNode { node : node_id } ) ;
69
71
}
72
+
73
+ response. context_menu ( |ui| {
74
+ Self :: context_menu ( app, node, on_action, node_id, ui) ;
75
+ } ) ;
70
76
} ) ;
71
77
} ) ;
72
78
@@ -181,23 +187,6 @@ impl NodeTree {
181
187
}
182
188
}
183
189
184
- response. context_menu ( |ui| {
185
- if ui. button ( "Add child node" ) . clicked ( ) {
186
- on_action ( GuiAction :: AddNode {
187
- parent : node_id,
188
- index : node. children . len ( ) ,
189
- } ) ;
190
- ui. close_menu ( )
191
- }
192
- if ui. button ( "Delete" ) . clicked ( ) {
193
- on_action ( GuiAction :: RemoveNode { node : node_id } ) ;
194
- ui. close_menu ( )
195
- }
196
- for tag in node. tags . iter ( ) {
197
- ui. label ( app. document . tag_name ( * tag) ) ;
198
- }
199
- } ) ;
200
-
201
190
// Check for drags:
202
191
let dnd_response = ui
203
192
. interact ( response. rect . clone ( ) , id, Sense :: drag ( ) )
@@ -207,6 +196,23 @@ impl NodeTree {
207
196
}
208
197
}
209
198
199
+ fn context_menu ( app : & Application , node : & Node , on_action : & mut impl FnMut ( GuiAction ) , node_id : NodeId , ui : & mut Ui ) {
200
+ if ui. button ( "Add child node" ) . clicked ( ) {
201
+ on_action ( GuiAction :: AddNode {
202
+ parent : node_id,
203
+ index : node. children . len ( ) ,
204
+ } ) ;
205
+ ui. close_menu ( )
206
+ }
207
+ if ui. button ( "Delete" ) . clicked ( ) {
208
+ on_action ( GuiAction :: RemoveNode { node : node_id } ) ;
209
+ ui. close_menu ( )
210
+ }
211
+ for tag in node. tags . iter ( ) {
212
+ ui. label ( app. document . tag_name ( * tag) ) ;
213
+ }
214
+ }
215
+
210
216
fn is_ancestor ( & self , app : & Application , node_id : NodeId , assumed_ancestor : NodeId ) -> bool {
211
217
let node = app. document . nodes . get ( node_id) . expect ( "" ) ;
212
218
0 commit comments