rustapi/actions/
orbit_camera.rs1use crate::prelude::*;
2
3pub struct OrbitCamera {
4 id: TheId,
5 nodeui: TheNodeUI,
6}
7
8impl Action for OrbitCamera {
9 fn new() -> Self
10 where
11 Self: Sized,
12 {
13 let mut nodeui: TheNodeUI = TheNodeUI::default();
14 let item = TheNodeUIItem::Markdown("desc".into(), fl!("action_orbit_camera_desc"));
15 nodeui.add_item(item);
16
17 Self {
18 id: TheId::named(&fl!("action_orbit_camera")),
19 nodeui,
20 }
21 }
22
23 fn id(&self) -> TheId {
24 self.id.clone()
25 }
26
27 fn info(&self) -> String {
28 fl!("action_orbit_camera_desc")
29 }
30
31 fn role(&self) -> ActionRole {
32 ActionRole::Camera
33 }
34
35 fn accel(&self) -> Option<TheAccelerator> {
36 Some(TheAccelerator::new(TheAcceleratorKey::CTRLCMD, '3'))
37 }
38
39 fn is_applicable(&self, _map: &Map, _ctx: &mut TheContext, server_ctx: &ServerContext) -> bool {
40 server_ctx.editor_view_mode != EditorViewMode::Orbit
41 && server_ctx.get_map_context() == MapContext::Region
42 }
43
44 fn apply(
45 &self,
46 _map: &mut Map,
47 ui: &mut TheUI,
48 ctx: &mut TheContext,
49 server_ctx: &mut ServerContext,
50 ) -> Option<ProjectUndoAtom> {
51 server_ctx.editing_surface = None;
52 ui.set_widget_value("Editor View Switch", ctx, TheValue::Int(1));
53 ctx.ui.send(TheEvent::IndexChanged(
54 TheId::named("Editor View Switch"),
55 1,
56 ));
57 None
58 }
59
60 fn apply_project(
61 &self,
62 project: &mut Project,
63 _ui: &mut TheUI,
64 _ctx: &mut TheContext,
65 server_ctx: &mut ServerContext,
66 ) {
67 crate::editor::TOOLLIST
68 .write()
69 .unwrap()
70 .update_geometry_overlay_3d(project, server_ctx);
71 }
72
73 fn params(&self) -> TheNodeUI {
74 self.nodeui.clone()
75 }
76
77 fn handle_event(
78 &mut self,
79 event: &TheEvent,
80 _project: &mut Project,
81 _ui: &mut TheUI,
82 _ctx: &mut TheContext,
83 _server_ctx: &mut ServerContext,
84 ) -> bool {
85 self.nodeui.handle_event(event)
86 }
87}