QGCPipState.qml 3.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
/****************************************************************************
 *
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

import QtQuick 2.12

// Used to manage state for itesm using with QGCPipOveral
Item {
    id:     _root
    state:  initState

    readonly property string initState:             "init"
    readonly property string pipState:              "pip"
    readonly property string fullState:             "full"
    readonly property string windowState:           "window"
    readonly property string windowClosingState:    "windowClosing"

    property var  pipOverlay            // QGCPipOverlay control
    property bool isDark:       true    // true: Use dark overlay visuals

    signal windowAboutToOpen    // Catch this signal to do something special prior to the item transition to windowed mode
    signal windowAboutToClose   // Catch this signal to do special processing prior to the item transition back to pip mode

    property var _clientControl: _root.parent

    states: [
        State {
            name: pipState

            AnchorChanges {
                target:         _clientControl
                anchors.top:    pipOverlay.top
                anchors.bottom: pipOverlay.bottom
                anchors.left:   pipOverlay.left
                anchors.right:  pipOverlay.right
            }

            PropertyChanges {
                target: _clientControl
                z:      pipOverlay.pipZOrder
            }
        },
        State {
            name: fullState

            AnchorChanges {
                target:         _clientControl
                anchors.top:    pipOverlay.parent.top
                anchors.bottom: pipOverlay.parent.bottom
                anchors.left:   pipOverlay.parent.left
                anchors.right:  pipOverlay.parent.right
            }

            PropertyChanges {
                target: _clientControl
                z:      pipOverlay.fullZOrder
            }
        },
        State {
            name: windowState

            AnchorChanges {
                target:         _root.parent
                anchors.top:    pipOverlay._windowContentItem.top
                anchors.bottom: pipOverlay._windowContentItem.bottom
                anchors.left:   pipOverlay._windowContentItem.left
                anchors.right:  pipOverlay._windowContentItem.right
            }

            ParentChange {
                target: _root.parent
                parent: pipOverlay._windowContentItem
            }

            StateChangeScript {
                script: {
                    _root.windowAboutToOpen()
                    pipOverlay.showWindow()
                }
            }
        },
        State {
            name: windowClosingState

            ParentChange {
                target: _root.parent
                parent: pipOverlay.parent
            }
        }
    ]
}