/*!
 *
 * 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    Circle.qml
 * \date    2020/02/03
 * \author  Behrouz NematiPour
 *
 */

// Qt
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Shapes 1.12

// Project

//  Qml imports
import "qrc:/globals"
import "qrc:/components"

/*!
 * \brief   Drawing Circle Component
 */
Item { id: _root
    property alias thickness    : _path.strokeWidth
    property alias color        : _path.strokeColor
    property alias shadow       : _rectangle.border
    property int   shadowEdge   : 1
    property alias fillColor    : _rectangle.color
    property alias capStyle     : _path.capStyle

    property alias angle        : _arc.sweepAngle
    property alias startAngle   : _arc.startAngle

    property real  diameter     : 350

    width   : diameter
    height  : diameter

    Rectangle { id: _rectangle
        anchors.centerIn: _root
        width   : _root.width
        height  : _root.height
        radius  : _root.width
        color   : "Transparent"
        border.width: _root.thickness + shadowEdge * 2
        border.color: "Transparent"
        antialiasing: true
        Shape { id: _shape
            width: parent.width
            height: parent.height
            layer.enabled: true
            layer.smooth: true
            layer.textureSize: Qt.size(_shape.width * 2, _shape.height * 2)
            ShapePath { id: _path
                fillColor: "Transparent"
                strokeColor: Colors.borderButton
                strokeWidth: 2
                capStyle: ShapePath.RoundCap
                PathAngleArc { id: _arc
                    centerX: _root.width  / 2
                    centerY: _root.height / 2
                    radiusX: (diameter - _path.strokeWidth - (shadowEdge * 2) ) / 2
                    radiusY: (diameter - _path.strokeWidth - (shadowEdge * 2) ) / 2
                    startAngle: -90
                    sweepAngle: 0
                }
            }
        }
    }
}


