summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Lundblad <ml@update.uu.se>2021-03-09 22:23:52 +0100
committerMarcus Lundblad <ml@update.uu.se>2021-03-10 19:31:55 +0100
commit6ca991733fac1103437385270f2eb4494a387dfb (patch)
treec8919b1bf607dda421a2b5178d527cb182a9d945
parent7d0319bc3962f2dce27acaa1d0f86921ae060980 (diff)
downloadgnome-maps-wip/mlundblad/more-bubble-position-fixes.tar.gz
mapMarker: Improve marker reposion when not fitting belowwip/mlundblad/more-bubble-position-fixes
Improve the bubble repositioning code to only use below the marker position when there's enough room, otherwise revert to left or right depeding on the closest edge horizontally.
-rw-r--r--src/mapMarker.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/mapMarker.js b/src/mapMarker.js
index 7fb45201..eb2747ab 100644
--- a/src/mapMarker.js
+++ b/src/mapMarker.js
@@ -240,13 +240,23 @@ var MapMarker = GObject.registerClass({
let bubbleSize = bubble.get_preferred_size()[1];
// Set bubble position left/right if it's close to a vertical map edge
- if (pos.x + pos.width / 2 + bubbleSize.width / 2 >= mapSize.width)
+ if (pos.x + pos.width / 2 + bubbleSize.width / 2 >= mapSize.width) {
bubble.position = Gtk.PositionType.LEFT;
- else if (pos.x + pos.width / 2 - bubbleSize.width / 2 <= 0)
+ } else if (pos.x + pos.width / 2 - bubbleSize.width / 2 <= 0) {
bubble.position = Gtk.PositionType.RIGHT;
// Avoid bubble to cover header bar if the marker is close to the top map edge
- else if (pos.y - bubbleSize.height <= 0)
- bubble.position = Gtk.PositionType.BOTTOM;
+ } else if (pos.y - bubbleSize.height <= 0) {
+ /* position bubble below marker if there's enough room,
+ * otherwise choose left or right pointing away from the edge
+ * closest to the marker
+ */
+ if (mapSize.height - pos.y >= bubbleSize.height)
+ bubble.position = Gtk.PositionType.BOTTOM;
+ else if (x >= mapSize.width / 2)
+ bubble.position = Gtk.PositionType.LEFT;
+ else
+ bubble.position = Gtk.PositionType.RIGHT;
+ }
}
_hideBubbleOn(signal, duration) {