bool SWINGTEXT_keypress(struct Tracker_Windows *window, struct WBlocks *wblock, struct WTracks *wtrack, int realline, const Place *place, int key){ int subsubtrack = SWINGTEXT_subsubtrack(window, wtrack); if (subsubtrack==-1) return false; struct Blocks *block = wblock->block; struct Tracks *track = wtrack==NULL ? NULL : wtrack->track; QVector<Swing*> swings = Swings_get(wblock, track, realline); if (swings.size() == 0) { // NO ELEMENTS if (key == EVENT_DEL) return true; data_as_text_t dat = DAT_get_newvalue(subsubtrack, key, 1, LOGTYPE_HOLD, 1, 99, 1, 99, false, true, false); if (dat.is_valid==false) return false; ADD_UNDO(Swings_CurrPos(window)); AddSwing(block, track, *place, dat.value, dat.logtype); } else { // ONE ELEMENT (or more than one element) struct Swing *swing = swings.last(); if (key == EVENT_DEL) { ADD_UNDO(Swings_CurrPos(window)); RemoveSwing(block, track, swing); } else { data_as_text_t dat = DAT_get_overwrite(swing->weight, swing->logtype, subsubtrack, key, 1, 99, 1, 99, false, false); if (dat.is_valid==false) return false; if (dat.value==swing->weight && dat.logtype==swing->logtype) return true; // I.e. although the user didn't change anything, the key was valid so we still eat it (by returning true instead of false). ADD_UNDO(Swings_CurrPos(window)); AddSwing(block, track, swing->l.p, dat.value, dat.logtype); } } return true; }
void AddVelocityCurrPos(struct Tracker_Windows *window){ struct WBlocks *wblock=window->wblock; struct LocalZooms *realline= wblock->reallines[wblock->curr_realline]; int subtrack=window->curr_track_sub; if(-1==subtrack) return; ADD_UNDO(Notes_CurrPos(window)); struct Notes *note = FindNoteOnSubTrack( wblock->wtrack, subtrack, &realline->l.p ); if(note==NULL) return; AddVelocity( root->standardvel, &realline->l.p, note ); #if !USE_OPENGL ClearTrack(window,wblock,wblock->wtrack,wblock->top_realline,wblock->bot_realline); UpdateWTrack(window,wblock,wblock->wtrack,wblock->top_realline,wblock->bot_realline); #endif }
void InsertTracks_CurrPos( struct Tracker_Windows *window, NInt toinsert ){ struct WBlocks *wblock; NInt curr_track; curr_track=window->curr_track; if(curr_track<0) return; ADD_UNDO(Block_CurrPos(window)); wblock=window->wblock; InsertTracks(window,wblock,curr_track,toinsert); if(curr_track>=wblock->block->num_tracks){ curr_track=wblock->block->num_tracks-1; } SetCursorPosConcrete(window,wblock,0,-1); #if !USE_OPENGL UpdateAllFXNodeLines(window,wblock); #endif SetCursorPosConcrete(window,wblock,curr_track,-1); window->must_redraw = true; }
void CutRange_CurrPos( struct Tracker_Windows *window ){ struct WBlocks *wblock = window->wblock; if( ! window->wblock->isranged) return; CopyRange(wblock); wblock->isranged=true; ADD_UNDO(Range( window, window->wblock, window->wblock->rangex1, window->wblock->rangex2, window->wblock->curr_realline )); Undo_start_ignoring_undo_operations();{ CutRangedRange(wblock); }Undo_stop_ignoring_undo_operations(); UpdateAndClearSomeTrackReallinesAndGfxWTracks( window, wblock, wblock->rangex1, wblock->rangex2 ); window->must_redraw = true; }
void pasteTrack(int tracknum, int blocknum, int windownum){ if (tracknum==-1 && blocknum==-1){ struct Tracker_Windows *window=getWindowFromNum(windownum);if(window==NULL) return; CB_PasteTrack_CurrPos(window); return; } struct Tracker_Windows *window=NULL; struct WTracks *wtrack; struct WBlocks *wblock; wtrack=getWTrackFromNumA( windownum, &window, blocknum, &wblock, tracknum ); if(wtrack==NULL) return; if (cb_wtrack != NULL) { Undo_Open_rec();{ ADD_UNDO(Track(window, wblock, wtrack, wblock->curr_realline)); co_CB_PasteTrack(wblock, cb_wtrack, wtrack); }Undo_Close(); } window->must_redraw = true; }
void Glissando_CurrPos(struct Tracker_Windows *window){ struct WBlocks *wblock=window->wblock; struct WTracks *wtrack=wblock->wtrack; struct Notes *note=wtrack->track->notes; struct Notes *nextnote; int realline = wblock->curr_realline; const Place *p=&wblock->reallines[realline]->l.p; while(note!=NULL){ nextnote=NextNote(note); if(nextnote==NULL) return; if(PlaceIsBetween2(p,¬e->l.p,&nextnote->l.p)){ ADD_UNDO(Notes(window, wblock->block, wtrack->track, realline)); Glissando(wblock,wtrack,note); /* UpdateAndClearSomeTrackReallinesAndGfxWTracks( window, wblock, wtrack->l.num, wtrack->l.num ); */ return; } note=nextnote; } }
void RemoveNoteCurrPos(struct Tracker_Windows *window){ struct WBlocks *wblock = window->wblock; struct WTracks *wtrack = wblock->wtrack; struct Tracks *track = wtrack->track; struct LocalZooms *realline = wblock->reallines[wblock->curr_realline]; int curr_realline = wblock->curr_realline; const Trs &trs = TRS_get(wblock, wtrack, curr_realline); ADD_UNDO(Notes_CurrPos(window)); if (trs.size()==0) { InsertStop(window,wblock,wtrack,&realline->l.p); maybe_scroll_down(window); return; } const TrackRealline2 &tr2 = trs[0]; if (tr2.pitch != NULL) { DeletePitch(track, tr2.note, tr2.pitch); if (trs.size()==1) maybe_scroll_down(window); return; } if (tr2.is_end_pitch) { struct Pitches *pitch = (struct Pitches*)ListLast3(&tr2.note->pitches->l); if (pitch!=NULL) tr2.note->pitch_end = pitch->note; else tr2.note->pitch_end = 0; return; } if (tr2.note != NULL) { PLAYER_lock();{ ListRemoveElement3(&track->notes,&tr2.note->l); LengthenNotesTo(wblock->block,track,&realline->l.p); }PLAYER_unlock(); SetNotePolyphonyAttributes(wtrack->track); ValidateCursorPos(window); if (trs.size()==1) maybe_scroll_down(window); return; } const struct Stops *stop = tr2.stop; PLAYER_lock();{ ListRemoveElement3(&track->stops, &stop->l); LengthenNotesTo(wblock->block,track,&realline->l.p); }PLAYER_unlock(); if (trs.size()==1) maybe_scroll_down(window); }
void InsertNoteCurrPos(struct Tracker_Windows *window, float notenum, bool polyphonic, float velocity){ if(notenum<0.001 || notenum>127.9) return; ADD_UNDO(Notes_CurrPos(window)); struct WBlocks *wblock = window->wblock; struct WTracks *wtrack = wblock->wtrack; struct Tracks *track = wtrack->track; int curr_realline = wblock->curr_realline; const Trs &trs = TRS_get(wblock, wtrack, curr_realline); if (polyphonic==false && trs.size() > 0) { const TrackRealline2 &tr2 = trs[0]; if (tr2.pitch != NULL) { tr2.pitch->note = notenum; // lock not necessary maybe_scroll_down(window); return; } if (tr2.note != NULL) { // lock not necessary if (tr2.is_end_pitch) tr2.note->pitch_end = notenum; else tr2.note->note = notenum; maybe_scroll_down(window); return; } const struct Stops *stop = tr2.stop; PLAYER_lock();{ ListRemoveElement3(&track->stops, &stop->l); }PLAYER_unlock(); } struct LocalZooms *realline = wblock->reallines[curr_realline]; InsertNote( wblock,wtrack,&realline->l.p,NULL,notenum, velocity < 0.0 ? NOTE_get_velocity(wtrack->track) : velocity*MAX_VELOCITY, polyphonic ); if(wtrack->l.num==wblock->right_track && polyphonic) UpdateAllWTracksCoordinates(window,wblock); if (!polyphonic) maybe_scroll_down(window); }
void TRACK_make_monophonic_destructively(struct Tracks *track){ struct Tracker_Windows *window = root->song->tracker_windows; struct WBlocks *wblock = window->wblock; struct Notes *note = track->notes; bool have_made_undo = false; while(note!=NULL){ struct Notes *next = NextNote(note); if (next==NULL) break; if (PlaceGreaterThan(¬e->end, &next->l.p)){ PLAYER_lock();{ if (PlaceEqual(¬e->l.p, &next->l.p)) { ListRemoveElement3(&track->notes, &next->l); } else { PlaceCopy(¬e->end, &next->l.p); note = next; } }PLAYER_unlock(); if (have_made_undo==false){ ADD_UNDO(Notes(window, wblock->block, track, wblock->curr_realline ) ); have_made_undo = true; } } else { note = next; } } if (have_made_undo==false) GFX_Message(NULL, "Track is already monophonic"); else window->must_redraw = true; }
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); }
void setMainBPM(int bpm_value){ if (bpm_value <=1) return; if (bpm_value == root->tempo) return; struct Tracker_Windows *window = root->song->tracker_windows; struct WBlocks *wblock = window->wblock; ADD_UNDO(MainTempo(window,wblock)); PC_Pause();{ root->tempo=bpm_value; UpdateAllSTimes(); }PC_StopPause(window); }
void InvertTrack_CurrPos( struct Tracker_Windows *window ){ ADD_UNDO(Notes_CurrPos(window)); InvertTrack(window->wblock->block,window->wblock->wtrack->track); UpdateAndClearSomeTrackReallinesAndGfxWTracks( window, window->wblock, window->wblock->wtrack->l.num, window->wblock->wtrack->l.num ); }
void setNoteContinueNextBlock(bool continuenextblock, int notenum, int tracknum, int blocknum, int windownum){ struct Tracker_Windows *window; struct WBlocks *wblock; struct WTracks *wtrack; struct Notes *note = getNoteFromNumA(windownum, &window, blocknum, &wblock, tracknum, &wtrack, notenum); if (note==NULL) return; ADD_UNDO(Notes(window, wblock->block, wtrack->track, wblock->curr_realline ) ); note->noend = continuenextblock?1:0; }
void setMainSignature(int numerator, int denominator){ if (numerator<=0 || denominator<=0) return; if (numerator==root->signature.numerator && denominator==root->signature.denominator) return; struct Tracker_Windows *window = root->song->tracker_windows; struct WBlocks *wblock = window->wblock; ADD_UNDO(MainTempo(window,wblock)); PC_Pause();{ root->signature = ratio(numerator, denominator); UpdateAllBeats(); }PC_StopPause(window); window->must_redraw = true; }
void TransposeTrack_CurrPos( struct Tracker_Windows *window, int trans ){ ADD_UNDO(Notes_CurrPos(window)); TransposeTrack(window->wblock->wtrack->track,trans); UpdateAndClearSomeTrackReallinesAndGfxWTracks( window, window->wblock, window->wblock->wtrack->l.num, window->wblock->wtrack->l.num ); }
void TransposeNote_CurrPos( struct Tracker_Windows *window, int trans ){ struct Notes *note = FindNoteCurrPos(window); if (note==NULL) return; ADD_UNDO(Notes_CurrPos(window)); Transpose_note(note,trans); UpdateAndClearSomeTrackReallinesAndGfxWTracks( window, window->wblock, window->wblock->wtrack->l.num, window->wblock->wtrack->l.num ); }
void TransposeRange_CurrPos( struct Tracker_Windows *window, int trans ){ if(!window->wblock->isranged) return; ADD_UNDO(Range(window,window->wblock,window->wblock->rangex1,window->wblock->rangex2,window->wblock->curr_realline)); TransposeRange(window->wblock,trans); UpdateAndClearSomeTrackReallinesAndGfxWTracks( window, window->wblock, window->wblock->rangex1, window->wblock->rangex2 ); }
void IncreaseVelocityCurrPos(struct Tracker_Windows *window,int inc){ inc = inc * MAX_VELOCITY / 100; struct WBlocks *wblock=window->wblock; struct WTracks *wtrack=wblock->wtrack; if(is_track_ranged(wblock,wtrack) && is_realline_ranged(wblock,wblock->curr_realline)){ vector_t *notes = get_all_ranged_notes(wblock); //printf("num_elements: %d\n",notes->num_elements); if(notes->num_elements==0) return; ADD_UNDO(Block_CurrPos(window)); VECTOR_FOR_EACH(struct Notes *, note, notes){ increase_note_velocity(note, inc); }END_VECTOR_FOR_EACH;
void setMainLPB(int lpb_value){ if (lpb_value <=1) return; if (lpb_value == root->lpb) return; struct Tracker_Windows *window = root->song->tracker_windows; struct WBlocks *wblock = window->wblock; printf("Undo MainTempo lpb: %d\n",lpb_value); ADD_UNDO(MainTempo(window,wblock)); PC_Pause();{ root->lpb=lpb_value; UpdateAllSTimes(); UpdateAllBeats(); }PC_StopPause(window); //UpdateAllWLPBs(window); window->must_redraw = true; }
void InvertBlock_CurrPos( struct Tracker_Windows *window ){ ADD_UNDO(Range( window, window->wblock, 0,window->wblock->block->num_tracks-1, window->wblock->curr_realline )); InvertBlock(window->wblock->block); UpdateAndClearSomeTrackReallinesAndGfxWTracks( window, window->wblock, 0, window->wblock->block->num_tracks-1 ); }
void TransposeBlock_CurrPos( struct Tracker_Windows *window, int trans ){ ADD_UNDO(Range( window, window->wblock, 0,window->wblock->block->num_tracks-1, window->wblock->curr_realline )); TransposeBlock(window->wblock->block,trans); UpdateAndClearSomeTrackReallinesAndGfxWTracks( window, window->wblock, 0, window->wblock->block->num_tracks-1 ); }
int addLPB(int lpb_value, Place place, int blocknum) { struct Tracker_Windows *window; struct WBlocks *wblock=getWBlockFromNumA(-1,&window,blocknum); if(wblock==NULL) return -1; if (!PlaceLegal(wblock->block, &place)) { GFX_Message(NULL, "Place %s is not legal", PlaceToString(&place)); return -1; } ADD_UNDO(LPBs_CurrPos(window)); struct LPBs *lpb = SetLPB(wblock->block,&place,lpb_value); window->must_redraw=true; return ListFindElementPos3(&wblock->block->lpbs->l,&lpb->l); }
int addBPM(int bpm, Place place, int blocknum) { struct Tracker_Windows *window; struct WBlocks *wblock=getWBlockFromNumA(-1,&window,blocknum); if(wblock==NULL) return -1; if (!PlaceLegal(wblock->block, &place)) { GFX_Message(NULL, "Place %s is not legal", PlaceToString(&place)); return -1; } ADD_UNDO(Tempos_CurrPos(window)); struct Tempos *tempo = SetTempo(wblock->block,&place,bpm); window->must_redraw=true; return ListFindElementPos3(&wblock->block->tempos->l,&tempo->l); }
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 InsertLines_CurrPos( struct Tracker_Windows *window, int toinsert ){ struct WBlocks *wblock=window->wblock; int curr_realline=wblock->curr_realline; int curr_line=wblock->reallines[curr_realline]->Tline; int num_lines=wblock->block->num_lines; if(toinsert==0) toinsert=GFX_GetInteger(window,NULL,"Number of lines to insert\n(number can be negative): ",-(num_lines-curr_line),10000); if(toinsert==-(num_lines-curr_line)-1) return; ADD_UNDO(Block_CurrPos(window)); InsertLines(window->wblock->block,curr_line,toinsert); window=root->song->tracker_windows; while(window!=NULL){ window->must_redraw = true; window=NextWindow(window); } }
int addSignature(int numerator, int denominator, Place place, int blocknum) { struct Tracker_Windows *window; struct WBlocks *wblock=getWBlockFromNumA(-1,&window,blocknum); if(wblock==NULL) { GFX_Message(NULL, "unknown block(%p)",blocknum); return -1; } if (!PlaceLegal(wblock->block, &place)) { GFX_Message(NULL, "Place %s is not legal", PlaceToString(&place)); return -1; } ADD_UNDO(Signatures_CurrPos(window)); struct Signatures *signature = SetSignature(wblock->block,&place,ratio(numerator, denominator)); window->must_redraw=true; return ListFindElementPos3(&wblock->block->signatures->l,&signature->l); }
void StopVelocityCurrPos(struct Tracker_Windows *window,int noend){ struct WBlocks *wblock; struct WTracks *wtrack; int reallinerealline; struct LocalZooms *realline; struct Notes *note; int subtrack; wblock=window->wblock; wtrack=wblock->wtrack; reallinerealline=wblock->curr_realline; realline=wblock->reallines[reallinerealline]; subtrack=window->curr_track_sub; note=FindNoteOnSubTrack(wtrack,subtrack,&realline->l.p); if(note==NULL) return; ADD_UNDO(Notes_CurrPos(window)); PLAYER_lock();{ if(PlaceGreaterOrEqual(¬e->l.p,&realline->l.p)){ RemoveNote(wblock->block,wtrack->track,note); SetNotePolyphonyAttributes(wtrack->track); ValidateCursorPos(window); }else{ CutNoteAt(wblock->block, wtrack->track, note, &realline->l.p); } note->noend=noend; }PLAYER_unlock(); window->must_redraw=true; }
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 TRACK_split_into_monophonic_tracks(struct Tracker_Windows *window, struct WBlocks *wblock, struct WTracks *wtrack){ PlayStop(); // This function is too chaotic. Don't bother pausing player. vector_t notesvector = {0}; struct Tracks *track = wtrack->track; struct Notes *notes = track->notes; struct Notes *notes_nexttrack = NULL; bool have_made_undo = false; if (NOTES_sorted_by_pitch_questionmark(track->notes)==false) { ADD_UNDO(Block_CurrPos(window)); have_made_undo = true; notes = NOTES_sort_by_pitch(notes); } while(notes != NULL){ struct Notes *notes_root = notes; while(notes != NULL) { struct Notes *next = NextNote(notes); if (next==NULL) break; if (PlaceGreaterThan(¬es->end, &next->l.p)){ if (have_made_undo==false) { have_made_undo=true; } ListRemoveElement3(¬es, &next->l); ListAddElement3_a(¬es_nexttrack, &next->l); } else notes = next; } VECTOR_push_back(¬esvector, notes_root); notes = notes_nexttrack; notes_nexttrack = NULL; } if (have_made_undo==false){ GFX_Message(NULL, "Track is already monophonic"); return; } int num_tracks = notesvector.num_elements; track->notes = NULL; struct WTracks *wtrack_copy = CB_CopyTrack(wblock,wtrack); VECTOR_clean(&wtrack_copy->track->fxs); InsertTracks(window, wblock, wtrack->l.num+1, num_tracks-1); printf("Vector length: %d\n",num_tracks); int i; for(i=0;i<num_tracks;i++){ struct Notes *notes = notesvector.elements[i]; printf(" %d: %d\n", i, ListFindNumElements3(¬es->l)); while(notes != NULL){ printf(" %s\n",NotesTexts3[(int)notes->note]); notes = NextNote(notes); } struct WTracks *towtrack = ListFindElement1(&wblock->wtracks->l, wtrack->l.num+i); if (i>0) co_CB_PasteTrack(wblock, wtrack_copy, towtrack); towtrack->track->notes = notesvector.elements[i]; } window->must_redraw = true; }
bool FXTEXT_keypress(struct Tracker_Windows *window, struct WBlocks *wblock, struct WTracks *wtrack, int realline, Place *place, int key){ struct FXs *fxs; int subsubtrack = FXTEXT_subsubtrack(window, wtrack, &fxs); if (subsubtrack==-1) return false; struct FX *fx = fxs->fx; //printf("FXmin: %d, fxmax: %d\n",fx->min, fx->max); const FXText_trss &fxtexts = FXTEXTS_get(wblock, wtrack, fxs); const FXText_trs &fxtext = fxtexts[realline]; // if (fxtext->num_elements == 0 && val==0) // return true; ADD_UNDO(FXs(window, wblock->block, wtrack->track, wblock->curr_realline)); if (fxtext.size() > 1){ // MORE THAN ONE ELEMENT if (key == EVENT_DEL){ for (auto vt : fxtext) { if (VECTOR_is_in_vector(&wtrack->track->fxs, fxs) && isInList3(&fxs->fxnodelines->l, &vt.fxnodeline->l)) // We might have removed all nodes already (see line below) DeleteFxNodeLine(window, wtrack, fxs, vt.fxnodeline); // In this line, two nodes are removed if there's only two left. } } else { Undo_CancelLastUndo(); } } else if (fxtext.size() == 0){ // NO ELEMENTS if (fx == NULL){ fprintf(stderr, "Can this happen?\n"); Undo_CancelLastUndo(); } else { data_as_text_t dat = DAT_get_newvalue(subsubtrack, key, round(scale_double(0x80, 0, 0x100, fx->min, fx->max)), fx->min, fx->max, true); if (dat.value > fx->max) dat.value = fx->max; if (dat.is_valid==false) return false; int pos = AddFXNodeLine(window, wblock, wtrack, fxs, dat.value, place); struct FXNodeLines *fxnodeline = (struct FXNodeLines*)ListFindElement1_num(&fxs->fxnodelines->l, pos); fxnodeline->logtype = dat.logtype; } } else { // ONE ELEMENT const FXText &vt = fxtext.at(0); struct FXNodeLines *fxnodeline = vt.fxnodeline; if (key == EVENT_DEL) { if (subsubtrack == 2) fxnodeline->logtype = LOGTYPE_LINEAR; else DeleteFxNodeLine(window, wtrack, fxs, fxnodeline); } else { data_as_text_t dat = DAT_get_overwrite(vt.value, vt.logtype, subsubtrack, key, fx->min, fx->max, true, true); printf("fx->min: %x, fx->max: %x, vt.value: %x, dat.value: %x\n",fx->min,fx->max,vt.value,dat.value); if (dat.is_valid==false) return false; fxnodeline->val = dat.value; fxnodeline->logtype = dat.logtype; } } return true; }