Add "BoxedIconButton" class

This commit is contained in:
Rafostar
2020-09-11 21:28:00 +02:00
parent 5afe5149aa
commit 6938f01433
3 changed files with 44 additions and 10 deletions

38
clapper_src/buttons.js Normal file
View File

@@ -0,0 +1,38 @@
const { GObject, Gtk } = imports.gi;
var BoxedIconButton = GObject.registerClass(
class BoxedIconButton extends Gtk.Button
{
_init(icon, size)
{
super._init();
let image = Gtk.Image.new_from_icon_name(icon, size);
if(image)
this.set_image(image);
this.box = new Gtk.Box();
this.box.pack_start(this, false, false, 0);
}
get visible()
{
return this.box.visible;
}
show_all()
{
this.box.show_all();
}
show()
{
this.box.show();
}
hide()
{
this.box.hide();
}
});

View File

@@ -1,4 +1,5 @@
const { GObject, Gtk } = imports.gi;
const Buttons = imports.clapper_src.buttons;
const Debug = imports.clapper_src.debug;
const CONTROLS_MARGIN = 4;
@@ -94,9 +95,7 @@ var Controls = GObject.registerClass({
{
size = size || Gtk.IconSize.SMALL_TOOLBAR;
let button = Gtk.Button.new_from_icon_name(iconName, size);
let box = new Gtk.Box();
let button = new Buttons.BoxedIconButton(iconName, size);
button.margin_top = CONTROLS_MARGIN;
button.margin_bottom = CONTROLS_MARGIN;
button.image.defaultSize = size;
@@ -107,11 +106,8 @@ var Controls = GObject.registerClass({
this.setDefaultWidgetBehaviour(button);
button.get_style_context().add_class('flat');
if(!noPack) {
box.pack_start(button, false, false, 0);
this.pack_start(box, false, false, 0);
box.show_all();
}
if(!noPack)
this.pack_start(button.box, false, false, 0);
this.buttonImages.push(button.image);
return button;

View File

@@ -101,7 +101,7 @@ class ClapperInterface extends Gtk.Grid
if(isOnVideo) {
this.remove(this.controls);
this.controls.pack_start(this.controls.unfullscreenButton, false, false, 0);
this.controls.pack_start(this.controls.unfullscreenButton.box, false, false, 0);
this.overlay.add_overlay(this.revealer);
this.revealerBox.pack_start(this.controls, false, true, 0);
this.revealer.show();
@@ -109,7 +109,7 @@ class ClapperInterface extends Gtk.Grid
}
else {
this.revealerBox.remove(this.controls);
this.controls.remove(this.controls.unfullscreenButton);
this.controls.remove(this.controls.unfullscreenButton.box);
this.overlay.remove(this.revealer);
this.attach(this.controls, 0, 1, 1, 1);
this.controls.show();