| 429 | } |
| 430 | |
| 431 | void DrawTextTool::drawImpl(QPainter* painter, MapWidget* widget) |
| 432 | { |
| 433 | painter->save(); |
| 434 | |
| 435 | if (!preview_text->hasSingleAnchor()) |
| 436 | { |
| 437 | painter->setPen(active_color); |
| 438 | painter->setBrush(Qt::NoBrush); |
| 439 | |
| 440 | // Default is what is fast (and stable!) while dragging. |
| 441 | auto map_rect = QRectF { click_pos_map, constrained_pos_map }; |
| 442 | if (!isDragging()) |
| 443 | { |
| 444 | // This is the actual frame, but it would be shaky while dragging, |
| 445 | // because of discretization in non-antialiased drawing. |
| 446 | const auto center = preview_text->getAnchorCoordF(); |
| 447 | const auto width = preview_text->getBoxWidth(); |
| 448 | const auto height = preview_text->getBoxHeight(); |
| 449 | map_rect = QRectF { center.x()-width/2, center.y()-height/2, width, height }; |
| 450 | } |
| 451 | auto rect = widget->mapToViewport(map_rect); |
| 452 | |
| 453 | painter->drawRect(rect); |
| 454 | rect.adjust(1, 1, -1, -1); |
| 455 | painter->setPen(qRgb(255, 255, 255)); |
| 456 | painter->drawRect(rect); |
| 457 | } |
| 458 | |
| 459 | widget->applyMapTransform(painter); |
| 460 | |
| 461 | float opacity = text_editor ? 1.0f : 0.5f; |
| 462 | RenderConfig config = { *map(), widget->getMapView()->calculateViewedRect(widget->viewportToView(widget->rect())), widget->getMapView()->calculateFinalZoomFactor(), RenderConfig::Tool, opacity }; |
| 463 | renderables.draw(painter, config); |
| 464 | |
| 465 | if (text_editor) |
| 466 | text_editor->draw(painter, widget); |
| 467 | |
| 468 | painter->restore(); |
| 469 | } |
| 470 | |
| 471 | void DrawTextTool::updateStatusText() |
| 472 | { |
nothing calls this directly
no test coverage detected