GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
Add BREADCRUMB_FONT layout static, parsing, getter/setter, and override widget_font in Breadcrumb
src/layout.rs | 47 ++++++++++++++++++++++++++++++++++++++
src/widget/container/breadcrumb.rs | 9 ++++++++
2 files changed, 56 insertions(+)
diff --git a/src/layout.rs b/src/layout.rs
index ddd758c..984def4c 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -42,6 +42,7 @@ static MENUBAR_FONT: RwLock<String> = RwLock::new(String::new());
static MENUBAR_FONT_CACHED: RwLock<Option<(String, f32)>> = RwLock::new(None);
static SECTION_LABEL_FONT: RwLock<String> = RwLock::new(String::new());
static NESTED_SECTION_LABEL_FONT: RwLock<String> = RwLock::new(String::new());
+static BREADCRUMB_FONT: RwLock<String> = RwLock::new(String::new());
static PAGINATOR_TAB_MARGIN_X: RwLock<f32> = RwLock::new(5.0);
static PAGINATOR_TAB_MARGIN_Y: RwLock<f32> = RwLock::new(10.0);
@@ -323,6 +324,14 @@ pub fn reload_config() {
*lock = font;
}
}
+ if let Some(rest) = trimmed.strip_prefix("breadcrumb_font") {
+ let rest = rest.trim_start_matches(|c: char| c == ' ' || c == '=');
+ let rest = mod_rest(rest);
+ let font = rest.trim().to_string();
+ if let Ok(mut lock) = BREADCRUMB_FONT.write() {
+ *lock = font;
+ }
+ }
if let Some(rest) = trimmed.strip_prefix("color_selector_preview_corner_radius") {
let rest = rest.trim_start_matches(|c: char| c == ' ' || c == '=' || c == '"');
let val_str = rest.trim_end_matches('"').trim();
@@ -1089,6 +1098,44 @@ pub fn set_nested_section_label_font(font: &str) {
}
}
+pub fn breadcrumb_font() -> String {
+ use std::sync::Once;
+ static INIT: Once = Once::new();
+ INIT.call_once(|| {
+ let mut font = "Outfit".to_string();
+ if let Some(content) = read_config() {
+ for line in content.lines() {
+ let trimmed = line.trim();
+ if let Some(rest) = trimmed.strip_prefix("breadcrumb_font") {
+ let rest = rest.trim_start_matches(|c: char| c == ' ' || c == '=');
+ let rest = rest.trim();
+ let val_str = if rest.starts_with('"') && rest.ends_with('"') && rest.len() >= 2 {
+ &rest[1..rest.len() - 1]
+ } else {
+ rest
+ };
+ font = val_str.trim().to_string();
+ }
+ }
+ }
+ if let Ok(mut lock) = BREADCRUMB_FONT.write() {
+ *lock = font;
+ }
+ });
+ let lock = BREADCRUMB_FONT.read().unwrap();
+ if lock.is_empty() {
+ "Outfit".to_string()
+ } else {
+ lock.clone()
+ }
+}
+
+pub fn set_breadcrumb_font(font: &str) {
+ if let Ok(mut lock) = BREADCRUMB_FONT.write() {
+ *lock = font.to_string();
+ }
+}
+
pub fn color_selector_preview_corner_radius() -> f32 {
use std::sync::Once;
static INIT: Once = Once::new();
diff --git a/src/widget/container/breadcrumb.rs b/src/widget/container/breadcrumb.rs
index efe5797..3f8c399 100644
--- a/src/widget/container/breadcrumb.rs
+++ b/src/widget/container/breadcrumb.rs
@@ -88,6 +88,15 @@ impl Element for Breadcrumb {
fn as_path_controller(&self) -> Option<&dyn PathController> { Some(self) }
fn as_path_controller_mut(&mut self) -> Option<&mut dyn PathController> { Some(self) }
+ fn widget_font(&self) -> Option<String> {
+ let font = crate::layout::breadcrumb_font();
+ if font.is_empty() {
+ None
+ } else {
+ Some(font)
+ }
+ }
+
fn extra_quads(&self) -> Vec<(f32, f32, f32, f32, [f32; 4])> {
let mut quads = Vec::new();
quads.push((self.x, self.y, self.w, self.h, self.color()));