rename spacing to gap

This commit is contained in:
2025-11-13 14:29:03 -05:00
parent 73afea8c35
commit 125fca4075
3 changed files with 8 additions and 8 deletions

View File

@@ -3,7 +3,7 @@ use crate::prelude::*;
pub struct Span {
pub children: Vec<WidgetId>,
pub dir: Dir,
pub spacing: f32,
pub gap: f32,
}
impl Widget for Span {
@@ -27,14 +27,14 @@ impl Widget for Span {
child_region.flip(self.dir.axis);
}
painter.widget_within(child, child_region);
start.abs += self.spacing;
start.abs += self.gap;
}
}
fn desired_size(&mut self, ctx: &mut SizeCtx) -> Size {
let mut sums = self.len_sum(ctx);
let dir_len = if sums.rest == 0.0 && sums.rel == 0.0 {
sums.abs += self.spacing * self.children.len().saturating_sub(1) as f32;
sums.abs += self.gap * self.children.len().saturating_sub(1) as f32;
sums
} else {
Len::default()
@@ -59,12 +59,12 @@ impl Span {
Self {
children: Vec::new(),
dir,
spacing: 0.0,
gap: 0.0,
}
}
pub fn spacing(mut self, spacing: impl UiNum) -> Self {
self.spacing = spacing.to_f32();
pub fn gap(mut self, gap: impl UiNum) -> Self {
self.gap = gap.to_f32();
self
}

View File

@@ -99,7 +99,7 @@ impl<const LEN: usize, Wa: WidgetArrLike<LEN, Tag>, Tag> CoreWidgetArr<LEN, Wa,
move |ui| Span {
children: self.ui(ui).arr.to_vec(),
dir,
spacing: 0.0,
gap: 0.0,
}
}
fn stack(self) -> StackBuilder<LEN, Wa, Tag> {

View File

@@ -125,7 +125,7 @@ impl Client {
.span(Dir::DOWN)
.add_static(&mut ui);
let texts = Span::empty(Dir::DOWN).spacing(10).add_static(&mut ui);
let texts = Span::empty(Dir::DOWN).gap(10).add_static(&mut ui);
let msg_area = (Rect::new(Color::SKY), texts.scroll().masked()).stack();
let add_text = text("add")
.editable()