From 02f1de59b23e2c74a8384abe8a3bfb82ea1bbec7 Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Sun, 12 Jul 2026 22:20:45 +0900 Subject: [PATCH] tweaks --- wayvr/src/assets/gui/toast.xml | 4 ++-- wayvr/src/assets/gui/watch.xml | 2 +- wgui/src/components/button.rs | 30 ++++++++++++++++++++++------- wgui/src/parser/component_button.rs | 19 ++++++++++++++---- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/wayvr/src/assets/gui/toast.xml b/wayvr/src/assets/gui/toast.xml index 1ad26ec7..27757534 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 b8f1ed86..933d6400 100644 --- a/wayvr/src/assets/gui/watch.xml +++ b/wayvr/src/assets/gui/watch.xml @@ -16,7 +16,7 @@ diff --git a/wgui/src/components/button.rs b/wgui/src/components/button.rs index f74b4799..12d19cba 100644 --- a/wgui/src/components/button.rs +++ b/wgui/src/components/button.rs @@ -3,24 +3,26 @@ use crate::{ assets::AssetPath, color::{WguiColor, WguiColorName}, components::{ - self, Component, ComponentBase, ComponentTrait, RefreshData, + self, tooltip::{ComponentTooltip, TooltipTrait}, + Component, ComponentBase, ComponentTrait, RefreshData, }, drawing::{self, Boundary}, event::{CallbackDataCommon, EventListenerCollection, EventListenerID, EventListenerKind}, i18n::Translation, layout::{WidgetID, WidgetPair}, renderer_vk::{ - text::{FontWeight, TextStyle, custom_glyph::CustomGlyphData}, + text::{custom_glyph::CustomGlyphData, FontWeight, TextStyle}, util::centered_matrix, }, sound::WguiSoundType, widget::{ - self, ConstructEssentials, EventResult, WidgetData, + self, label::{WidgetLabel, WidgetLabelParams}, rectangle::{WidgetRectangle, WidgetRectangleParams}, sprite::{WidgetSprite, WidgetSpriteParams}, util::WLength, + ConstructEssentials, EventResult, WidgetData, }, }; use glam::{Mat4, Vec2, Vec3}; @@ -29,7 +31,7 @@ use std::{ rc::Rc, time::{Duration, Instant}, }; -use taffy::{AlignItems, JustifyContent, prelude::length}; +use taffy::{prelude::length, AlignItems, JustifyContent}; pub struct Params<'a> { pub text: Option, // if unset, label will not be populated @@ -38,8 +40,10 @@ pub struct Params<'a> { pub color: Option, pub border: f32, pub border_color: Option, - pub hover_border_color: Option, pub hover_color: Option, + pub hover_border_color: Option, + pub sticky_color: Option, + pub sticky_border_color: Option, pub round: WLength, pub style: taffy::Style, pub text_style: TextStyle, @@ -58,10 +62,12 @@ impl Default for Params<'_> { text: Some(Translation::from_raw_text("")), sprite_src: None, color: None, - hover_color: None, border_color: None, - border: 2.0, + hover_color: None, hover_border_color: None, + sticky_color: None, + sticky_border_color: None, + border: 2.0, round: WLength::Units(4.0), style: Default::default(), text_style: TextStyle::default(), @@ -84,6 +90,8 @@ pub struct Colors { pub border_color: WguiColor, pub hover_color: WguiColor, pub hover_border_color: WguiColor, + pub sticky_color: WguiColor, + pub sticky_border_color: WguiColor, } struct State { @@ -478,6 +486,12 @@ pub fn construct(ess: &mut ConstructEssentials, params: Params) -> anyhow::Resul .hover_border_color .unwrap_or_else(|| border_color.add_rgb(0.5).add_alpha(0.5)); + let sticky_color = params.hover_color.unwrap_or_else(|| color.add_rgb(0.15).add_alpha(0.1)); + + let sticky_border_color = params + .hover_border_color + .unwrap_or_else(|| border_color.add_rgb(0.25).add_alpha(0.35)); + let gradient_intensity = theme.gradient_intensity; drop(globals); @@ -568,6 +582,8 @@ pub fn construct(ess: &mut ConstructEssentials, params: Params) -> anyhow::Resul border_color, hover_color, hover_border_color, + sticky_color, + sticky_border_color, }, })); diff --git a/wgui/src/parser/component_button.rs b/wgui/src/parser/component_button.rs index 10f8ea9e..8cdec888 100644 --- a/wgui/src/parser/component_button.rs +++ b/wgui/src/parser/component_button.rs @@ -1,14 +1,15 @@ use crate::{ assets::AssetPath, color::WguiColor, - components::{Component, button}, + components::{button, Component}, i18n::Translation, layout::WidgetID, parser::{ - AttribPair, ParserContext, ParserFile, get_asset_path_from_kv, - helpers::{TooltipAttribs, parse_attrib_tooltip}, + get_asset_path_from_kv, + helpers::{parse_attrib_tooltip, TooltipAttribs}, parse_children, parse_f32, process_component, style::{parse_color_opt, parse_round, parse_style, parse_text_style}, + AttribPair, ParserContext, ParserFile, }, widget::util::WLength, }; @@ -27,6 +28,8 @@ pub fn parse_component_button<'a>( let mut border_color: Option = None; let mut hover_color: Option = None; let mut hover_border_color: Option = None; + let mut sticky_color: Option = None; + let mut sticky_border_color: Option = None; let mut round = WLength::Units(4.0); let mut tooltip = TooltipAttribs::default(); let mut sticky: bool = false; @@ -79,6 +82,12 @@ pub fn parse_component_button<'a>( "hover_border_color" => { parse_color_opt(ctx, tag_name, key, value, &mut hover_border_color); } + "sticky_color" => { + parse_color_opt(ctx, tag_name, key, value, &mut sticky_color); + } + "sticky_border_color" => { + parse_color_opt(ctx, tag_name, key, value, &mut sticky_border_color); + } "sprite_src" | "sprite_src_ext" | "sprite_src_builtin" | "sprite_src_internal" => { let asset_path = get_asset_path_from_kv("sprite_", key, value); @@ -106,8 +115,10 @@ pub fn parse_component_button<'a>( color, border, border_color, - hover_border_color, hover_color, + hover_border_color, + sticky_color, + sticky_border_color, text: translation, style, text_style,