Skip to content

Commit cced2a4

Browse files
CtByteLGUG2Z
authored andcommitted
feat(bar): added icon_scale to the config allowing a custom value between 1.0 and 2.0
1 parent d93b6fa commit cced2a4

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

komorebi-bar/src/bar.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,11 @@ impl Komobar {
245245
Self::set_font_size(ctx, *font_size);
246246
}
247247

248-
self.render_config
249-
.replace(config.new_renderconfig(ctx, *self.bg_color.borrow()));
248+
self.render_config.replace(config.new_renderconfig(
249+
ctx,
250+
*self.bg_color.borrow(),
251+
config.icon_scale,
252+
));
250253

251254
let mut komorebi_notification_state = previous_notification_state;
252255
let mut komorebi_widgets = Vec::new();

komorebi-bar/src/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pub struct KomobarConfig {
2525
pub font_family: Option<String>,
2626
/// Font size (default: 12.5)
2727
pub font_size: Option<f32>,
28+
/// Scale of the icons relative to the font_size [[1.0-2.0]]. (default: 1.4)
29+
pub icon_scale: Option<f32>,
2830
/// Max label width before text truncation (default: 400.0)
2931
pub max_label_width: Option<f32>,
3032
/// Theme

komorebi-bar/src/render.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,21 @@ pub struct RenderConfig {
5656
}
5757

5858
pub trait RenderExt {
59-
fn new_renderconfig(&self, ctx: &Context, background_color: Color32) -> RenderConfig;
59+
fn new_renderconfig(
60+
&self,
61+
ctx: &Context,
62+
background_color: Color32,
63+
icon_scale: Option<f32>,
64+
) -> RenderConfig;
6065
}
6166

6267
impl RenderExt for &KomobarConfig {
63-
fn new_renderconfig(&self, ctx: &Context, background_color: Color32) -> RenderConfig {
68+
fn new_renderconfig(
69+
&self,
70+
ctx: &Context,
71+
background_color: Color32,
72+
icon_scale: Option<f32>,
73+
) -> RenderConfig {
6474
let text_font_id = ctx
6575
.style()
6676
.text_styles
@@ -69,7 +79,7 @@ impl RenderExt for &KomobarConfig {
6979
.unwrap_or_else(FontId::default);
7080

7181
let mut icon_font_id = text_font_id.clone();
72-
icon_font_id.size *= 1.4;
82+
icon_font_id.size *= icon_scale.unwrap_or(1.4).clamp(1.0, 2.0);
7383

7484
RenderConfig {
7585
monitor_idx: self.monitor.index,

0 commit comments

Comments
 (0)