2024-03-23 09:09:05 -05:00
|
|
|
use crate::rect::{Corners, 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-23 11:54:47 -05:00
|
|
|
impl<T: Into<FrameLayer>> From<T> for Frame {
|
2024-03-23 09:09:05 -05:00
|
|
|
fn from(layer: T) -> Self {
|
2024-03-22 19:57:07 -05:00
|
|
|
let mut frame = Self::default();
|
2024-03-23 09:09:05 -05:00
|
|
|
frame.add(layer.into());
|
2024-03-22 19:57:07 -05:00
|
|
|
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
|
|
|
}
|