Skip to main content

ActionMap

Struct ActionMap 

Source
pub struct ActionMap { /* private fields */ }

Implementations§

Source§

impl ActionMap

Source

pub fn new() -> Self

Examples found in repository?
examples/actions_demo.rs (line 14)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let config = WindowConfig {
9        title: "Actions + Button States".into(),
10        width: 640,
11        height: 240,
12    };
13
14    let mut actions = ActionMap::new();
15    actions.bind_button("toggle_hover", ButtonSource::Key("Character(\"H\")".into()));
16    actions.bind_button("toggle_press", ButtonSource::Key("Character(\"P\")".into()));
17    actions.bind_button("toggle_focus", ButtonSource::Key("Character(\"F\")".into()));
18    actions.bind_button("click", ButtonSource::MouseLeft);
19    actions.bind_axis(
20        "move_x",
21        AxisSource::KeyPair {
22            negative: "Named(ArrowLeft)".into(),
23            positive: "Named(ArrowRight)".into(),
24        },
25        1.0,
26        0.0,
27    );
28
29    let mut state = ButtonVisualState {
30        hovered: false,
31        pressed: false,
32        focused: false,
33    };
34    let style = ButtonStyle::default();
35
36    run_app(config, move |engine, frame| {
37        engine.begin_frame();
38        // Background
39        let bg = Rectangle::new(0.0, 0.0, 640.0, 240.0);
40        engine.draw_rect(bg, [0.10, 0.11, 0.14, 1.0], 0.0, None, 0);
41
42        let (pressed_actions, axes) = actions.resolve(frame);
43        if pressed_actions.contains("toggle_hover") {
44            state.hovered = !state.hovered;
45        }
46        if pressed_actions.contains("toggle_press") || pressed_actions.contains("click") {
47            state.pressed = !state.pressed;
48        }
49        if pressed_actions.contains("toggle_focus") {
50            state.focused = !state.focused;
51        }
52        let dx = axes.get("move_x").copied().unwrap_or(0.0) * 3.0;
53
54        let rect = Rectangle::new(80.0 + dx, 80.0, 200.0, 64.0);
55        // Base panel behind
56        engine.draw_rect(
57            Rectangle::new(
58                rect.x - 16.0,
59                rect.y - 16.0,
60                rect.width + 32.0,
61                rect.height + 32.0,
62            ),
63            [0.16, 0.17, 0.22, 1.0],
64            8.0,
65            None,
66            1,
67        );
68        draw_button_background(engine, rect, &state, &style, 2);
69
70        engine.end_frame().unwrap();
71    })
72}
More examples
Hide additional examples
examples/ui_primitives.rs (line 15)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let config = WindowConfig {
9        title: "UI Primitives".into(),
10        width: 800,
11        height: 600,
12    };
13
14    let mut focus: bool = true;
15    let mut actions = ActionMap::new();
16    actions.bind_button("toggle_focus", ButtonSource::Key("Character(\"F\")".into()));
17    actions.bind_button("click", ButtonSource::MouseLeft);
18    actions.bind_axis(
19        "move_x",
20        AxisSource::KeyPair {
21            negative: "Named(ArrowLeft)".into(),
22            positive: "Named(ArrowRight)".into(),
23        },
24        1.0,
25        0.0,
26    );
27    run_app(config, move |engine, frame| {
28        engine.begin_frame();
29
30        // Panel
31        let panel = Rectangle::new(80.0, 60.0, 640.0, 420.0);
32        engine.draw_rect(
33            panel,
34            [0.12, 0.12, 0.15, 1.0],
35            12.0,
36            Some(([0.2, 0.2, 0.25, 1.0], 2.0)),
37            0,
38        );
39
40        // Demonstrate nested clipping: clip to panel, then to an inner area
41        engine.push_clip(panel);
42        let inner = Rectangle::new(
43            panel.x + 20.0,
44            panel.y + 20.0,
45            panel.width - 40.0,
46            panel.height - 40.0,
47        );
48        engine.push_clip(inner);
49
50        // Draw content inside inner clip (visible)
51        let inside = Rectangle::new(inner.x + 10.0, inner.y + 10.0, 200.0, 80.0);
52        engine.draw_rect(
53            inside,
54            [0.25, 0.3, 0.6, 1.0],
55            8.0,
56            Some(([0.15, 0.18, 0.4, 1.0], 2.0)),
57            1,
58        );
59
60        // Draw content partially outside inner but inside panel (only the portion inside inner should show)
61        let partly = Rectangle::new(inner.x - 30.0, inner.y + inner.height - 30.0, 120.0, 60.0);
62        engine.draw_rect(partly, [0.2, 0.6, 0.5, 1.0], 6.0, None, 1);
63
64        // Pop inner clip
65        engine.pop_clip();
66
67        // Resolve actions and move demo rect horizontally
68        let (pressed, axes) = actions.resolve(frame);
69        if pressed.contains("toggle_focus") || pressed.contains("click") {
70            focus = !focus;
71        }
72        let dx = axes.get("move_x").copied().unwrap_or(0.0) * 2.0;
73
74        // Draw something outside inner but inside panel (visible now that inner clip popped)
75        let ring_area = Rectangle::new(panel.x + 300.0 + dx, panel.y + 280.0, 220.0, 100.0);
76        engine.draw_rect(ring_area, [0.18, 0.18, 0.22, 1.0], 10.0, None, 1);
77
78        // Focus ring toggle with mouse click
79        if frame.mouse_info.is_lmb_clicked {
80            focus = !focus;
81        }
82        if focus {
83            draw_focus_ring(
84                engine,
85                Rectangle::new(
86                    ring_area.x - 4.0,
87                    ring_area.y - 4.0,
88                    ring_area.width + 8.0,
89                    ring_area.height + 8.0,
90                ),
91                FocusRingStyle {
92                    thickness_px: 2.0,
93                    color: [1.0, 0.9, 0.2, 1.0],
94                    corner_radius_px: 10.0,
95                    inset_px: 0.0,
96                },
97                2,
98            );
99        }
100
101        // Pop outer clip (panel)
102        engine.pop_clip();
103
104        // Draw an out-of-panel rect to show clipping difference (should not be clipped anymore)
105        let outside_panel = Rectangle::new(panel.x - 30.0, panel.y - 30.0, 40.0, 40.0);
106        engine.draw_rect(outside_panel, [0.8, 0.2, 0.2, 1.0], 4.0, None, 0);
107
108        // End frame
109        engine.end_frame().unwrap();
110    })?;
111
112    Ok(())
113}
Source

