1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

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

This commit is contained in:
ed 2018-05-08 09:17:57 +01:00
parent 955f6fbc2b
commit 38e065cb8f
2 changed files with 19 additions and 1 deletions

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)

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;