Skip to content

Commit 2fab3ba

Browse files
committed
Fixing tooltip bug on Linux
1 parent 99deca0 commit 2fab3ba

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Source/Components/CheckedTooltip.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ 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)
2221
{
2322
setOpaque(false);
24-
tooltipShadow.setOwner(this);
2523
}
2624

2725
float getDesktopScaleFactor() const override
@@ -40,5 +38,4 @@ class CheckedTooltip : public TooltipWindow {
4038
}
4139

4240
std::function<bool(Component*)> checker;
43-
StackDropShadower tooltipShadow;
4441
};

Source/LookAndFeel.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -735,9 +735,14 @@ 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);
739-
auto cornerSize = Corners::defaultCornerRadius;
740-
738+
auto bounds = Rectangle<float>(0, 0, width, height).reduced(ProjectInfo::canUseSemiTransparentWindows() ? 6 : 0);
739+
auto shadowBounds = bounds.reduced(2);
740+
auto const cornerSize = ProjectInfo::canUseSemiTransparentWindows() ? Corners::defaultCornerRadius : 0;
741+
742+
Path shadowPath;
743+
shadowPath.addRoundedRectangle(shadowBounds.getX(), shadowBounds.getY(), shadowBounds.getWidth(), shadowBounds.getHeight(), cornerSize);
744+
StackShadow::renderDropShadow(g, shadowPath, Colours::black.withAlpha(0.44f), 8, {0, 0}, 0);
745+
741746
g.setColour(findColour(PlugDataColour::popupMenuBackgroundColourId));
742747
g.fillRoundedRectangle(bounds.toFloat(), cornerSize);
743748

@@ -766,7 +771,7 @@ void PlugDataLook::drawTooltip(Graphics& g, String const& text, int width, int h
766771

767772
TextLayout tl;
768773
tl.createLayoutWithBalancedLineLengths(s, (float)maxToolTipWidth);
769-
tl.draw(g, bounds.withSizeKeepingCentre(width - 20, height - 2));
774+
tl.draw(g, bounds.withSizeKeepingCentre(width - 28, height - 14));
770775
}
771776

772777
Font PlugDataLook::getComboBoxFont(ComboBox& box)
@@ -868,15 +873,15 @@ Rectangle<int> PlugDataLook::getTooltipBounds(String const& tipText, Point<int>
868873
TextLayout tl;
869874
tl.createLayoutWithBalancedLineLengths(s, (float)maxToolTipWidth);
870875

871-
int marginX = 22.0f;
876+
int marginX = 17.0f;
872877
int marginY = 10.0f;
873878

874879
auto w = (int)(tl.getWidth() + marginX);
875880
auto h = (int)(tl.getHeight() + marginY);
876881

877882
return Rectangle<int>(screenPos.x > parentArea.getCentreX() ? screenPos.x - (w + 12) : screenPos.x + 24,
878883
screenPos.y > parentArea.getCentreY() ? screenPos.y - (h + 6) : screenPos.y + 6,
879-
w, h)
884+
w, h).expanded(ProjectInfo::canUseSemiTransparentWindows() ? 6 : 0)
880885
.constrainedWithin(parentArea);
881886
}
882887

0 commit comments

Comments
 (0)