| 292 | } |
| 293 | |
| 294 | void PaneManager::update(float dt) { |
| 295 | auto newTooltipParentPane = getPaneAt(m_tooltipLastMousePos); |
| 296 | |
| 297 | bool updateTooltip = m_tooltipShowTimer.tick(dt) || (m_activeTooltip && ( |
| 298 | vmag(m_tooltipInitialPosition - m_tooltipLastMousePos) > m_tooltipMouseoverRadius |
| 299 | || m_tooltipParentPane != newTooltipParentPane |
| 300 | || !m_tooltipParentPane->inWindow(m_tooltipLastMousePos))); |
| 301 | |
| 302 | if (updateTooltip) { |
| 303 | if (m_activeTooltip) { |
| 304 | dismiss(m_activeTooltip); |
| 305 | m_activeTooltip.reset(); |
| 306 | m_tooltipParentPane.reset(); |
| 307 | } |
| 308 | |
| 309 | m_tooltipShowTimer.reset(); |
| 310 | if (newTooltipParentPane) { |
| 311 | if (auto tooltip = newTooltipParentPane->createTooltip(m_tooltipLastMousePos)) { |
| 312 | m_activeTooltip = std::move(tooltip); |
| 313 | m_tooltipParentPane = std::move(newTooltipParentPane); |
| 314 | m_tooltipInitialPosition = m_tooltipLastMousePos; |
| 315 | displayPane(PaneLayer::Tooltip, m_activeTooltip); |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | if (m_activeTooltip) { |
| 321 | Vec2I offsetDirection = Vec2I::filled(1); |
| 322 | Vec2I offsetAdjust = Vec2I(); |
| 323 | |
| 324 | if (m_tooltipLastMousePos[0] + m_tooltipMouseOffset[0] + m_activeTooltip->size()[0] > (int)m_context->windowWidth() / m_context->interfaceScale()) { |
| 325 | offsetDirection[0] = -1; |
| 326 | offsetAdjust[0] = -m_activeTooltip->size()[0]; |
| 327 | } |
| 328 | |
| 329 | if (m_tooltipLastMousePos[1] + m_tooltipMouseOffset[1] - m_activeTooltip->size()[1] < 0) |
| 330 | offsetDirection[1] = -1; |
| 331 | else |
| 332 | offsetAdjust[1] = -m_activeTooltip->size()[1]; |
| 333 | |
| 334 | m_activeTooltip->setPosition(m_tooltipLastMousePos + (offsetAdjust + m_tooltipMouseOffset.piecewiseMultiply(offsetDirection))); |
| 335 | } |
| 336 | |
| 337 | for (auto const& layerPair : m_displayedPanes) { |
| 338 | for (auto const& panePair : copy(layerPair.second)) { |
| 339 | if (panePair.first->isDismissed()) |
| 340 | dismiss(panePair.first); |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | for (auto const& layerPair : reverseIterate(m_displayedPanes)) { |
| 345 | for (auto const& panePair : reverseIterate(layerPair.second)) { |
| 346 | panePair.first->tick(dt); |
| 347 | if (panePair.first->active()) |
| 348 | panePair.first->update(dt); |
| 349 | } |
| 350 | } |
| 351 | } |
nothing calls this directly
no test coverage detected