bool CB_PasteTrack( struct WBlocks *wblock, struct WTracks *wtrack, struct WTracks *towtrack ){ struct Tracks *totrack; struct Tracks *track; Place *p1,p2; if(towtrack==NULL){ RError("Error in function CB_PasteTrack in file clipboard_track_paste.c; towtrack=NULL\n"); return false; } totrack=towtrack->track; track=wtrack->track; towtrack->notelength=wtrack->notelength; towtrack->fxwidth=wtrack->fxwidth; totrack->patch=track->patch; totrack->onoff=track->onoff; totrack->pan=track->pan; totrack->volume=track->volume; totrack->panonoff=track->panonoff; totrack->volumeonoff=track->volumeonoff; if(track->midi_instrumentdata!=NULL){ totrack->midi_instrumentdata=MIDI_CopyInstrumentData(track); } totrack->trackname=talloc_strdup(track->trackname); totrack->notes=NULL; totrack->stops=NULL; totrack->fxs=NULL; p1=PlaceGetFirstPos(); PlaceSetLastPos(wblock->block,&p2); CopyRange_notes(&totrack->notes,track->notes,p1,&p2); CopyRange_stops(&totrack->stops,track->stops,p1,&p2); CopyRange_fxs(&totrack->fxs,track->fxs,p1,&p2); LegalizeFXlines(wblock->block,totrack); LegalizeNotes(wblock->block,totrack); return true; }
static bool paste_track( struct WBlocks *wblock, struct WTracks *wtrack, struct WTracks *towtrack ) { struct Tracks *totrack = towtrack->track; struct Tracks *track = wtrack->track; Place *p1,p2; towtrack->notelength=wtrack->notelength; towtrack->fxwidth=wtrack->fxwidth; totrack->onoff=track->onoff; totrack->pan=track->pan; totrack->volume=track->volume; totrack->panonoff=track->panonoff; totrack->volumeonoff=track->volumeonoff; ATOMIC_SET(totrack->midi_channel, ATOMIC_GET(track->midi_channel)); if(track->midi_instrumentdata!=NULL){ totrack->midi_instrumentdata=MIDI_CopyInstrumentData(track); } totrack->trackname=talloc_strdup(track->trackname); totrack->notes=NULL; totrack->stops=NULL; VECTOR_clean(&totrack->fxs); p1=PlaceGetFirstPos(); PlaceSetLastPos(wblock->block,&p2); CopyRange_notes(&totrack->notes,track->notes,p1,&p2); CopyRange_stops(&totrack->stops,track->stops,p1,&p2); if (totrack->patch != NULL) CopyRange_fxs(&totrack->fxs,&track->fxs,p1,&p2); LegalizeFXlines(wblock->block,totrack); LegalizeNotes(wblock->block,totrack); return true; }
/* Argh. This one was difficult, I don`t think it works correctly in all situations yet either. */ void InsertLines( struct Blocks *block, int line, int toinsert ){ int lokke; struct LocalZooms *localzoom; struct Tracker_Windows *window=root->song->tracker_windows; struct WBlocks *wblock; struct Tracks *track=block->tracks; int num_lines=block->num_lines; if(line>num_lines+toinsert){ toinsert=line-num_lines; } if (line==num_lines-1) { // special case Block_Properties(block, block->num_tracks, block->num_lines + toinsert); return; } if( line<0 || line>=num_lines) return; if(toinsert==0 || num_lines+toinsert<2 || num_lines+toinsert>=MAX_UINT32) return; PC_Pause();{ blocktobelongtoforinsertlines_notes_a_terrible_hack=block; block->num_lines=num_lines+toinsert; List_InsertLines3(&block->temponodes,block->temponodes->l.next,line,toinsert,NULL); LegalizeTempoNodes(block); List_InsertLines3(&block->signatures,&block->signatures->l,line,toinsert,NULL); List_InsertLines3(&block->lpbs,&block->lpbs->l,line,toinsert,NULL); List_InsertLines3(&block->tempos,&block->tempos->l,line,toinsert,NULL); UpdateSTimes(block); UpdateBeats(block); while(track!=NULL){ List_InsertLines3(&track->notes,&track->notes->l,line,toinsert,InsertLines_notes); LegalizeNotes(block,track); List_InsertLines3(&track->stops,&track->stops->l,line,toinsert,NULL); VECTOR_FOR_EACH(struct FXs *fxs, &track->fxs){ List_InsertLines3(&fxs->fxnodelines,&fxs->fxnodelines->l,line,toinsert,NULL); }END_VECTOR_FOR_EACH; LegalizeFXlines(block,track); track=NextTrack(track); } while(window!=NULL){ wblock=ListFindElement1(&window->wblocks->l,block->l.num); List_InsertLines3( &wblock->localzooms, &wblock->localzooms->l, line, toinsert, InsertLines_localzooms // NULL ); for(lokke=line;lokke<line+toinsert;lokke++){ localzoom=talloc(sizeof(struct LocalZooms)); localzoom->Tline=lokke; localzoom->Tdividor=1; localzoom->zoomline=lokke; ListAddElement3(&wblock->localzooms,&localzoom->l); } UpdateWBlockWidths(window,wblock); wblock->reallines = NULL; // We changed the localzooms, which is used to set new curr_realline. We don't need to set new curr_realline, so just set reallines to NULL. UpdateRealLines(window,wblock); UpdateReallinesDependens(window,wblock); if(wblock->curr_realline>=wblock->num_reallines){ wblock->curr_realline=wblock->num_reallines-1; } window=NextWindow(window); } blocktobelongtoforinsertlines_notes_a_terrible_hack=NULL; }PC_StopPause(window); }
void Block_Set_num_lines( struct Blocks *block, int num_lines ){ Place lastplace1,lastplace; struct Tracker_Windows *window=root->song->tracker_windows; struct WBlocks *wblock; struct LocalZooms *localzoom; struct Tracks *track=block->tracks; struct Notes *note; struct FXs *fxs; int org_num_lines=block->num_lines; int lokke; if(org_num_lines==num_lines || num_lines<2) return; PlaceSetLastPos(block,&lastplace1); block->num_lines=num_lines; PlaceSetLastPos(block,&lastplace); if(num_lines<org_num_lines){ CutListAt_a(&block->lpbs,&lastplace); CutListAt_a(&block->tempos,&lastplace); CutListAt_a(&block->temponodes,&lastplace); PlaceSetLastPos(block,&block->lasttemponode->l.p); ListAddElement3(&block->temponodes,&block->lasttemponode->l); while(track!=NULL){ CutListAt_a(&track->notes,&lastplace); note=track->notes; while(note!=NULL){ CutListAt(¬e->velocities,&lastplace); CutListAt(¬e->pitches,&lastplace); if(PlaceEqual(¬e->end,&lastplace1) && note->noend==1){ PlaceCopy(¬e->end,&lastplace); } note=NextNote(note); } LegalizeNotes(block,track); CutListAt_a(&track->stops,&lastplace); fxs=track->fxs; while(fxs!=NULL){ CutListAt_a(&fxs->fxnodelines,&lastplace); fxs=NextFX(fxs); } LegalizeFXlines(block,track); track=NextTrack(track); } while(window!=NULL){ wblock=ListFindElement1(&window->wblocks->l,block->l.num); CutListAt_a(&wblock->localzooms,&lastplace); window=NextWindow(window); } }else{ PlaceSetLastPos(block,&block->lasttemponode->l.p); while(track!=NULL){ note=track->notes; while(note!=NULL){ if(PlaceEqual(¬e->end,&lastplace1) && note->noend==1){ PlaceSetLastPos(block,¬e->end); } note=NextNote(note); } LegalizeNotes(block,track); track=NextTrack(track); } while(window!=NULL){ wblock=ListFindElement1(&window->wblocks->l,block->l.num); for(lokke=org_num_lines;lokke<num_lines;lokke++){ localzoom=talloc(sizeof(struct LocalZooms)); localzoom->Tline=lokke; localzoom->Tdividor=1; localzoom->zoomline=lokke; ListAddElement3(&wblock->localzooms,&localzoom->l); } window=NextWindow(window); } } window=root->song->tracker_windows; while(window!=NULL){ wblock=ListFindElement1(&window->wblocks->l,block->l.num); UpdateWBlockWidths(window,wblock); UpdateRealLines(window,wblock); window=NextWindow(window); } UpdateSTimes(block); UpdateBeats(block); }