/*!
 *
 * 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    Circle.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      28-Jan-2022
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  04-Feb-2020
 *
 */

// Qt
import QtQuick 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     : Variables.circleNormalDiameter

    width   : diameter
    height  : diameter

    Rectangle { id: _rectangle
        anchors.centerIn: _root
        width   : _root.width
        height  : _root.height
        radius  : _root.width
        color   : Colors.transparent
        border.width: _root.thickness + shadowEdge * 2
        border.color: Colors.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: Colors.transparent
                strokeColor: Colors.borderButton
                strokeWidth: 1
                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
                }
            }
        }
    }
}
