Skip to content

Commit

Permalink
- fixed minor MIDI keyboard glitches
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-hart committed Jul 10, 2024
1 parent 5398eec commit 2bcf6f9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
5 changes: 3 additions & 2 deletions hi_backend/backend/BackendEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,8 @@ struct ToolkitPopup : public Component,
sustainButton.setToggleModeWithColourChange(true);

keyboard.setUseVectorGraphics(true);
keyboard.setRange(24, 127);
keyboard.setRange(36, 127);
keyboard.setShowOctaveNumber(true);

addAndMakeVisible(clockController);

Expand All @@ -978,7 +979,7 @@ struct ToolkitPopup : public Component,
auto l = keyboard.getRangeStart() + delta;
auto h = jmin(127, keyboard.getRangeEnd() + delta);

if(l > 0)
if(l > 0 && l <= 64)
keyboard.setRange(l, h);
}
}
Expand Down
34 changes: 34 additions & 0 deletions hi_core/hi_components/floating_layout/FloatingTile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,40 @@ Component* FloatingTile::wrapInViewport(Component* c, bool shouldBeMaximised)
return vp;
}

void FloatingTile::callToggleCallback()
{
if(auto c = togglePopupCallbackComponent.getComponent())
{
if(toggleFlag != nullptr)
{
*toggleFlag = false;
}

c->repaint();

toggleFlag = nullptr;
togglePopupCallbackComponent = {};
}
}

bool FloatingTile::setTogglePopupFlag(Component& c, bool& shouldClose)
{
if(shouldClose)
{
callToggleCallback();
showComponentInRootPopup(nullptr, nullptr, {});
return false;
}
else
{
callToggleCallback();
shouldClose = true;
toggleFlag = &shouldClose;
togglePopupCallbackComponent = &c;
return true;
}
}

FloatingTilePopup* FloatingTile::showComponentInRootPopup(Component* newComponent, Component* attachedComponent, Point<int> localPoint, bool shouldWrapInViewport, bool maximiseViewport)
{
if(newComponent != nullptr && shouldWrapInViewport)
Expand Down
8 changes: 4 additions & 4 deletions hi_core/hi_components/keyboard/CustomKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ CustomKeyboard::CustomKeyboard(MainController* mc_) :
narrowKeys(true),
lowKey(12)
{
setKeyPressBaseOctave(5);

state->addChangeListener(this);

setColour(whiteNoteColourId, Colours::black);
Expand Down Expand Up @@ -458,10 +460,8 @@ void CustomKeyboard::drawWhiteNote(int midiNoteNumber, Graphics &g, Rectangle<fl

if (displayOctaveNumber && midiNoteNumber % 12 == 0)
{
g.setFont(GLOBAL_BOLD_FONT().withHeight((float)w / 3.0f));

g.setColour(Colours::grey);

g.setFont(GLOBAL_BOLD_FONT().withHeight((float)w / 1.5f));
g.setColour(Colours::darkgrey);
g.drawText(MidiMessage::getMidiNoteName(midiNoteNumber, true, true, 3), x, (h*3)/4, w, h / 4, Justification::centred);
}

Expand Down

0 comments on commit 2bcf6f9

Please sign in to comment.