forked from MrBesen/soundboard
move samplees to other buttons
This commit is contained in:
parent
9944959d8f
commit
e4cd81e811
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue