Skip to content

Commit

Permalink
Make sure plot size is positive (#4429)
Browse files Browse the repository at this point in the history
* Closes #4425 

Fix: in Plot, Minimum values for screen protection.
  • Loading branch information
rustbasic authored May 11, 2024
1 parent e06b225 commit 3b3ce22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions crates/egui_demo_lib/src/demo/context_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ impl super::View for ContextMenus {
egui::Grid::new("button_grid").show(ui, |ui| {
ui.add(
egui::DragValue::new(&mut self.width)
.clamp_range(0.0..=f32::INFINITY)
.speed(1.0)
.prefix("Width: "),
);
ui.add(
egui::DragValue::new(&mut self.height)
.clamp_range(0.0..=f32::INFINITY)
.speed(1.0)
.prefix("Height: "),
);
Expand Down
6 changes: 5 additions & 1 deletion crates/egui_plot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ impl Plot {
margin_fraction,
width,
height,
min_size,
mut min_size,
data_aspect,
view_aspect,
mut show_x,
Expand Down Expand Up @@ -773,6 +773,10 @@ impl Plot {

// Determine position of widget.
let pos = ui.available_rect_before_wrap().min;
// Minimum values for screen protection
min_size.x = min_size.x.at_least(1.0);
min_size.y = min_size.y.at_least(1.0);

// Determine size of widget.
let size = {
let width = width
Expand Down

0 comments on commit 3b3ce22

Please sign in to comment.