electron_sys/class/
browser_view.rs

1use crate::{
2    class::WebContents,
3    interface::{AutoResizeOptions, BrowserViewOptions, Rectangle},
4};
5use js_sys::Object;
6use wasm_bindgen::prelude::*;
7
8#[wasm_bindgen(module = "electron")]
9extern {
10    #[wasm_bindgen(extends = Object)]
11    #[derive(Clone, Debug, Eq, PartialEq)]
12    /// Docs: http://electronjs.org/docs/api/browser-view
13    pub type BrowserView;
14
15    //*************//
16    // Constructor //
17    //*************//
18
19    #[wasm_bindgen(constructor)]
20    pub fn new(options: Option<BrowserViewOptions>) -> BrowserView;
21
22    // Static Methods
23
24    #[wasm_bindgen(static_method_of = BrowserView)]
25    pub fn from_id(id: u32) -> BrowserView;
26
27    #[wasm_bindgen(static_method_of = BrowserView)]
28    pub fn from_web_contents(web_contents: &WebContents) -> Option<BrowserView>;
29
30    #[wasm_bindgen(static_method_of = BrowserView)]
31    pub fn get_all_views() -> Box<[JsValue]>;
32
33    //******************//
34    // Instance Methods //
35    //******************//
36
37    #[wasm_bindgen(method)]
38    pub fn destroy(this: &BrowserView);
39
40    #[wasm_bindgen(method, js_name = "getBounds")]
41    pub fn get_bounds(this: &BrowserView) -> Rectangle;
42
43    #[wasm_bindgen(method, js_name = "isDestroyed")]
44    pub fn is_destroyed(this: &BrowserView) -> bool;
45
46    #[wasm_bindgen(method, js_name = "set_auto_resize")]
47    pub fn set_auto_resize(this: &BrowserView, options: AutoResizeOptions);
48
49    #[wasm_bindgen(method, js_name = "set_background_color")]
50    pub fn set_background_color(this: &BrowserView, color: &str);
51
52    #[wasm_bindgen(method, js_name = "set_bounds")]
53    pub fn set_bounds(this: &BrowserView, bounds: Rectangle);
54
55    //*********************//
56    // Instance Properties //
57    //*********************//
58
59    #[wasm_bindgen(method, getter)]
60    pub fn id(this: &BrowserView) -> u32;
61
62    #[wasm_bindgen(method, setter)]
63    pub fn set_id(this: &BrowserView, value: u32);
64
65    #[wasm_bindgen(method, getter)]
66    pub fn web_contents(this: &BrowserView) -> WebContents;
67
68    #[wasm_bindgen(method, getter)]
69    pub fn set_web_contents(this: &BrowserView, value: WebContents);
70}