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

commit9eae50b64698f306d4263d6e2a1c5cd182fa8327
parent518ae6b2a8
authorLucas Galante <[email protected]>
date2026-09-18 22:59
Button::new_icon: any bundled cce-icons glyph as a plateless icon button

new_copy_icon hardcoded the copy glyph; generalize it so a client can face
a bar button with another icon (cce-mail's app menu wants mail.svg) and
keep the copy constructor as a wrapper.

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

 src/widget/input/button.rs | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/widget/input/button.rs b/src/widget/input/button.rs
index 04c3a4d..ce6238e 100644
--- a/src/widget/input/button.rs
+++ b/src/widget/input/button.rs
@@ -122,12 +122,19 @@ impl Button {
     }
 
     pub fn new_copy_icon(x: f32, y: f32, w: f32, h: f32) -> Adapted<Button> {
+        Button::new_icon("copy", "📋", x, y, w, h)
+    }
+
+    /// A plateless icon button faced with the bundled cce-icons glyph
+    /// `<name>.svg` (see [`crate::upload_icon`]): transparent until hovered,
+    /// the [`ButtonKind::CopyIcon`] treatment, for glyphs that sit in a bar
+    /// rather than on a plate. `fallback` is the label drawn instead when the
+    /// icon set is missing on this machine.
+    pub fn new_icon(name: &str, fallback: &str, x: f32, y: f32, w: f32, h: f32) -> Adapted<Button> {
         let b = Button::adapted(ButtonKind::CopyIcon, x, y, w, h);
-        // Copy icon face (cce-icons); label fallback if the icon set is
-        // missing on this machine.
-        match crate::upload_icon("copy", 32) {
+        match crate::upload_icon(name, 32) {
             Some((id, iw, ih)) => b.with_icon(id, iw as f32, ih as f32),
-            None => b.with_label("📋"),
+            None => b.with_label(fallback),
         }
     }