mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-23 15:48:42 -06:00
30 lines
626 B
Rust
30 lines
626 B
Rust
use glam::vec2;
|
|
use crate::{
|
|
element::{MeasureContext, ProcessContext, UiElement},
|
|
measure::Response,
|
|
layout::UiDirection
|
|
};
|
|
|
|
pub struct Spacer(pub f32);
|
|
|
|
impl Default for Spacer {
|
|
fn default() -> Self {
|
|
Self(5.)
|
|
}
|
|
}
|
|
|
|
impl UiElement for Spacer {
|
|
fn measure(&self, ctx: MeasureContext) -> Response {
|
|
Response {
|
|
size: match ctx.layout.direction {
|
|
UiDirection::Horizontal => vec2(self.0, 0.),
|
|
UiDirection::Vertical => vec2(0., self.0),
|
|
},
|
|
hints: Default::default(),
|
|
user_data: None
|
|
}
|
|
}
|
|
|
|
fn process(&self, _ctx: ProcessContext) {}
|
|
}
|