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

View File

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

View File

@@ -125,7 +125,7 @@ impl Client {
.span(Dir::DOWN) .span(Dir::DOWN)
.add_static(&mut ui); .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 msg_area = (Rect::new(Color::SKY), texts.scroll().masked()).stack();
let add_text = text("add") let add_text = text("add")
.editable() .editable()