/*!
 *
 * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved.
 * \copyright                                                       \n
 *          THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM,  \n
 *          IN PART OR IN WHOLE,                                    \n
 *          WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n
 *
 * \file    Slider.qml
 * \date    2020/03/13
 * \author  Behrouz NematiPour
 *
 */

// 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 int    minimum     : parent.minimum
    property int    maximum     : parent.maximum
    property int    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   : "white"

    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
                }
            }
        }
    }
}
