Commit ffe6bfd4 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4363 from DonLakeFlyer/DropButtonParent

Fix DropButton parenting
parents 3f88517e d53bb78e
...@@ -77,7 +77,7 @@ FlightMap { ...@@ -77,7 +77,7 @@ FlightMap {
color: mapPal.text color: mapPal.text
visible: !ScreenTools.isShortScreen visible: !ScreenTools.isShortScreen
anchors.topMargin: _toolButtonTopMargin anchors.topMargin: _toolButtonTopMargin
anchors.horizontalCenter: toolColumn.horizontalCenter anchors.horizontalCenter: centerMapDropButton.horizontalCenter
anchors.top: parent.top anchors.top: parent.top
} }
...@@ -103,109 +103,116 @@ FlightMap { ...@@ -103,109 +103,116 @@ FlightMap {
} }
} }
Column { // IMPORTANT NOTE: Drop Buttons must be parented directly to the map. If they are placed in a Column for example the drop control positioning
id: toolColumn // will not work correctly.
anchors.topMargin: ScreenTools.isShortScreen ? _toolButtonTopMargin : ScreenTools.defaultFontPixelHeight / 2
anchors.leftMargin: ScreenTools.defaultFontPixelHeight //-- Map Center Control
anchors.left: parent.left CenterMapDropButton {
anchors.top: ScreenTools.isShortScreen ? parent.top : flyLabel.bottom id: centerMapDropButton
spacing: ScreenTools.defaultFontPixelHeight anchors.topMargin: flyLabel.visible ? ScreenTools.defaultFontPixelHeight / 2 : _toolButtonTopMargin
anchors.leftMargin: ScreenTools.defaultFontPixelHeight
anchors.left: parent.left
anchors.top: flyLabel.visible ? flyLabel.bottom : parent.top
z: QGroundControl.zOrderWidgets
exclusiveGroup: dropButtonsExclusiveGroup
map: _flightMap
mapFitViewport: Qt.rect(leftToolWidth, _toolButtonTopMargin, flightMap.width - leftToolWidth - rightPanelWidth, flightMap.height - _toolButtonTopMargin)
usePlannedHomePosition: false
geoFenceController: geoFenceController
missionController: missionController
rallyPointController: rallyPointController
showFollowVehicle: true
followVehicle: _followVehicle
onFollowVehicleChanged: _followVehicle = followVehicle
property real leftToolWidth: centerMapDropButton.x + centerMapDropButton.width
}
//-- Map Type Control
DropButton {
id: mapTypeButton
anchors.topMargin: ScreenTools.defaultFontPixelHeight
anchors.top: centerMapDropButton.bottom
anchors.left: centerMapDropButton.left
dropDirection: dropRight
buttonImage: "/qmlimages/MapType.svg"
viewportMargins: ScreenTools.defaultFontPixelWidth / 2
exclusiveGroup: dropButtonsExclusiveGroup
z: QGroundControl.zOrderWidgets z: QGroundControl.zOrderWidgets
lightBorders: isSatelliteMap
//-- Map Center Control dropDownComponent: Component {
CenterMapDropButton { Column {
id: centerMapDropButton spacing: ScreenTools.defaultFontPixelWidth
exclusiveGroup: dropButtonsExclusiveGroup
map: _flightMap
mapFitViewport: Qt.rect(leftToolWidth, _toolButtonTopMargin, flightMap.width - leftToolWidth - rightPanelWidth, flightMap.height - _toolButtonTopMargin)
usePlannedHomePosition: false
geoFenceController: geoFenceController
missionController: missionController
rallyPointController: rallyPointController
showFollowVehicle: true
followVehicle: _followVehicle
onFollowVehicleChanged: _followVehicle = followVehicle
property real leftToolWidth: centerMapDropButton.x + centerMapDropButton.width
}
//-- Map Type Control Row {
DropButton {
id: mapTypeButton
dropDirection: dropRight
buttonImage: "/qmlimages/MapType.svg"
viewportMargins: ScreenTools.defaultFontPixelWidth / 2
exclusiveGroup: dropButtonsExclusiveGroup
z: QGroundControl.zOrderWidgets
lightBorders: isSatelliteMap
dropDownComponent: Component {
Column {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
Row { Repeater {
spacing: ScreenTools.defaultFontPixelWidth model: QGroundControl.flightMapSettings.mapTypes
Repeater {
model: QGroundControl.flightMapSettings.mapTypes
QGCButton { QGCButton {
checkable: true checkable: true
checked: QGroundControl.flightMapSettings.mapType === text checked: QGroundControl.flightMapSettings.mapType === text
text: modelData text: modelData
width: clearButton.width width: clearButton.width
exclusiveGroup: mapTypeButtonsExclusiveGroup exclusiveGroup: mapTypeButtonsExclusiveGroup
onClicked: { onClicked: {
QGroundControl.flightMapSettings.mapType = text QGroundControl.flightMapSettings.mapType = text
checked = true checked = true
dropButtonsExclusiveGroup.current = null dropButtonsExclusiveGroup.current = null
}
} }
} }
} }
}
QGCButton { QGCButton {
id: clearButton id: clearButton
text: qsTr("Clear Flight Trails") text: qsTr("Clear Flight Trails")
enabled: QGroundControl.multiVehicleManager.activeVehicle enabled: QGroundControl.multiVehicleManager.activeVehicle
onClicked: { onClicked: {
QGroundControl.multiVehicleManager.activeVehicle.clearTrajectoryPoints() QGroundControl.multiVehicleManager.activeVehicle.clearTrajectoryPoints()
dropButtonsExclusiveGroup.current = null dropButtonsExclusiveGroup.current = null
}
} }
} }
} }
} }
}
//-- Zoom Map In //-- Zoom Map In
RoundButton { RoundButton {
id: mapZoomPlus id: mapZoomPlus
visible: !ScreenTools.isTinyScreen && _mainIsMap anchors.topMargin: ScreenTools.defaultFontPixelHeight
buttonImage: "/qmlimages/ZoomPlus.svg" anchors.top: mapTypeButton.bottom
exclusiveGroup: dropButtonsExclusiveGroup anchors.left: mapTypeButton.left
z: QGroundControl.zOrderWidgets visible: !ScreenTools.isTinyScreen && _mainIsMap
lightBorders: isSatelliteMap buttonImage: "/qmlimages/ZoomPlus.svg"
onClicked: { exclusiveGroup: dropButtonsExclusiveGroup
if(_flightMap) z: QGroundControl.zOrderWidgets
_flightMap.zoomLevel += 0.5 lightBorders: isSatelliteMap
checked = false onClicked: {
} if(_flightMap)
_flightMap.zoomLevel += 0.5
checked = false
} }
}
//-- Zoom Map Out //-- Zoom Map Out
RoundButton { RoundButton {
id: mapZoomMinus id: mapZoomMinus
visible: !ScreenTools.isTinyScreen && _mainIsMap anchors.topMargin: ScreenTools.defaultFontPixelHeight
buttonImage: "/qmlimages/ZoomMinus.svg" anchors.top: mapZoomPlus.bottom
exclusiveGroup: dropButtonsExclusiveGroup anchors.left: mapZoomPlus.left
z: QGroundControl.zOrderWidgets visible: !ScreenTools.isTinyScreen && _mainIsMap
lightBorders: isSatelliteMap buttonImage: "/qmlimages/ZoomMinus.svg"
onClicked: { exclusiveGroup: dropButtonsExclusiveGroup
if(_flightMap) z: QGroundControl.zOrderWidgets
_flightMap.zoomLevel -= 0.5 lightBorders: isSatelliteMap
checked = false onClicked: {
} if(_flightMap)
_flightMap.zoomLevel -= 0.5
checked = false
} }
} }
......
...@@ -768,136 +768,152 @@ QGCView { ...@@ -768,136 +768,152 @@ QGCView {
} }
QGCLabel { QGCLabel {
id: planLabel id: planLabel
text: qsTr("Plan") text: qsTr("Plan")
color: mapPal.text color: mapPal.text
visible: !ScreenTools.isShortScreen visible: !ScreenTools.isShortScreen
anchors.topMargin: _toolButtonTopMargin anchors.topMargin: _toolButtonTopMargin
anchors.horizontalCenter: toolColumn.horizontalCenter anchors.horizontalCenter: addMissionItemsButton.horizontalCenter
anchors.top: parent.top anchors.top: parent.top
} }
// IMPORTANT NOTE: Drop Buttons must be parented directly to the map. If they are placed in a Column for example the drop control positioning
// will not work correctly.
//-- Vertical Tool Buttons //-- Vertical Tool Buttons
Column {
id: toolColumn RoundButton {
anchors.topMargin: ScreenTools.isShortScreen ? _toolButtonTopMargin : ScreenTools.defaultFontPixelHeight / 2 id: addMissionItemsButton
anchors.topMargin: planLabel.visible ? ScreenTools.defaultFontPixelHeight / 2 : _toolButtonTopMargin
anchors.leftMargin: ScreenTools.defaultFontPixelHeight anchors.leftMargin: ScreenTools.defaultFontPixelHeight
anchors.left: parent.left anchors.left: parent.left
anchors.top: ScreenTools.isShortScreen ? parent.top : planLabel.bottom anchors.top: planLabel.visible ? planLabel.bottom : parent.top
spacing: ScreenTools.defaultFontPixelHeight buttonImage: "/qmlimages/MapAddMission.svg"
z: QGroundControl.zOrderWidgets lightBorders: _lightWidgetBorders
visible: _editingLayer == _layerMission
RoundButton { }
id: addMissionItemsButton
buttonImage: "/qmlimages/MapAddMission.svg"
lightBorders: _lightWidgetBorders
visible: _editingLayer == _layerMission
}
RoundButton { RoundButton {
id: addShapeButton id: addShapeButton
buttonImage: "/qmlimages/MapDrawShape.svg" anchors.topMargin: ScreenTools.defaultFontPixelHeight
lightBorders: _lightWidgetBorders anchors.top: addMissionItemsButton.bottom
visible: _editingLayer == _layerMission anchors.left: addMissionItemsButton.left
buttonImage: "/qmlimages/MapDrawShape.svg"
onClicked: { lightBorders: _lightWidgetBorders
var coordinate = editorMap.center visible: _editingLayer == _layerMission
coordinate.latitude = coordinate.latitude.toFixed(_decimalPlaces)
coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
coordinate.altitude = coordinate.altitude.toFixed(_decimalPlaces)
var sequenceNumber = missionController.insertComplexMissionItem(coordinate, missionController.visualItems.count)
setCurrentItem(sequenceNumber)
checked = false
addMissionItemsButton.checked = false
}
}
DropButton { onClicked: {
id: syncButton var coordinate = editorMap.center
dropDirection: dropRight coordinate.latitude = coordinate.latitude.toFixed(_decimalPlaces)
buttonImage: _syncDropDownController.dirty ? "/qmlimages/MapSyncChanged.svg" : "/qmlimages/MapSync.svg" coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
viewportMargins: ScreenTools.defaultFontPixelWidth / 2 coordinate.altitude = coordinate.altitude.toFixed(_decimalPlaces)
exclusiveGroup: _dropButtonsExclusiveGroup var sequenceNumber = missionController.insertComplexMissionItem(coordinate, missionController.visualItems.count)
dropDownComponent: syncDropDownComponent setCurrentItem(sequenceNumber)
enabled: !_syncDropDownController.syncInProgress checked = false
rotateImage: _syncDropDownController.syncInProgress addMissionItemsButton.checked = false
lightBorders: _lightWidgetBorders
} }
}
CenterMapDropButton { DropButton {
id: centerMapButton id: syncButton
exclusiveGroup: _dropButtonsExclusiveGroup anchors.topMargin: ScreenTools.defaultFontPixelHeight
map: editorMap anchors.top: addShapeButton.bottom
mapFitViewport: Qt.rect(leftToolWidth, toolbarHeight, editorMap.width - leftToolWidth - rightPanelWidth, editorMap.height - toolbarHeight) anchors.left: addShapeButton.left
usePlannedHomePosition: true dropDirection: dropRight
geoFenceController: geoFenceController buttonImage: _syncDropDownController.dirty ? "/qmlimages/MapSyncChanged.svg" : "/qmlimages/MapSync.svg"
missionController: missionController viewportMargins: ScreenTools.defaultFontPixelWidth / 2
rallyPointController: rallyPointController exclusiveGroup: _dropButtonsExclusiveGroup
dropDownComponent: syncDropDownComponent
property real toolbarHeight: qgcView.height - ScreenTools.availableHeight enabled: !_syncDropDownController.syncInProgress
property real rightPanelWidth: _rightPanelWidth rotateImage: _syncDropDownController.syncInProgress
property real leftToolWidth: centerMapButton.x + centerMapButton.width lightBorders: _lightWidgetBorders
} }
DropButton { CenterMapDropButton {
id: mapTypeButton id: centerMapButton
dropDirection: dropRight anchors.topMargin: ScreenTools.defaultFontPixelHeight
buttonImage: "/qmlimages/MapType.svg" anchors.top: syncButton.bottom
viewportMargins: ScreenTools.defaultFontPixelWidth / 2 anchors.left: syncButton.left
exclusiveGroup: _dropButtonsExclusiveGroup exclusiveGroup: _dropButtonsExclusiveGroup
lightBorders: _lightWidgetBorders map: editorMap
mapFitViewport: Qt.rect(leftToolWidth, toolbarHeight, editorMap.width - leftToolWidth - rightPanelWidth, editorMap.height - toolbarHeight)
dropDownComponent: Component { usePlannedHomePosition: true
Column { geoFenceController: geoFenceController
spacing: _margin missionController: missionController
QGCLabel { text: qsTr("Map type:") } rallyPointController: rallyPointController
Row {
spacing: ScreenTools.defaultFontPixelWidth property real toolbarHeight: qgcView.height - ScreenTools.availableHeight
Repeater { property real rightPanelWidth: _rightPanelWidth
model: QGroundControl.flightMapSettings.mapTypes property real leftToolWidth: centerMapButton.x + centerMapButton.width
}
QGCButton {
checkable: true DropButton {
checked: QGroundControl.flightMapSettings.mapType === text id: mapTypeButton
text: modelData anchors.topMargin: ScreenTools.defaultFontPixelHeight
exclusiveGroup: _mapTypeButtonsExclusiveGroup anchors.top: centerMapButton.bottom
onClicked: { anchors.left: centerMapButton.left
QGroundControl.flightMapSettings.mapType = text dropDirection: dropRight
checked = true buttonImage: "/qmlimages/MapType.svg"
mapTypeButton.hideDropDown() viewportMargins: ScreenTools.defaultFontPixelWidth / 2
} exclusiveGroup: _dropButtonsExclusiveGroup
lightBorders: _lightWidgetBorders
dropDownComponent: Component {
Column {
spacing: _margin
QGCLabel { text: qsTr("Map type:") }
Row {
spacing: ScreenTools.defaultFontPixelWidth
Repeater {
model: QGroundControl.flightMapSettings.mapTypes
QGCButton {
checkable: true
checked: QGroundControl.flightMapSettings.mapType === text
text: modelData
exclusiveGroup: _mapTypeButtonsExclusiveGroup
onClicked: {
QGroundControl.flightMapSettings.mapType = text
checked = true
mapTypeButton.hideDropDown()
} }
} }
} }
} }
} }
} }
}
//-- Zoom Map In //-- Zoom Map In
RoundButton { RoundButton {
id: mapZoomPlus id: mapZoomPlus
visible: !ScreenTools.isTinyScreen && !ScreenTools.isShortScreen anchors.topMargin: ScreenTools.defaultFontPixelHeight
buttonImage: "/qmlimages/ZoomPlus.svg" anchors.top: mapTypeButton.bottom
lightBorders: _lightWidgetBorders anchors.left: mapTypeButton.left
visible: !ScreenTools.isTinyScreen && !ScreenTools.isShortScreen
onClicked: { buttonImage: "/qmlimages/ZoomPlus.svg"
if(editorMap) lightBorders: _lightWidgetBorders
editorMap.zoomLevel += 0.5
checked = false onClicked: {
} if(editorMap)
editorMap.zoomLevel += 0.5
checked = false
} }
}
//-- Zoom Map Out //-- Zoom Map Out
RoundButton { RoundButton {
id: mapZoomMinus id: mapZoomMinus
visible: !ScreenTools.isTinyScreen && !ScreenTools.isShortScreen anchors.topMargin: ScreenTools.defaultFontPixelHeight
buttonImage: "/qmlimages/ZoomMinus.svg" anchors.top: mapZoomPlus.bottom
lightBorders: _lightWidgetBorders anchors.left: mapZoomPlus.left
onClicked: { visible: !ScreenTools.isTinyScreen && !ScreenTools.isShortScreen
if(editorMap) buttonImage: "/qmlimages/ZoomMinus.svg"
editorMap.zoomLevel -= 0.5 lightBorders: _lightWidgetBorders
checked = false onClicked: {
} if(editorMap)
editorMap.zoomLevel -= 0.5
checked = false
} }
} }
......
...@@ -15,6 +15,7 @@ Item { ...@@ -15,6 +15,7 @@ Item {
property int dropDirection: dropDown property int dropDirection: dropDown
property alias dropDownComponent: dropDownLoader.sourceComponent property alias dropDownComponent: dropDownLoader.sourceComponent
property real viewportMargins: 0 property real viewportMargins: 0
property real topMargin: parent.height - ScreenTools.availableHeight
property alias lightBorders: roundButton.lightBorders property alias lightBorders: roundButton.lightBorders
width: radius * 2 width: radius * 2
...@@ -35,7 +36,7 @@ Item { ...@@ -35,7 +36,7 @@ Item {
property real _viewportMaxLeft: -x + viewportMargins property real _viewportMaxLeft: -x + viewportMargins
property real _viewportMaxRight: parent.width - (viewportMargins * 2) - x property real _viewportMaxRight: parent.width - (viewportMargins * 2) - x
property real _viewportMaxTop: -y + viewportMargins property real _viewportMaxTop: -y + viewportMargins + topMargin
property real _viewportMaxBottom: parent.height - (viewportMargins * 2) - y property real _viewportMaxBottom: parent.height - (viewportMargins * 2) - y
// Set up ExclusiveGroup support. We use the checked property to drive visibility of drop down. // Set up ExclusiveGroup support. We use the checked property to drive visibility of drop down.
...@@ -53,8 +54,6 @@ Item { ...@@ -53,8 +54,6 @@ Item {
checked = false checked = false
} }
Component.onCompleted: _calcPositions()
function _calcPositions() { function _calcPositions() {
var dropComponentWidth = dropDownLoader.item.width var dropComponentWidth = dropDownLoader.item.width
var dropComponentHeight = dropDownLoader.item.height var dropComponentHeight = dropDownLoader.item.height
...@@ -161,6 +160,7 @@ Item { ...@@ -161,6 +160,7 @@ Item {
id: roundButton id: roundButton
radius: parent.width / 2 radius: parent.width / 2
onClicked: { onClicked: {
_calcPositions()
_root.clicked() _root.clicked()
} }
} }
...@@ -216,20 +216,11 @@ Item { ...@@ -216,20 +216,11 @@ Item {
Item { Item {
id: dropItemHolderRect id: dropItemHolderRect
//color: qgcPal.button
//radius: _dropCornerRadius
Loader { Loader {
id: dropDownLoader id: dropDownLoader
x: _dropMargin x: _dropMargin
y: _dropMargin y: _dropMargin
Connections {
target: dropDownLoader.item
onWidthChanged: _calcPositions()
onHeightChanged: _calcPositions()
}
} }
} }
} // Item - dropDownItem } // Item - dropDownItem
......
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