Skip to main content

eov_plugin_api/
host.rs

1//! Shared host-facing types for plugin access to application state.
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
6#[serde(rename_all = "snake_case")]
7pub enum HostToolMode {
8    Navigate,
9    RegionOfInterest,
10    MeasureDistance,
11    PointAnnotation,
12    PolygonAnnotation,
13}
14
15#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
16pub struct SidebarRequest {
17    pub button_id: Option<String>,
18    pub width_px: u32,
19    pub ui_path: String,
20    pub component: String,
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
24pub struct ActiveSidebar {
25    pub plugin_id: String,
26    pub button_id: Option<String>,
27    pub width_px: u32,
28    pub ui_path: String,
29    pub component: String,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
33pub struct ConfirmationDialogRequest {
34    pub title: String,
35    pub message: String,
36    pub confirm_label: String,
37    pub cancel_label: String,
38    pub confirm_callback: Option<String>,
39    pub confirm_args_json: Option<String>,
40    pub cancel_callback: Option<String>,
41    pub cancel_args_json: Option<String>,
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
45pub struct ModalDialogRequest {
46    pub ui_path: String,
47    pub component: String,
48    pub width_px: u32,
49    pub height_px: u32,
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
53pub struct ViewportOverlayComponentRequest {
54    pub ui_path: String,
55    pub component: String,
56    pub z_index: i32,
57}
58
59#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
60pub struct PluginUndoRedoState {
61    pub enabled: bool,
62    pub undo_available: bool,
63    pub redo_available: bool,
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
67pub struct OpenFileDialogRequest {
68    pub filter_name: String,
69    pub extension: String,
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
73pub struct HostSnapshot {
74    pub app_name: String,
75    pub app_version: String,
76    pub render_backend: String,
77    pub filtering_mode: String,
78    pub split_enabled: bool,
79    pub focused_pane: u32,
80    pub open_files: Vec<OpenFileInfo>,
81    pub active_file: Option<OpenFileInfo>,
82    pub active_viewport: Option<ViewportSnapshot>,
83    pub recent_files: Vec<String>,
84    pub active_sidebar: Option<ActiveSidebar>,
85}
86
87/// One level of a slide's pyramid. See [`crate::ffi::LevelInfoFFI`] for what
88/// `downsample` means and why it is not always a power of two.
89#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
90pub struct LevelInfo {
91    pub level: u32,
92    pub width: u64,
93    pub height: u64,
94    pub downsample: f64,
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
98pub struct OpenFileInfo {
99    pub file_id: i32,
100    pub path: String,
101    pub filename: String,
102    pub width: u64,
103    pub height: u64,
104    pub level_count: u32,
105    pub vendor: Option<String>,
106    pub mpp_x: Option<f64>,
107    pub mpp_y: Option<f64>,
108    pub objective_power: Option<f64>,
109    pub scan_date: Option<String>,
110}
111
112#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
113pub struct ViewportSnapshot {
114    pub pane_index: u32,
115    pub file_id: i32,
116    pub file_path: String,
117    pub filename: String,
118    pub center_x: f64,
119    pub center_y: f64,
120    pub zoom: f64,
121    pub width: f64,
122    pub height: f64,
123    pub image_width: f64,
124    pub image_height: f64,
125    pub bounds_left: f64,
126    pub bounds_top: f64,
127    pub bounds_right: f64,
128    pub bounds_bottom: f64,
129}
130
131#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
132#[serde(rename_all = "snake_case")]
133pub enum HostLogLevel {
134    Trace,
135    Debug,
136    Info,
137    Warn,
138    Error,
139}