void DeleteBlock_CurrPos( struct Tracker_Windows *window ){ struct WBlocks *wblock=window->wblock; NInt blockpos; PlayStop(); if(wblock->l.next==NULL && wblock==window->wblocks) return; blockpos=window->wblock->l.num; Undo_Block_Delete(blockpos); DeleteBlock(blockpos); wblock=ListFindElement1_r0(&window->wblocks->l,blockpos); if(wblock==NULL){ wblock=ListLast1(&window->wblocks->l); } SelectWBlock(window,wblock); BS_UpdateBlockList(); BS_UpdatePlayList(); }
// Simpler version when using opengl void P2MUpdateSongPosCallBack(void){ bool setfirstpos=ATOMIC_GET(root->setfirstpos); NInt curr_block_num = ATOMIC_GET(root->curr_blocknum); struct Tracker_Windows *window=root->song->tracker_windows; struct WBlocks *wblock = ListFindElement1(&window->wblocks->l,curr_block_num); int old_curr_realline = wblock->curr_realline; int till_curr_realline = R_BOUNDARIES(0, ATOMIC_GET(wblock->till_curr_realline), wblock->num_reallines-1); // till_curr_realline can be set from any thread, at any time, to any value. if (!ATOMIC_GET(root->play_cursor_onoff)){ //printf("P2MUpdateSongPosCallBack: Setting to %d\n",till_curr_realline); wblock->curr_realline = till_curr_realline; wblock->top_realline += till_curr_realline - old_curr_realline; wblock->bot_realline += till_curr_realline - old_curr_realline; } if(pc->playtype==PLAYSONG) BS_SelectPlaylistPos(ATOMIC_GET2(root->curr_playlist)); if(window->curr_block!=curr_block_num){ //printf("Bef. w: %d, r: %d\n",window->curr_block,root->curr_block); if(setfirstpos){ wblock->curr_realline=0; SetWBlock_Top_And_Bot_Realline(window,wblock); GE_set_curr_realline(0); } SelectWBlock( window, wblock ); //printf("Aft. w: %d, r: %d\n",window->curr_block,root->curr_block); } // make sure "Rec" is updated { static struct Tracks *current_track = NULL; static bool current_track_recording = false; struct Tracks *track = wblock->wtrack->track; if (track != current_track || (current_track!=NULL && track->is_recording != current_track_recording)){ current_track = track; current_track_recording = current_track->is_recording; GL_create(window, wblock); } } //GE_set_curr_realline(wblock->curr_realline); // printf("till_curr_realline: %d\n",wblock->till_curr_realline); //ScrollEditorToRealLine(window,wblock,wblock->curr_realline); }
void CB_PasteBlock_CurrPos( struct Tracker_Windows *window ){ if(cb_wblock==NULL) return; PC_Pause();{ ADD_UNDO(Block_CurrPos(window)); CB_PasteBlock(window,cb_wblock,window->wblock); SelectWBlock(window,window->wblock); }PC_StopPause(window); }
struct Blocks *InsertBlock_CurrPos( struct Tracker_Windows *window ) { struct WBlocks *wblock=window->wblock; NInt blockpos=wblock->l.num; ADD_UNDO(Block_Insert(blockpos)); struct Blocks *ret; PC_Pause();{ ret = InsertBlock(blockpos,wblock->block->num_tracks,wblock->block->num_lines,"NN"); SelectWBlock(window,(struct WBlocks *)ListFindElement1(&window->wblocks->l,blockpos)); BS_UpdateBlockList(); BS_UpdatePlayList(); }PC_StopPause(window); return ret; }
void P2MUpdateSongPosCallBack(void){ struct Tracker_Windows *window=root->song->tracker_windows; bool setfirstpos=ATOMIC_GET(root->setfirstpos); NInt curr_block=ATOMIC_GET(root->curr_blocknum); struct WBlocks *wblock; int till_curr_realline; if(scrolls_per_second==-1) scrolls_per_second = SETTINGS_read_int("scrolls_per_second", default_scrolls_per_second); if(pc->playtype==PLAYSONG) BS_SelectPlaylistPos(root->curr_playlist); while(window!=NULL){ if(window->playalong==true){ DO_GFX({ wblock=ListFindElement1(&window->wblocks->l,curr_blocknum); till_curr_realline=ATOMIC_GET(wblock->till_curr_realline); if(window->curr_block!=curr_block){ if(setfirstpos){ wblock->curr_realline=0; SetWBlock_Top_And_Bot_Realline(window,wblock); } SelectWBlock( window, wblock ); } if(setfirstpos){ // The player routine (PEQblock.c) sets this one. ATOMIC_SET(wblock->till_curr_realline, 0); till_curr_realline=0; } //fprintf(stderr,"tilline: %d\n",till_curr_realline); #if 0 if(wblock->curr_realline != till_curr_realline) ScrollEditorToRealLine(window,wblock,till_curr_realline); #else { bool do_scrolling = false; if(wblock != last_wblock) do_scrolling = true; else if (last_time > ATOMIC_GET(pc->therealtime)) do_scrolling = true; else if(till_curr_realline < wblock->curr_realline) do_scrolling = true; else if(till_curr_realline > wblock->curr_realline){ STime from_time = (STime) ((double)Place2STime(wblock->block, &wblock->reallines[wblock->curr_realline]->l.p) / wblock->block->reltempo); STime to_time = (STime) ((double)Place2STime(wblock->block, &wblock->reallines[till_curr_realline]->l.p) / wblock->block->reltempo); STime time = to_time - from_time; STime time_necessary_to_scroll = pc->pfreq / scrolls_per_second; if(time>=time_necessary_to_scroll) do_scrolling = true; } if(do_scrolling==true) { ScrollEditorToRealLine(window,wblock,till_curr_realline); last_time = ATOMIC_GET(pc->therealtime); last_wblock = wblock; } } #endif }); }