-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonMenu.cpp
More file actions
58 lines (51 loc) · 1.17 KB
/
Copy pathButtonMenu.cpp
File metadata and controls
58 lines (51 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// Copyright (c) 2013 - Allen Bauer - http://blog.thereadoracleatdelphi.com
// Under MIT License
//
#include "ButtonMenu.h"
void ButtonMenu::ArrangeButtons(Direction dir, uint8_t buttonWidth, uint8_t buttonHeight,
uint8_t bufferX, uint8_t bufferY, uint8_t startX, uint8_t startY, MenuItem *items,
uint8_t numButtons, OnTouchHandler onTouchHandler)
{
int i, x = startX, y = startY;
for (i = 0; i < numButtons; i++)
{
items[i].button.initSimpleButton(x, y, buttonWidth, buttonHeight, items[i].caption, 1, i, onTouchHandler);
if (dir == Vertical)
{
y += (buttonHeight + bufferY);
if (y + buttonHeight > _maxY)
{
x += buttonWidth + bufferX;
y = startY;
}
} else
{
x += (buttonWidth + bufferX);
if (x + buttonWidth > _maxX)
{
y += buttonHeight + bufferY;
x = startX;
}
}
}
}
void ButtonMenu::ShowButtonMenu(MenuItem *items, uint8_t numButtons)
{
while (numButtons-- > 0)
{
items->button.drawButton();
items++;
}
}
void ButtonMenu::HideButtonMenu(MenuItem *items, uint8_t numButtons)
{
while (numButtons-- > 0)
{
items->button.deactivate();
items++;
}
_LCD->clearGraphic();
_LCD->clearText();
}
ButtonMenu buttonMenu;