Skip to content

Commit

Permalink
Update remaining Vec2b arguments to impl Into<Vec2b>.
Browse files Browse the repository at this point in the history
  • Loading branch information
jetuk committed Jan 8, 2025
1 parent e6d6a6c commit 89c4d2a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions egui_plot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ impl<'a> Plot<'a> {
///
/// This is enabled by default.
#[inline]
pub fn auto_bounds(mut self, auto_bounds: Vec2b) -> Self {
self.default_auto_bounds = auto_bounds;
pub fn auto_bounds(mut self, auto_bounds: impl Into<Vec2b>) -> Self {
self.default_auto_bounds = auto_bounds.into();
self
}

Expand Down Expand Up @@ -1262,7 +1262,7 @@ impl<'a> Plot<'a> {
/// Returns the rect left after adding axes.
fn axis_widgets<'a>(
mem: Option<&PlotMemory>,
show_axes: Vec2b,
show_axes: impl Into<Vec2b>,
complete_rect: Rect,
[x_axes, y_axes]: [&'a [AxisHints<'a>]; 2],
) -> ([Vec<AxisWidget<'a>>; 2], Rect) {
Expand All @@ -1288,6 +1288,7 @@ fn axis_widgets<'a>(
// | X-axis 1 | |
// + +--------------------+---+
//
let show_axes = show_axes.into();

let mut x_axis_widgets = Vec::<AxisWidget<'_>>::new();
let mut y_axis_widgets = Vec::<AxisWidget<'_>>::new();
Expand Down
4 changes: 2 additions & 2 deletions egui_plot/src/plot_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ impl PlotUi {
}

/// Set the auto-bounds mode for the plot axes.
pub fn set_auto_bounds(&mut self, auto_bounds: Vec2b) {
pub fn set_auto_bounds(&mut self, auto_bounds: impl Into<Vec2b>) {
self.bounds_modifications
.push(BoundsModification::AutoBounds(auto_bounds));
.push(BoundsModification::AutoBounds(auto_bounds.into()));
}

/// Can be used to check if the plot was hovered or clicked.
Expand Down
3 changes: 2 additions & 1 deletion egui_plot/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,12 @@ pub struct PlotTransform {
}

impl PlotTransform {
pub fn new(frame: Rect, bounds: PlotBounds, center_axis: Vec2b) -> Self {
pub fn new(frame: Rect, bounds: PlotBounds, center_axis: impl Into<Vec2b>) -> Self {
debug_assert!(
0.0 <= frame.width() && 0.0 <= frame.height(),
"Bad plot frame: {frame:?}"
);
let center_axis = center_axis.into();

// Since the current Y bounds an affect the final X bounds and vice versa, we need to keep
// the original version of the `bounds` before we start modifying it.
Expand Down

0 comments on commit 89c4d2a

Please sign in to comment.