gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit b085b8975d131b18e23f0df98ac9715261e97017
parent edea1c30eaeff939d5cee3d4ad6c8078a671e3e0
Author: dsp56300 <87139854+dsp56300@users.noreply.github.com>
Date:   Sun, 19 May 2024 22:30:04 +0200

Merge pull request #196 from mkruselj/constrain-tooltip-within-plugin-window

Constrain tooltip to plugin window
Diffstat:
Msource/jucePluginEditorLib/focusedParameter.cpp | 2+-
Msource/jucePluginEditorLib/focusedParameterTooltip.cpp | 21+++++++++------------
Msource/jucePluginEditorLib/focusedParameterTooltip.h | 8+++++++-
3 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/source/jucePluginEditorLib/focusedParameter.cpp b/source/jucePluginEditorLib/focusedParameter.cpp @@ -21,7 +21,7 @@ namespace jucePluginEditorLib if (m_focusedParameterValue) m_focusedParameterValue->setVisible(false); - m_tooltip.reset(new FocusedParameterTooltip(_editor.findComponentT<juce::Label>("FocusedParameterTooltip", false))); + m_tooltip.reset(new FocusedParameterTooltip(_editor.findComponentT<juce::Label>("FocusedParameterTooltip", false), _editor)); updateControlLabel(nullptr); diff --git a/source/jucePluginEditorLib/focusedParameterTooltip.cpp b/source/jucePluginEditorLib/focusedParameterTooltip.cpp @@ -1,10 +1,13 @@ #include "focusedParameterTooltip.h" +#include "pluginEditor.h" + #include "juce_gui_basics/juce_gui_basics.h" namespace jucePluginEditorLib { - FocusedParameterTooltip::FocusedParameterTooltip(juce::Label* _label) : m_label(_label), m_defaultWidth(_label ? _label->getWidth() : 0) + FocusedParameterTooltip::FocusedParameterTooltip(juce::Label *_label, const genericUI::Editor &_editor) : + m_label(_label), m_editor(_editor), m_defaultWidth(_label ? _label->getWidth() : 0) { setVisible(false); @@ -46,22 +49,16 @@ namespace jucePluginEditorLib x += (_component->getWidth()>>1) - (labelWidth>>1); y += _component->getHeight() + (m_label->getHeight()>>1); - /* - // global to local of tooltip parent - parent = m_label->getParentComponent(); - - while(parent && parent != this) - { - x -= parent->getX(); - y -= parent->getY(); - parent = parent->getParentComponent(); - } - */ if(m_label->getProperties().contains("offsetY")) y += static_cast<int>(m_label->getProperties()["offsetY"]); m_label->setTopLeftPosition(x,y); m_label->setSize(labelWidth, m_label->getHeight()); + + const auto editorRect = m_editor.getBounds(); + auto labelRect = m_label->getBounds(); + + m_label->setBounds(labelRect.constrainedWithin(editorRect)); m_label->setText(_value, juce::dontSendNotification); m_label->setVisible(true); m_label->toFront(false); diff --git a/source/jucePluginEditorLib/focusedParameterTooltip.h b/source/jucePluginEditorLib/focusedParameterTooltip.h @@ -7,12 +7,17 @@ namespace juce class Label; } +namespace genericUI +{ + class Editor; +} + namespace jucePluginEditorLib { class FocusedParameterTooltip { public: - FocusedParameterTooltip(juce::Label* _label); + FocusedParameterTooltip(juce::Label* _label, const genericUI::Editor& _editor); bool isValid() const { return m_label != nullptr; } void setVisible(bool _visible) const; @@ -21,5 +26,6 @@ namespace jucePluginEditorLib private: juce::Label* m_label = nullptr; int m_defaultWidth; + const genericUI::Editor& m_editor; }; }