mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-25 01:58:51 +02:00
fix(bar): fix background color clobbering
This commit is contained in:
@@ -57,6 +57,7 @@ pub struct Komobar {
|
|||||||
pub rx_gui: Receiver<komorebi_client::Notification>,
|
pub rx_gui: Receiver<komorebi_client::Notification>,
|
||||||
pub rx_config: Receiver<KomobarConfig>,
|
pub rx_config: Receiver<KomobarConfig>,
|
||||||
pub bg_color: Rc<RefCell<Color32>>,
|
pub bg_color: Rc<RefCell<Color32>>,
|
||||||
|
pub bg_color_with_alpha: Rc<RefCell<Color32>>,
|
||||||
pub scale_factor: f32,
|
pub scale_factor: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +65,7 @@ pub fn apply_theme(
|
|||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
theme: KomobarTheme,
|
theme: KomobarTheme,
|
||||||
bg_color: Rc<RefCell<Color32>>,
|
bg_color: Rc<RefCell<Color32>>,
|
||||||
|
bg_color_with_alpha: Rc<RefCell<Color32>>,
|
||||||
transparency_alpha: Option<u8>,
|
transparency_alpha: Option<u8>,
|
||||||
grouping: Option<Grouping>,
|
grouping: Option<Grouping>,
|
||||||
) {
|
) {
|
||||||
@@ -150,7 +152,7 @@ pub fn apply_theme(
|
|||||||
// Apply transparency_alpha
|
// Apply transparency_alpha
|
||||||
let theme_color = *bg_color.borrow();
|
let theme_color = *bg_color.borrow();
|
||||||
|
|
||||||
bg_color.replace(theme_color.try_apply_alpha(transparency_alpha));
|
bg_color_with_alpha.replace(theme_color.try_apply_alpha(transparency_alpha));
|
||||||
|
|
||||||
// apply rounding to the widgets
|
// apply rounding to the widgets
|
||||||
if let Some(Grouping::Bar(config) | Grouping::Alignment(config) | Grouping::Widget(config)) =
|
if let Some(Grouping::Bar(config) | Grouping::Alignment(config) | Grouping::Widget(config)) =
|
||||||
@@ -236,6 +238,7 @@ impl Komobar {
|
|||||||
ctx,
|
ctx,
|
||||||
theme,
|
theme,
|
||||||
self.bg_color.clone(),
|
self.bg_color.clone(),
|
||||||
|
self.bg_color_with_alpha.clone(),
|
||||||
config.transparency_alpha,
|
config.transparency_alpha,
|
||||||
config.grouping,
|
config.grouping,
|
||||||
);
|
);
|
||||||
@@ -264,6 +267,7 @@ impl Komobar {
|
|||||||
ctx,
|
ctx,
|
||||||
KomobarTheme::from(theme),
|
KomobarTheme::from(theme),
|
||||||
self.bg_color.clone(),
|
self.bg_color.clone(),
|
||||||
|
self.bg_color_with_alpha.clone(),
|
||||||
bar_transparency_alpha,
|
bar_transparency_alpha,
|
||||||
bar_grouping,
|
bar_grouping,
|
||||||
);
|
);
|
||||||
@@ -290,7 +294,9 @@ impl Komobar {
|
|||||||
|
|
||||||
// apply rounding to the widgets since we didn't call `apply_theme`
|
// apply rounding to the widgets since we didn't call `apply_theme`
|
||||||
if let Some(
|
if let Some(
|
||||||
Grouping::Bar(config) | Grouping::Alignment(config) | Grouping::Widget(config),
|
Grouping::Bar(config)
|
||||||
|
| Grouping::Alignment(config)
|
||||||
|
| Grouping::Widget(config),
|
||||||
) = &bar_grouping
|
) = &bar_grouping
|
||||||
{
|
{
|
||||||
if let Some(rounding) = config.rounding {
|
if let Some(rounding) = config.rounding {
|
||||||
@@ -440,6 +446,7 @@ impl Komobar {
|
|||||||
rx_gui,
|
rx_gui,
|
||||||
rx_config,
|
rx_config,
|
||||||
bg_color: Rc::new(RefCell::new(Style::default().visuals.panel_fill)),
|
bg_color: Rc::new(RefCell::new(Style::default().visuals.panel_fill)),
|
||||||
|
bg_color_with_alpha: Rc::new(RefCell::new(Style::default().visuals.panel_fill)),
|
||||||
scale_factor: cc.egui_ctx.native_pixels_per_point().unwrap_or(1.0),
|
scale_factor: cc.egui_ctx.native_pixels_per_point().unwrap_or(1.0),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -535,6 +542,7 @@ impl eframe::App for Komobar {
|
|||||||
self.config.monitor.index,
|
self.config.monitor.index,
|
||||||
self.rx_gui.clone(),
|
self.rx_gui.clone(),
|
||||||
self.bg_color.clone(),
|
self.bg_color.clone(),
|
||||||
|
self.bg_color_with_alpha.clone(),
|
||||||
self.config.transparency_alpha,
|
self.config.transparency_alpha,
|
||||||
self.config.grouping,
|
self.config.grouping,
|
||||||
self.config.theme,
|
self.config.theme,
|
||||||
@@ -547,9 +555,9 @@ impl eframe::App for Komobar {
|
|||||||
frame.inner_margin.x,
|
frame.inner_margin.x,
|
||||||
frame.inner_margin.y,
|
frame.inner_margin.y,
|
||||||
))
|
))
|
||||||
.fill(*self.bg_color.borrow())
|
.fill(*self.bg_color_with_alpha.borrow())
|
||||||
} else {
|
} else {
|
||||||
Frame::none().fill(*self.bg_color.borrow())
|
Frame::none().fill(*self.bg_color_with_alpha.borrow())
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut render_config = self.render_config.borrow_mut();
|
let mut render_config = self.render_config.borrow_mut();
|
||||||
|
|||||||
@@ -491,12 +491,14 @@ impl KomorebiNotificationState {
|
|||||||
self.hide_empty_workspaces = config.hide_empty_workspaces;
|
self.hide_empty_workspaces = config.hide_empty_workspaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn handle_notification(
|
pub fn handle_notification(
|
||||||
&mut self,
|
&mut self,
|
||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
monitor_index: usize,
|
monitor_index: usize,
|
||||||
rx_gui: Receiver<komorebi_client::Notification>,
|
rx_gui: Receiver<komorebi_client::Notification>,
|
||||||
bg_color: Rc<RefCell<Color32>>,
|
bg_color: Rc<RefCell<Color32>>,
|
||||||
|
bg_color_with_alpha: Rc<RefCell<Color32>>,
|
||||||
transparency_alpha: Option<u8>,
|
transparency_alpha: Option<u8>,
|
||||||
grouping: Option<Grouping>,
|
grouping: Option<Grouping>,
|
||||||
default_theme: Option<KomobarTheme>,
|
default_theme: Option<KomobarTheme>,
|
||||||
@@ -521,6 +523,7 @@ impl KomorebiNotificationState {
|
|||||||
ctx,
|
ctx,
|
||||||
KomobarTheme::from(theme),
|
KomobarTheme::from(theme),
|
||||||
bg_color.clone(),
|
bg_color.clone(),
|
||||||
|
bg_color_with_alpha.clone(),
|
||||||
transparency_alpha,
|
transparency_alpha,
|
||||||
grouping,
|
grouping,
|
||||||
);
|
);
|
||||||
@@ -530,6 +533,7 @@ impl KomorebiNotificationState {
|
|||||||
ctx,
|
ctx,
|
||||||
default_theme,
|
default_theme,
|
||||||
bg_color.clone(),
|
bg_color.clone(),
|
||||||
|
bg_color_with_alpha.clone(),
|
||||||
transparency_alpha,
|
transparency_alpha,
|
||||||
grouping,
|
grouping,
|
||||||
);
|
);
|
||||||
@@ -544,6 +548,7 @@ impl KomorebiNotificationState {
|
|||||||
ctx,
|
ctx,
|
||||||
KomobarTheme::from(theme),
|
KomobarTheme::from(theme),
|
||||||
bg_color,
|
bg_color,
|
||||||
|
bg_color_with_alpha.clone(),
|
||||||
transparency_alpha,
|
transparency_alpha,
|
||||||
grouping,
|
grouping,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user