Fix layouts and colors

This commit is contained in:
2025-02-23 21:18:21 -05:00
parent d6957ecd09
commit f7408ac9b7
8 changed files with 78 additions and 29 deletions
+17 -1
View File
@@ -41,7 +41,7 @@ impl UiExt for Ui {
frame.inner_margin.top += 2.0;
let res = self.push_id(&title, |ui| {
frame.show(ui, |ui| {
ui.set_min_width(ui.available_width());
ui.set_max_width(ui.available_width());
add_contents(ui);
})
});
@@ -143,6 +143,7 @@ pub struct NumberEdit<'a, T: Number> {
precision: usize,
min: Option<T>,
max: Option<T>,
desired_width: Option<f32>,
arrows: bool,
hex: bool,
}
@@ -155,6 +156,7 @@ impl<'a, T: Number> NumberEdit<'a, T> {
precision: 3,
min: None,
max: None,
desired_width: None,
arrows: true,
hex: false,
}
@@ -178,6 +180,13 @@ impl<'a, T: Number> NumberEdit<'a, T> {
Self { min, max, ..self }
}
pub fn desired_width(self, desired_width: f32) -> Self {
Self {
desired_width: Some(desired_width),
..self
}
}
pub fn arrows(self, arrows: bool) -> Self {
Self { arrows, ..self }
}
@@ -246,9 +255,16 @@ impl<T: Number> Widget for NumberEdit<'_, T> {
})
});
}
let mut desired_width = self
.desired_width
.unwrap_or_else(|| ui.spacing().text_edit_width);
if self.arrows {
desired_width -= 16.0;
}
let text = TextEdit::singleline(&mut str)
.horizontal_align(Align::Max)
.id(id)
.desired_width(desired_width)
.margin(Margin {
left: 4.0,
right: if self.arrows { 20.0 } else { 4.0 },