@@ -2185,6 +2185,7 @@ int nbgl_layoutAddProgressBar(nbgl_layout_t *layout,
2185
2185
nbgl_container_t * container ;
2186
2186
nbgl_text_area_t * textArea ;
2187
2187
nbgl_progress_bar_t * progress ;
2188
+ uint16_t height_nearest_multiple_of_8 = 0 ;
2188
2189
2189
2190
LOG_DEBUG (LAYOUT_LOGGER , "nbgl_layoutAddProgressBar():\n" );
2190
2191
if (layout == NULL ) {
@@ -2194,7 +2195,7 @@ int nbgl_layoutAddProgressBar(nbgl_layout_t *layout,
2194
2195
// First Create Container :
2195
2196
container = (nbgl_container_t * ) nbgl_objPoolGet (CONTAINER , layoutInt -> layer );
2196
2197
// progressbar + text + subText
2197
- container -> nbChildren = 3 ;
2198
+ container -> nbChildren = ( subText != NULL ) ? 3 : 2 ;
2198
2199
container -> children = nbgl_containerPoolGet (container -> nbChildren , layoutInt -> layer );
2199
2200
2200
2201
container -> obj .area .width = AVAILABLE_WIDTH ;
@@ -2214,15 +2215,20 @@ int nbgl_layoutAddProgressBar(nbgl_layout_t *layout,
2214
2215
// set this new progressbar as child of the container
2215
2216
container -> children [0 ] = (nbgl_obj_t * ) progress ;
2216
2217
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
+ }
2217
2223
// update container height
2218
- container -> obj .area .height += PROGRESSBAR_HEIGHT ;
2224
+ container -> obj .area .height += ( height_nearest_multiple_of_8 ) ;
2219
2225
2220
2226
// create text area
2221
2227
textArea = (nbgl_text_area_t * ) nbgl_objPoolGet (TEXT_AREA , layoutInt -> layer );
2222
2228
textArea -> textColor = BLACK ;
2223
2229
textArea -> text = PIC (text );
2224
2230
textArea -> textAlignment = CENTER ;
2225
- textArea -> fontId = ( subText != NULL ) ? LARGE_MEDIUM_FONT : SMALL_REGULAR_FONT ;
2231
+ textArea -> fontId = LARGE_MEDIUM_FONT ;
2226
2232
textArea -> wrapping = true;
2227
2233
textArea -> obj .alignmentMarginY = BAR_TEXT_MARGIN ;
2228
2234
textArea -> obj .alignTo = (nbgl_obj_t * ) progress ;
@@ -2232,8 +2238,13 @@ int nbgl_layoutAddProgressBar(nbgl_layout_t *layout,
2232
2238
textArea -> fontId , textArea -> text , textArea -> obj .area .width , textArea -> wrapping );
2233
2239
textArea -> style = NO_STYLE ;
2234
2240
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
+ }
2235
2246
// update container height
2236
- container -> obj .area .height += textArea -> obj . alignmentMarginY + textArea -> obj . area . height ;
2247
+ container -> obj .area .height += ( height_nearest_multiple_of_8 ) ;
2237
2248
2238
2249
// set this text as child of the container
2239
2250
container -> children [1 ] = (nbgl_obj_t * ) textArea ;
@@ -2257,9 +2268,14 @@ int nbgl_layoutAddProgressBar(nbgl_layout_t *layout,
2257
2268
subTextArea -> wrapping );
2258
2269
subTextArea -> style = NO_STYLE ;
2259
2270
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
+ }
2260
2277
// update container height
2261
- container -> obj .area .height
2262
- += subTextArea -> obj .alignmentMarginY + subTextArea -> obj .area .height ;
2278
+ container -> obj .area .height += (height_nearest_multiple_of_8 );
2263
2279
2264
2280
// set thissub-text as child of the container
2265
2281
container -> children [2 ] = (nbgl_obj_t * ) subTextArea ;
0 commit comments