Skip to content
Merged
Changes from all 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
15 changes: 5 additions & 10 deletions egui_plot/src/plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,10 +827,8 @@ impl<'a> Plot<'a> {
self.show_dyn(ui, Box::new(build_fn))
}

/// Calculate the rect inside which everything will be drawn.
fn calculate_widget_complete_rect(&self, ui: &Ui) -> Rect {
// Determine position of widget.
let pos = ui.available_rect_before_wrap().min;
/// Allocate the rect inside which everything will be drawn.
fn allocate_widget_complete_rect(&self, ui: &mut Ui) -> Rect {
// Minimum values for screen protection
let mut min_size = self.min_size;
min_size.x = min_size.x.at_least(1.0);
Expand Down Expand Up @@ -862,11 +860,8 @@ impl<'a> Plot<'a> {
vec2(width, height)
};

// Determine complete rect of widget.
Rect {
min: pos,
max: pos + size,
}
// Let the layout place the widget, so we respect its direction, alignment and wrapping.
ui.allocate_space(size).1
}

fn allocate_axis_responses(&self, ui: &mut Ui, axis_widgets: &AxisWidgets<'_>) -> AxisResponses {
Expand Down Expand Up @@ -1635,7 +1630,7 @@ impl<'a> Plot<'a> {
let plot_id = self.id.unwrap_or_else(|| ui.make_persistent_id(self.id_salt));

// Get complete rect for drawing.
let complete_rect = self.calculate_widget_complete_rect(ui);
let complete_rect = self.allocate_widget_complete_rect(ui);

let (axis_widgets, plot_rect) = axis_widgets(
PlotMemory::load(ui.ctx(), plot_id).as_ref(), // TODO(#164): avoid loading plot memory twice
Expand Down
Loading