Warning, /office/klevernotes/src/contents/ui/dialogs/colorDialog/LightnessSlider.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2023 Louis Schul <schul9louis@gmail.com>
0003 
0004 import QtQuick 2.11
0005 
0006 Item {
0007     id: lightSlider
0008 
0009     property real l
0010     property int cursorHeight: 7
0011 
0012     Rectangle {
0013         id: gradientRect
0014 
0015         y: 10
0016         width: parent.width
0017         height: parent.height - 20
0018 
0019         gradient: Gradient {
0020             GradientStop { position: 0.0; color: "#FFFFFFFF" }
0021             GradientStop { position: 1.0; color: "#FF000000" }
0022         }
0023 
0024         Item {
0025             id: pickerCursor
0026 
0027             width: parent.width
0028 
0029             Rectangle {
0030                 property real cal: (gradientRect.height - (gradientRect.height * lightSlider.l))
0031 
0032                 x: -2;
0033                 y: Math.min(cal, gradientRect.height)
0034                 width: parent.width + 4; height: cursorHeight
0035 
0036                 color: "transparent"
0037                 border.color: (lightSlider.l > 50) ? "black" : "white"
0038                 border.width: 2
0039             }
0040         }
0041 
0042         MouseArea {
0043             id: mouseArea
0044 
0045             anchors.fill: parent
0046 
0047             onPressed: {
0048                 handleMouse(mouse)
0049             }
0050             onPositionChanged: {
0051                 handleMouse(mouse)
0052             }
0053 
0054             function handleMouse(mouse) {
0055                 if (mouse.buttons & Qt.LeftButton) {
0056                     const currentY = Math.max(0, Math.min(height, mouse.y))
0057 
0058                     lightSlider.l = (height-currentY)/height
0059                 }
0060             }
0061         }
0062     }
0063 }