Skip to content

Commit

Permalink
Add seq block split operation
Browse files Browse the repository at this point in the history
  • Loading branch information
FangCunWuChang committed Jun 3, 2024
1 parent e302cda commit 27a2445
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/ui/component/sequencer/SeqTrackContentViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../../misc/AudioExtractor.h"
#include "../../misc/MainThreadPool.h"
#include "../../misc/Tools.h"
#include "../../misc/CoreActions.h"
#include "../../Utils.h"
#include "../../../audioCore/AC_API.h"

Expand Down Expand Up @@ -85,7 +86,7 @@ void SeqTrackContentViewer::update(int index) {
}
}

void SeqTrackContentViewer::updateBlock(int blockIndex) {
void SeqTrackContentViewer::updateBlock(int /*blockIndex*/) {
/** Create Or Remove Block */
int currentSize = this->blockTemp.size();
int newSize = quickAPI::getBlockNum(this->index);
Expand All @@ -102,13 +103,8 @@ void SeqTrackContentViewer::updateBlock(int blockIndex) {
}

/** Update Blocks */
if (blockIndex >= 0 && blockIndex < this->blockTemp.size()) {
this->updateBlockInternal(blockIndex);
}
else {
for (int i = 0; i < this->blockTemp.size(); i++) {
this->updateBlockInternal(i);
}
for (int i = 0; i < this->blockTemp.size(); i++) {
this->updateBlockInternal(i);
}

/** Repaint */
Expand Down Expand Up @@ -669,5 +665,5 @@ double SeqTrackContentViewer::limitTimeSec(double timeSec) {
}

void SeqTrackContentViewer::splitBlock(int blockIndex, double timeSec) {
/** TODO */
CoreActions::splitSeqBlock(this->index, blockIndex, timeSec);
}
18 changes: 18 additions & 0 deletions src/ui/misc/CoreActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,24 @@ void CoreActions::setLabelBeat(int index, int numerator, int denominator) {
ActionDispatcher::getInstance()->dispatch(std::move(action));
}

void CoreActions::insertSeqBlock(
int track, double startTime, double endTime, double offset) {
auto action = std::unique_ptr<ActionBase>(new ActionAddSequencerBlock{
track, startTime, endTime, offset });
ActionDispatcher::getInstance()->dispatch(std::move(action));
}

void CoreActions::splitSeqBlock(int track, int index, double time) {
auto action = std::unique_ptr<ActionBase>(new ActionSplitSequencerBlock{
track, index, time });
ActionDispatcher::getInstance()->dispatch(std::move(action));
}

void CoreActions::removeSeqBlock(int track, int index) {
auto action = std::unique_ptr<ActionBase>(new ActionRemoveSequencerBlock{ track, index });
ActionDispatcher::getInstance()->dispatch(std::move(action));
}

void CoreActions::loadProjectGUI(const juce::String& filePath) {
if (!CoreActions::askForSaveGUI()) { return; }

Expand Down
4 changes: 4 additions & 0 deletions src/ui/misc/CoreActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ class CoreActions final {
static void setLabelTempo(int index, double tempo);
static void setLabelBeat(int index, int numerator, int denominator);

static void insertSeqBlock(int track, double startTime, double endTime, double offset);
static void splitSeqBlock(int track, int index, double time);
static void removeSeqBlock(int track, int index);

static void loadProjectGUI(const juce::String& filePath);
static void loadProjectGUI();
static void newProjectGUI();
Expand Down

0 comments on commit 27a2445

Please sign in to comment.