mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-25 10:08:33 +02:00
added RoundingConfig
This commit is contained in:
@@ -446,7 +446,7 @@ impl eframe::App for Komobar {
|
|||||||
let mut render_config = self.render_config.borrow_mut();
|
let mut render_config = self.render_config.borrow_mut();
|
||||||
let render_config_clone = *render_config;
|
let render_config_clone = *render_config;
|
||||||
|
|
||||||
// prefer the custom background from the config
|
// prefer the custom background from the config over the theme background
|
||||||
if let Some(bg_color) = render_config.background_color {
|
if let Some(bg_color) = render_config.background_color {
|
||||||
self.bg_color.replace(bg_color);
|
self.bg_color.replace(bg_color);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use eframe::egui::Stroke;
|
|||||||
use eframe::egui::Ui;
|
use eframe::egui::Ui;
|
||||||
use komorebi_client::Colour;
|
use komorebi_client::Colour;
|
||||||
use komorebi_client::Rect;
|
use komorebi_client::Rect;
|
||||||
use komorebi_client::Rgb;
|
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
@@ -110,25 +109,12 @@ impl Grouping {
|
|||||||
bottom: rect.bottom as f32,
|
bottom: rect.bottom as f32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: this is also in the komorebi_gui. Should be moved to the "komorebi colour"
|
|
||||||
pub fn colour_to_color32(colour: Option<Colour>) -> Color32 {
|
|
||||||
match colour {
|
|
||||||
Some(Colour::Rgb(rgb)) => Color32::from_rgb(rgb.r as u8, rgb.g as u8, rgb.b as u8),
|
|
||||||
Some(Colour::Hex(hex)) => {
|
|
||||||
let rgb = Rgb::from(hex);
|
|
||||||
Color32::from_rgb(rgb.r as u8, rgb.g as u8, rgb.b as u8)
|
|
||||||
}
|
|
||||||
//None => Color32::from_rgb(0, 0, 0),
|
|
||||||
None => Color32::TRANSPARENT,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct GroupingConfig {
|
pub struct GroupingConfig {
|
||||||
pub fill: Option<AlphaColour>,
|
pub fill: Option<AlphaColour>,
|
||||||
pub rounding: Option<BorderRadius>,
|
pub rounding: Option<RoundingConfig>,
|
||||||
pub outer_margin: Option<Rect>,
|
pub outer_margin: Option<Rect>,
|
||||||
pub inner_margin: Option<Rect>,
|
pub inner_margin: Option<Rect>,
|
||||||
pub stroke: Option<Line>,
|
pub stroke: Option<Line>,
|
||||||
@@ -144,30 +130,32 @@ impl From<Line> for Stroke {
|
|||||||
fn from(value: Line) -> Self {
|
fn from(value: Line) -> Self {
|
||||||
Self {
|
Self {
|
||||||
width: value.width,
|
width: value.width,
|
||||||
color: Grouping::colour_to_color32(value.color),
|
color: match value.color {
|
||||||
|
Some(color) => color.into(),
|
||||||
|
None => Color32::from_rgb(0, 0, 0),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub struct BorderRadius {
|
pub enum RoundingConfig {
|
||||||
/// Radius of the rounding of the North-West (left top) corner.
|
/// All 4 corners are the same
|
||||||
pub nw: f32,
|
Same(f32),
|
||||||
/// Radius of the rounding of the North-East (right top) corner.
|
/// All 4 corners are custom. Order: NW, NE, SW, SE
|
||||||
pub ne: f32,
|
Individual([f32; 4]),
|
||||||
/// Radius of the rounding of the South-West (left bottom) corner.
|
|
||||||
pub sw: f32,
|
|
||||||
/// Radius of the rounding of the South-East (right bottom) corner.
|
|
||||||
pub se: f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<BorderRadius> for Rounding {
|
impl From<RoundingConfig> for Rounding {
|
||||||
fn from(value: BorderRadius) -> Self {
|
fn from(value: RoundingConfig) -> Self {
|
||||||
Self {
|
match value {
|
||||||
nw: value.nw,
|
RoundingConfig::Same(value) => Rounding::same(value),
|
||||||
ne: value.ne,
|
RoundingConfig::Individual(values) => Self {
|
||||||
sw: value.sw,
|
nw: values[0],
|
||||||
se: value.se,
|
ne: values[1],
|
||||||
|
sw: values[2],
|
||||||
|
se: values[3],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user