Skip to content

Commit 62fa300

Browse files
committed
Sequencer view.
1 parent 9b89539 commit 62fa300

File tree

5 files changed

+121
-2
lines changed

5 files changed

+121
-2
lines changed

Aeolus.jucer

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
file="Source/ui/ParameterSlider.cpp"/>
7979
<FILE id="j8xpdL" name="ParameterSlider.h" compile="0" resource="0"
8080
file="Source/ui/ParameterSlider.h"/>
81+
<FILE id="JLGrPz" name="SequencerView.cpp" compile="1" resource="0"
82+
file="Source/ui/SequencerView.cpp"/>
83+
<FILE id="ZXjyL1" name="SequencerView.h" compile="0" resource="0" file="Source/ui/SequencerView.h"/>
8184
<FILE id="IMWRu0" name="StopButton.cpp" compile="1" resource="0" file="Source/ui/StopButton.cpp"/>
8285
<FILE id="lZISO8" name="StopButton.h" compile="0" resource="0" file="Source/ui/StopButton.h"/>
8386
</GROUP>

Source/PluginEditor.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ AeolusAudioProcessorEditor::AeolusAudioProcessorEditor (AeolusAudioProcessor& p)
3333
, _divisionsComponent{}
3434
, _divisionViews{}
3535
, _midiKeyboard(p.getEngine().getMidiKeyboardState(), MidiKeyboardComponent::horizontalKeyboard)
36+
, _sequencerView(p.getEngine().getSequencer())
3637
, _versionLabel{{}, JucePlugin_VersionString}
3738
, _cpuLoadLabel{{}, "CPU Load:"}
3839
, _cpuLoadValueLabel{}
@@ -127,6 +128,8 @@ AeolusAudioProcessorEditor::AeolusAudioProcessorEditor (AeolusAudioProcessor& p)
127128
_midiKeyboard.setAvailableRange(24, 108);
128129
addAndMakeVisible(_midiKeyboard);
129130

131+
addAndMakeVisible(_sequencerView);
132+
130133
resized();
131134

132135
startTimerHz(10);
@@ -170,6 +173,7 @@ void AeolusAudioProcessorEditor::resized()
170173
constexpr int H = 30;
171174
constexpr int S = 5;
172175
constexpr int T = margin * 2 + 20;
176+
constexpr int sequencerHeight = 26;
173177
constexpr int keyboardHeight = 70;
174178

175179
int y = 0;;
@@ -181,12 +185,13 @@ void AeolusAudioProcessorEditor::resized()
181185
}
182186

183187
_divisionsComponent.setBounds(0, 0, getWidth(), y);
184-
_divisionsViewport.setBounds(0, T, getWidth(), getHeight() - T - keyboardHeight);
188+
_divisionsViewport.setBounds(0, T, getWidth(), getHeight() - T - keyboardHeight - sequencerHeight);
185189

186190
int keyboardWidth = jmin((int)_midiKeyboard.getTotalKeyboardWidth(), getWidth());
187-
188191
_midiKeyboard.setBounds((getWidth() - keyboardWidth) / 2, getHeight() - keyboardHeight, keyboardWidth, keyboardHeight);
189192

193+
_sequencerView.setBounds(_midiKeyboard.getX(), _midiKeyboard.getY() - sequencerHeight, _midiKeyboard.getWidth(), sequencerHeight);
194+
190195
_cancelButton.setColour(TextButton::buttonColourId, Colour(0x66, 0x66, 0x33));
191196
_cancelButton.setBounds((_midiKeyboard.getX() - 60)/2, getHeight() - 60, 60, 35);
192197
}

Source/PluginEditor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "ui/LevelIndicator.h"
2727
#include "ui/ParameterSlider.h"
2828
#include "ui/DivisionView.h"
29+
#include "ui/SequencerView.h"
2930

3031
//==============================================================================
3132
/**
@@ -61,6 +62,8 @@ class AeolusAudioProcessorEditor : public juce::AudioProcessorEditor,
6162

6263
CustomMidiKeyboard _midiKeyboard;
6364

65+
ui::SequencerView _sequencerView;
66+
6467
juce::Label _versionLabel;
6568
juce::Label _cpuLoadLabel;
6669
juce::Label _cpuLoadValueLabel;

Source/ui/SequencerView.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// ----------------------------------------------------------------------------
2+
//
3+
// Copyright (C) 2021 Arthur Benilov <[email protected]>
4+
//
5+
// This program is free software; you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation; either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// This program is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
//
18+
// ----------------------------------------------------------------------------
19+
20+
#include "ui/SequencerView.h"
21+
22+
using namespace juce;
23+
24+
namespace ui {
25+
26+
SequencerView::SequencerView(aeolus::Sequencer* sequencer)
27+
: Component{}
28+
, _sequencer{sequencer}
29+
, _stepButtons{}
30+
{
31+
jassert(sequencer != nullptr);
32+
populateStepButtons();
33+
}
34+
35+
void SequencerView::resized()
36+
{
37+
constexpr int buttonWidth = 25;
38+
constexpr int buttonPadding = 3;
39+
40+
int buttonsWidth = buttonWidth * _sequencer->getStepsCount()
41+
+ buttonPadding * (_sequencer->getStepsCount() - 1);
42+
43+
int x = (getWidth() - buttonsWidth) / 2;
44+
45+
for (auto* button : _stepButtons) {
46+
button->setBounds(x, buttonPadding, buttonWidth, getHeight() - 2 * buttonPadding);
47+
x += buttonWidth + buttonPadding;
48+
}
49+
}
50+
51+
void SequencerView::populateStepButtons()
52+
{
53+
const auto numSteps = _sequencer->getStepsCount();
54+
55+
for (int i = 0; i < numSteps; ++i) {
56+
auto button = std::make_unique<TextButton>(String(i + 1));
57+
addAndMakeVisible(button.get());
58+
_stepButtons.add(button.release());
59+
}
60+
}
61+
62+
} // namespace ui

Source/ui/SequencerView.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// ----------------------------------------------------------------------------
2+
//
3+
// Copyright (C) 2021 Arthur Benilov <[email protected]>
4+
//
5+
// This program is free software; you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation; either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// This program is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
//
18+
// ----------------------------------------------------------------------------
19+
20+
#pragma once
21+
22+
#include "aeolus/globals.h"
23+
#include "aeolus/sequencer.h"
24+
25+
namespace ui {
26+
27+
class SequencerView : public juce::Component
28+
{
29+
public:
30+
31+
SequencerView(aeolus::Sequencer* sequencer);
32+
33+
// juce::Component
34+
void resized() override;
35+
36+
private:
37+
38+
void populateStepButtons();
39+
40+
aeolus::Sequencer* _sequencer;
41+
juce::OwnedArray<juce::TextButton> _stepButtons;
42+
43+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SequencerView)
44+
};
45+
46+
} // namespace ui

0 commit comments

Comments
 (0)