use crate::ui::ViewContext;
use crate::ui::layouts::Layoutable;
use crate::ui::workspace::UiView;
#[derive(Debug, Clone)]
pub struct Spacer {
pub rect: [f32; 4], pub flexible: bool, }
impl Spacer {
pub fn new(width: f32, height: f32) -> Self {
Self {
rect: [0.0, 0.0, width, height],
flexible: false,
}
}
pub fn flexible() -> Self {
Self {
rect: [0.0, 0.0, 0.0, 0.0], flexible: true,
}
}
}
impl UiView for Spacer {
fn build(&mut self, _ctx: &mut ViewContext) {
}
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
}
impl Layoutable for Spacer {
fn set_layout_rect(&mut self, rect: [f32; 4]) {
self.rect = rect;
}
fn get_desired_size(&self) -> Option<[f32; 2]> {
let [_x, _y, w, h] = self.rect;
Some([w, h])
}
}