Skip to content

Commit

Permalink
Position tooltips more inteligently
Browse files Browse the repository at this point in the history
Closes #41
  • Loading branch information
baconpaul committed Jan 2, 2025
1 parent b934699 commit febcf90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ui/patch-data-bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ void createComponent(SixSinesEditor &e, P &panel, const Param &parm, std::unique
e.uiToAudio.push({Synth::UIToAudioMsg::Action::BEGIN_EDIT, id});
if (std::is_same_v<Q, PatchContinuous>)
{
e.showTooltipOn(cm.get());
e.updateTooltip(pc.get());
e.showTooltipOn(cm.get());
}

panel.beginEdit(args...);
Expand Down
7 changes: 4 additions & 3 deletions src/ui/six-sines-editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,15 @@ void SixSinesEditor::showTooltipOn(juce::Component *c)
}
y += c->getHeight();
toolTip->resetSizeFromData();
if (y + toolTip->getHeight() > getHeight())
if (y + toolTip->getHeight() > getHeight() - 40)
{
y -= c->getHeight() - 3 - toolTip->getHeight();
y -= c->getHeight() + 3 + toolTip->getHeight();
}

if (x + toolTip->getWidth() > getWidth())
{
x -= toolTip->getWidth() - c->getWidth() / 2;
x -= toolTip->getWidth();
x += c->getWidth() - 3;
}

toolTip->setTopLeftPosition(x, y);
Expand Down

0 comments on commit febcf90

Please sign in to comment.