feat(ags): start experimenting with gestures
This commit is contained in:
parent
1488f4992f
commit
137a1614bf
2 changed files with 42 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { exec } from 'resource:///com/github/Aylur/ags/utils.js';
|
import { exec } from 'resource:///com/github/Aylur/ags/utils.js';
|
||||||
import { Powermenu } from './js/powermenu.js';
|
import { Powermenu } from './js/powermenu.js';
|
||||||
import { Bar } from './js/bar/bar.js';
|
import { Bar } from './js/bar/bar.js';
|
||||||
|
import { DragTest } from './js/test/drag.js';
|
||||||
import { Closer } from './js/common.js';
|
import { Closer } from './js/common.js';
|
||||||
|
|
||||||
const scss = ags.App.configDir + '/scss/main.scss';
|
const scss = ags.App.configDir + '/scss/main.scss';
|
||||||
|
@ -17,5 +18,6 @@ export default {
|
||||||
Powermenu,
|
Powermenu,
|
||||||
Bar,
|
Bar,
|
||||||
Closer,
|
Closer,
|
||||||
|
DragTest,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
40
config/ags/js/test/drag.js
Normal file
40
config/ags/js/test/drag.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
const { Window, Box, EventBox } = ags.Widget;
|
||||||
|
const { Gtk, Gdk } = imports.gi;
|
||||||
|
|
||||||
|
var Gesture;
|
||||||
|
var shouldDelete = false;
|
||||||
|
|
||||||
|
const DraggableCtor = props => EventBox({
|
||||||
|
setup: widget => {
|
||||||
|
Gesture = Gtk.GestureDrag.new(widget);
|
||||||
|
},
|
||||||
|
child: Box({
|
||||||
|
style: 'background: black; min-width: 20px; min-height: 20px',
|
||||||
|
}),
|
||||||
|
...props,
|
||||||
|
});
|
||||||
|
|
||||||
|
const Draggable = DraggableCtor();
|
||||||
|
|
||||||
|
export const DragTest = Window({
|
||||||
|
name: 'drag-test',
|
||||||
|
layer: 'overlay',
|
||||||
|
anchor: 'top right',
|
||||||
|
child: Box({
|
||||||
|
style: 'background: white; min-width: 200px; min-height: 200px;',
|
||||||
|
children: [
|
||||||
|
Draggable,
|
||||||
|
Box({
|
||||||
|
connections: [
|
||||||
|
[Gesture, event => {
|
||||||
|
Draggable.child.setStyle('background: black; min-width: 20px; min-height: 20px; margin-left: ' + Gesture.get_offset()[1] + 'px;')
|
||||||
|
}, 'drag-update'],
|
||||||
|
|
||||||
|
[Gesture, event => {
|
||||||
|
Draggable.child.setStyle('transition: margin 0.5s ease; background: black; min-width: 20px; min-height: 20px')
|
||||||
|
}, 'drag-end'],
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
});
|
Loading…
Reference in a new issue