hUI/hui/src/frame.rs
2024-03-23 15:09:05 +01:00

43 lines
1.1 KiB
Rust

use crate::rect::{Corners, FillColor};
pub mod point;
pub mod layer;
use layer::{FrameLayer, RectLayer};
///XXX: this is not used yet, and also kinda a mess, simplify?
///Maybe limit to a single layer? (aka `Frame` will be just one of the options)
///Because currently, this is just a duplicate of the dormal draw command system, but with a different name...
///Then, there's no need for the positioning stuff too, which is a bit overkill and is kinda code duplication too!
///aka Frame::Rectangle, Frame::NinePatch, ...
/// A frame, which can contain multiple layers
///
/// Use these to construct complex backgrounds
#[derive(Default, Clone)]
pub struct Frame {
/// Layers of the frame
layers: Vec<FrameLayer>
}
impl<T: Into<RectLayer>> From<T> for Frame {
fn from(layer: T) -> Self {
let mut frame = Self::default();
frame.add(layer.into());
frame
}
}
impl Frame {
#[inline]
pub fn add(&mut self, layer: impl Into<FrameLayer>) -> &mut Self {
self.layers.push(layer.into());
self
}
#[inline]
pub fn finish(&mut self) -> Self {
self.clone()
}
}