Select one of the symbols to view example projects that use it.
 
Outline
#include <gui/custom_controls_screen/ThreeWayProgressBar.hpp>
#include <BitmapDatabase.hpp>
#include <assert.h>
#include <touchgfx/Color.hpp>
#include <texts/TextKeysAndLanguages.hpp>
ThreeWayProgressBar::ThreeWayProgressBar()
ThreeWayProgressBar::~ThreeWayProgressBar()
ThreeWayProgressBar::reset()
ThreeWayProgressBar::stopAnimation()
ThreeWayProgressBar::buttonPressedHandler(const AbstractButton &)
ThreeWayProgressBar::setActive(bool)
ThreeWayProgressBar::setBarPercentage(int, int)
Files
loading...
CodeScopeSTM32 Libraries and SamplesTouchGFXGui/gui/src/custom_controls_screen/ThreeWayProgressBar.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * 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/custom_controls_screen/ThreeWayProgressBar.hpp> #include <BitmapDatabase.hpp> #include <assert.h> #include <touchgfx/Color.hpp> #include <texts/TextKeysAndLanguages.hpp> 5 includes ThreeWayProgressBar::ThreeWayProgressBar() : buttonClickedAction(0), buttonPressedCallback(this, &ThreeWayProgressBar::buttonPressedHandler) { background.setBitmap(Bitmap(BITMAP_CONTROLS_WHEEL_BACKGROUND_ID)); background.setXY(14, 14); add(background); centerButton.setBitmaps(Bitmap(BITMAP_CONTROL_CENTER_BUTTON_ID), Bitmap(BITMAP_CONTROL_CENTER_BUTTON_PRESSED_ID)); centerButton.setXY(background.getX() + (background.getWidth() - centerButton.getWidth()) / 2, background.getY() + (background.getHeight() - centerButton.getHeight()) / 2); centerButton.setAction(buttonPressedCallback); centerButton.setLabelColor(Color::getColorFrom24BitRGB(0xFF, 0xFF, 0xFF)); centerButton.setLabelColorPressed(Color::getColorFrom24BitRGB(0xFF, 0xFF, 0xFF)); add(centerButton); bitmapPainter.setBitmap(Bitmap(BITMAP_CONTROL_COLOR_WHEEL_ID)); radius = 147; for (int i = 0; i < NUMBER_OF_BARS; i++) { bars[i].setPosition(background.getX(), background.getY(), background.getWidth(), background.getHeight()); bars[i].setCenter(bars[i].getWidth() / 2.0f, bars[i].getHeight() / 2.0f); bars[i].setRadius(radius); bars[i].setLineWidth(34); bars[i].setPainter(bitmapPainter); bars[i].setCapPrecision(15); bars[i].setArc(i * 120, i * 120); bars[i].setVisible(false); add(bars[i]); }for (int i = 0; i < NUMBER_OF_BARS; i++) { ... } for (int i = 0; i < NUMBER_OF_BARS; i++) { add(circles[i]); }for (int i = 0; i < NUMBER_OF_BARS; i++) { ... } setWidth(background.getWidth() + 28); setHeight(background.getHeight() + 28); reset(); }{ ... } ThreeWayProgressBar::~ThreeWayProgressBar() { }{ ... } void ThreeWayProgressBar::reset() { for (int i = 0; i < NUMBER_OF_BARS; i++) { // Center circles before animating out circles[i].moveTo(background.getX() + ((background.getWidth() - circles[i].getWidth()) / 2) + ( -40 + ((i+1) % 3) * 40), background.getY() + (background.getHeight() - circles[i].getHeight()) / 2); circles[i].setPercentage(0); }for (int i = 0; i < NUMBER_OF_BARS; i++) { ... } circles[0].setIcon(BITMAP_SMALL_CIRCLE_BIN_ICON_INACTIVE_ID, BITMAP_SMALL_CIRCLE_BIN_ICON_ACTIVE_ID); circles[1].setIcon(BITMAP_SMALL_CIRCLE_PAPERS_ICON_INACTIVE_ID, BITMAP_SMALL_CIRCLE_PAPERS_ICON_ACTIVE_ID); circles[2].setIcon(BITMAP_SMALL_CIRCLE_FOLDER_ICON_INACTIVE_ID, BITMAP_SMALL_CIRCLE_FOLDER_ICON_ACTIVE_ID); circles[0].startMoveAnimation(circles[0].getX(), circles[0].getY() - radius, 30, EasingEquations::cubicEaseInOut, EasingEquations::cubicEaseInOut); circles[1].startMoveAnimation(background.getX() + background.getWidth() - circles[1].getWidth(), 216, 30, EasingEquations::cubicEaseInOut, EasingEquations::cubicEaseInOut); circles[2].startMoveAnimation(background.getX(), 216, 30, EasingEquations::cubicEaseInOut, EasingEquations::cubicEaseInOut); for (int i = 0; i < NUMBER_OF_BARS; i++) { bars[i].setVisible(false); circles[i].setActive(false); }for (int i = 0; i < NUMBER_OF_BARS; i++) { ... } setActive(false); }{ ... } void ThreeWayProgressBar::stopAnimation() { for (int i = 0; i < NUMBER_OF_BARS; i++) { circles[i].cancelMoveAnimation(); }for (int i = 0; i < NUMBER_OF_BARS; i++) { ... } }{ ... } void ThreeWayProgressBar::buttonPressedHandler(const AbstractButton& button) { if (buttonClickedAction && buttonClickedAction->isValid()) { buttonClickedAction->execute(*this); }if (buttonClickedAction && buttonClickedAction->isValid()) { ... } }{ ... } void ThreeWayProgressBar::setActive(bool active) { centerButton.setTouchable(!active); for (int i = 0; i < NUMBER_OF_BARS; i++) { if (active) { bars[i].setVisible(true); setBarPercentage(i, 0); }if (active) { ... } circles[i].setActive(active); }for (int i = 0; i < NUMBER_OF_BARS; i++) { ... } centerButton.setLabelText(TypedText((active) ? T_THREE_WAY_PROGRESS_BAR_SCANNING : T_THREE_WAY_PROGRESS_BAR_SCAN)); invalidate(); }{ ... } void ThreeWayProgressBar::setBarPercentage(int barIndex, int percentage) { if (percentage > 100) { percentage = 100; }if (percentage > 100) { ... } bars[barIndex].updateArcEnd((int) ((barIndex * 120) + (120 * percentage / 100.f))); circles[barIndex].setPercentage(percentage); }{ ... }