kas-core 0.17.0

KAS GUI / core
Documentation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License in the LICENSE-APACHE file or at:
//     https://www.apache.org/licenses/LICENSE-2.0

//! Action types

#[allow(unused)]
use crate::event::{ConfigCx, EventCx, EventState};

/// Action: widget has moved/opened/closed
///
/// This action indicates that the following should happen:
///
/// -   Re-probe which widget is under the mouse / any touch instance / any
///     other location picker since widgets may have moved
/// -   Redraw the window
#[must_use]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct ActionMoved;

/// Action: widget must be resized
///
/// This type implies that either a local or full-window resize is required.
#[must_use]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct ActionResize;

/// Action: content must be redrawn
#[must_use]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct ActionRedraw;

/// Action: close window
#[must_use]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub(crate) struct ActionClose;

bitflags! {
    /// Action: configuration data updates must be applied
    #[must_use]
    #[derive(Copy, Clone, Debug, Default)]
    pub struct ConfigAction: u32 {
        /// Event configuration data must be updated
        const EVENT = 1 << 0;
        /// Theme configuration data must be updated
        const THEME = 1 << 10;
        /// The theme must be switched
        const THEME_SWITCH = 1 << 12;
    }
}

/// Set of actions which may affect a window
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub(crate) struct WindowActions {
    pub resize: Option<ActionResize>,
    pub redraw: Option<ActionRedraw>,
    pub close: Option<ActionClose>,
}