mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Make sure plot size is positive (#4429)
* Closes #4425 Fix: in Plot, Minimum values for screen protection.
This commit is contained in:
@@ -97,11 +97,13 @@ impl super::View for ContextMenus {
|
|||||||
egui::Grid::new("button_grid").show(ui, |ui| {
|
egui::Grid::new("button_grid").show(ui, |ui| {
|
||||||
ui.add(
|
ui.add(
|
||||||
egui::DragValue::new(&mut self.width)
|
egui::DragValue::new(&mut self.width)
|
||||||
|
.clamp_range(0.0..=f32::INFINITY)
|
||||||
.speed(1.0)
|
.speed(1.0)
|
||||||
.prefix("Width: "),
|
.prefix("Width: "),
|
||||||
);
|
);
|
||||||
ui.add(
|
ui.add(
|
||||||
egui::DragValue::new(&mut self.height)
|
egui::DragValue::new(&mut self.height)
|
||||||
|
.clamp_range(0.0..=f32::INFINITY)
|
||||||
.speed(1.0)
|
.speed(1.0)
|
||||||
.prefix("Height: "),
|
.prefix("Height: "),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -742,7 +742,7 @@ impl Plot {
|
|||||||
margin_fraction,
|
margin_fraction,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
min_size,
|
mut min_size,
|
||||||
data_aspect,
|
data_aspect,
|
||||||
view_aspect,
|
view_aspect,
|
||||||
mut show_x,
|
mut show_x,
|
||||||
@@ -773,6 +773,10 @@ impl Plot {
|
|||||||
|
|
||||||
// Determine position of widget.
|
// Determine position of widget.
|
||||||
let pos = ui.available_rect_before_wrap().min;
|
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.
|
// Determine size of widget.
|
||||||
let size = {
|
let size = {
|
||||||
let width = width
|
let width = width
|
||||||
|
|||||||
Reference in New Issue
Block a user