Skip to content

Commit

Permalink
Avoid opening popups and tooltips as new windows as a workaround to f…
Browse files Browse the repository at this point in the history
…ix a display issue with AUs on Apple silicon
  • Loading branch information
cvde committed Apr 15, 2022
1 parent c603cc3 commit 19fa674
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
11 changes: 9 additions & 2 deletions Source/LookAndFeel/CustomLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ namespace LookAndFeelHelpers
}
}

CustomLookAndFeel::CustomLookAndFeel()
CustomLookAndFeel::CustomLookAndFeel(juce::Component& tlc)
: topLevelComponent(tlc)
{
defaultFont = juce::Typeface::createSystemTypefaceFor(BinaryData::OpenSansCondensedBold_ttf, BinaryData::OpenSansCondensedBold_ttfSize);
LookAndFeel::getDefaultLookAndFeel().setDefaultSansSerifTypeface(defaultFont.getTypefacePtr());
setDefaultSansSerifTypeface(defaultFont.getTypefacePtr());

setColour(juce::ResizableWindow::ColourIds::backgroundColourId, juce::Colour(0xff5e5e5e));
setColour(juce::DocumentWindow::textColourId, juce::Colours::white);
Expand All @@ -66,6 +67,12 @@ CustomLookAndFeel::CustomLookAndFeel()
setColour(juce::TextEditor::backgroundColourId, juce::Colour(0xff5e5e5e));
}

// draw tooltips and menus directly into the editor window (https://forum.juce.com/t/bug-popup-menu-background-and-logic-silicon/43243/10)
juce::Component* CustomLookAndFeel::getParentComponentForMenuOptions (const juce::PopupMenu::Options&)
{
return &topLevelComponent;
}

// change size of slider textbox
juce::Slider::SliderLayout CustomLookAndFeel::getSliderLayout (juce::Slider& slider)
{
Expand Down
5 changes: 4 additions & 1 deletion Source/LookAndFeel/CustomLookAndFeel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
class CustomLookAndFeel : public juce::LookAndFeel_V4
{
public:
CustomLookAndFeel();
explicit CustomLookAndFeel(juce::Component&);

juce::Component* getParentComponentForMenuOptions (const juce::PopupMenu::Options&) override;

juce::Slider::SliderLayout getSliderLayout (juce::Slider&) override;
void drawLinearSlider (juce::Graphics&, int x, int y, int width, int height,
Expand Down Expand Up @@ -59,6 +61,7 @@ class CustomLookAndFeel : public juce::LookAndFeel_V4

private:
juce::Font defaultFont;
juce::Component& topLevelComponent;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CustomLookAndFeel)
};
2 changes: 2 additions & 0 deletions Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ ReverbAudioProcessorEditor::ReverbAudioProcessorEditor(
juce::ValueTree& appStateTree)
: AudioProcessorEditor(&processor),
applicationState(appStateTree),
customLookAndFeel(*this),
headerSection(processor, parameterTree, aboutDialog),
outputSection(parameterTree),
earlySection(parameterTree),
lateSection(parameterTree)
{
juce::LookAndFeel::setDefaultLookAndFeel(&customLookAndFeel);
setLookAndFeel(&customLookAndFeel);
headerSection.setLookAndFeel(&customLookAndFeel);
outputSection.setLookAndFeel(&customLookAndFeel);
Expand Down
2 changes: 1 addition & 1 deletion Source/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ReverbAudioProcessorEditor : public juce::AudioProcessorEditor
AboutDialog aboutDialog;

// make tooltips visible
juce::TooltipWindow tooltipWindow{nullptr, 300};
juce::TooltipWindow tooltipWindow{this, 300};

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ReverbAudioProcessorEditor)
};

0 comments on commit 19fa674

Please sign in to comment.