GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
dropdown: a per-widget face for the trigger plate
The trigger's plate face came only from the configured dropdown fill,
through face_from_fill, which forces it opaque. An app whose panes are
made of one material had no way to face its switchers with that same
material.
with_face() overrides it, defaulting to the old path when unset, so
nothing changes for a dropdown that does not ask.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
src/widget/input/dropdown.rs | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/widget/input/dropdown.rs b/src/widget/input/dropdown.rs
index 01d1465..cce2b8e 100644
--- a/src/widget/input/dropdown.rs
+++ b/src/widget/input/dropdown.rs
@@ -107,6 +107,12 @@ pub struct Dropdown {
/// Raised style: the closed control's background is an SDF-lit `Bevel`
/// plate (fill + rolled lit edge) instead of a flat fill + border stroke.
raised: Option<bool>,
+ /// Per-widget override for the trigger plate's FACE, bypassing
+ /// [`ControlPlate::face_from_fill`] on the configured fill. The default
+ /// forces the face opaque; an app that wants its controls made of the
+ /// same frosted material as its panes passes the blur-behind sentinel (a
+ /// negative alpha) here, which that helper would strip.
+ face: Option<[f32; 4]>,
/// Keyboard focus (FocusIn / FocusOut): lights the trigger plate's rim.
focused: bool,
/// The open menu REPLACES the trigger instead of growing out of it: no
@@ -162,6 +168,7 @@ impl Dropdown {
hovered: false,
corner_frame: None,
raised: None,
+ face: None,
focused: false,
menu_replaces_trigger: false,
anim_from: 0.0,
@@ -469,7 +476,7 @@ impl Dropdown {
Rect { x, y, width: w, height: visual_h },
radius,
crate::widget::PlateStance::Flush,
- crate::widget::ControlPlate::face_from_fill(raw_bg),
+ self.face.unwrap_or_else(|| crate::widget::ControlPlate::face_from_fill(raw_bg)),
)
.with_radii((r4[0], r4[1], r4[2], r4[3]))
.with_depth(depth)
@@ -748,6 +755,12 @@ impl Adapted<Dropdown> {
self
}
+ /// Override the trigger plate's face — see the `face` field.
+ pub fn with_face(mut self, face: [f32; 4]) -> Self {
+ self.face = Some(face);
+ self
+ }
+
pub fn with_custom_display_text(mut self, text: &str) -> Self {
self.custom_display_text = Some(text.to_string());
self