Skip to content

Commit d62f85f

Browse files
committed
Fix tooltips on Windows
1 parent 20b4a33 commit d62f85f

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Source/Components/CheckedTooltip.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ class CheckedTooltip : public TooltipWindow {
1818
Component* target, std::function<bool(Component*)> checkTooltip = [](Component*) { return true; }, int timeout = 500)
1919
: TooltipWindow(target, timeout)
2020
, checker(std::move(checkTooltip))
21+
, tooltipShadow(DropShadow(Colour(0, 0, 0).withAlpha(0.2f), 5, { 0, 0 }), Corners::defaultCornerRadius)
2122
{
2223
setOpaque(false);
24+
#if JUCE_WINDOWS
25+
tooltipShadow.setOwner(this);
26+
#endif
2327
}
2428

2529
float getDesktopScaleFactor() const override
@@ -38,4 +42,5 @@ class CheckedTooltip : public TooltipWindow {
3842
}
3943

4044
std::function<bool(Component*)> checker;
45+
StackDropShadower tooltipShadow;
4146
};

Source/LookAndFeel.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,12 @@ void PlugDataLook::drawCornerResizer(Graphics& g, int w, int h, bool isMouseOver
735735

736736
void PlugDataLook::drawTooltip(Graphics& g, String const& text, int width, int height)
737737
{
738-
auto bounds = Rectangle<float>(0, 0, width, height).reduced(ProjectInfo::canUseSemiTransparentWindows() ? 6 : 0);
738+
#if JUCE_WINDOWS
739+
auto expandTooltip = false;
740+
#else
741+
auto expandTooltip = ProjectInfo::canUseSemiTransparentWindows();
742+
#endif
743+
auto bounds = Rectangle<float>(0, 0, width, height).reduced(expandTooltip ? 6 : 0);
739744
auto shadowBounds = bounds.reduced(2);
740745
auto const cornerSize = ProjectInfo::canUseSemiTransparentWindows() ? Corners::defaultCornerRadius : 0;
741746

@@ -769,7 +774,7 @@ void PlugDataLook::drawTooltip(Graphics& g, String const& text, int width, int h
769774
}
770775
}
771776

772-
auto textOffset = ProjectInfo::canUseSemiTransparentWindows() ? 10 : 0;
777+
auto textOffset = expandTooltip ? 10 : 0;
773778
TextLayout tl;
774779
tl.createLayoutWithBalancedLineLengths(s, (float)maxToolTipWidth);
775780
tl.draw(g, bounds.withSizeKeepingCentre(width - (20 + textOffset), height - (2 + textOffset)));
@@ -851,6 +856,12 @@ void PlugDataLook::drawPropertyPanelSectionHeader(Graphics& g, String const& nam
851856

852857
Rectangle<int> PlugDataLook::getTooltipBounds(String const& tipText, Point<int> screenPos, Rectangle<int> parentArea)
853858
{
859+
#if JUCE_WINDOWS
860+
auto expandTooltip = false;
861+
#else
862+
auto expandTooltip = ProjectInfo::canUseSemiTransparentWindows();
863+
#endif
864+
854865
float const tooltipFontSize = 14.0f;
855866
int const maxToolTipWidth = 1000;
856867

@@ -882,7 +893,7 @@ Rectangle<int> PlugDataLook::getTooltipBounds(String const& tipText, Point<int>
882893

883894
return Rectangle<int>(screenPos.x > parentArea.getCentreX() ? screenPos.x - (w + 12) : screenPos.x + 24,
884895
screenPos.y > parentArea.getCentreY() ? screenPos.y - (h + 6) : screenPos.y + 6,
885-
w, h).expanded(ProjectInfo::canUseSemiTransparentWindows() ? 6 : 0)
896+
w, h).expanded(expandTooltip ? 6 : 0)
886897
.constrainedWithin(parentArea);
887898
}
888899

0 commit comments

Comments
 (0)