git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commit7d5eeff06a62c42d61d73e131dfc5e40cee92341
parent26deadb288
authorLucas Galante <[email protected]>
date2026-07-30 10:18
fix: slide toggle label is fixed left — text shows through the glider

The free-half hopping is gone: the label always sits left-aligned, and
when the glider covers it the text stays legible through the glass —
glyphs render in the engine's later text pass, over the button's
mostly-transparent fill.

Co-Authored-By: Claude Fable 5 <[email protected]>

 src/widget/input/checkbox.rs | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/widget/input/checkbox.rs b/src/widget/input/checkbox.rs
index 1a4fcc7..f905453 100644
--- a/src/widget/input/checkbox.rs
+++ b/src/widget/input/checkbox.rs
@@ -528,15 +528,11 @@ impl Paint for Toggle {
             let (font_fam, font_size) = crate::layout::control_label_font_parsed();
             let est_w = crate::widget::display::measure_text_width(label, &font_fam, font_size);
             let tx = if slide {
-                // The label lives centered in the FREE half — the side the
-                // button has slid away from — so the two never fight. It
-                // follows the state, not the glide: the text hops at the
-                // click, the button catches up. A label wider than the half
-                // overflows AWAY from the button, never over it.
-                let half_w = w * 0.5;
-                let hx = if self.toggled { x } else { x + half_w };
-                let centered = hx + (half_w - est_w) / 2.0;
-                if self.toggled { centered.min(x + half_w - est_w - 4.0) } else { centered.max(hx + 4.0) }
+                // Fixed left alignment — the label never moves. When the
+                // glider covers it, the text shows through the glass: glyphs
+                // render in the engine's later text pass, over the button's
+                // mostly-transparent fill.
+                x + 8.0
             } else {
                 match self.justify {
                     Justification::Left => x + 8.0,