added widget grouping and group module

This commit is contained in:
Csaba
2024-11-08 00:40:13 +01:00
parent f446a6a45f
commit d188222be7
14 changed files with 436 additions and 376 deletions
+1 -39
View File
@@ -1,6 +1,6 @@
use crate::group::Grouping;
use crate::widget::WidgetConfig;
use eframe::egui::Pos2;
use eframe::egui::Rounding;
use eframe::egui::TextBuffer;
use eframe::egui::Vec2;
use komorebi_client::KomorebiTheme;
@@ -181,41 +181,3 @@ pub enum LabelPrefix {
/// Show an icon and text
IconAndText,
}
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
pub enum Grouping {
/// No grouping is applied
None,
/// Widgets are grouped individually
Widget(GroupingConfig),
/// Widgets are grouped on each side
Side(GroupingConfig),
}
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
pub struct GroupingConfig {
pub rounding: Option<BorderRadius>,
}
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)]
pub struct BorderRadius {
/// Radius of the rounding of the North-West (left top) corner.
pub nw: f32,
/// Radius of the rounding of the North-East (right top) corner.
pub ne: f32,
/// 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 {
fn from(value: BorderRadius) -> Self {
Self {
nw: value.nw,
ne: value.ne,
sw: value.sw,
se: value.se,
}
}
}