77
88#[ allow( unused) ]
99use crate :: event:: { ConfigCx , EventCx , EventState } ;
10- use std:: ops:: { BitOr , BitOrAssign , Deref } ;
1110
1211/// Action: widget has moved/opened/closed
1312///
14- /// When the state is `true`, this indicates that the following should happen:
13+ /// This action indicates that the following should happen:
1514///
1615/// - Re-probe which widget is under the mouse / any touch instance / any
1716/// other location picker since widgets may have moved
1817/// - Redraw the window
1918#[ must_use]
20- #[ derive( Copy , Clone , Debug , Default ) ]
21- pub struct ActionMoved ( pub bool ) ;
22-
23- impl BitOr for ActionMoved {
24- type Output = Self ;
25- #[ inline]
26- fn bitor ( self , rhs : Self ) -> Self {
27- ActionMoved ( self . 0 | rhs. 0 )
28- }
29- }
30-
31- impl BitOrAssign for ActionMoved {
32- #[ inline]
33- fn bitor_assign ( & mut self , rhs : Self ) {
34- self . 0 |= rhs. 0 ;
35- }
36- }
37-
38- impl Deref for ActionMoved {
39- type Target = bool ;
40- #[ inline]
41- fn deref ( & self ) -> & bool {
42- & self . 0
43- }
44- }
19+ #[ derive( Copy , Clone , Debug , Default , PartialEq , Eq ) ]
20+ pub struct ActionMoved ;
4521
4622/// Action: widget must be resized
23+ ///
24+ /// This type implies that either a local or full-window resize is required.
4725#[ must_use]
48- #[ derive( Copy , Clone , Debug , Default ) ]
49- pub struct ActionResize ( pub bool ) ;
50-
51- impl ActionResize {
52- #[ inline]
53- pub ( crate ) fn clear ( & mut self ) {
54- self . 0 = false ;
55- }
56- }
26+ #[ derive( Copy , Clone , Debug , Default , PartialEq , Eq ) ]
27+ pub struct ActionResize ;
5728
58- impl BitOr for ActionResize {
59- type Output = Self ;
60- #[ inline]
61- fn bitor ( self , rhs : Self ) -> Self {
62- ActionResize ( self . 0 | rhs. 0 )
63- }
64- }
65-
66- impl BitOrAssign for ActionResize {
67- #[ inline]
68- fn bitor_assign ( & mut self , rhs : Self ) {
69- self . 0 |= rhs. 0 ;
70- }
71- }
29+ /// Action: content must be redrawn
30+ #[ must_use]
31+ #[ derive( Copy , Clone , Debug , Default , PartialEq , Eq ) ]
32+ pub struct ActionRedraw ;
7233
73- impl Deref for ActionResize {
74- type Target = bool ;
75- #[ inline]
76- fn deref ( & self ) -> & bool {
77- & self . 0
78- }
79- }
34+ /// Action: close window
35+ #[ must_use]
36+ #[ derive( Copy , Clone , Debug , Default , PartialEq , Eq ) ]
37+ pub ( crate ) struct ActionClose ;
8038
8139bitflags ! {
8240 /// Action: configuration data updates must be applied
@@ -92,31 +50,10 @@ bitflags! {
9250 }
9351}
9452
95- bitflags ! {
96- /// Action required after processing
97- ///
98- /// Some methods operate directly on a context ([`ConfigCx`] or [`EventCx`])
99- /// while others don't reqiure a context but do require that some *action*
100- /// is performed afterwards. This enum is used to convey that action.
101- ///
102- /// A `WindowAction` produced at run-time should be passed to a context, usually
103- /// via [`EventState::action`] (to associate the `WindowAction` with a widget)
104- /// or [`EventState::window_action`] (if no particular widget is relevant).
105- ///
106- /// A `WindowAction` produced before starting the GUI may be discarded, for
107- /// example: `let _ = runner.config_mut().font.set_size(24.0);`.
108- ///
109- /// Two `WindowAction` values may be combined via bit-or (`a | b`).
110- #[ must_use]
111- #[ derive( Copy , Clone , Debug , Default ) ]
112- pub struct WindowAction : u32 {
113- /// The whole window requires redrawing
114- ///
115- /// See also [`EventState::redraw`].
116- const REDRAW = 1 << 0 ;
117- /// The current window should be closed
118- ///
119- /// See also [`EventState::exit`] which closes the UI (all windows).
120- const CLOSE = 1 << 30 ;
121- }
53+ /// Set of actions which may affect a window
54+ #[ derive( Clone , Debug , Default , PartialEq , Eq ) ]
55+ pub ( crate ) struct WindowActions {
56+ pub resize : Option < ActionResize > ,
57+ pub redraw : Option < ActionRedraw > ,
58+ pub close : Option < ActionClose > ,
12259}
0 commit comments