diff --git a/Source/DXComponents.cpp b/Source/DXComponents.cpp index 71f2d411..8fa107a0 100644 --- a/Source/DXComponents.cpp +++ b/Source/DXComponents.cpp @@ -344,7 +344,7 @@ void LcdDisplay::setSystemMsg(String msg) { void LcdDisplay::paint(Graphics &g) { g.setColour (Colours::white); - g.drawText (paramMsg, + g.drawFittedText(paramMsg, 0, 0, 140, 14, Justification::centred, false); } diff --git a/Source/DXLookNFeel.cpp b/Source/DXLookNFeel.cpp index 23475b18..ecf7982d 100644 --- a/Source/DXLookNFeel.cpp +++ b/Source/DXLookNFeel.cpp @@ -276,7 +276,7 @@ Typeface::Ptr DXLookNFeel::getTypefaceForFont(const Font &) { void DXLookNFeel::drawRotarySlider( Graphics &g, int x, int y, int width, int height, float sliderPosProportional, float rotaryStartAngle, float rotaryEndAngle, Slider &slider ) { if ( imageKnob.isNull() ) { - LookAndFeel_V3::drawRotarySlider(g, x, y, width, height, sliderPosProportional, rotaryStartAngle, rotaryEndAngle, slider); + LookAndFeel_V4::drawRotarySlider(g, x, y, width, height, sliderPosProportional, rotaryStartAngle, rotaryEndAngle, slider); return; } @@ -296,7 +296,7 @@ void DXLookNFeel::drawRotarySlider( Graphics &g, int x, int y, int width, int he void DXLookNFeel::drawToggleButton(Graphics& g, ToggleButton& button, bool isMouseOverButton, bool isButtonDown) { if ( imageSwitch.isNull() ) { - LookAndFeel_V3::drawToggleButton(g, button, isMouseOverButton, isButtonDown); + LookAndFeel_V4::drawToggleButton(g, button, isMouseOverButton, isButtonDown); return; } @@ -305,7 +305,7 @@ void DXLookNFeel::drawToggleButton(Graphics& g, ToggleButton& button, bool isMou if( lb ) { if( imageSwitchLighted.isNull() ) { - LookAndFeel_V3::drawToggleButton(g, button, isMouseOverButton, isButtonDown); + LookAndFeel_V4::drawToggleButton(g, button, isMouseOverButton, isButtonDown); return; } g.drawImage(imageSwitchLighted, 0, 0, 48, 26, 0, button.getToggleState() ? 0 : 26, 48, 26); @@ -317,23 +317,24 @@ void DXLookNFeel::drawToggleButton(Graphics& g, ToggleButton& button, bool isMou void DXLookNFeel::drawButtonBackground(Graphics &g, Button &button, const Colour& backgroundColour, bool isMouseOverButton, bool isButtonDown) { if ( imageButton.isNull() ) { - LookAndFeel_V3::drawButtonBackground(g, button, backgroundColour, isMouseOverButton, isButtonDown); + LookAndFeel_V4::drawButtonBackground(g, button, backgroundColour, isMouseOverButton, isButtonDown); return; } int w = button.getWidth(); - + int l = button.getHeight(); + // dx, dy, dw, dl, sx, sy, sw, sl - g.drawImage(imageButton, 0, 0, 3, 30, 0, isButtonDown ? 30 : 0, 3, 30); - g.drawImage(imageButton, 3, 0, w-6, 30, 3, isButtonDown ? 30 : 0, 44, 30); - g.drawImage(imageButton, w-3, 0, 3, 30, 47, isButtonDown ? 30 : 0, 47, 30); + g.drawImage(imageButton, 0, 0, 3, l, 0, isButtonDown ? 30 : 0, 3, 30); + g.drawImage(imageButton, 3, 0, w-6, l, 3, isButtonDown ? 30 : 0, 44, 30); + g.drawImage(imageButton, w-3, 0, 3, l, 47, isButtonDown ? 30 : 0, 47, 30); } void DXLookNFeel::drawLinearSlider (Graphics& g, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const Slider::SliderStyle style, Slider& slider) { if ( imageSlider.isNull() ) { - LookAndFeel_V3::drawLinearSliderThumb(g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider); + LookAndFeel_V4::drawLinearSliderThumb(g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider); return; } @@ -351,7 +352,7 @@ void DXLookNFeel::positionComboBoxText(ComboBox& box, Label& label) { return; } - LookAndFeel_V3::positionComboBoxText(box, label); + LookAndFeel_V4::positionComboBoxText(box, label); } Colour DXLookNFeel::fillColour = Colour(77,159,151); diff --git a/Source/ParamDialog.cpp b/Source/ParamDialog.cpp index e02e2e3a..6ed75f2c 100644 --- a/Source/ParamDialog.cpp +++ b/Source/ParamDialog.cpp @@ -19,6 +19,7 @@ //[Headers] You can add your own extra header files here... #include "Dexed.h" +#include "DXComponents.h" //[/Headers] #include "ParamDialog.h" @@ -33,7 +34,7 @@ ParamDialog::ParamDialog () //[Constructor_pre] You can add your own custom stuff here.. //[/Constructor_pre] - pitchRangeDn.reset (new juce::Slider ("pitchRangeDn")); + pitchRangeDn.reset (new DXSlider ("pitchRangeDn")); addAndMakeVisible (pitchRangeDn.get()); pitchRangeDn->setExplicitFocusOrder (2); pitchRangeDn->setRange (0, 48, 1); @@ -43,7 +44,7 @@ ParamDialog::ParamDialog () pitchRangeDn->setBounds (264, 16, 72, 24); - pitchStep.reset (new juce::Slider ("pitchStep")); + pitchStep.reset (new DXSlider ("pitchStep")); addAndMakeVisible (pitchStep.get()); pitchStep->setExplicitFocusOrder (3); pitchStep->setRange (0, 12, 1); @@ -75,7 +76,7 @@ ParamDialog::ParamDialog () sysexOut->setBounds (104, 280, 224, 24); - sysexChl.reset (new juce::Slider ("sysexChl")); + sysexChl.reset (new DXSlider ("sysexChl")); addAndMakeVisible (sysexChl.get()); sysexChl->setExplicitFocusOrder (9); sysexChl->setRange (1, 16, 1); @@ -107,7 +108,7 @@ ParamDialog::ParamDialog () showKeyboard->setBounds (264, 96, 56, 24); - whlRange.reset (new juce::Slider ("whlRange")); + whlRange.reset (new DXSlider ("whlRange")); addAndMakeVisible (whlRange.get()); whlRange->setExplicitFocusOrder (10); whlRange->setRange (0, 99, 1); @@ -117,7 +118,7 @@ ParamDialog::ParamDialog () whlRange->setBounds (448, 16, 72, 24); - ftRange.reset (new juce::Slider ("ftRange")); + ftRange.reset (new DXSlider ("ftRange")); addAndMakeVisible (ftRange.get()); ftRange->setExplicitFocusOrder (14); ftRange->setRange (0, 99, 1); @@ -127,7 +128,7 @@ ParamDialog::ParamDialog () ftRange->setBounds (448, 56, 72, 24); - brRange.reset (new juce::Slider ("brRange")); + brRange.reset (new DXSlider ("brRange")); addAndMakeVisible (brRange.get()); brRange->setExplicitFocusOrder (18); brRange->setRange (0, 99, 1); @@ -137,7 +138,7 @@ ParamDialog::ParamDialog () brRange->setBounds (448, 96, 72, 24); - atRange.reset (new juce::Slider ("atRange")); + atRange.reset (new DXSlider ("atRange")); addAndMakeVisible (atRange.get()); atRange->setExplicitFocusOrder (22); atRange->setRange (0, 99, 1); @@ -284,7 +285,7 @@ ParamDialog::ParamDialog () transposeScale->setBounds (592, 240, 56, 30); - mpePBRange.reset (new juce::Slider ("mpePBRange")); + mpePBRange.reset (new DXSlider ("mpePBRange")); addAndMakeVisible (mpePBRange.get()); mpePBRange->setExplicitFocusOrder (32); mpePBRange->setRange (0, 96, 1); @@ -312,7 +313,7 @@ ParamDialog::ParamDialog () juce::Image(), 1.000f, juce::Colour (0x00000000)); transposeHelp->setBounds (500, 245, 20, 20); - pitchRangeUp.reset (new juce::Slider ("pitchRangeUp")); + pitchRangeUp.reset (new DXSlider ("pitchRangeUp")); addAndMakeVisible (pitchRangeUp.get()); pitchRangeUp->setExplicitFocusOrder (1); pitchRangeUp->setRange (0, 48, 1); @@ -349,8 +350,6 @@ ParamDialog::ParamDialog () //[Constructor] You can add your own custom stuff here.. pitchRangeUp->setEnabled(pitchStep->getValue() == 0); pitchRangeDn->setEnabled(pitchStep->getValue() == 0); - pitchRangeUp->grabKeyboardFocus(); - StringArray input; input.add("None"); @@ -434,6 +433,9 @@ ParamDialog::ParamDialog () mpeEnabled->setWantsKeyboardFocus(true); transposeHelp->setWantsKeyboardFocus(true); scalingFactor->setWantsKeyboardFocus(true); + + setWantsKeyboardFocus(true); + startTimer(100); //[/Constructor] } @@ -478,6 +480,7 @@ ParamDialog::~ParamDialog() //[Destructor]. You can add your own custom destruction code here.. + stopTimer(); //[/Destructor] } @@ -1203,6 +1206,13 @@ void ParamDialog::setIsStandardTuning( bool b ) resetTuningButton->setEnabled( ! b ); } +// Force the internal component dialog to have keyboard focus. Ugly, but it is +// the only way I have found (including on the JUCE forum). +void ParamDialog::timerCallback() { + stopTimer(); + grabKeyboardFocus(); +} + //[/MiscUserCode] diff --git a/Source/ParamDialog.h b/Source/ParamDialog.h index 8b322305..3fb08d2d 100644 --- a/Source/ParamDialog.h +++ b/Source/ParamDialog.h @@ -40,7 +40,8 @@ class ParamDialog : public Component, public juce::Slider::Listener, public juce::ComboBox::Listener, - public juce::Button::Listener + public juce::Button::Listener, + Timer { public: //============================================================================== @@ -63,6 +64,7 @@ class ParamDialog : public Component, void setGeneralCallback(std::function gc ) { general_callback_ = gc; } void setIsStandardTuning(bool s); + void timerCallback() override; //[/UserMethods] void paint (juce::Graphics& g) override;