|
From: <cn...@us...> - 2024-08-16 02:23:31
|
Revision: 1508
http://sourceforge.net/p/seq/svn/1508
Author: cn187
Date: 2024-08-16 02:23:28 +0000 (Fri, 16 Aug 2024)
Log Message:
-----------
Don't cut off map location labels if at right edge of map
Modified Paths:
--------------
showeq/branches/cn187_devel/src/mapcore.cpp
Modified: showeq/branches/cn187_devel/src/mapcore.cpp
===================================================================
--- showeq/branches/cn187_devel/src/mapcore.cpp 2024-08-16 02:23:21 UTC (rev 1507)
+++ showeq/branches/cn187_devel/src/mapcore.cpp 2024-08-16 02:23:28 UTC (rev 1508)
@@ -2313,6 +2313,7 @@
// set the font
p.setFont(param.font());
+ QFontMetrics fm(param.font());
for (int i = 0; i < m_mapLayers.count(); ++i)
{
@@ -2341,8 +2342,17 @@
p.setPen(color);
// draw the text
- p.drawText(param.calcXOffsetI(currentLoc->x()) - 2,
- param.calcYOffsetI(currentLoc->y()) - 2,
+ int offset_x = -2;
+ int offset_y = -2;
+ int ha = fm.horizontalAdvance(currentLoc->name());
+ // if the location label is going to run off the side of the map (and
+ // thus be cut off), scoot the label to the left enough to show the
+ // whole thing
+ if (param.calcXOffsetI(currentLoc->x()) + ha > param.calcXOffsetI(m_minX))
+ offset_x -= ha - (param.calcXOffsetI(m_minX) - param.calcXOffsetI(currentLoc->x()));
+
+ p.drawText(param.calcXOffsetI(currentLoc->x()) + offset_x,
+ param.calcYOffsetI(currentLoc->y()) + offset_y,
currentLoc->name());
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|