color tweaks & fmt

This commit is contained in:
galister 2026-07-12 21:27:44 +09:00
parent e79dfcb719
commit 0a7f8340d7
9 changed files with 55 additions and 40 deletions

View File

@ -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},

View File

@ -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 {}

View File

@ -8,9 +8,9 @@ use glam::Vec2;
use wgui::{
assets::AssetPath,
components::{
Component,
button::{ButtonClickCallback, ComponentButton},
checkbox::ComponentCheckbox,
Component,
},
drawing::Color,
font_config::WguiFontConfig,

View File

@ -10,15 +10,15 @@
<div flex_direction="row" padding="8" justify_content="space_between">
<div flex_direction="column" align_items="center" gap="8" max_width="160" min_width="160">
<sprite src="grab-help/controller-grip-joy.svg" min_width="128" min_height="128" max_width="128" max_height="128" flex_grow="1" />
<sprite src="grab-help/controller-grip-joy.svg" min_width="128" min_height="128" max_width="128" max_height="128" flex_grow="1" color="primary" />
<label wrap="1" size="25" padding_left="16" padding_right="16" translation="GRAB.ADJUST_DISTANCE" align="center" />
</div>
<div flex_direction="column" align_items="center" gap="8" max_width="160" min_width="160">
<sprite src="grab-help/controller-grip-trigger-joy.svg" min_width="128" min_height="128" max_width="128" max_height="128" flex_grow="1" />
<sprite src="grab-help/controller-grip-trigger-joy.svg" min_width="128" min_height="128" max_width="128" max_height="128" flex_grow="1" color="primary" />
<label wrap="1" size="25" padding_left="16" padding_right="16" translation="GRAB.ADJUST_SIZE" align="center" />
</div>
<div flex_direction="column" align_items="center" gap="8" max_width="160" min_width="160">
<sprite src="grab-help/controller-grip-b.svg" min_width="128" min_height="128" max_width="128" max_height="128" flex_grow="1" />
<sprite src="grab-help/controller-grip-b.svg" min_width="128" min_height="128" max_width="128" max_height="128" flex_grow="1" color="primary" />
<label wrap="1" size="25" padding_left="16" padding_right="16" translation="GRAB.UNRESTRICTED_MOVEMENT" align="center" />
</div>
</div>

View File

@ -10,8 +10,8 @@
<!-- Toast title -->
<div flex_direction="row" align_items="center" gap="8">
<sprite src="icons/bell.svg" color="on_background" min_width="32" min_height="32" max_width="32" max_height="32" flex_grow="1" />
<label wrap="1" id="toast_title" color="on_background" weight="bold" size="25" padding_left="16" padding_right="16" />
<sprite src="icons/bell.svg" color="on_background_variant" min_width="32" min_height="32" max_width="32" max_height="32" flex_grow="1" />
<label wrap="1" id="toast_title" color="on_background_variant" weight="bold" size="25" padding_left="16" padding_right="16" />
</div>
<!-- A simple separator -->

View File

@ -3,8 +3,6 @@
<var key="clock0_size" value="46" />
<var key="clock0_date_size" value="16" />
<var key="clock0_dow_size" value="16" />
<var key="clock_alt1_color" value="#8bd5ca" />
<var key="clock_alt2_color" value="#b7bdf8" />
<var key="clock_alt_size" value="24" />
<var key="clock_alt_tz_size" value="14" />
</theme>
@ -18,7 +16,7 @@
<template name="Device">
<rectangle macro="decorative_rect" padding_top="4" padding_bottom="4" align_items="center" gap="8">
<sprite width="32" height="32" src_builtin="${src}" color="on_background" />
<label _source="battery" _device="${idx}" size="24" weight="bold" />
<label _source="battery" _device="${idx}" size="24" weight="bold" _low_color="danger" _normal_color="primary" _charging_color="secondary" />
</rectangle>
</template>
@ -83,12 +81,12 @@
<div flex_direction="row" gap="8" justify_content="space_around">
<!-- Timezone names here are only placeholders. Set your timezones via ~/.config/wayvr/conf.d -->
<div flex_direction="column">
<label text="Paris" _source="clock" _display="name" _timezone="0" color="~clock_alt1_color" size="~clock_alt_tz_size" weight="bold" align="center" />
<label text="23:59" _source="clock" _display="time" _timezone="0" color="~clock_alt1_color" size="~clock_alt_size" weight="bold" align="center" />
<label text="Paris" _source="clock" _display="name" _timezone="0" color="secondary" size="~clock_alt_tz_size" weight="bold" align="center" />
<label text="23:59" _source="clock" _display="time" _timezone="0" color="secondary" size="~clock_alt_size" weight="bold" align="center" />
</div>
<div flex_direction="column">
<label text="New York" _source="clock" _display="name" _timezone="1" color="~clock_alt2_color" size="~clock_alt_tz_size" weight="bold" align="center" />
<label text="23:59" _source="clock" _display="time" _timezone="1" color="~clock_alt2_color" size="~clock_alt_size" weight="bold" align="center" />
<label text="New York" _source="clock" _display="name" _timezone="1" color="tertiary" size="~clock_alt_tz_size" weight="bold" align="center" />
<label text="23:59" _source="clock" _display="time" _timezone="1" color="tertiary" size="~clock_alt_size" weight="bold" align="center" />
</div>
</div>
</div>

View File

@ -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<S: 'static>(
layout: &mut Layout,
@ -44,18 +64,19 @@ pub(super) fn setup_custom_label<S: 'static>(
};
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;
}

View File

@ -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,

View File

@ -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 }
}
}