1use cursor_icon::CursorIcon;
4
5pub struct ClipboardError;
8
9pub trait ShellProvider: Send + Sync + 'static {
12 fn request_redraw(&self) {}
13 fn set_cursor(&self, icon: CursorIcon) {
14 let _ = icon;
15 }
16 fn set_window_title(&self, title: String) {
17 let _ = title;
18 }
19 fn set_ime_enabled(&self, is_enabled: bool) {
20 let _ = is_enabled;
21 }
22 fn set_ime_cursor_area(&self, x: f32, y: f32, width: f32, height: f32) {
23 let _ = x;
24 let _ = y;
25 let _ = width;
26 let _ = height;
27 }
28 fn get_clipboard_text(&self) -> Result<String, ClipboardError> {
29 Err(ClipboardError)
30 }
31 fn set_clipboard_text(&self, text: String) -> Result<(), ClipboardError> {
32 let _ = text;
33 Err(ClipboardError)
34 }
35 fn open_file_dialog(
36 &self,
37 multiple: bool,
38 filter: Option<FileDialogFilter>,
39 ) -> Vec<std::path::PathBuf> {
40 let _ = multiple;
41 let _ = filter;
42 vec![]
43 }
44
45 fn request_window_close(&self) {}
48 fn set_window_minimized(&self, minimized: bool) {
49 let _ = minimized;
50 }
51 fn set_window_maximized(&self, maximized: bool) {
52 let _ = maximized;
53 }
54 fn is_window_maximized(&self) -> bool {
55 false
56 }
57 fn set_window_decorations(&self, decorations: bool) {
58 let _ = decorations;
59 }
60 fn drag_window(&self) {}
63}
64
65pub struct DummyShellProvider;
66impl ShellProvider for DummyShellProvider {}
67
68#[derive(Default, Debug, Clone, Copy, PartialEq)]
70pub enum ColorScheme {
71 #[default]
72 Light,
73 Dark,
74}
75
76#[derive(Debug, Clone, PartialEq)]
77pub struct Viewport {
78 pub color_scheme: ColorScheme,
79 pub window_size: (u32, u32),
80 pub hidpi_scale: f32,
81 pub zoom: f32,
82}
83
84impl Default for Viewport {
85 fn default() -> Self {
86 Self {
87 window_size: (0, 0),
88 hidpi_scale: 1.0,
89 zoom: 1.0,
90 color_scheme: ColorScheme::Light,
91 }
92 }
93}
94
95impl Viewport {
96 pub fn new(
97 physical_width: u32,
98 physical_height: u32,
99 scale_factor: f32,
100 color_scheme: ColorScheme,
101 ) -> Self {
102 Self {
103 window_size: (physical_width, physical_height),
104 hidpi_scale: scale_factor,
105 zoom: 1.0,
106 color_scheme,
107 }
108 }
109
110 pub fn scale(&self) -> f32 {
112 self.hidpi_scale * self.zoom
113 }
114 pub fn scale_f64(&self) -> f64 {
116 self.scale() as f64
117 }
118
119 pub fn set_hidpi_scale(&mut self, scale: f32) {
121 self.hidpi_scale = scale;
122 }
123
124 pub fn zoom(&self) -> f32 {
126 self.zoom
127 }
128
129 pub fn set_zoom(&mut self, zoom: f32) {
131 self.zoom = zoom;
132 }
133
134 pub fn zoom_by(&mut self, zoom: f32) {
135 self.zoom += zoom;
136 }
137
138 pub fn zoom_mut(&mut self) -> &mut f32 {
139 &mut self.zoom
140 }
141}
142
143pub struct FileDialogFilter {
145 pub name: String,
146 pub extensions: Vec<String>,
147}