Move buttons margins to CSS and tweak them a little

This commit is contained in:
Rafał Dzięgiel
2021-03-30 22:15:12 +02:00
parent 3fd30e41bf
commit 66ce006f00
3 changed files with 47 additions and 37 deletions

View File

@@ -9,7 +9,7 @@ radio {
.osd list { .osd list {
background: none; background: none;
} }
.osd list row { .osd list row image {
-gtk-icon-shadow: none; -gtk-icon-shadow: none;
} }
.gtk402 trough highlight { .gtk402 trough highlight {
@@ -75,9 +75,28 @@ radio {
font-size: 21px; font-size: 21px;
font-weight: 500; font-weight: 500;
} }
.tvmode button { .playercontrols {
margin-bottom: -1px;
margin-left: 2px;
margin-right: 2px;
}
.tvmode .playercontrols {
margin-left: 1px;
margin-right: 1px;
}
.playercontrols button {
margin: 3px;
margin-left: 1px;
margin-right: 1px;
}
.tvmode .playercontrols button {
min-width: 32px; min-width: 32px;
min-height: 32px; min-height: 32px;
margin: 4px;
margin-left: 3px;
margin-right: 3px;
}
.tvmode button image {
-gtk-icon-shadow: none; -gtk-icon-shadow: none;
} }
.tvmode radio { .tvmode radio {
@@ -88,7 +107,7 @@ radio {
min-height: 17px; min-height: 17px;
} }
.tvmode .playercontrols { .tvmode .playercontrols button image {
-gtk-icon-size: 24px; -gtk-icon-size: 24px;
} }
.adwicons .playbackicon { .adwicons .playbackicon {
@@ -97,18 +116,16 @@ radio {
.adwicons.tvmode .playbackicon { .adwicons.tvmode .playbackicon {
-gtk-icon-size: 28px; -gtk-icon-size: 28px;
} }
.labelbutton { .labelbuttonlabel {
margin-left: -4px; margin-left: -4px;
margin-right: -4px; margin-right: -4px;
margin-top: 1px;
min-width: 8px; min-width: 8px;
font-family: 'Cantarell', sans-serif; font-family: 'Cantarell', sans-serif;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
font-weight: 600; font-weight: 600;
} }
.tvmode .labelbutton { .tvmode .labelbuttonlabel {
margin-top: 0px; font-size: 22px;
font-size: 23px;
text-shadow: none; text-shadow: none;
} }
@@ -146,11 +163,9 @@ radio {
/* Position Scale */ /* Position Scale */
.positionscale { .positionscale {
margin-top: -2px; margin: -2px;
margin-bottom: -2px; margin-left: -4px;
} margin-right: -4px;
.tvmode .positionscale {
margin-top: -1px;
} }
.positionscale trough highlight { .positionscale trough highlight {
min-height: 4px; min-height: 4px;

View File

@@ -1,5 +1,11 @@
const { GObject, Gtk } = imports.gi; const { GObject, Gtk } = imports.gi;
/* Negative values from CSS */
const PopoverOffset = {
DEFAULT: -3,
TVMODE: -4,
};
var CustomButton = GObject.registerClass( var CustomButton = GObject.registerClass(
class ClapperCustomButton extends Gtk.Button class ClapperCustomButton extends Gtk.Button
{ {
@@ -8,10 +14,8 @@ class ClapperCustomButton extends Gtk.Button
opts = opts || {}; opts = opts || {};
const defaults = { const defaults = {
margin_top: 4, halign: Gtk.Align.CENTER,
margin_bottom: 4, valign: Gtk.Align.CENTER,
margin_start: 2,
margin_end: 2,
can_focus: false, can_focus: false,
}; };
Object.assign(opts, defaults); Object.assign(opts, defaults);
@@ -27,9 +31,6 @@ class ClapperCustomButton extends Gtk.Button
if(this.isFullscreen === isFullscreen) if(this.isFullscreen === isFullscreen)
return; return;
this.margin_top = (isFullscreen) ? 5 : 4;
this.margin_start = (isFullscreen) ? 3 : 2;
this.margin_end = (isFullscreen) ? 3 : 2;
this.can_focus = isFullscreen; this.can_focus = isFullscreen;
/* Redraw icon after style class change */ /* Redraw icon after style class change */
@@ -79,10 +80,8 @@ class ClapperPopoverButtonBase extends Gtk.ToggleButton
_init() _init()
{ {
super._init({ super._init({
margin_top: 4, halign: Gtk.Align.CENTER,
margin_bottom: 4, valign: Gtk.Align.CENTER,
margin_start: 2,
margin_end: 2,
can_focus: false, can_focus: false,
}); });
@@ -97,7 +96,7 @@ class ClapperPopoverButtonBase extends Gtk.ToggleButton
}); });
this.popover.set_child(this.popoverBox); this.popover.set_child(this.popoverBox);
this.popover.set_offset(0, -this.margin_top); this.popover.set_offset(0, PopoverOffset.DEFAULT);
if(this.isFullscreen) if(this.isFullscreen)
this.popover.add_css_class('osd'); this.popover.add_css_class('osd');
@@ -111,9 +110,6 @@ class ClapperPopoverButtonBase extends Gtk.ToggleButton
if(this.isFullscreen === isFullscreen) if(this.isFullscreen === isFullscreen)
return; return;
this.margin_top = (isFullscreen) ? 5 : 4;
this.margin_start = (isFullscreen) ? 3 : 2;
this.margin_end = (isFullscreen) ? 3 : 2;
this.can_focus = isFullscreen; this.can_focus = isFullscreen;
/* Redraw icon after style class change */ /* Redraw icon after style class change */
@@ -122,7 +118,12 @@ class ClapperPopoverButtonBase extends Gtk.ToggleButton
this.isFullscreen = isFullscreen; this.isFullscreen = isFullscreen;
this.popover.set_offset(0, -this.margin_top); /* TODO: Fullscreen non-tv mode */
const offset = (isFullscreen)
? PopoverOffset.TVMODE
: PopoverOffset.DEFAULT;
this.popover.set_offset(0, offset);
const cssClass = 'osd'; const cssClass = 'osd';
if(isFullscreen === this.popover.has_css_class(cssClass)) if(isFullscreen === this.popover.has_css_class(cssClass))
@@ -189,7 +190,7 @@ class ClapperLabelPopoverButton extends PopoverButtonBase
label: text, label: text,
single_line_mode: true, single_line_mode: true,
}); });
this.customLabel.add_css_class('labelbutton'); this.customLabel.add_css_class('labelbuttonlabel');
this.set_child(this.customLabel); this.set_child(this.customLabel);
} }

8
src/controls.js vendored
View File

@@ -4,9 +4,6 @@ const Debug = imports.src.debug;
const Misc = imports.src.misc; const Misc = imports.src.misc;
const Revealers = imports.src.revealers; const Revealers = imports.src.revealers;
const CONTROLS_MARGIN = 2;
const CONTROLS_SPACING = 0;
const { debug } = Debug; const { debug } = Debug;
const { settings } = Misc; const { settings } = Misc;
@@ -17,9 +14,6 @@ class ClapperControls extends Gtk.Box
{ {
super._init({ super._init({
orientation: Gtk.Orientation.HORIZONTAL, orientation: Gtk.Orientation.HORIZONTAL,
margin_start: CONTROLS_MARGIN,
margin_end: CONTROLS_MARGIN,
spacing: CONTROLS_SPACING,
valign: Gtk.Align.END, valign: Gtk.Align.END,
can_focus: false, can_focus: false,
}); });
@@ -439,7 +433,7 @@ class ClapperControls extends Gtk.Box
const scaleHeight = this.positionScale.parent.get_height(); const scaleHeight = this.positionScale.parent.get_height();
this.chapterPopover.set_pointing_to(new Gdk.Rectangle({ this.chapterPopover.set_pointing_to(new Gdk.Rectangle({
x: 2, x: -2,
y: -(controlsHeight - scaleHeight) / 2, y: -(controlsHeight - scaleHeight) / 2,
width: 2 * end, width: 2 * end,
height: 0, height: 0,