electron_sys/interface/
browser_window_options.rs

1use crate::{
2    class::{BrowserWindow, NativeImage},
3    interface::WebPreferences,
4};
5use js_sys::JsString;
6use wasm_bindgen::prelude::*;
7
8#[wasm_bindgen]
9#[derive(Clone, Default)]
10pub struct BrowserWindowOptions {
11    accept_first_mouse: Option<bool>,
12    always_on_top: Option<bool>,
13    auto_hide_menu_bar: Option<bool>,
14    background_color: Option<JsString>,
15    center: Option<bool>,
16    closable: Option<bool>,
17    dark_theme: Option<bool>,
18    disable_auto_hide_cursor: Option<bool>,
19    enable_larger_than_screen: Option<bool>,
20    focusable: Option<bool>,
21    frame: Option<bool>,
22    fullscreen_window_title: Option<bool>,
23    fullscreen: Option<bool>,
24    fullscreenable: Option<bool>,
25    has_shadow: Option<bool>,
26    height: Option<usize>,
27    icon: Option<NativeImage>, // FIXME: NativeImage
28    kind: Option<JsString>,
29    kiosk: Option<bool>,
30    max_height: Option<usize>,
31    max_width: Option<usize>,
32    maximizable: Option<bool>,
33    min_height: Option<usize>,
34    min_width: Option<usize>,
35    minimizable: Option<bool>,
36    modal: Option<bool>,
37    movable: Option<bool>,
38    opacity: Option<f32>,
39    paint_when_initially_hidden: Option<bool>,
40    parent: Option<BrowserWindow>,
41    resizable: Option<bool>,
42    show: Option<bool>,
43    simple_fullscreen: Option<bool>,
44    skip_taskbar: Option<bool>,
45    tabbing_identifier: Option<JsString>,
46    thick_frame: Option<bool>,
47    title_bar_style: Option<JsString>,
48    title: Option<JsString>,
49    transparent: Option<bool>,
50    use_content_size: Option<bool>,
51    vibrancy: Option<JsString>,
52    web_preferences: Option<WebPreferences>,
53    width: Option<usize>,
54    x: Option<usize>,
55    y: Option<usize>,
56    zoom_to_page_width: Option<bool>,
57}
58
59#[wasm_bindgen]
60impl BrowserWindowOptions {
61    #[allow(clippy::too_many_arguments)]
62    #[wasm_bindgen(constructor)]
63    pub fn new_with_values(
64        accept_first_mouse: Option<bool>,
65        always_on_top: Option<bool>,
66        auto_hide_menu_bar: Option<bool>,
67        background_color: Option<JsString>,
68        center: Option<bool>,
69        closable: Option<bool>,
70        dark_theme: Option<bool>,
71        disable_auto_hide_cursor: Option<bool>,
72        enable_larger_than_screen: Option<bool>,
73        focusable: Option<bool>,
74        frame: Option<bool>,
75        fullscreen_window_title: Option<bool>,
76        fullscreen: Option<bool>,
77        fullscreenable: Option<bool>,
78        has_shadow: Option<bool>,
79        height: Option<usize>,
80        icon: Option<NativeImage>,
81        kind: Option<JsString>,
82        kiosk: Option<bool>,
83        max_height: Option<usize>,
84        max_width: Option<usize>,
85        maximizable: Option<bool>,
86        min_height: Option<usize>,
87        min_width: Option<usize>,
88        minimizable: Option<bool>,
89        modal: Option<bool>,
90        movable: Option<bool>,
91        opacity: Option<f32>,
92        paint_when_initially_hidden: Option<bool>,
93        parent: Option<BrowserWindow>,
94        resizable: Option<bool>,
95        show: Option<bool>,
96        simple_fullscreen: Option<bool>,
97        skip_taskbar: Option<bool>,
98        tabbing_identifier: Option<JsString>,
99        thick_frame: Option<bool>,
100        title_bar_style: Option<JsString>,
101        title: Option<JsString>,
102        transparent: Option<bool>,
103        use_content_size: Option<bool>,
104        vibrancy: Option<JsString>,
105        web_preferences: Option<WebPreferences>,
106        width: Option<usize>,
107        x: Option<usize>,
108        y: Option<usize>,
109        zoom_to_page_width: Option<bool>,
110    ) -> BrowserWindowOptions {
111        BrowserWindowOptions {
112            accept_first_mouse,
113            always_on_top,
114            auto_hide_menu_bar,
115            background_color,
116            center,
117            closable,
118            dark_theme,
119            disable_auto_hide_cursor,
120            enable_larger_than_screen,
121            focusable,
122            frame,
123            fullscreen_window_title,
124            fullscreen,
125            fullscreenable,
126            has_shadow,
127            height,
128            icon,
129            kind,
130            kiosk,
131            max_height,
132            max_width,
133            maximizable,
134            min_height,
135            min_width,
136            minimizable,
137            modal,
138            movable,
139            opacity,
140            paint_when_initially_hidden,
141            parent,
142            resizable,
143            show,
144            simple_fullscreen,
145            skip_taskbar,
146            tabbing_identifier,
147            thick_frame,
148            title_bar_style,
149            title,
150            transparent,
151            use_content_size,
152            vibrancy,
153            web_preferences,
154            width,
155            x,
156            y,
157            zoom_to_page_width,
158        }
159    }
160
161    pub fn new() -> BrowserWindowOptions {
162        Default::default()
163    }
164
165    #[wasm_bindgen(getter, js_name = "acceptFirstMouse")]
166    pub fn accept_first_mouse(&self) -> Option<bool> {
167        self.accept_first_mouse
168    }
169
170    #[wasm_bindgen(setter)]
171    pub fn set_accept_first_mouse(&mut self, value: Option<bool>) {
172        self.accept_first_mouse = value;
173    }
174
175    #[wasm_bindgen(getter, js_name = "alwaysOnTop")]
176    pub fn always_on_top(&self) -> Option<bool> {
177        self.always_on_top
178    }
179
180    #[wasm_bindgen(setter)]
181    pub fn set_always_on_top(&mut self, value: Option<bool>) {
182        self.always_on_top = value;
183    }
184
185    #[wasm_bindgen(getter, js_name = "autoHideMenuBar")]
186    pub fn auto_hide_menu_bar(&self) -> Option<bool> {
187        self.auto_hide_menu_bar
188    }
189
190    #[wasm_bindgen(setter)]
191    pub fn set_auto_hide_menu_bar(&mut self, value: Option<bool>) {
192        self.auto_hide_menu_bar = value;
193    }
194
195    #[wasm_bindgen(getter, js_name = "backgroundColor")]
196    pub fn background_color(&self) -> Option<JsString> {
197        self.background_color.clone()
198    }
199
200    #[wasm_bindgen(setter)]
201    pub fn set_background_color(&mut self, value: Option<JsString>) {
202        self.background_color = value;
203    }
204
205    #[wasm_bindgen(getter)]
206    pub fn center(&self) -> Option<bool> {
207        self.center
208    }
209
210    #[wasm_bindgen(setter)]
211    pub fn set_center(&mut self, value: Option<bool>) {
212        self.center = value;
213    }
214
215    #[wasm_bindgen(getter)]
216    pub fn closable(&self) -> Option<bool> {
217        self.closable
218    }
219
220    #[wasm_bindgen(setter)]
221    pub fn set_closable(&mut self, value: Option<bool>) {
222        self.closable = value;
223    }
224
225    #[wasm_bindgen(getter, js_name = "darkTheme")]
226    pub fn dark_theme(&self) -> Option<bool> {
227        self.dark_theme
228    }
229
230    #[wasm_bindgen(setter)]
231    pub fn set_dark_theme(&mut self, value: Option<bool>) {
232        self.dark_theme = value;
233    }
234
235    #[wasm_bindgen(getter, js_name = "disableAutoHideCursor")]
236    pub fn disable_auto_hide_cursor(&self) -> Option<bool> {
237        self.disable_auto_hide_cursor
238    }
239
240    #[wasm_bindgen(setter)]
241    pub fn set_disable_auto_hide_cursor(&mut self, value: Option<bool>) {
242        self.disable_auto_hide_cursor = value;
243    }
244
245    #[wasm_bindgen(getter, js_name = "enableLargerThanScreen")]
246    pub fn enable_larger_than_screen(&self) -> Option<bool> {
247        self.enable_larger_than_screen
248    }
249
250    #[wasm_bindgen(setter)]
251    pub fn set_enable_larger_than_screen(&mut self, value: Option<bool>) {
252        self.enable_larger_than_screen = value;
253    }
254
255    #[wasm_bindgen(getter)]
256    pub fn focusable(&self) -> Option<bool> {
257        self.focusable
258    }
259
260    #[wasm_bindgen(setter)]
261    pub fn set_focusable(&mut self, value: Option<bool>) {
262        self.focusable = value;
263    }
264
265    #[wasm_bindgen(getter)]
266    pub fn frame(&self) -> Option<bool> {
267        self.frame
268    }
269
270    #[wasm_bindgen(setter)]
271    pub fn set_frame(&mut self, value: Option<bool>) {
272        self.frame = value;
273    }
274
275    #[wasm_bindgen(getter, js_name = "fullscreenWindowTitle")]
276    pub fn fullscreen_window_title(&self) -> Option<bool> {
277        self.fullscreen_window_title
278    }
279
280    #[wasm_bindgen(setter)]
281    pub fn set_fullscreen_window_title(&mut self, value: Option<bool>) {
282        self.fullscreen_window_title = value;
283    }
284
285    #[wasm_bindgen(getter)]
286    pub fn fullscreen(&self) -> Option<bool> {
287        self.fullscreen
288    }
289
290    #[wasm_bindgen(setter)]
291    pub fn set_fullscreen(&mut self, value: Option<bool>) {
292        self.fullscreen = value;
293    }
294
295    #[wasm_bindgen(getter)]
296    pub fn fullscreenable(&self) -> Option<bool> {
297        self.fullscreenable
298    }
299
300    #[wasm_bindgen(setter)]
301    pub fn set_fullscreenable(&mut self, value: Option<bool>) {
302        self.fullscreenable = value;
303    }
304
305    #[wasm_bindgen(getter, js_name = "hasShadow")]
306    pub fn has_shadow(&self) -> Option<bool> {
307        self.has_shadow
308    }
309
310    #[wasm_bindgen(setter)]
311    pub fn set_has_shadow(&mut self, value: Option<bool>) {
312        self.has_shadow = value;
313    }
314
315    #[wasm_bindgen(getter)]
316    pub fn height(&self) -> Option<usize> {
317        self.height
318    }
319
320    #[wasm_bindgen(setter)]
321    pub fn set_height(&mut self, value: Option<usize>) {
322        self.height = value;
323    }
324
325    #[wasm_bindgen(getter)]
326    pub fn icon(&self) -> Option<NativeImage> {
327        self.icon.clone()
328    }
329
330    #[wasm_bindgen(setter)]
331    pub fn set_icon(&mut self, value: Option<NativeImage>) {
332        self.icon = value;
333    }
334
335    #[wasm_bindgen(getter, js_name = "type")]
336    pub fn kind(&self) -> Option<JsString> {
337        self.kind.clone()
338    }
339
340    #[wasm_bindgen(setter)]
341    pub fn set_kind(&mut self, value: Option<JsString>) {
342        self.kind = value;
343    }
344
345    #[wasm_bindgen(getter)]
346    pub fn kiosk(&self) -> Option<bool> {
347        self.kiosk
348    }
349
350    #[wasm_bindgen(setter)]
351    pub fn set_kiosk(&mut self, value: Option<bool>) {
352        self.kiosk = value;
353    }
354
355    #[wasm_bindgen(getter, js_name = "maxHeight")]
356    pub fn max_height(&self) -> Option<usize> {
357        self.max_height
358    }
359
360    #[wasm_bindgen(setter)]
361    pub fn set_max_height(&mut self, value: Option<usize>) {
362        self.max_height = value;
363    }
364
365    #[wasm_bindgen(getter, js_name = "maxWidth")]
366    pub fn max_width(&self) -> Option<usize> {
367        self.max_width
368    }
369
370    #[wasm_bindgen(setter)]
371    pub fn set_max_width(&mut self, value: Option<usize>) {
372        self.max_width = value;
373    }
374
375    #[wasm_bindgen(getter)]
376    pub fn maximizable(&self) -> Option<bool> {
377        self.maximizable
378    }
379
380    #[wasm_bindgen(setter)]
381    pub fn set_maximizable(&mut self, value: Option<bool>) {
382        self.maximizable = value;
383    }
384
385    #[wasm_bindgen(getter, js_name = "minHeight")]
386    pub fn min_height(&self) -> Option<usize> {
387        self.min_height
388    }
389
390    #[wasm_bindgen(setter)]
391    pub fn set_min_height(&mut self, value: Option<usize>) {
392        self.min_height = value;
393    }
394
395    #[wasm_bindgen(getter, js_name = "minWidth")]
396    pub fn min_width(&self) -> Option<usize> {
397        self.min_width
398    }
399
400    #[wasm_bindgen(setter)]
401    pub fn set_min_width(&mut self, value: Option<usize>) {
402        self.min_width = value;
403    }
404
405    #[wasm_bindgen(getter)]
406    pub fn minimizable(&self) -> Option<bool> {
407        self.minimizable
408    }
409
410    #[wasm_bindgen(setter)]
411    pub fn set_minimizable(&mut self, value: Option<bool>) {
412        self.minimizable = value;
413    }
414
415    #[wasm_bindgen(getter)]
416    pub fn modal(&self) -> Option<bool> {
417        self.modal
418    }
419
420    #[wasm_bindgen(setter)]
421    pub fn set_modal(&mut self, value: Option<bool>) {
422        self.modal = value;
423    }
424
425    #[wasm_bindgen(getter)]
426    pub fn movable(&self) -> Option<bool> {
427        self.movable
428    }
429
430    #[wasm_bindgen(setter)]
431    pub fn set_movable(&mut self, value: Option<bool>) {
432        self.movable = value;
433    }
434
435    #[wasm_bindgen(getter)]
436    pub fn opacity(&self) -> Option<f32> {
437        self.opacity
438    }
439
440    #[wasm_bindgen(setter)]
441    pub fn set_opacity(&mut self, value: Option<f32>) {
442        self.opacity = value;
443    }
444
445    #[wasm_bindgen(getter, js_name = "painWhenInitiallyHidden")]
446    pub fn paint_when_initially_hidden(&self) -> Option<bool> {
447        self.paint_when_initially_hidden
448    }
449
450    #[wasm_bindgen(setter)]
451    pub fn set_paint_when_initially_hidden(&mut self, value: Option<bool>) {
452        self.paint_when_initially_hidden = value;
453    }
454
455    #[wasm_bindgen(getter)]
456    pub fn parent(&self) -> Option<BrowserWindow> {
457        self.parent.clone()
458    }
459
460    #[wasm_bindgen(setter)]
461    pub fn set_parent(&mut self, value: Option<BrowserWindow>) {
462        self.parent = value;
463    }
464
465    #[wasm_bindgen(getter)]
466    pub fn resizable(&self) -> Option<bool> {
467        self.resizable
468    }
469
470    #[wasm_bindgen(setter)]
471    pub fn set_resizable(&mut self, value: Option<bool>) {
472        self.resizable = value;
473    }
474
475    #[wasm_bindgen(getter)]
476    pub fn show(&self) -> Option<bool> {
477        self.show
478    }
479
480    #[wasm_bindgen(setter)]
481    pub fn set_show(&mut self, value: Option<bool>) {
482        self.show = value;
483    }
484
485    #[wasm_bindgen(getter, js_name = "simpleFullscreen")]
486    pub fn simple_fullscreen(&self) -> Option<bool> {
487        self.simple_fullscreen
488    }
489
490    #[wasm_bindgen(setter)]
491    pub fn set_simple_fullscreen(&mut self, value: Option<bool>) {
492        self.simple_fullscreen = value;
493    }
494
495    #[wasm_bindgen(getter, js_name = "skipTaskbar")]
496    pub fn skip_taskbar(&self) -> Option<bool> {
497        self.skip_taskbar
498    }
499
500    #[wasm_bindgen(setter)]
501    pub fn set_skip_taskbar(&mut self, value: Option<bool>) {
502        self.skip_taskbar = value;
503    }
504
505    #[wasm_bindgen(getter, js_name = "tabbingIdentifier")]
506    pub fn tabbing_identifier(&self) -> Option<JsString> {
507        self.tabbing_identifier.clone()
508    }
509
510    #[wasm_bindgen(setter)]
511    pub fn set_tabbing_identifier(&mut self, value: Option<JsString>) {
512        self.tabbing_identifier = value;
513    }
514
515    #[wasm_bindgen(getter, js_name = "thickFrame")]
516    pub fn thick_frame(&self) -> Option<bool> {
517        self.thick_frame
518    }
519
520    #[wasm_bindgen(setter)]
521    pub fn set_thick_frame(&mut self, value: Option<bool>) {
522        self.thick_frame = value;
523    }
524
525    #[wasm_bindgen(getter, js_name = "titleBarStyle")]
526    pub fn title_bar_style(&self) -> Option<JsString> {
527        self.title_bar_style.clone()
528    }
529
530    #[wasm_bindgen(setter)]
531    pub fn set_title_bar_style(&mut self, value: Option<JsString>) {
532        self.title_bar_style = value;
533    }
534
535    #[wasm_bindgen(getter)]
536    pub fn title(&self) -> Option<JsString> {
537        self.title.clone()
538    }
539
540    #[wasm_bindgen(setter)]
541    pub fn set_title(&mut self, value: Option<JsString>) {
542        self.title = value;
543    }
544
545    #[wasm_bindgen(getter)]
546    pub fn transparent(&self) -> Option<bool> {
547        self.transparent
548    }
549
550    #[wasm_bindgen(setter)]
551    pub fn set_transparent(&mut self, value: Option<bool>) {
552        self.transparent = value;
553    }
554
555    #[wasm_bindgen(getter, js_name = "useContentSize")]
556    pub fn use_content_size(&self) -> Option<bool> {
557        self.use_content_size
558    }
559
560    #[wasm_bindgen(setter)]
561    pub fn set_use_content_size(&mut self, value: Option<bool>) {
562        self.use_content_size = value;
563    }
564
565    #[wasm_bindgen(getter)]
566    pub fn vibrancy(&self) -> Option<JsString> {
567        self.vibrancy.clone()
568    }
569
570    #[wasm_bindgen(setter)]
571    pub fn set_vibrancy(&mut self, value: Option<JsString>) {
572        self.vibrancy = value;
573    }
574
575    #[wasm_bindgen(getter, js_name = "webPreferences")]
576    pub fn web_preferences(&self) -> Option<WebPreferences> {
577        self.web_preferences.clone()
578    }
579
580    #[wasm_bindgen(setter)]
581    pub fn set_web_preferences(&mut self, value: Option<WebPreferences>) {
582        self.web_preferences = value;
583    }
584
585    #[wasm_bindgen(getter)]
586    pub fn width(&self) -> Option<usize> {
587        self.width
588    }
589
590    #[wasm_bindgen(setter)]
591    pub fn set_width(&mut self, value: Option<usize>) {
592        self.width = value;
593    }
594
595    #[wasm_bindgen(getter)]
596    pub fn x(&self) -> Option<usize> {
597        self.x
598    }
599
600    #[wasm_bindgen(setter)]
601    pub fn set_x(&mut self, value: Option<usize>) {
602        self.x = value;
603    }
604
605    #[wasm_bindgen(getter)]
606    pub fn y(&self) -> Option<usize> {
607        self.y
608    }
609
610    #[wasm_bindgen(setter)]
611    pub fn set_y(&mut self, value: Option<usize>) {
612        self.y = value;
613    }
614
615    #[wasm_bindgen(getter, js_name = "zoomToPageWidth")]
616    pub fn zoom_to_page_width(&self) -> Option<bool> {
617        self.zoom_to_page_width
618    }
619
620    #[wasm_bindgen(setter)]
621    pub fn set_zoom_to_page_width(&mut self, value: Option<bool>) {
622        self.zoom_to_page_width = value;
623    }
624}