improve styling in relation to windows theme
This commit is contained in:
+12
-1
@@ -1,6 +1,10 @@
|
||||
use crate::{
|
||||
features,
|
||||
gui::{settings::Settings, tools, ui_ext::UiExt},
|
||||
gui::{
|
||||
settings::{Settings, Theme},
|
||||
tools,
|
||||
ui_ext::UiExt,
|
||||
},
|
||||
util::{consts::game::WINDOW_TITLE, meta::Meta, persistent_state::PersistentState, win},
|
||||
};
|
||||
use eframe::egui;
|
||||
@@ -201,6 +205,13 @@ impl App {
|
||||
if selection != self.settings.theme {
|
||||
catppuccin_egui::set_theme(ctx, self.settings.theme.into());
|
||||
}
|
||||
if ui
|
||||
.add_visible(self.settings.theme == Theme::Auto, egui::Button::new("⟲"))
|
||||
.on_hover_text("Refresh theme")
|
||||
.clicked()
|
||||
{
|
||||
catppuccin_egui::set_theme(ctx, self.settings.theme.into());
|
||||
}
|
||||
});
|
||||
ui.checkbox(&mut self.settings.start_elevated, "Always start elevated");
|
||||
}
|
||||
|
||||
+4
-2
@@ -50,10 +50,12 @@ fn app_creator(
|
||||
app.sysinfo.refresh_all();
|
||||
// enable image loading support in egui
|
||||
egui_extras::install_image_loaders(&cc.egui_ctx);
|
||||
// set our initial theme, from earlier loaded settings
|
||||
// set our initial theme, from earlier loaded settings. we set the egui theme
|
||||
// to dark here to work around system theme based switching of the egui style
|
||||
cc.egui_ctx.set_theme(egui::Theme::Dark);
|
||||
catppuccin_egui::set_theme(&cc.egui_ctx, app.settings.theme.into());
|
||||
// apply some global styling that we like
|
||||
cc.egui_ctx.style_mut(|style| {
|
||||
cc.egui_ctx.all_styles_mut(|style| {
|
||||
style.spacing.item_spacing = egui::vec2(4.0, 4.0);
|
||||
style.interaction.selectable_labels = false;
|
||||
});
|
||||
|
||||
+11
-1
@@ -1,8 +1,11 @@
|
||||
use crate::util::win;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use strum::{Display, EnumIter};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Display, PartialEq, Eq, Serialize, Deserialize, EnumIter)]
|
||||
pub enum Theme {
|
||||
#[strum(to_string = "Auto")]
|
||||
Auto,
|
||||
#[strum(to_string = "Catppuccin Latte")]
|
||||
CatppuccinLatte,
|
||||
#[strum(to_string = "Catppuccin Frappe")]
|
||||
@@ -16,6 +19,13 @@ pub enum Theme {
|
||||
impl From<Theme> for catppuccin_egui::Theme {
|
||||
fn from(val: Theme) -> Self {
|
||||
match val {
|
||||
Theme::Auto => {
|
||||
if win::is_system_theme_dark() {
|
||||
catppuccin_egui::MOCHA
|
||||
} else {
|
||||
catppuccin_egui::LATTE
|
||||
}
|
||||
}
|
||||
Theme::CatppuccinLatte => catppuccin_egui::LATTE,
|
||||
Theme::CatppuccinFrappe => catppuccin_egui::FRAPPE,
|
||||
Theme::CatppuccinMacchiato => catppuccin_egui::MACCHIATO,
|
||||
@@ -33,7 +43,7 @@ pub struct Settings {
|
||||
impl Default for Settings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
theme: Theme::CatppuccinMocha,
|
||||
theme: Theme::Auto,
|
||||
start_elevated: false,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user