GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
Vertically center text and arrow in Dropdown using mathematical bounding box center
src/widget/input/dropdown.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/widget/input/dropdown.rs b/src/widget/input/dropdown.rs
index d52b246..92a3de7 100644
--- a/src/widget/input/dropdown.rs
+++ b/src/widget/input/dropdown.rs
@@ -541,7 +541,7 @@ impl Element for Dropdown {
let start_x = x + 8.0;
let right_limit = x + w - 28.0; // 10px margin before the arrow
let fade_start_x = (right_limit - 24.0).max(start_x); // Fade out over the last 24px
- let text_y = crate::layout::align_text_y(self.base.y, self.base.h, 12.0, top);
+ let text_y = self.base.y + top + (self.base.h - top - 12.0) / 2.0;
let tc = colors::dropdown_text_color();
let default_color = [
(colors::linear_to_srgb(tc[0]) * 255.0).round() as u8,
@@ -669,7 +669,7 @@ impl Element for Dropdown {
labels.push(TextLabel {
text: "▼".to_string(),
x: x + w - 18.0,
- y: crate::layout::align_text_y(self.base.y, self.base.h, 10.0, top),
+ y: self.base.y + top + (self.base.h - top - 10.0) / 2.0,
font_size: 10.0,
color: [0x83, 0x83, 0x8a],
});