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

Conversation

gweisert
Copy link
Contributor

Implement custom ruler color for Plot which is exposed through the new custom_ruler_color method. The entire thing is only a few lines.

@bircni
Copy link
Contributor

bircni commented Sep 23, 2024

This should work, the current implementation doesn't support setting the color BUT it works with light and dark mode - your implementation doesn't work with light and dark mode as it is always the same color

pub(crate) fn rulers_color(ui: &Ui) -> Color32 {

@gweisert
Copy link
Contributor Author

@bircni I'm not quite sure what you are trying to say.
If no custom ruler color is specified, the function you mentioned is still used to determine the color:

  // before
  let line_color = rulers_color(ui);
  // now
  let line_color = self.ruler_color.unwrap_or_else(|| rulers_color(ui));

@bircni
Copy link
Contributor

bircni commented Sep 23, 2024

Sure I wanted to say that it might be better to set two colors, one for dark and one for light.
Sorry that was kinda weird how I wrote that

@gweisert
Copy link
Contributor Author

gweisert commented Sep 24, 2024

That seems really unnecessary to me.
If that is your use case, you can easily choose the color beforehand:

let my_color = if ui.visuals().dark_mode { Color32::RED } else { Color32::GREEN };
egui_plot::Plot::new("my_plot").custom_ruler_color(my_color).show( [...] )

egui_plot/src/lib.rs Outdated Show resolved Hide resolved
@emilk emilk added the include in changelog This change will be included in the changelog label Sep 26, 2024
@bircni
Copy link
Contributor

bircni commented Dec 4, 2024

@emilk this seems to be ready to merge

egui_plot/src/lib.rs Outdated Show resolved Hide resolved
egui_plot/src/lib.rs Outdated Show resolved Hide resolved
@emilk emilk added the enhancement New feature or request label Dec 17, 2024
@emilk emilk merged commit 7b9a4df into emilk:main Dec 17, 2024
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request include in changelog This change will be included in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants