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

Function update_ui_canvas

perro_editor/res/scripts/scene/editor_nav.rs:1336–1362  ·  view source on GitHub ↗
(ctx: &mut ScriptContext<'_, API>)

Source from the content-addressed store, hash-verified

1334 } else {
1335 String::new()
1336 }
1337 })
1338 .unwrap_or_default();
1339 if moved {
1340 apply_freecam_2d(ctx);
1341 }
1342 apply_viewport_canvas(ctx);
1343 if !label.is_empty() {
1344 set_viewport_label(ctx, &label);
1345 }
1346}
1347
1348pub fn update_ui_canvas<API: ScriptAPI + ?Sized>(ctx: &mut ScriptContext<'_, API>) {
1349 let mode = with_state!(ctx.run, EditorState, ctx.id, |state| {
1350 state.viewport_mode.clone()
1351 }).unwrap_or_default();
1352 if mode != "UI" {
1353 return;
1354 }
1355 let inside = viewport_pointer(ctx).is_some();
1356 let wheel = if inside { mouse_wheel!(ctx.ipt).y } else { 0.0 };
1357 let zoomed = wheel.abs() > 0.001;
1358 let label = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
1359 let reset = state.ui_canvas_zoom <= 0.001;
1360 if reset {
1361 state.ui_canvas_zoom = 1.0;
1362 }
1363 state.ui_canvas_x = 0.0;
1364 state.ui_canvas_y = 0.0;
1365 if zoomed {

Callers

nothing calls this directly

Calls 3

viewport_pointerFunction · 0.85
apply_viewport_canvasFunction · 0.85
set_labelFunction · 0.85

Tested by

no test coverage detected