mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-04 16:51:37 -05:00
A bit of a string performance trick.
This commit is contained in:
parent
8cf5e19848
commit
402935bcac
2 changed files with 17 additions and 11 deletions
|
@ -211,14 +211,12 @@ void ClipSelector::draw()
|
|||
|
||||
// clip bars
|
||||
if(!_master) {
|
||||
int bars = clips[i].getBeats() / 4;
|
||||
int barsToRecord = clips[i].getBarsToRecord();
|
||||
bars = (bars == 0) ? barsToRecord : bars;
|
||||
if(bars > 0) {
|
||||
const char * bars = clips[i].getBarsString();
|
||||
if(bars) {
|
||||
cairo_move_to( cr, x + clipHeight + 5, drawY + textHeight + 8);
|
||||
cairo_set_source_rgba( cr, 255 / 255.f, 255 / 255.f , 255 / 255.f , 0.9 );
|
||||
cairo_set_font_size( cr, 8 );
|
||||
cairo_show_text( cr, std::to_string(bars).c_str());
|
||||
cairo_show_text( cr, bars);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,23 +71,31 @@ public:
|
|||
|
||||
// we wrap it here, so there may be no
|
||||
// fuzz with the looperclip
|
||||
int getBeats(){
|
||||
const char * getBarsString(){
|
||||
if(!lclip)
|
||||
return 0;
|
||||
|
||||
return lclip->getBeats();
|
||||
}
|
||||
int beats = lclip->getBeats();
|
||||
int barsToRecord = lclip->getBarsToRecord();
|
||||
int bars = (beats == 0) ? barsToRecord : beats / 4;
|
||||
|
||||
int getBarsToRecord(){
|
||||
if(!lclip)
|
||||
if (bars <= 0)
|
||||
return 0;
|
||||
return lclip->getBarsToRecord();
|
||||
|
||||
if(bars != lastBars)
|
||||
barsText = std::to_string(bars);
|
||||
|
||||
return barsText.c_str();
|
||||
}
|
||||
|
||||
private:
|
||||
GridLogic::State state;
|
||||
std::string name;
|
||||
LooperClip* lclip;
|
||||
std::string barsText;
|
||||
|
||||
// tmp
|
||||
int lastBars;
|
||||
};
|
||||
|
||||
class ClipSelector : public Fl_Button
|
||||
|
|
Loading…
Add table
Reference in a new issue