simplify no_spacing

This commit is contained in:
Csaba
2024-11-13 22:21:19 +01:00
parent cba2b2f7ac
commit 9311cb00ec
2 changed files with 8 additions and 8 deletions

View File

@@ -352,7 +352,7 @@ impl Komobar {
grouping: Grouping::None, grouping: Grouping::None,
background_color: Color32::BLACK, background_color: Color32::BLACK,
alignment: None, alignment: None,
no_spacing: None, no_spacing: false,
})), })),
komorebi_notification_state: None, komorebi_notification_state: None,
left_widgets: vec![], left_widgets: vec![],
@@ -486,7 +486,7 @@ impl eframe::App for Komobar {
w.render(ctx, ui, render_conf); w.render(ctx, ui, render_conf);
} }
render_conf.no_spacing = Some(true); render_conf.no_spacing = true;
last.render(ctx, ui, render_conf); last.render(ctx, ui, render_conf);
} }
}); });
@@ -503,7 +503,7 @@ impl eframe::App for Komobar {
w.render(ctx, ui, render_conf); w.render(ctx, ui, render_conf);
} }
render_conf.no_spacing = Some(true); render_conf.no_spacing = true;
last.render(ctx, ui, render_conf); last.render(ctx, ui, render_conf);
} }
}); });

View File

@@ -36,7 +36,7 @@ pub struct RenderConfig {
/// Alignment of the widgets /// Alignment of the widgets
pub alignment: Option<Alignment>, pub alignment: Option<Alignment>,
/// Remove spacing if true /// Remove spacing if true
pub no_spacing: Option<bool>, pub no_spacing: bool,
} }
pub trait RenderExt { pub trait RenderExt {
@@ -50,7 +50,7 @@ impl RenderExt for &KomobarConfig {
grouping: self.grouping.unwrap_or(Grouping::None), grouping: self.grouping.unwrap_or(Grouping::None),
background_color, background_color,
alignment: None, alignment: None,
no_spacing: None, no_spacing: false,
} }
} }
} }
@@ -90,7 +90,7 @@ impl RenderConfig {
// TODO: this should remove the margin on the last widget on the left side and the first widget on the right side // TODO: this should remove the margin on the last widget on the left side and the first widget on the right side
// This is complex, since the last/first widget can have multiple "sections", like komorebi, network, ... // This is complex, since the last/first widget can have multiple "sections", like komorebi, network, ...
// This and the same setting on RenderConfig needs to be combined. // This and the same setting on RenderConfig needs to be combined.
//_first_or_last: Option<bool>, //no_spacing: Option<bool>,
ui: &mut Ui, ui: &mut Ui,
add_contents: impl FnOnce(&mut Ui) -> R, add_contents: impl FnOnce(&mut Ui) -> R,
) -> InnerResponse<R> { ) -> InnerResponse<R> {
@@ -167,7 +167,7 @@ impl RenderConfig {
Some(align) => match align { Some(align) => match align {
Alignment::Left => 0.0, Alignment::Left => 0.0,
Alignment::Right => { Alignment::Right => {
if self.no_spacing.is_some_and(|v| v) { if self.no_spacing {
0.0 0.0
} else { } else {
self.spacing self.spacing
@@ -179,7 +179,7 @@ impl RenderConfig {
right: match self.alignment { right: match self.alignment {
Some(align) => match align { Some(align) => match align {
Alignment::Left => { Alignment::Left => {
if self.no_spacing.is_some_and(|v| v) { if self.no_spacing {
0.0 0.0
} else { } else {
self.spacing self.spacing