61
61
#define SPINNER_INTER_TEXTS_MARGIN 20
62
62
#define BAR_TEXT_MARGIN 24
63
63
#define BAR_INTER_TEXTS_MARGIN 16
64
+ #define PROGRESSBAR_ALIGNMENT_MARGIN_Y 28
64
65
#elif defined(TARGET_FLEX )
65
66
#define RADIO_CHOICE_HEIGHT 92
66
67
#define FOOTER_HEIGHT 80
83
84
#define SPINNER_INTER_TEXTS_MARGIN 16
84
85
#define BAR_TEXT_MARGIN 24
85
86
#define BAR_INTER_TEXTS_MARGIN 16
87
+ #define PROGRESSBAR_ALIGNMENT_MARGIN_Y 32
86
88
#else // TARGETS
87
89
#error Undefined target
88
90
#endif // TARGETS
89
91
92
+ // width & height for progress bar
93
+ #define PROGRESSBAR_WIDTH 120
94
+ #define PROGRESSBAR_HEIGHT 12
95
+
90
96
// refresh period of the spinner, in ms
91
97
#define SPINNER_REFRESH_PERIOD 400
92
98
@@ -2185,7 +2191,6 @@ int nbgl_layoutAddProgressBar(nbgl_layout_t *layout,
2185
2191
nbgl_container_t * container ;
2186
2192
nbgl_text_area_t * textArea ;
2187
2193
nbgl_progress_bar_t * progress ;
2188
- uint16_t height_nearest_multiple_of_8 = 0 ;
2189
2194
2190
2195
LOG_DEBUG (LAYOUT_LOGGER , "nbgl_layoutAddProgressBar():\n" );
2191
2196
if (layout == NULL ) {
@@ -2204,24 +2209,18 @@ int nbgl_layoutAddProgressBar(nbgl_layout_t *layout,
2204
2209
2205
2210
// Create progressbar
2206
2211
progress = (nbgl_progress_bar_t * ) nbgl_objPoolGet (PROGRESS_BAR , layoutInt -> layer );
2207
- progress -> foregroundColor = BLACK ;
2208
- progress -> withBorder = true;
2209
- progress -> state = percentage ;
2210
- progress -> obj .area .width = PROGRESSBAR_WIDTH ;
2211
- progress -> obj .area .height = PROGRESSBAR_HEIGHT ;
2212
- progress -> obj .alignment = TOP_MIDDLE ;
2213
- progress -> obj .alignmentMarginY = PROGRESSBAR_ALIGNMENT_MARGIN_Y ;
2212
+ progress -> foregroundColor = BLACK ;
2213
+ progress -> withBorder = true;
2214
+ progress -> state = percentage ;
2215
+ progress -> obj .area .width = PROGRESSBAR_WIDTH ;
2216
+ progress -> obj .area .height = PROGRESSBAR_HEIGHT ;
2217
+ progress -> obj .alignment = TOP_MIDDLE ;
2214
2218
2215
2219
// set this new progressbar as child of the container
2216
2220
container -> children [0 ] = (nbgl_obj_t * ) progress ;
2217
2221
2218
- // The height of containers must be a multiple of eight :
2219
- height_nearest_multiple_of_8 = PROGRESSBAR_HEIGHT + 4 ;
2220
- if (height_nearest_multiple_of_8 % 8 != 0 ) {
2221
- height_nearest_multiple_of_8 += 8 - (height_nearest_multiple_of_8 % 8 );
2222
- }
2223
2222
// update container height
2224
- container -> obj .area .height += ( height_nearest_multiple_of_8 ) ;
2223
+ container -> obj .area .height = progress -> obj . alignmentMarginY + progress -> obj . area . height ;
2225
2224
2226
2225
// create text area
2227
2226
textArea = (nbgl_text_area_t * ) nbgl_objPoolGet (TEXT_AREA , layoutInt -> layer );
@@ -2238,13 +2237,8 @@ int nbgl_layoutAddProgressBar(nbgl_layout_t *layout,
2238
2237
textArea -> fontId , textArea -> text , textArea -> obj .area .width , textArea -> wrapping );
2239
2238
textArea -> style = NO_STYLE ;
2240
2239
2241
- // The height of containers must be a multiple of eight :
2242
- height_nearest_multiple_of_8 = (textArea -> obj .alignmentMarginY + textArea -> obj .area .height ) + 4 ;
2243
- if (height_nearest_multiple_of_8 % 8 != 0 ) {
2244
- height_nearest_multiple_of_8 += 8 - (height_nearest_multiple_of_8 % 8 );
2245
- }
2246
2240
// update container height
2247
- container -> obj .area .height += ( height_nearest_multiple_of_8 ) ;
2241
+ container -> obj .area .height += textArea -> obj . alignmentMarginY + textArea -> obj . area . height ;
2248
2242
2249
2243
// set this text as child of the container
2250
2244
container -> children [1 ] = (nbgl_obj_t * ) textArea ;
@@ -2268,18 +2262,15 @@ int nbgl_layoutAddProgressBar(nbgl_layout_t *layout,
2268
2262
subTextArea -> wrapping );
2269
2263
subTextArea -> style = NO_STYLE ;
2270
2264
2271
- // The height of containers must be a multiple of eight :
2272
- height_nearest_multiple_of_8
2273
- = (subTextArea -> obj .alignmentMarginY + subTextArea -> obj .area .height ) + 4 ;
2274
- if (height_nearest_multiple_of_8 % 8 != 0 ) {
2275
- height_nearest_multiple_of_8 += 8 - (height_nearest_multiple_of_8 % 8 );
2276
- }
2277
2265
// update container height
2278
- container -> obj .area .height += (height_nearest_multiple_of_8 );
2266
+ container -> obj .area .height
2267
+ += subTextArea -> obj .alignmentMarginY + subTextArea -> obj .area .height ;
2279
2268
2280
2269
// set thissub-text as child of the container
2281
2270
container -> children [2 ] = (nbgl_obj_t * ) subTextArea ;
2282
2271
}
2272
+ // The height of containers must be a multiple of eight
2273
+ container -> obj .area .height = (container -> obj .area .height + 7 ) & 0xFFF8 ;
2283
2274
2284
2275
layoutAddObject (layoutInt , (nbgl_obj_t * ) container );
2285
2276
0 commit comments