vlc | branch: master | Fatih Uzunoglu <[email protected]> | Tue Aug 4 21:39:44 2020 +0300| [14d571d324fec3ca6a50c6fc37a11aca8720fb0b] | committer: Pierre Lamot
qml: play control button better mouse handling Signed-off-by: Pierre Lamot <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=14d571d324fec3ca6a50c6fc37a11aca8720fb0b --- modules/gui/qt/player/qml/ControlButtons.qml | 41 ++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/modules/gui/qt/player/qml/ControlButtons.qml b/modules/gui/qt/player/qml/ControlButtons.qml index ff1b10faa9..7602ca869b 100644 --- a/modules/gui/qt/player/qml/ControlButtons.qml +++ b/modules/gui/qt/player/qml/ControlButtons.qml @@ -156,7 +156,7 @@ Item{ property bool paintOnly: false enabled: !paintOnly - onClicked: mainPlaylistController.togglePlayPause() + property bool realHovered: false contentItem: Label { color: videoOverlays ? (playBtn.enabled ? playBtn.color : playBtn.colorDisabled) @@ -176,6 +176,43 @@ Item{ background: Item { + MouseArea { + id: playBtnMouseArea + + anchors.fill: parent + anchors.margins: VLCStyle.dp(1) + + hoverEnabled: true + + readonly property int radius: playBtnMouseArea.width / 2 + + function distance2D(x0, y0, x1, y1) { + return Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)) + } + + onPositionChanged: { + if (distance2D(playBtnMouseArea.mouseX, playBtnMouseArea.mouseY, playBtnMouseArea.width / 2, playBtnMouseArea.height / 2) < radius) { + // mouse is inside of the round button + playBtn.realHovered = true + } + else { + // mouse is outside + playBtn.realHovered = false + } + } + + onHoveredChanged: { + if (!playBtnMouseArea.containsMouse) + playBtn.realHovered = false + } + + onClicked: { + if (playBtn.realHovered) + mainPlaylistController.togglePlayPause() + } + + } + Rectangle { radius: (width * 0.5) anchors.fill: parent @@ -218,7 +255,7 @@ Item{ source: outerRect maskSource: innerRect - visible: !(playBtn.activeFocus || playBtn.hovered || playBtn.highlighted) + visible: !(playBtn.activeFocus || playBtn.realHovered || playBtn.highlighted) antialiasing: true } } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
