status bar
git clone https://git.lucas.co/cce-status-interface.git
feat: window mode moves from the strip readout into the module menu
The window module's strip shows only the (quantized-width) title; the
focused window's mode is an inert first row of its right-click menu,
like the light module's radians value. Layout pushes no longer redraw
anything — the value is read at menu-open time — and the layout param
drops off the StatusModule trait.
Co-Authored-By: Claude Fable 5 <[email protected]>
src/main.rs | 18 ++++++++++----
src/modules.rs | 74 ++++++++--------------------------------------------------
2 files changed, 23 insertions(+), 69 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index a5b6df6..917a9ef 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -383,7 +383,6 @@ impl StatusApp {
for module in &left_modules {
let w = module.width(
&self.stats,
- &self.layout,
&self.title,
&mut self.font_system,
&font_family,
@@ -419,7 +418,6 @@ impl StatusApp {
left_x,
w,
&self.stats,
- &self.layout,
&self.title,
&mut self.font_system,
&font_family,
@@ -455,7 +453,6 @@ impl StatusApp {
for module in right_modules.iter().rev() {
let w = module.width(
&self.stats,
- &self.layout,
&self.title,
&mut self.font_system,
&font_family,
@@ -499,7 +496,6 @@ impl StatusApp {
right_x,
w,
&self.stats,
- &self.layout,
&self.title,
&mut self.font_system,
&font_family,
@@ -1165,7 +1161,9 @@ impl cce_ui::engine::Application for StatusApp {
let mut changed = true;
match msg {
CustomEvent::LayoutUpdated(l) => {
- changed = self.layout != l;
+ // Nothing renders the mode in the strip anymore; it is read
+ // at menu-open time for the window module's menu row.
+ changed = false;
self.layout = l;
}
CustomEvent::TitleUpdated(t) => {
@@ -1656,6 +1654,16 @@ impl cce_ui::engine::Application for StatusApp {
action: MenuRowAction::Inert,
});
}
+ // The window module's strip shows only the title; the
+ // focused window's mode lives here in its menu.
+ if mb.name == "window" && !self.layout.is_empty() {
+ rows.insert(0, MenuRow {
+ label: self.layout.clone(),
+ enabled: true,
+ separator: false,
+ action: MenuRowAction::Inert,
+ });
+ }
self.context_menu = Some(ModuleContextMenu {
pages: vec![MenuPage { title: mb.name.clone(), rows }],
page: 0,
diff --git a/src/modules.rs b/src/modules.rs
index 4d6f1d4..e183060 100644
--- a/src/modules.rs
+++ b/src/modules.rs
@@ -24,7 +24,6 @@ pub trait StatusModule {
fn width(
&self,
stats: &Option<SystemStats>,
- layout: &str,
title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -38,7 +37,6 @@ pub trait StatusModule {
x: f32,
w: f32,
stats: &Option<SystemStats>,
- layout: &str,
title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -92,7 +90,6 @@ impl StatusModule for WindowModule {
fn width(
&self,
_stats: &Option<SystemStats>,
- layout: &str,
title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -102,26 +99,12 @@ impl StatusModule for WindowModule {
) -> f32 {
let has_title = !title.is_empty() && title != "(none)";
if has_title {
- let has_layout = !layout.is_empty();
- let mut total_w = 0.0;
- if has_title {
- let mut display_title = title.to_string();
- if display_title.chars().count() > 40 {
- display_title = display_title.chars().take(37).collect::<String>() + "...";
- }
- let label = Label::new_with_family(font_system, &display_title, font_size, [0.0, 0.0, 0.0, 1.0], font_family);
- total_w += label.w;
- }
-
- if has_title && has_layout {
- let sep_label = Label::new_with_family(font_system, " - ", font_size, [0.0, 0.0, 0.0, 1.0], font_family);
- total_w += sep_label.w;
- }
-
- if has_layout {
- let layout_label = Label::new_with_family(font_system, layout, font_size, [0.0, 0.0, 0.0, 1.0], font_family);
- total_w += layout_label.w;
+ let mut display_title = title.to_string();
+ if display_title.chars().count() > 40 {
+ display_title = display_title.chars().take(37).collect::<String>() + "...";
}
+ let label = Label::new_with_family(font_system, &display_title, font_size, [0.0, 0.0, 0.0, 1.0], font_family);
+ let total_w = label.w;
// Title-mode width quantized UP to a coarse step: titles change
// constantly (dirty markers, browser tabs, terminal cwd), and
@@ -150,7 +133,6 @@ impl StatusModule for WindowModule {
x: f32,
_w: f32,
_stats: &Option<SystemStats>,
- layout: &str,
title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -170,32 +152,12 @@ impl StatusModule for WindowModule {
) {
let has_title = !title.is_empty() && title != "(none)";
if has_title {
- let has_layout = !layout.is_empty();
- let mut cur_x = x + padding;
- let y_pos = centered_text_y(bar_h, font_size);
-
- if has_title {
- let mut display_title = title.to_string();
- if display_title.chars().count() > 40 {
- display_title = display_title.chars().take(37).collect::<String>() + "...";
- }
- let label = Label::new_with_family(font_system, &display_title, font_size, normal_color, font_family);
- let w = label.w;
- crate::draw_label(text_prims, label, cur_x, y_pos);
- cur_x += w;
- }
-
- if has_title && has_layout {
- let sep_label = Label::new_with_family(font_system, " - ", font_size, normal_color, font_family);
- let w = sep_label.w;
- crate::draw_label(text_prims, sep_label, cur_x, y_pos);
- cur_x += w;
- }
-
- if has_layout {
- let layout_label = Label::new_with_family(font_system, layout, font_size, normal_color, font_family);
- crate::draw_label(text_prims, layout_label, cur_x, y_pos);
+ let mut display_title = title.to_string();
+ if display_title.chars().count() > 40 {
+ display_title = display_title.chars().take(37).collect::<String>() + "...";
}
+ let label = Label::new_with_family(font_system, &display_title, font_size, normal_color, font_family);
+ crate::draw_label(text_prims, label, x + padding, centered_text_y(bar_h, font_size));
} else if title == "(none)" {
// Dim chip signalling that no window has keyboard focus — the
// state where typing goes nowhere. Half-alpha text, not
@@ -229,7 +191,6 @@ impl StatusModule for ClockModule {
fn width(
&self,
stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -251,7 +212,6 @@ impl StatusModule for ClockModule {
x: f32,
_w: f32,
stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -284,7 +244,6 @@ impl StatusModule for BatteryModule {
fn width(
&self,
stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -305,7 +264,6 @@ impl StatusModule for BatteryModule {
x: f32,
_w: f32,
stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -345,7 +303,6 @@ impl StatusModule for VolumeModule {
fn width(
&self,
stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -366,7 +323,6 @@ impl StatusModule for VolumeModule {
x: f32,
_w: f32,
stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -419,7 +375,6 @@ impl StatusModule for BrightnessModule {
fn width(
&self,
stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -440,7 +395,6 @@ impl StatusModule for BrightnessModule {
x: f32,
_w: f32,
stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -475,7 +429,6 @@ impl StatusModule for MemoryModule {
fn width(
&self,
stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -504,7 +457,6 @@ impl StatusModule for MemoryModule {
x: f32,
_w: f32,
stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -537,7 +489,6 @@ impl StatusModule for CpuModule {
fn width(
&self,
stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -558,7 +509,6 @@ impl StatusModule for CpuModule {
x: f32,
_w: f32,
stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -591,7 +541,6 @@ impl StatusModule for TrayModule {
fn width(
&self,
_stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
_font_system: &mut FontSystem,
_font_family: &str,
@@ -612,7 +561,6 @@ impl StatusModule for TrayModule {
x: f32,
_w: f32,
_stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
font_system: &mut FontSystem,
font_family: &str,
@@ -804,7 +752,6 @@ impl StatusModule for LightSourceModule {
fn width(
&self,
_stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
_font_system: &mut FontSystem,
_font_family: &str,
@@ -822,7 +769,6 @@ impl StatusModule for LightSourceModule {
x: f32,
w: f32,
_stats: &Option<SystemStats>,
- _layout: &str,
_title: &str,
_font_system: &mut FontSystem,
_font_family: &str,