Skip to content

Commit 99a8396

Browse files
Add seq track input monitoring button
1 parent 8f4f357 commit 99a8396

18 files changed

+240
-6
lines changed

src/audioCore/graph/SeqSourceProcessor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,9 @@ bool SeqSourceProcessor::getMute() const {
550550

551551
void SeqSourceProcessor::setInputMonitoring(bool inputMonitoring) {
552552
this->inputMonitoring = inputMonitoring;
553+
554+
/** Callback */
555+
UICallbackAPI<int>::invoke(UICallbackType::SeqInputMonitoringChanged, this->index);
553556
}
554557

555558
bool SeqSourceProcessor::getInputMonitoring() const {

src/audioCore/quickAPI/QuickGet.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,15 @@ namespace quickAPI {
634634
return false;
635635
}
636636

637+
bool getSeqTrackInputMonitoring(int index) {
638+
if (auto graph = AudioCore::getInstance()->getGraph()) {
639+
if (auto track = graph->getSourceProcessor(index)) {
640+
return track->getInputMonitoring();
641+
}
642+
}
643+
return false;
644+
}
645+
637646
RecordState getSeqTrackRecording(int index) {
638647
if (auto graph = AudioCore::getInstance()->getGraph()) {
639648
if (auto track = graph->getSourceProcessor(index)) {

src/audioCore/quickAPI/QuickGet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ namespace quickAPI {
128128
const juce::Array<MIDILink> getSeqTrackMIDIOutputToMixer(int index);
129129
const juce::Array<AudioLink> getSeqTrackAudioOutputToMixer(int index);
130130
bool getSeqTrackMute(int index);
131+
bool getSeqTrackInputMonitoring(int index);
131132
RecordState getSeqTrackRecording(int index);
132133
const juce::Array<float> getSeqTrackOutputLevel(int index);
133134
const juce::String getSeqTrackType(int index);

src/audioCore/uiCallback/UICallbackType.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ enum class UICallbackType : int {
1717
SeqChanged,
1818
SeqBlockChanged,
1919
SeqMuteChanged,
20+
SeqInputMonitoringChanged,
2021
SeqRecChanged,
2122
TempoChanged,
2223
SeqDataRefChanged,

src/ui/component/sequencer/SeqTrackComponent.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ SeqTrackComponent::SeqTrackComponent(
4040
this->muteButton = std::make_unique<SeqTrackMuteComponent>();
4141
this->addChildComponent(this->muteButton.get());
4242

43+
/** Input Monitoring Button */
44+
this->inputMonitoringButton = std::make_unique<SeqTrackInputMonitoringComponent>();
45+
this->addChildComponent(this->inputMonitoringButton.get());
46+
4347
/** Record Button */
4448
this->recButton = std::make_unique<SeqTrackRecComponent>();
4549
this->addChildComponent(this->recButton.get());
@@ -143,6 +147,7 @@ void SeqTrackComponent::update(int index) {
143147
this->trackName->setButtonText(juce::String{ index } + " - " + name);
144148

145149
this->updateMute();
150+
this->updateInputMonitoring();
146151
this->updateRec();
147152

148153
this->updateInstr();
@@ -168,6 +173,10 @@ void SeqTrackComponent::updateMute() {
168173
this->muteButton->update(this->index);
169174
}
170175

176+
void SeqTrackComponent::updateInputMonitoring() {
177+
this->inputMonitoringButton->update(this->index);
178+
}
179+
171180
void SeqTrackComponent::updateRec() {
172181
this->recButton->update(this->index);
173182
}
@@ -297,30 +306,37 @@ void SeqTrackComponent::resized() {
297306
}
298307

299308
/** IO */
309+
/** Input Monitoring Button */
310+
juce::Rectangle<int> inputMonitoringRect(
311+
leftX + buttonSplitWidth, topY + contentLineSplitHeight,
312+
ioLineHeight, ioLineHeight);
313+
this->inputMonitoringButton->setBounds(inputMonitoringRect);
314+
this->inputMonitoringButton->setVisible(isIOLineShown);
315+
300316
/** Record Button */
301317
juce::Rectangle<int> recRect(
302-
leftX + buttonSplitWidth, topY + contentLineSplitHeight,
318+
inputMonitoringRect.getRight() + buttonSplitWidth, inputMonitoringRect.getY(),
303319
ioLineHeight, ioLineHeight);
304320
this->recButton->setBounds(recRect);
305321
this->recButton->setVisible(isIOLineShown);
306322

307323
/** Mute Button */
308324
juce::Rectangle<int> muteRect(
309-
recRect.getRight() + buttonSplitWidth, recRect.getY(),
325+
recRect.getRight() + buttonSplitWidth, inputMonitoringRect.getY(),
310326
ioLineHeight, ioLineHeight);
311327
this->muteButton->setBounds(muteRect);
312328
this->muteButton->setVisible(isIOLineShown);
313329

314330
/** MIDI Output */
315331
juce::Rectangle<int> midiOutputRect(
316-
muteRect.getRight() + buttonSplitWidth, recRect.getY(),
332+
muteRect.getRight() + buttonSplitWidth, inputMonitoringRect.getY(),
317333
ioLineHeight, ioLineHeight);
318334
this->midiOutput->setBounds(midiOutputRect);
319335
this->midiOutput->setVisible(isIOLineShown);
320336

321337
/** Audio Output */
322338
juce::Rectangle<int> audioOutputRect(
323-
midiOutputRect.getRight() + ioLineSplitWidth, recRect.getY(),
339+
midiOutputRect.getRight() + ioLineSplitWidth, inputMonitoringRect.getY(),
324340
ioLineHeight, ioLineHeight);
325341
this->audioOutput->setBounds(audioOutputRect);
326342
this->audioOutput->setVisible(isIOLineShown);

src/ui/component/sequencer/SeqTrackComponent.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <JuceHeader.h>
44
#include "SeqTrackMuteComponent.h"
5+
#include "SeqTrackInputMonitoringComponent.h"
56
#include "SeqTrackRecComponent.h"
67
#include "SeqTrackIOComponent.h"
78
#include "SeqTrackLevelMeter.h"
@@ -34,6 +35,7 @@ class SeqTrackComponent final
3435
void update(int index);
3536
void updateBlock(int blockIndex);
3637
void updateMute();
38+
void updateInputMonitoring();
3739
void updateRec();
3840
void updateInstr();
3941
void updateHPos(double pos, double itemSize);
@@ -76,6 +78,7 @@ class SeqTrackComponent final
7678

7779
std::unique_ptr<juce::TextButton> trackName = nullptr;
7880
std::unique_ptr<SeqTrackMuteComponent> muteButton = nullptr;
81+
std::unique_ptr<SeqTrackInputMonitoringComponent> inputMonitoringButton = nullptr;
7982
std::unique_ptr<SeqTrackRecComponent> recButton = nullptr;
8083

8184
std::unique_ptr<RightClickableTextButton> instrButton = nullptr;
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#include "SeqTrackInputMonitoringComponent.h"
2+
#include "../../lookAndFeel/LookAndFeelFactory.h"
3+
#include "../../misc/CoreActions.h"
4+
#include "../../Utils.h"
5+
#include "../../../audioCore/AC_API.h"
6+
7+
SeqTrackInputMonitoringComponent::SeqTrackInputMonitoringComponent() {
8+
this->setLookAndFeel(
9+
LookAndFeelFactory::getInstance()->getLAFFor(LookAndFeelFactory::InputMonitoringButton));
10+
}
11+
12+
void SeqTrackInputMonitoringComponent::paint(juce::Graphics& g) {
13+
/** Size */
14+
auto screenSize = utils::getScreenSize(this);
15+
float lineThickness = screenSize.getHeight() * 0.001;
16+
17+
int buttonWidth = std::min(this->getWidth(), this->getHeight()) - lineThickness;
18+
int buttonHeight = buttonWidth;
19+
20+
float textFontHeight = buttonWidth * 0.7;
21+
22+
/** Color */
23+
auto& laf = this->getLookAndFeel();
24+
juce::Colour backgroundColor = laf.findColour(this->inputMonitoring
25+
? juce::TextButton::ColourIds::buttonOnColourId
26+
: juce::TextButton::ColourIds::buttonColourId);
27+
juce::Colour textColor = laf.findColour(this->inputMonitoring
28+
? juce::TextButton::ColourIds::textColourOnId
29+
: juce::TextButton::ColourIds::textColourOffId);
30+
31+
/** Font */
32+
juce::Font textFont(juce::FontOptions{ textFontHeight });
33+
34+
/** Button */
35+
juce::Rectangle<float> buttonRect(
36+
this->getWidth() / 2.f - buttonWidth / 2.f,
37+
this->getHeight() / 2.f - buttonHeight / 2.f,
38+
buttonWidth, buttonHeight);
39+
g.setColour(backgroundColor);
40+
g.fillRect(buttonRect);
41+
42+
g.setColour(textColor);
43+
g.drawRect(buttonRect, lineThickness);
44+
45+
g.setFont(textFont);
46+
g.drawFittedText("I", buttonRect.toNearestInt(),
47+
juce::Justification::centred, 1, 0.f);
48+
}
49+
50+
void SeqTrackInputMonitoringComponent::mouseDrag(const juce::MouseEvent& event) {
51+
this->mouseMove(event);
52+
}
53+
54+
void SeqTrackInputMonitoringComponent::mouseMove(const juce::MouseEvent& event) {
55+
/** Size */
56+
auto screenSize = utils::getScreenSize(this);
57+
float lineThickness = screenSize.getHeight() * 0.001;
58+
int buttonWidth = std::min(this->getWidth(), this->getHeight()) - lineThickness;
59+
int buttonHeight = buttonWidth;
60+
juce::Rectangle<float> buttonRect(
61+
this->getWidth() / 2.f - buttonWidth / 2.f,
62+
this->getHeight() / 2.f - buttonHeight / 2.f,
63+
buttonWidth, buttonHeight);
64+
65+
/** Cursor */
66+
this->setMouseCursor(buttonRect.contains(event.position)
67+
? juce::MouseCursor::PointingHandCursor
68+
: juce::MouseCursor::NormalCursor);
69+
}
70+
71+
void SeqTrackInputMonitoringComponent::mouseUp(const juce::MouseEvent& event) {
72+
/** Size */
73+
auto screenSize = utils::getScreenSize(this);
74+
float lineThickness = screenSize.getHeight() * 0.001;
75+
int buttonWidth = std::min(this->getWidth(), this->getHeight()) - lineThickness;
76+
int buttonHeight = buttonWidth;
77+
juce::Rectangle<float> buttonRect(
78+
this->getWidth() / 2.f - buttonWidth / 2.f,
79+
this->getHeight() / 2.f - buttonHeight / 2.f,
80+
buttonWidth, buttonHeight);
81+
82+
if (buttonRect.contains(event.position)) {
83+
if (event.mods.isLeftButtonDown()) {
84+
this->changeInputMonitoring();
85+
}
86+
else if (event.mods.isRightButtonDown()) {
87+
this->changeInputMonitoring();
88+
}
89+
}
90+
}
91+
92+
void SeqTrackInputMonitoringComponent::update(int index) {
93+
this->index = index;
94+
if (index > -1) {
95+
this->inputMonitoring = quickAPI::getSeqTrackInputMonitoring(index);
96+
97+
this->repaint();
98+
}
99+
}
100+
101+
void SeqTrackInputMonitoringComponent::changeInputMonitoring() {
102+
CoreActions::setSeqInputMonitoring(this->index, !(this->inputMonitoring));
103+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#pragma once
2+
3+
#include <JuceHeader.h>
4+
5+
class SeqTrackInputMonitoringComponent final
6+
: public juce::Component,
7+
public juce::SettableTooltipClient {
8+
public:
9+
SeqTrackInputMonitoringComponent();
10+
11+
void paint(juce::Graphics& g) override;
12+
13+
void mouseDrag(const juce::MouseEvent& event) override;
14+
void mouseMove(const juce::MouseEvent& event) override;
15+
void mouseUp(const juce::MouseEvent& event) override;
16+
17+
void update(int index);
18+
19+
private:
20+
int index = -1;
21+
bool inputMonitoring = false;
22+
23+
void changeInputMonitoring();
24+
25+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SeqTrackInputMonitoringComponent)
26+
};

src/ui/component/sequencer/SeqView.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ void SeqView::TrackList::updateMute(int index) {
5656
}
5757
}
5858

59+
void SeqView::TrackList::updateInputMonitoring(int index) {
60+
if (index >= 0 && index < this->list.size()) {
61+
this->list[index]->updateInputMonitoring();
62+
}
63+
}
64+
5965
void SeqView::TrackList::updateRec(int index) {
6066
if (index >= 0 && index < this->list.size()) {
6167
this->list[index]->updateRec();
@@ -431,6 +437,13 @@ SeqView::SeqView()
431437
}
432438
}
433439
);
440+
CoreCallbacks::getInstance()->addSeqInputMonitoringChanged(
441+
[comp = SeqView::SafePointer(this)](int index) {
442+
if (comp) {
443+
comp->updateInputMonitoring(index);
444+
}
445+
}
446+
);
434447
CoreCallbacks::getInstance()->addSeqRecChanged(
435448
[comp = SeqView::SafePointer(this)](int index) {
436449
if (comp) {
@@ -811,6 +824,10 @@ void SeqView::updateMute(int index) {
811824
this->trackList->updateMute(index);
812825
}
813826

827+
void SeqView::updateInputMonitoring(int index) {
828+
this->trackList->updateInputMonitoring(index);
829+
}
830+
814831
void SeqView::updateRec(int index) {
815832
this->trackList->updateRec(index);
816833
}

src/ui/component/sequencer/SeqView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class SeqView final
2222
void updateBlock(int track, int index);
2323
void updateTempo();
2424
void updateMute(int index);
25+
void updateInputMonitoring(int index);
2526
void updateRec(int index);
2627
void updateInstr(int index);
2728
void updateLevelMeter() override;
@@ -63,6 +64,7 @@ class SeqView final
6364
void update(int index);
6465
void updateBlock(int track, int index);
6566
void updateMute(int index);
67+
void updateInputMonitoring(int index);
6668
void updateRec(int index);
6769
void updateInstr(int index);
6870
void updateMixerTrack();

src/ui/lookAndFeel/LookAndFeelFactory.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "editor/EditorSwitchBarLookAndFeel.h"
3030
#include "editor/PianoLookAndFeel.h"
3131
#include "editor/MidiContentLookAndFeel.h"
32+
#include "base/InputMonitoringButtonLookAndFeel.h"
3233
#include "../misc/ColorMap.h"
3334
#include <FlowUI.h>
3435

@@ -95,7 +96,8 @@ void LookAndFeelFactory::initialise() {
9596
new EditorLookAndFeel{},
9697
new EditorSwitchBarLookAndFeel{},
9798
new PianoLookAndFeel{},
98-
new MidiContentLookAndFeel{}
99+
new MidiContentLookAndFeel{},
100+
new InputMonitoringButtonLookAndFeel{}
99101
};
100102
}
101103

src/ui/lookAndFeel/LookAndFeelFactory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class LookAndFeelFactory final : private juce::DeletedAtShutdown {
1515
Mixer, Scroller, ColorEditor, SideChain, LevelMeter,
1616
MuteButton, RecButton, Effect, Seq, TimeRuler, SeqTrack,
1717
SeqTrackName, InstrName, SeqBlock, Editor, EditorSwitchBar,
18-
Piano, MidiContent,
18+
Piano, MidiContent, InputMonitoringButton,
1919

2020
TotalTypeNum
2121
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "InputMonitoringButtonLookAndFeel.h"
2+
#include "../../misc/ColorMap.h"
3+
4+
InputMonitoringButtonLookAndFeel::InputMonitoringButtonLookAndFeel()
5+
: MainLookAndFeel() {
6+
/** Button */
7+
this->setColour(juce::TextButton::ColourIds::buttonColourId,
8+
ColorMap::getInstance()->get("ThemeColorB2"));
9+
this->setColour(juce::TextButton::ColourIds::buttonOnColourId,
10+
juce::Colours::seagreen.withAlpha(0.6f));
11+
this->setColour(juce::TextButton::ColourIds::textColourOffId,
12+
ColorMap::getInstance()->get("ThemeColorB8"));
13+
this->setColour(juce::TextButton::ColourIds::textColourOnId,
14+
ColorMap::getInstance()->get("ThemeColorB10"));
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
#include <JuceHeader.h>
4+
#include "../MainLookAndFeel.h"
5+
6+
class InputMonitoringButtonLookAndFeel : public MainLookAndFeel {
7+
public:
8+
InputMonitoringButtonLookAndFeel();
9+
10+
private:
11+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(InputMonitoringButtonLookAndFeel)
12+
};

src/ui/misc/CoreActions.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,11 @@ void CoreActions::setSeqMuteAll(bool mute) {
427427
}
428428
}
429429

430+
void CoreActions::setSeqInputMonitoring(int index, bool inputMonitoring) {
431+
auto action = std::unique_ptr<ActionBase>(new ActionSetSequencerTrackInputMonitoring{ index, inputMonitoring });
432+
ActionDispatcher::getInstance()->dispatch(std::move(action));
433+
}
434+
430435
void CoreActions::setSeqRec(int index, quickAPI::RecordState rec) {
431436
auto action = std::unique_ptr<ActionBase>(new ActionSetSequencerTrackRecording{ index, rec });
432437
ActionDispatcher::getInstance()->dispatch(std::move(action));

src/ui/misc/CoreActions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class CoreActions final {
9090
static void setSeqMute(int index, bool mute);
9191
static void setSeqSolo(int index);
9292
static void setSeqMuteAll(bool mute);
93+
static void setSeqInputMonitoring(int index, bool inputMonitoring);
9394
static void setSeqRec(int index, quickAPI::RecordState rec);
9495
static void setSeqMIDITrack(int index, int midiTrack);
9596
static void setSeqAudioRef(int index, const juce::String& path,

0 commit comments

Comments
 (0)