Warning, /maui/booth/src/widgets/ZoomControl.qml is written in an unsupported language. File is not indexed.
0001 /**************************************************************************** 0002 ** 0003 ** Copyright (C) 2017 The Qt Company Ltd. 0004 ** Contact: https://www.qt.io/licensing/ 0005 ** 0006 ** This file is part of the examples of the Qt Toolkit. 0007 ** 0008 ** $QT_BEGIN_LICENSE:BSD$ 0009 ** Commercial License Usage 0010 ** Licensees holding valid commercial Qt licenses may use this file in 0011 ** accordance with the commercial license agreement provided with the 0012 ** Software or, alternatively, in accordance with the terms contained in 0013 ** a written agreement between you and The Qt Company. For licensing terms 0014 ** and conditions see https://www.qt.io/terms-conditions. For further 0015 ** information use the contact form at https://www.qt.io/contact-us. 0016 ** 0017 ** BSD License Usage 0018 ** Alternatively, you may use this file under the terms of the BSD license 0019 ** as follows: 0020 ** 0021 ** "Redistribution and use in source and binary forms, with or without 0022 ** modification, are permitted provided that the following conditions are 0023 ** met: 0024 ** * Redistributions of source code must retain the above copyright 0025 ** notice, this list of conditions and the following disclaimer. 0026 ** * Redistributions in binary form must reproduce the above copyright 0027 ** notice, this list of conditions and the following disclaimer in 0028 ** the documentation and/or other materials provided with the 0029 ** distribution. 0030 ** * Neither the name of The Qt Company Ltd nor the names of its 0031 ** contributors may be used to endorse or promote products derived 0032 ** from this software without specific prior written permission. 0033 ** 0034 ** 0035 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0036 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0037 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0038 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0039 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0040 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0041 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0042 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0043 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0044 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0045 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 0046 ** 0047 ** $QT_END_LICENSE$ 0048 ** 0049 ****************************************************************************/ 0050 0051 import QtQuick 2.0 0052 import QtMultimedia 5.0 0053 0054 Item { 0055 id : zoomControl 0056 property real currentZoom : 1 0057 property real maximumZoom : 1 0058 signal zoomTo(real value) 0059 0060 visible: zoomControl.maximumZoom > 1 0061 0062 MouseArea { 0063 id : mouseArea 0064 anchors.fill: parent 0065 0066 property real initialZoom : 0 0067 property real initialPos : 0 0068 0069 onPressed: { 0070 initialPos = mouseY 0071 initialZoom = zoomControl.currentZoom 0072 } 0073 0074 onPositionChanged: { 0075 if (pressed) { 0076 var target = initialZoom * Math.pow(5, (initialPos-mouseY)/zoomControl.height); 0077 target = Math.max(1, Math.min(target, zoomControl.maximumZoom)) 0078 zoomControl.zoomTo(target) 0079 } 0080 } 0081 } 0082 0083 Item { 0084 id : bar 0085 x : 16 0086 y : parent.height/4 0087 width : 24 0088 height : parent.height/2 0089 0090 Rectangle { 0091 anchors.fill: parent 0092 0093 smooth: true 0094 radius: 8 0095 border.color: "white" 0096 border.width: 2 0097 color: "black" 0098 opacity: 0.3 0099 } 0100 0101 Rectangle { 0102 id: groove 0103 x : 0 0104 y : parent.height * (1.0 - (zoomControl.currentZoom-1.0) / (zoomControl.maximumZoom-1.0)) 0105 width: parent.width 0106 height: parent.height - y 0107 smooth: true 0108 radius: 8 0109 color: "white" 0110 opacity: 0.5 0111 } 0112 0113 Text { 0114 id: zoomText 0115 anchors { 0116 left: bar.right; leftMargin: 16 0117 } 0118 y: Math.min(parent.height - height, Math.max(0, groove.y - height / 2)) 0119 text: "x" + Math.round(zoomControl.currentZoom * 100) / 100 0120 font.bold: true 0121 color: "white" 0122 style: Text.Raised; styleColor: "black" 0123 opacity: 0.85 0124 font.pixelSize: 18 0125 } 0126 } 0127 }