[gnome-maps/wip/mlundblad/more-bubble-position-fixes] mapMarker: Improve marker reposion when not fitting below
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/more-bubble-position-fixes] mapMarker: Improve marker reposion when not fitting below
- Date: Wed, 10 Mar 2021 18:31:32 +0000 (UTC)
commit 82a4ec15274ab81e42f8031f6f6ff716e582f33d
Author: Marcus Lundblad <ml update uu se>
Date: Tue Mar 9 22:23:52 2021 +0100
mapMarker: Improve marker reposion when not fitting below
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.
src/mapMarker.js | 18 ++++++++++++++----
1 file 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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]