rustapi/actions/
toggle_editing_geo.rs1use crate::prelude::*;
2
3pub struct ToggleEditingGeo {
4 id: TheId,
5 nodeui: TheNodeUI,
6}
7
8impl Action for ToggleEditingGeo {
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_toggle_edit_geo_desc"));
15 nodeui.add_item(item);
16
17 Self {
18 id: TheId::named(&fl!("action_toggle_edit_geo")),
19 nodeui,
20 }
21 }
22
23 fn id(&self) -> TheId {
24 self.id.clone()
25 }
26
27 fn info(&self) -> String {
28 fl!("action_toggle_edit_geo_desc")
29 }
30
31 fn role(&self) -> ActionRole {
32 ActionRole::Editor
33 }
34
35 fn accel(&self) -> Option<TheAccelerator> {
36 Some(TheAccelerator::new(TheAcceleratorKey::CTRLCMD, 't'))
37 }
38
39 fn is_applicable(&self, _map: &Map, _ctx: &mut TheContext, server_ctx: &ServerContext) -> bool {
40 let _ = server_ctx;
41 true
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.show_editing_geometry = !server_ctx.show_editing_geometry;
52
53 None
54 }
55
56 fn apply_project(
57 &self,
58 project: &mut Project,
59 _ui: &mut TheUI,
60 _ctx: &mut TheContext,
61 server_ctx: &mut ServerContext,
62 ) {
63 crate::editor::TOOLLIST
64 .write()
65 .unwrap()
66 .update_geometry_overlay_3d(project, server_ctx);
67 }
68
69 fn params(&self) -> TheNodeUI {
70 self.nodeui.clone()
71 }
72
73 fn handle_event(
74 &mut self,
75 event: &TheEvent,
76 _project: &mut Project,
77 _ui: &mut TheUI,
78 _ctx: &mut TheContext,
79 _server_ctx: &mut ServerContext,
80 ) -> bool {
81 self.nodeui.handle_event(event)
82 }
83}