Skip to main content

kas_core/
action.rs

1// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License in the LICENSE-APACHE file or at:
4//     https://www.apache.org/licenses/LICENSE-2.0
5
6//! Action types
7
8#[allow(unused)]
9use crate::event::{ConfigCx, EventCx, EventState};
10
11/// Action: widget has moved/opened/closed
12///
13/// This action indicates that the following should happen:
14///
15/// -   Re-probe which widget is under the mouse / any touch instance / any
16///     other location picker since widgets may have moved
17/// -   Redraw the window
18#[must_use]
19#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
20pub struct ActionMoved;
21
22/// Action: widget must be resized
23///
24/// This type implies that either a local or full-window resize is required.
25#[must_use]
26#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
27pub struct ActionResize;
28
29/// Action: content must be redrawn
30#[must_use]
31#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
32pub struct ActionRedraw;
33
34/// Action: close window
35#[must_use]
36#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
37pub(crate) struct ActionClose;
38
39bitflags! {
40    /// Action: configuration data updates must be applied
41    #[must_use]
42    #[derive(Copy, Clone, Debug, Default)]
43    pub struct ConfigAction: u32 {
44        /// Event configuration data must be updated
45        const EVENT = 1 << 0;
46        /// Theme configuration data must be updated
47        const THEME = 1 << 10;
48        /// The theme must be switched
49        const THEME_SWITCH = 1 << 12;
50    }
51}
52
53/// Set of actions which may affect a window
54#[derive(Clone, Debug, Default, PartialEq, Eq)]
55pub(crate) struct WindowActions {
56    pub resize: Option<ActionResize>,
57    pub redraw: Option<ActionRedraw>,
58    pub close: Option<ActionClose>,
59}