diff --git a/dash-frontend/src/frontend.rs b/dash-frontend/src/frontend.rs
index 514b7f9b..78b35e45 100644
--- a/dash-frontend/src/frontend.rs
+++ b/dash-frontend/src/frontend.rs
@@ -29,8 +29,8 @@ use wlx_common::{
use crate::{
assets,
tab::{
- apps::TabApps, donate::TabDonate, games::TabGames, home::TabHome, monado::TabMonado, settings::TabSettings,
- welcome::TabWelcome, Tab, TabType,
+ Tab, TabType, apps::TabApps, donate::TabDonate, games::TabGames, home::TabHome, monado::TabMonado,
+ settings::TabSettings, welcome::TabWelcome,
},
util::{
popup_manager::{MountPopupOnceParams, PopupManager, PopupManagerParams},
diff --git a/dash-frontend/src/tab/settings/tab_look_and_feel.rs b/dash-frontend/src/tab/settings/tab_look_and_feel.rs
index df697371..d1f8218b 100644
--- a/dash-frontend/src/tab/settings/tab_look_and_feel.rs
+++ b/dash-frontend/src/tab/settings/tab_look_and_feel.rs
@@ -12,9 +12,8 @@ use wgui::{
use wlx_common::{config::GeneralConfig, dash_interface::ConfigChangeKind};
use crate::tab::settings::{
- horiz_cell,
- macros::{options_category, options_checkbox, options_dropdown, options_slider_f32, MacroParams},
- SettingType, SettingsMountParams, SettingsTab, Task,
+ SettingType, SettingsMountParams, SettingsTab, Task, horiz_cell,
+ macros::{MacroParams, options_category, options_checkbox, options_dropdown, options_slider_f32},
};
pub struct State {}
diff --git a/uidev/src/testbed/testbed_generic.rs b/uidev/src/testbed/testbed_generic.rs
index cc1fe30a..aa303479 100644
--- a/uidev/src/testbed/testbed_generic.rs
+++ b/uidev/src/testbed/testbed_generic.rs
@@ -8,9 +8,9 @@ use glam::Vec2;
use wgui::{
assets::AssetPath,
components::{
+ Component,
button::{ButtonClickCallback, ComponentButton},
checkbox::ComponentCheckbox,
- Component,
},
drawing::Color,
font_config::WguiFontConfig,
diff --git a/wayvr/src/assets/gui/grab-help.xml b/wayvr/src/assets/gui/grab-help.xml
index fdb4da20..dff8ef7b 100644
--- a/wayvr/src/assets/gui/grab-help.xml
+++ b/wayvr/src/assets/gui/grab-help.xml
@@ -10,15 +10,15 @@
diff --git a/wayvr/src/assets/gui/toast.xml b/wayvr/src/assets/gui/toast.xml
index b407acc5..1ad26ec7 100644
--- a/wayvr/src/assets/gui/toast.xml
+++ b/wayvr/src/assets/gui/toast.xml
@@ -10,8 +10,8 @@
-
-
+
+
diff --git a/wayvr/src/assets/gui/watch.xml b/wayvr/src/assets/gui/watch.xml
index 1791d715..b8f1ed86 100644
--- a/wayvr/src/assets/gui/watch.xml
+++ b/wayvr/src/assets/gui/watch.xml
@@ -3,8 +3,6 @@
-
-
@@ -18,7 +16,7 @@
-
+
@@ -83,12 +81,12 @@
diff --git a/wayvr/src/gui/panel/label.rs b/wayvr/src/gui/panel/label.rs
index 353b9b41..24b8f4ab 100644
--- a/wayvr/src/gui/panel/label.rs
+++ b/wayvr/src/gui/panel/label.rs
@@ -3,6 +3,8 @@ use std::rc::Rc;
use chrono::DateTime;
use chrono::Local;
use chrono_tz::Tz;
+use wgui::color::WguiColor;
+use wgui::globals::WguiGlobals;
use wgui::{
drawing,
event::{self, EventCallback},
@@ -17,6 +19,24 @@ use crate::{
state::AppState,
};
+fn parse_color(
+ attribs: &CustomAttribsInfoOwned,
+ key: &str,
+ globals: &WguiGlobals,
+ default: drawing::Color,
+) -> WguiColor {
+ let Some(value) = attribs.get_value(key) else {
+ return default.into();
+ };
+ if let Some(color) = drawing::Color::from_hex(value) {
+ return color.into();
+ }
+ if let Some(color) = globals.get().palette.find(value) {
+ return color;
+ }
+ default.into()
+}
+
#[allow(clippy::too_many_lines)]
pub(super) fn setup_custom_label(
layout: &mut Layout,
@@ -44,18 +64,19 @@ pub(super) fn setup_custom_label(
};
let state = BatteryLabelState {
- low_color: attribs
- .get_value("_low_color")
- .and_then(drawing::Color::from_hex)
- .unwrap_or(BAT_LOW),
- normal_color: attribs
- .get_value("_normal_color")
- .and_then(drawing::Color::from_hex)
- .unwrap_or(BAT_NORMAL),
- charging_color: attribs
- .get_value("_charging_color")
- .and_then(drawing::Color::from_hex)
- .unwrap_or(BAT_CHARGING),
+ low_color: parse_color(attribs, "_low_color", &layout.state.globals, BAT_LOW),
+ normal_color: parse_color(
+ attribs,
+ "_normal_color",
+ &layout.state.globals,
+ BAT_NORMAL,
+ ),
+ charging_color: parse_color(
+ attribs,
+ "_charging_color",
+ &layout.state.globals,
+ BAT_CHARGING,
+ ),
low_threshold: attribs
.get_value("_low_threshold")
.and_then(|s| s.parse().ok())
@@ -182,9 +203,9 @@ const BAT_LOW_THRESHOLD: u32 = 30;
struct BatteryLabelState {
device: usize,
- low_color: drawing::Color,
- normal_color: drawing::Color,
- charging_color: drawing::Color,
+ low_color: WguiColor,
+ normal_color: WguiColor,
+ charging_color: WguiColor,
low_threshold: u32,
}
@@ -211,7 +232,7 @@ fn battery_on_tick(
} else {
state.normal_color
};
- label.set_color(common, color.into(), false);
+ label.set_color(common, color, false);
label.set_text(common, Translation::from_raw_text(&text));
return;
}
diff --git a/wgui/src/components/slider.rs b/wgui/src/components/slider.rs
index d1f32466..b358366a 100644
--- a/wgui/src/components/slider.rs
+++ b/wgui/src/components/slider.rs
@@ -5,7 +5,7 @@ use taffy::prelude::{length, percent};
use crate::{
animation::{Animation, AnimationCallback, AnimationEasing},
- color::{WguiColor, WguiColorName}, palette::WguiColorPalette,
+ color::{WguiColor, WguiColorName},
components::{
Component, ComponentBase, ComponentTrait, RefreshData,
tooltip::{self, ComponentTooltip, TooltipTrait},
@@ -16,6 +16,7 @@ use crate::{
},
i18n::Translation,
layout::{WidgetID, WidgetPair},
+ palette::WguiColorPalette,
renderer_vk::{
text::{FontWeight, HorizontalAlign, TextStyle},
util,
diff --git a/wgui/src/renderer_vk/text/mod.rs b/wgui/src/renderer_vk/text/mod.rs
index 0ccdc7f6..4366026c 100644
--- a/wgui/src/renderer_vk/text/mod.rs
+++ b/wgui/src/renderer_vk/text/mod.rs
@@ -108,11 +108,7 @@ impl From<&TextStyle> for Metrics {
impl From<&TextStyle> for Wrap {
fn from(value: &TextStyle) -> Self {
- if value.wrap {
- Self::WordOrGlyph
- } else {
- Self::None
- }
+ if value.wrap { Self::WordOrGlyph } else { Self::None }
}
}