settings for text+bg colors, anim speed, rounding

This commit is contained in:
galister
2025-12-22 15:03:17 +09:00
parent b9513c3c36
commit a0bc4001c0
16 changed files with 134 additions and 76 deletions

View File

@@ -15,7 +15,7 @@
<template name="KeySpecial">
<div macro="keycap_div">
<rectangle id="${id}" macro="keycap_rect">
<sprite width="32" height="32" src="keyboard/${text}.svg" />
<sprite color="~color_text" width="32" height="32" src="keyboard/${text}.svg" />
</rectangle>
</div>
</template>

View File

@@ -54,6 +54,7 @@ impl InteractLockHandler {
&mut self,
common: &mut CallbackDataCommon,
app: &mut AppState,
anim_mult: f32,
) -> Box<ModifyOverlayTask> {
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::<WidgetRectangle>().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::<WidgetRectangle>().unwrap();

View File

@@ -282,6 +282,8 @@ fn make_edit_panel(app: &mut AppState) -> anyhow::Result<EditModeWrapPanel> {
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<EditModeWrapPanel> {
}
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)

View File

@@ -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::<WidgetRectangle>().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::<WidgetRectangle>().unwrap();

View File

@@ -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: ""

View File

@@ -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<String>) {
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();