AlphaColour, transparency, bar background, more grouping config options

This commit is contained in:
Csaba
2024-11-08 23:51:00 +01:00
parent 7fff6d29a9
commit 655e8ce4c1
6 changed files with 152 additions and 33 deletions
+27
View File
@@ -1,8 +1,10 @@
use crate::group::Grouping;
use crate::widget::WidgetConfig;
use eframe::egui::Color32;
use eframe::egui::Pos2;
use eframe::egui::TextBuffer;
use eframe::egui::Vec2;
use komorebi_client::Colour;
use komorebi_client::KomorebiTheme;
use komorebi_client::Rect;
use schemars::JsonSchema;
@@ -29,6 +31,8 @@ pub struct KomobarConfig {
pub max_label_width: Option<f32>,
/// Theme
pub theme: Option<KomobarTheme>,
/// Background color
pub background: Option<AlphaColour>,
/// Visual grouping for widgets
pub grouping: Option<Grouping>,
/// Left side widgets (ordered left-to-right)
@@ -181,3 +185,26 @@ pub enum LabelPrefix {
/// Show an icon and text
IconAndText,
}
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
pub struct AlphaColour {
/// Color
pub color: Option<Colour>,
/// Alpha value for the color transparency [[0-255]] (default: 200)
pub transparency_alpha: Option<u8>,
}
impl From<AlphaColour> for Color32 {
fn from(value: AlphaColour) -> Self {
let color = match value.color {
Some(color) => color.into(),
None => Color32::from_rgb(0, 0, 0),
};
if let Some(alpha) = value.transparency_alpha {
return Color32::from_rgba_premultiplied(color.r(), color.g(), color.b(), alpha);
}
color
}
}