28 #ifndef _LCDGFX_MENU_H_ 29 #define _LCDGFX_MENU_H_ 38 #define lcd_gfx_min(x, y) ((x) < (y) ? (x) : (y)) 43 #define lcd_gfx_max(x, y) ((x) > (y) ? (x) : (y)) 74 template <
typename D>
void show(D &d);
96 void setSelection(uint8_t s);
128 template <
typename D> uint8_t getMaxScreenItems(D &d)
130 return (menu.
height - 16) / d.getFont().getHeader().height;
133 template <
typename D> uint8_t calculateScrollPosition(D &d, uint8_t selection)
139 else if ( selection - menu.
scrollPosition > getMaxScreenItems(d) - 1 )
141 return selection - getMaxScreenItems(d) + 1;
146 template <
typename D>
void drawMenuItem(D &d, uint8_t index)
153 uint16_t color = d.getColor();
155 d.fillRect(menu.
left + 8 + d.getFont().getTextSize(menu.
items[index]), item_top, menu.
width + menu.
left - 9,
156 item_top + d.getFont().getHeader().height - 1);
158 d.printFixed(menu.
left + 8, item_top, menu.
items[index], STYLE_NORMAL);
165 template <
typename D>
void drawScrollIndicators(D &d, uint8_t maxItems)
167 uint16_t color = d.getColor();
171 lcdint_t itemsBot = itemsTop + maxItems * d.getFont().getHeader().height;
176 d.fillRect(5 + menu.
left, borderTop + 1, menu.
width + menu.
left - 6, itemsTop - 1);
180 d.drawHLine(cx, borderTop + 1, cx);
181 d.drawHLine(cx - 1, borderTop + 2, cx + 1);
182 d.drawHLine(cx - 2, borderTop + 3, cx + 2);
187 d.fillRect(5 + menu.
left, itemsBot, menu.
width + menu.
left - 6, borderBot - 1);
191 d.drawHLine(cx - 2, borderBot - 3, cx + 2);
192 d.drawHLine(cx - 1, borderBot - 2, cx + 1);
193 d.drawHLine(cx, borderBot - 1, cx);
198 lcdint_t sbH = itemsBot - itemsTop - 1;
210 d.fillRect(sbX, itemsTop, sbX + 1, itemsTop + sbH);
212 d.fillRect(sbX, thumbY, sbX + 1, thumbY + thumbH);
223 uint8_t maxItems = getMaxScreenItems(d);
226 this->drawMenuItem(d, i);
229 if ( menu.
count > maxItems )
231 this->drawScrollIndicators(d, maxItems);
NanoRect structure describes rectangle area.
int8_t lcdint_t
internal int type, used by the library.
Basic structures of nano gfx library.