From f2a8bab01e57ac28c01e71e4ee6affceacce96c1 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Tue, 25 Jul 2017 23:43:18 +0300 Subject: mapwidget.qml: include map location text The MapItemView delegate now includes a white Text element. It uses the MapLocation "name" property as text. This text is only visible if the map zoom is above "textVisibleZoom". For hundreds of dives, using the DropShadow effect for the text makes it laggy. Instead, using a fake drop shadow (duplicate black Text under the default text) makes it much better. Signed-off-by: Lubomir I. Ivanov --- mobile-widgets/qml/MapWidget.qml | 51 +++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'mobile-widgets/qml') diff --git a/mobile-widgets/qml/MapWidget.qml b/mobile-widgets/qml/MapWidget.qml index 4794533be..128423285 100644 --- a/mobile-widgets/qml/MapWidget.qml +++ b/mobile-widgets/qml/MapWidget.qml @@ -31,6 +31,7 @@ Item { readonly property var defaultCenter: QtPositioning.coordinate(0, 0) readonly property real defaultZoomIn: 17.0 readonly property real defaultZoomOut: 1.0 + readonly property real textVisibleZoom: 8.0 readonly property real zoomStep: 2.0 property var newCenter: defaultCenter property real newZoom: 1.0 @@ -50,25 +51,43 @@ Item { anchorPoint.y: mapItemImage.height coordinate: model.coordinate z: mapHelper.model.selectedUuid === model.uuid ? mapHelper.model.count - 1 : 0 - sourceItem: Image { - id: mapItemImage - source: "qrc:///mapwidget-marker" + (mapHelper.model.selectedUuid === model.uuid ? "-selected" : "") - - SequentialAnimation { - id: mapItemImageAnimation - PropertyAnimation { - target: mapItemImage; property: "scale"; from: 1.0; to: 0.7; duration: 120 + sourceItem: Item { + Image { + id: mapItemImage + source: "qrc:///mapwidget-marker" + (mapHelper.model.selectedUuid === model.uuid ? "-selected" : "") + SequentialAnimation { + id: mapItemImageAnimation + PropertyAnimation { + target: mapItemImage; property: "scale"; from: 1.0; to: 0.7; duration: 120 + } + PropertyAnimation { + target: mapItemImage; property: "scale"; from: 0.7; to: 1.0; duration: 80 + } } - PropertyAnimation { - target: mapItemImage; property: "scale"; from: 0.7; to: 1.0; duration: 80 + MouseArea { + anchors.fill: parent + onClicked: mapHelper.model.setSelectedUuid(model.uuid, true) + onDoubleClicked: map.doubleClickHandler(model.coordinate) + } + } + Item { + // Text with a duplicate for shadow. DropShadow as layer effect is kind of slow here. + y: mapItemImage.y + mapItemImage.height + visible: map.zoomLevel > map.textVisibleZoom + Text { + id: mapItemTextShadow + x: mapItemText.x + 2; y: mapItemText.y + 2 + text: mapItemText.text + font.pointSize: mapItemText.font.pointSize + color: "black" + } + Text { + id: mapItemText + text: model.name + font.pointSize: 11.0 + color: "white" } } - } - - MouseArea { - anchors.fill: parent - onClicked: mapHelper.model.setSelectedUuid(model.uuid, true) - onDoubleClicked: map.doubleClickHandler(model.coordinate) } } } -- cgit v1.2.3-70-g09d2