From 38e065cb8f1744fb2940f10ea9b9da295a83fde6 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 8 May 2018 09:17:57 +0100 Subject: [PATCH] Added methods to get and set the octave scroll button width to MidiKeyboardComponent --- .../gui/juce_MidiKeyboardComponent.cpp | 13 ++++++++++++- .../gui/juce_MidiKeyboardComponent.h | 7 +++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp index ae08f8b8f4..aa96f3a438 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp @@ -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) diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h index 40a5302e97..dd49248e04 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h @@ -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;