From a0bc4001c06b0e76bc3bdf6d550aceee93ca2845 Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Mon, 22 Dec 2025 15:03:17 +0900 Subject: [PATCH] settings for text+bg colors, anim speed, rounding --- dash-frontend/src/util/toast_manager.rs | 2 +- wgui/src/components/button.rs | 40 +++++++++++++------ wgui/src/components/checkbox.rs | 33 +++++++++------ wgui/src/components/slider.rs | 22 +++++----- wgui/src/globals.rs | 6 +++ wgui/src/parser/component_button.rs | 8 ++-- wgui/src/parser/mod.rs | 3 +- wgui/src/parser/style.rs | 10 ++--- wgui/src/parser/widget_rectangle.rs | 9 ++++- wlx-common/src/config.rs | 9 +++++ wlx-overlay-s/src/assets/gui/keyboard.xml | 2 +- wlx-overlay-s/src/overlays/edit/lock.rs | 5 ++- wlx-overlay-s/src/overlays/edit/mod.rs | 4 +- .../src/overlays/keyboard/builder.rs | 16 +++++--- wlx-overlay-s/src/res/config.yaml | 8 ++++ wlx-overlay-s/src/state.rs | 33 +++++++-------- 16 files changed, 134 insertions(+), 76 deletions(-) diff --git a/dash-frontend/src/util/toast_manager.rs b/dash-frontend/src/util/toast_manager.rs index d6eb3bd..929f6d9 100644 --- a/dash-frontend/src/util/toast_manager.rs +++ b/dash-frontend/src/util/toast_manager.rs @@ -124,7 +124,7 @@ impl ToastManager { // show-up animation layout.animations.add(Animation::new( rect.id, - 160, + 160, // does not use anim_mult AnimationEasing::Linear, Box::new(move |common, data| { let pos_showup = AnimationEasing::OutQuint.interpolate((data.pos * 4.0).min(1.0)); diff --git a/wgui/src/components/button.rs b/wgui/src/components/button.rs index c185220..6ab9043 100644 --- a/wgui/src/components/button.rs +++ b/wgui/src/components/button.rs @@ -1,29 +1,30 @@ use crate::{ animation::{Animation, AnimationEasing}, assets::AssetPath, - components::{self, Component, ComponentBase, ComponentTrait, RefreshData, tooltip::ComponentTooltip}, + components::{self, tooltip::ComponentTooltip, Component, ComponentBase, ComponentTrait, RefreshData}, drawing::{self, Boundary, Color}, event::{CallbackDataCommon, EventListenerCollection, EventListenerID, EventListenerKind}, i18n::Translation, layout::{LayoutTask, WidgetID, WidgetPair}, renderer_vk::{ text::{ - FontWeight, TextStyle, custom_glyph::{CustomGlyphContent, CustomGlyphData}, + FontWeight, TextStyle, }, util::centered_matrix, }, widget::{ - self, ConstructEssentials, EventResult, WidgetData, + self, label::{WidgetLabel, WidgetLabelParams}, rectangle::{WidgetRectangle, WidgetRectangleParams}, sprite::{WidgetSprite, WidgetSpriteParams}, util::WLength, + ConstructEssentials, EventResult, WidgetData, }, }; use glam::{Mat4, Vec3}; use std::{cell::RefCell, rc::Rc}; -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 @@ -170,10 +171,13 @@ impl ComponentButton { return; } + let anim_mult = common.state.globals.defaults().animation_mult; + let anim_ticks = if sticky_down { 5. } else { 10. }; + let state = self.state.clone(); let anim = Animation::new( self.data.id_rect, - if sticky_down { 5 } else { 10 }, + (anim_ticks * anim_mult) as _, AnimationEasing::OutCubic, Box::new(move |common, anim_data| { let rect = anim_data.obj.get_as_mut::().unwrap(); @@ -227,10 +231,10 @@ fn anim_hover( rect.params.border_color = init_border_color.lerp(&colors.hover_border_color, mult); } -fn anim_hover_create(state: Rc>, widget_id: WidgetID, fade_in: bool) -> Animation { +fn anim_hover_create(state: Rc>, widget_id: WidgetID, fade_in: bool, anim_mult: f32) -> Animation { Animation::new( widget_id, - if fade_in { 5 } else { 10 }, + ((if fade_in { 5. } else { 10. }) * anim_mult) as _, AnimationEasing::OutCubic, Box::new(move |common, anim_data| { let rect = anim_data.obj.get_as_mut::().unwrap(); @@ -254,6 +258,7 @@ fn register_event_mouse_enter( state: Rc>, listeners: &mut EventListenerCollection, info: Option, + anim_mult: f32, ) -> EventListenerID { listeners.register( EventListenerKind::MouseEnter, @@ -262,7 +267,7 @@ fn register_event_mouse_enter( common.alterables.mark_redraw(); common .alterables - .animate(anim_hover_create(state.clone(), event_data.widget_id, true)); + .animate(anim_hover_create(state.clone(), event_data.widget_id, true, anim_mult)); if let Some(info) = info.clone() { common.alterables.tasks.push(LayoutTask::ModifyLayoutState({ @@ -282,14 +287,18 @@ fn register_event_mouse_enter( ) } -fn register_event_mouse_leave(state: Rc>, listeners: &mut EventListenerCollection) -> EventListenerID { +fn register_event_mouse_leave( + state: Rc>, + listeners: &mut EventListenerCollection, + anim_mult: f32, +) -> EventListenerID { listeners.register( EventListenerKind::MouseLeave, Box::new(move |common, event_data, (), ()| { common.alterables.trigger_haptics(); common .alterables - .animate(anim_hover_create(state.clone(), event_data.widget_id, false)); + .animate(anim_hover_create(state.clone(), event_data.widget_id, false, anim_mult)); let mut state = state.borrow_mut(); state.active_tooltip = None; state.hovered = false; @@ -510,9 +519,16 @@ pub fn construct(ess: &mut ConstructEssentials, params: Params) -> anyhow::Resul id: root.id, lhandles: { let mut widget = ess.layout.state.widgets.get(id_rect).unwrap().state(); + let anim_mult = ess.layout.state.globals.defaults().animation_mult; vec![ - register_event_mouse_enter(data.clone(), state.clone(), &mut widget.event_listeners, params.tooltip), - register_event_mouse_leave(state.clone(), &mut widget.event_listeners), + register_event_mouse_enter( + data.clone(), + state.clone(), + &mut widget.event_listeners, + params.tooltip, + anim_mult, + ), + register_event_mouse_leave(state.clone(), &mut widget.event_listeners, anim_mult), register_event_mouse_press(state.clone(), &mut widget.event_listeners), register_event_mouse_release(data.clone(), state.clone(), &mut widget.event_listeners), ] diff --git a/wgui/src/components/checkbox.rs b/wgui/src/components/checkbox.rs index affe0af..71195c9 100644 --- a/wgui/src/components/checkbox.rs +++ b/wgui/src/components/checkbox.rs @@ -1,7 +1,7 @@ use std::{cell::RefCell, rc::Rc}; use taffy::{ - AlignItems, prelude::{length, percent}, + AlignItems, }; use crate::{ @@ -13,10 +13,10 @@ use crate::{ layout::{self, WidgetID, WidgetPair}, renderer_vk::text::{FontWeight, TextStyle}, widget::{ - ConstructEssentials, EventResult, label::{WidgetLabel, WidgetLabelParams}, rectangle::{WidgetRectangle, WidgetRectangleParams}, util::WLength, + ConstructEssentials, EventResult, }, }; @@ -120,10 +120,10 @@ fn anim_hover(rect: &mut WidgetRectangle, pos: f32, pressed: bool) { } } -fn anim_hover_in(state: Rc>, widget_id: WidgetID) -> Animation { +fn anim_hover_in(state: Rc>, widget_id: WidgetID, anim_mult: f32) -> Animation { Animation::new( widget_id, - 5, + (5. * anim_mult) as _, AnimationEasing::OutQuad, Box::new(move |common, anim_data| { let rect = anim_data.obj.get_as_mut::().unwrap(); @@ -133,10 +133,10 @@ fn anim_hover_in(state: Rc>, widget_id: WidgetID) -> Animation { ) } -fn anim_hover_out(state: Rc>, widget_id: WidgetID) -> Animation { +fn anim_hover_out(state: Rc>, widget_id: WidgetID, anim_mult: f32) -> Animation { Animation::new( widget_id, - 8, + (8. * anim_mult) as _, AnimationEasing::OutQuad, Box::new(move |common, anim_data| { let rect = anim_data.obj.get_as_mut::().unwrap(); @@ -146,28 +146,36 @@ fn anim_hover_out(state: Rc>, widget_id: WidgetID) -> Animation { ) } -fn register_event_mouse_enter(state: Rc>, listeners: &mut EventListenerCollection) -> EventListenerID { +fn register_event_mouse_enter( + state: Rc>, + listeners: &mut EventListenerCollection, + anim_mult: f32, +) -> EventListenerID { listeners.register( EventListenerKind::MouseEnter, Box::new(move |common, event_data, (), ()| { common.alterables.trigger_haptics(); common .alterables - .animate(anim_hover_in(state.clone(), event_data.widget_id)); + .animate(anim_hover_in(state.clone(), event_data.widget_id, anim_mult)); state.borrow_mut().hovered = true; Ok(EventResult::Pass) }), ) } -fn register_event_mouse_leave(state: Rc>, listeners: &mut EventListenerCollection) -> EventListenerID { +fn register_event_mouse_leave( + state: Rc>, + listeners: &mut EventListenerCollection, + anim_mult: f32, +) -> EventListenerID { listeners.register( EventListenerKind::MouseLeave, Box::new(move |common, event_data, (), ()| { common.alterables.trigger_haptics(); common .alterables - .animate(anim_hover_out(state.clone(), event_data.widget_id)); + .animate(anim_hover_out(state.clone(), event_data.widget_id, anim_mult)); state.borrow_mut().hovered = false; Ok(EventResult::Pass) }), @@ -341,9 +349,10 @@ pub fn construct(ess: &mut ConstructEssentials, params: Params) -> anyhow::Resul id: root.id, lhandles: { let mut widget = ess.layout.state.widgets.get(id_container).unwrap().state(); + let anim_mult = ess.layout.state.globals.defaults().animation_mult; vec![ - register_event_mouse_enter(state.clone(), &mut widget.event_listeners), - register_event_mouse_leave(state.clone(), &mut widget.event_listeners), + register_event_mouse_enter(state.clone(), &mut widget.event_listeners, anim_mult), + register_event_mouse_leave(state.clone(), &mut widget.event_listeners, anim_mult), register_event_mouse_press(state.clone(), &mut widget.event_listeners), register_event_mouse_release(data.clone(), state.clone(), &mut widget.event_listeners), ] diff --git a/wgui/src/components/slider.rs b/wgui/src/components/slider.rs index bbb0964..1b7f0f7 100644 --- a/wgui/src/components/slider.rs +++ b/wgui/src/components/slider.rs @@ -18,11 +18,11 @@ use crate::{ util, }, widget::{ - ConstructEssentials, EventResult, div::WidgetDiv, label::{WidgetLabel, WidgetLabelParams}, rectangle::{WidgetRectangle, WidgetRectangleParams}, util::WLength, + ConstructEssentials, EventResult, }, }; @@ -263,10 +263,10 @@ fn anim_rect(rect: &mut WidgetRectangle, pos: f32) { rect.params.border_color = drawing::Color::lerp(&HANDLE_BORDER_COLOR, &HANDLE_BORDER_COLOR_HOVERED, pos); } -fn on_enter_anim(common: &mut event::CallbackDataCommon, handle_id: WidgetID) { +fn on_enter_anim(common: &mut event::CallbackDataCommon, handle_id: WidgetID, anim_mult: f32) { common.alterables.animate(Animation::new( handle_id, - 20, + (20. * anim_mult) as _, AnimationEasing::OutBack, Box::new(move |common, data| { let rect = data.obj.get_as_mut::().unwrap(); @@ -277,10 +277,10 @@ fn on_enter_anim(common: &mut event::CallbackDataCommon, handle_id: WidgetID) { )); } -fn on_leave_anim(common: &mut event::CallbackDataCommon, handle_id: WidgetID) { +fn on_leave_anim(common: &mut event::CallbackDataCommon, handle_id: WidgetID, anim_mult: f32) { common.alterables.animate(Animation::new( handle_id, - 10, + (10. * anim_mult) as _, AnimationEasing::OutQuad, Box::new(move |common, data| { let rect = data.obj.get_as_mut::().unwrap(); @@ -295,13 +295,14 @@ fn register_event_mouse_enter( data: Rc, state: Rc>, listeners: &mut EventListenerCollection, + anim_mult: f32, ) -> event::EventListenerID { listeners.register( EventListenerKind::MouseEnter, Box::new(move |common, _data, (), ()| { common.alterables.trigger_haptics(); state.borrow_mut().hovered = true; - on_enter_anim(common, data.slider_handle_rect_id); + on_enter_anim(common, data.slider_handle_rect_id, anim_mult); Ok(EventResult::Pass) }), ) @@ -311,13 +312,14 @@ fn register_event_mouse_leave( data: Rc, state: Rc>, listeners: &mut EventListenerCollection, + anim_mult: f32, ) -> event::EventListenerID { listeners.register( EventListenerKind::MouseLeave, Box::new(move |common, _data, (), ()| { common.alterables.trigger_haptics(); state.borrow_mut().hovered = false; - on_leave_anim(common, data.slider_handle_rect_id); + on_leave_anim(common, data.slider_handle_rect_id, anim_mult); Ok(EventResult::Pass) }), ) @@ -500,12 +502,12 @@ pub fn construct(ess: &mut ConstructEssentials, params: Params) -> anyhow::Resul id: root.id, lhandles: { let mut widget = ess.layout.state.widgets.get(body_id).unwrap().state(); + let anim_mult = ess.layout.state.globals.defaults().animation_mult; vec![ - register_event_mouse_enter(data.clone(), state.clone(), &mut widget.event_listeners), - register_event_mouse_leave(data.clone(), state.clone(), &mut widget.event_listeners), + register_event_mouse_enter(data.clone(), state.clone(), &mut widget.event_listeners, anim_mult), + register_event_mouse_leave(data.clone(), state.clone(), &mut widget.event_listeners, anim_mult), register_event_mouse_motion(data.clone(), state.clone(), &mut widget.event_listeners), register_event_mouse_press(data.clone(), state.clone(), &mut widget.event_listeners), - register_event_mouse_leave(data.clone(), state.clone(), &mut widget.event_listeners), register_event_mouse_release(state.clone(), &mut widget.event_listeners), ] }, diff --git a/wgui/src/globals.rs b/wgui/src/globals.rs index 24b9524..cdcbe59 100644 --- a/wgui/src/globals.rs +++ b/wgui/src/globals.rs @@ -22,7 +22,10 @@ pub struct Defaults { pub accent_color: drawing::Color, pub danger_color: drawing::Color, pub faded_color: drawing::Color, + pub bg_color: drawing::Color, pub translucent_alpha: f32, + pub animation_mult: f32, + pub rounding_mult: f32, } impl Default for Defaults { @@ -34,7 +37,10 @@ impl Default for Defaults { accent_color: drawing::Color::new(0.0, 0.54, 1.0, 1.0), danger_color: drawing::Color::new(0.8, 0.0, 0.0, 1.0), faded_color: drawing::Color::new(0.4, 0.5, 0.6, 1.0), + bg_color: drawing::Color::new(0.0039, 0.0078, 0.0235, 0.8352), translucent_alpha: 0.25, + animation_mult: 1.0, + rounding_mult: 1.0, } } } diff --git a/wgui/src/parser/component_button.rs b/wgui/src/parser/component_button.rs index 1aeab62..02dab0f 100644 --- a/wgui/src/parser/component_button.rs +++ b/wgui/src/parser/component_button.rs @@ -1,13 +1,13 @@ use crate::{ assets::AssetPath, - components::{Component, button, tooltip}, + components::{button, tooltip, Component}, drawing::Color, i18n::Translation, layout::WidgetID, parser::{ - AttribPair, ParserContext, ParserFile, parse_check_f32, parse_check_i32, parse_children, print_invalid_attrib, - process_component, + parse_check_f32, parse_check_i32, parse_children, print_invalid_attrib, process_component, style::{parse_color_opt, parse_round, parse_style, parse_text_style}, + AttribPair, ParserContext, ParserFile, }, widget::util::WLength, }; @@ -45,7 +45,7 @@ pub fn parse_component_button<'a>( translation = Some(Translation::from_translation_key(value)); } "round" => { - parse_round(value, &mut round); + parse_round(value, &mut round, ctx.doc_params.globals.get().defaults.rounding_mult); } "color" => { parse_color_opt(value, &mut color); diff --git a/wgui/src/parser/mod.rs b/wgui/src/parser/mod.rs index ea22263..92fb89f 100644 --- a/wgui/src/parser/mod.rs +++ b/wgui/src/parser/mod.rs @@ -8,7 +8,7 @@ mod widget_rectangle; mod widget_sprite; use crate::{ - assets::{AssetPath, AssetPathOwned, normalize_path}, + assets::{normalize_path, AssetPath, AssetPathOwned}, components::{Component, ComponentWeak}, drawing::{self}, globals::WguiGlobals, @@ -400,6 +400,7 @@ impl ParserContext<'_> { insert_color_vars!(self, "accent", def.accent_color, def.translucent_alpha); insert_color_vars!(self, "danger", def.danger_color, def.translucent_alpha); insert_color_vars!(self, "faded", def.faded_color, def.translucent_alpha); + insert_color_vars!(self, "bg", def.bg_color, def.translucent_alpha); } } diff --git a/wgui/src/parser/style.rs b/wgui/src/parser/style.rs index 8e2b1a6..46a8cb0 100644 --- a/wgui/src/parser/style.rs +++ b/wgui/src/parser/style.rs @@ -6,22 +6,22 @@ use taffy::{ use crate::{ drawing, parser::{ - AttribPair, is_percent, parse_color_hex, parse_f32, parse_percent, parse_size_unit, parse_val, - print_invalid_attrib, print_invalid_value, + is_percent, parse_color_hex, parse_f32, parse_percent, parse_size_unit, parse_val, print_invalid_attrib, + print_invalid_value, AttribPair, }, renderer_vk::text::{FontWeight, HorizontalAlign, TextStyle}, widget::util::WLength, }; -pub fn parse_round(value: &str, round: &mut WLength) { +pub fn parse_round(value: &str, round: &mut WLength, multiplier: f32) { if is_percent(value) { if let Some(val) = parse_percent(value) { - *round = WLength::Percent(val); + *round = WLength::Percent((val * multiplier).clamp(0., 1.)); } else { print_invalid_value(value); } } else if let Some(val) = parse_f32(value) { - *round = WLength::Units(val); + *round = WLength::Units((val * multiplier).max(0.)); } else { print_invalid_value(value); } diff --git a/wgui/src/parser/widget_rectangle.rs b/wgui/src/parser/widget_rectangle.rs index 86ee223..0b42326 100644 --- a/wgui/src/parser/widget_rectangle.rs +++ b/wgui/src/parser/widget_rectangle.rs @@ -2,8 +2,9 @@ use crate::{ drawing::GradientMode, layout::WidgetID, parser::{ - AttribPair, ParserContext, ParserFile, parse_children, parse_widget_universal, print_invalid_attrib, + parse_children, parse_widget_universal, print_invalid_attrib, style::{parse_color, parse_round, parse_style}, + AttribPair, ParserContext, ParserFile, }, widget::rectangle::{WidgetRectangle, WidgetRectangleParams}, }; @@ -40,7 +41,11 @@ pub fn parse_widget_rectangle<'a>( } } "round" => { - parse_round(value, &mut params.round); + parse_round( + value, + &mut params.round, + ctx.doc_params.globals.get().defaults.rounding_mult, + ); } "border" => { params.border = value.parse().unwrap_or_else(|_| { diff --git a/wlx-common/src/config.rs b/wlx-common/src/config.rs index 03590e7..c064a51 100644 --- a/wlx-common/src/config.rs +++ b/wlx-common/src/config.rs @@ -92,9 +92,18 @@ pub struct GeneralConfig { #[serde(default = "def_theme_path")] pub theme_path: Arc, + pub color_text: Option, pub color_accent: Option, pub color_danger: Option, pub color_faded: Option, + pub color_background: Option, + + #[serde(default = "def_one")] + pub animation_speed: f32, + + #[serde(default = "def_one")] + pub round_multiplier: f32, + pub default_keymap: Option, #[serde(default)] diff --git a/wlx-overlay-s/src/assets/gui/keyboard.xml b/wlx-overlay-s/src/assets/gui/keyboard.xml index a2c5d1c..f012e92 100644 --- a/wlx-overlay-s/src/assets/gui/keyboard.xml +++ b/wlx-overlay-s/src/assets/gui/keyboard.xml @@ -15,7 +15,7 @@ diff --git a/wlx-overlay-s/src/overlays/edit/lock.rs b/wlx-overlay-s/src/overlays/edit/lock.rs index 4aa54ad..0825095 100644 --- a/wlx-overlay-s/src/overlays/edit/lock.rs +++ b/wlx-overlay-s/src/overlays/edit/lock.rs @@ -54,6 +54,7 @@ impl InteractLockHandler { &mut self, common: &mut CallbackDataCommon, app: &mut AppState, + anim_mult: f32, ) -> Box { let defaults = app.wgui_globals.get().defaults.clone(); let rect_color = self.color; @@ -63,7 +64,7 @@ impl InteractLockHandler { let anim = if self.interactable { Animation::new( self.id, - 10, + (10. * anim_mult) as _, AnimationEasing::OutQuad, Box::new(move |common, data| { let rect = data.obj.get_as_mut::().unwrap(); @@ -79,7 +80,7 @@ impl InteractLockHandler { } else { Animation::new( self.id, - 10, + (10. * anim_mult) as _, AnimationEasing::OutBack, Box::new(move |common, data| { let rect = data.obj.get_as_mut::().unwrap(); diff --git a/wlx-overlay-s/src/overlays/edit/mod.rs b/wlx-overlay-s/src/overlays/edit/mod.rs index 3694e1d..e6581b3 100644 --- a/wlx-overlay-s/src/overlays/edit/mod.rs +++ b/wlx-overlay-s/src/overlays/edit/mod.rs @@ -282,6 +282,8 @@ fn make_edit_panel(app: &mut AppState) -> anyhow::Result { mouse: SpriteTabHandler::default(), }; + let anim_mult = app.wgui_globals.defaults().animation_mult; + let on_custom_attrib: OnCustomAttribFunc = Box::new(move |layout, attribs, _app| { for (name, kind, test_btn) in &BUTTON_EVENTS { let Some(action) = attribs.get_value(name) else { @@ -300,7 +302,7 @@ fn make_edit_panel(app: &mut AppState) -> anyhow::Result { } let sel = OverlaySelector::Id(*state.id.borrow()); - let task = state.lock.toggle(common, app); + let task = state.lock.toggle(common, app, anim_mult); app.tasks .enqueue(TaskType::Overlay(OverlayTask::Modify(sel, task))); Ok(EventResult::Consumed) diff --git a/wlx-overlay-s/src/overlays/keyboard/builder.rs b/wlx-overlay-s/src/overlays/keyboard/builder.rs index 4989fb1..5974e42 100644 --- a/wlx-overlay-s/src/overlays/keyboard/builder.rs +++ b/wlx-overlay-s/src/overlays/keyboard/builder.rs @@ -39,11 +39,13 @@ pub(super) fn create_keyboard_panel( let globals = app.wgui_globals.clone(); let accent_color = globals.get().defaults.accent_color; + let anim_mult = globals.defaults().animation_mult; + let (background, _) = panel.layout.add_child( panel.layout.content_root_widget, WidgetRectangle::create(WidgetRectangleParams { - color: wgui::drawing::Color::new(0., 0., 0., 0.75), - round: WLength::Units(16.0), + color: globals.defaults().bg_color, + round: WLength::Units((16.0 * globals.defaults().rounding_mult).max(0.)), border: 2.0, border_color: accent_color, ..Default::default() @@ -176,7 +178,7 @@ pub(super) fn create_keyboard_panel( let k = key_state.clone(); move |common, data, _app, _state| { common.alterables.trigger_haptics(); - on_enter_anim(k.clone(), common, data, accent_color); + on_enter_anim(k.clone(), common, data, accent_color, anim_mult); Ok(EventResult::Pass) } }), @@ -188,7 +190,7 @@ pub(super) fn create_keyboard_panel( let k = key_state.clone(); move |common, data, _app, _state| { common.alterables.trigger_haptics(); - on_leave_anim(k.clone(), common, data, accent_color); + on_leave_anim(k.clone(), common, data, accent_color, anim_mult); Ok(EventResult::Pass) } }), @@ -291,10 +293,11 @@ fn on_enter_anim( common: &mut event::CallbackDataCommon, data: &event::CallbackData, accent_color: drawing::Color, + anim_mult: f32, ) { common.alterables.animate(Animation::new( data.widget_id, - 10, + (10. * anim_mult) as _, AnimationEasing::OutBack, Box::new(move |common, data| { let rect = data.obj.get_as_mut::().unwrap(); @@ -310,10 +313,11 @@ fn on_leave_anim( common: &mut event::CallbackDataCommon, data: &event::CallbackData, accent_color: drawing::Color, + anim_mult: f32, ) { common.alterables.animate(Animation::new( data.widget_id, - 15, + (15. * anim_mult) as _, AnimationEasing::OutQuad, Box::new(move |common, data| { let rect = data.obj.get_as_mut::().unwrap(); diff --git a/wlx-overlay-s/src/res/config.yaml b/wlx-overlay-s/src/res/config.yaml index 073a1d0..77624eb 100644 --- a/wlx-overlay-s/src/res/config.yaml +++ b/wlx-overlay-s/src/res/config.yaml @@ -91,9 +91,17 @@ #theme_path: "theme" ## These can be used to control the color theme of WlxOverlay-S. +#color_text: "#ffffff" #color_accent: "#008cff" #color_danger: "#ff3300" #color_faded: "#668299" +#color_background: "#010206", + +## Multiplier for animation speed. 2.0 → double speed, 0.5 → half speed +#animation_speed: 1.0 + +## Adjust this between 0..1 for a more rectangular feel. +#round_multiplier: 1.0 ## Path to custom skybox texture, relative to `~/.config/wlxoverlay` #skybox_texture: "" diff --git a/wlx-overlay-s/src/state.rs b/wlx-overlay-s/src/state.rs index e68c80f..072e463 100644 --- a/wlx-overlay-s/src/state.rs +++ b/wlx-overlay-s/src/state.rs @@ -3,7 +3,7 @@ use idmap::IdMap; use smallvec::{SmallVec, smallvec}; use std::sync::Arc; use wgui::{ - font_config::WguiFontConfig, gfx::WGfx, globals::WguiGlobals, parser::parse_color_hex, + drawing, font_config::WguiFontConfig, gfx::WGfx, globals::WguiGlobals, parser::parse_color_hex, renderer_vk::context::SharedContext as WSharedContext, }; use wlx_common::{ @@ -96,26 +96,21 @@ impl AppState { let theme = session.config.theme_path.clone(); let mut defaults = wgui::globals::Defaults::default(); - defaults.accent_color = session - .config - .color_accent - .as_ref() - .and_then(|c| parse_color_hex(&c)) - .unwrap_or(defaults.accent_color); - defaults.danger_color = session - .config - .color_danger - .as_ref() - .and_then(|c| parse_color_hex(&c)) - .unwrap_or(defaults.danger_color); + fn apply_color(default: &mut drawing::Color, value: &Option) { + if let Some(parsed) = value.as_ref().and_then(|c| parse_color_hex(c)) { + *default = parsed; + } + } - defaults.faded_color = session - .config - .color_faded - .as_ref() - .and_then(|c| parse_color_hex(&c)) - .unwrap_or(defaults.faded_color); + apply_color(&mut defaults.text_color, &session.config.color_text); + apply_color(&mut defaults.accent_color, &session.config.color_accent); + apply_color(&mut defaults.danger_color, &session.config.color_danger); + apply_color(&mut defaults.faded_color, &session.config.color_faded); + apply_color(&mut defaults.bg_color, &session.config.color_background); + + defaults.animation_mult = 1. / session.config.animation_speed; + defaults.rounding_mult = session.config.round_multiplier; let dbus = DbusConnector::default();