1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Editor and GUI-related traits.
use crate::types::Size;
/// Size constraints for the plugin editor.
#[derive(Debug, Clone, Copy)]
pub struct EditorConstraints {
/// Minimum size.
pub min: Size,
/// Maximum size.
pub max: Size,
/// Whether the editor is resizable.
pub resizable: bool,
}
impl Default for EditorConstraints {
fn default() -> Self {
Self {
min: Size::new(400, 300),
max: Size::new(1600, 1200),
resizable: true,
}
}
}
/// Trait for plugin editor/GUI callbacks.
///
/// Implement this trait to provide GUI-related configuration and callbacks.
/// The actual WebView creation and management is handled by the framework;
/// this trait just provides configuration and lifecycle hooks.
pub trait EditorDelegate: Send {
/// Get the initial editor size.
///
/// This is the size the editor window will have when first opened.
/// Default is 800x600.
fn editor_size(&self) -> Size {
Size::new(800, 600)
}
/// Get the editor size constraints.
///
/// These constraints determine the minimum and maximum sizes the editor
/// can be resized to, and whether resizing is allowed at all.
fn editor_constraints(&self) -> EditorConstraints {
EditorConstraints::default()
}
/// Called when the editor is opened.
///
/// Use this to initialize any editor-specific state.
fn editor_opened(&mut self) {}
/// Called when the editor is closed.
///
/// Use this to clean up editor-specific state.
fn editor_closed(&mut self) {}
/// Called when the editor is resized.
///
/// The new size has already been constrained to the editor constraints.
fn editor_resized(&mut self, _new_size: Size) {}
}
/// Trait for plugins that don't need an editor.
///
/// Implement this for plugins that don't have a GUI. This is the default
/// for the basic `Processor` trait, but can be explicitly implemented
/// to opt out of editor support.
pub trait NoEditor {}