Settings panel ui
This commit is contained in:
@@ -3,12 +3,49 @@ use super::Window;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SettingsW {
|
||||
|
||||
accent_color: egui::Color32,
|
||||
primary_bg_color: egui::Color32,
|
||||
secondary_bg_color: egui::Color32,
|
||||
text_color: egui::Color32,
|
||||
dim_text_color: egui::Color32,
|
||||
}
|
||||
|
||||
impl Default for SettingsW {
|
||||
fn default() -> Self {
|
||||
let def = xmpd_settings::theme::Theme::default();
|
||||
Self {
|
||||
accent_color: def.accent_color,
|
||||
primary_bg_color: def.primary_bg_color,
|
||||
secondary_bg_color: def.secondary_bg_color,
|
||||
text_color: def.text_color,
|
||||
dim_text_color: def.dim_text_color
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl Window for SettingsW {
|
||||
fn draw(&self, ui: &mut egui::Ui, _: &mut crate::GuiState) -> crate::Result<()> {
|
||||
fn draw(&mut self, ui: &mut egui::Ui, _: &mut crate::GuiState) -> crate::Result<()> {
|
||||
let theme = &mut xmpd_settings::Settings::get()?.theme;
|
||||
ui.group(|ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.heading("Theme");
|
||||
Self::add_theme_button(&mut theme.accent_color, ui, "Accent");
|
||||
Self::add_theme_button(&mut theme.primary_bg_color, ui, "Primary BG");
|
||||
Self::add_theme_button(&mut theme.secondary_bg_color, ui, "Secondary BG");
|
||||
Self::add_theme_button(&mut theme.text_color, ui, "Text");
|
||||
Self::add_theme_button(&mut theme.dim_text_color, ui, "Dim Text");
|
||||
});
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl SettingsW {
|
||||
fn add_theme_button(rf: &mut egui::Color32, ui: &mut egui::Ui, name: &str) {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(format!("{name}: "));
|
||||
ui.color_edit_button_srgba(rf);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user