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

Implement custom ruler color for Plot #47

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Changes from 1 commit
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
16 changes: 15 additions & 1 deletion egui_plot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
x_axes: Vec<AxisHints<'a>>, // default x axes
y_axes: Vec<AxisHints<'a>>, // default y axes
legend_config: Option<Legend>,
ruler_color: Option<Color32>,
show_background: bool,
show_axes: Vec2b,

Expand Down Expand Up @@ -227,6 +228,7 @@
x_axes: vec![AxisHints::new(Axis::X)],
y_axes: vec![AxisHints::new(Axis::Y)],
legend_config: None,
ruler_color: None,
show_background: true,
show_axes: true.into(),

Expand Down Expand Up @@ -727,6 +729,15 @@
self
}

/// Set color of the rulers.
///
/// You may set the color to Color32::TRANSPARENT to hide the rulers.

Check failure on line 734 in egui_plot/src/lib.rs

View workflow job for this annotation

GitHub Actions / Rust

item in documentation is missing backticks

Check failure on line 734 in egui_plot/src/lib.rs

View workflow job for this annotation

GitHub Actions / Check wasm32

item in documentation is missing backticks
#[inline]
pub fn custom_ruler_color(mut self, color: Color32) -> Self {
self.ruler_color = Some(color);
self
}

/// Interact with and add items to the plot and finally draw it.
pub fn show<R>(
self,
Expand Down Expand Up @@ -768,6 +779,7 @@
x_axes,
y_axes,
legend_config,
ruler_color,
reset,
show_background,
show_axes,
Expand Down Expand Up @@ -1196,6 +1208,7 @@
draw_cursor_x: linked_cursors.as_ref().map_or(false, |group| group.1.x),
draw_cursor_y: linked_cursors.as_ref().map_or(false, |group| group.1.y),
draw_cursors,
ruler_color,
grid_spacers,
sharp_grid_lines,
clamp_grid,
Expand Down Expand Up @@ -1480,6 +1493,7 @@
draw_cursor_x: bool,
draw_cursor_y: bool,
draw_cursors: Vec<Cursor>,
ruler_color: Option<Color32>,

sharp_grid_lines: bool,
clamp_grid: bool,
Expand Down Expand Up @@ -1517,7 +1531,7 @@
};

// Draw cursors
let line_color = rulers_color(ui);
let line_color = self.ruler_color.unwrap_or_else(|| rulers_color(ui));
gweisert marked this conversation as resolved.
Show resolved Hide resolved

let mut draw_cursor = |cursors: &Vec<Cursor>, always| {
for &cursor in cursors {
Expand Down
Loading