Example #1
0
void CB_PasteTrack_CurrPos(struct Tracker_Windows *window){
	struct WBlocks *wblock=window->wblock;
	struct Blocks *block=wblock->block;
	struct WTracks *wtrack=wblock->wtrack;
	Place lastplace;

	PlayStop();

	PlaceSetLastPos(wblock->block,&lastplace);

	switch(window->curr_track){
		case LPBTRACK:
			if(cb_lpb==NULL) return;
			Undo_LPBs_CurrPos(window);
			block->lpbs=CB_CopyLPBs(cb_lpb);
			CutListAt_a(&block->lpbs,&lastplace);
			UpdateSTimes(block);
                        UpdateBeats(block);
			UpdateWLPBs(window,wblock);
#if !USE_OPENGL
			DrawUpLPBs(window,wblock);
#endif
			break;
		case TEMPOTRACK:
			if(cb_tempo==NULL) return;
			Undo_Tempos_CurrPos(window);
			block->tempos=CB_CopyTempos(cb_tempo);
			CutListAt_a(&block->tempos,&lastplace);
			//UpdateWTempos(window,wblock);
#if !USE_OPENGL
			DrawUpTempos(window,wblock);
#endif
			UpdateSTimes(block);
			break;
		case TEMPONODETRACK:
			if(cb_temponode==NULL) return;
			Undo_TempoNodes_CurrPos(window);
			block->temponodes=CB_CopyTempoNodes(cb_temponode);
			CutListAt_a(&block->temponodes,&lastplace);
			LegalizeTempoNodes(block);
#if !USE_OPENGL
			UpdateWTempoNodes(window,wblock);
			DrawUpWTempoNodes(window,wblock);
#endif
			UpdateSTimes(block);
			break;
		default:
			if(cb_wtrack==NULL) return;
			Undo_Track_CurrPos(window);
			if(window->curr_track_sub==-1){
				if(CB_PasteTrack(wblock,cb_wtrack,wtrack)){
#if !USE_OPENGL
					UpdateFXNodeLines(window,wblock,wtrack);
#endif
					window->must_redraw = true;
				}else{
#if !USE_OPENGL
					UpdateAndClearSomeTrackReallinesAndGfxWTracks(
						window,
						wblock,
						window->curr_track,
						window->curr_track
					);
#endif
				}
			}else{
				if(CB_PasteTrackFX(wblock,cb_wtrack,wtrack)){
#if !USE_OPENGL
                                  UpdateFXNodeLines(window,wblock,wtrack);
#endif
					window->must_redraw = true;
				}else{
#if !USE_OPENGL
					UpdateAndClearSomeTrackReallinesAndGfxWTracks(
						window,
						wblock,
						window->curr_track,
						window->curr_track
					);
#endif
				}
			}
			break;
	}

        SetNoteSubtrackAttributes(wtrack->track);
        ValidateCursorPos(window);
}
Example #2
0
void CB_PasteTrack_CurrPos(struct Tracker_Windows *window){
	struct WBlocks *wblock=window->wblock;
	struct Blocks *block=wblock->block;
	struct WTracks *wtrack=wblock->wtrack;
	Place lastplace;

	PlaceSetLastPos(wblock->block,&lastplace);

        PC_Pause();
                  
	switch(window->curr_track){
		case SIGNATURETRACK:
                  if(cb_signature==NULL) goto exit;
			ADD_UNDO(Signatures_CurrPos(window));
			block->signatures=CB_CopySignatures(cb_signature);
			CutListAt_a(&block->signatures,&lastplace);
                        UpdateWBlockWidths(window, wblock);
                        UpdateBeats(block);
			//UpdateSTimes(block);
			//UpdateWLPBs(window,wblock);
			break;
		case LPBTRACK:
			if(cb_lpb==NULL) goto exit;
			ADD_UNDO(LPBs_CurrPos(window));
			block->lpbs=CB_CopyLPBs(cb_lpb);
			CutListAt_a(&block->lpbs,&lastplace);
			UpdateSTimes(block);
			//UpdateWLPBs(window,wblock);
                        UpdateBeats(block);
#if !USE_OPENGL
			DrawUpLPBs(window,wblock);
#endif
			break;
		case TEMPOTRACK:
			if(cb_tempo==NULL) goto exit;
			ADD_UNDO(Tempos_CurrPos(window));
			block->tempos=CB_CopyTempos(cb_tempo);
			CutListAt_a(&block->tempos,&lastplace);
			//UpdateWTempos(window,wblock);
#if !USE_OPENGL
			DrawUpTempos(window,wblock);
#endif
			UpdateSTimes(block);
			break;
		case TEMPONODETRACK:
			if(cb_temponode==NULL) goto exit;
			ADD_UNDO(TempoNodes_CurrPos(window));
			block->temponodes=CB_CopyTempoNodes(cb_temponode);
			CutListAt_a(&block->temponodes,&lastplace);
			LegalizeTempoNodes(block);
#if !USE_OPENGL
			///UpdateWTempoNodes(window,wblock);
			DrawUpWTempoNodes(window,wblock);
#endif
			UpdateSTimes(block);
			break;
		default:
			if(cb_wtrack==NULL) goto exit;

                        Undo_Open_rec();{
                          printf("curr_track_sub: %d\n",window->curr_track_sub);
                          ADD_UNDO(Track_CurrPos(window));
                          
                          if(window->curr_track_sub==-1 && cb_wtrack_only_contains_one_fxs==false){

                            // copy all
                            
                            printf("aaa\n");
                            if(co_CB_PasteTrack(wblock,cb_wtrack,wtrack)){
#if !USE_OPENGL
                              UpdateFXNodeLines(window,wblock,wtrack);
#endif
                              window->must_redraw = true;
                            }else{
#if !USE_OPENGL
                              UpdateAndClearSomeTrackReallinesAndGfxWTracks(
                                                                            window,
                                                                            wblock,
                                                                            window->curr_track,
                                                                            window->curr_track
                                                                            );
#endif
                            }
                          }else{
                            printf("bbb\n");

                            // only copy fx
                            
                            struct WTracks *fromwtrack = cb_wtrack;
                                                                                    
                            if (cb_wtrack_only_contains_one_fxs==true){

                              // only copy one fx
                              
                              R_ASSERT(cb_wtrack->track->fxs.num_elements==1);

                              struct FXs *fxs = cb_wtrack->track->fxs.elements[0];
                              
                              vector_t *fxss = VECTOR_copy(&wtrack->track->fxs);
                              remove_fxs_from_fxss(fxss, fxs);
                              
                              VECTOR_push_back(fxss, fxs);
                              
                              fromwtrack = CB_CopyTrack(wblock, cb_wtrack);
                              fromwtrack->track->fxs = *VECTOR_copy(fxss);
                            }
                            
                            if(co_CB_PasteTrackFX(wblock,fromwtrack,wtrack)){
#if !USE_OPENGL
                              UpdateFXNodeLines(window,wblock,wtrack);
#endif
                              window->must_redraw = true;
                            }else{
#if !USE_OPENGL
                              UpdateAndClearSomeTrackReallinesAndGfxWTracks(
                                                                            window,
                                                                            wblock,
                                                                            window->curr_track,
                                                                            window->curr_track
                                                                            );
#endif
                            }
                          }

                        }Undo_Close();
                        
			break;
	}

        SetNotePolyphonyAttributes(wtrack->track);
        ValidateCursorPos(window);


 exit:
        PC_StopPause(window);
}
void CB_PasteBlock(
	struct Tracker_Windows *window,
	struct WBlocks *wblock,
	struct WBlocks *towblock
){

  R_ASSERT(is_playing()==false);
  
	struct Blocks *block=wblock->block;
	struct Blocks *toblock=towblock->block;
	struct WTracks *towtrack=towblock->wtracks;
	struct WTracks *towtrack_wtrack=towblock->wtrack;
	struct Tracks *totrack=toblock->tracks;
	struct WTracks *wtrack;

	NInt wblocknum=towblock->l.num;
	struct ListHeader1 *nextwblock=towblock->l.next;

	NInt blocknum=toblock->l.num;
	struct ListHeader1 *nextblock=toblock->l.next;

        unsigned int org_color = toblock->color;
          
	NInt org_num_tracks=toblock->num_tracks;

	memcpy(towblock,wblock,sizeof(struct WBlocks));
	memcpy(toblock,block,sizeof(struct Blocks));

        toblock->color = org_color; // Don't want to paste color.
        
	towblock->l.next=nextwblock;
	towblock->l.num=wblocknum;

	towblock->block=toblock;
	towblock->wtracks=towtrack;
	towblock->wtrack=towtrack_wtrack;
	toblock->tracks=totrack;

	toblock->l.next=nextblock;
	toblock->l.num=blocknum;

        //printf("org num_tracks: %d, before: %d\n",org_num_tracks,toblock->num_tracks);

	toblock->num_tracks=org_num_tracks;

	Block_Set_num_tracks(toblock,block->num_tracks);
        TIME_everything_in_block_has_changed(towblock->block); // UpdateReallines requires updated time values (for whether to show swing type track or not).
        
	toblock->name=block->name;
        
	towblock->localzooms=NULL;
	CB_UnpackLocalZooms(&towblock->localzooms,wblock->localzooms,block->num_lines);
	//towblock->reallines=NULL;
        
	UpdateRealLines_dont_change_curr_realline(window, towblock);

	//towblock->wtempos=NULL;
	//towblock->wlpbs=NULL;

        toblock->swings=CB_CopySwings(block->swings, NULL);
        toblock->signatures=CB_CopySignatures(block->signatures);
	toblock->lpbs=CB_CopyLPBs(block->lpbs);

	toblock->tempos=CB_CopyTempos(block->tempos);
	toblock->temponodes=CB_CopyTempoNodes(block->temponodes);
	toblock->lasttemponode=(struct TempoNodes *)ListLast3(&toblock->temponodes->l);

	UpdateReallinesDependens(window,towblock);

	wtrack=wblock->wtracks;
	towtrack=towblock->wtracks;
	while(wtrack!=NULL){
		if(towtrack==NULL){
			RError("Error in funtion CB_PasteBlock in file clipboard_block_paste.c; towtrack=NULL\n");
			break;
		}
		if(towtrack->l.num!=wtrack->l.num){
			RError("Error in funtion CB_PasteBlock in file clipboard_block_paste.c; towtrack->l.num!=wtrack->l.num\n");
			break;
		}

		co_CB_PasteTrack(towblock,wtrack,towtrack);
		towtrack=NextWTrack(towtrack);
		wtrack=NextWTrack(wtrack);
	}

	if(towtrack!=NULL){
		RError("Error in funtion CB_PasteBlock in file clipboard_block_paste.c; towtrack!=NULL when wtrack==NULL\n");
	}

        g_editor_blocks_generation++;
	BS_UpdateBlockList();
	BS_UpdatePlayList();
}