/*!
 *
 * Copyright (c) 2020-2023 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)      15-May-2021
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  22-Mar-2020
 *
 */

// Qt
import QtQuick 2.12

// Project

//  Qml imports
import "qrc:/globals"

/*!
 * \brief   Denali project TickMarks
 */
Item { id : _root
    // if loader used then assign ranges when used.
    // since loader get the parenthood and it has no range definition.
    property int    decimal     : 0
    property real   minimum     : parent.minimum
    property real   maximum     : parent.maximum
    property real   step        : parent.step
    property bool   stepSnap    : false

    property color  color       : Colors.backgroundDialog

    property int    orientation : Line.Orientation.Vertical
    property int    length      : parent.height
    property int    thickness   : 1

    property bool   textVisible : false
    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
            color       : _root.color
            length      : _root.length
            x: (((index * step) * (parent.width - parent.x)) / (maximum - minimum)) + gap
            y: 0
            Text { id : _text
                visible: textVisible
                color: _root.textColor
                font.pixelSize: 10
                text: ((index * step) + minimum).toFixed(decimal)
                anchors {
                    top: parent.bottom
                    topMargin: 5
                    horizontalCenter: parent.horizontalCenter
                }
            }
        }
    }
}
