GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
Added style.data.tree.open_search configuration support for tree searchbox keybind
src/color.rs | 19 +++++++++++++++++++
src/config.rs | 4 ++--
src/widget/container/treelist.rs | 2 +-
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/color.rs b/src/color.rs
index 72c5700..42389b0 100644
--- a/src/color.rs
+++ b/src/color.rs
@@ -53,6 +53,7 @@ static TREE_BACKGROUND_COLOR: RwLock<[f32; 4]> = RwLock::new([0.08, 0.08, 0.12,
static TREE_BORDER_COLOR: RwLock<[f32; 4]> = RwLock::new([0.18, 0.18, 0.24, 1.0]);
static TREE_BORDER_HOVER_COLOR: RwLock<[f32; 4]> = RwLock::new([0.25, 0.25, 0.35, 1.0]);
static TREE_BORDER_FOCUS_COLOR: RwLock<[f32; 4]> = RwLock::new([0.30, 0.50, 0.32, 1.0]);
+static TREE_OPEN_SEARCH_KEY: RwLock<String> = RwLock::new(String::new());
static TREE_SECTION_BG_COLOR: RwLock<[f32; 4]> = RwLock::new([0.07, 0.07, 0.09, 1.0]);
static TREE_SECTION_BG_HOVER_COLOR: RwLock<[f32; 4]> = RwLock::new([0.10, 0.12, 0.18, 1.0]);
@@ -372,6 +373,9 @@ fn parse_and_set_colors(content: &str) {
if let Some(c) = get_color("/style/data/tree/separator_color") {
if let Ok(mut lock) = TREE_SEPARATOR_COLOR.write() { *lock = c; }
}
+ if let Some(k) = val.pointer("/style/data/tree/open_search").and_then(|v| v.as_str()) {
+ if let Ok(mut lock) = TREE_OPEN_SEARCH_KEY.write() { *lock = k.to_string(); }
+ }
if let Some(c) = get_color("/style/control/scrollbar/track_color") {
if let Ok(mut lock) = SCROLLBAR_TRACK_COLOR.write() { *lock = c; }
}
@@ -936,3 +940,18 @@ pub fn set_scrollbar_track_color(c: [f32; 4]) { if let Ok(mut lock) = SCROLLBAR_
pub fn scrollbar_thumb_color() -> [f32; 4] { *SCROLLBAR_THUMB_COLOR.read().unwrap() }
pub fn set_scrollbar_thumb_color(c: [f32; 4]) { if let Ok(mut lock) = SCROLLBAR_THUMB_COLOR.write() { *lock = c; } }
+pub fn tree_open_search_key() -> String {
+ load_colors_once();
+ let val = TREE_OPEN_SEARCH_KEY.read().unwrap().clone();
+ if val.is_empty() {
+ "ctrl+f".to_string()
+ } else {
+ val
+ }
+}
+pub fn set_tree_open_search_key(k: String) {
+ if let Ok(mut lock) = TREE_OPEN_SEARCH_KEY.write() {
+ *lock = k;
+ }
+}
+
diff --git a/src/config.rs b/src/config.rs
index dfe01e4..f24cdbd 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -627,7 +627,7 @@ pub fn value_to_kdl_with_annotations(
let s_clean = s.trim_start_matches('#');
let ty = if s_clean.len() == 8 { "rgba" } else { "rgb" };
(format!("\"{}\"", s), Some(ty.to_string()))
- } else if prop_name == "key" || prop_name == "keybind" || prop_name == "shortcut" || prop_name.ends_with("_key") || prop_name.ends_with(".key") || prop_name.ends_with(".keybind") {
+ } else if prop_name == "key" || prop_name == "keybind" || prop_name == "shortcut" || prop_name == "open_search" || prop_name.ends_with("_key") || prop_name.ends_with(".key") || prop_name.ends_with(".keybind") {
(format!("\"{}\"", s), Some("keybind".to_string()))
} else {
(format!("\"{}\"", s), None)
@@ -668,7 +668,7 @@ pub fn value_to_kdl_with_annotations(
let s_clean = s.trim_start_matches('#');
let ty = if s_clean.len() == 8 { "rgba" } else { "rgb" };
(format!("\"{}\"", s), Some(ty.to_string()))
- } else if key == "key" || key == "keybind" || key == "shortcut" || key.ends_with("_key") || key.ends_with(".key") || key.ends_with(".keybind") {
+ } else if key == "key" || key == "keybind" || key == "shortcut" || key == "open_search" || key.ends_with("_key") || key.ends_with(".key") || key.ends_with(".keybind") {
(format!("\"{}\"", s), Some("keybind".to_string()))
} else {
(format!("\"{}\"", s), None)
diff --git a/src/widget/container/treelist.rs b/src/widget/container/treelist.rs
index 99eec22..f12e824 100644
--- a/src/widget/container/treelist.rs
+++ b/src/widget/container/treelist.rs
@@ -680,7 +680,7 @@ impl Element for TreeList {
} else {
Some("rgb")
}
- } else if name == "key" || name == "keybind" || name == "shortcut" || name.ends_with("_key") || name.ends_with(".key") || name.ends_with(".keybind") || name.ends_with(".shortcut") {
+ } else if name == "key" || name == "keybind" || name == "shortcut" || name == "open_search" || name.ends_with("_key") || name.ends_with(".key") || name.ends_with(".keybind") || name.ends_with(".shortcut") {
Some("keybind")
} else if name == "font" || name.ends_with("_font") || name.ends_with(".font") {
Some("font")