Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure plot size is positive #4429

Merged
merged 6 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 All @@ -768,6 +768,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(64.0);
min_size.y = min_size.y.at_least(15.0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should do this. If the user wants a plot that is 16x32 pixels big, let them have it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should do this. If the user wants a plot that is 16x32 pixels big, let them have it

If it is greater than 1.0, panic does not occur, so it was set to 1.0.
If you want to edit it to a different size, please do so.


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