2
0
Fork 0
OB-Xd/Source/Components/ScaleComponent.h

87 lines
2.5 KiB
C
Raw Normal View History

2021-09-01 08:38:39 +00:00
/*
==============================================================================
ScaleComponent.h
Created: 27 Aug 2021 1:26:08pm
Author: discoDSP
==============================================================================
*/
#pragma once
//==============================================================================
#include <JuceHeader.h>
class ObxdAudioProcessor;
2021-09-09 15:30:38 +00:00
2021-09-01 08:38:39 +00:00
//==============================================================================
class ScalableComponent
{
public:
~ScalableComponent();
int getScaleInt();
void setScaleFactor(float newScaleFactor, bool newIsHighResolutionDisplay);
float getScaleImage();
float getScaleFactor() const;
bool getIsHighResolutionDisplay() const;
virtual void scaleFactorChanged();
protected:
ScalableComponent(ObxdAudioProcessor* owner_);
Image getScaledImageFromCache(const String& imageName, float scaleFactor, bool isHighResolutionDisplay);
private:
ObxdAudioProcessor* processor;
float scaleFactor;
bool isHighResolutionDisplay;
};
2021-09-09 15:30:38 +00:00
//==============================================================================
2021-09-24 05:30:17 +00:00
class CustomLookAndFeel : public LookAndFeel_V4,
2021-09-09 15:30:38 +00:00
public ScalableComponent
{
public:
2021-09-24 05:30:17 +00:00
CustomLookAndFeel(ObxdAudioProcessor* owner_):LookAndFeel_V4(), ScalableComponent(owner_) {
2021-09-09 15:30:38 +00:00
this->setColour(PopupMenu::backgroundColourId, Colour(20, 20, 20));
this->setColour(PopupMenu::textColourId, Colour(245, 245, 245));
this->setColour(PopupMenu::highlightedBackgroundColourId, Colour(60, 60, 60));
2021-09-17 12:16:21 +00:00
this->setColour(Label::textColourId, Colour(245, 245, 245));
2021-09-24 05:30:17 +00:00
2021-09-09 15:30:38 +00:00
};
2021-09-17 12:16:21 +00:00
2021-09-09 15:30:38 +00:00
PopupMenu::Options getOptionsForComboBoxPopupMenu (ComboBox& box, Label& label) override
{
2021-09-24 05:30:17 +00:00
PopupMenu::Options option = LookAndFeel_V4::getOptionsForComboBoxPopupMenu(box, label);
2021-09-09 15:30:38 +00:00
return option.withStandardItemHeight (label.getHeight()/ getScaleFactor());
};
2021-09-17 12:16:21 +00:00
Font getPopupMenuFont () override
{
float scaleFactor = getScaleFactor();
DBG("getPopupMenuFont::scaleFactor " << scaleFactor);
2021-09-24 05:30:17 +00:00
if (scaleFactor > 1.0) scaleFactor *= 0.85;
2021-09-17 12:16:21 +00:00
#ifdef JUCE_MAC
2021-09-24 05:30:17 +00:00
return Font("Helvetica Neue", 18.0 * scaleFactor, Font::plain);
2021-09-17 12:16:21 +00:00
#endif
#ifdef JUCE_WINDOWS
2021-09-24 05:30:17 +00:00
return Font("Arial", 18.0 * scaleFactor, Font::plain);
2021-09-17 12:16:21 +00:00
#endif
#ifdef JUCE_LINUX
2021-09-24 05:30:17 +00:00
return Font("DejaVu Sans", 18.0 * scaleFactor, Font::plain);
2021-09-17 12:16:21 +00:00
#endif
}
2021-09-24 05:30:17 +00:00
2021-09-09 15:30:38 +00:00
};