2024-03-22 19:57:07 -05:00
|
|
|
use crate::rect::FillColor;
|
2024-03-22 12:33:34 -05:00
|
|
|
|
2024-03-22 19:57:07 -05:00
|
|
|
pub mod point;
|
|
|
|
pub mod layer;
|
2024-03-22 13:35:00 -05:00
|
|
|
|
2024-03-22 19:57:07 -05:00
|
|
|
use layer::{FrameLayer, RectLayer};
|
2024-03-22 12:33:34 -05:00
|
|
|
|
2024-03-22 19:57:07 -05:00
|
|
|
///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)
|
|
|
|
///aka Frame::Rectangle, Frame::NinePatch, ...
|
2024-03-22 13:35:00 -05:00
|
|
|
|
2024-03-22 19:57:07 -05:00
|
|
|
/// 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>
|
2024-03-22 12:33:34 -05:00
|
|
|
}
|
|
|
|
|
2024-03-22 19:57:07 -05:00
|
|
|
impl<T: Into<FillColor>> From<T> for Frame {
|
|
|
|
fn from(color: T) -> Self {
|
|
|
|
let mut frame = Self::default();
|
|
|
|
frame.add(RectLayer::from_color(color));
|
|
|
|
frame
|
2024-03-22 12:33:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-22 19:57:07 -05:00
|
|
|
impl Frame {
|
|
|
|
pub fn add(&mut self, layer: impl Into<FrameLayer>) -> &mut Self {
|
|
|
|
self.layers.push(layer.into());
|
|
|
|
self
|
2024-03-22 12:33:34 -05:00
|
|
|
}
|
|
|
|
}
|