pub struct ActionMap { /* private fields */ }Implementations§
Source§impl ActionMap
impl ActionMap
Sourcepub fn new() -> Self
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
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}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
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}Sourcepub fn bind_axis(
&mut self,
axis: impl Into<String>,
source: AxisSource,
scale: f32,
deadzone: f32,
)
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
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}Sourcepub fn resolve(
&self,
frame: &FrameContext,
) -> (HashSet<String>, HashMap<String, f32>)
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
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§
Auto Trait Implementations§
impl Freeze for ActionMap
impl RefUnwindSafe for ActionMap
impl Send for ActionMap
impl Sync for ActionMap
impl Unpin for ActionMap
impl UnsafeUnpin for ActionMap
impl UnwindSafe for ActionMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
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().