feat(inserts): copy and paste chains between tracks (phase 92)
This commit is contained in:
parent
062b33f55f
commit
58f0dc51c5
5 changed files with 40 additions and 4 deletions
|
|
@ -1405,6 +1405,7 @@ xtc_result MainWindow::install_project(xtc_project *candidate, bool reset_histor
|
|||
if (reset_history) {
|
||||
history_.swap(new_history);
|
||||
for(auto &snapshot:mix_snapshots_)snapshot.reset();
|
||||
if(track_inserts_)track_inserts_->clear_session();
|
||||
}
|
||||
graph_widget_->reset_layout();
|
||||
graph_widget_->set_graph(xtc_project_graph(candidate));
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ class TrackInsertsPanel : public Fl_Group {
|
|||
xtc_graph *model_=nullptr;
|
||||
uint64_t track_=UINT64_MAX;
|
||||
xtc_track_chain cached_{};
|
||||
xtc_track_chain clipboard_{};
|
||||
bool clipboard_ready_=false;
|
||||
std::vector<uint64_t> ids_;
|
||||
std::vector<std::string> names_;
|
||||
void result(xtc_result r) { if(r!=XTC_OK)owner_->report_error("Track inserts",r);refresh(true); }
|
||||
|
|
@ -51,6 +53,8 @@ class TrackInsertsPanel : public Fl_Group {
|
|||
gain_=new Fl_Value_Input(x+360,y+52,100,26,"Chain gain");gain_->bounds(0,4);gain_->step(.01);gain_->when(FL_WHEN_RELEASE);
|
||||
for(auto *input:{wet_,gain_})input->callback([](Fl_Widget *,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);p->result(p->set_mix(p->wet_->value(),p->gain_->value()));},this);
|
||||
actions_=new Fl_Menu_Button(x+486,y+52,150,26,"Rack actions");
|
||||
actions_->add("Copy chain",0,[](Fl_Widget *,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);p->result(p->copy_chain());},this);
|
||||
actions_->add("Paste chain (replace)",0,[](Fl_Widget *,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);p->result(p->paste_chain());},this,FL_MENU_INACTIVE);
|
||||
actions_->add("Duplicate effect",0,[](Fl_Widget *,void *c){auto *p=static_cast<TrackInsertsPanel *>(c);p->result(p->duplicate_slot());},this);
|
||||
message_=new Fl_Box(x+16,y+84,w-32,30,"Track input > inserts > output gain > track fader > bus/master");message_->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
|
||||
slots_=new Fl_Hold_Browser(x+16,y+126,230,h-142);slots_->format_char(0);slots_->callback([](Fl_Widget *,void *c){static_cast<TrackInsertsPanel *>(c)->update_mix();},this);
|
||||
|
|
@ -64,6 +68,20 @@ class TrackInsertsPanel : public Fl_Group {
|
|||
void select_track(uint64_t id) {track_=id;refresh(true);}
|
||||
const xtc_graph *graph() const {return model_;}
|
||||
void add(const char *file,unsigned int index) { result(owner_->add_track_effect(track_,file,index)); }
|
||||
void clear_session() {clipboard_={};clipboard_ready_=false;update_actions();}
|
||||
bool clipboard_ready() const {return clipboard_ready_;}
|
||||
void update_actions() {
|
||||
int index=actions_->find_index("Paste chain (replace)");
|
||||
if(index>=0)actions_->mode(index,clipboard_ready_ ? 0 : FL_MENU_INACTIVE);
|
||||
}
|
||||
xtc_result copy_chain() {
|
||||
xtc_track_chain chain{};auto r=xtc_project_get_chain(owner_->project_.get(),track_,&chain);
|
||||
if(r==XTC_OK){clipboard_=chain;clipboard_ready_=true;update_actions();}return r;
|
||||
}
|
||||
xtc_result paste_chain() {
|
||||
if(!clipboard_ready_)return XTC_ERR_NOT_FOUND;
|
||||
return owner_->set_track_chain(track_,clipboard_);
|
||||
}
|
||||
xtc_result duplicate_slot() {
|
||||
xtc_track_chain chain{};auto r=xtc_project_get_chain(owner_->project_.get(),track_,&chain);size_t index=selected_slot();
|
||||
if(r==XTC_OK)r=xtc_track_chain_duplicate(&chain,index,&chain);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue