From 6244f9726e0fc30be3e07fd5fa519e08108edd9f Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 25 Nov 2024 13:15:13 -0500 Subject: [PATCH] feat(ags osk): add excl button and cap slide up anim --- nixosModules/ags/config/configurations/wim.ts | 4 -- nixosModules/ags/config/style/main.scss | 2 +- .../widgets/on-screen-keyboard/_index.scss | 15 ++++++ .../widgets/on-screen-keyboard/gesture.ts | 13 +++-- .../widgets/on-screen-keyboard/keyboard.tsx | 50 +++++++++++++++++-- 5 files changed, 72 insertions(+), 12 deletions(-) diff --git a/nixosModules/ags/config/configurations/wim.ts b/nixosModules/ags/config/configurations/wim.ts index 2f6d8e87..67567a91 100644 --- a/nixosModules/ags/config/configurations/wim.ts +++ b/nixosModules/ags/config/configurations/wim.ts @@ -46,10 +46,6 @@ export default () => { popup_osd(request.replace('popup ', '')); respond('osd popped up'); } - else if (request.startsWith('osk')) { - console.log(`TODO: ${request.replace('osk ', '')}`); - respond('implement this'); - } }, main: () => { diff --git a/nixosModules/ags/config/style/main.scss b/nixosModules/ags/config/style/main.scss index d7822bfb..0c9a5fd5 100644 --- a/nixosModules/ags/config/style/main.scss +++ b/nixosModules/ags/config/style/main.scss @@ -7,7 +7,7 @@ @use '../widgets/icon-browser'; @use '../widgets/misc'; @use '../widgets/notifs'; +@use '../widgets/on-screen-display'; @use '../widgets/on-screen-keyboard'; -@use '../widgets/osd'; @use '../widgets/powermenu'; @use '../widgets/screenshot'; diff --git a/nixosModules/ags/config/widgets/on-screen-keyboard/_index.scss b/nixosModules/ags/config/widgets/on-screen-keyboard/_index.scss index a5456401..bcb82491 100644 --- a/nixosModules/ags/config/widgets/on-screen-keyboard/_index.scss +++ b/nixosModules/ags/config/widgets/on-screen-keyboard/_index.scss @@ -1,6 +1,21 @@ @use 'sass:color'; @use '../../style/colors'; +.settings { + padding: 0.5rem; + + .button { + background-color: colors.$window_bg_color; + border: 0.1rem solid color.adjust(colors.$window_bg_color, $lightness: -3%); + border-radius: 0.7rem; + padding: 0.3rem; + + &.toggled { + background-color: colors.$accent-color; + } + } +} + .osk { padding-top: 4px; border-radius: 10px 10px 0; diff --git a/nixosModules/ags/config/widgets/on-screen-keyboard/gesture.ts b/nixosModules/ags/config/widgets/on-screen-keyboard/gesture.ts index 6e08d351..27681122 100644 --- a/nixosModules/ags/config/widgets/on-screen-keyboard/gesture.ts +++ b/nixosModules/ags/config/widgets/on-screen-keyboard/gesture.ts @@ -85,9 +85,16 @@ export default (window: OskWindow) => { return; } - window.get_child().css = ` - margin-bottom: ${offset - HIDDEN_MARGIN}px; - `; + if (offset > HIDDEN_MARGIN) { + window.get_child().css = ` + margin-bottom: 0px; + `; + } + else { + window.get_child().css = ` + margin-bottom: ${offset - HIDDEN_MARGIN}px; + `; + } }); }), ); diff --git a/nixosModules/ags/config/widgets/on-screen-keyboard/keyboard.tsx b/nixosModules/ags/config/widgets/on-screen-keyboard/keyboard.tsx index 61fc7548..57f08cde 100644 --- a/nixosModules/ags/config/widgets/on-screen-keyboard/keyboard.tsx +++ b/nixosModules/ags/config/widgets/on-screen-keyboard/keyboard.tsx @@ -1,4 +1,5 @@ -import { Gtk, Widget } from 'astal/gtk3'; +import { Astal, astalify, Gtk, type ConstructProps, Widget } from 'astal/gtk3'; +import { register } from 'astal/gobject'; import Separator from '../misc/separator'; @@ -6,15 +7,26 @@ import Key from './keys'; import { defaultOskLayout, oskLayouts } from './keyboard-layouts'; + const keyboardLayout = defaultOskLayout; const keyboardJson = oskLayouts[keyboardLayout]; +@register() +class ToggleButton extends astalify(Gtk.ToggleButton) { + constructor(props: ConstructProps< + ToggleButton, + Gtk.ToggleButton.ConstructorProps + >) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + super(props as any); + } +} const L_KEY_PER_ROW = [8, 7, 6, 6, 6, 4]; // eslint-disable-line const COLOR = 'rgba(0, 0, 0, 0.3)'; const SPACING = 4; -export default (): Widget.Box => ( +export default () => ( ( + + { + self.toggleClassName( + 'toggled', + self.get_active(), + ); + + if (self.get_toplevel() === self) { + return; + } + + (self.get_toplevel() as Widget.Window | undefined) + ?.set_exclusivity( + self.get_active() ? + Astal.Exclusivity.EXCLUSIVE : + Astal.Exclusivity.NORMAL, + ); + }} + > + Exclusive + + ( return ( -