Skip to content

Commit

Permalink
tip.cpp: Default to placing tooltips *above* the widget
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Feb 25, 2024
1 parent 4f9f0b1 commit 5cdf6e0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/widget/tip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ static void refreshTip(std::shared_ptr<WIDGET> mouseOverWidget)
height += displayCache.wzTip.back().belowBase();
}
auto x = clip<SDWORD>(mouseOverWidget->screenPosX() + mouseOverWidget->width() / 2, 0, screenWidth - width - 1);
auto y = std::max(mouseOverWidget->screenPosY() + mouseOverWidget->height() + TIP_VGAP, 0);
if (y + height >= (int)screenHeight)
auto y = std::min(mouseOverWidget->screenPosY() - height - TIP_VGAP, (int)screenHeight);
if (y < 0)
{
/* Position the tip above the button */
y = mouseOverWidget->screenPosY() - height - TIP_VGAP;
/* Position the tip below the button */
y = std::max(mouseOverWidget->screenPosY() + mouseOverWidget->height() + TIP_VGAP, 0);
}
tipRect = WzRect(x - 1, y - 1, width + 2, height + 2);

Expand Down

0 comments on commit 5cdf6e0

Please sign in to comment.