From af760648b64978c2c9939aba1471bda29a23a48f Mon Sep 17 00:00:00 2001 From: 4bb4 <67376761+4bb4@users.noreply.github.com> Date: Sun, 29 Nov 2020 19:21:12 +0100 Subject: [PATCH] Added some simple colorscheme setters These don't properly expose the implot style yet in a way that is consistent with imgui-rs' handling of styles. This is to be added later. --- implot-examples/implot-glium-demo/src/main.rs | 1 - src/context.rs | 36 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/implot-examples/implot-glium-demo/src/main.rs b/implot-examples/implot-glium-demo/src/main.rs index d6ce5db..ed67d71 100644 --- a/implot-examples/implot-glium-demo/src/main.rs +++ b/implot-examples/implot-glium-demo/src/main.rs @@ -1,4 +1,3 @@ - use imgui::{im_str, Condition, Window}; use implot::Context; diff --git a/src/context.rs b/src/context.rs index d7f086b..054500b 100644 --- a/src/context.rs +++ b/src/context.rs @@ -48,6 +48,42 @@ impl Context { pub fn get_plot_ui(&self) -> PlotUi { PlotUi { context: self } } + + /// Use light colors for the implot style. + /// + /// This will eventually be exposed more thoroughly in the form of ImPlotStyle, + /// but for now this allows one to at least easily set the color preset. + pub fn use_light_colors(&self) { + unsafe { + let style = sys::ImPlot_GetStyle(); + assert_ne!(style, std::ptr::null_mut()); + sys::ImPlot_StyleColorsLight(style); + } + } + + /// Use dark colors for the implot style. + /// + /// This will eventually be exposed more thoroughly in the form of ImPlotStyle, + /// but for now this allows one to at least easily set the color preset. + pub fn use_dark_colors(&self) { + unsafe { + let style = sys::ImPlot_GetStyle(); + assert_ne!(style, std::ptr::null_mut()); + sys::ImPlot_StyleColorsDark(style); + } + } + + /// Use classic colors for the implot style. + /// + /// This will eventually be exposed more thoroughly in the form of ImPlotStyle, + /// but for now this allows one to at least easily set the color preset. + pub fn use_classic_colors(&self) { + unsafe { + let style = sys::ImPlot_GetStyle(); + assert_ne!(style, std::ptr::null_mut()); + sys::ImPlot_StyleColorsClassic(style); + } + } } impl Drop for Context {