Commit 6940e70c authored by Gus Grubba's avatar Gus Grubba

Plan View Work

Toggle Rally Point insertion on/off.
Highlight current Rally Point and current Waypoint.
Use tab bar instead of a row of radio buttons for selection (Mission, Fence, Rally).
Fix QGCHoverButton to handle proper checked state toggle.
Get rid of the many arrays used to define behaviors for the ToolStrip. They are now all defined within its model.
Fixed color for disabled text within ToolStrip (it was invisible)
parent 4dbbe70a
...@@ -581,9 +581,6 @@ Item { ...@@ -581,9 +581,6 @@ Item {
z: _mapAndVideo.z + 4 z: _mapAndVideo.z + 4
maxHeight: (_flightVideo.visible ? _flightVideo.y : parent.height) - toolStrip.y maxHeight: (_flightVideo.visible ? _flightVideo.y : parent.height) - toolStrip.y
buttonVisible: [true, _useChecklist, _guidedController.showTakeoff || !_guidedController.showLand, _guidedController.showLand && !_guidedController.showTakeoff, true, _guidedController.showPause, !_guidedController.showPause ]
buttonEnabled: [true, _useChecklist && activeVehicle && !activeVehicle.armed, _guidedController.showTakeoff, _guidedController.showLand, _guidedController.showRTL, _guidedController.showPause, _anyActionAvailable ]
property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort
property var _actionModel: [ property var _actionModel: [
{ {
...@@ -622,35 +619,49 @@ Item { ...@@ -622,35 +619,49 @@ Item {
{ {
name: "Plan", name: "Plan",
iconSource: "/qmlimages/Plan.svg", iconSource: "/qmlimages/Plan.svg",
buttonVisible: true,
buttonEnabled: true,
}, },
{ {
name: "Checklist", name: "Checklist",
iconSource: "/qmlimages/check.svg", iconSource: "/qmlimages/check.svg",
buttonVisible: _useChecklist,
buttonEnabled: _useChecklist && activeVehicle && !activeVehicle.armed,
}, },
{ {
name: _guidedController.takeoffTitle, name: _guidedController.takeoffTitle,
iconSource: "/res/takeoff.svg", iconSource: "/res/takeoff.svg",
action: _guidedController.actionTakeoff buttonVisible: _guidedController.showTakeoff || !_guidedController.showLand,
buttonEnabled: _guidedController.showTakeoff,
action: _guidedController.actionTakeoff
}, },
{ {
name: _guidedController.landTitle, name: _guidedController.landTitle,
iconSource: "/res/land.svg", iconSource: "/res/land.svg",
action: _guidedController.actionLand buttonVisible: _guidedController.showLand && !_guidedController.showTakeoff,
buttonEnabled: _guidedController.showLand,
action: _guidedController.actionLand
}, },
{ {
name: _guidedController.rtlTitle, name: _guidedController.rtlTitle,
iconSource: "/res/rtl.svg", iconSource: "/res/rtl.svg",
action: _guidedController.actionRTL buttonVisible: true,
buttonEnabled: _guidedController.showRTL,
action: _guidedController.actionRTL
}, },
{ {
name: _guidedController.pauseTitle, name: _guidedController.pauseTitle,
iconSource: "/res/pause-mission.svg", iconSource: "/res/pause-mission.svg",
action: _guidedController.actionPause buttonVisible: _guidedController.showPause,
buttonEnabled: _guidedController.showPause,
action: _guidedController.actionPause
}, },
{ {
name: qsTr("Action"), name: qsTr("Action"),
iconSource: "/res/action.svg", iconSource: "/res/action.svg",
action: -1 buttonVisible: !_guidedController.showPause,
buttonEnabled: _anyActionAvailable,
action: -1
} }
] ]
......
...@@ -74,7 +74,7 @@ Rectangle { ...@@ -74,7 +74,7 @@ Rectangle {
QGCLabel { QGCLabel {
id: actionMessage id: actionMessage
text: modelData.text text: modelData.text ? modelData.text : ""
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
Layout.minimumWidth: _width Layout.minimumWidth: _width
......
...@@ -36,8 +36,8 @@ MapQuickItem { ...@@ -36,8 +36,8 @@ MapQuickItem {
gimbalYaw: missionItem.missionGimbalYaw gimbalYaw: missionItem.missionGimbalYaw
vehicleYaw: missionItem.missionVehicleYaw vehicleYaw: missionItem.missionVehicleYaw
showGimbalYaw: !isNaN(missionItem.missionGimbalYaw) showGimbalYaw: !isNaN(missionItem.missionGimbalYaw)
highlightSelected: true
onClicked: _item.clicked() onClicked: _item.clicked()
property bool _isCurrentItem: missionItem ? missionItem.isCurrentItem : false property bool _isCurrentItem: missionItem ? missionItem.isCurrentItem : false
} }
} }
...@@ -33,19 +33,16 @@ MapItemView { ...@@ -33,19 +33,16 @@ MapItemView {
parent._retaskSequence = object.sequenceNumber parent._retaskSequence = object.sequenceNumber
parent.flightWidgets.guidedModeBar.confirmAction(parent.flightWidgets.guidedModeBar.confirmRetask) parent.flightWidgets.guidedModeBar.confirmAction(parent.flightWidgets.guidedModeBar.confirmRetask)
} }
// These are the non-coordinate child mission items attached to this item // These are the non-coordinate child mission items attached to this item
Row { Row {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.right anchors.left: parent.right
Repeater { Repeater {
model: object.childItems model: object.childItems
delegate: MissionItemIndexLabel { delegate: MissionItemIndexLabel {
label: object.abbreviation label: object.abbreviation
checked: object.isCurrentItem checked: object.isCurrentItem
z: 2 z: 2
} }
} }
} }
......
...@@ -33,8 +33,8 @@ public: ...@@ -33,8 +33,8 @@ public:
Q_PROPERTY(QString editorQml READ editorQml CONSTANT) Q_PROPERTY(QString editorQml READ editorQml CONSTANT)
Q_PROPERTY(QObject* currentRallyPoint READ currentRallyPoint WRITE setCurrentRallyPoint NOTIFY currentRallyPointChanged) Q_PROPERTY(QObject* currentRallyPoint READ currentRallyPoint WRITE setCurrentRallyPoint NOTIFY currentRallyPointChanged)
Q_INVOKABLE void addPoint(QGeoCoordinate point); Q_INVOKABLE void addPoint (QGeoCoordinate point);
Q_INVOKABLE void removePoint(QObject* rallyPoint); Q_INVOKABLE void removePoint (QObject* rallyPoint);
bool supported (void) const final; bool supported (void) const final;
void save (QJsonObject& json) final; void save (QJsonObject& json) final;
......
...@@ -52,10 +52,12 @@ Item { ...@@ -52,10 +52,12 @@ Item {
property bool _addWaypointOnClick: false property bool _addWaypointOnClick: false
property bool _addROIOnClick: false property bool _addROIOnClick: false
property bool _singleComplexItem: _missionController.complexMissionItemNames.length === 1 property bool _singleComplexItem: _missionController.complexMissionItemNames.length === 1
property int _editingLayer: _layerMission property int _editingLayer: bar.currentIndex ? _layers[bar.currentIndex] : _layerMission
property int _toolStripBottom: toolStrip.height + toolStrip.y property int _toolStripBottom: toolStrip.height + toolStrip.y
property var _appSettings: QGroundControl.settingsManager.appSettings property var _appSettings: QGroundControl.settingsManager.appSettings
readonly property var _layers: [_layerMission, _layerGeoFence, _layerRallyPoints]
readonly property int _layerMission: 1 readonly property int _layerMission: 1
readonly property int _layerGeoFence: 2 readonly property int _layerGeoFence: 2
readonly property int _layerRallyPoints: 3 readonly property int _layerRallyPoints: 3
...@@ -447,7 +449,7 @@ Item { ...@@ -447,7 +449,7 @@ Item {
} }
break break
case _layerRallyPoints: case _layerRallyPoints:
if (_rallyPointController.supported) { if (_rallyPointController.supported && _addWaypointOnClick) {
_rallyPointController.addPoint(coordinate) _rallyPointController.addPoint(coordinate)
} }
break break
...@@ -523,91 +525,111 @@ Item { ...@@ -523,91 +525,111 @@ Item {
//----------------------------------------------------------- //-----------------------------------------------------------
// Left tool strip // Left tool strip
ToolStrip { ToolStrip {
id: toolStrip id: toolStrip
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
anchors.left: parent.left anchors.left: parent.left
anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.5 anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.5
anchors.top: parent.top anchors.top: parent.top
z: QGroundControl.zOrderWidgets z: QGroundControl.zOrderWidgets
maxHeight: mapScale.y - toolStrip.y
showAlternateIcon: [ false, _planMasterController.dirty, false, false, false, false, false, false ] property bool _isRally: _editingLayer == _layerRallyPoints
rotateImage: [ false, _planMasterController.syncInProgress, false, false, false, false, false, false ] property bool _showZoom: !ScreenTools.isMobile
animateImage: [ false, _planMasterController.dirty, false, false, false, false, false, false ]
buttonEnabled: [ true, !_planMasterController.syncInProgress, true, true, true, true, true, true ]
buttonVisible: [ true, true, true, _waypointsOnlyMode, true, true, _showZoom, _showZoom ]
maxHeight: mapScale.y - toolStrip.y
property bool _showZoom: !ScreenTools.isMobile
model: [ model: [
{ {
name: qsTr("Fly"), name: qsTr("Fly"),
iconSource: "/qmlimages/PaperPlane.svg", iconSource: "/qmlimages/PaperPlane.svg",
buttonEnabled: true,
buttonVisible: true,
}, },
{ {
name: qsTr("File"), name: qsTr("File"),
iconSource: "/qmlimages/MapSync.svg", iconSource: "/qmlimages/MapSync.svg",
alternateIconSource: "/qmlimages/MapSyncChanged.svg", buttonEnabled: !_planMasterController.syncInProgress,
dropPanelComponent: syncDropPanel buttonVisible: true,
}, showAlternateIcon: _planMasterController.dirty,
{ alternateIconSource:"/qmlimages/MapSyncChanged.svg",
name: qsTr("Waypoint"), dropPanelComponent: syncDropPanel
iconSource: "/qmlimages/MapAddMission.svg", },
toggle: true {
}, name: _editingLayer == _layerRallyPoints ? qsTr("Rally Point") : qsTr("Waypoint"),
{ iconSource: "/qmlimages/MapAddMission.svg",
name: qsTr("ROI"), buttonEnabled: true,
iconSource: "/qmlimages/MapAddMission.svg", buttonVisible: true,
toggle: true toggle: true,
}, checked: _addWaypointOnClick
{ },
name: _singleComplexItem ? _missionController.complexMissionItemNames[0] : qsTr("Pattern"), {
iconSource: "/qmlimages/MapDrawShape.svg", name: qsTr("ROI"),
dropPanelComponent: _singleComplexItem ? undefined : patternDropPanel iconSource: "/qmlimages/MapAddMission.svg",
}, buttonEnabled: true,
{ buttonVisible: !_isRally && _waypointsOnlyMode,
name: qsTr("Center"), toggle: true
iconSource: "/qmlimages/MapCenter.svg", },
dropPanelComponent: centerMapDropPanel {
}, name: _singleComplexItem ? _missionController.complexMissionItemNames[0] : qsTr("Pattern"),
{ iconSource: "/qmlimages/MapDrawShape.svg",
name: qsTr("In"), buttonEnabled: true,
iconSource: "/qmlimages/ZoomPlus.svg" buttonVisible: !_isRally,
}, dropPanelComponent: _singleComplexItem ? undefined : patternDropPanel
{ },
name: qsTr("Out"), {
iconSource: "/qmlimages/ZoomMinus.svg" name: qsTr("Center"),
} iconSource: "/qmlimages/MapCenter.svg",
] buttonEnabled: true,
buttonVisible: true,
dropPanelComponent: centerMapDropPanel
},
{
name: qsTr("In"),
buttonEnabled: true,
buttonVisible: _showZoom,
iconSource: "/qmlimages/ZoomPlus.svg"
},
{
name: qsTr("Out"),
buttonEnabled: true,
buttonVisible: _showZoom,
iconSource: "/qmlimages/ZoomMinus.svg"
}
]
onClicked: { onClicked: {
switch (index) { switch (index) {
case 0: case 0:
mainWindow.showFlyView() mainWindow.showFlyView()
break; break;
case 2: case 2:
if(_addWaypointOnClick) {
//-- Toggle it off
_addWaypointOnClick = false
_addROIOnClick = false
setChecked(index, false)
} else {
_addWaypointOnClick = checked _addWaypointOnClick = checked
_addROIOnClick = false _addROIOnClick = false
break }
break
case 3: case 3:
_addROIOnClick = checked _addROIOnClick = checked
_addWaypointOnClick = false _addWaypointOnClick = false
break break
case 4: case 4:
if (_singleComplexItem) { if (_singleComplexItem) {
addComplexItem(_missionController.complexMissionItemNames[0]) addComplexItem(_missionController.complexMissionItemNames[0])
} }
break break
case 6: case 6:
editorMap.zoomLevel += 0.5 editorMap.zoomLevel += 0.5
break break
case 7: case 7:
editorMap.zoomLevel -= 0.5 editorMap.zoomLevel -= 0.5
break break
}
} }
} }
}
//----------------------------------------------------------- //-----------------------------------------------------------
// Right pane for mission editing controls // Right pane for mission editing controls
...@@ -626,6 +648,9 @@ Item { ...@@ -626,6 +648,9 @@ Item {
Item { Item {
anchors.fill: rightPanel anchors.fill: rightPanel
anchors.topMargin: _toolButtonTopMargin anchors.topMargin: _toolButtonTopMargin
DeadMouseArea {
anchors.fill: parent
}
Column { Column {
id: rightControls id: rightControls
spacing: ScreenTools.defaultFontPixelHeight * 0.5 spacing: ScreenTools.defaultFontPixelHeight * 0.5
...@@ -693,55 +718,33 @@ Item { ...@@ -693,55 +718,33 @@ Item {
Rectangle { Rectangle {
id: planExpanded id: planExpanded
width: parent.width width: parent.width
height: (!planControlColapsed || !_airspaceEnabled) ? expandedCol.height + ScreenTools.defaultFontPixelHeight : 0 height: (!planControlColapsed || !_airspaceEnabled) ? bar.height + ScreenTools.defaultFontPixelHeight : 0
color: qgcPal.missionItemEditor color: qgcPal.missionItemEditor
radius: _radius radius: _radius
visible: !planControlColapsed || !_airspaceEnabled visible: (!planControlColapsed || !_airspaceEnabled) && QGroundControl.corePlugin.options.enablePlanViewSelector
Item { Item {
height: expandedCol.height height: bar.height
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
Column { QGCTabBar {
id: expandedCol id: bar
spacing: ScreenTools.defaultFontPixelHeight * 0.5 width: parent.width
anchors.left: parent.left anchors.centerIn: parent
anchors.right: parent.right Component.onCompleted: {
//-- Header currentIndex = 0
Row { }
id: expandedRow QGCTabButton {
spacing: ScreenTools.defaultFontPixelWidth text: qsTr("Mission")
anchors.left: parent.left }
anchors.leftMargin: ScreenTools.defaultFontPixelWidth QGCTabButton {
readonly property real _buttonRadius: ScreenTools.defaultFontPixelHeight * 0.75 text: qsTr("Fence")
QGCLabel { enabled: _geoFenceController.supported
text: qsTr("Plan") }
color: qgcPal.text QGCTabButton {
visible: !QGroundControl.corePlugin.options.enablePlanViewSelector text: qsTr("Rally")
anchors.verticalCenter: parent.verticalCenter enabled: _rallyPointController.supported
}
QGCRadioButton {
id: planElementMission
text: qsTr("Mission")
checked: true
visible: QGroundControl.corePlugin.options.enablePlanViewSelector
anchors.verticalCenter: parent.verticalCenter
onClicked: _editingLayer = _layerMission
}
QGCRadioButton {
id: planElementGeoFence
text: qsTr("Fence")
visible: QGroundControl.corePlugin.options.enablePlanViewSelector
anchors.verticalCenter: parent.verticalCenter
onClicked: _editingLayer = _layerGeoFence
}
QGCRadioButton {
id: planElementRallyPoints
text: qsTr("Rally")
visible: QGroundControl.corePlugin.options.enablePlanViewSelector
anchors.verticalCenter: parent.verticalCenter
onClicked: _editingLayer = _layerRallyPoints
}
} }
} }
} }
...@@ -754,29 +757,29 @@ Item { ...@@ -754,29 +757,29 @@ Item {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: rightControls.bottom anchors.top: rightControls.bottom
anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.5 anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.25
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * 0.25 anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * 0.25
visible: _editingLayer == _layerMission && !planControlColapsed visible: _editingLayer == _layerMission && !planControlColapsed
QGCListView { QGCListView {
id: missionItemEditorListView id: missionItemEditorListView
anchors.fill: parent anchors.fill: parent
spacing: ScreenTools.defaultFontPixelHeight / 4 spacing: ScreenTools.defaultFontPixelHeight / 4
orientation: ListView.Vertical orientation: ListView.Vertical
model: _missionController.visualItems model: _missionController.visualItems
cacheBuffer: Math.max(height * 2, 0) cacheBuffer: Math.max(height * 2, 0)
clip: true clip: true
currentIndex: _missionController.currentPlanViewIndex currentIndex: _missionController.currentPlanViewIndex
highlightMoveDuration: 250 highlightMoveDuration: 250
visible: _editingLayer == _layerMission && !planControlColapsed visible: _editingLayer == _layerMission && !planControlColapsed
//-- List Elements //-- List Elements
delegate: MissionItemEditor { delegate: MissionItemEditor {
map: editorMap map: editorMap
masterController: _planMasterController masterController: _planMasterController
missionItem: object missionItem: object
width: parent.width width: parent.width
readOnly: false readOnly: false
onClicked: _missionController.setCurrentPlanViewIndex(object.sequenceNumber, false) onClicked: _missionController.setCurrentPlanViewIndex(object.sequenceNumber, false)
onRemove: { onRemove: {
var removeIndex = index var removeIndex = index
_missionController.removeMissionItem(removeIndex) _missionController.removeMissionItem(removeIndex)
...@@ -793,7 +796,7 @@ Item { ...@@ -793,7 +796,7 @@ Item {
// GeoFence Editor // GeoFence Editor
GeoFenceEditor { GeoFenceEditor {
anchors.top: rightControls.bottom anchors.top: rightControls.bottom
anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.5 anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.25
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
...@@ -805,7 +808,7 @@ Item { ...@@ -805,7 +808,7 @@ Item {
RallyPointEditorHeader { RallyPointEditorHeader {
id: rallyPointHeader id: rallyPointHeader
anchors.top: rightControls.bottom anchors.top: rightControls.bottom
anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.5 anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.25
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
visible: _editingLayer == _layerRallyPoints visible: _editingLayer == _layerRallyPoints
...@@ -814,7 +817,7 @@ Item { ...@@ -814,7 +817,7 @@ Item {
RallyPointItemEditor { RallyPointItemEditor {
id: rallyPointEditor id: rallyPointEditor
anchors.top: rallyPointHeader.bottom anchors.top: rallyPointHeader.bottom
anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.5 anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.25
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
visible: _editingLayer == _layerRallyPoints && _rallyPointController.points.count visible: _editingLayer == _layerRallyPoints && _rallyPointController.points.count
......
...@@ -36,7 +36,7 @@ QGCFlickable { ...@@ -36,7 +36,7 @@ QGCFlickable {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: editorLabel.bottom anchors.top: editorLabel.bottom
height: helpLabel.height + helpLabel.height + (_margin * 2) height: infoLabel.height + (_margin * 2)
color: qgcPal.windowShadeDark color: qgcPal.windowShadeDark
radius: _radius radius: _radius
...@@ -51,6 +51,7 @@ QGCFlickable { ...@@ -51,6 +51,7 @@ QGCFlickable {
text: qsTr("Rally Points provide alternate landing points when performing a Return to Launch (RTL).") text: qsTr("Rally Points provide alternate landing points when performing a Return to Launch (RTL).")
} }
/*
QGCLabel { QGCLabel {
id: helpLabel id: helpLabel
anchors.margins: _margin anchors.margins: _margin
...@@ -62,6 +63,7 @@ QGCFlickable { ...@@ -62,6 +63,7 @@ QGCFlickable {
qsTr("Click in the map to add new rally points.") : qsTr("Click in the map to add new rally points.") :
qsTr("This vehicle does not support Rally Points.") qsTr("This vehicle does not support Rally Points.")
} }
*/
} }
} }
} }
...@@ -14,11 +14,13 @@ Rectangle { ...@@ -14,11 +14,13 @@ Rectangle {
color: _currentItem ? qgcPal.missionItemEditor : qgcPal.windowShade color: _currentItem ? qgcPal.missionItemEditor : qgcPal.windowShade
radius: _radius radius: _radius
signal clicked()
property var rallyPoint ///< RallyPoint object associated with editor property var rallyPoint ///< RallyPoint object associated with editor
property var controller ///< RallyPointController property var controller ///< RallyPointController
property bool _currentItem: rallyPoint ? rallyPoint === controller.currentRallyPoint : false property bool _currentItem: rallyPoint ? rallyPoint === controller.currentRallyPoint : false
property color _outerTextColor: _currentItem ? "black" : qgcPal.text property color _outerTextColor: qgcPal.text // _currentItem ? "black" : qgcPal.text
readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2 readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2
readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2 readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2
...@@ -101,7 +103,6 @@ Rectangle { ...@@ -101,7 +103,6 @@ Rectangle {
Repeater { Repeater {
model: rallyPoint ? rallyPoint.textFieldFacts : 0 model: rallyPoint ? rallyPoint.textFieldFacts : 0
QGCLabel { QGCLabel {
text: modelData.name + ":" text: modelData.name + ":"
} }
...@@ -109,7 +110,6 @@ Rectangle { ...@@ -109,7 +110,6 @@ Rectangle {
Repeater { Repeater {
model: rallyPoint ? rallyPoint.textFieldFacts : 0 model: rallyPoint ? rallyPoint.textFieldFacts : 0
FactTextField { FactTextField {
Layout.fillWidth: true Layout.fillWidth: true
showUnits: true showUnits: true
......
...@@ -67,11 +67,11 @@ Item { ...@@ -67,11 +67,11 @@ Item {
property var rallyPointObject property var rallyPointObject
sourceItem: MissionItemIndexLabel { sourceItem: MissionItemIndexLabel {
id: itemIndexLabel id: itemIndexLabel
label: qsTr("R", "rally point map item label") label: qsTr("R", "rally point map item label")
checked: _editingLayer == _layerRallyPoints ? rallyPointObject === myRallyPointController.currentRallyPoint : false checked: _editingLayer == _layerRallyPoints ? rallyPointObject === myRallyPointController.currentRallyPoint : false
highlightSelected: true
onClicked: myRallyPointController.currentRallyPoint = rallyPointObject onClicked: myRallyPointController.currentRallyPoint = rallyPointObject
} }
} }
} }
......
...@@ -108,25 +108,20 @@ Item { ...@@ -108,25 +108,20 @@ Item {
z: QGroundControl.zOrderMapItems z: QGroundControl.zOrderMapItems
missionItem: _missionItem missionItem: _missionItem
sequenceNumber: _missionItem.sequenceNumber sequenceNumber: _missionItem.sequenceNumber
onClicked: _root.clicked(_missionItem.sequenceNumber)
onClicked: _root.clicked(_missionItem.sequenceNumber)
// These are the non-coordinate child mission items attached to this item // These are the non-coordinate child mission items attached to this item
Row { Row {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.right anchors.left: parent.right
Repeater { Repeater {
model: _missionItem.childItems model: _missionItem.childItems
delegate: MissionItemIndexLabel { delegate: MissionItemIndexLabel {
z: 2 z: 2
label: object.abbreviation.length === 0 ? object.sequenceNumber : object.abbreviation.charAt(0) label: object.abbreviation.length === 0 ? object.sequenceNumber : object.abbreviation.charAt(0)
checked: object.isCurrentItem checked: object.isCurrentItem
child: true child: true
specifiesCoordinate: false specifiesCoordinate: false
onClicked: _root.clicked(object.sequenceNumber)
onClicked: _root.clicked(object.sequenceNumber)
} }
} }
} }
......
...@@ -56,7 +56,7 @@ void QGCPalette::_buildMap() ...@@ -56,7 +56,7 @@ void QGCPalette::_buildMap()
DECLARE_QGC_COLOR(text, "#9d9d9d", "#000000", "#707070", "#ffffff") DECLARE_QGC_COLOR(text, "#9d9d9d", "#000000", "#707070", "#ffffff")
DECLARE_QGC_COLOR(warningText, "#cc0808", "#cc0808", "#f85761", "#f85761") DECLARE_QGC_COLOR(warningText, "#cc0808", "#cc0808", "#f85761", "#f85761")
DECLARE_QGC_COLOR(button, "#ffffff", "#ffffff", "#707070", "#626270") DECLARE_QGC_COLOR(button, "#ffffff", "#ffffff", "#707070", "#626270")
DECLARE_QGC_COLOR(buttonText, "#9d9d9d", "#000000", "#202020", "#ffffff") DECLARE_QGC_COLOR(buttonText, "#9d9d9d", "#000000", "#A6A6A6", "#ffffff")
DECLARE_QGC_COLOR(buttonHighlight, "#e4e4e4", "#946120", "#3a3a3a", "#fff291") DECLARE_QGC_COLOR(buttonHighlight, "#e4e4e4", "#946120", "#3a3a3a", "#fff291")
DECLARE_QGC_COLOR(buttonHighlightText, "#2c2c2c", "#ffffff", "#2c2c2c", "#000000") DECLARE_QGC_COLOR(buttonHighlightText, "#2c2c2c", "#ffffff", "#2c2c2c", "#000000")
DECLARE_QGC_COLOR(primaryButton, "#585858", "#8cb3be", "#585858", "#8cb3be") DECLARE_QGC_COLOR(primaryButton, "#585858", "#8cb3be", "#585858", "#8cb3be")
......
...@@ -17,6 +17,7 @@ Canvas { ...@@ -17,6 +17,7 @@ Canvas {
property bool checked: false property bool checked: false
property bool small: false property bool small: false
property bool child: false property bool child: false
property bool highlightSelected: false
property var color: checked ? "green" : (child ? qgcPal.mapIndicatorChild : qgcPal.mapIndicator) property var color: checked ? "green" : (child ? qgcPal.mapIndicatorChild : qgcPal.mapIndicator)
property real anchorPointX: _height / 2 property real anchorPointX: _height / 2
property real anchorPointY: _height / 2 property real anchorPointY: _height / 2
...@@ -114,6 +115,17 @@ Canvas { ...@@ -114,6 +115,17 @@ Canvas {
} }
} }
Rectangle {
width: indicator.width * 2
height: width
radius: width * 0.5
color: Qt.rgba(0,0,0,0)
border.color: Qt.rgba(1,1,1,0.5)
border.width: 1
visible: checked && highlightSelected
anchors.centerIn: indicator
}
QGCMouseArea { QGCMouseArea {
fillItem: parent fillItem: parent
onClicked: { onClicked: {
......
...@@ -30,10 +30,8 @@ Button { ...@@ -30,10 +30,8 @@ Button {
QGCPalette { id: qgcPalDisabled; colorGroupEnabled: false } QGCPalette { id: qgcPalDisabled; colorGroupEnabled: false }
// Initial state // Initial state
state: "Default" state: "Default"
// Update state on status changed // Update state on status changed
onEnabledChanged: state = "Default"
// Content Icon + Text // Content Icon + Text
contentItem: Item { contentItem: Item {
id: contentLayoutItem id: contentLayoutItem
...@@ -79,8 +77,8 @@ Button { ...@@ -79,8 +77,8 @@ Button {
name: "Hovering" name: "Hovering"
PropertyChanges { PropertyChanges {
target: button; target: button;
_currentColor: (checked || pressed) ? qgcPal.buttonHighlight : qgcPal.hoverColor _currentColor: (checked || pressed) ? qgcPal.buttonHighlight : qgcPal.hoverColor
_currentContentColor: qgcPal.buttonHighlightText _currentContentColor: qgcPal.buttonHighlightText
} }
PropertyChanges { PropertyChanges {
target: buttonBkRect target: buttonBkRect
...@@ -91,8 +89,8 @@ Button { ...@@ -91,8 +89,8 @@ Button {
name: "Default" name: "Default"
PropertyChanges { PropertyChanges {
target: button; target: button;
_currentColor: enabled ? ((checked || pressed) ? qgcPal.buttonHighlight : qgcPal.button) : qgcPalDisabled.button _currentColor: enabled ? ((checked || pressed) ? qgcPal.buttonHighlight : qgcPal.button) : qgcPalDisabled.button
_currentContentColor: enabled ? ((checked || pressed) ? qgcPal.buttonHighlightText : qgcPal.buttonText) : qgcPalDisabled.buttonText _currentContentColor: enabled ? ((checked || pressed) ? qgcPal.buttonHighlightText : qgcPal.buttonText) : qgcPalDisabled.buttonText
} }
PropertyChanges { PropertyChanges {
target: buttonBkRect target: buttonBkRect
...@@ -114,19 +112,19 @@ Button { ...@@ -114,19 +112,19 @@ Button {
// Process hover events // Process hover events
MouseArea { MouseArea {
enabled: !ScreenTools.isMobile enabled: !ScreenTools.isMobile
hoverEnabled: true
propagateComposedEvents: true propagateComposedEvents: true
preventStealing: true hoverEnabled: true
anchors.fill: button preventStealing: true
onEntered: { button.state = 'Hovering'; } anchors.fill: button
onExited: { button.state = 'Default'; } onEntered: button.state = 'Hovering'
onExited: button.state = 'Default'
// Propagate events down // Propagate events down
onClicked: { mouse.accepted = false; } onClicked: { mouse.accepted = false; }
onDoubleClicked: { mouse.accepted = false; } onDoubleClicked: { mouse.accepted = false; }
onPositionChanged: { mouse.accepted = false; } onPositionChanged: { mouse.accepted = false; }
onPressAndHold: { mouse.accepted = false; } onPressAndHold: { mouse.accepted = false; }
onPressed: { mouse.accepted = false } onPressed: { mouse.accepted = false }
onReleased: { mouse.accepted = false } onReleased: { mouse.accepted = false }
} }
} }
...@@ -9,12 +9,13 @@ import QGroundControl.ScreenTools 1.0 ...@@ -9,12 +9,13 @@ import QGroundControl.ScreenTools 1.0
TabButton { TabButton {
id: control id: control
property bool _showHighlight: (pressed | hovered | checked) property bool _showHighlight: (pressed | hovered | checked)
QGCPalette { id: qgcPalDisabled; colorGroupEnabled: false }
background: Rectangle { background: Rectangle {
color: _showHighlight ? qgcPal.buttonHighlight : qgcPal.button color: enabled ? (_showHighlight ? qgcPal.buttonHighlight : qgcPal.button) : qgcPalDisabled.button
} }
contentItem: QGCLabel { contentItem: QGCLabel {
text: control.text text: control.text
color: _showHighlight ? qgcPal.buttonHighlightText : qgcPal.buttonText color: enabled ? (_showHighlight ? qgcPal.buttonHighlightText : qgcPal.buttonText) : qgcPalDisabled.buttonText
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight elide: Text.ElideRight
......
...@@ -23,12 +23,7 @@ Rectangle { ...@@ -23,12 +23,7 @@ Rectangle {
radius: ScreenTools.defaultFontPixelWidth / 2 radius: ScreenTools.defaultFontPixelWidth / 2
property alias model: repeater.model property alias model: repeater.model
property var rotateImage ///< List of bool values, one for each button in strip - true: animation rotation, false: static image
property var animateImage ///< List of bool values, one for each button in strip - true: animate image, false: static image
property var buttonEnabled ///< List of bool values, one for each button in strip - true: button enabled, false: button disabled
property var buttonVisible ///< List of bool values, one for each button in strip - true: button visible, false: button invisible
property real maxHeight ///< Maximum height for control, determines whether text is hidden to make control shorter property real maxHeight ///< Maximum height for control, determines whether text is hidden to make control shorter
property var showAlternateIcon ///< List of bool values, one for each button in strip - true: show alternate icon, false: show normal icon
property AbstractButton lastClickedButton: null property AbstractButton lastClickedButton: null
...@@ -37,9 +32,17 @@ Rectangle { ...@@ -37,9 +32,17 @@ Rectangle {
signal clicked(int index, bool checked) signal clicked(int index, bool checked)
function setChecked(idx, check) {
repeater.itemAt(idx).checked = check
}
function getChecked(idx) {
return repeater.itemAt(idx).checked
}
ButtonGroup { ButtonGroup {
id: buttonGroup id: buttonGroup
exclusive: false buttons: toolStripColumn.children
} }
Column { Column {
...@@ -54,21 +57,20 @@ Rectangle { ...@@ -54,21 +57,20 @@ Rectangle {
id: repeater id: repeater
QGCHoverButton { QGCHoverButton {
id: buttonTemplate id: buttonTemplate
anchors.left: toolStripColumn.left anchors.left: toolStripColumn.left
anchors.right: toolStripColumn.right anchors.right: toolStripColumn.right
height: width height: width
radius: ScreenTools.defaultFontPixelWidth / 2 radius: ScreenTools.defaultFontPixelWidth / 2
fontPointSize: ScreenTools.smallFontPointSize fontPointSize: ScreenTools.smallFontPointSize
autoExclusive: true
enabled: _root.buttonEnabled ? _root.buttonEnabled[index] : true enabled: modelData.buttonEnabled
visible: _root.buttonVisible ? _root.buttonVisible[index] : true visible: modelData.buttonVisible
imageSource: (_root.showAlternateIcon && _root.showAlternateIcon[index]) ? _alternateIconSource : _iconSource imageSource: modelData.showAlternateIcon ? modelData.alternateIconSource : modelData.iconSource
text: modelData.name text: modelData.name
checked: modelData.checked !== undefined ? modelData.checked : checked
property var _iconSource: modelData.iconSource
property var _alternateIconSource: modelData.alternateIconSource
ButtonGroup.group: buttonGroup ButtonGroup.group: buttonGroup
// Only drop pannel and toggleable are checkable // Only drop pannel and toggleable are checkable
...@@ -76,23 +78,14 @@ Rectangle { ...@@ -76,23 +78,14 @@ Rectangle {
onClicked: { onClicked: {
dropPanel.hide() // DropPanel will call hide on "lastClickedButton" dropPanel.hide() // DropPanel will call hide on "lastClickedButton"
// Uncheck other checked buttons
// TODO: Implement ButtonGroup exclusive with checkable and uncheckable and get rid of this workaround
for(var i = 0; i < buttonGroup.buttons.length; i++) {
var b = buttonGroup.buttons[i]
if(b !== buttonTemplate) {
b.checked = false;
}
}
if (modelData.dropPanelComponent === undefined) { if (modelData.dropPanelComponent === undefined) {
_root.clicked(index, checked) _root.clicked(index, checked)
} else if (checked) { } else if (checked) {
var panelEdgeTopPoint = mapToItem(_root, width, 0) var panelEdgeTopPoint = mapToItem(_root, width, 0)
dropPanel.show(panelEdgeTopPoint, height, modelData.dropPanelComponent) dropPanel.show(panelEdgeTopPoint, height, modelData.dropPanelComponent)
} }
lastClickedButton = buttonTemplate if(_root && buttonTemplate)
_root.lastClickedButton = buttonTemplate
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment