hUI/hui/src/element/builtin/spacer.rs

30 lines
626 B
Rust
Raw Normal View History

2024-02-17 14:43:46 -06:00
use glam::vec2;
use crate::{
element::{MeasureContext, ProcessContext, UiElement},
2024-02-17 14:43:46 -06:00
measure::Response,
2024-02-20 10:49:44 -06:00
layout::UiDirection
2024-02-17 14:43:46 -06:00
};
pub struct Spacer(pub f32);
impl Default for Spacer {
fn default() -> Self {
Self(5.)
}
}
impl UiElement for Spacer {
fn measure(&self, ctx: MeasureContext) -> Response {
2024-02-17 14:43:46 -06:00
Response {
size: match ctx.layout.direction {
2024-02-17 14:43:46 -06:00
UiDirection::Horizontal => vec2(self.0, 0.),
UiDirection::Vertical => vec2(0., self.0),
},
hints: Default::default(),
user_data: None
}
}
fn process(&self, _ctx: ProcessContext) {}
2024-02-17 14:43:46 -06:00
}