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 015e69ad9f6a59dab342ec3a540468249f8c5a21
parent ffc6587eb25b8610fc58009b93659e052a7d8394
Author: Mario Kruselj <mario.kruselj@gmail.com>
Date:   Sun, 12 May 2024 22:12:42 +0200

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; }; }