use crate::Node;
#[derive(Clone, Debug)]
pub struct LayerState {
pub root_node: Option<Node>,
pub visible: bool,
pub opacity: f32,
pub transform: [f32; 2],
pub scale: f32,
pub focused_node: Option<Node>,
pub saved_focus: Option<Node>,
}
impl Default for LayerState {
fn default() -> Self {
Self {
root_node: None,
visible: true,
opacity: 1.0,
transform: [0.0, 0.0],
scale: 1.0,
focused_node: None,
saved_focus: None,
}
}
}
impl LayerState {
pub fn hidden() -> Self {
Self {
visible: false,
opacity: 0.0,
..Default::default()
}
}
}
#[derive(Clone, Debug, Default)]
pub struct InternalLayer {
pub state: LayerState,
}
impl InternalLayer {
pub fn new(visible: bool) -> Self {
Self {
state: LayerState {
visible,
opacity: if visible { 1.0 } else { 0.0 },
..Default::default()
},
}
}
}
#[derive(Clone, Debug)]
pub struct UserLayer {
pub id: u32,
pub state: LayerState,
pub blocking: bool,
}
impl UserLayer {
pub fn new(id: u32, visible: bool, blocking: bool) -> Self {
Self {
id,
state: LayerState {
visible,
opacity: if visible { 1.0 } else { 0.0 },
..Default::default()
},
blocking,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ActiveLayerId {
Base,
Intermediate(u32),
Overlay,
Modal,
}