Index: sources/gui/qml/components/TickMarks.qml =================================================================== diff -u -rccb91da4becded9a7ad409b758bba96784d9feba -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 --- sources/gui/qml/components/TickMarks.qml (.../TickMarks.qml) (revision ccb91da4becded9a7ad409b758bba96784d9feba) +++ sources/gui/qml/components/TickMarks.qml (.../TickMarks.qml) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) @@ -1,15 +1,15 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * - * \file TickMarks.qml - * \author (last) Behrouz NematiPour - * \date (last) 16-Oct-2020 - * \author (original) Behrouz NematiPour - * \date (original) 22-Mar-2020 + * \file TickMarks.qml + * \author (last) Vy + * \date (last) 15-Mar-2023 + * \author (original) Behrouz NematiPour + * \date (original) 22-Mar-2020 * */ @@ -35,30 +35,37 @@ property color color : Colors.backgroundDialog - property int orientation : Line.Orientation.Vertical - property int length : parent.height - property int thickness : 1 + property bool isTickMarkRound : false + property real roundTickMarkDiameter : Variables.sliderDefaultRoundTickMarkDiameter + property real yDisplacement : 0 + property bool showEndMarks : true + // For the case that the tickmark is a line + property real lineTickMarkHeight : 20 + property real lineTickMarkThickness : 1 + property bool textVisible : false - property color textColor : "white" + property color textColor : Colors.textMain anchors.fill: parent Repeater { id : _repeater - model: (maximum - minimum) / step // + 1 - Line { id: _line - property int gap : stepSnap ? - ( - (parent.width * (step - (minimum % step))) / (maximum - minimum) - ) : 0 - orientation : _root.orientation - thickness : _root.thickness + readonly property real totalTickCount: ((maximum - minimum) / step + 1) // added property for clarity + + model: totalTickCount + + Rectangle { + visible : _repeater.isTickMarkVisible(index) + x : (((index * step) * (parent.width - parent.x)) / (maximum - minimum)) - width/2 // "-width/2 " for moving tick mark to center on handle + y : _root.yDisplacement color : _root.color - length : _root.length - x: (((index * step) * (parent.width - parent.x)) / (maximum - minimum)) + gap - y: 0 + + height : isTickMarkRound ? _root.roundTickMarkDiameter : _root.lineTickMarkHeight + width : isTickMarkRound ? _root.roundTickMarkDiameter : _root.lineTickMarkThickness + radius : isTickMarkRound ? _root.roundTickMarkDiameter : 0 + Text { id : _text - visible: textVisible + visible: _root.textVisible color: _root.textColor font.pixelSize: 10 text: ((index * step) + minimum).toFixed(decimal) @@ -69,5 +76,17 @@ } } } + + function isTickMarkVisible(index) { + if (showEndMarks) { + return true // all marks shown + } else { + // Only the center marks are shown, ie: exclude the end marks + if ((index > 0) && (index < (_repeater.totalTickCount-1))) { + return true + } + } + return false + } } }