Select one of the symbols to view example projects that use it.
 
Outline
#include <gui/common/DotIndicator.hpp>
#include <BitmapDatabase.hpp>
#include <assert.h>
DotIndicator::DotIndicator()
DotIndicator::~DotIndicator()
DotIndicator::setNumberOfDots(uint8_t)
DotIndicator::setBitmaps(const touchgfx::Bitmap &, const touchgfx::Bitmap &)
DotIndicator::goRight()
DotIndicator::goLeft()
DotIndicator::setHighlightPosition(uint8_t)
Files
loading...
CodeScopeSTM32 Libraries and SamplesTouchGFXGui/gui/src/common/DotIndicator.cpp
 
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * This file is part of the TouchGFX 4.10.0 distribution. * * @attention * * Copyright (c) 2018 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ #include <gui/common/DotIndicator.hpp> #include <BitmapDatabase.hpp> #include <assert.h> DotIndicator::DotIndicator() : unselectedDots(touchgfx::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++) { ... } // adjust size of container according to the actual bitmaps setWidth(unselectedDots.getWidth()); setHeight(unselectedDots.getHeight()); setHighlightPosition(currentDot = 0); }{ ... } void DotIndicator::setBitmaps(const touchgfx::Bitmap& normalDot, const touchgfx::Bitmap& highlightedDot) { dotHighlighted.setBitmap(highlightedDot); for (int i = 0; i < MAX_SIZE - 1; i++) { dotNormal[i].setBitmap(normalDot); }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) { currentDot = index; // note that index is unsigned if (index < numberOfDots) { dotHighlighted.setX(index*dotNormal[0].getWidth()); }if (index < numberOfDots) { ... } invalidate(); }{ ... }