Skip to content

Commit 3b3ce22

Browse files
authored
Make sure plot size is positive (#4429)
* Closes #4425 Fix: in Plot, Minimum values for screen protection.
1 parent e06b225 commit 3b3ce22

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

crates/egui_demo_lib/src/demo/context_menu.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,13 @@ impl super::View for ContextMenus {
9797
egui::Grid::new("button_grid").show(ui, |ui| {
9898
ui.add(
9999
egui::DragValue::new(&mut self.width)
100+
.clamp_range(0.0..=f32::INFINITY)
100101
.speed(1.0)
101102
.prefix("Width: "),
102103
);
103104
ui.add(
104105
egui::DragValue::new(&mut self.height)
106+
.clamp_range(0.0..=f32::INFINITY)
105107
.speed(1.0)
106108
.prefix("Height: "),
107109
);

crates/egui_plot/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ impl Plot {
742742
margin_fraction,
743743
width,
744744
height,
745-
min_size,
745+
mut min_size,
746746
data_aspect,
747747
view_aspect,
748748
mut show_x,
@@ -773,6 +773,10 @@ impl Plot {
773773

774774
// Determine position of widget.
775775
let pos = ui.available_rect_before_wrap().min;
776+
// Minimum values for screen protection
777+
min_size.x = min_size.x.at_least(1.0);
778+
min_size.y = min_size.y.at_least(1.0);
779+
776780
// Determine size of widget.
777781
let size = {
778782
let width = width

0 commit comments

Comments
 (0)