mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-25 10:08:33 +02:00
Group enum, Copy RenderConfig
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::config::Group;
|
||||||
use crate::config::KomobarConfig;
|
use crate::config::KomobarConfig;
|
||||||
use crate::config::KomobarTheme;
|
use crate::config::KomobarTheme;
|
||||||
use crate::config::Position;
|
use crate::config::Position;
|
||||||
@@ -317,7 +318,12 @@ impl Komobar {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
let mut komobar = Self {
|
let mut komobar = Self {
|
||||||
config: config.clone(),
|
config: config.clone(),
|
||||||
render_config: RenderConfig::from(config.clone()),
|
render_config: RenderConfig {
|
||||||
|
_group: match config.group {
|
||||||
|
None => Group::None,
|
||||||
|
Some(group) => group,
|
||||||
|
},
|
||||||
|
},
|
||||||
komorebi_notification_state: None,
|
komorebi_notification_state: None,
|
||||||
left_widgets: vec![],
|
left_widgets: vec![],
|
||||||
right_widgets: vec![],
|
right_widgets: vec![],
|
||||||
@@ -440,13 +446,13 @@ impl eframe::App for Komobar {
|
|||||||
ui.horizontal_centered(|ui| {
|
ui.horizontal_centered(|ui| {
|
||||||
ui.with_layout(Layout::left_to_right(Align::Center), |ui| {
|
ui.with_layout(Layout::left_to_right(Align::Center), |ui| {
|
||||||
for w in &mut self.left_widgets {
|
for w in &mut self.left_widgets {
|
||||||
w.render(ctx, ui, self.render_config.clone());
|
w.render(ctx, ui, self.render_config);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
|
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
|
||||||
for w in &mut self.right_widgets {
|
for w in &mut self.right_widgets {
|
||||||
w.render(ctx, ui, self.render_config.clone());
|
w.render(ctx, ui, self.render_config);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ pub struct KomobarConfig {
|
|||||||
pub max_label_width: Option<f32>,
|
pub max_label_width: Option<f32>,
|
||||||
/// Theme
|
/// Theme
|
||||||
pub theme: Option<KomobarTheme>,
|
pub theme: Option<KomobarTheme>,
|
||||||
|
/// Visual grouping for widgets
|
||||||
|
pub group: Option<Group>,
|
||||||
/// Left side widgets (ordered left-to-right)
|
/// Left side widgets (ordered left-to-right)
|
||||||
pub left_widgets: Vec<WidgetConfig>,
|
pub left_widgets: Vec<WidgetConfig>,
|
||||||
/// Right side widgets (ordered left-to-right)
|
/// Right side widgets (ordered left-to-right)
|
||||||
@@ -178,3 +180,8 @@ pub enum LabelPrefix {
|
|||||||
/// Show an icon and text
|
/// Show an icon and text
|
||||||
IconAndText,
|
IconAndText,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
pub enum Group {
|
||||||
|
None
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::battery::Battery;
|
use crate::battery::Battery;
|
||||||
use crate::battery::BatteryConfig;
|
use crate::battery::BatteryConfig;
|
||||||
use crate::config::KomobarConfig;
|
use crate::config::Group;
|
||||||
use crate::cpu::Cpu;
|
use crate::cpu::Cpu;
|
||||||
use crate::cpu::CpuConfig;
|
use crate::cpu::CpuConfig;
|
||||||
use crate::date::Date;
|
use crate::date::Date;
|
||||||
@@ -22,22 +22,15 @@ use eframe::egui::Ui;
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub trait BarWidget {
|
pub trait BarWidget {
|
||||||
fn render(&mut self, ctx: &Context, ui: &mut Ui, config: RenderConfig);
|
fn render(&mut self, ctx: &Context, ui: &mut Ui, config: RenderConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct RenderConfig {
|
pub struct RenderConfig {
|
||||||
/// Sets how widgets are grouped
|
/// Sets how widgets are grouped
|
||||||
_group: i32,
|
pub _group: Group,
|
||||||
}
|
|
||||||
|
|
||||||
impl RenderConfig {
|
|
||||||
pub fn from(_config: Arc<KomobarConfig>) -> Self {
|
|
||||||
Self { _group: 1 }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
|||||||
Reference in New Issue
Block a user