[Marble-commits] branches/KDE/4.6/kdeedu/marble/src/lib
Dennis Nienhüser
earthwings at gentoo.org
Sat Feb 19 22:51:34 CET 2011
SVN commit 1221647 by nienhueser:
Extend drawAnnotation() to calculate and use the optimal text height when an invalid height is passed. Use it for painting driving instructions in the map. Fixes long instructions being cut off. Reduce the rounded corner radius for a better text/bubble ratio.
BUG: 265926
REVIEW: 6525
Backport of commit 1221644.
M +6 -0 GeoPainter.cpp
M +2 -0 GeoPainter.h
M +2 -2 routing/RoutingLayer.cpp
--- branches/KDE/4.6/kdeedu/marble/src/lib/GeoPainter.cpp #1221646:1221647
@@ -219,6 +219,12 @@
bool globeHidesPoint;
AbstractProjection *projection = d->m_viewport->currentProjection();
+ if ( bubbleSize.height() <= 0 ) {
+ QRectF rect = QRectF( QPointF( 0.0, 0.0 ), bubbleSize - QSizeF( 2 * xRnd, 0.0 ) );
+ qreal idealTextHeight = boundingRect( rect, Qt::TextWordWrap, text ).height();
+ bubbleSize.setHeight( 2 * yRnd + idealTextHeight );
+ }
+
bool visible = projection->screenCoordinates( position, d->m_viewport, d->m_x, y, pointRepeatNum, globeHidesPoint );
if ( visible ) {
--- branches/KDE/4.6/kdeedu/marble/src/lib/GeoPainter.h #1221646:1221647
@@ -156,6 +156,8 @@
\param position The geodesic position
\param text The text contained by the bubble
\param bubbleSize The size of the bubble that holds the annotation text.
+ A height of 0 can be used to have the height calculated
+ automatically to fit the needed text height.
\param bubbleOffsetX The x-axis offset between the annotated position and
the "root" of the speech bubble's "arrow".
\param bubbleOffsetY The y-axis offset between the annotated position and
--- branches/KDE/4.6/kdeedu/marble/src/lib/routing/RoutingLayer.cpp #1221646:1221647
@@ -321,7 +321,7 @@
if ( m_selectionModel->selection().contains( proxyIndex ) ) {
painter->setPen( QColor( Qt::black ) );
painter->setBrush( QBrush( oxygenSunYellow6 ) );
- painter->drawAnnotation( pos, index.data().toString(), QSize( 120, 60 ), 10, 30, 15, 15 );
+ painter->drawAnnotation( pos, index.data().toString(), QSize( 120, 0 ), 10, 30, 5, 5 );
GeoDataLineString currentRoutePoints = qVariantValue<GeoDataLineString>( index.data( RoutingModel::InstructionWayPointRole ) );
@@ -346,7 +346,7 @@
} else if ( !m_routeDirty && type == RoutingModel::Error ) {
painter->setPen( QColor( Qt::white ) );
painter->setBrush( QBrush( alphaAdjusted( oxygenBrickRed4, 200 ) ) );
- painter->drawAnnotation( pos, index.data().toString(), QSize( 180, 80 ), 10, 30, 15, 15 );
+ painter->drawAnnotation( pos, index.data().toString(), QSize( 180, 0 ), 10, 30, 5, 5 );
}
if( !m_routingModel->deviatedFromRoute() ) {
More information about the Marble-commits
mailing list