NoteList zip_to_long_notes(SingleNoteList const &HNL, SingleNoteList const &RNL) { auto Hmap = split_notes_by_key(HNL); auto Rmap = split_notes_by_key(RNL); std::list<std::future<NoteList>> futures; for(auto node : Hmap) futures.push_back( std::async( std::launch::async, zip_key, Hmap[node.first], Rmap[node.first] ) ); NoteList L; while(!futures.empty()) { auto it = futures.begin(); NoteList l = it->get(); L.insert(L.end(), l.begin(), l.end()); futures.erase(it); } return L; }
void TrackEditorPattern::paint_multiple_note_events( GUI::Painter& p, int p_row , const NoteList& p_list , bool p_repeat) { /* separate in columns */ std::vector<NoteList> notes_in_column( track->get_visible_columns() ); NoteList::const_iterator I=p_list.begin(); for (;I!=p_list.end();I++) { int col=I->pos.column; ERR_CONTINUE( col < 0 ); ERR_CONTINUE( col >= notes_in_column.size() ); notes_in_column[col].push_back(*I); } /* now draw columns */ for (int i=0;i<notes_in_column.size();i++) { if (notes_in_column[i].empty()) continue; if (notes_in_column[i].size()==1) { paint_note_event(p,p_row,*notes_in_column[i].begin(),p_repeat); } else paint_multiple_nonvisible_events(p,p_row,notes_in_column[i]); } }
void TrackEditorPattern::draw(const GUI::Point& p_pos,const GUI::Size& p_size,const GUI::Rect& p_exposed) { Editor::get_singleton()->set_window_rows( p_size.height / get_row_height() ); GUI::Painter &p=*get_painter(); // p.set_clip_rect(false,p_exposed); //p.set_clip_rect(true,p_exposed); p.draw_fill_rect(GUI::Point(0,0),size,color(COLOR_PATTERN_BG)); paint_frames(p); paint_selection(p,p_exposed.pos.y,p_exposed.pos.y+p_exposed.size.height); int visible_rows=Editor::get_singleton()->get_window_rows(); for (int i=0;i<visible_rows;i++) { Tick from=Editor::get_singleton()->get_row_ticks( Editor::get_singleton()->get_window_offset() + i ); Tick to=from+Editor::get_singleton()->get_ticks_per_row()-1; Tick adjust=0; /* Calculate Repeat, if exists */ bool repeat=false; int blk_idx = track->get_block_at_pos( from ); int prev=track->find_block_at_pos( from ); if (blk_idx<0 && prev>=0 && track->get_block( prev )->is_repeat_enabled()) repeat=true; //printf("row %i, blkidx %i , prev %i, repeat %i\n",i,blk_idx,prev,repeat); /* If repeat, adjust from and to */ if (repeat) { Tick block_from=track->get_block_pos( prev ); Tick block_len=track->get_block( prev )->get_length(); Tick new_tick_from=block_from+(from-block_from)%block_len; adjust=from-new_tick_from; to=new_tick_from+(to-from); from=new_tick_from; } NoteList nl; { int from_block=track->find_block_at_pos(from); int to_block=track->find_block_at_pos(to); for (int b=from_block;b<=to_block;b++) { if (b<0) continue; PatternTrack::PatternBlock *block = static_cast<PatternTrack::PatternBlock*>(track->get_block(b)); Tick block_pos = track->get_block_pos(b); Tick block_len = block->get_length(); if (block_pos+block_len < from ) continue; int note_from,note_to; //printf("tick %i-%i, notes %i-%i\n",from,to,note_from,note_to); if (block->get_notes_in_local_range(from-block_pos,to-block_pos,¬e_from,¬e_to)) { for (int n=note_from;n<=note_to;n++) { NoteListElement nle; nle.pos=block->get_note_pos(n); nle.pos.tick=nle.pos.tick+block_pos-from; nle.note=block->get_note(n); nl.push_back(nle); } } } } /* Then if repeat, adjust positions */ NoteList::iterator I=nl.begin(); if (repeat) { for(;I!=nl.end();I++) { I->pos.tick+=adjust; } } if (!nl.empty()) { paint_multiple_note_events( p,i , nl, repeat ); } //paint_cursor(p,i); } paint_row_lines(p); // printf("focus %i, track %i, row %i (%i-%i)\n",(int)has_focus(),(int)Editor::get_singleton()->get_cursor_track(),(int)Editor::get_singleton()->get_cursor_row(),(int)Editor::get_singleton()->get_window_offset(),(int)(Editor::get_singleton()->get_window_offset()+visible_rows)); if ( has_focus() && Editor::get_singleton()->get_cursor_track()==song->find_track_pos(track) && Editor::get_singleton()->get_cursor_row()>=Editor::get_singleton()->get_window_offset() && Editor::get_singleton()->get_cursor_row()<(Editor::get_singleton()->get_window_offset()+visible_rows)) { /* cursor is here */ paint_cursor( p, Editor::get_singleton()->get_cursor_row()-Editor::get_singleton()->get_window_offset() ); } }
void TrackEditorPattern::paint_multiple_nonvisible_events( GUI::Painter& p, int p_row, const NoteList& p_list) { int font_width=get_font_width(); int rowsize=get_row_size(); int fontofs=(rowsize-get_font_height())/2; int eventofs=p_row*rowsize+fontofs; int notewidth=get_font_width()*3; int columnwidth=get_font_width()*4; NoteList::const_iterator I=p_list.begin(); int howmany=p_list.size(); int maxevents=(rowsize-4)/2; if (howmany>maxevents) howmany=maxevents; int maxsize=(rowsize-4)-(howmany-1); for (int i=0;i<howmany;I++,i++) { NoteListElement note = *I; int xofs=font_width+note.pos.column*columnwidth; int from=i*maxsize/howmany; int to=((i+1)*maxsize/howmany); int eheight = to-from; if (eheight<=0) eheight=1; from+=i; //printf("%i - from %i, height %i\n",i,from,eheight); //GUI::Color col=color(COLOR_PATTERN_FONT); if (note.note.is_note()) { switch( Editor::get_singleton()->get_track_edit_mode() ) { case Editor::EDIT_MODE_FRONT: { GUI::Color bg=GUI::Color(COLOR_PATTERN_NOTE_BG); GUI::Color fg=color(COLOR_PATTERN_FONT); int note_w=get_note_display_column_pos(notewidth,note.note.note); p.draw_fill_rect(GUI::Point(xofs,eventofs+from),GUI::Size(notewidth,eheight),bg); p.draw_fill_rect(GUI::Point(xofs+note_w,eventofs+from),GUI::Size(constant(C_TRACK_EDITOR_VOL_NOTE_BAR_HEIGHT),eheight),fg); } break; case Editor::EDIT_MODE_BACK: { GUI::Color bg=GUI::Color(COLOR_PATTERN_VOLUME_BG); GUI::Color fg=color(COLOR_PATTERN_FONT_VOLUME); int vol_w=(note.note.volume*notewidth)/PatternTrack::Note::MAX_VOLUME; p.draw_fill_rect(GUI::Point(xofs,eventofs+from),GUI::Size(notewidth,eheight),bg); p.draw_fill_rect(GUI::Point(xofs,eventofs+from),GUI::Size(vol_w,eheight),fg); } break; } } else if (note.note.is_note_off()) { GUI::Color col = color(COLOR_PATTERN_SUBBEAT_LINE); p.draw_fill_rect(GUI::Point(xofs,eventofs+from),GUI::Size(notewidth,eheight),col); } else { //printf("WTF!!\n"); } } }