Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
72f76223 by Fatih Uzunoglu at 2024-04-03T14:12:56+00:00
qml: use rectangle instead of image in PlayButton.qml

Originally, the interface had view transition
animations and they interfered with the appearance
of the play button.

There was a period in which opacity mask was used
to eliminate this issue, but it was removed because
opacity effect is expensive and should not be used
in a delegate. Alternatively, layering could be
used although was not used before.

Up until now, a svg image was used for the play
button background. An image has the advantage of
getting rendered in batch, provided that it is
placed in the atlas texture. However, image has
the disadvantage that arises from the cost
texture sampling incurs.

Since we do not use animations anymore, we can
simply use rectangle again.

- - - - -
2689db62 by Fatih Uzunoglu at 2024-04-03T14:12:56+00:00
qt: remove play_button.svg

- - - - -
6f115bf3 by Fatih Uzunoglu at 2024-04-03T14:12:56+00:00
qml: add press and hold animation to PlayButton

- - - - -


4 changed files:

- modules/gui/qt/Makefile.am
- − modules/gui/qt/pixmaps/misc/play_button.svg
- modules/gui/qt/player/qml/controlbarcontrols/PlayButton.qml
- modules/gui/qt/vlc.qrc


Changes:

=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -808,7 +808,6 @@ libqt_plugin_la_RES = \
        pixmaps/menu/volume-muted.svg \
        pixmaps/misc/cone.svg \
        pixmaps/misc/new_indicator.svg \
-       pixmaps/misc/play_button.svg \
        pixmaps/misc/play_shadow.png \
        pixmaps/misc/theme_dark.svg \
        pixmaps/misc/theme_daynight.svg \


=====================================
modules/gui/qt/pixmaps/misc/play_button.svg deleted
=====================================
@@ -1,11 +0,0 @@
-<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg";>
-  <defs>
-    <linearGradient id="a" x2="0" y1="1">
-      <stop stop-color="#e25b01" offset="0"/>
-      <stop stop-color="#f89a06" offset="1"/>
-    </linearGradient>
-  </defs>
-  <circle cx="24" cy="24" r="24" fill="url(#a)"/>
-  <circle cx="24" cy="24" r="22" fill="#fff"/>
-</svg>
-


=====================================
modules/gui/qt/player/qml/controlbarcontrols/PlayButton.qml
=====================================
@@ -115,6 +115,7 @@ T.Control {
             if (!event.isAutoRepeat) {
                 _keyOkPressed = true
                 keyHoldTimer.restart()
+                innerRectangle.state = "diminished"
             }
             event.accepted = true
         }
@@ -126,6 +127,7 @@ T.Control {
             if (!event.isAutoRepeat) {
                 _keyOkPressed = false
                 keyHoldTimer.stop()
+                innerRectangle.state = ""
                 if (Player.playingState !== Player.PLAYING_STATE_STOPPED)
                     MainPlaylistController.togglePlayPause()
             }
@@ -136,6 +138,7 @@ T.Control {
     // Functions
 
     function _pressAndHoldAction() {
+        innerRectangle.state = ""
         _keyOkPressed = false
         MainPlaylistController.stop()
     }
@@ -180,6 +183,11 @@ T.Control {
             }
 
             root.forceActiveFocus(Qt.MouseFocusReason)
+            innerRectangle.state = "diminished"
+        }
+
+        onReleased: {
+            innerRectangle.state = ""
         }
 
         onClicked: (mouse) => {
@@ -270,9 +278,63 @@ T.Control {
             yRadius: xRadius
         }
 
-        Widgets.ScaledImage {
+        Rectangle {
             anchors.fill: parent
-            source: "qrc:/misc/play_button.svg"
+
+            radius: width
+
+            gradient: Gradient {
+                GradientStop { position: 0.0; color: "#e25b01" }
+                GradientStop { position: 1.0; color: "#f89a06" }
+            }
+
+            Rectangle {
+                id: innerRectangle
+
+                color: "white"
+
+                anchors.fill: parent
+                anchors.margins: VLCStyle.dp(2)
+
+                radius: width
+
+                Binding on anchors.margins {
+                    id: marginBinding
+                    when: false
+                    value: (innerRectangle.parent.width / 2)
+                }
+
+                onStateChanged: {
+                    if (state === "diminished") {
+                        marginBehavior.enabled = true
+                        bindingTimer.start()
+                    } else {
+                        bindingTimer.stop()
+                        marginBehavior.enabled = false
+                        marginBinding.when = false
+                    }
+                }
+
+                Timer {
+                    // Do not immediately start the animation.
+                    // Give some time if the intention is not
+                    // to hold the button.
+                    id: bindingTimer
+                    interval: mouseArea.pressAndHoldInterval / 3
+                    onTriggered: marginBinding.when = true
+                }
+
+                Behavior on anchors.margins {
+                    id: marginBehavior
+                    NumberAnimation {
+                        // Press and hold action must be triggered
+                        // as soon as the inner rectangle diminishes.
+                        // Subtract the interval here so that we satisfy
+                        // that condition.
+                        duration: mouseArea.pressAndHoldInterval - 
bindingTimer.interval
+                    }
+                }
+            }
         }
     }
 }


=====================================
modules/gui/qt/vlc.qrc
=====================================
@@ -57,7 +57,6 @@
     </qresource>
     <qresource prefix="/misc">
         <file alias="cone.svg">pixmaps/misc/cone.svg</file>
-        <file alias="play_button.svg">pixmaps/misc/play_button.svg</file>
         <file alias="play_shadow.png">pixmaps/misc/play_shadow.png</file>
         <file alias="new_indicator.svg">pixmaps/misc/new_indicator.svg</file>
         <file alias="theme_dark.svg">pixmaps/misc/theme_dark.svg</file>



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/b64455307a5a06cb19d30974b909e143f6ae6abe...6f115bf3597ecbdedc11f9e9fbd923b48eddbf11

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/b64455307a5a06cb19d30974b909e143f6ae6abe...6f115bf3597ecbdedc11f9e9fbd923b48eddbf11
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to