Skip to content

Commit bc5470a

Browse files
committed
Fix bad tooltip scaling when zooming
1 parent 1dfee09 commit bc5470a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Source/Components/CheckedTooltip.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ class CheckedTooltip final : public TooltipWindow {
1313

1414
public:
1515
explicit CheckedTooltip(
16-
Component* target, std::function<bool(Component*)> checkTooltip = [](Component*) { return true; }, int const timeout = 500)
16+
Component* target, std::function<float()> getScaleFactor,
17+
std::function<bool(Component*)> checkTooltip,
18+
int const timeout = 500)
1719
: TooltipWindow(target, timeout)
1820
, checker(std::move(checkTooltip))
21+
, getScaleFactor(getScaleFactor)
1922
{
2023
}
2124

@@ -28,6 +31,11 @@ class CheckedTooltip final : public TooltipWindow {
2831
}
2932
TooltipWindow::setVisible(shouldBeVisible);
3033
}
34+
35+
float getDesktopScaleFactor() const override
36+
{
37+
return getScaleFactor();
38+
}
3139

3240
private:
3341
String getTipFor(Component& c) override
@@ -39,4 +47,5 @@ class CheckedTooltip final : public TooltipWindow {
3947
}
4048

4149
std::function<bool(Component*)> checker;
50+
std::function<float()> getScaleFactor;
4251
};

Source/PluginEditor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ PluginEditor::PluginEditor(PluginProcessor& p)
9393
, nvgSurface(this)
9494
, openedDialog(nullptr)
9595
, pluginConstrainer(*getConstrainer())
96-
, tooltipWindow(nullptr, [](Component* c) {
96+
, tooltipWindow(nullptr, [this](){ return std::sqrt(std::abs(getTransform().getDeterminant())); },
97+
[](Component* c) {
9798
if (auto const* cnv = c->findParentComponentOfClass<Canvas>()) {
9899
return !getValue<bool>(cnv->locked);
99100
}

0 commit comments

Comments
 (0)