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
use super::Control;
use crate::{object_constructor, object_property_set};
use js_sys::Object;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern "C" {
    #[derive(Clone, Debug)]
    #[wasm_bindgen(extends = Control, js_namespace = ["L", "Control"])]
    pub type Zoom;

    #[wasm_bindgen(js_namespace = ["L", "control"], js_name = "zoom")]
    fn constructor_zoom(options: &ZoomOptions) -> Zoom;

    #[wasm_bindgen(extends = Object , js_name = ZoomOptions)]
    #[derive(Debug, Clone, PartialEq, Eq)]
    #[wasm_bindgen(extends = Control)]
    pub type ZoomOptions;
}

impl Zoom {
    /// Creates a new `Zoom` control.
    #[must_use]
    pub fn new(options: &ZoomOptions) -> Self {
        constructor_zoom(options)
    }
}

impl ZoomOptions {
    object_constructor!();

    // ZoomOptions
    object_property_set!(zoom_in_text, zoomInText, &str);
    object_property_set!(zoom_in_title, zoomInTitle, &str);
    object_property_set!(zoom_out_text, zoomOutText, &str);
    object_property_set!(zoom_out_title, zoomOutTitle, &str);

    // ControlOptions
    object_property_set!(position, position, &str);
}

impl Default for ZoomOptions {
    fn default() -> Self {
        ZoomOptions::new()
    }
}