MCPcopy Create free account
hub / github.com/PerroEngine/Perro / click_scene_node_slot

Function click_scene_node_slot

perro_editor/res/scripts/scene/editor_nodes.rs:123–197  ·  view source on GitHub ↗
(
    ctx: &mut ScriptContext<'_, API>,
    idx: usize,
)

Source from the content-addressed store, hash-verified

121}
122
123pub fn click_scene_node_slot<API: ScriptAPI + ?Sized>(
124 ctx: &mut ScriptContext<'_, API>,
125 idx: usize,
126) {
127 let Some(key) = with_state!(ctx.run, EditorState, ctx.id, |state| {
128 if state.doc_text.is_empty() {
129 None
130 } else {
131 let doc = cached_scene_doc_shared(&state.doc_text);
132 scene_tree_view(
133 &doc,
134 state.selected_key,
135 &state.scene_filter,
136 &state.collapsed_scene_keys,
137 )
138 .keys
139 .get(idx)
140 .copied()
141 }
142 }).unwrap_or_default() else {
143 return;
144 };
145
146 let was_selected = with_state!(ctx.run, EditorState, ctx.id, |state| {
147 state.selected_key == Some(key)
148 }).unwrap_or_default();
149 let should_toggle = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
150 let frame = state.file_watch_frame;
151 let should_toggle = state
152 .last_scene_row_click_slot
153 .is_some_and(|prev| prev == idx)
154 && frame.wrapping_sub(state.last_scene_row_click_frame) <= LIST_DOUBLE_CLICK_FRAMES;
155 state.last_scene_row_click_slot = Some(idx);
156 state.last_scene_row_click_frame = frame;
157 should_toggle || was_selected
158 })
159 .unwrap_or(false);
160
161 select_node_slot(ctx, idx);
162 crate::scripts::scene::editor_animation::follow_player_selection(ctx);
163
164 if !should_toggle {
165 return;
166 }
167
168 let has_children = with_state!(ctx.run, EditorState, ctx.id, |state| {
169 if state.doc_text.is_empty() {
170 false
171 } else {
172 let doc = cached_scene_doc_shared(&state.doc_text);
173 scene_child_count(&doc, key) > 0
174 }
175 }).unwrap_or_default();
176 if !has_children {
177 return;
178 }
179
180 let changed = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {

Callers

nothing calls this directly

Calls 2

select_node_slotFunction · 0.85
refresh_scene_panelFunction · 0.85

Tested by

no test coverage detected