mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
Enable scroll on volume button
This commit is contained in:
@@ -149,9 +149,6 @@ var App = GObject.registerClass({
|
|||||||
this.player.connectWidget(
|
this.player.connectWidget(
|
||||||
'button-press-event', this._onPlayerButtonPressEvent.bind(this)
|
'button-press-event', this._onPlayerButtonPressEvent.bind(this)
|
||||||
);
|
);
|
||||||
this.player.connectWidget(
|
|
||||||
'scroll-event', this._onPlayerScrollEvent.bind(this)
|
|
||||||
);
|
|
||||||
this.player.connectWidget(
|
this.player.connectWidget(
|
||||||
'enter-notify-event', this._onPlayerEnterNotifyEvent.bind(this)
|
'enter-notify-event', this._onPlayerEnterNotifyEvent.bind(this)
|
||||||
);
|
);
|
||||||
@@ -212,12 +209,12 @@ var App = GObject.registerClass({
|
|||||||
bool = true;
|
bool = true;
|
||||||
case Gdk.KEY_Left:
|
case Gdk.KEY_Left:
|
||||||
// disabled due to missing "seek on drop" support
|
// disabled due to missing "seek on drop" support
|
||||||
//this._handleScaleIncrement('position', bool);
|
//this.interface.controls.handleScaleIncrement('position', bool);
|
||||||
break;
|
break;
|
||||||
case Gdk.KEY_Up:
|
case Gdk.KEY_Up:
|
||||||
bool = true;
|
bool = true;
|
||||||
case Gdk.KEY_Down:
|
case Gdk.KEY_Down:
|
||||||
this._handleScaleIncrement('volume', bool);
|
this.interface.controls.handleScaleIncrement('volume', bool);
|
||||||
break;
|
break;
|
||||||
case Gdk.KEY_F11:
|
case Gdk.KEY_F11:
|
||||||
this.window.toggleFullscreen();
|
this.window.toggleFullscreen();
|
||||||
@@ -340,46 +337,6 @@ var App = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPlayerScrollEvent(self, event)
|
|
||||||
{
|
|
||||||
let [res, direction] = event.get_scroll_direction();
|
|
||||||
if(!res) return;
|
|
||||||
|
|
||||||
let type = 'volume';
|
|
||||||
|
|
||||||
switch(direction) {
|
|
||||||
case Gdk.ScrollDirection.RIGHT:
|
|
||||||
case Gdk.ScrollDirection.LEFT:
|
|
||||||
type = 'position';
|
|
||||||
case Gdk.ScrollDirection.UP:
|
|
||||||
case Gdk.ScrollDirection.DOWN:
|
|
||||||
let isUp = (
|
|
||||||
direction === Gdk.ScrollDirection.UP
|
|
||||||
|| direction === Gdk.ScrollDirection.RIGHT
|
|
||||||
);
|
|
||||||
this._handleScaleIncrement(type, isUp);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_handleScaleIncrement(type, isUp)
|
|
||||||
{
|
|
||||||
let value = this.interface.controls[`${type}Scale`].get_value();
|
|
||||||
let maxValue = this.interface.controls[`${type}Adjustment`].get_upper();
|
|
||||||
let increment = this.interface.controls[`${type}Adjustment`].get_page_increment();
|
|
||||||
|
|
||||||
value += (isUp) ? increment : -increment;
|
|
||||||
value = (value < 0)
|
|
||||||
? 0
|
|
||||||
: (value > maxValue)
|
|
||||||
? maxValue
|
|
||||||
: value;
|
|
||||||
|
|
||||||
this.interface.controls[`${type}Scale`].set_value(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
_onPlayerEnterNotifyEvent(self, event)
|
_onPlayerEnterNotifyEvent(self, event)
|
||||||
{
|
{
|
||||||
this.isCursorInPlayer = true;
|
this.isCursorInPlayer = true;
|
||||||
|
46
clapper_src/controls.js
vendored
46
clapper_src/controls.js
vendored
@@ -1,4 +1,4 @@
|
|||||||
const { GObject, Gtk } = imports.gi;
|
const { GObject, Gdk, Gtk } = imports.gi;
|
||||||
const Buttons = imports.clapper_src.buttons;
|
const Buttons = imports.clapper_src.buttons;
|
||||||
const Debug = imports.clapper_src.debug;
|
const Debug = imports.clapper_src.debug;
|
||||||
|
|
||||||
@@ -187,6 +187,22 @@ var Controls = GObject.registerClass({
|
|||||||
this.volumeScale.add_mark(2, Gtk.PositionType.LEFT, '200%');
|
this.volumeScale.add_mark(2, Gtk.PositionType.LEFT, '200%');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleScaleIncrement(type, isUp)
|
||||||
|
{
|
||||||
|
let value = this[`${type}Scale`].get_value();
|
||||||
|
let maxValue = this[`${type}Adjustment`].get_upper();
|
||||||
|
let increment = this[`${type}Adjustment`].get_page_increment();
|
||||||
|
|
||||||
|
value += (isUp) ? increment : -increment;
|
||||||
|
value = (value < 0)
|
||||||
|
? 0
|
||||||
|
: (value > maxValue)
|
||||||
|
? maxValue
|
||||||
|
: value;
|
||||||
|
|
||||||
|
this[`${type}Scale`].set_value(value);
|
||||||
|
}
|
||||||
|
|
||||||
_addTogglePlayButton()
|
_addTogglePlayButton()
|
||||||
{
|
{
|
||||||
this.togglePlayButton = this.addButton(
|
this.togglePlayButton = this.addButton(
|
||||||
@@ -239,6 +255,10 @@ var Controls = GObject.registerClass({
|
|||||||
this.volumeButton = this.addPopoverButton(
|
this.volumeButton = this.addPopoverButton(
|
||||||
'audio-volume-muted-symbolic'
|
'audio-volume-muted-symbolic'
|
||||||
);
|
);
|
||||||
|
this.volumeButton.add_events(Gdk.EventMask.SCROLL_MASK);
|
||||||
|
this.volumeButton.connect(
|
||||||
|
'scroll-event', (self, event) => this._onScrollEvent(event)
|
||||||
|
);
|
||||||
this.volumeScale = new Gtk.Scale({
|
this.volumeScale = new Gtk.Scale({
|
||||||
orientation: Gtk.Orientation.VERTICAL,
|
orientation: Gtk.Orientation.VERTICAL,
|
||||||
inverted: true,
|
inverted: true,
|
||||||
@@ -330,4 +350,28 @@ var Controls = GObject.registerClass({
|
|||||||
for(let name of hiddenButtons)
|
for(let name of hiddenButtons)
|
||||||
this[`${name}Button`].hide();
|
this[`${name}Button`].hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onScrollEvent(event)
|
||||||
|
{
|
||||||
|
let [res, direction] = event.get_scroll_direction();
|
||||||
|
if(!res) return;
|
||||||
|
|
||||||
|
let type = 'volume';
|
||||||
|
|
||||||
|
switch(direction) {
|
||||||
|
case Gdk.ScrollDirection.RIGHT:
|
||||||
|
case Gdk.ScrollDirection.LEFT:
|
||||||
|
type = 'position';
|
||||||
|
case Gdk.ScrollDirection.UP:
|
||||||
|
case Gdk.ScrollDirection.DOWN:
|
||||||
|
let isUp = (
|
||||||
|
direction === Gdk.ScrollDirection.UP
|
||||||
|
|| direction === Gdk.ScrollDirection.RIGHT
|
||||||
|
);
|
||||||
|
this.handleScaleIncrement(type, isUp);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
@@ -52,6 +52,10 @@ class ClapperInterface extends Gtk.Grid
|
|||||||
this._player.connect('duration-changed', this._onPlayerDurationChanged.bind(this));
|
this._player.connect('duration-changed', this._onPlayerDurationChanged.bind(this));
|
||||||
this._player.connect('position-updated', this._onPlayerPositionUpdated.bind(this));
|
this._player.connect('position-updated', this._onPlayerPositionUpdated.bind(this));
|
||||||
|
|
||||||
|
this._player.connectWidget(
|
||||||
|
'scroll-event', (self, event) => this.controls._onScrollEvent(event)
|
||||||
|
);
|
||||||
|
|
||||||
this.controls.togglePlayButton.connect(
|
this.controls.togglePlayButton.connect(
|
||||||
'clicked', this._onControlsTogglePlayClicked.bind(this)
|
'clicked', this._onControlsTogglePlayClicked.bind(this)
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user