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.
This commit is contained in:
4bb4 2020-11-29 19:21:12 +01:00
parent d02f25fb32
commit af760648b6
2 changed files with 36 additions and 1 deletions

View file

@ -1,4 +1,3 @@
use imgui::{im_str, Condition, Window}; use imgui::{im_str, Condition, Window};
use implot::Context; use implot::Context;

View file

@ -48,6 +48,42 @@ impl Context {
pub fn get_plot_ui(&self) -> PlotUi { pub fn get_plot_ui(&self) -> PlotUi {
PlotUi { context: self } 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 { impl Drop for Context {