[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: introduce `ScrollBarExt.qml`
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Mar 28 08:04:52 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
56d0e9cc by Fatih Uzunoglu at 2025-03-28T07:40:07+00:00
qt: introduce `ScrollBarExt.qml`
A customized scroll bar, inspired from WinUI 3.
- - - - -
258722d7 by Fatih Uzunoglu at 2025-03-28T07:40:07+00:00
qt: use `ScrollBarExt`
- - - - -
11 changed files:
- modules/gui/qt/Makefile.am
- modules/gui/qt/dialogs/toolbar/qml/EditorDNDView.qml
- modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorButtonList.qml
- modules/gui/qt/maininterface/qml/BannerSources.qml
- modules/gui/qt/meson.build
- modules/gui/qt/network/qml/BrowseHomeDisplay.qml
- modules/gui/qt/style/VLCStyle.qml
- modules/gui/qt/util/qml/ViewDragAutoScrollHandler.qml
- modules/gui/qt/widgets/qml/ExpandGridView.qml
- modules/gui/qt/widgets/qml/ListViewExt.qml
- + modules/gui/qt/widgets/qml/ScrollBarExt.qml
Changes:
=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -1300,7 +1300,8 @@ libqml_module_widgets_a_QML = \
widgets/qml/ViewHeader.qml \
widgets/qml/ProgressIndicator.qml \
widgets/qml/RectangularGlow.qml \
- widgets/qml/ImageExt.qml
+ widgets/qml/ImageExt.qml \
+ widgets/qml/ScrollBarExt.qml
if HAVE_QT65
libqml_module_widgets_a_QML += \
widgets/qml/DynamicShadow.qml \
=====================================
modules/gui/qt/dialogs/toolbar/qml/EditorDNDView.qml
=====================================
@@ -22,6 +22,7 @@ import QtQml.Models
import VLC.Style
import VLC.Util
+import VLC.Widgets as Widgets
ListView {
id: playerBtnDND
@@ -40,7 +41,7 @@ ListView {
property bool extraWidthAvailable: true
- ScrollBar.horizontal: ScrollBar {
+ ScrollBar.horizontal: Widgets.ScrollBarExt {
id: scrollBar
}
=====================================
modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorButtonList.qml
=====================================
@@ -31,7 +31,7 @@ GridView {
clip: true
- ScrollBar.vertical: ScrollBar { }
+ ScrollBar.vertical: Widgets.ScrollBarExt { }
model: PlayerControlbarControls.controlList.length
currentIndex: -1
=====================================
modules/gui/qt/maininterface/qml/BannerSources.qml
=====================================
@@ -348,7 +348,7 @@ T.ToolBar {
contentWidth: localMenuGroup.width
contentHeight: VLCStyle.localToolbar_height // don't allow vertical flickering
- ScrollBar.horizontal: ScrollBar {
+ ScrollBar.horizontal: Widgets.ScrollBarExt {
y: localMenuView.height - height
width: localMenuView.availableWidth
policy: ScrollBar.AsNeeded
=====================================
modules/gui/qt/meson.build
=====================================
@@ -900,6 +900,7 @@ qml_modules += {
qml_dynamicshadow_file,
qml_blureffect_file,
'widgets/qml/ImageExt.qml',
+ 'widgets/qml/ScrollBarExt.qml',
),
}
=====================================
modules/gui/qt/network/qml/BrowseHomeDisplay.qml
=====================================
@@ -135,7 +135,7 @@ FocusScope {
anchors.leftMargin: root.leftPadding
anchors.rightMargin: root.rightPadding
- ScrollBar.vertical: ScrollBar { }
+ ScrollBar.vertical: Widgets.ScrollBarExt { }
flickableDirection: Flickable.AutoFlickIfNeeded
boundsBehavior: Flickable.StopAtBounds
=====================================
modules/gui/qt/style/VLCStyle.qml
=====================================
@@ -20,6 +20,7 @@ import QtQuick
import QtQuick.Controls
import VLC.MainInterface
import VLC.Style
+import VLC.Widgets as Widgets
QtObject {
id: vlc_style
@@ -57,7 +58,7 @@ QtObject {
readonly property double margin_xlarge: MainCtx.dp(32, scale);
readonly property double margin_xxlarge: MainCtx.dp(36, scale);
- property Component _scrollBarComponent: ScrollBar { }
+ property Component _scrollBarComponent: Widgets.ScrollBarExt { }
property real resizeHandleWidth
// Borders
=====================================
modules/gui/qt/util/qml/ViewDragAutoScrollHandler.qml
=====================================
@@ -17,6 +17,7 @@
*****************************************************************************/
import QtQuick
import QtQuick.Controls
+import QtQuick.Templates as T
import VLC.Style
@@ -66,7 +67,7 @@ QtObject {
interval: 100
}
- readonly property ScrollBar _scrollBar: (root.view) ? ((root.orientation === Qt.Vertical) ? root.view.ScrollBar.vertical
+ readonly property T.ScrollBar _scrollBar: (root.view) ? ((root.orientation === Qt.Vertical) ? root.view.ScrollBar.vertical
: root.view.ScrollBar.horizontal)
: null
=====================================
modules/gui/qt/widgets/qml/ExpandGridView.qml
=====================================
@@ -784,7 +784,7 @@ FocusScope {
boundsBehavior: Flickable.StopAtBounds
- ScrollBar.vertical: ScrollBar {
+ ScrollBar.vertical: ScrollBarExt {
id: flickableScrollBar
}
=====================================
modules/gui/qt/widgets/qml/ListViewExt.qml
=====================================
@@ -81,8 +81,8 @@ ListView {
keyNavigationEnabled: false
keyNavigationWraps: false
- ScrollBar.vertical: ScrollBar { }
- ScrollBar.horizontal: ScrollBar { }
+ ScrollBar.vertical: ScrollBarExt { }
+ ScrollBar.horizontal: ScrollBarExt { }
flickableDirection: Flickable.AutoFlickIfNeeded
=====================================
modules/gui/qt/widgets/qml/ScrollBarExt.qml
=====================================
@@ -0,0 +1,103 @@
+/*****************************************************************************
+ * Copyright (C) 2025 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+import QtQuick
+import QtQuick.Templates as T
+
+import VLC.Style
+
+T.ScrollBar {
+ id: control
+
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ implicitContentWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ implicitContentHeight + topPadding + bottomPadding)
+
+ padding: VLCStyle.dp(2, VLCStyle.scale)
+ visible: policy !== T.ScrollBar.AlwaysOff
+ minimumSize: horizontal ? (height / width) : (width / height)
+
+ // We don't want to show anything is scrolling is not possible (content size less than
+ // or equal to flickable size), unless `ScrollBar.AlwaysOn` is used (not by default):
+ readonly property bool _shown: (policy === T.ScrollBar.AlwaysOn) || (control.size < 1.0)
+
+ // active is not used here, because it is set when the attached Flickable is moving.
+ // interacting is only set when the scroll bar itself is interacted.
+ readonly property bool interacting: (interactive && (control.hovered || control.pressed))
+
+ readonly property ColorContext colorContext: ColorContext {
+ id: theme
+ colorSet: ColorContext.Item
+
+ // focused: control.activeFocus // irrelevant
+ enabled: control.enabled
+
+ // Do not change the colors when pressed or hovered, similar to WinUI3:
+ pressed: false
+ hovered: true
+ }
+
+ component DefaultBehavior : Behavior {
+ // WARNING: Qt bug: OpacityAnimator is bugged
+ NumberAnimation {
+ easing.type: Easing.OutSine
+ duration: VLCStyle.duration_veryShort
+ }
+ }
+
+ background: Rectangle {
+ color: theme.bg.primary
+ radius: width / 2
+
+ opacity: (control._shown && control.interacting) ? 1.0 : 0.0
+
+ visible: (opacity > 0.0)
+
+ DefaultBehavior on opacity { }
+ }
+
+ contentItem: Rectangle {
+ implicitWidth: VLCStyle.dp(control.interacting ? 5 : 2, VLCStyle.scale)
+ implicitHeight: VLCStyle.dp(control.interacting ? 5 : 2, VLCStyle.scale)
+
+ radius: width / 2
+ color: theme.fg.secondary
+
+ visible: (opacity > 0.0)
+
+ opacity: control._shown ? 1.0 : 0.0
+
+ DefaultBehavior on opacity { }
+
+ component SizeBehavior : Behavior {
+ NumberAnimation {
+ easing.type: Easing.OutSine
+ duration: VLCStyle.duration_veryShort
+ }
+ }
+
+ SizeBehavior on implicitWidth {
+ enabled: control.vertical
+ }
+
+ SizeBehavior on implicitHeight {
+ enabled: control.horizontal
+ }
+ }
+}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3ee11e23766bc837023b150f45da1647bf7d79e0...258722d74cba782abe5d7a714ccf0516df639984
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3ee11e23766bc837023b150f45da1647bf7d79e0...258722d74cba782abe5d7a714ccf0516df639984
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list