Skip to content

Commit

Permalink
Added clear button to midi monitor node
Browse files Browse the repository at this point in the history
Closes #176
  • Loading branch information
mfisher31 committed Jun 7, 2020
1 parent efbe7dd commit c73c120
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/engine/nodes/MidiMonitorNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ void MidiMonitorNode::getMessages (MidiBuffer& destBuffer)
void MidiMonitorNode::clearMessages()
{
midiLog.clearQuick();
{
ScopedLock sl (lock);
inputMessages.reset (currentSampleRate);
numSamples = 0;
}
messagesLogged();
ScopedLock sl (lock);
inputMessages.reset (currentSampleRate);
numSamples = 0;
}

void MidiMonitorNode::timerCallback()
Expand Down
14 changes: 13 additions & 1 deletion src/gui/nodes/MidiMonitorNodeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ MidiMonitorNodeEditor::MidiMonitorNodeEditor (const Node& node)
setOpaque (true);
logger.reset (new Logger (getNodeObjectOfType<MidiMonitorNode>()));
addAndMakeVisible (logger.get());

addAndMakeVisible (clearButton);
clearButton.setButtonText ("Clear");
clearButton.onClick = [this]() {
if (auto* n = getNodeObjectOfType<MidiMonitorNode>())
n->clearMessages();
};

setSize (320, 160);
}

Expand All @@ -89,7 +97,11 @@ MidiMonitorNodeEditor::~MidiMonitorNodeEditor()

void MidiMonitorNodeEditor::resized ()
{
logger->setBounds (getLocalBounds().reduced (4));
auto r1 = getLocalBounds().reduced (4);
clearButton.changeWidthToFitText (24);
clearButton.setBounds (r1.getX(), r1.getY(), clearButton.getWidth(), clearButton.getHeight());
r1.removeFromTop (24 + 2);
logger->setBounds (r1);
}

};
1 change: 1 addition & 0 deletions src/gui/nodes/MidiMonitorNodeEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class MidiMonitorNodeEditor : public NodeEditorComponent

private:
class Logger; std::unique_ptr<Logger> logger;
TextButton clearButton;
};

}

0 comments on commit c73c120

Please sign in to comment.