Compare commits

..

No commits in common. "b4e51f101082a9a318ff588616c3e86f16f630c4" and "2a64ff2a963915b1ddb28c75e915cf49289b50b6" have entirely different histories.

6 changed files with 87 additions and 151 deletions

View file

@ -2,10 +2,7 @@ import { Box, DrawingArea } from 'resource:///com/github/Aylur/ags/widget.js';
import Gtk from 'gi://Gtk'; import Gtk from 'gi://Gtk';
const Lang = imports.lang; const Lang = imports.lang;
export default ( export default place => Box({
place,
css = 'background-color: black;',
) => Box({
hpack: place.includes('left') ? 'start' : 'end', hpack: place.includes('left') ? 'start' : 'end',
vpack: place.includes('top') ? 'start' : 'end', vpack: place.includes('top') ? 'start' : 'end',
css: ` css: `
@ -17,9 +14,10 @@ export default (
`, `,
child: DrawingArea({ child: DrawingArea({
css: ` css: `
background-color: black;
border-radius: 18px; border-radius: 18px;
border-width: 0.068rem; border-width: 0.068rem;
` + css, `,
setup: widget => { setup: widget => {
const r = widget.get_style_context() const r = widget.get_style_context()
.get_property('border-radius', Gtk.StateFlags.NORMAL); .get_property('border-radius', Gtk.StateFlags.NORMAL);

View file

@ -1,16 +1,16 @@
import { Box } from 'resource:///com/github/Aylur/ags/widget.js'; import { Box } from 'resource:///com/github/Aylur/ags/widget.js';
export default (size, { vertical = false, css = '', ...props } = {}) => { export default (size, { vertical = false, ...props } = {}) => {
if (vertical) { if (vertical) {
return Box({ return Box({
css: `min-height: ${size}px; ${css}`, css: `min-height: ${size}px;`,
...props, ...props,
}); });
} }
else { else {
return Box({ return Box({
css: `min-width: ${size}px; ${css}`, css: `min-width: ${size}px;`,
...props, ...props,
}); });
} }

View file

@ -1,46 +1,10 @@
import { execAsync, timeout } from 'resource:///com/github/Aylur/ags/utils.js';
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js'; import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
import Gtk from 'gi://Gtk'; import Gtk from 'gi://Gtk';
const releaseAllKeys = () => {
const keycodes = Array.from(Array(249).keys());
execAsync([
'ydotool', 'key',
...keycodes.map(keycode => `${keycode}:0`),
]).catch(print);
};
const hidden = 340;
export default window => { export default window => {
window.child.setCss(`margin-bottom: -${hidden}px;`);
const gesture = Gtk.GestureDrag.new(window); const gesture = Gtk.GestureDrag.new(window);
window.setVisible = state => {
if (state) {
window.visible = true;
window.setSlideDown();
window.child.setCss(`
transition: margin-bottom 0.7s cubic-bezier(0.36, 0, 0.66, -0.56);
margin-bottom: 0px;
`);
}
else {
timeout(710, () => {
if (!Tablet.tabletMode)
window.visible = false;
});
releaseAllKeys();
window.setSlideUp();
window.child.setCss(`
transition: margin-bottom 0.7s cubic-bezier(0.36, 0, 0.66, -0.56);
margin-bottom: -${hidden}px;
`);
}
};
gesture.signals = []; gesture.signals = [];
window.killGestureSigs = () => { window.killGestureSigs = () => {
gesture.signals.forEach(id => gesture.disconnect(id)); gesture.signals.forEach(id => gesture.disconnect(id));
@ -48,6 +12,8 @@ export default window => {
}; };
window.setSlideUp = () => { window.setSlideUp = () => {
console.log(window.get_allocated_height());
window.killGestureSigs(); window.killGestureSigs();
// Begin drag // Begin drag
@ -70,7 +36,7 @@ export default window => {
return; return;
window.child.setCss(` window.child.setCss(`
margin-bottom: ${offset - hidden}px; margin-bottom: ${offset}px;
`); `);
}); });
}), }),
@ -81,7 +47,7 @@ export default window => {
gesture.connect('drag-end', () => { gesture.connect('drag-end', () => {
window.child.setCss(` window.child.setCss(`
transition: margin-bottom 0.5s ease-in-out; transition: margin-bottom 0.5s ease-in-out;
margin-bottom: -${hidden}px; margin-bottom: 0px;
`); `);
}), }),
); );
@ -127,5 +93,7 @@ export default window => {
); );
}; };
window.setSlideDown();
return window; return window;
}; };

View file

@ -1,7 +1,6 @@
import { Box, CenterBox, Label, ToggleButton } from 'resource:///com/github/Aylur/ags/widget.js'; import { Box, CenterBox, Label, ToggleButton } from 'resource:///com/github/Aylur/ags/widget.js';
import Separator from '../misc/separator.js'; import Separator from '../misc/separator.js';
import RoundedCorner from '../corners/screen-corners.js';
import Key from './keys.js'; import Key from './keys.js';
import { defaultOskLayout, oskLayouts } from './keyboard-layouts.js'; import { defaultOskLayout, oskLayouts } from './keyboard-layouts.js';
@ -11,26 +10,7 @@ const keyboardJson = oskLayouts[keyboardLayout];
const L_KEY_PER_ROW = [8, 7, 6, 6, 6, 4]; const L_KEY_PER_ROW = [8, 7, 6, 6, 6, 4];
const color = 'rgba(0, 0, 0, 0.3)'; export default window => CenterBox({
export default window => Box({
vertical: true,
children: [
CenterBox({
hpack: 'center',
start_widget: RoundedCorner('bottomright', `
background-color: ${color};
`),
center_widget: Box({
class_name: 'thingy',
css: `background: ${color};`,
}),
end_widget: RoundedCorner('bottomleft', `
background-color: ${color};
`),
}),
CenterBox({
css: `background: ${color};`,
class_name: 'osk', class_name: 'osk',
hexpand: true, hexpand: true,
start_widget: Box({ start_widget: Box({
@ -42,12 +22,9 @@ export default window => Box({
children: [ children: [
Box({ Box({
class_name: 'row', class_name: 'row',
children: [ children: row.map((key, keyIndex) => {
Separator(4),
...row.map((key, keyIndex) => {
return keyIndex < L_KEY_PER_ROW[rowIndex] ? Key(key) : null; return keyIndex < L_KEY_PER_ROW[rowIndex] ? Key(key) : null;
}), }),
],
}), }),
Separator(4, { vertical: true }), Separator(4, { vertical: true }),
], ],
@ -95,6 +72,4 @@ export default window => Box({
], ],
})), })),
}), }),
}),
],
}); });

View file

@ -1,31 +1,33 @@
import { Window } from 'resource:///com/github/Aylur/ags/widget.js';
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js'; import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
import Gesture from './gesture.js'; import Gesture from './gesture.js';
import Keyboard from './keyboard.js'; import Keyboard from './keyboard.js';
import PopupWindow from '../misc/popup.js';
// start ydotool daemon // ydotool stuff
execAsync('ydotoold').catch(print); execAsync('ydotoold').catch(print);
function releaseAllKeys() {
const keycodes = Array.from(Array(249).keys());
execAsync([
'ydotool', 'key',
...keycodes.map(keycode => `${keycode}:0`),
]).catch(print);
}
// Window // Window
export default () => { export default () => {
const window = Window({ const window = PopupWindow({
name: 'osk', name: 'osk',
visible: false,
anchor: ['left', 'bottom', 'right'], anchor: ['left', 'bottom', 'right'],
connections: [ onClose: releaseAllKeys,
[Tablet, (self, state) => { closeOnUnfocus: 'none',
self.setVisible(state); connections: [[Tablet, self => {
}, 'osk-toggled'], self.visible = Tablet.oskState;
}, 'osk-toggled']],
[Tablet, () => {
if (!Tablet.tabletMode && !Tablet.oskState)
window.visible = false;
}, 'mode-toggled'],
],
}); });
window.child = Keyboard(window); window.setChild(Keyboard(window));
return Gesture(window); return Gesture(window);
}; };

View file

@ -1,12 +1,5 @@
.thingy {
border-radius: 2rem 2rem 0 0;
min-height: 2.7rem;
min-width: 20rem;
}
.osk { .osk {
padding-top: 4px; margin-left: 4px;
border-radius: 10px 10px 0;
.settings { .settings {
background-color: $bg; background-color: $bg;