Skip to content

Commit

Permalink
Merge pull request #1790 from plugdata-team/develop
Browse files Browse the repository at this point in the history
Revert tooltip change for Windows
  • Loading branch information
timothyschoen authored Aug 10, 2024
2 parents 04917e9 + d62f85f commit e213743
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Source/Components/CheckedTooltip.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ class CheckedTooltip : public TooltipWindow {
Component* target, std::function<bool(Component*)> checkTooltip = [](Component*) { return true; }, int timeout = 500)
: TooltipWindow(target, timeout)
, checker(std::move(checkTooltip))
, tooltipShadow(DropShadow(Colour(0, 0, 0).withAlpha(0.2f), 5, { 0, 0 }), Corners::defaultCornerRadius)
{
setOpaque(false);
#if JUCE_WINDOWS
tooltipShadow.setOwner(this);
#endif
}

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

std::function<bool(Component*)> checker;
StackDropShadower tooltipShadow;
};
17 changes: 14 additions & 3 deletions Source/LookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,12 @@ void PlugDataLook::drawCornerResizer(Graphics& g, int w, int h, bool isMouseOver

void PlugDataLook::drawTooltip(Graphics& g, String const& text, int width, int height)
{
auto bounds = Rectangle<float>(0, 0, width, height).reduced(ProjectInfo::canUseSemiTransparentWindows() ? 6 : 0);
#if JUCE_WINDOWS
auto expandTooltip = false;
#else
auto expandTooltip = ProjectInfo::canUseSemiTransparentWindows();
#endif
auto bounds = Rectangle<float>(0, 0, width, height).reduced(expandTooltip ? 6 : 0);
auto shadowBounds = bounds.reduced(2);
auto const cornerSize = ProjectInfo::canUseSemiTransparentWindows() ? Corners::defaultCornerRadius : 0;

Expand Down Expand Up @@ -769,7 +774,7 @@ void PlugDataLook::drawTooltip(Graphics& g, String const& text, int width, int h
}
}

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

Rectangle<int> PlugDataLook::getTooltipBounds(String const& tipText, Point<int> screenPos, Rectangle<int> parentArea)
{
#if JUCE_WINDOWS
auto expandTooltip = false;
#else
auto expandTooltip = ProjectInfo::canUseSemiTransparentWindows();
#endif

float const tooltipFontSize = 14.0f;
int const maxToolTipWidth = 1000;

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

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

Expand Down

0 comments on commit e213743

Please sign in to comment.