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
35
36
39
40
41
42
43
44
45
46
47
48
52
53
54
55
56
57
58
70
71
75
76
80
81
/* ... */
#include <gui/common/DotIndicator.hpp>
#include <BitmapDatabase.hpp>
#include <assert.h>
DotIndicator::DotIndicator() :
unselectedDots(EAST),
numberOfDots(0),
currentDot(0)
{
unselectedDots.setXY(0, 0);
dotHighlighted.setXY(0, 0);
add(unselectedDots);
add(dotHighlighted);
}{ ... }
DotIndicator::~DotIndicator()
{
}{ ... }
void DotIndicator::setNumberOfDots(uint8_t size)
{
numberOfDots = size;
assert(numberOfDots > 0 && "At least one dot is needed");
assert(numberOfDots <= MAX_SIZE && "Above maximum number of dots");
unselectedDots.removeAll();
for (int i = 0; i < numberOfDots; i++)
{
unselectedDots.add(dotNormal[i]);
}for (int i = 0; i < numberOfDots; i++) { ... }
setWidth(unselectedDots.getWidth());
setHeight(unselectedDots.getHeight());
setHighlightPosition(currentDot = 0);
}{ ... }
void DotIndicator::setBitmaps(const Bitmap& unselected, const Bitmap& selected)
{
dotHighlighted.setBitmap(selected);
for (int i = 0; i < MAX_SIZE - 1; i++)
{
dotNormal[i].setBitmap(unselected);
}for (int i = 0; i < MAX_SIZE - 1; i++) { ... }
if (numberOfDots > 0)
{
setNumberOfDots(numberOfDots);
}if (numberOfDots > 0) { ... }
}{ ... }
void DotIndicator::goRight()
{
setHighlightPosition(currentDot = (currentDot + 1) % numberOfDots);
}{ ... }
void DotIndicator::goLeft()
{
setHighlightPosition(currentDot = (currentDot + numberOfDots - 1) % numberOfDots);
}{ ... }
void DotIndicator::setHighlightPosition(uint8_t index)
{
if (index < numberOfDots)
{
dotHighlighted.setX(index * dotNormal[0].getWidth());
}if (index < numberOfDots) { ... }
invalidate();
}{ ... }