app work
This commit is contained in:
@@ -3,6 +3,7 @@ use crate::prelude::*;
|
||||
pub struct Span {
|
||||
pub children: Vec<(WidgetId, SpanLen)>,
|
||||
pub dir: Dir,
|
||||
pub spacing: f32,
|
||||
}
|
||||
|
||||
impl Widget for Span {
|
||||
@@ -36,6 +37,7 @@ impl Widget for Span {
|
||||
child_region.flip(self.dir.axis);
|
||||
}
|
||||
painter.widget_within(child, child_region);
|
||||
start.abs += self.spacing;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +47,10 @@ impl Widget for Span {
|
||||
let dir_len = if total.ratio != 0.0 {
|
||||
UiScalar::rel_max()
|
||||
} else {
|
||||
UiScalar::new(total.rel, total.abs)
|
||||
UiScalar::new(
|
||||
total.rel,
|
||||
total.abs + self.spacing * self.children.len().saturating_sub(1) as f32,
|
||||
)
|
||||
};
|
||||
let mut max_ortho = UiScalar::ZERO;
|
||||
for (child, _) in &self.children {
|
||||
@@ -68,9 +73,15 @@ impl Span {
|
||||
Self {
|
||||
children: Vec::new(),
|
||||
dir,
|
||||
spacing: 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn spacing(mut self, spacing: impl UiNum) -> Self {
|
||||
self.spacing = spacing.to_f32();
|
||||
self
|
||||
}
|
||||
|
||||
fn setup(&mut self, ctx: &mut SizeCtx) -> SpanLenSums {
|
||||
self.children
|
||||
.iter_mut()
|
||||
|
||||
Reference in New Issue
Block a user