GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
Implement ScrollingList background color configuration and fix Makefile install target path
Makefile | 2 +-
src/color.rs | 15 +++++++++++++++
src/widget/container/scroll_box.rs | 4 ++--
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 72a0653..d16078c 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ build:
install: build
mkdir -p ~/.local/bin
- install -m 755 target/release/clear-ui ~/.local/bin/clear-ui
+ install -m 755 ../target/release/clear-ui ~/.local/bin/clear-ui
run:
cargo run
diff --git a/src/color.rs b/src/color.rs
index bff5603..9b6e673 100644
--- a/src/color.rs
+++ b/src/color.rs
@@ -35,6 +35,7 @@ static MENUBAR_TAB_LABEL_COLOR: RwLock<[f32; 4]> = RwLock::new([0.90196, 0.90196
static OPACITY: RwLock<Option<f32>> = RwLock::new(None);
static TOGGLE_ON_COLOR: RwLock<[f32; 4]> = RwLock::new(TOGGLE_ON);
static TOGGLE_OFF_COLOR: RwLock<[f32; 4]> = RwLock::new(TOGGLE_OFF);
+static SCROLLINGLIST_BG_COLOR: RwLock<[f32; 4]> = RwLock::new([0.08, 0.08, 0.12, 0.3]);
pub fn node_color() -> [f32; 4] {
@@ -149,6 +150,9 @@ fn parse_and_set_colors(content: &str) {
if let Some(c) = parse_hex(trimmed, "toggle_disabled_color") {
if let Ok(mut lock) = TOGGLE_OFF_COLOR.write() { *lock = c; }
}
+ if let Some(c) = parse_hex(trimmed, "scrollinglist_bg_color") {
+ if let Ok(mut lock) = SCROLLINGLIST_BG_COLOR.write() { *lock = [c[0], c[1], c[2], 0.3]; }
+ }
}
}
@@ -323,6 +327,17 @@ pub fn set_toggle_off_color(color: [f32; 4]) {
}
}
+pub fn scrollinglist_bg_color() -> [f32; 4] {
+ load_colors_once();
+ *SCROLLINGLIST_BG_COLOR.read().unwrap()
+}
+
+pub fn set_scrollinglist_bg_color(color: [f32; 4]) {
+ if let Ok(mut lock) = SCROLLINGLIST_BG_COLOR.write() {
+ *lock = [color[0], color[1], color[2], 0.3];
+ }
+}
+
#[derive(Debug, Clone, Copy)]
pub struct Theme {
pub surface_bg: [f32; 4],
diff --git a/src/widget/container/scroll_box.rs b/src/widget/container/scroll_box.rs
index 2475ee1..59e5bd7 100644
--- a/src/widget/container/scroll_box.rs
+++ b/src/widget/container/scroll_box.rs
@@ -62,7 +62,7 @@ impl Element for ScrollBox {
self.viewport_y = y + self.viewport_offset_y;
self.viewport_h = h + self.viewport_offset_h;
}
- fn color(&self) -> [f32; 4] { [0.08, 0.08, 0.12, 0.3] }
+ fn color(&self) -> [f32; 4] { crate::color::scrollinglist_bg_color() }
fn set_hovered(&mut self, v: bool) { self.hovered = v; }
fn hovered(&self) -> bool { self.hovered }
fn highlight_color(&self, ctx: &UiContext) -> Option<[f32; 4]> { None }
@@ -108,7 +108,7 @@ impl Element for ScrollBox {
let mut quads = Vec::new();
// Background
- quads.push((self.x, self.y, self.w, self.h, [0.08, 0.08, 0.12, 0.3]));
+ quads.push((self.x, self.y, self.w, self.h, crate::color::scrollinglist_bg_color()));
// Border lines
let box_border_color = if focus::is_focused(self) {