Tooltip improvements
This commit is contained in:
parent
37f3178d33
commit
c68ebd2e0e
@ -184,7 +184,7 @@ bool PaneManager::sendInputEvent(InputEvent const& event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.is<MouseButtonDownEvent>() || vmag(m_tooltipInitialPosition - m_tooltipLastMousePos) > m_tooltipMouseoverRadius) {
|
if (event.is<MouseButtonDownEvent>()) {
|
||||||
m_tooltipShowTimer = m_tooltipMouseoverTime;
|
m_tooltipShowTimer = m_tooltipMouseoverTime;
|
||||||
if (m_activeTooltip) {
|
if (m_activeTooltip) {
|
||||||
dismiss(m_activeTooltip);
|
dismiss(m_activeTooltip);
|
||||||
@ -271,14 +271,33 @@ void PaneManager::render() {
|
|||||||
|
|
||||||
void PaneManager::update(float dt) {
|
void PaneManager::update(float dt) {
|
||||||
m_tooltipShowTimer -= GlobalTimestep;
|
m_tooltipShowTimer -= GlobalTimestep;
|
||||||
if (m_tooltipShowTimer < 0 && !m_activeTooltip) {
|
if (m_tooltipParentPane.expired())
|
||||||
|
m_tooltipParentPane.reset();
|
||||||
|
|
||||||
|
bool removeTooltip = vmag(m_tooltipInitialPosition - m_tooltipLastMousePos) > m_tooltipMouseoverRadius
|
||||||
|
|| m_tooltipParentPane.expired() || m_tooltipParentPane.lock()->inWindow(m_tooltipLastMousePos);
|
||||||
|
|
||||||
|
if (removeTooltip) {
|
||||||
|
dismiss(m_activeTooltip);
|
||||||
|
m_activeTooltip.reset();
|
||||||
|
m_tooltipParentPane.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan for a new tooltip if we just removed the old one, or the show timer has expired
|
||||||
|
if (removeTooltip || (m_tooltipShowTimer < 0 && !m_activeTooltip)) {
|
||||||
if (auto parentPane = getPaneAt(m_tooltipLastMousePos)) {
|
if (auto parentPane = getPaneAt(m_tooltipLastMousePos)) {
|
||||||
if (auto tooltip = parentPane->createTooltip(m_tooltipLastMousePos)) {
|
if (auto tooltip = parentPane->createTooltip(m_tooltipLastMousePos)) {
|
||||||
m_activeTooltip = std::move(tooltip);
|
m_activeTooltip = std::move(tooltip);
|
||||||
m_tooltipParentPane = std::move(parentPane);
|
m_tooltipParentPane = std::move(parentPane);
|
||||||
m_tooltipInitialPosition = m_tooltipLastMousePos;
|
m_tooltipInitialPosition = m_tooltipLastMousePos;
|
||||||
displayPane(PaneLayer::Tooltip, m_activeTooltip);
|
displayPane(PaneLayer::Tooltip, m_activeTooltip);
|
||||||
|
} else {
|
||||||
|
m_tooltipShowTimer = m_tooltipMouseoverTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_activeTooltip) {
|
||||||
Vec2I offsetDirection = Vec2I::filled(1);
|
Vec2I offsetDirection = Vec2I::filled(1);
|
||||||
Vec2I offsetAdjust = Vec2I();
|
Vec2I offsetAdjust = Vec2I();
|
||||||
|
|
||||||
@ -293,14 +312,6 @@ void PaneManager::update(float dt) {
|
|||||||
offsetAdjust[1] = -m_activeTooltip->size()[1];
|
offsetAdjust[1] = -m_activeTooltip->size()[1];
|
||||||
|
|
||||||
m_activeTooltip->setPosition(m_tooltipLastMousePos + (offsetAdjust + m_tooltipMouseOffset.piecewiseMultiply(offsetDirection)));
|
m_activeTooltip->setPosition(m_tooltipLastMousePos + (offsetAdjust + m_tooltipMouseOffset.piecewiseMultiply(offsetDirection)));
|
||||||
} else {
|
|
||||||
m_tooltipShowTimer = m_tooltipMouseoverTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (m_activeTooltip && !m_tooltipParentPane->isDisplayed()) {
|
|
||||||
dismiss(m_activeTooltip);
|
|
||||||
m_activeTooltip.reset();
|
|
||||||
m_tooltipParentPane.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& layerPair : m_displayedPanes) {
|
for (auto const& layerPair : m_displayedPanes) {
|
||||||
|
@ -100,7 +100,7 @@ private:
|
|||||||
Vec2I m_tooltipLastMousePos;
|
Vec2I m_tooltipLastMousePos;
|
||||||
Vec2I m_tooltipInitialPosition;
|
Vec2I m_tooltipInitialPosition;
|
||||||
PanePtr m_activeTooltip;
|
PanePtr m_activeTooltip;
|
||||||
PanePtr m_tooltipParentPane;
|
PaneWeakPtr m_tooltipParentPane;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user