Skip to content

Commit 4dc42ce

Browse files
committed
minor fix, excessive redraw of exit option (GFX screen)
1 parent 131b872 commit 4dc42ce

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

menuGFX.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,23 @@ Use graphics screens (adafruit library based) as menu output
6666
o.printTo(gfx);
6767
println();
6868
}
69+
inline int needRedraw(menu& m,int i) {return (drawn!=&m)||(top!=lastTop)||(m.sel!=lastSel&&((i==m.sel)||(i==lastSel)));}
6970
virtual void printMenu(menu& m,bool drawExit) {
7071
if (drawn!=&m) clear();//clear all screen when changing menu
7172
if (m.sel-top>=maxY) top=m.sel-maxY+1;//selected option outside device (bottom)
7273
else if (m.sel<top) top=m.sel;//selected option outside device (top)
7374
int i=0;for(;i<m.sz;i++) {
7475
if ((i>=top)&&((i-top)<maxY)) {
7576
if(i-top>=maxY) break;
76-
if ((drawn!=&m)||(top!=lastTop)||(m.sel!=lastSel&&((i==m.sel)||(i==lastSel)))) {
77+
if (needRedraw(m,i)) {
7778
Serial<<hex((long)drawn)<<" <-> "<<hex((long)&m)
7879
<<(drawn!=&m)<<(top!=lastTop)<<(m.sel!=lastSel&&((i==m.sel)||(i==lastSel)))
7980
<<" drawing option:"<<m.data[i]->text<<endl;
8081
print(*m.data[i],i==m.sel,i+1,i-top,m.width);
8182
}
8283
}
8384
}
84-
if (drawExit&&i-top<maxY&&((top!=lastTop)||(i==m.sel)||(i==lastSel)||(drawn!=&m)))
85+
if (drawExit&&i-top<maxY&&needRedraw(m,i))
8586
print(menu::exitOption,m.sel==m.sz,0,i-top,m.width);
8687
lastTop=top;
8788
lastSel=m.sel;

0 commit comments

Comments
 (0)