fix(ags corners): fix standalone corners not showing
This commit is contained in:
parent
d8cdcda982
commit
cfeba78d79
1 changed files with 55 additions and 48 deletions
|
@ -2,64 +2,71 @@ import { Widget } from '../imports.js';
|
||||||
const { Gtk } = imports.gi;
|
const { Gtk } = imports.gi;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
|
|
||||||
export const RoundedCorner = (place, props) => Widget({
|
export const RoundedCorner = (place, props) => Widget.Box({
|
||||||
...props,
|
|
||||||
type: Gtk.DrawingArea,
|
|
||||||
halign: place.includes('left') ? 'start' : 'end',
|
halign: place.includes('left') ? 'start' : 'end',
|
||||||
valign: place.includes('top') ? 'start' : 'end',
|
valign: place.includes('top') ? 'start' : 'end',
|
||||||
setup: widget => {
|
style: `padding: 1px; margin:
|
||||||
const r = widget.get_style_context()
|
${place.includes('top') ? '-1px' : '0'}
|
||||||
.get_property('border-radius', Gtk.StateFlags.NORMAL);
|
${place.includes('right') ? '-1px' : '0'}
|
||||||
|
${place.includes('bottom') ? '-1px' : '0'}
|
||||||
widget.set_size_request(r, r);
|
${place.includes('left') ? '-1px' : '0'};`,
|
||||||
widget.connect('draw', Lang.bind(widget, (widget, cr) => {
|
child: Widget({
|
||||||
const c = widget.get_style_context()
|
...props,
|
||||||
.get_property('background-color', Gtk.StateFlags.NORMAL);
|
type: Gtk.DrawingArea,
|
||||||
|
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);
|
||||||
|
|
||||||
const borderColor = widget.get_style_context()
|
|
||||||
.get_property('color', Gtk.StateFlags.NORMAL);
|
|
||||||
|
|
||||||
// ur going to write border-width: something anyway
|
|
||||||
const borderWidth = widget.get_style_context()
|
|
||||||
.get_border(Gtk.StateFlags.NORMAL).left;
|
|
||||||
widget.set_size_request(r, r);
|
widget.set_size_request(r, r);
|
||||||
|
widget.connect('draw', Lang.bind(widget, (widget, cr) => {
|
||||||
|
const c = widget.get_style_context()
|
||||||
|
.get_property('background-color', Gtk.StateFlags.NORMAL);
|
||||||
|
|
||||||
switch (place) {
|
const r = widget.get_style_context()
|
||||||
case 'topleft':
|
.get_property('border-radius', Gtk.StateFlags.NORMAL);
|
||||||
cr.arc(r, r, r, Math.PI, 3 * Math.PI / 2);
|
|
||||||
cr.lineTo(0, 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'topright':
|
const borderColor = widget.get_style_context()
|
||||||
cr.arc(0, r, r, 3 * Math.PI / 2, 2 * Math.PI);
|
.get_property('color', Gtk.StateFlags.NORMAL);
|
||||||
cr.lineTo(r, 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'bottomleft':
|
// ur going to write border-width: something anyway
|
||||||
cr.arc(r, 0, r, Math.PI / 2, Math.PI);
|
const borderWidth = widget.get_style_context()
|
||||||
cr.lineTo(0, r);
|
.get_border(Gtk.StateFlags.NORMAL).left;
|
||||||
break;
|
widget.set_size_request(r, r);
|
||||||
|
|
||||||
case 'bottomright':
|
switch (place) {
|
||||||
cr.arc(0, 0, r, 0, Math.PI / 2);
|
case 'topleft':
|
||||||
cr.lineTo(r, r);
|
cr.arc(r, r, r, Math.PI, 3 * Math.PI / 2);
|
||||||
break;
|
cr.lineTo(0, 0);
|
||||||
}
|
break;
|
||||||
|
|
||||||
cr.closePath();
|
case 'topright':
|
||||||
cr.setSourceRGBA(c.red, c.green, c.blue, c.alpha);
|
cr.arc(0, r, r, 3 * Math.PI / 2, 2 * Math.PI);
|
||||||
cr.fill();
|
cr.lineTo(r, 0);
|
||||||
cr.setLineWidth(borderWidth);
|
break;
|
||||||
cr.setSourceRGBA(borderColor.red,
|
|
||||||
borderColor.green,
|
case 'bottomleft':
|
||||||
borderColor.blue,
|
cr.arc(r, 0, r, Math.PI / 2, Math.PI);
|
||||||
borderColor.alpha);
|
cr.lineTo(0, r);
|
||||||
cr.stroke();
|
break;
|
||||||
}));
|
|
||||||
},
|
case 'bottomright':
|
||||||
|
cr.arc(0, 0, r, 0, Math.PI / 2);
|
||||||
|
cr.lineTo(r, r);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cr.closePath();
|
||||||
|
cr.setSourceRGBA(c.red, c.green, c.blue, c.alpha);
|
||||||
|
cr.fill();
|
||||||
|
cr.setLineWidth(borderWidth);
|
||||||
|
cr.setSourceRGBA(borderColor.red,
|
||||||
|
borderColor.green,
|
||||||
|
borderColor.blue,
|
||||||
|
borderColor.alpha);
|
||||||
|
cr.stroke();
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Topleft = () => Widget.Window({
|
export const Topleft = () => Widget.Window({
|
||||||
|
|
Loading…
Reference in a new issue