easy_imgui/
style.rs

1/*! Module with Dear Imgui Style definitions
2 */
3
4use super::*;
5
6transparent_mut! {
7    /// A wrapper for the `ImGuiStyle` type.
8    ///
9    /// It can be deref-ed directly into a `ImGuiStyle` reference.
10    #[derive(Debug)]
11    pub struct Style(ImGuiStyle);
12}
13
14impl Style {
15    pub fn set_colors_light(&mut self) {
16        unsafe {
17            ImGui_StyleColorsLight(&mut self.0);
18        }
19    }
20    pub fn set_colors_dark(&mut self) {
21        unsafe {
22            ImGui_StyleColorsDark(&mut self.0);
23        }
24    }
25    pub fn set_colors_classic(&mut self) {
26        unsafe {
27            ImGui_StyleColorsClassic(&mut self.0);
28        }
29    }
30    pub fn color(&self, id: ColorId) -> Color {
31        self.Colors[id.bits() as usize].into()
32    }
33    pub fn set_color(&mut self, id: ColorId, color: Color) {
34        self.Colors[id.bits() as usize] = color.into();
35    }
36    pub fn color_alpha(&self, id: ColorId, alpha_mul: f32) -> Color {
37        let mut c = self.color(id);
38        let a = self.Alpha;
39        c.a *= a * alpha_mul;
40        c
41    }
42    pub fn font_size_base(&self) -> f32 {
43        self.FontSizeBase
44    }
45    pub fn font_scale_main(&self) -> f32 {
46        self.FontScaleMain
47    }
48    pub fn font_scale_dpi(&self) -> f32 {
49        self.FontScaleDpi
50    }
51    pub fn scale_all_sizes(&mut self, scale_factor: f32) {
52        unsafe {
53            self.ScaleAllSizes(scale_factor);
54        }
55    }
56}