move samplees to other buttons

This commit is contained in:
mrbesen 2021-12-25 14:26:19 +01:00
parent 9944959d8f
commit e4cd81e811
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 31 additions and 0 deletions

View File

@ -407,6 +407,7 @@ void SampleItem::moveUp() {
setExpanded(wasexpanded);
pos--;
updatePosition();
}
void SampleItem::moveDown() {
@ -462,8 +463,38 @@ void SampleItem::moveToButtonAbove() {
pos = newbuttonconf.size()-1;
setExpanded(wasExpanded);
mparent->setExpanded(true);
updatePosition();
}
void SampleItem::moveToButtonBelow() {
ButtonItem* buttonbelow = getParent<ButtonItem>()->getItemBelow<ButtonItem>();
if(!buttonbelow) {
buttonbelow = getParent<ButtonItem>()->getParent<RowItem>()->getItemBelow<RowItem>()->getChild<ButtonItem>(0);
}
// apply change in config
auto& buttonConf = getParent<ButtonItem>()->getConfig().samples;
auto& newButtonconf = buttonbelow->getConfig().samples;
newButtonconf.insert(newButtonconf.begin(), buttonConf.back());
buttonConf.erase(buttonConf.end());
// remove button from this row and attach to other
bool wasExpanded = isExpanded();
getParent<ButtonItem>()->removeChild(this);
buttonbelow->insertChild(0, this);
//update local parent
mparent = buttonbelow;
//update local pos
pos = 0;
//update new buttons below
reenumerateAllSiblings();
setExpanded(wasExpanded);
mparent->setExpanded(true);
}