pub fn bind_button(&mut self, action: impl Into<String>, source: ButtonSource)

Examples found in repository?
examples/actions_demo.rs (line 15)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let config = WindowConfig {
9        title: "Actions + Button States".into(),
10        width: 640,
11        height: 240,
12    };
13
14    let mut actions = ActionMap::new();
15    actions.bind_button("toggle_hover", ButtonSource::Key("Character(\"H\")".into()));
16    actions.bind_button("toggle_press", ButtonSource::Key("Character(\"P\")".into()));
17    actions.bind_button("toggle_focus", ButtonSource::Key("Character(\"F\")".into()));
18    actions.bind_button("click", ButtonSource::MouseLeft);
19    actions.bind_axis(
20        "move_x",
21        AxisSource::KeyPair {
22            negative: "Named(ArrowLeft)".into(),
23            positive: "Named(ArrowRight)".into(),
24        },
25        1.0,
26        0.0,
27    );
28
29    let mut state = ButtonVisualState {
30        hovered: false,
31        pressed: false,
32        focused: false,
33    };
34    let style = ButtonStyle::default();
35
36    run_app(config, move |engine, frame| {
37        engine.begin_frame();
38        // Background
39        let bg = Rectangle::new(0.0, 0.0, 640.0, 240.0);
40        engine.draw_rect(bg, [0.10, 0.11, 0.14, 1.0], 0.0, None, 0);
41
42        let (pressed_actions, axes) = actions.resolve(frame);
43        if pressed_actions.contains("toggle_hover") {
44            state.hovered = !state.hovered;
45        }
46        if pressed_actions.contains("toggle_press") || pressed_actions.contains("click") {
47            state.pressed = !state.pressed;
48        }
49        if pressed_actions.contains("toggle_focus") {
50            state.focused = !state.focused;
51        }
52        let dx = axes.get("move_x").copied().unwrap_or(0.0) * 3.0;
53
54        let rect = Rectangle::new(80.0 + dx, 80.0, 200.0, 64.0);
55        // Base panel behind
56        engine.draw_rect(
57            Rectangle::new(
58                rect.x - 16.0,
59                rect.y - 16.0,
60                rect.width + 32.0,
61                rect.height + 32.0,
62            ),
63            [0.16, 0.17, 0.22, 1.0],
64            8.0,
65            None,
66            1,
67        );
68        draw_button_background(engine, rect, &state, &style, 2);
69
70        engine.end_frame().unwrap();
71    })
72}
More examples
Hide additional examples
examples/ui_primitives.rs (line 16)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let config = WindowConfig {
9        title: "UI Primitives".into(),
10        width: 800,
11        height: 600,
12    };
13
14    let mut focus: bool = true;
15    let mut actions = ActionMap::new();
16    actions.bind_button("toggle_focus", ButtonSource::Key("Character(\"F\")".into()));
17    actions.bind_button("click", ButtonSource::MouseLeft);
18    actions.bind_axis(
19        "move_x",
20        AxisSource::KeyPair {
21            negative: "Named(ArrowLeft)".into(),
22            positive: "Named(ArrowRight)".into(),
23        },
24        1.0,
25        0.0,
26    );
27    run_app(config, move |engine, frame| {
28        engine.begin_frame();
29
30        // Panel
31        let panel = Rectangle::new(80.0, 60.0, 640.0, 420.0);
32        engine.draw_rect(
33            panel,
34            [0.12, 0.12, 0.15, 1.0],
35            12.0,
36            Some(([0.2, 0.2, 0.25, 1.0], 2.0)),
37            0,
38        );
39
40        // Demonstrate nested clipping: clip to panel, then to an inner area
41        engine.push_clip(panel);
42        let inner = Rectangle::new(
43            panel.x + 20.0,
44            panel.y + 20.0,
45            panel.width - 40.0,
46            panel.height - 40.0,
47        );
48        engine.push_clip(inner);
49
50        // Draw content inside inner clip (visible)
51        let inside = Rectangle::new(inner.x + 10.0, inner.y + 10.0, 200.0, 80.0);
52        engine.draw_rect(
53            inside,
54            [0.25, 0.3, 0.6, 1.0],
55            8.0,
56            Some(([0.15, 0.18, 0.4, 1.0], 2.0)),
57            1,
58        );
59
60        // Draw content partially outside inner but inside panel (only the portion inside inner should show)
61        let partly = Rectangle::new(inner.x - 30.0, inner.y + inner.height - 30.0, 120.0, 60.0);
62        engine.draw_rect(partly, [0.2, 0.6, 0.5, 1.0], 6.0, None, 1);
63
64        // Pop inner clip
65        engine.pop_clip();
66
67        // Resolve actions and move demo rect horizontally
68        let (pressed, axes) = actions.resolve(frame);
69        if pressed.contains("toggle_focus") || pressed.contains("click") {
70            focus = !focus;
71        }
72        let dx = axes.get("move_x").copied().unwrap_or(0.0) * 2.0;
73
74        // Draw something outside inner but inside panel (visible now that inner clip popped)
75        let ring_area = Rectangle::new(panel.x + 300.0 + dx, panel.y + 280.0, 220.0, 100.0);
76        engine.draw_rect(ring_area, [0.18, 0.18, 0.22, 1.0], 10.0, None, 1);
77
78        // Focus ring toggle with mouse click
79        if frame.mouse_info.is_lmb_clicked {
80            focus = !focus;
81        }
82        if focus {
83            draw_focus_ring(
84                engine,
85                Rectangle::new(
86                    ring_area.x - 4.0,
87                    ring_area.y - 4.0,
88                    ring_area.width + 8.0,
89                    ring_area.height + 8.0,
90                ),
91                FocusRingStyle {
92                    thickness_px: 2.0,
93                    color: [1.0, 0.9, 0.2, 1.0],
94                    corner_radius_px: 10.0,
95                    inset_px: 0.0,
96                },
97                2,
98            );
99        }
100
101        // Pop outer clip (panel)
102        engine.pop_clip();
103
104        // Draw an out-of-panel rect to show clipping difference (should not be clipped anymore)
105        let outside_panel = Rectangle::new(panel.x - 30.0, panel.y - 30.0, 40.0, 40.0);
106        engine.draw_rect(outside_panel, [0.8, 0.2, 0.2, 1.0], 4.0, None, 0);
107
108        // End frame
109        engine.end_frame().unwrap();
110    })?;
111
112    Ok(())
113}
Source

