Skip to main content

rustapi/docks/
mod.rs

1pub mod code;
2pub mod code_undo;
3pub mod console;
4pub mod data;
5pub mod data_editor;
6pub mod data_undo;
7pub mod log;
8pub mod tilemap;
9pub mod tiles;
10pub mod tiles_editor;
11pub mod tiles_editor_undo;
12pub mod visual_code;
13pub mod visual_code_undo;
14
15pub use crate::prelude::*;
16use codegridfx::DebugModule;
17
18#[derive(Clone, Copy, PartialEq)]
19pub enum DockDefaultState {
20    Minimized,
21    Maximized,
22}
23
24#[derive(Clone, Copy, PartialEq)]
25pub enum DockMaximizedState {
26    Maximized,
27    Editor,
28}
29
30#[allow(unused)]
31pub trait Dock: Send + Sync {
32    fn new() -> Self
33    where
34        Self: Sized;
35
36    fn setup(&mut self, ctx: &mut TheContext) -> TheCanvas;
37
38    fn activate(
39        &mut self,
40        ui: &mut TheUI,
41        ctx: &mut TheContext,
42        project: &Project,
43        server_ctx: &mut ServerContext,
44    ) {
45    }
46
47    fn minimized(&mut self, ui: &mut TheUI, ctx: &mut TheContext) {}
48
49    fn supports_actions(&self) -> bool {
50        true
51    }
52
53    fn default_state(&self) -> DockDefaultState {
54        DockDefaultState::Minimized
55    }
56
57    fn maximized_state(&self) -> DockMaximizedState {
58        DockMaximizedState::Maximized
59    }
60
61    /// Dock supports an import operation from JSON.
62    fn import(
63        &mut self,
64        content: String,
65        ui: &mut TheUI,
66        ctx: &mut TheContext,
67        project: &mut Project,
68        server_ctx: &mut ServerContext,
69    ) {
70    }
71
72    /// Dock supports an export operation to JSON.
73    fn export(&self) -> Option<String> {
74        None
75    }
76
77    fn handle_event(
78        &mut self,
79        event: &TheEvent,
80        ui: &mut TheUI,
81        ctx: &mut TheContext,
82        project: &mut Project,
83        server_ctx: &mut ServerContext,
84    ) -> bool {
85        false
86    }
87
88    /// Returns true if this dock supports internal undo / redo.
89    fn supports_undo(&self) -> bool {
90        false
91    }
92
93    /// Returns true if this dock has unsaved changes in its undo stack.
94    fn has_changes(&self) -> bool {
95        false
96    }
97
98    /// Mark dock-local undo state as saved.
99    fn mark_saved(&mut self) {}
100
101    /// If the dock supports undo, set its current state to the UI.
102    fn set_undo_state_to_ui(&self, ctx: &mut TheContext) {}
103
104    /// Undo an action in the current dock
105    fn undo(
106        &mut self,
107        ui: &mut TheUI,
108        ctx: &mut TheContext,
109        project: &mut Project,
110        server_ctx: &mut ServerContext,
111    ) {
112    }
113
114    /// Redo an action in the current dock
115    fn redo(
116        &mut self,
117        ui: &mut TheUI,
118        ctx: &mut TheContext,
119        project: &mut Project,
120        server_ctx: &mut ServerContext,
121    ) {
122    }
123
124    /// Returns the custom editor tools for this dock.
125    /// If None, no custom tools are available.
126    fn editor_tools(&self) -> Option<Vec<Box<dyn EditorTool>>> {
127        None
128    }
129
130    /// Draw custom minimap content when this dock is active.
131    /// Returns true if the dock drew custom content (minimap should not draw default content).
132    /// Returns false to let the default minimap drawing proceed.
133    fn draw_minimap(
134        &self,
135        buffer: &mut TheRGBABuffer,
136        project: &Project,
137        ctx: &mut TheContext,
138        server_ctx: &ServerContext,
139    ) -> bool {
140        false
141    }
142
143    /// Returns true if this dock animates minimap content (requires soft updates each tick).
144    fn supports_minimap_animation(&self) -> bool {
145        false
146    }
147
148    /// Apply a live debug overlay to the visible dock, if supported.
149    fn apply_debug_data(
150        &mut self,
151        ui: &mut TheUI,
152        ctx: &mut TheContext,
153        project: &Project,
154        server_ctx: &ServerContext,
155        debug: &DebugModule,
156    ) {
157    }
158}