fix remaining off-by-ones in the pattern editor

portability/macos
zetaPRIME 2019-07-21 02:33:07 -04:00
parent 24b7c72ef9
commit b380959241
2 changed files with 8 additions and 6 deletions

2
notes
View File

@ -57,6 +57,8 @@ TODO {
}
misc features needed before proper release {
expand/compact pattern 2x/3x, keeping fold interval
at *least* js plugin support, with lua+lv2 highly preferable
different context menu for multiple selected nodes

View File

@ -113,8 +113,8 @@ PatternEditorView::PatternEditorView(QWidget *parent) : QTableView(parent) {
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);
if (p->rowAt(ch, i-1).port >= 0) {
auto c = new PatternDeltaCommand(p, ch, i-1);
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();
@ -124,7 +124,7 @@ PatternEditorView::PatternEditorView(QWidget *parent) : QTableView(parent) {
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 c = new PatternDeltaCommand(p, Util::channelForColumn(sel.left()), sel.top()-1);
auto& r = c->row;
auto par = static_cast<size_t>((sel.left() % Util::colsPerChannel) - 2) / 2;
if (r.numParams() > par) {
@ -138,7 +138,7 @@ PatternEditorView::PatternEditorView(QWidget *parent) : QTableView(parent) {
for (auto s : sel.indexes()) {
if (s.column() % Util::colsPerChannel != 1) continue;
int ch = Util::channelForColumn(s.column());
auto c = new PatternDeltaCommand(p, ch, s.row());
auto c = new PatternDeltaCommand(p, ch, s.row()-1);
if (c->row.note >= 0) {
c->row.note = static_cast<int16_t>(std::max(c->row.note + amt, 0));
cc->compose(c);
@ -193,7 +193,7 @@ PatternEditorView::PatternEditorView(QWidget *parent) : QTableView(parent) {
chm << first << last;
for (int r = sel.top(); r <= sel.bottom(); r++) {
QCborArray rm;
auto& row = p->rowAt(ch, r);
auto& row = p->rowAt(ch, r-1);
rm << row.port;
rm << row.note;
if (row.params) for (auto p : *row.params) rm << p[0] << p[1];
@ -220,7 +220,7 @@ PatternEditorView::PatternEditorView(QWidget *parent) : QTableView(parent) {
auto p = mdl->getPattern();
auto idx = currentIndex();
auto chMin = Util::channelForColumn(idx.column());
auto rMin = idx.row();
auto rMin = idx.row()-1;
auto root = QCborValue::fromCbor(data->data("xybrid-internal/x-pattern-copy")).toArray();