This commit is contained in:
2026-09-14 00:55:25 +01:00
parent ec43d7b57a
commit e8c0e79bae
17 changed files with 183 additions and 46 deletions
+19 -15
View File
@@ -10,17 +10,18 @@ use std::collections::BTreeSet;
use common::{BarModule, HyprlandEvent, HyprlandMsg, ModuleEffect, Service, Wire};
use iced::border;
use iced::theme::palette;
use iced::widget::{container, row, space};
use iced::{window, Color, Element, Length, Task};
use iced::{window, Element, Length, Task, Theme};
use serde::Deserialize;
use toml::Table;
/// Focused workspace (gruvbox base10 / `Colors.primaryText`).
const ACTIVE: Color = Color::from_rgb(0.9216, 0.8588, 0.6980);
/// Workspace exists but is not focused (base06 / `Colors.textSecondary`).
const EXISTS: Color = Color::from_rgb(0.4863, 0.4353, 0.3922);
/// Workspace does not exist (base04 / `Colors.textDisabled`).
const ABSENT: Color = Color::from_rgb(0.3137, 0.2863, 0.2706);
/// How far each state's cube fades from the theme text colour toward the
/// theme background. Opaque (mixed, not alpha) so cubes stay solid over the
/// transparent bar instead of washing out.
const FADE_ACTIVE: f32 = 0.0;
const FADE_EXISTS: f32 = 0.55;
const FADE_ABSENT: f32 = 0.8;
/// Look of the workspace row, from `[modules.workspaces]`; every field
/// defaults to the value Quickshell's `Workspaces.qml` hardcodes, so an
@@ -81,21 +82,24 @@ impl Workspaces {
}
fn cube(&self, id: i32) -> Element<'_, Wire> {
let (color, scale) = if self.active == Some(id) {
(ACTIVE, self.cfg.scale_active)
let (fade, scale) = if self.active == Some(id) {
(FADE_ACTIVE, self.cfg.scale_active)
} else if self.existing.contains(&id) {
(EXISTS, self.cfg.scale_exists)
(FADE_EXISTS, self.cfg.scale_exists)
} else {
(ABSENT, self.cfg.scale_absent)
(FADE_ABSENT, self.cfg.scale_absent)
};
let radius = self.cfg.radius;
let bar = container(space())
.width(Length::Fixed(self.cfg.slot_w * scale))
.height(Length::Fixed(self.cfg.slot_h * scale))
.style(move |_| container::Style {
background: Some(color.into()),
border: border::rounded(radius),
..Default::default()
.style(move |theme: &Theme| {
let p = theme.palette();
container::Style {
background: Some(palette::mix(p.text, p.background, fade).into()),
border: border::rounded(radius),
..Default::default()
}
});
container(bar)
.center_x(Length::Fixed(self.cfg.slot_w))