diff --git a/komorebi-bar/src/bar.rs b/komorebi-bar/src/bar.rs index 69ff22ad..20fd5d0d 100644 --- a/komorebi-bar/src/bar.rs +++ b/komorebi-bar/src/bar.rs @@ -65,6 +65,7 @@ pub fn apply_theme( theme: KomobarTheme, bg_color: Rc>, transparency_alpha: Option, + grouping: Option, ) { match theme { KomobarTheme::Catppuccin { @@ -150,6 +151,21 @@ pub fn apply_theme( let theme_color = *bg_color.borrow(); bg_color.replace(theme_color.try_apply_alpha(transparency_alpha)); + + // apply rounding to the widgets + if let Some(Grouping::Bar(config) | Grouping::Alignment(config) | Grouping::Widget(config)) = + &grouping + { + if let Some(rounding) = config.rounding { + ctx.style_mut(|style| { + style.visuals.widgets.noninteractive.rounding = rounding.into(); + style.visuals.widgets.inactive.rounding = rounding.into(); + style.visuals.widgets.hovered.rounding = rounding.into(); + style.visuals.widgets.active.rounding = rounding.into(); + style.visuals.widgets.open.rounding = rounding.into(); + }); + } + } } impl Komobar { @@ -216,7 +232,13 @@ impl Komobar { let background_color_before_transparency = *self.bg_color.borrow(); match config.theme { Some(theme) => { - apply_theme(ctx, theme, self.bg_color.clone(), config.transparency_alpha); + apply_theme( + ctx, + theme, + self.bg_color.clone(), + config.transparency_alpha, + config.grouping, + ); } None => { let home_dir: PathBuf = std::env::var("KOMOREBI_CONFIG_HOME").map_or_else( @@ -233,6 +255,7 @@ impl Komobar { ); let bar_transparency_alpha = config.transparency_alpha; + let bar_grouping = config.grouping; let config = home_dir.join("komorebi.json"); match komorebi_client::StaticConfig::read(&config) { Ok(config) => { @@ -242,6 +265,7 @@ impl Komobar { KomobarTheme::from(theme), self.bg_color.clone(), bar_transparency_alpha, + bar_grouping, ); let stack_accent = match theme { @@ -263,27 +287,27 @@ impl Komobar { Err(_) => { ctx.set_style(Style::default()); self.bg_color.replace(Style::default().visuals.panel_fill); + + // apply rounding to the widgets since we didn't call `apply_theme` + if let Some( + Grouping::Bar(config) | Grouping::Alignment(config) | Grouping::Widget(config), + ) = &bar_grouping + { + if let Some(rounding) = config.rounding { + ctx.style_mut(|style| { + style.visuals.widgets.noninteractive.rounding = rounding.into(); + style.visuals.widgets.inactive.rounding = rounding.into(); + style.visuals.widgets.hovered.rounding = rounding.into(); + style.visuals.widgets.active.rounding = rounding.into(); + style.visuals.widgets.open.rounding = rounding.into(); + }); + } + } } } } } - // apply rounding to the widgets - if let Some( - Grouping::Bar(config) | Grouping::Alignment(config) | Grouping::Widget(config), - ) = &config.grouping - { - if let Some(rounding) = config.rounding { - ctx.style_mut(|style| { - style.visuals.widgets.noninteractive.rounding = rounding.into(); - style.visuals.widgets.inactive.rounding = rounding.into(); - style.visuals.widgets.hovered.rounding = rounding.into(); - style.visuals.widgets.active.rounding = rounding.into(); - style.visuals.widgets.open.rounding = rounding.into(); - }); - } - } - if let Some(font_size) = &config.font_size { tracing::info!("attempting to set custom font size: {font_size}"); Self::set_font_size(ctx, *font_size); @@ -512,6 +536,7 @@ impl eframe::App for Komobar { self.rx_gui.clone(), self.bg_color.clone(), self.config.transparency_alpha, + self.config.grouping, self.config.theme, ); } diff --git a/komorebi-bar/src/komorebi.rs b/komorebi-bar/src/komorebi.rs index 0280b06c..7fe17ff9 100644 --- a/komorebi-bar/src/komorebi.rs +++ b/komorebi-bar/src/komorebi.rs @@ -2,6 +2,7 @@ use crate::bar::apply_theme; use crate::config::DisplayFormat; use crate::config::KomobarTheme; use crate::komorebi_layout::KomorebiLayout; +use crate::render::Grouping; use crate::render::RenderConfig; use crate::selected_frame::SelectableFrame; use crate::ui::CustomUi; @@ -497,6 +498,7 @@ impl KomorebiNotificationState { rx_gui: Receiver, bg_color: Rc>, transparency_alpha: Option, + grouping: Option, default_theme: Option, ) { match rx_gui.try_recv() { @@ -520,6 +522,7 @@ impl KomorebiNotificationState { KomobarTheme::from(theme), bg_color.clone(), transparency_alpha, + grouping, ); tracing::info!("applied theme from updated komorebi.json"); } else if let Some(default_theme) = default_theme { @@ -528,6 +531,7 @@ impl KomorebiNotificationState { default_theme, bg_color.clone(), transparency_alpha, + grouping, ); tracing::info!("removed theme from updated komorebi.json and applied default theme"); } else { @@ -541,6 +545,7 @@ impl KomorebiNotificationState { KomobarTheme::from(theme), bg_color, transparency_alpha, + grouping, ); tracing::info!("applied theme from komorebi socket message"); }