import QtQuick 2.0

import QtQuick.Layouts 1.11

import QGroundControl.Controls 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.ScreenTools   1.0

GridLayout {

    property var generator: undefined // LinearGenerator
    property var availableWidth: 300
    property real   _margin: ScreenTools.defaultFontPixelWidth / 2

    width:      availableWidth
    columnSpacing:  _margin
    rowSpacing:     _margin
    columns:        2

    Component.onCompleted: {
        console.assert(generator !== undefined, "please set the generator property")
    }

    QGCLabel { text: qsTr("Distance") }
    FactTextField {
        fact:                   generator.distance
        Layout.fillWidth:       true
    }

    QGCLabel {
        text: qsTr("Alpha: ")
        Layout.fillWidth: true
    }
    FactTextField {
        fact:                   generator.alpha
        Layout.fillWidth:       true
    }
    QGCSlider {
        id:                     rSlider
        minimumValue:           0
        maximumValue:           180
        stepSize:               0.1
        tickmarksEnabled:       false
        Layout.fillWidth:       true
        Layout.columnSpan:      2
        Layout.preferredHeight: ScreenTools.defaultFontPixelHeight * 1.5
        onValueChanged:         {
            generator.alpha.value = value
            value = Qt.binding(function(){return generator.alpha.value})
        }
        Component.onCompleted:  value = generator.alpha.value
        updateValueWhileDragging: true
    }

    QGCLabel { text: qsTr("Min. Length") }
    FactTextField {
        fact:                   generator.minLength
        Layout.fillWidth:       true
    }
}