pub fn bind_axis( &mut self, axis: impl Into<String>, source: AxisSource, scale: f32, deadzone: f32, )

Examples found in repository?
examples/actions_demo.rs (lines 19-27)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let config = WindowConfig {
9        title: "Actions + Button States".into(),
10        width: 640,
11        height: 240,
12    };
13
14    let mut actions = ActionMap::new();
15    actions.bind_button("toggle_hover", ButtonSource::Key("Character(\"H\")".into()));
16    actions.bind_button("toggle_press", ButtonSource::Key("Character(\"P\")".into()));
17    actions.bind_button("toggle_focus", ButtonSource::Key("Character(\"F\")".into()));
18    actions.bind_button("click", ButtonSource::MouseLeft);
19    actions.bind_axis(
20        "move_x",
21        AxisSource::KeyPair {
22            negative: "Named(ArrowLeft)".into(),
23            positive: "Named(ArrowRight)".into(),
24        },
25        1.0,
26        0.0,
27    );
28
29    let mut state = ButtonVisualState {
30        hovered: false,
31        pressed: false,
32        focused: false,
33    };
34    let style = ButtonStyle::default();
35
36    run_app(config, move |engine, frame| {
37        engine.begin_frame();
38        // Background
39        let bg = Rectangle::new(0.0, 0.0, 640.0, 240.0);
40        engine.draw_rect(bg, [0.10, 0.11, 0.14, 1.0], 0.0, None, 0);
41
42        let (pressed_actions, axes) = actions.resolve(frame);
43        if pressed_actions.contains("toggle_hover") {
44            state.hovered = !state.hovered;
45        }
46        if pressed_actions.contains("toggle_press") || pressed_actions.contains("click") {
47            state.pressed = !state.pressed;
48        }
49        if pressed_actions.contains("toggle_focus") {
50            state.focused = !state.focused;
51        }
52        let dx = axes.get("move_x").copied().unwrap_or(0.0) * 3.0;
53
54        let rect = Rectangle::new(80.0 + dx, 80.0, 200.0, 64.0);
55        // Base panel behind
56        engine.draw_rect(
57            Rectangle::new(
58                rect.x - 16.0,
59                rect.y - 16.0,
60                rect.width + 32.0,
61                rect.height + 32.0,
62            ),
63            [0.16, 0.17, 0.22, 1.0],
64            8.0,
65            None,
66            1,
67        );
68        draw_button_background(engine, rect, &state, &style, 2);
69
70        engine.end_frame().unwrap();
71    })
72}
More examples
Hide additional examples
examples/ui_primitives.rs (lines 18-26)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let config = WindowConfig {
9        title: "UI Primitives".into(),
10        width: 800,
11        height: 600,
12    };
13
14    let mut focus: bool = true;
15    let mut actions = ActionMap::new();
16    actions.bind_button("toggle_focus", ButtonSource::Key("Character(\"F\")".into()));
17    actions.bind_button("click", ButtonSource::MouseLeft);
18    actions.bind_axis(
19        "move_x",
20        AxisSource::KeyPair {
21            negative: "Named(ArrowLeft)".into(),
22            positive: "Named(ArrowRight)".into(),
23        },
24        1.0,
25        0.0,
26    );
27    run_app(config, move |engine, frame| {
28        engine.begin_frame();
29
30        // Panel
31        let panel = Rectangle::new(80.0, 60.0, 640.0, 420.0);
32        engine.draw_rect(
33            panel,
34            [0.12, 0.12, 0.15, 1.0],
35            12.0,
36            Some(([0.2, 0.2, 0.25, 1.0], 2.0)),
37            0,
38        );
39
40        // Demonstrate nested clipping: clip to panel, then to an inner area
41        engine.push_clip(panel);
42        let inner = Rectangle::new(
43            panel.x + 20.0,
44            panel.y + 20.0,
45            panel.width - 40.0,
46            panel.height - 40.0,
47        );
48        engine.push_clip(inner);
49
50        // Draw content inside inner clip (visible)
51        let inside = Rectangle::new(inner.x + 10.0, inner.y + 10.0, 200.0, 80.0);
52        engine.draw_rect(
53            inside,
54            [0.25, 0.3, 0.6, 1.0],
55            8.0,
56            Some(([0.15, 0.18, 0.4, 1.0], 2.0)),
57            1,
58        );
59
60        // Draw content partially outside inner but inside panel (only the portion inside inner should show)
61        let partly = Rectangle::new(inner.x - 30.0, inner.y + inner.height - 30.0, 120.0, 60.0);
62        engine.draw_rect(partly, [0.2, 0.6, 0.5, 1.0], 6.0, None, 1);
63
64        // Pop inner clip
65        engine.pop_clip();
66
67        // Resolve actions and move demo rect horizontally
68        let (pressed, axes) = actions.resolve(frame);
69        if pressed.contains("toggle_focus") || pressed.contains("click") {
70            focus = !focus;
71        }
72        let dx = axes.get("move_x").copied().unwrap_or(0.0) * 2.0;
73
74        // Draw something outside inner but inside panel (visible now that inner clip popped)
75        let ring_area = Rectangle::new(panel.x + 300.0 + dx, panel.y + 280.0, 220.0, 100.0);
76        engine.draw_rect(ring_area, [0.18, 0.18, 0.22, 1.0], 10.0, None, 1);
77
78        // Focus ring toggle with mouse click
79        if frame.mouse_info.is_lmb_clicked {
80            focus = !focus;
81        }
82        if focus {
83            draw_focus_ring(
84                engine,
85                Rectangle::new(
86                    ring_area.x - 4.0,
87                    ring_area.y - 4.0,
88                    ring_area.width + 8.0,
89                    ring_area.height + 8.0,
90                ),
91                FocusRingStyle {
92                    thickness_px: 2.0,
93                    color: [1.0, 0.9, 0.2, 1.0],
94                    corner_radius_px: 10.0,
95                    inset_px: 0.0,
96                },
97                2,
98            );
99        }
100
101        // Pop outer clip (panel)
102        engine.pop_clip();
103
104        // Draw an out-of-panel rect to show clipping difference (should not be clipped anymore)
105        let outside_panel = Rectangle::new(panel.x - 30.0, panel.y - 30.0, 40.0, 40.0);
106        engine.draw_rect(outside_panel, [0.8, 0.2, 0.2, 1.0], 4.0, None, 0);
107
108        // End frame
109        engine.end_frame().unwrap();
110    })?;
111
112    Ok(())
113}
Source

