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)
|
2024-03-22 20:05:44 -05:00
|
|
|
///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!
|
2024-03-22 19:57:07 -05:00
|
|
|
///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 {
|
2024-03-22 20:05:44 -05:00
|
|
|
#[inline]
|
2024-03-22 19:57:07 -05:00
|
|
|
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
|
|
|
}
|
2024-03-22 20:05:44 -05:00
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub fn finish(&mut self) -> Self {
|
|
|
|
self.clone()
|
|
|
|
}
|
2024-03-22 12:33:34 -05:00
|
|
|
}
|