mirror of
https://codeberg.org/armin/monostep.git
synced 2026-09-01 12:20:46 +02:00
67 lines
1.7 KiB
C
67 lines
1.7 KiB
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <JuceHeader.h>
|
||
|
|
|
||
|
|
class MonoStepAudioProcessor;
|
||
|
|
|
||
|
|
class SequencerMatrix final : public juce::Component
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
explicit SequencerMatrix (MonoStepAudioProcessor& processor);
|
||
|
|
~SequencerMatrix() override = default;
|
||
|
|
|
||
|
|
std::function<void (int stepIdx)> onStepSelected;
|
||
|
|
std::function<void (int stepIdx, bool gate)> onGateChanged;
|
||
|
|
std::function<void (int stepIdx, int semitone)> onNoteChanged;
|
||
|
|
std::function<void (int stepIdx, float cents)> onFineChanged;
|
||
|
|
std::function<void (int stepIdx, bool slide)> onSlideChanged;
|
||
|
|
|
||
|
|
void setSelectedStep (int stepIdx);
|
||
|
|
int getSelectedStep() const { return selectedStep; }
|
||
|
|
|
||
|
|
void setPlayPosition (int stepIdx);
|
||
|
|
|
||
|
|
void paint (juce::Graphics&) override;
|
||
|
|
void mouseDown (const juce::MouseEvent&) override;
|
||
|
|
void mouseDrag (const juce::MouseEvent&) override;
|
||
|
|
void mouseUp (const juce::MouseEvent&) override;
|
||
|
|
|
||
|
|
private:
|
||
|
|
struct CellRect
|
||
|
|
{
|
||
|
|
int step;
|
||
|
|
int row;
|
||
|
|
bool hit;
|
||
|
|
};
|
||
|
|
|
||
|
|
CellRect cellAt (const juce::MouseEvent&) const;
|
||
|
|
juce::Rectangle<int> matrixBounds() const;
|
||
|
|
int rowForSemitone (int semitone) const;
|
||
|
|
int semitoneForRow (int row) const;
|
||
|
|
|
||
|
|
MonoStepAudioProcessor& processor;
|
||
|
|
|
||
|
|
float cellW = 24.0f;
|
||
|
|
float cellH = 17.0f;
|
||
|
|
float labelW = 40.0f;
|
||
|
|
float headerH = 24.0f;
|
||
|
|
float headerPad = 10.0f;
|
||
|
|
|
||
|
|
int selectedStep = 0;
|
||
|
|
int playPos = -1;
|
||
|
|
|
||
|
|
bool dragging = false;
|
||
|
|
bool startedActive = false;
|
||
|
|
bool moved = false;
|
||
|
|
int lastRow = 0;
|
||
|
|
int dragStep = 0;
|
||
|
|
|
||
|
|
bool fineDragging = false;
|
||
|
|
int fineRefRow = 0;
|
||
|
|
float fineStartCents = 0.0f;
|
||
|
|
float fineLastCents = -1000.0f;
|
||
|
|
|
||
|
|
bool slideDragging = false;
|
||
|
|
bool startedSlideActive = false;
|
||
|
|
int slideLastStep = -1;
|
||
|
|
};
|