GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
refactor(widget): dead widgets FontPreview / LayoutPreview / Sidebar deleted
The post-dissolution constructor census (the 6am pattern) found three
widgets with zero constructors workspace-wide: FontPreview (cce-fonts grew
its own preview rendering), LayoutPreview + its PreviewLayoutMode enum
(nothing renders layout thumbnails through it), and Sidebar (every app's
sidebar is app-drawn). 292 lines + re-exports. Zero-constructor widgets
have no runtime surface, so this is provably behavior-free; 164 tests.
Census notes: the old god-trait-era containers (Layer/List/Page/Switcher/
SectionHeader) are ALREADY gone from cce-ui — the remaining name matches
are app-local copies (TI's ti_widgets) and unrelated app enums.
PreviewState looked dead but cce-files re-exports it (pages::preview);
PageSelector is a live controller trait, not a widget.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018u7qTwzX95dd5ysAkaSCLk
src/widget/display/font_preview.rs | 59 ----------
src/widget/display/layout_preview.rs | 208 -----------------------------------
src/widget/display/mod.rs | 6 -
src/widget/display/sidebar.rs | 25 -----
src/widget/mod.rs | 4 +-
5 files changed, 2 insertions(+), 300 deletions(-)
diff --git a/src/widget/display/font_preview.rs b/src/widget/display/font_preview.rs
deleted file mode 100644
index 231e796..0000000
--- a/src/widget/display/font_preview.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-//! Narrow-trait font preview card (Phase 5i leaf sweep). Its `widget_font` forward makes every
-//! text prim render in the previewed family on the legacy text paths.
-
-use crate::scene::layout::Rect;
-use crate::scene::paint::PaintCtx;
-use crate::widget::{Adapted, Input, Layout, Paint};
-
-#[derive(Debug, Clone)]
-pub struct FontPreview {
- pub font_family: String,
-}
-
-impl FontPreview {
- pub fn new(font_family: String) -> Adapted<FontPreview> {
- Adapted::new(FontPreview { font_family })
- }
-
- pub fn set_font_family(&mut self, font_family: String) {
- self.font_family = font_family;
- }
-}
-
-impl Layout for FontPreview {
- fn inline_label(&self) -> bool {
- true
- }
-}
-
-impl Paint for FontPreview {
- fn color(&self) -> [f32; 4] {
- [0.0, 0.0, 0.0, 0.0]
- }
-
- fn widget_font(&self) -> Option<String> {
- Some(self.font_family.clone())
- }
-
- fn paint(&self, rect: Rect, ctx: &mut PaintCtx) {
- let (x, y, w, h) = (rect.x, rect.y, rect.width, rect.height);
- let border_t = 1.0;
- let card_color = [0.10, 0.10, 0.14, 0.3];
- let border_color = [0.25, 0.25, 0.35, 0.5];
- ctx.quad(rect, card_color);
- ctx.quad(Rect { x, y, width: w, height: border_t }, border_color);
- ctx.quad(Rect { x, y: y + h - border_t, width: w, height: border_t }, border_color);
- ctx.quad(Rect { x, y, width: border_t, height: h }, border_color);
- ctx.quad(Rect { x: x + w - border_t, y, width: border_t, height: h }, border_color);
- ctx.quad(Rect { x: x + 16.0, y: y + 44.0, width: w - 32.0, height: 1.0 }, [0.22, 0.22, 0.30, 0.8]);
-
- ctx.text(format!("Family: {}", self.font_family), x + 16.0, y + 16.0, 15.0, [230, 230, 242]);
- ctx.text("abcdefghijklmnopqrstuvwxyz".to_string(), x + 16.0, y + 61.0, 13.0, [191, 191, 204]);
- ctx.text("ABCDEFGHIJKLMNOPQRSTUVWXYZ".to_string(), x + 16.0, y + 83.0, 13.0, [191, 191, 204]);
- ctx.text("0123456789 (!@#$%&*?)".to_string(), x + 16.0, y + 105.0, 13.0, [191, 191, 204]);
- ctx.text("The quick brown fox jumps over the lazy dog.".to_string(), x + 16.0, y + 131.0, 16.0, [230, 230, 242]);
- ctx.text("The five boxing wizards jump quickly.".to_string(), x + 16.0, y + 163.0, 20.0, [255, 255, 255]);
- }
-}
-
-impl Input for FontPreview {}
diff --git a/src/widget/display/layout_preview.rs b/src/widget/display/layout_preview.rs
deleted file mode 100644
index 69e77ef..0000000
--- a/src/widget/display/layout_preview.rs
+++ /dev/null
@@ -1,208 +0,0 @@
-//! Narrow-trait `LayoutPreview` (Phase 5t) — a static thumbnail of a window-layout mode
-//! (fullscreen / cascade / grid / …) drawn as bordered boxes with per-node labels. Pure
-//! display: all geometry and text come out of [`Paint::paint`]. No consumers exist
-//! workspace-wide (only the re-exports); migrated for completeness of the Phase 5 sweep.
-
-use crate::scene::layout::Rect;
-use crate::scene::paint::PaintCtx;
-use crate::widget::{Adapted, Input, Layout, Paint};
-
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum PreviewLayoutMode {
- Fullscreen,
- Cascade,
- Stack,
- Grid,
- LeftTiled,
- RightTiled,
- Equal,
- Spiral,
- Floating,
-}
-
-struct SimNode {
- x: f32,
- y: f32,
- w: f32,
- h: f32,
- label: String,
-}
-
-#[derive(Debug, Clone)]
-pub struct LayoutPreview {
- pub mode: PreviewLayoutMode,
- pub is_active: bool,
- label: Option<String>,
-}
-
-impl LayoutPreview {
- pub fn new(mode: PreviewLayoutMode) -> Adapted<LayoutPreview> {
- Adapted::new(LayoutPreview { mode, is_active: false, label: None })
- }
-
- /// The simulated node boxes for `mode` inside a preview area of the given size — the one
- /// source both the boxes and their labels are drawn from (legacy duplicated this match in
- /// `extra_quads` and `text_labels`).
- fn sim_nodes(&self, preview_w: f32, preview_h: f32) -> Vec<SimNode> {
- let mut nodes = Vec::new();
- match self.mode {
- PreviewLayoutMode::Fullscreen => {
- nodes.push(SimNode { x: 2.0, y: 2.0, w: preview_w - 4.0, h: preview_h - 4.0, label: "F".to_string() });
- }
- PreviewLayoutMode::Cascade => {
- nodes.push(SimNode { x: 2.0, y: 2.0, w: preview_w - 12.0, h: preview_h - 12.0, label: "1".to_string() });
- nodes.push(SimNode { x: 6.0, y: 6.0, w: preview_w - 12.0, h: preview_h - 12.0, label: "2".to_string() });
- nodes.push(SimNode { x: 10.0, y: 10.0, w: preview_w - 12.0, h: preview_h - 12.0, label: "3".to_string() });
- }
- PreviewLayoutMode::Stack => {
- nodes.push(SimNode { x: 2.0, y: 2.0, w: preview_w - 4.0, h: preview_h - 4.0, label: "Stack".to_string() });
- }
- PreviewLayoutMode::Grid => {
- let hw = (preview_w - 6.0) / 2.0;
- let hh = (preview_h - 6.0) / 2.0;
- nodes.push(SimNode { x: 2.0, y: 2.0, w: hw, h: hh, label: "1".to_string() });
- nodes.push(SimNode { x: 4.0 + hw, y: 2.0, w: hw, h: hh, label: "2".to_string() });
- nodes.push(SimNode { x: 2.0, y: 4.0 + hh, w: hw, h: hh, label: "3".to_string() });
- nodes.push(SimNode { x: 4.0 + hw, y: 4.0 + hh, w: hw, h: hh, label: "4".to_string() });
- }
- PreviewLayoutMode::LeftTiled => {
- let mw = (preview_w - 6.0) * 0.55;
- let sw = (preview_w - 6.0) - mw;
- let sh = (preview_h - 6.0) / 2.0;
- nodes.push(SimNode { x: 2.0, y: 2.0, w: mw, h: preview_h - 4.0, label: "M".to_string() });
- nodes.push(SimNode { x: 4.0 + mw, y: 2.0, w: sw, h: sh, label: "1".to_string() });
- nodes.push(SimNode { x: 4.0 + mw, y: 4.0 + sh, w: sw, h: sh, label: "2".to_string() });
- }
- PreviewLayoutMode::RightTiled => {
- let mw = (preview_w - 6.0) * 0.55;
- let sw = (preview_w - 6.0) - mw;
- let sh = (preview_h - 6.0) / 2.0;
- nodes.push(SimNode { x: 2.0, y: 2.0, w: sw, h: sh, label: "1".to_string() });
- nodes.push(SimNode { x: 2.0, y: 4.0 + sh, w: sw, h: sh, label: "2".to_string() });
- nodes.push(SimNode { x: 4.0 + sw, y: 2.0, w: mw, h: preview_h - 4.0, label: "M".to_string() });
- }
- PreviewLayoutMode::Equal => {
- let ew = (preview_w - 8.0) / 3.0;
- nodes.push(SimNode { x: 2.0, y: 2.0, w: ew, h: preview_h - 4.0, label: "1".to_string() });
- nodes.push(SimNode { x: 4.0 + ew, y: 2.0, w: ew, h: preview_h - 4.0, label: "2".to_string() });
- nodes.push(SimNode { x: 6.0 + 2.0 * ew, y: 2.0, w: ew, h: preview_h - 4.0, label: "3".to_string() });
- }
- PreviewLayoutMode::Spiral => {
- let w1 = (preview_w - 6.0) * 0.5;
- let w2 = (preview_w - 6.0) - w1;
- let h2 = (preview_h - 6.0) * 0.5;
- nodes.push(SimNode { x: 2.0, y: 2.0, w: w1, h: preview_h - 4.0, label: "1".to_string() });
- nodes.push(SimNode { x: 4.0 + w1, y: 2.0, w: w2, h: h2, label: "2".to_string() });
- nodes.push(SimNode { x: 4.0 + w1, y: 4.0 + h2, w: w2 * 0.5, h: h2, label: "3".to_string() });
- nodes.push(SimNode { x: 4.0 + w1 + w2 * 0.5, y: 4.0 + h2, w: w2 * 0.5, h: h2, label: "4".to_string() });
- }
- PreviewLayoutMode::Floating => {
- nodes.push(SimNode { x: 4.0, y: 6.0, w: preview_w * 0.45, h: preview_h * 0.5, label: "1".to_string() });
- nodes.push(SimNode { x: preview_w * 0.4, y: 12.0, w: preview_w * 0.5, h: preview_h * 0.45, label: "2".to_string() });
- nodes.push(SimNode { x: 8.0, y: preview_h * 0.4, w: preview_w * 0.55, h: preview_h * 0.5, label: "3".to_string() });
- }
- }
- nodes
- }
-
- fn mode_name(&self) -> &'static str {
- match self.mode {
- PreviewLayoutMode::Fullscreen => "Fullscreen",
- PreviewLayoutMode::Cascade => "Cascade",
- PreviewLayoutMode::Stack => "Stack",
- PreviewLayoutMode::Grid => "Grid",
- PreviewLayoutMode::LeftTiled => "L-Tiled",
- PreviewLayoutMode::RightTiled => "R-Tiled",
- PreviewLayoutMode::Equal => "Equal",
- PreviewLayoutMode::Spiral => "Spiral",
- PreviewLayoutMode::Floating => "Floating",
- }
- }
-}
-
-impl Adapted<LayoutPreview> {
- pub fn with_active(mut self, active: bool) -> Self {
- self.is_active = active;
- self
- }
-}
-
-impl Layout for LayoutPreview {
- /// The tag/name header draws inside the widget rect.
- fn inline_label(&self) -> bool {
- true
- }
-}
-
-impl Paint for LayoutPreview {
- fn color(&self) -> [f32; 4] {
- [0.0, 0.0, 0.0, 0.0]
- }
-
- fn sync_label(&mut self, label: &str) {
- self.label = Some(label.to_string());
- }
-
- fn paint(&self, rect: Rect, ctx: &mut PaintCtx) {
- let (x, y, w, h) = (rect.x, rect.y, rect.width, rect.height);
-
- let bg_col = if self.is_active { [0.12, 0.24, 0.14, 0.55] } else { [0.08, 0.08, 0.12, 0.35] };
- let border_col = if self.is_active { [0.36, 0.56, 0.38, 0.95] } else { [0.24, 0.24, 0.28, 0.45] };
-
- ctx.quad(Rect { x, y, width: w, height: h }, bg_col);
- ctx.quad(Rect { x, y, width: w, height: 1.0 }, border_col);
- ctx.quad(Rect { x, y: y + h - 1.0, width: w, height: 1.0 }, border_col);
- ctx.quad(Rect { x, y, width: 1.0, height: h }, border_col);
- ctx.quad(Rect { x: x + w - 1.0, y, width: 1.0, height: h }, border_col);
-
- ctx.text(
- self.label.clone().unwrap_or_else(|| "TAG".to_string()),
- x + 8.0,
- y + 8.0,
- 10.0,
- [140, 140, 153],
- );
- ctx.text(self.mode_name().to_string(), x + 8.0, y + 20.0, 13.0, [230, 230, 242]);
-
- let preview_x = x + 8.0;
- let preview_y = y + 38.0;
- let preview_w = w - 16.0;
- let preview_h = h - 46.0;
-
- if preview_w > 0.0 && preview_h > 0.0 {
- ctx.quad(Rect { x: preview_x, y: preview_y, width: preview_w, height: preview_h }, [0.16, 0.16, 0.20, 0.6]);
- let preview_border = [0.22, 0.22, 0.26, 0.8];
- ctx.quad(Rect { x: preview_x, y: preview_y, width: preview_w, height: 1.0 }, preview_border);
- ctx.quad(Rect { x: preview_x, y: preview_y + preview_h - 1.0, width: preview_w, height: 1.0 }, preview_border);
- ctx.quad(Rect { x: preview_x, y: preview_y, width: 1.0, height: preview_h }, preview_border);
- ctx.quad(Rect { x: preview_x + preview_w - 1.0, y: preview_y, width: 1.0, height: preview_h }, preview_border);
-
- for node in self.sim_nodes(preview_w, preview_h) {
- let rect_x = preview_x + node.x;
- let rect_y = preview_y + node.y;
- let node_bg = if self.is_active { [0.30, 0.45, 0.65, 0.45] } else { [0.20, 0.24, 0.30, 0.25] };
- let node_border = if self.is_active { [0.45, 0.65, 0.90, 0.85] } else { [0.35, 0.40, 0.45, 0.55] };
-
- ctx.quad(Rect { x: rect_x, y: rect_y, width: node.w, height: node.h }, node_bg);
- ctx.quad(Rect { x: rect_x, y: rect_y, width: node.w, height: 1.0 }, node_border);
- ctx.quad(Rect { x: rect_x, y: rect_y + node.h - 1.0, width: node.w, height: 1.0 }, node_border);
- ctx.quad(Rect { x: rect_x, y: rect_y, width: 1.0, height: node.h }, node_border);
- ctx.quad(Rect { x: rect_x + node.w - 1.0, y: rect_y, width: 1.0, height: node.h }, node_border);
-
- let text_sz = 9.0;
- let text_w = node.label.len() as f32 * 6.0;
- let text_color = if self.is_active { [242, 242, 255] } else { [178, 178, 191] };
- let tx_offset = ((node.w - text_w) / 2.0).max(1.0);
- ctx.text(
- node.label,
- rect_x + tx_offset,
- crate::layout::align_text_y(rect_y, node.h, text_sz, 0.0),
- text_sz,
- text_color,
- );
- }
- }
- }
-}
-
-impl Input for LayoutPreview {}
diff --git a/src/widget/display/mod.rs b/src/widget/display/mod.rs
index 50a7a2f..ba7bba2 100644
--- a/src/widget/display/mod.rs
+++ b/src/widget/display/mod.rs
@@ -1,5 +1,4 @@
pub mod text_label;
-pub mod sidebar;
pub mod panel;
pub mod node;
pub mod label;
@@ -12,8 +11,6 @@ pub mod separator;
pub mod serialize;
pub mod graph;
pub mod usage_bar;
-pub mod layout_preview;
-pub mod font_preview;
pub mod info_box;
pub mod status_dot;
pub mod preview;
@@ -21,7 +18,6 @@ pub mod text_sizer;
pub use self::text_label::TextLabel;
pub(crate) use self::text_label::make_widget_text_buffer;
-pub use self::sidebar::Sidebar;
pub use self::panel::Panel;
pub use self::node::Node;
pub use self::label::{Label, StyledLabel, LabelPrim};
@@ -34,8 +30,6 @@ pub use self::separator::Separator;
pub use self::serialize::serialize_widgets;
pub use self::graph::{GraphNode, Graph};
pub use self::usage_bar::UsageBar;
-pub use self::layout_preview::{PreviewLayoutMode, LayoutPreview};
-pub use self::font_preview::FontPreview;
pub use self::info_box::InfoBox;
pub use self::status_dot::{DotStatus, StatusDot};
pub use self::preview::{PreviewState, ImagePreviewData};
diff --git a/src/widget/display/sidebar.rs b/src/widget/display/sidebar.rs
deleted file mode 100644
index e7605a9..0000000
--- a/src/widget/display/sidebar.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-//! Narrow-trait sidebar strip (Phase 5i leaf sweep). Pure colored band; the legacy struct's raw
-//! x/y/w/h fields now live on the `Adapted` base.
-
-use crate::colors;
-use crate::widget::{Adapted, WidgetHost, Input, Layout, Paint};
-
-pub struct Sidebar;
-
-impl Sidebar {
- pub fn new(w: f32) -> Adapted<Sidebar> {
- let mut s = Adapted::new(Sidebar);
- WidgetHost::set_rect(&mut s, 0.0, 0.0, w, 0.0);
- s
- }
-}
-
-impl Layout for Sidebar {}
-
-impl Paint for Sidebar {
- fn color(&self) -> [f32; 4] {
- colors::sidebar_bg_color()
- }
-}
-
-impl Input for Sidebar {}
diff --git a/src/widget/mod.rs b/src/widget/mod.rs
index ba26f8d..204157d 100644
--- a/src/widget/mod.rs
+++ b/src/widget/mod.rs
@@ -594,9 +594,9 @@ pub use self::container::{
};
pub use self::display::{
TextLabel, Label, StyledLabel, LabelPrim, TextItem, UsageBar,
- LayoutPreview, FontPreview, InfoBox, StatusDot, InteractiveListItem,
+ InfoBox, StatusDot, InteractiveListItem,
GraphNode, Graph, Float3, ProgressBar, StatusBar, Splitter, Node, Separator,
- DotStatus, PreviewLayoutMode, Sidebar, Panel, PreviewState, ImagePreviewData, serialize_widgets
+ DotStatus, Panel, PreviewState, ImagePreviewData, serialize_widgets
};
pub trait PageSelector {