Select one of the symbols to view example projects that use it.
 
Outline
#include <gui/product_presenter_screen/ProductPresenterView.hpp>
#include "BitmapDatabase.hpp"
#include <touchgfx/Color.hpp>
#include <touchgfx/EasingEquations.hpp>
#include <texts/TextKeysAndLanguages.hpp>
ProductPresenterView::ProductPresenterView()
ProductPresenterView::~ProductPresenterView()
ProductPresenterView::setupScreen()
ProductPresenterView::tearDownScreen()
ProductPresenterView::buttonPressedHandler(const AbstractButton &)
ProductPresenterView::languageSelectorStateChangedHandler(const CollapsibleMenu &, const bool)
ProductPresenterView::setLanguage()
ProductPresenterView::screenSaverMinorTick()
Files
loading...
CodeScopeSTM32 Libraries and SamplesTouchGFXGui/gui/src/product_presenter_screen/ProductPresenterView.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
149
150
151
152
153
154
155
156
157
158
159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * 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/product_presenter_screen/ProductPresenterView.hpp> #include "BitmapDatabase.hpp" #include <touchgfx/Color.hpp> #include <touchgfx/EasingEquations.hpp> #include <texts/TextKeysAndLanguages.hpp> 5 includes ProductPresenterView::ProductPresenterView() : DemoView(), screenSaverCounter(0), onButtonPressed(this, &ProductPresenterView::buttonPressedHandler), languageSelectorStateChanged(this, &ProductPresenterView::languageSelectorStateChangedHandler) { }{ ... } ProductPresenterView::~ProductPresenterView() { Texts::setLanguage(GBR); }{ ... } void ProductPresenterView::setupScreen() { background.setBitmap(Bitmap(BITMAP_PRODUCT_PRESENTER_BACKGROUND_ID)); background.setXY(0, 0); add(background); poster[0].setup(BITMAP_POSTER_IMAGE_00_ID, T_POSTER_00_HEADLINE, T_POSTER_00_TEXT, false); poster[1].setup(BITMAP_POSTER_IMAGE_01_ID, T_POSTER_01_HEADLINE, T_POSTER_01_TEXT, true); poster[2].setup(BITMAP_POSTER_IMAGE_02_ID, T_POSTER_02_HEADLINE, T_POSTER_02_TEXT, false); poster[2].setHeadlineColor(Color::getColorFrom24BitRGB(0x0, 0x0, 0x0)); for (int i = 0; i < NUMBER_OF_POSTERS; i++) { // Enlarge the poster swipe area by placing it in the posters container poster[i].setXY(302, 0); posters[i].add(poster[i]); posters[i].setPosition(0, 0, 302 + poster[i].getWidth() + 210, poster[i].getHeight()); posterSwipeContainer.add(posters[i]); }for (int i = 0; i < NUMBER_OF_POSTERS; i++) { ... } posterSwipeContainer.setXY(0, 50); posterSwipeContainer.setSwipeCutoff(100); posterSwipeContainer.setEndSwipeElasticWidth(70); add(posterSwipeContainer); paperOverlay.setBitmap(Bitmap(BITMAP_PAPER_OVERLAY_ID)); paperOverlay.setXY(0, getActiveDisplayHeight() - paperOverlay.getHeight()); add(paperOverlay); activateLanguageSelectorButton.setXY(726, 433); activateLanguageSelectorButton.setAction(onButtonPressed); add(activateLanguageSelectorButton); languages[0] = GBR; inactiveLanguageButtons[0] = BITMAP_FLAG_GBR_INACTIVE_ID; languages[1] = DNK; inactiveLanguageButtons[1] = BITMAP_FLAG_DNK_INACTIVE_ID; languages[2] = JPN; inactiveLanguageButtons[2] = BITMAP_FLAG_JPN_INACTIVE_ID; languages[3] = UKR; inactiveLanguageButtons[3] = BITMAP_FLAG_UKR_INACTIVE_ID; languages[4] = NLD; inactiveLanguageButtons[4] = BITMAP_FLAG_NLD_INACTIVE_ID; languageSelector.addMenuElement(Bitmap(BITMAP_FLAG_GBR_ACTIVE_ID), Bitmap(BITMAP_FLAG_GBR_ACTIVE_ID)); languageSelector.addMenuElement(Bitmap(BITMAP_FLAG_DNK_ACTIVE_ID), Bitmap(BITMAP_FLAG_DNK_ACTIVE_ID)); languageSelector.addMenuElement(Bitmap(BITMAP_FLAG_JPN_ACTIVE_ID), Bitmap(BITMAP_FLAG_JPN_ACTIVE_ID)); languageSelector.addMenuElement(Bitmap(BITMAP_FLAG_UKR_ACTIVE_ID), Bitmap(BITMAP_FLAG_UKR_ACTIVE_ID)); languageSelector.addMenuElement(Bitmap(BITMAP_FLAG_NLD_ACTIVE_ID), Bitmap(BITMAP_FLAG_NLD_ACTIVE_ID)); languageSelector.setElementSpace(24); languageSelector.setExpandDirection(CollapsibleMenu::LEFT); languageSelector.setStateChangedCallback(languageSelectorStateChanged); languageSelector.setTimeout(300); languageSelector.finilizeInitialization(); languageSelector.setXY(800 - 20 - languageSelector.getWidth(), 429); languageSelector.fadeOut(10); add(languageSelector); gotoMenuButton.setBitmaps(Bitmap(BITMAP_MENU_BUTTON_ID), Bitmap(BITMAP_MENU_BUTTON_ACTIVE_ID)); gotoMenuButton.setXY(20, 18); add(gotoMenuButton); mcuLoadTxt.setXY(618, 40 - mcuLoadTxt.getTypedText().getFont()->getFontHeight()); mcuLoadValueTxt.setPosition(mcuLoadTxt.getRect().right(), mcuLoadTxt.getY(), 45, 30); add(mcuLoadTxt); add(mcuLoadValueTxt); setLanguage(); posterSwipeContainer.moveTo(-450, posterSwipeContainer.getY()); posterSwipeContainer.startMoveAnimation(0, posterSwipeContainer.getY(), 24, EasingEquations::backEaseOut); }{ ... } void ProductPresenterView::tearDownScreen() { }{ ... } void ProductPresenterView::buttonPressedHandler(const AbstractButton& button) { if (languageSelector.isFadedOut()) { languageSelector.fadeInAndExpand(); }if (languageSelector.isFadedOut()) { ... } }{ ... } void ProductPresenterView::languageSelectorStateChangedHandler(const CollapsibleMenu& menu, const bool isExpanded) { if (!isExpanded) { languageSelector.fadeOut(); setLanguage(); }if (!isExpanded) { ... } }{ ... } void ProductPresenterView::setLanguage() { int languageIndex = languageSelector.getSelectedElementIndex(); activateLanguageSelectorButton.setBitmaps(Bitmap(inactiveLanguageButtons[languageIndex]), Bitmap(inactiveLanguageButtons[languageIndex])); activateLanguageSelectorButton.invalidate(); Texts::setLanguage(languages[languageIndex]); mcuLoadTxt.invalidate(); for (int i = 0; i < NUMBER_OF_POSTERS; i++) { poster[i].invalidateText(); }for (int i = 0; i < NUMBER_OF_POSTERS; i++) { ... } }{ ... } void ProductPresenterView::screenSaverMinorTick() { screenSaverCounter++; if (screenSaverCounter > 10) { gotoMenuClickedHandler(gotoMenuButton); }if (screenSaverCounter > 10) { ... } else { poster[posterSwipeContainer.getSelectedScreen()].toggleViewMode(); }else { ... } }{ ... }