`egui_plot`: Add `sense` option to `Plot` (#4052)
This PR adds a `sense` option to `Plot`.
This commit is contained in:
parent
61b53ae937
commit
62e80c7729
|
|
@ -181,6 +181,8 @@ pub struct Plot {
|
||||||
grid_spacers: [GridSpacer; 2],
|
grid_spacers: [GridSpacer; 2],
|
||||||
sharp_grid_lines: bool,
|
sharp_grid_lines: bool,
|
||||||
clamp_grid: bool,
|
clamp_grid: bool,
|
||||||
|
|
||||||
|
sense: Sense,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Plot {
|
impl Plot {
|
||||||
|
|
@ -226,6 +228,8 @@ impl Plot {
|
||||||
grid_spacers: [log_grid_spacer(10), log_grid_spacer(10)],
|
grid_spacers: [log_grid_spacer(10), log_grid_spacer(10)],
|
||||||
sharp_grid_lines: true,
|
sharp_grid_lines: true,
|
||||||
clamp_grid: false,
|
clamp_grid: false,
|
||||||
|
|
||||||
|
sense: egui::Sense::click_and_drag(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -477,6 +481,15 @@ impl Plot {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the sense for the plot rect.
|
||||||
|
///
|
||||||
|
/// Default: `Sense::click_and_drag()`.
|
||||||
|
#[inline]
|
||||||
|
pub fn sense(mut self, sense: Sense) -> Self {
|
||||||
|
self.sense = sense;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Expand bounds to include the given x value.
|
/// Expand bounds to include the given x value.
|
||||||
/// For instance, to always show the y axis, call `plot.include_x(0.0)`.
|
/// For instance, to always show the y axis, call `plot.include_x(0.0)`.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
@ -745,6 +758,7 @@ impl Plot {
|
||||||
clamp_grid,
|
clamp_grid,
|
||||||
grid_spacers,
|
grid_spacers,
|
||||||
sharp_grid_lines,
|
sharp_grid_lines,
|
||||||
|
sense,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
// Determine position of widget.
|
// Determine position of widget.
|
||||||
|
|
@ -789,7 +803,7 @@ impl Plot {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Allocate the plot window.
|
// Allocate the plot window.
|
||||||
let response = ui.allocate_rect(plot_rect, Sense::click_and_drag());
|
let response = ui.allocate_rect(plot_rect, sense);
|
||||||
|
|
||||||
// Load or initialize the memory.
|
// Load or initialize the memory.
|
||||||
ui.ctx().check_for_id_clash(plot_id, plot_rect, "Plot");
|
ui.ctx().check_for_id_clash(plot_id, plot_rect, "Plot");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue