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

Function rename_bitmask_instance

perro_editor/res/scripts/ui/bitmask.rs:46–70  ·  view source on GitHub ↗
(
    ctx: &mut ScriptContext<'_, API>,
    root_id: NodeID,
    idx: usize,
)

Source from the content-addressed store, hash-verified

44
45pub fn update_inspector_bitmask_grid<API: ScriptAPI + ?Sized>(
46 ctx: &mut ScriptContext<'_, API>,
47 idx: usize,
48 mask: u32,
49) {
50 for bit in 1..=32 {
51 let on = mask & (1_u32 << (bit - 1)) != 0;
52 let Some(id) = find_named(ctx, &format!("inspector_var_{idx}_bit_{bit}")) else {
53 continue;
54 };
55 let _ = with_node_mut!(ctx.run, UiButton, id, |node| {
56 node.style.fill =
57 Color::from_hex(if on { "#4D84D1" } else { "#2A2F36" }).unwrap_or(node.style.fill);
58 node.style.stroke = Color::from_hex(if on { "#5A91DD" } else { "#343A43" })
59 .unwrap_or(node.style.stroke);
60 });
61 }
62}
63
64fn rename_bitmask_instance<API: ScriptAPI + ?Sized>(
65 ctx: &mut ScriptContext<'_, API>,
66 root_id: NodeID,
67 idx: usize,
68) {
69 let mut stack = vec![root_id];
70 while let Some(id) = stack.pop() {
71 if let Some(children) = ctx.run.Nodes().get_node_children_ids(id) {
72 stack.extend(children);
73 }

Callers 1

Calls 7

bitmask_instance_nameFunction · 0.85
NodesMethod · 0.80
extendMethod · 0.80
popMethod · 0.45
get_node_children_idsMethod · 0.45
get_node_nameMethod · 0.45
set_node_nameMethod · 0.45

Tested by

no test coverage detected