pub fn resolve( &self, frame: &FrameContext, ) -> (HashSet<String>, HashMap<String, f32>)

Examples found in repository?
examples/actions_demo.rs (line 42)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let config = WindowConfig {
9        title: "Actions + Button States".into(),
10        width: 640,
11        height: 240,
12    };
13
14    let mut actions = ActionMap::new();
15    actions.bind_button("toggle_hover", ButtonSource::Key("Character(\"H\")".into()));
16    actions.bind_button("toggle_press", ButtonSource::Key("Character(\"P\")".into()));
17    actions.bind_button("toggle_focus", ButtonSource::Key("Character(\"F\")".into()));
18    actions.bind_button("click", ButtonSource::MouseLeft);
19    actions.bind_axis(
20        "move_x",
21        AxisSource::KeyPair {
22            negative: "Named(ArrowLeft)".into(),
23            positive: "Named(ArrowRight)".into(),
24        },
25        1.0,
26        0.0,
27    );
28
29    let mut state = ButtonVisualState {
30        hovered: false,
31        pressed: false,
32        focused: false,
33    };
34    let style = ButtonStyle::default();
35
36    run_app(config, move |engine, frame| {
37        engine.begin_frame();
38        // Background
39        let bg = Rectangle::new(0.0, 0.0, 640.0, 240.0);
40        engine.draw_rect(bg, [0.10, 0.11, 0.14, 1.0], 0.0, None, 0);
41
42        let (pressed_actions, axes) = actions.resolve(frame);
43        if pressed_actions.contains("toggle_hover") {
44            state.hovered = !state.hovered;
45        }
46        if pressed_actions.contains("toggle_press") || pressed_actions.contains("click") {
47            state.pressed = !state.pressed;
48        }
49        if pressed_actions.contains("toggle_focus") {
50            state.focused = !state.focused;
51        }
52        let dx = axes.get("move_x").copied().unwrap_or(0.0) * 3.0;
53
54        let rect = Rectangle::new(80.0 + dx, 80.0, 200.0, 64.0);
55        // Base panel behind
56        engine.draw_rect(
57            Rectangle::new(
58                rect.x - 16.0,
59                rect.y - 16.0,
60                rect.width + 32.0,
61                rect.height + 32.0,
62            ),
63            [0.16, 0.17, 0.22, 1.0],
64            8.0,
65            None,
66            1,
67        );
68        draw_button_background(engine, rect, &state, &style, 2);
69
70        engine.end_frame().unwrap();
71    })
72}
More examples
Hide additional examples
examples/ui_primitives.rs (line 68)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let config = WindowConfig {
9        title: "UI Primitives".into(),
10        width: 800,
11        height: 600,
12    };
13
14    let mut focus: bool = true;
15    let mut actions = ActionMap::new();
16    actions.bind_button("toggle_focus", ButtonSource::Key("Character(\"F\")".into()));
17    actions.bind_button("click", ButtonSource::MouseLeft);
18    actions.bind_axis(
19        "move_x",
20        AxisSource::KeyPair {
21            negative: "Named(ArrowLeft)".into(),
22            positive: "Named(ArrowRight)".into(),
23        },
24        1.0,
25        0.0,
26    );
27    run_app(config, move |engine, frame| {
28        engine.begin_frame();
29
30        // Panel
31        let panel = Rectangle::new(80.0, 60.0, 640.0, 420.0);
32        engine.draw_rect(
33            panel,
34            [0.12, 0.12, 0.15, 1.0],
35            12.0,
36            Some(([0.2, 0.2, 0.25, 1.0], 2.0)),
37            0,
38        );
39
40        // Demonstrate nested clipping: clip to panel, then to an inner area
41        engine.push_clip(panel);
42        let inner = Rectangle::new(
43            panel.x + 20.0,
44            panel.y + 20.0,
45            panel.width - 40.0,
46            panel.height - 40.0,
47        );
48        engine.push_clip(inner);
49
50        // Draw content inside inner clip (visible)
51        let inside = Rectangle::new(inner.x + 10.0, inner.y + 10.0, 200.0, 80.0);
52        engine.draw_rect(
53            inside,
54            [0.25, 0.3, 0.6, 1.0],
55            8.0,
56            Some(([0.15, 0.18, 0.4, 1.0], 2.0)),
57            1,
58        );
59
60        // Draw content partially outside inner but inside panel (only the portion inside inner should show)
61        let partly = Rectangle::new(inner.x - 30.0, inner.y + inner.height - 30.0, 120.0, 60.0);
62        engine.draw_rect(partly, [0.2, 0.6, 0.5, 1.0], 6.0, None, 1);
63
64        // Pop inner clip
65        engine.pop_clip();
66
67        // Resolve actions and move demo rect horizontally
68        let (pressed, axes) = actions.resolve(frame);
69        if pressed.contains("toggle_focus") || pressed.contains("click") {
70            focus = !focus;
71        }
72        let dx = axes.get("move_x").copied().unwrap_or(0.0) * 2.0;
73
74        // Draw something outside inner but inside panel (visible now that inner clip popped)
75        let ring_area = Rectangle::new(panel.x + 300.0 + dx, panel.y + 280.0, 220.0, 100.0);
76        engine.draw_rect(ring_area, [0.18, 0.18, 0.22, 1.0], 10.0, None, 1);
77
78        // Focus ring toggle with mouse click
79        if frame.mouse_info.is_lmb_clicked {
80            focus = !focus;
81        }
82        if focus {
83            draw_focus_ring(
84                engine,
85                Rectangle::new(
86                    ring_area.x - 4.0,
87                    ring_area.y - 4.0,
88                    ring_area.width + 8.0,
89                    ring_area.height + 8.0,
90                ),
91                FocusRingStyle {
92                    thickness_px: 2.0,
93                    color: [1.0, 0.9, 0.2, 1.0],
94                    corner_radius_px: 10.0,
95                    inset_px: 0.0,
96                },
97                2,
98            );
99        }
100
101        // Pop outer clip (panel)
102        engine.pop_clip();
103
104        // Draw an out-of-panel rect to show clipping difference (should not be clipped anymore)
105        let outside_panel = Rectangle::new(panel.x - 30.0, panel.y - 30.0, 40.0, 40.0);
106        engine.draw_rect(outside_panel, [0.8, 0.2, 0.2, 1.0], 4.0, None, 0);
107
108        // End frame
109        engine.end_frame().unwrap();
110    })?;
111
112    Ok(())
113}

Trait Implementations§

Source§

impl Clone for ActionMap

Source§

fn clone(&self) -> ActionMap

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActionMap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ActionMap

Source§

fn default() -> ActionMap

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,