fix(color): copy/paste inputs/mixers (#2545)

Fixes #2541
This commit is contained in:
Raphael Coeffic
2022-10-14 12:01:18 +10:00
committed by GitHub
parent 41c788267b
commit 82ce6d0240
2 changed files with 51 additions and 47 deletions
+24 -23
View File
@@ -253,44 +253,38 @@ InputMixButton* ModelInputsPage::createLineButton(InputMixGroup *group,
menu->addLine(STR_EDIT, [=]() {
uint8_t idx = button->getIndex();
editInput(input, idx);
_copyMode = 0;
});
if (!reachExposLimit()) {
menu->addLine(STR_INSERT_BEFORE, [=]() {
uint8_t idx = button->getIndex();
insertInput(input, idx);
_copyMode = 0;
});
menu->addLine(STR_INSERT_AFTER, [=]() {
uint8_t idx = button->getIndex();
insertInput(input, idx + 1);
_copyMode = 0;
});
menu->addLine(STR_COPY, [=]() {
_copyMode = COPY_MODE;
_copySrc = button;
});
if (_copyMode != 0) {
if (this->_copyMode != 0) {
menu->addLine(STR_PASTE_BEFORE, [=]() {
uint8_t idx = button->getIndex();
pasteInputBefore(idx);
_copyMode = 0;
});
menu->addLine(STR_PASTE_AFTER, [=]() {
uint8_t idx = button->getIndex();
pasteInputAfter(idx);
_copyMode = 0;
});
}
menu->addLine(STR_INSERT_BEFORE, [=]() {
uint8_t idx = button->getIndex();
insertInput(input, idx);
});
menu->addLine(STR_INSERT_AFTER, [=]() {
uint8_t idx = button->getIndex();
insertInput(input, idx + 1);
});
menu->addLine(STR_COPY, [=]() {
this->_copyMode = COPY_MODE;
this->_copySrc = button;
});
menu->addLine(STR_MOVE, [=]() {
this->_copyMode = MOVE_MODE;
this->_copySrc = button;
});
}
menu->addLine(STR_MOVE, [=]() {
_copyMode = MOVE_MODE;
_copySrc = button;
});
menu->addLine(STR_DELETE, [=]() {
uint8_t idx = button->getIndex();
deleteInput(idx);
_copyMode = 0;
});
return 0;
});
@@ -356,6 +350,8 @@ void ModelInputsPage::addLineButton(mixsrc_t src, uint8_t index)
void ModelInputsPage::editInput(uint8_t input, uint8_t index)
{
_copyMode = 0;
auto group = getGroupBySrc(MIXSRC_FIRST_INPUT + input);
if (!group) return;
@@ -380,6 +376,8 @@ void ModelInputsPage::insertInput(uint8_t input, uint8_t index)
void ModelInputsPage::deleteInput(uint8_t index)
{
_copyMode = 0;
auto group = getGroupByIndex(index);
if (!group) return;
@@ -408,8 +406,11 @@ void ModelInputsPage::pasteInput(uint8_t dst_idx, uint8_t input)
addLineButton(dst_idx);
if (_copyMode == MOVE_MODE) {
src_idx = _copySrc->getIndex();
deleteInput(src_idx);
}
_copyMode = 0;
}
static int _inputChnFromIndex(uint8_t index)
+27 -24
View File
@@ -342,44 +342,38 @@ InputMixButton* ModelMixesPage::createLineButton(InputMixGroup *group, uint8_t i
menu->addLine(STR_EDIT, [=]() {
uint8_t idx = button->getIndex();
editMix(ch, idx);
_copyMode = 0;
});
if (!reachMixesLimit()) {
menu->addLine(STR_INSERT_BEFORE, [=]() {
uint8_t idx = button->getIndex();
insertMix(ch, idx);
_copyMode = 0;
});
menu->addLine(STR_INSERT_AFTER, [=]() {
uint8_t idx = button->getIndex();
insertMix(ch, idx + 1);
_copyMode = 0;
});
menu->addLine(STR_COPY, [=]() {
_copyMode = COPY_MODE;
_copySrc = button;
});
if (_copyMode != 0) {
if (this->_copyMode != 0) {
menu->addLine(STR_PASTE_BEFORE, [=]() {
uint8_t idx = button->getIndex();
pasteMixBefore(idx);
_copyMode = 0;
});
menu->addLine(STR_PASTE_AFTER, [=]() {
uint8_t idx = button->getIndex();
pasteMixAfter(idx);
_copyMode = 0;
});
}
menu->addLine(STR_INSERT_BEFORE, [=]() {
uint8_t idx = button->getIndex();
insertMix(ch, idx);
});
menu->addLine(STR_INSERT_AFTER, [=]() {
uint8_t idx = button->getIndex();
insertMix(ch, idx + 1);
});
menu->addLine(STR_COPY, [=]() {
this->_copyMode = COPY_MODE;
this->_copySrc = button;
});
menu->addLine(STR_MOVE, [=]() {
this->_copyMode = MOVE_MODE;
this->_copySrc = button;
});
}
menu->addLine(STR_MOVE, [=]() {
_copyMode = MOVE_MODE;
_copySrc = button;
});
menu->addLine(STR_DELETE, [=]() {
uint8_t idx = button->getIndex();
deleteMix(idx);
_copyMode = 0;
});
return 0;
});
@@ -429,6 +423,8 @@ void ModelMixesPage::newMix()
void ModelMixesPage::editMix(uint8_t channel, uint8_t index)
{
_copyMode = 0;
auto line = getLineByIndex(index);
if (!line) return;
@@ -446,6 +442,8 @@ void ModelMixesPage::editMix(uint8_t channel, uint8_t index)
void ModelMixesPage::insertMix(uint8_t channel, uint8_t index)
{
_copyMode = 0;
::insertMix(index, channel);
addLineButton(MIXSRC_CH1 + channel, index);
editMix(channel, index);
@@ -453,6 +451,8 @@ void ModelMixesPage::insertMix(uint8_t channel, uint8_t index)
void ModelMixesPage::deleteMix(uint8_t index)
{
_copyMode = 0;
auto group = getGroupByIndex(index);
if (!group) return;
@@ -481,8 +481,11 @@ void ModelMixesPage::pasteMix(uint8_t dst_idx, uint8_t channel)
addLineButton(dst_idx);
if (_copyMode == MOVE_MODE) {
deleteInput(src_idx);
src_idx = _copySrc->getIndex();
deleteMix(src_idx);
}
_copyMode = 0;
}
static int _mixChnFromIndex(uint8_t index)