View hbias worlds
This commit is contained in:
+8
-5
@@ -34,10 +34,11 @@ pub trait UiExt {
|
||||
|
||||
impl UiExt for Ui {
|
||||
fn section(&mut self, title: impl Into<String>, add_contents: impl FnOnce(&mut Ui)) {
|
||||
let title: String = title.into();
|
||||
let mut frame = Frame::group(self.style());
|
||||
frame.outer_margin.top += 10.0;
|
||||
frame.inner_margin.top += 2.0;
|
||||
let res = frame.show(self, add_contents);
|
||||
let res = self.push_id(&title, |ui| frame.show(ui, add_contents));
|
||||
let text = RichText::new(title).background_color(self.style().visuals.panel_fill);
|
||||
let old_rect = res.response.rect;
|
||||
let mut text_rect = old_rect;
|
||||
@@ -133,12 +134,14 @@ impl<'a, T: Number> NumberEdit<'a, T> {
|
||||
|
||||
impl<T: Number> Widget for NumberEdit<'_, T> {
|
||||
fn ui(self, ui: &mut Ui) -> Response {
|
||||
let id = ui.id();
|
||||
|
||||
let (last_value, mut str, focus) = ui.memory(|m| {
|
||||
let (lv, s) = m
|
||||
.data
|
||||
.get_temp(ui.id())
|
||||
.get_temp(id)
|
||||
.unwrap_or((*self.value, self.value.to_string()));
|
||||
let focus = m.has_focus(ui.id());
|
||||
let focus = m.has_focus(id);
|
||||
(lv, s, focus)
|
||||
});
|
||||
let mut stale = false;
|
||||
@@ -174,7 +177,7 @@ impl<T: Number> Widget for NumberEdit<'_, T> {
|
||||
}
|
||||
let text = TextEdit::singleline(&mut str)
|
||||
.horizontal_align(Align::Max)
|
||||
.id(ui.id())
|
||||
.id(id)
|
||||
.margin(Margin {
|
||||
left: 4.0,
|
||||
right: 20.0,
|
||||
@@ -242,7 +245,7 @@ impl<T: Number> Widget for NumberEdit<'_, T> {
|
||||
stale = true;
|
||||
}
|
||||
if stale {
|
||||
ui.memory_mut(|m| m.data.insert_temp(ui.id(), (*self.value, str)));
|
||||
ui.memory_mut(|m| m.data.insert_temp(id, (*self.value, str)));
|
||||
}
|
||||
res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user