Browse Source

Added methods to get and set the octave scroll button width to MidiKeyboardComponent

tags/2021-05-28
ed 7 years ago
parent
commit
38e065cb8f
2 changed files with 19 additions and 1 deletions
  1. +12
    -1
      modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp
  2. +7
    -0
      modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h

+ 12
- 1
modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp View File

@@ -108,6 +108,17 @@ void MidiKeyboardComponent::setKeyWidth (float widthInPixels)
}
}
void MidiKeyboardComponent::setScrollButtonWidth (int widthInPixels)
{
jassert (widthInPixels > 0);
if (scrollButtonWidth != widthInPixels)
{
scrollButtonWidth = widthInPixels;
resized();
}
}
void MidiKeyboardComponent::setOrientation (Orientation newOrientation)
{
if (orientation != newOrientation)
@@ -610,7 +621,7 @@ void MidiKeyboardComponent::resized()
if (canScroll)
{
auto scrollButtonW = jmin (12, w / 2);
auto scrollButtonW = jmin (scrollButtonWidth, w / 2);
auto r = getLocalBounds();
if (orientation == horizontalKeyboard)


+ 7
- 0
modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h View File

@@ -129,6 +129,12 @@ public:
/** Returns the width that was set by setKeyWidth(). */
float getKeyWidth() const noexcept { return keyWidth; }
/** Changes the width used to draw the buttons that scroll the keyboard up/down in octaves. */
void setScrollButtonWidth (int widthInPixels);
/** Returns the width that was set by setScrollButtonWidth(). */
int getScrollButtonWidth() const noexcept { return scrollButtonWidth; };
/** Changes the keyboard's current direction. */
void setOrientation (Orientation newOrientation);
@@ -396,6 +402,7 @@ private:
float blackNoteWidthRatio = 0.7f;
float xOffset = 0;
float keyWidth = 16.0f;
int scrollButtonWidth = 12;
Orientation orientation;
int midiChannel = 1, midiInChannelMask = 0xffff;


Loading…
Cancel
Save