vlc | branch: master | Prince Gupta <guptaprince8...@gmail.com> | Sun Aug 23 23:09:44 2020 +0530| [8ec81503ea4a574d91a6b24cf9812e744baed994] | committer: Pierre Lamot
qml: introduce HorizontalResizehandle Signed-off-by: Pierre Lamot <pie...@videolabs.io> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8ec81503ea4a574d91a6b24cf9812e744baed994 --- modules/gui/qt/Makefile.am | 1 + modules/gui/qt/vlc.qrc | 1 + .../gui/qt/widgets/qml/HorizontalResizeHandle.qml | 55 ++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am index 2b0e180b83..9a8f5fab26 100644 --- a/modules/gui/qt/Makefile.am +++ b/modules/gui/qt/Makefile.am @@ -672,6 +672,7 @@ libqt_plugin_la_QML = \ gui/qt/widgets/qml/ExpandGridView.qml \ gui/qt/widgets/qml/FocusBackground.qml \ gui/qt/widgets/qml/GridItem.qml \ + gui/qt/widgets/qml/HorizontalResizeHandle.qml \ gui/qt/widgets/qml/IconLabel.qml \ gui/qt/widgets/qml/IconToolButton.qml \ gui/qt/widgets/qml/ImageToolButton.qml \ diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc index 4c329dbb2a..df2c7bbef7 100644 --- a/modules/gui/qt/vlc.qrc +++ b/modules/gui/qt/vlc.qrc @@ -222,6 +222,7 @@ <file alias="MediaCover.qml">widgets/qml/MediaCover.qml</file> <file alias="MenuLabel.qml">widgets/qml/MenuLabel.qml</file> <file alias="ListSubtitleLabel.qml">widgets/qml/ListSubtitleLabel.qml</file> + <file alias="HorizontalResizeHandle.qml">widgets/qml/HorizontalResizeHandle.qml</file> </qresource> <qresource prefix="/util"> <file alias="SelectableDelegateModel.qml">util/qml/SelectableDelegateModel.qml</file> diff --git a/modules/gui/qt/widgets/qml/HorizontalResizeHandle.qml b/modules/gui/qt/widgets/qml/HorizontalResizeHandle.qml new file mode 100644 index 0000000000..c86cbefa8e --- /dev/null +++ b/modules/gui/qt/widgets/qml/HorizontalResizeHandle.qml @@ -0,0 +1,55 @@ +/***************************************************************************** + * Copyright (C) 2020 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 2.11 +import QtQuick.Controls 2.4 +import "qrc:///style/" + +// targetWidth: concerned widget's current width +// sourceWidth: target's width is bounded by this value (parent's width?) +// HorizontalResizeHandle actually doesn't resizes target +// you have to assign target's width manually using widthFactor property +// the idea behind using widthFactor is to maintain scale ratio when source itself resizes +// e.g target.width: resizeHandle.clamp(sourceWidth / resizeHandle.widthFactor, minimumWidth, maximumWidth) +MouseArea { + id: root + + // provided by parent, this widget don't modify these properties + property int sourceWidth + property int targetWidth + + property double widthFactor: 4 + property bool atRight: true + + property int _previousX + + cursorShape: Qt.SplitHCursor + width: VLCStyle.dp(8) + acceptedButtons: Qt.LeftButton + + onPressed: _previousX = mouseX + + onPositionChanged: { + var f = atRight ? -1 : 1 + var delta = mouseX + _previousX * f + root.widthFactor = root.sourceWidth / (root.targetWidth + (delta * - f)) + } + + function clamp(num, min, max) { + return num <= min ? min : num >= max ? max : num; + } +} _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits