@@ -8,6 +8,7 @@ Thread Safe: No
88Extensible: Yes
99
1010Use graphics screens (adafruit library based) as menu output
11+ www.r-site.net
1112***/
1213#ifndef RSITE_ARDUINOP_MENU_GFX
1314 #define RSITE_ARDUINOP_MENU_GFX
@@ -30,10 +31,10 @@ Use graphics screens (adafruit library based) as menu output
3031
3132 class menuGFX :public menuOut {
3233 public:
33- uint16_t bgColor ;
34- uint16_t enabledColor ;
35- uint16_t disabledColor ;
36- uint16_t hiliteColor ;
34+ uint16_t hiliteColor=BLUE ;
35+ uint16_t bgColor=SILVER ;
36+ uint16_t enabledColor=WHITE ;
37+ uint16_t disabledColor=RED ;
3738 Adafruit_GFX& gfx;
3839 menuGFX (
3940 Adafruit_GFX& gfx,
@@ -50,7 +51,14 @@ Use graphics screens (adafruit library based) as menu output
5051 disabledColor(disabledColor),
5152 hiliteColor(hiliteColor),
5253 menuOut(gfx.width()/resX,gfx.height()/resY,resX,resY) {}
53- virtual void clear () {gfx.fillScreen (bgColor);gfx.setCursor (0 ,0 );}
54+
55+ virtual void clear () {
56+ // gfx.fillScreen(bgColor);
57+ Serial<<" max:" <<maxX<<" ," <<maxY<<endl
58+ <<" res:" <<resX<<" ," <<resY<<endl;
59+ gfx.fillRect (0 ,0 ,resX*maxX,resY*maxY,bgColor);
60+ gfx.setCursor (0 ,0 );
61+ }
5462 virtual void setCursor (int x,int y) {gfx.setCursor (x*resX,y*resY);}
5563 virtual void print (char ch) {gfx.print (ch);}
5664 virtual void print (const char *text) {gfx.print (text);}
@@ -60,27 +68,37 @@ Use graphics screens (adafruit library based) as menu output
6068 virtual void print (double i) {gfx.print (i);};
6169 virtual void println (double i) {gfx.println (i);};
6270 virtual void print (prompt &o,bool selected,int idx,int posY,int width) {
71+ Serial<<" menuGFX printing prompt " <<o.text <<endl;
6372 gfx.fillRect (0 ,posY*resY,width*resX,resY,selected?hiliteColor:bgColor);
6473 gfx.setTextColor (o.enabled ?enabledColor:disabledColor);
6574 gfx.setCursor (0 ,posY*resY);
6675 o.printTo (gfx);
67- println ();
76+ // println();
6877 }
69- inline int needRedraw (menu& m,int i) {return (drawn!=&m)||(top!=lastTop)||(m.sel !=lastSel&&((i==m.sel )||(i==lastSel)));}
78+ /* virtual void print(menuField &o,bool selected,int idx,int posY,int width) {
79+ p.print(text);
80+ p.print(activeNode==this?(tunning?'>':':'):' ');
81+ p.print(value);
82+ p.print(" ");
83+ p.print(units);
84+ p.print(" ");
85+ }*/
86+ /* drawStyle getStyle(prompt& p,bool selected,bool editing=false) {
87+ if (p.enabled)
88+ return selected?SELECTED:NORMAL;
89+ else return DISABLED;
90+ }*/
7091 virtual void printMenu (menu& m,bool drawExit) {
7192 if (drawn!=&m) clear ();// clear all screen when changing menu
7293 if (m.sel -top>=maxY) top=m.sel -maxY+1 ;// selected option outside device (bottom)
7394 else if (m.sel <top) top=m.sel ;// selected option outside device (top)
74- int i=0 ;for (;i<m.sz ;i++) {
75- if ((i>=top)&&((i-top)<maxY)) {
95+ int i=top ;for (;i<m.sz ;i++) {
96+ // if ((i>=top)&&((i-top)<maxY)) {
7697 if (i-top>=maxY) break ;
7798 if (needRedraw (m,i)) {
78- Serial<<hex ((long )drawn)<<" <-> " <<hex ((long )&m)
79- <<(drawn!=&m)<<(top!=lastTop)<<(m.sel !=lastSel&&((i==m.sel )||(i==lastSel)))
80- <<" drawing option:" <<m.data [i]->text <<endl;
8199 print (*m.data [i],i==m.sel ,i+1 ,i-top,m.width );
82100 }
83- }
101+ // }
84102 }
85103 if (drawExit&&i-top<maxY&&needRedraw (m,i))
86104 print (menu::exitOption,m.sel ==m.sz ,0 ,i-top,m.width );
0 commit comments