batch port transpose
parent
3282b2ee94
commit
0e8c25ccae
|
@ -533,8 +533,9 @@ void MainWindow::updateTitle() {
|
|||
else songTitle = project->title;
|
||||
}
|
||||
|
||||
if (!undoStack->isClean()) songTitle.append(" (modified)");
|
||||
ui->labelSongInfo->setText(songTitle);
|
||||
setWindowTitle(qs("Xybrid - %1%2").arg(songTitle).arg(undoStack->isClean() ? "" : "*"));
|
||||
setWindowTitle(qs("Xybrid - %1%2").arg(songTitle));
|
||||
}
|
||||
|
||||
void MainWindow::setSongInfoPaneExpanded(bool open) {
|
||||
|
|
|
@ -101,15 +101,33 @@ PatternEditorView::PatternEditorView(QWidget *parent) : QTableView(parent) {
|
|||
auto transpose = [this](int amt, int key = Qt::Key_Alt) {
|
||||
auto p = mdl->getPattern();
|
||||
auto sel = this->selectionModel()->selection().first();
|
||||
if (sel.width() == 1 && sel.height() == 1 && sel.left() % Util::colsPerChannel >= 2) { // single param
|
||||
amt = std::clamp(amt, -16, 16);
|
||||
auto c = new PatternDeltaCommand(p, Util::channelForColumn(sel.left()), sel.top());
|
||||
auto& r = c->row;
|
||||
auto par = static_cast<size_t>((sel.left() % Util::colsPerChannel) - 2) / 2;
|
||||
if (r.numParams() > par) {
|
||||
if (r.param(par)[0] != ' ') r.param(par)[1] = static_cast<uint8_t>(std::clamp(static_cast<int>(r.param(par)[1]) + amt, 0, 255));
|
||||
c->commit();
|
||||
} else c->cancel();
|
||||
auto startCol = sel.left() % Util::colsPerChannel;
|
||||
if (sel.width() == 1 && startCol != 1) {
|
||||
if (startCol == 0) { // port
|
||||
amt = std::clamp(amt, -16, 16);
|
||||
auto cc = new CompositeCommand();
|
||||
auto ch = Util::channelForColumn(sel.left());
|
||||
auto last = sel.bottom();
|
||||
for (auto i = sel.top(); i <= last; i++) {
|
||||
if (p->rowAt(ch, i).port >= 0) {
|
||||
auto c = new PatternDeltaCommand(p, ch, i);
|
||||
auto op = c->row.port;
|
||||
c->row.port = static_cast<int16_t>(std::clamp(op + amt, 0, 255));
|
||||
if (c->row.port == op) c->cancel();
|
||||
else cc->compose(c);
|
||||
}
|
||||
}
|
||||
cc->commit("change note port(s)");
|
||||
} else if (startCol >= 2 && sel.height() == 1) { // single param
|
||||
amt = std::clamp(amt, -16, 16);
|
||||
auto c = new PatternDeltaCommand(p, Util::channelForColumn(sel.left()), sel.top());
|
||||
auto& r = c->row;
|
||||
auto par = static_cast<size_t>((sel.left() % Util::colsPerChannel) - 2) / 2;
|
||||
if (r.numParams() > par) {
|
||||
if (r.param(par)[0] != ' ') r.param(par)[1] = static_cast<uint8_t>(std::clamp(static_cast<int>(r.param(par)[1]) + amt, 0, 255));
|
||||
c->commit();
|
||||
} else c->cancel();
|
||||
}
|
||||
} else { // note(s)
|
||||
amt = std::clamp(amt, -12, 12);
|
||||
auto cc = new CompositeCommand();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QStringBuilder>
|
||||
#include <QVariant>
|
||||
|
||||
#define qs QStringLiteral
|
||||
|
|
Loading…
Reference in New Issue