Skip to main content

rustapi/actions/
minimize.rs

1use crate::{editor::DOCKMANAGER, prelude::*};
2
3pub struct Minimize {
4    id: TheId,
5    nodeui: TheNodeUI,
6}
7
8impl Action for Minimize {
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_minimize_desc"));
15        nodeui.add_item(item);
16
17        Self {
18            id: TheId::named(&fl!("action_minimize")),
19            nodeui,
20        }
21    }
22
23    fn id(&self) -> TheId {
24        self.id.clone()
25    }
26
27    fn info(&self) -> String {
28        fl!("action_minimize_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, ']'))
37    }
38
39    fn is_applicable(
40        &self,
41        _map: &Map,
42        _ctx: &mut TheContext,
43        _server_ctx: &ServerContext,
44    ) -> bool {
45        DOCKMANAGER.read().unwrap().get_state() != DockManagerState::Minimized
46    }
47
48    fn apply(
49        &self,
50        _map: &mut Map,
51        ui: &mut TheUI,
52        ctx: &mut TheContext,
53        _server_ctx: &mut ServerContext,
54    ) -> Option<ProjectUndoAtom> {
55        DOCKMANAGER.write().unwrap().minimize(ui, ctx);
56
57        None
58    }
59
60    fn params(&self) -> TheNodeUI {
61        self.nodeui.clone()
62    }
63
64    fn handle_event(
65        &mut self,
66        event: &TheEvent,
67        _project: &mut Project,
68        _ui: &mut TheUI,
69        _ctx: &mut TheContext,
70        _server_ctx: &mut ServerContext,
71    ) -> bool {
72        self.nodeui.handle_event(event)
73    }
74}