Browse Source

Clamp margin values in `Margin::ui` (#4873)

limit margin value in `settings.ui()`.

Issues: If the `window margin` of `settings.ui()` becomes -10.0 or less,
a panic occurs.
pull/4072/merge
rustbasic 3 months ago
committed by GitHub
parent
commit
378df03910
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 10
      crates/egui/src/style.rs

10
crates/egui/src/style.rs

@ -2222,7 +2222,7 @@ impl Widget for &mut Margin {
ui.checkbox(&mut same, "same");
let mut value = self.left;
ui.add(DragValue::new(&mut value));
ui.add(DragValue::new(&mut value).range(0.0..=100.0));
*self = Margin::same(value);
})
.response
@ -2232,19 +2232,19 @@ impl Widget for &mut Margin {
crate::Grid::new("margin").num_columns(2).show(ui, |ui| {
ui.label("Left");
ui.add(DragValue::new(&mut self.left));
ui.add(DragValue::new(&mut self.left).range(0.0..=100.0));
ui.end_row();
ui.label("Right");
ui.add(DragValue::new(&mut self.right));
ui.add(DragValue::new(&mut self.right).range(0.0..=100.0));
ui.end_row();
ui.label("Top");
ui.add(DragValue::new(&mut self.top));
ui.add(DragValue::new(&mut self.top).range(0.0..=100.0));
ui.end_row();
ui.label("Bottom");
ui.add(DragValue::new(&mut self.bottom));
ui.add(DragValue::new(&mut self.bottom).range(0.0..=100.0));
ui.end_row();
});
})

Loading…
Cancel
Save