2024-01-30 11:29:07 -05:00
|
|
|
const { Box, CenterBox, Label, ToggleButton } = Widget;
|
2023-11-19 15:00:29 -05:00
|
|
|
|
2024-01-11 10:25:53 -05:00
|
|
|
const { Gdk } = imports.gi;
|
|
|
|
const display = Gdk.Display.get_default();
|
|
|
|
|
2024-01-13 23:38:31 -05:00
|
|
|
import Separator from '../misc/separator.ts';
|
|
|
|
import RoundedCorner from '../corners/screen-corners.ts';
|
|
|
|
import Key from './keys.ts';
|
2023-11-19 15:00:29 -05:00
|
|
|
|
2024-01-13 23:38:31 -05:00
|
|
|
import { defaultOskLayout, oskLayouts } from './keyboard-layouts.ts';
|
2023-11-19 15:00:29 -05:00
|
|
|
const keyboardLayout = defaultOskLayout;
|
|
|
|
const keyboardJson = oskLayouts[keyboardLayout];
|
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
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;
|
2023-11-19 15:00:29 -05:00
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
// Types
|
2024-04-07 11:34:44 -04:00
|
|
|
import { BoxGeneric, OskWindow } from 'global-types';
|
2023-11-19 15:00:29 -05:00
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
|
2024-04-07 11:34:44 -04:00
|
|
|
export default (window: OskWindow) => Box({
|
2023-11-19 20:39:08 -05:00
|
|
|
vertical: true,
|
|
|
|
children: [
|
|
|
|
CenterBox({
|
|
|
|
hpack: 'center',
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-19 20:39:08 -05:00
|
|
|
start_widget: RoundedCorner('bottomright', `
|
2023-11-21 01:29:46 -05:00
|
|
|
background-color: ${COLOR};
|
2023-11-19 20:39:08 -05:00
|
|
|
`),
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-28 16:29:17 -05:00
|
|
|
center_widget: CenterBox({
|
2023-11-19 20:39:08 -05:00
|
|
|
class_name: 'thingy',
|
2023-11-21 01:29:46 -05:00
|
|
|
css: `background: ${COLOR};`,
|
2023-12-21 01:25:59 -05:00
|
|
|
|
2023-11-28 16:29:17 -05:00
|
|
|
center_widget: Box({
|
|
|
|
hpack: 'center',
|
|
|
|
class_name: 'settings',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
ToggleButton({
|
|
|
|
class_name: 'button',
|
|
|
|
active: true,
|
|
|
|
vpack: 'center',
|
|
|
|
|
2023-12-17 00:01:58 -05:00
|
|
|
setup: (self) => {
|
2024-01-11 10:25:53 -05:00
|
|
|
self
|
|
|
|
.on('toggled', () => {
|
|
|
|
self.toggleClassName(
|
|
|
|
'toggled',
|
|
|
|
self.get_active(),
|
|
|
|
);
|
|
|
|
window.exclusivity = self.get_active() ?
|
|
|
|
'exclusive' :
|
|
|
|
'normal';
|
|
|
|
})
|
|
|
|
|
|
|
|
// OnHover
|
|
|
|
.on('enter-notify-event', () => {
|
2024-01-22 10:23:32 -05:00
|
|
|
if (!display) {
|
|
|
|
return;
|
|
|
|
}
|
2024-01-11 10:25:53 -05:00
|
|
|
self.window.set_cursor(
|
|
|
|
Gdk.Cursor.new_from_name(
|
|
|
|
display,
|
|
|
|
'pointer',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
self.toggleClassName('hover', true);
|
|
|
|
})
|
|
|
|
|
|
|
|
// OnHoverLost
|
|
|
|
.on('leave-notify-event', () => {
|
|
|
|
self.window.set_cursor(null);
|
|
|
|
self.toggleClassName('hover', false);
|
|
|
|
});
|
2023-12-17 00:01:58 -05:00
|
|
|
},
|
2023-11-28 16:29:17 -05:00
|
|
|
|
|
|
|
child: Label('Exclusive'),
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
}),
|
2023-11-19 20:39:08 -05:00
|
|
|
}),
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-19 20:39:08 -05:00
|
|
|
end_widget: RoundedCorner('bottomleft', `
|
2023-11-21 01:29:46 -05:00
|
|
|
background-color: ${COLOR};
|
2023-11-19 20:39:08 -05:00
|
|
|
`),
|
|
|
|
}),
|
2023-11-19 15:00:29 -05:00
|
|
|
|
2023-11-19 20:39:08 -05:00
|
|
|
CenterBox({
|
2023-11-21 01:29:46 -05:00
|
|
|
css: `background: ${COLOR};`,
|
2023-11-19 20:39:08 -05:00
|
|
|
class_name: 'osk',
|
|
|
|
hexpand: true,
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-19 20:39:08 -05:00
|
|
|
start_widget: Box({
|
|
|
|
class_name: 'left-side side',
|
|
|
|
hpack: 'start',
|
|
|
|
vertical: true,
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-21 01:25:59 -05:00
|
|
|
children: keyboardJson.keys.map((row, rowIndex) => {
|
2024-01-29 20:56:56 -05:00
|
|
|
const keys = [] as BoxGeneric[];
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-21 01:25:59 -05:00
|
|
|
row.forEach((key, keyIndex) => {
|
|
|
|
if (keyIndex < L_KEY_PER_ROW[rowIndex]) {
|
|
|
|
keys.push(Key(key));
|
|
|
|
}
|
|
|
|
});
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-21 01:25:59 -05:00
|
|
|
return Box({
|
|
|
|
vertical: true,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
Box({
|
|
|
|
class_name: 'row',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
Separator(SPACING),
|
|
|
|
|
|
|
|
...keys,
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
|
|
|
|
Separator(SPACING, { vertical: true }),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
}),
|
2023-11-19 20:39:08 -05:00
|
|
|
}),
|
|
|
|
|
|
|
|
center_widget: Box({
|
|
|
|
hpack: 'center',
|
|
|
|
vpack: 'center',
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-19 16:25:01 -05:00
|
|
|
children: [
|
|
|
|
],
|
|
|
|
}),
|
2023-11-19 15:00:29 -05:00
|
|
|
|
2023-11-19 20:39:08 -05:00
|
|
|
end_widget: Box({
|
|
|
|
class_name: 'right-side side',
|
|
|
|
hpack: 'end',
|
|
|
|
vertical: true,
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-21 01:25:59 -05:00
|
|
|
children: keyboardJson.keys.map((row, rowIndex) => {
|
2024-01-29 20:56:56 -05:00
|
|
|
const keys = [] as BoxGeneric[];
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-21 01:25:59 -05:00
|
|
|
row.forEach((key, keyIndex) => {
|
|
|
|
if (keyIndex >= L_KEY_PER_ROW[rowIndex]) {
|
|
|
|
keys.push(Key(key));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return Box({
|
|
|
|
vertical: true,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
Box({
|
|
|
|
hpack: 'end',
|
|
|
|
class_name: 'row',
|
|
|
|
|
|
|
|
children: keys,
|
2023-11-19 20:39:08 -05:00
|
|
|
}),
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-21 01:25:59 -05:00
|
|
|
Separator(SPACING, { vertical: true }),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
}),
|
2023-11-19 20:39:08 -05:00
|
|
|
}),
|
|
|
|
}),
|
|
|
|
],
|
2023-11-19 15:00:29 -05:00
|
|
|
});
|