GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
Add open_upward layout direction setting to Dropdown widget
src/widget/input/dropdown.rs | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/widget/input/dropdown.rs b/src/widget/input/dropdown.rs
index b70ca7c..12a9937 100644
--- a/src/widget/input/dropdown.rs
+++ b/src/widget/input/dropdown.rs
@@ -13,6 +13,7 @@ pub struct Dropdown {
pub children: Vec<*mut (dyn Element + 'static)>,
pub font_family: String,
pub custom_display_text: Option<String>,
+ pub open_upward: Option<bool>,
}
impl Dropdown {
@@ -28,6 +29,7 @@ impl Dropdown {
children: Vec::new(),
font_family: "sans-serif".to_string(),
custom_display_text: None,
+ open_upward: None,
}
}
@@ -46,6 +48,11 @@ impl Dropdown {
self
}
+ pub fn with_open_upward(mut self, open_upward: bool) -> Self {
+ self.open_upward = Some(open_upward);
+ self
+ }
+
pub fn with_config(mut self, file: &str, key: &str) -> Self {
self.base.config_file = Some(file.to_string());
self.base.config_key = Some(key.to_string());
@@ -77,8 +84,8 @@ impl Dropdown {
}
pub fn get_dy_dh(&self) -> (f32, f32) {
- let open_upward = self.base.y > 400.0;
let dh = self.options.len() as f32 * 24.0;
+ let open_upward = self.open_upward.unwrap_or_else(|| self.base.y > 400.0);
let dy = if open_upward {
self.base.y - dh
} else {