From 7bc44415e817c89e26be2de40e105a96cfe69f42 Mon Sep 17 00:00:00 2001 From: Nicolas Roggeman Date: Wed, 12 Jun 2024 15:45:24 +0200 Subject: [PATCH] FWEO-1192 - New UI for Stax --- lib_nbgl/doc/nbgl_layout.dox | 21 -- lib_nbgl/glyphs/32px/radio_active_32px.png | Bin 0 -> 533 bytes lib_nbgl/glyphs/32px/radio_inactive_32px.png | Bin 0 -> 773 bytes lib_nbgl/glyphs/40px/radio_active_40px.png | Bin 0 -> 550 bytes lib_nbgl/glyphs/40px/radio_inactive_40px.png | Bin 0 -> 811 bytes lib_nbgl/glyphs/wallet/radio_active_32px.bmp | Bin 3126 -> 0 bytes lib_nbgl/glyphs/wallet/radio_active_40.bmp | Bin 6454 -> 0 bytes .../glyphs/wallet/radio_inactive_32px.bmp | Bin 3126 -> 0 bytes lib_nbgl/glyphs/wallet/radio_inactive_40.bmp | Bin 4854 -> 0 bytes lib_nbgl/include/nbgl_layout.h | 52 +-- lib_nbgl/include/nbgl_obj.h | 8 +- lib_nbgl/include/nbgl_page.h | 38 +-- lib_nbgl/include/nbgl_use_case.h | 2 +- lib_nbgl/src/nbgl_layout.c | 302 ++++++---------- lib_nbgl/src/nbgl_layout_internal.h | 4 +- lib_nbgl/src/nbgl_layout_keyboard.c | 322 +++++------------- lib_nbgl/src/nbgl_layout_keypad.c | 14 +- lib_nbgl/src/nbgl_layout_navigation.c | 107 ++---- lib_nbgl/src/nbgl_obj.c | 17 +- lib_nbgl/src/nbgl_page.c | 187 ++++------ lib_nbgl/src/nbgl_use_case.c | 179 +++------- unit-tests/lib_nbgl/test_nbgl_obj.c | 6 +- 22 files changed, 381 insertions(+), 878 deletions(-) create mode 100755 lib_nbgl/glyphs/32px/radio_active_32px.png create mode 100755 lib_nbgl/glyphs/32px/radio_inactive_32px.png create mode 100755 lib_nbgl/glyphs/40px/radio_active_40px.png create mode 100755 lib_nbgl/glyphs/40px/radio_inactive_40px.png delete mode 100755 lib_nbgl/glyphs/wallet/radio_active_32px.bmp delete mode 100755 lib_nbgl/glyphs/wallet/radio_active_40.bmp delete mode 100755 lib_nbgl/glyphs/wallet/radio_inactive_32px.bmp delete mode 100755 lib_nbgl/glyphs/wallet/radio_inactive_40.bmp diff --git a/lib_nbgl/doc/nbgl_layout.dox b/lib_nbgl/doc/nbgl_layout.dox index 33110e831..d07417c97 100644 --- a/lib_nbgl/doc/nbgl_layout.dox +++ b/lib_nbgl/doc/nbgl_layout.dox @@ -314,27 +314,6 @@ The API to insert such an object is @ref nbgl_layoutAddSpinner(). \warning No other object shall be inserted beside this one. -@subsection progress_indicator Progress indicator - -\image{inline} html layout5.png "caption" height=300 - -This object, drawned in top of the screen, is essentially made of a discrete page progress bar (slashes or digits). -An optional "back" button, symbolized with a left arrow, can also be drawned on the left of the page progress. - -The parameters to build this object are: - -- The total number of pages -- The current page (from 0 to (total_nb_pages-1)) -- A boolean to indicate whether to use a "back" button or not -- A \b token used with the action callback when the "back" button is touched - -Digits are represented instead of slashes if the number of pages exceeds 10. In this case, instead of marking the active page -as a slash in @ref BLACK, the page indicator will indicate *" of "* - -The API to insert such an object is @ref nbgl_layoutAddProgressIndicator(). - -\warning This object is incompatible with top-right button and page selector. - @subsection qr_code QR Code \image{inline} html stax_layout13.png "caption" height=300 diff --git a/lib_nbgl/glyphs/32px/radio_active_32px.png b/lib_nbgl/glyphs/32px/radio_active_32px.png new file mode 100755 index 0000000000000000000000000000000000000000..e6558c3f600f2b1c8cb06b22b0947061a581daa2 GIT binary patch literal 533 zcmV+w0_y#VP)LC$Og~}GD6x3LMMO?U;`RKdgs2#u^qy3*W=yk4o4qL zNU~+%fjroTiiYZj4h@}JlHXO!v$z3VLpyK77>Vo~Mu5R3+S5SVwKfJpA~;;Jxu2dn zGBNKlRS!(3BV+5cSKvFQ6Y_nnwVY!{jX6$!l( z-z97wsvB-=wHWztnh`(eM65{HpxcsXOgy0zDNSh2{1{^TXZ{oJ4Bvqx@eHj$k&Z2` zIh{w%fjtR5)A|eP;3_w?-f9l;1}}=yJ>n3V5BkQp;kTw}(XCYOXM_BM$S86a0kH8h zAm{M6Ev4;N&~M9);$#pG5@-j`68U(Co}wrW^nqlJw1Gm>P%8S#1Bt*P zTxjBmRP~IUmTv{ZbL618aIB%!VIU0h-UCcEt{BUGINa%B!mzmHxkC48R^x_Gv;T`9 XD~U|gir?h*00000NkvXXu0mjf%rfUT literal 0 HcmV?d00001 diff --git a/lib_nbgl/glyphs/32px/radio_inactive_32px.png b/lib_nbgl/glyphs/32px/radio_inactive_32px.png new file mode 100755 index 0000000000000000000000000000000000000000..49443fab06660d58db426a7b1084851bf25f8a29 GIT binary patch literal 773 zcmV+g1N!`lP))~(+rqk(D z-ZgU(SglqA3^V*3$_E8P-e@%X@vn)Q1Qv^h(`Ymv@z|#8ptjrXz3aN_+=R-x59{^1 zU$56+3T)0`1zupfE?q(Zn|EPX|77D6*wz@n!OlJS!p(R*w)h8Ghh_L~I&vFxA6X&O zUMUmsv9soKb0BE7S`R=(8Q5$#&VIl5@PD~s1aowxIcjnN9N8~st;?X9JDE(rQVtA< zLxo|0V^`38rhT$wf9mM-6DEkg-4Scf^KPyKq3AJjA#O`kNFSJqcON$P=t{)I16>AE zo{<1284}v#25P5h5fJ9dR~I5`fo!(kE4`)qu*w zlX$;15lAE)gwk&+3AI`+6e1@@fJErQ`9dlQ22V;XlC>~$vO2GMMQhRRI67PmTrMe)bP7kqsQC+|~pE1ZP zs*qo9bU~^gz-B$zh)MjlKi)ko=%BF7v-&#*`wi+on=ava+)W|9ryScl!+wC_oc(~_00WOvx8Z|J7@=zHjrgIoj{+(=?UCQ&F7;yZ&2vcBniW?RmhL0fLo z9J&r6n>4GezwL{O#OZ2=W92m6)~{yqrq7pN%|7r4j;0>2KknSN00000NkvXXu0mjf DI9^(m literal 0 HcmV?d00001 diff --git a/lib_nbgl/glyphs/40px/radio_active_40px.png b/lib_nbgl/glyphs/40px/radio_active_40px.png new file mode 100755 index 0000000000000000000000000000000000000000..fd259f525e3ed5b57984d34da9b57ef288a9bc8b GIT binary patch literal 550 zcmV+>0@?kEP)J6F=!U${-IsqflPCz;V*&yA3;)C{FA!Be%!(I9AbQjyQ zEx!~AU}a_Hf1?^n8z~#PG*WkBeivPv!VS=kRF*+LF}lzA0|@PI)qzrVW6XltfeXTo zvyXp=$m|9tOS^Wm^tWAI2DhQnj+`LxT;9lLWd98E;s_C_gu(ZiP9ls`;!3nIXo7I| zho3}JkA*X2;3q2+ zE5BhpCsy8i=K5jCz%wg9u<|>`!(S<}^2yO}&_Hg$qcG_ievHm5tK-qk2Le#&zclX8 z2-6)k33>{F@X2$Bp2lytW86vtIoiq4Uqmn(aUz*-4u~8q7$k>$z;s?9UxBM3$N}pS z;{r}|%(>7%TEJ@1a6bfNsCkvPZ=?`)9Dvh_W%F@07*qoM6N<$f(nZ8xc~qF literal 0 HcmV?d00001 diff --git a/lib_nbgl/glyphs/40px/radio_inactive_40px.png b/lib_nbgl/glyphs/40px/radio_inactive_40px.png new file mode 100755 index 0000000000000000000000000000000000000000..2f90c954975014678a09874f696c0c0b8d0d36bf GIT binary patch literal 811 zcmV+`1JwM9P)DW`K~#7F?O4fe z+dvfk)C%at66gv-RbaaVsRG$YZAe&ws0x%okaP@Fft3nkS75mVrURV?EqNcH0&>Dx zxB!6-K0uh6uNm^q{B=lFp+bfC4T}n3xm@1WYPBA^x0lPsu`J7GIr@9_cj&&I&*$xQ zI(?>`$VG6qT0Nkd;pZ4G2|?H&jYdBxBQgImYwDY-ZhYJA?9Aa-@C*4f}p7zeO1pK>DF z*fuT$XkK#ZVAL_EZRPiak6$;oVU-N`;gl zyzWzcT(8%+R34s%@vUs4ieMrjBUJpRlF(>0c7n)}%~h#55nA9JJ1Pk&ree$H8mGGd z1r@B0jv$hnkBZ<+d<-YKr;>opiecqVHdm!$ zF{}(wIM`GWTzrUy16SR$`BH*WnI6VOcDvpFP6dI=$QMMR>Pn#V;zVkL+IvXuUnnQw z95eCs_$r`Uqpb(=(0{6Eq$VG+EK^>_b3UUHtDq3^^+vT$TMvRvA2z}y|JonMK3?b` z@y~SyC)+LRJ~oYnV{kQ&^r>|`qf1j%7s~7}0O6n5NO;XQ95au{qYK#`hzwGyaaL^~ zw>)irH@?;JMF%frl7&1ux-)y&OkgrU)3uXN2B*bW0EhBn$0n1dZ2MRjcM;c5A5a^o pK{x*CBO>)u^wUR$3KiZv{s3^a9&wdTLN!99&Ob*MXXnf8jiWJQyI)HU-5S+25w-f3Q&3yD{m_D` zVe(q5lVVY0TID5aHw8R1^1u+RP_GQ0N93Mr#wrZ)jLk)avq1nj&Wxu5j6t-Jn?nmG zgW&0CY7zd(!xIeR5dlf77R;(vr3L@LpMFm3eWrZ(FG$~~exj&o0KX_D8350NZfUH- z;8h4ea!=yrfhSmbHj$@>6cEDsSm|npl3C)-^`c2~sO2pf^`KQ;LFElakBNCsotyO_ U)P^((Y+{wFVnEn%j9a|@085L&RsaA1 diff --git a/lib_nbgl/glyphs/wallet/radio_active_40.bmp b/lib_nbgl/glyphs/wallet/radio_active_40.bmp deleted file mode 100755 index fe276accf9c91433d343ec5c3f1dc5cf73c8298f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6454 zcmeHHyKTcT6jbVT=~9JdN>{Fh^Z~pV59s(<8;F=jDCz{#)YzF~UvZ-u(sQcefw-a1_O5{>>AZC-5&PfIFZB_CN!i zflCWMp8&?n-yRNXR)7aWKdF_u)lc_{8V(rKm-fw>x}WG1x+@^wL#>@_Q{!7_Nj;#i zevKG=Uxc~f*|okM*1mUIh5WCqZ7r(?`^wrYmajY0LUJV^@ z<>vaJR~ee?T)yT(Yh&n5K8w)uqIcAqw2@N*@thmj+n(GSF>(UDm6!5?Uq%|#Ix7c0 z2Y4XV(v`8!8KZ6Fm#Uqzp~1U9uD4eX;;bL%SkK$NR;)o%;ax7O?uU ze4R5!E#Wp=KV^e|7LA9PgIFVRtFPcY33nmftFsg5ThGG3O3`@ARsqe|c*;)kHJ-Ay zp5|*jWrMH#yNEf6>-h|OX|0WLo%A19E$VG^xK<9hYeUa`4~uX4pyv(EwUs;MgT~g-8U0;o4QM(*&kN^x)LhGM z`3J1z#Gt0LIAeX#(fc6OVGVwZjDOa`^P=?~u!dY+U&i(^l#el~Fjh{{o;mXb K<_Y}$3A_O$AOA-H diff --git a/lib_nbgl/glyphs/wallet/radio_inactive_32px.bmp b/lib_nbgl/glyphs/wallet/radio_inactive_32px.bmp deleted file mode 100755 index a15bc3d5118fdd35708fb336c76d38a542ab4be6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3126 zcmb7-I}QRd5JQ(5Dk@4!POt}{=l;im(FR6}$K#ktVdLN9`PwhrarXFq#Jzv-X}iTM zPUP3~xWm}Cw{d=5{2EhLL0qpDrOA32PZ|ud`QCF0Zniv(YR$Y!iP_XU#9!rD(0;{M z#~jvLMRm?{yDW6%^aVjgId>i%2Yd(BbtsCO9YOmQ1x`p!&}pTCqvuWvK#&eWcK`@d zZ=Do?ARU7401%|!Iw=4_It1MTV3m5VQ%VC<6Ld;Z)YP0Vr6@2%c603uj)*if(*t+wkzjc{Dm1Ms(Y9mTI-nAr*mOe!qO2mh?Xc_09s1D8tDg! CnhzuZ diff --git a/lib_nbgl/glyphs/wallet/radio_inactive_40.bmp b/lib_nbgl/glyphs/wallet/radio_inactive_40.bmp deleted file mode 100755 index 9738cf8c59f3b0a9b6136d3c24ec9984537c838a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4854 zcmeH`I}XA?3`9dsmx?2B0uDgWojDaPn5T%e@Hnc#mtGz`vfr?<25(_c#@MlBI4n-D0=3>y|z5^cZBfp)3&3INV z-~j`O843JmOG8YX5V2H+^u#yJ)_szN7`Bq>i`6Z=p6tE5ZPlct)a0^1zR3V)n(wg2-0h1HjADt!Lc}& z;{QbxNZ|%ioBlW=2=&!N6}{Lpo(jwtF*fezrtype == CONTAINER)) { -#if (!defined(TARGET_STAX) && defined(NBGL_KEYBOARD)) +#ifdef NBGL_KEYBOARD if (layout->swipeUsage == SWIPE_USAGE_SUGGESTIONS) { keyboardSwipeCallback(obj, eventType); return; } -#endif // TARGET_STAX +#endif // NBGL_KEYBOARD if (layout->swipeUsage == SWIPE_USAGE_CUSTOM) { layoutObj->index = eventType; } @@ -493,6 +493,9 @@ layoutObj_t *layoutAddCallbackObj(nbgl_layoutInternal_t *layout, layoutObj->token = token; layoutObj->tuneId = tuneId; } + else { + LOG_FATAL(LAYOUT_LOGGER, "layoutAddCallbackObj: no more callback obj\n"); + } return layoutObj; } @@ -770,21 +773,14 @@ nbgl_layout_t *nbgl_layoutGet(const nbgl_layoutDescription_t *description) layout->container->obj.touchMask = (1 << TOUCHED); layout->container->obj.touchId = WHOLE_SCREEN_ID; - // create 'tap to continue' text area - layout->tapText = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, 0); - layout->tapText->localized = false; - layout->tapText->text = PIC(description->tapActionText); - layout->tapText->textColor = DARK_GRAY; - layout->tapText->fontId = SMALL_REGULAR_FONT; - layout->tapText->obj.area.width = SCREEN_WIDTH - 2 * BORDER_MARGIN; - layout->tapText->obj.area.height = nbgl_getFontLineHeight(layout->tapText->fontId); - layout->tapText->textAlignment = CENTER; -#ifdef TARGET_STAX - layout->tapText->obj.alignmentMarginY = BORDER_MARGIN; -#else // TARGET_STAX - layout->tapText->obj.alignmentMarginY = 30; -#endif // TARGET_STAX - layout->tapText->obj.alignment = BOTTOM_MIDDLE; + nbgl_layoutFooter_t footerDesc; + footerDesc.type = FOOTER_SIMPLE_TEXT; + footerDesc.separationLine = false; + footerDesc.simpleText.text = PIC(description->tapActionText); + footerDesc.simpleText.mutedOut = true; + footerDesc.simpleText.token = description->tapActionToken; + footerDesc.simpleText.tuneId = description->tapTuneId; + nbgl_layoutAddExtendedFooter((nbgl_layout_t *) layout, &footerDesc); } return (nbgl_layout_t *) layout; @@ -1048,7 +1044,7 @@ int nbgl_layoutAddText(nbgl_layout_t *layout, const char *text, const char *subT textArea->wrapping = true; textArea->obj.alignment = NO_ALIGNMENT; #ifdef TARGET_STAX - textArea->obj.alignmentMarginY = BORDER_MARGIN; + textArea->obj.alignmentMarginY = 32; #else // TARGET_STAX textArea->obj.alignmentMarginY = 28; #endif // TARGET_STAX @@ -1075,12 +1071,12 @@ int nbgl_layoutAddText(nbgl_layout_t *layout, const char *text, const char *subT subTextArea->obj.alignment = NO_ALIGNMENT; if (text != NULL) { #ifdef TARGET_STAX - subTextArea->obj.alignmentMarginY = INTERNAL_MARGIN; - fullHeight += BORDER_MARGIN; -#else // TARGET_STAX + subTextArea->obj.alignmentMarginY = 16; + fullHeight += 28; // under the subText +#else // TARGET_STAX subTextArea->obj.alignmentMarginY = 14; fullHeight += 26; // under the subText -#endif // TARGET_STAX +#endif // TARGET_STAX } else { #ifdef TARGET_STAX @@ -1097,7 +1093,7 @@ int nbgl_layoutAddText(nbgl_layout_t *layout, const char *text, const char *subT } else { #ifdef TARGET_STAX - fullHeight += BORDER_MARGIN; + fullHeight += 32; #else // TARGET_STAX fullHeight += 28; #endif // TARGET_STAX @@ -1189,9 +1185,13 @@ int nbgl_layoutAddTextContent(nbgl_layout_t *layout, textArea->wrapping = true; textArea->obj.alignment = NO_ALIGNMENT; textArea->obj.alignmentMarginX = BORDER_MARGIN; +#ifdef TARGET_STAX + textArea->obj.alignmentMarginY = 24; +#else // TARGET_STAX textArea->obj.alignmentMarginY = 16; - textArea->obj.area.width = AVAILABLE_WIDTH; - textArea->obj.area.height = nbgl_getTextHeightInWidth( +#endif // TARGET_STAX + textArea->obj.area.width = AVAILABLE_WIDTH; + textArea->obj.area.height = nbgl_getTextHeightInWidth( textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping); // set this new obj as child of main container layoutAddObject(layoutInt, (nbgl_obj_t *) textArea); @@ -1209,7 +1209,11 @@ int nbgl_layoutAddTextContent(nbgl_layout_t *layout, textArea->textAlignment = MID_LEFT; textArea->obj.alignment = NO_ALIGNMENT; textArea->obj.alignmentMarginX = BORDER_MARGIN; +#ifdef TARGET_STAX + textArea->obj.alignmentMarginY = 16; +#else // TARGET_STAX textArea->obj.alignmentMarginY = 24; +#endif // TARGET_STAX // set this new obj as child of main container layoutAddObject(layoutInt, (nbgl_obj_t *) textArea); @@ -1432,12 +1436,8 @@ int nbgl_layoutAddCenteredInfo(nbgl_layout_t *layout, const nbgl_layoutCenteredI textArea->obj.alignment = BOTTOM_MIDDLE; textArea->obj.alignTo = (nbgl_obj_t *) container->children[container->nbChildren - 1]; if (info->text1 != NULL) { -#ifdef TARGET_STAX - // if previous element is text1, only space of 20 px - textArea->obj.alignmentMarginY = 20; -#else // TARGET_STAX + // if previous element is text1, only space of 16 px textArea->obj.alignmentMarginY = 16; -#endif // TARGET_STAX } else { #ifdef TARGET_STAX @@ -1495,7 +1495,7 @@ int nbgl_layoutAddCenteredInfo(nbgl_layout_t *layout, const nbgl_layoutCenteredI textArea->obj.alignTo = (nbgl_obj_t *) container->children[container->nbChildren - 1]; #ifdef TARGET_STAX textArea->obj.alignmentMarginY - = (info->style == LARGE_CASE_BOLD_INFO) ? 0 : BORDER_MARGIN; + = (info->style == LARGE_CASE_BOLD_INFO) ? 16 : BORDER_MARGIN; #else // TARGET_STAX textArea->obj.alignmentMarginY = (info->style == LARGE_CASE_BOLD_INFO) ? 16 : 28; #endif // TARGET_STAX @@ -1592,11 +1592,7 @@ int nbgl_layoutAddQRCode(nbgl_layout_t *layout, const nbgl_layoutQRCode_t *info) textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping); textArea->obj.alignment = BOTTOM_MIDDLE; textArea->obj.alignTo = (nbgl_obj_t *) container->children[container->nbChildren - 1]; -#ifdef TARGET_STAX - textArea->obj.alignmentMarginY = 40; -#else // TARGET_STAX textArea->obj.alignmentMarginY = 24; -#endif // TARGET_STAX fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY; @@ -1615,11 +1611,17 @@ int nbgl_layoutAddQRCode(nbgl_layout_t *layout, const nbgl_layoutQRCode_t *info) textArea->fontId, textArea->text, textArea->obj.area.width, textArea->wrapping); textArea->obj.alignment = BOTTOM_MIDDLE; textArea->obj.alignTo = (nbgl_obj_t *) container->children[container->nbChildren - 1]; + if (info->text1 != NULL) { #ifdef TARGET_STAX - textArea->obj.alignmentMarginY = 40; + textArea->obj.alignmentMarginY = 40; #else // TARGET_STAX - textArea->obj.alignmentMarginY = 28; + textArea->obj.alignmentMarginY = 28; #endif // TARGET_STAX + } + else { + textArea->obj.alignmentMarginY = 32; + fullHeight += 8; + } fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY; @@ -1884,7 +1886,13 @@ int nbgl_layoutAddTagValueList(nbgl_layout_t *layout, const nbgl_layoutTagValueL container->layout = VERTICAL; container->obj.alignmentMarginX = BORDER_MARGIN; #ifdef TARGET_STAX - container->obj.alignmentMarginY = 12; + // On Stax, 12 px between each tag/value pair + if (i > 0) { + container->obj.alignmentMarginY = 12; + } + else { + container->obj.alignmentMarginY = 24; + } #else // TARGET_STAX // On Flex, 24 px between each tag/value pair if (i > 0) { @@ -2030,17 +2038,18 @@ int nbgl_layoutAddButton(nbgl_layout_t *layout, const nbgl_layoutButton_t *butto return -1; } -#ifdef TARGET_STAX - button->obj.alignmentMarginY = BORDER_MARGIN; -#else // TARGET_STAX - button->obj.alignmentMarginY = BOTTOM_BORDER_MARGIN; -#endif // TARGET_STAX if (buttonInfo->onBottom != true) { button->obj.alignmentMarginX = BORDER_MARGIN; + button->obj.alignmentMarginY = 12; button->obj.alignment = NO_ALIGNMENT; } else { button->obj.alignment = BOTTOM_MIDDLE; +#ifdef TARGET_STAX + button->obj.alignmentMarginY = 20; +#else // TARGET_STAX + button->obj.alignmentMarginY = 24; +#endif // TARGET_STAX } if (buttonInfo->style == BLACK_BACKGROUND) { button->innerColor = BLACK; @@ -2067,7 +2076,7 @@ int nbgl_layoutAddButton(nbgl_layout_t *layout, const nbgl_layoutButton_t *butto if (buttonInfo->fittingContent == true) { button->obj.area.width = nbgl_getTextWidth(button->fontId, button->text) + SMALL_BUTTON_HEIGHT - + ((button->icon) ? (button->icon->width + 8) : 0); + + ((button->icon) ? (button->icon->width + 12) : 0); button->obj.area.height = SMALL_BUTTON_HEIGHT; button->radius = RADIUS_32_PIXELS; if (buttonInfo->onBottom != true) { @@ -2196,11 +2205,12 @@ int nbgl_layoutAddFooter(nbgl_layout_t *layout, tune_index_e tuneId) { nbgl_layoutFooter_t footerDesc; - footerDesc.type = FOOTER_SIMPLE_TEXT; - footerDesc.separationLine = true; - footerDesc.simpleText.text = text; - footerDesc.simpleText.token = token; - footerDesc.simpleText.tuneId = tuneId; + footerDesc.type = FOOTER_SIMPLE_TEXT; + footerDesc.separationLine = true; + footerDesc.simpleText.text = text; + footerDesc.simpleText.mutedOut = false; + footerDesc.simpleText.token = token; + footerDesc.simpleText.tuneId = tuneId; return nbgl_layoutAddExtendedFooter(layout, &footerDesc); } @@ -2375,57 +2385,6 @@ int nbgl_layoutAddHeader(nbgl_layout_t *layout, const nbgl_layoutHeader_t *heade layoutInt->headerContainer->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT; break; } - case HEADER_BACK_AND_PROGRESS: { -#ifdef TARGET_STAX - // add optional back button - if (headerDesc->progressAndBack.withBack) { - button = (nbgl_button_t *) nbgl_objPoolGet(BUTTON, layoutInt->layer); - obj = layoutAddCallbackObj(layoutInt, - (nbgl_obj_t *) button, - headerDesc->progressAndBack.token, - headerDesc->progressAndBack.tuneId); - if (obj == NULL) { - return -1; - } - - button->obj.alignment = MID_LEFT; - button->innerColor = WHITE; - button->foregroundColor = BLACK; - button->borderColor = WHITE; - button->obj.area.width = BACK_KEY_WIDTH; - button->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT; - button->text = NULL; - button->icon = PIC(&LEFT_ARROW_ICON); - button->obj.touchMask = (1 << TOUCHED); - button->obj.touchId = BACK_BUTTON_ID; - // add to container - layoutInt->headerContainer->children[layoutInt->headerContainer->nbChildren] - = (nbgl_obj_t *) button; - layoutInt->headerContainer->nbChildren++; - } - - // add progress indicator - if (headerDesc->progressAndBack.nbPages > 1 - && headerDesc->progressAndBack.nbPages != NBGL_NO_PROGRESS_INDICATOR) { - nbgl_page_indicator_t *progress; - - progress - = (nbgl_page_indicator_t *) nbgl_objPoolGet(PAGE_INDICATOR, layoutInt->layer); - progress->activePage = headerDesc->progressAndBack.activePage; - progress->nbPages = headerDesc->progressAndBack.nbPages; - progress->obj.area.width = 224; - progress->obj.alignment = CENTER; - // add to container - layoutInt->headerContainer->children[layoutInt->headerContainer->nbChildren] - = (nbgl_obj_t *) progress; - layoutInt->headerContainer->nbChildren++; - } - layoutInt->activePage = headerDesc->progressAndBack.activePage; - layoutInt->nbPages = headerDesc->progressAndBack.nbPages; - layoutInt->headerContainer->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT; -#endif // TARGET_STAX - break; - } case HEADER_TITLE: { textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer); textArea->textColor = BLACK; @@ -2452,11 +2411,11 @@ int nbgl_layoutAddHeader(nbgl_layout_t *layout, const nbgl_layoutHeader_t *heade } textArea->obj.alignment = MID_RIGHT; textArea->textColor = BLACK; - textArea->obj.area.width = 124; - textArea->obj.area.height = 96; + textArea->obj.area.width = AVAILABLE_WIDTH; + textArea->obj.area.height = TOUCHABLE_HEADER_BAR_HEIGHT; textArea->text = PIC(headerDesc->rightText.text); textArea->fontId = SMALL_BOLD_FONT; - textArea->textAlignment = CENTER; + textArea->textAlignment = MID_RIGHT; textArea->obj.touchMask = (1 << TOUCHED); textArea->obj.touchId = TOP_RIGHT_BUTTON_ID; // add to bottom container @@ -2543,13 +2502,10 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ } textArea->obj.alignment = BOTTOM_MIDDLE; - textArea->textColor = BLACK; + textArea->textColor = (footerDesc->simpleText.mutedOut) ? LIGHT_GRAY : BLACK; textArea->obj.area.width = AVAILABLE_WIDTH; -#ifdef TARGET_STAX - textArea->obj.area.height = 88; -#else // TARGET_STAX - textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT; -#endif // TARGET_STAX + textArea->obj.area.height + = (footerDesc->simpleText.mutedOut) ? SMALL_FOOTER_HEIGHT : SIMPLE_FOOTER_HEIGHT; textArea->text = PIC(footerDesc->simpleText.text); textArea->fontId = SMALL_BOLD_FONT; textArea->textAlignment = CENTER; @@ -2570,19 +2526,15 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ if (obj == NULL) { return -1; } - textArea->obj.alignment = BOTTOM_LEFT; - textArea->textColor = BLACK; - textArea->obj.area.width = AVAILABLE_WIDTH / 2; -#ifdef TARGET_STAX - textArea->obj.area.height = 88; -#else // TARGET_STAX - textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT; -#endif // TARGET_STAX - textArea->text = PIC(footerDesc->doubleText.leftText); - textArea->fontId = SMALL_BOLD_FONT; - textArea->textAlignment = CENTER; - textArea->obj.touchMask = (1 << TOUCHED); - textArea->obj.touchId = BOTTOM_BUTTON_ID; + textArea->obj.alignment = BOTTOM_LEFT; + textArea->textColor = BLACK; + textArea->obj.area.width = AVAILABLE_WIDTH / 2; + textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT; + textArea->text = PIC(footerDesc->doubleText.leftText); + textArea->fontId = SMALL_BOLD_FONT; + textArea->textAlignment = CENTER; + textArea->obj.touchMask = (1 << TOUCHED); + textArea->obj.touchId = BOTTOM_BUTTON_ID; // add to bottom container layoutInt->footerContainer->children[layoutInt->footerContainer->nbChildren] = (nbgl_obj_t *) textArea; @@ -2598,19 +2550,15 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ return -1; } - textArea->obj.alignment = BOTTOM_RIGHT; - textArea->textColor = BLACK; - textArea->obj.area.width = AVAILABLE_WIDTH / 2; -#ifdef TARGET_STAX - textArea->obj.area.height = 88; -#else // TARGET_STAX - textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT; -#endif // TARGET_STAX - textArea->text = PIC(footerDesc->doubleText.rightText); - textArea->fontId = SMALL_BOLD_FONT; - textArea->textAlignment = CENTER; - textArea->obj.touchMask = (1 << TOUCHED); - textArea->obj.touchId = RIGHT_BUTTON_ID; + textArea->obj.alignment = BOTTOM_RIGHT; + textArea->textColor = BLACK; + textArea->obj.area.width = AVAILABLE_WIDTH / 2; + textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT; + textArea->text = PIC(footerDesc->doubleText.rightText); + textArea->fontId = SMALL_BOLD_FONT; + textArea->textAlignment = CENTER; + textArea->obj.touchMask = (1 << TOUCHED); + textArea->obj.touchId = RIGHT_BUTTON_ID; // add to bottom container layoutInt->footerContainer->children[layoutInt->footerContainer->nbChildren] = (nbgl_obj_t *) textArea; @@ -2630,7 +2578,6 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ break; } case FOOTER_TEXT_AND_NAV: { -#ifndef TARGET_STAX layoutInt->footerContainer->obj.area.width = SCREEN_WIDTH; layoutInt->footerContainer->obj.area.height = SIMPLE_FOOTER_HEIGHT; // add touchable text on the left @@ -2642,9 +2589,13 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ if (obj == NULL) { return -1; } - textArea->obj.alignment = BOTTOM_LEFT; - textArea->textColor = BLACK; - textArea->obj.area.width = 192; + textArea->obj.alignment = BOTTOM_LEFT; + textArea->textColor = BLACK; +#ifdef TARGET_STAX + textArea->obj.area.width = 160; +#else // TARGET_STAX + textArea->obj.area.width = 192; +#endif // TARGET_STAX textArea->obj.area.height = SIMPLE_FOOTER_HEIGHT; textArea->text = PIC(footerDesc->textAndNav.text); textArea->fontId = SMALL_BOLD_FONT; @@ -2693,13 +2644,10 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ layoutInt->footerContainer->children[layoutInt->footerContainer->nbChildren] = (nbgl_obj_t *) navContainer; layoutInt->footerContainer->nbChildren++; -#endif // TARGET_STAX break; } case FOOTER_NAV: { -#ifndef TARGET_STAX - layoutInt->footerContainer->obj.area.width = SCREEN_WIDTH; -#endif // TARGET_STAX + layoutInt->footerContainer->obj.area.width = SCREEN_WIDTH; layoutInt->footerContainer->obj.area.height = SIMPLE_FOOTER_HEIGHT; layoutNavigationPopulate( layoutInt->footerContainer, &footerDesc->navigation, layoutInt->layer); @@ -2753,7 +2701,7 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ button->radius = BUTTON_RADIUS; button->obj.area.height = BUTTON_DIAMETER; #ifdef TARGET_STAX - layoutInt->footerContainer->obj.area.height = SIMPLE_FOOTER_HEIGHT; + layoutInt->footerContainer->obj.area.height = 128; #else // TARGET_STAX layoutInt->footerContainer->obj.area.height = 136; #endif // TARGET_STAX @@ -2761,10 +2709,6 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ button->obj.area.width = BUTTON_DIAMETER; } else { -#ifdef TARGET_STAX - button->obj.alignment = TOP_MIDDLE; - layoutInt->footerContainer->obj.area.height = 104; -#endif // TARGET_STAX button->obj.area.width = AVAILABLE_WIDTH; } button->obj.touchMask = (1 << TOUCHED); @@ -2800,14 +2744,8 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ button->borderColor = WHITE; } else if (footerDesc->choiceButtons.style == BOTH_ROUNDED_STYLE) { -#ifdef TARGET_STAX - button->obj.alignmentMarginY - = BOTTOM_BORDER_MARGIN; // 24 pixels from screen bottom - button->borderColor = LIGHT_GRAY; -#else // TARGET_STAX button->obj.alignmentMarginY = 4; // 4 pixels from screen bottom button->borderColor = WHITE; // not a real round button on Flex -#endif // TARGET_STAX } button->innerColor = WHITE; button->foregroundColor = BLACK; @@ -2823,7 +2761,6 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ = (nbgl_obj_t *) button; layoutInt->footerContainer->nbChildren++; -#ifndef TARGET_STAX // add line if needed if (footerDesc->choiceButtons.style == BOTH_ROUNDED_STYLE) { line = createHorizontalLine(layoutInt->layer); @@ -2834,7 +2771,6 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ = (nbgl_obj_t *) line; layoutInt->footerContainer->nbChildren++; } -#endif // TARGET_STAX // then black button, on top of it button = (nbgl_button_t *) nbgl_objPoolGet(BUTTON, layoutInt->layer); @@ -2846,14 +2782,9 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ return -1; } // associate with with index 0 - obj->index = 0; - button->obj.alignment = TOP_MIDDLE; -#ifdef TARGET_STAX - button->innerColor = BLACK; - button->borderColor = BLACK; - button->foregroundColor = WHITE; -#else // TARGET_STAX - button->obj.alignmentMarginY = 24; // 12 pixels from bottom button + obj->index = 0; + button->obj.alignment = TOP_MIDDLE; + button->obj.alignmentMarginY = 24; // 12 pixels from bottom button if (footerDesc->choiceButtons.style == BOTH_ROUNDED_STYLE) { button->innerColor = WHITE; button->borderColor = LIGHT_GRAY; @@ -2864,7 +2795,6 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ button->borderColor = BLACK; button->foregroundColor = WHITE; } -#endif // TARGET_STAX button->obj.area.width = AVAILABLE_WIDTH; button->obj.area.height = BUTTON_DIAMETER; button->radius = BUTTON_RADIUS; @@ -2878,7 +2808,12 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ layoutInt->footerContainer->nbChildren++; #ifdef TARGET_STAX - layoutInt->footerContainer->obj.area.height = 168; + if (footerDesc->choiceButtons.style == BOTH_ROUNDED_STYLE) { + layoutInt->footerContainer->obj.area.height = 232; + } + else { + layoutInt->footerContainer->obj.area.height = 192; + } #else // TARGET_STAX if (footerDesc->choiceButtons.style == BOTH_ROUNDED_STYLE) { layoutInt->footerContainer->obj.area.height = 232; @@ -2929,39 +2864,6 @@ int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_ return layoutInt->footerContainer->obj.area.height; } -/** - * @brief Creates a kind of navigation bar with an optional <- arrow on the left. This widget is - * placed on top of the main container - * - * @param layout the current layout - * @param activePage current page [O,(nbPages-1)] - * @param nbPages number of pages - * @param withBack if true, the back arrow is drawn - * @param backToken token used with actionCallback is withBack is true - * @param tuneId if not @ref NBGL_NO_TUNE, a tune will be played when back button is pressed - * @return the height of the control if OK - */ -int nbgl_layoutAddProgressIndicator(nbgl_layout_t *layout, - uint8_t activePage, - uint8_t nbPages, - bool withBack, - uint8_t backToken, - tune_index_e tuneId) -{ - nbgl_layoutHeader_t headerDesc = {.type = HEADER_BACK_AND_PROGRESS, - .separationLine = false, - .progressAndBack.activePage = activePage, - .progressAndBack.nbPages = nbPages, - .progressAndBack.token = backToken, - .progressAndBack.tuneId = tuneId, - .progressAndBack.withBack = withBack, - .progressAndBack.actionIcon = NULL, - .progressAndBack.actionToken = NBGL_INVALID_TOKEN}; - LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddProgressIndicator():\n"); - - return nbgl_layoutAddHeader(layout, &headerDesc); -} - /** * @brief Creates a centered (vertically & horizontally) spinner with a text under it * diff --git a/lib_nbgl/src/nbgl_layout_internal.h b/lib_nbgl/src/nbgl_layout_internal.h index 5b20c1160..40602361e 100644 --- a/lib_nbgl/src/nbgl_layout_internal.h +++ b/lib_nbgl/src/nbgl_layout_internal.h @@ -29,7 +29,7 @@ extern "C" { * @brief Max number of complex objects with callback retrievable from pool * */ -#define LAYOUT_OBJ_POOL_LEN 10 +#define LAYOUT_OBJ_POOL_LEN 16 #define KEYBOARD_FOOTER_TYPE 99 #define KEYPAD_FOOTER_TYPE 98 @@ -56,8 +56,8 @@ enum { HEADER_INDEX = 0, // For header container TOP_RIGHT_BUTTON_INDEX, MAIN_CONTAINER_INDEX, - LEFT_BORDER_INDEX, FOOTER_INDEX, + LEFT_BORDER_INDEX, NB_MAX_SCREEN_CHILDREN }; diff --git a/lib_nbgl/src/nbgl_layout_keyboard.c b/lib_nbgl/src/nbgl_layout_keyboard.c index 5228f5247..7bdc0b8b4 100644 --- a/lib_nbgl/src/nbgl_layout_keyboard.c +++ b/lib_nbgl/src/nbgl_layout_keyboard.c @@ -25,19 +25,21 @@ /********************* * DEFINES *********************/ -#ifdef TARGET_STAX -#define FIRST_BUTTON_INDEX 0 -#else // TARGET_STAX // for suggestion buttons, on Flex there are other objects than buttons enum { PAGE_INDICATOR_INDEX = 0, +#ifndef TARGET_STAX LEFT_HALF_INDEX, // half disc displayed on the bottom left RIGHT_HALF_INDEX, // half disc displayed on the bottom right +#endif // TARGET_STAX FIRST_BUTTON_INDEX, SECOND_BUTTON_INDEX, +#ifdef TARGET_STAX + THIRD_BUTTON_INDEX, + FOURTH_BUTTON_INDEX, +#endif // TARGET_STAX NB_SUGGESTION_CHILDREN }; -#endif // TARGET_STAX #define TEXT_ENTRY_NORMAL_HEIGHT 64 #define TEXT_ENTRY_COMPACT_HEIGHT 56 @@ -65,61 +67,89 @@ static nbgl_image_t *partialButtonImages[2]; * STATIC PROTOTYPES **********************/ -#ifndef TARGET_STAX // function used on Flex to display (or not) beginning of next button and/or end of // previous button, and update buttons when swipping static bool updateSuggestionButtons(nbgl_container_t *container, nbgl_touchType_t eventType, uint8_t currentLeftButtonIndex) { - bool needRefresh = false; - uint8_t page = 0; - if ((eventType == SWIPED_LEFT) && (currentLeftButtonIndex < (uint32_t) (nbActiveButtons - 2))) { - // shift all buttons on the left if there are still at least 2 buttons to display - currentLeftButtonIndex += 2; + bool needRefresh = false; + uint8_t page = 0; + uint32_t i; + + if ((eventType == SWIPED_LEFT) + && (currentLeftButtonIndex + < (uint32_t) (nbActiveButtons - NB_MAX_VISIBLE_SUGGESTION_BUTTONS))) { + // shift all buttons on the left if there are still at least + // NB_MAX_VISIBLE_SUGGESTION_BUTTONS buttons to display + currentLeftButtonIndex += NB_MAX_VISIBLE_SUGGESTION_BUTTONS; container->children[FIRST_BUTTON_INDEX] = (nbgl_obj_t *) choiceButtons[currentLeftButtonIndex]; - if (currentLeftButtonIndex < (uint32_t) (nbActiveButtons - 1)) { - container->children[FIRST_BUTTON_INDEX + 1] - = (nbgl_obj_t *) choiceButtons[currentLeftButtonIndex + 1]; - } - else { - container->children[FIRST_BUTTON_INDEX + 1] = NULL; + + for (i = 1; i < NB_MAX_VISIBLE_SUGGESTION_BUTTONS; i++) { + if (currentLeftButtonIndex < (uint32_t) (nbActiveButtons - i)) { + container->children[FIRST_BUTTON_INDEX + i] + = (nbgl_obj_t *) choiceButtons[currentLeftButtonIndex + i]; + } + else { + container->children[FIRST_BUTTON_INDEX + i] = NULL; + } } - page = currentLeftButtonIndex / 2; + page = currentLeftButtonIndex / NB_MAX_VISIBLE_SUGGESTION_BUTTONS; needRefresh = true; } - else if ((eventType == SWIPED_RIGHT) && (currentLeftButtonIndex > 1)) { - // shift all buttons on the left if we are not already displaying the 2 first ones - currentLeftButtonIndex -= 2; - container->children[FIRST_BUTTON_INDEX] - = (nbgl_obj_t *) choiceButtons[currentLeftButtonIndex]; - container->children[FIRST_BUTTON_INDEX + 1] - = (nbgl_obj_t *) choiceButtons[currentLeftButtonIndex + 1]; - page = currentLeftButtonIndex / 2; + else if ((eventType == SWIPED_RIGHT) + && (currentLeftButtonIndex > (NB_MAX_VISIBLE_SUGGESTION_BUTTONS - 1))) { + // shift all buttons on the left if we are not already displaying the + // NB_MAX_VISIBLE_SUGGESTION_BUTTONS first ones + currentLeftButtonIndex -= NB_MAX_VISIBLE_SUGGESTION_BUTTONS; + for (i = 0; i < NB_MAX_VISIBLE_SUGGESTION_BUTTONS; i++) { + container->children[FIRST_BUTTON_INDEX + i] + = (nbgl_obj_t *) choiceButtons[currentLeftButtonIndex + i]; + } + page = currentLeftButtonIndex / NB_MAX_VISIBLE_SUGGESTION_BUTTONS; needRefresh = true; } - // align left button on the left - if (nbActiveButtons > 0) { + // align top-left button on the left + if (container->children[FIRST_BUTTON_INDEX] != NULL) { container->children[FIRST_BUTTON_INDEX]->alignmentMarginX = BORDER_MARGIN; + container->children[FIRST_BUTTON_INDEX]->alignmentMarginY = 0; container->children[FIRST_BUTTON_INDEX]->alignment = TOP_LEFT; container->children[FIRST_BUTTON_INDEX]->alignTo = (nbgl_obj_t *) container; } - // align right button on left one - if (container->children[FIRST_BUTTON_INDEX + 1] != NULL) { - container->children[FIRST_BUTTON_INDEX + 1]->alignmentMarginX = INTERNAL_MARGIN; - container->children[FIRST_BUTTON_INDEX + 1]->alignment = MID_RIGHT; - container->children[FIRST_BUTTON_INDEX + 1]->alignTo - = container->children[FIRST_BUTTON_INDEX]; + // align top-right button on top-left one + if (container->children[SECOND_BUTTON_INDEX] != NULL) { + container->children[SECOND_BUTTON_INDEX]->alignmentMarginX = INTERNAL_MARGIN; + container->children[SECOND_BUTTON_INDEX]->alignmentMarginY = 0; + container->children[SECOND_BUTTON_INDEX]->alignment = MID_RIGHT; + container->children[SECOND_BUTTON_INDEX]->alignTo = container->children[FIRST_BUTTON_INDEX]; + } +#ifdef TARGET_STAX + // align bottom-left button on top_left one + if (container->children[THIRD_BUTTON_INDEX] != NULL) { + container->children[THIRD_BUTTON_INDEX]->alignmentMarginX = 0; + container->children[THIRD_BUTTON_INDEX]->alignmentMarginY = INTERNAL_MARGIN; + container->children[THIRD_BUTTON_INDEX]->alignment = BOTTOM_MIDDLE; + container->children[THIRD_BUTTON_INDEX]->alignTo = container->children[FIRST_BUTTON_INDEX]; } - // on Flex, the first child is used by the progress indicator, displayed if more that 2 - // buttons + // align bottom-right button on bottom-left one + if (container->children[FOURTH_BUTTON_INDEX] != NULL) { + container->children[FOURTH_BUTTON_INDEX]->alignmentMarginX = INTERNAL_MARGIN; + container->children[FOURTH_BUTTON_INDEX]->alignmentMarginY = 0; + container->children[FOURTH_BUTTON_INDEX]->alignment = MID_RIGHT; + container->children[FOURTH_BUTTON_INDEX]->alignTo = container->children[THIRD_BUTTON_INDEX]; + } +#endif // TARGET_STAX + + // the first child is used by the progress indicator, displayed if more that + // NB_MAX_VISIBLE_SUGGESTION_BUTTONS buttons nbgl_page_indicator_t *indicator = (nbgl_page_indicator_t *) container->children[PAGE_INDICATOR_INDEX]; indicator->activePage = page; +#ifndef TARGET_STAX // if not on the first button, display end of previous button if (currentLeftButtonIndex > 0) { container->children[LEFT_HALF_INDEX] = (nbgl_obj_t *) partialButtonImages[0]; @@ -128,21 +158,20 @@ static bool updateSuggestionButtons(nbgl_container_t *container, container->children[LEFT_HALF_INDEX] = NULL; } // if not on the last button, display beginning of next button - if (currentLeftButtonIndex < (nbActiveButtons - 2)) { + if (currentLeftButtonIndex < (nbActiveButtons - NB_MAX_VISIBLE_SUGGESTION_BUTTONS)) { container->children[RIGHT_HALF_INDEX] = (nbgl_obj_t *) partialButtonImages[1]; } else { container->children[RIGHT_HALF_INDEX] = NULL; } +#endif // TARGET_STAX return needRefresh; } -#endif // TARGET_STAX /********************** * GLOBAL INTERNAL FUNCTIONS **********************/ -#ifdef TARGET_FLEX bool keyboardSwipeCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType) { nbgl_container_t *container = (nbgl_container_t *) obj; @@ -152,10 +181,10 @@ bool keyboardSwipeCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType) return false; } suggestionsContainer = (nbgl_container_t *) container->children[1]; - // try if suggestions buttons + // try if suggestions buttons (more than NB_MAX_VISIBLE_SUGGESTION_BUTTONS) if (((eventType == SWIPED_LEFT) || (eventType == SWIPED_RIGHT)) && (suggestionsContainer->nbChildren == (nbActiveButtons + FIRST_BUTTON_INDEX)) - && (nbActiveButtons > 2)) { + && (nbActiveButtons > NB_MAX_VISIBLE_SUGGESTION_BUTTONS)) { uint32_t i = 0; while (i < (uint32_t) nbActiveButtons) { if (suggestionsContainer->children[FIRST_BUTTON_INDEX] @@ -177,7 +206,6 @@ bool keyboardSwipeCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType) } return false; } -#endif // TARGET_FLEX static nbgl_container_t *addTextEntry(nbgl_layoutInternal_t *layoutInt, const char *title, @@ -311,19 +339,15 @@ static nbgl_container_t *addSuggestionButtons(nbgl_layoutInternal_t *layoutInt, suggestionsContainer->obj.area.width = SCREEN_WIDTH; #ifdef TARGET_STAX // 2 rows of buttons with radius=32, and a intervale of 8px - suggestionsContainer->obj.area.height = 2 * SMALL_BUTTON_HEIGHT + INTERNAL_MARGIN; - suggestionsContainer->nbChildren = nbActiveButtons; - suggestionsContainer->children = (nbgl_obj_t **) nbgl_containerPoolGet( - NB_MAX_VISIBLE_SUGGESTION_BUTTONS, layoutInt->layer); -#else // TARGET_STAX + suggestionsContainer->obj.area.height = 2 * SMALL_BUTTON_HEIGHT + INTERNAL_MARGIN + 28; +#else // TARGET_STAX // 1 row of buttons + 24px + page indicator suggestionsContainer->obj.area.height = SMALL_BUTTON_HEIGHT + 28; - // on Flex, the first child is used by the progress indicator, if more that 2 buttons +#endif // TARGET_STAX suggestionsContainer->nbChildren = nbActiveButtons + FIRST_BUTTON_INDEX; suggestionsContainer->children = (nbgl_obj_t **) nbgl_containerPoolGet(NB_SUGGESTION_CHILDREN, layoutInt->layer); -#endif // TARGET_STAX // put suggestionsContainer at 24px of the bottom of main container suggestionsContainer->obj.alignmentMarginY = compactMode ? 12 : 24; suggestionsContainer->obj.alignment = BOTTOM_MIDDLE; @@ -341,50 +365,31 @@ static nbgl_container_t *addSuggestionButtons(nbgl_layoutInternal_t *layoutInt, choiceButtons[i]->innerColor = BLACK; choiceButtons[i]->borderColor = BLACK; choiceButtons[i]->foregroundColor = WHITE; - choiceButtons[i]->obj.area.width = (SCREEN_WIDTH - 2 * BORDER_MARGIN - INTERNAL_MARGIN) / 2; + choiceButtons[i]->obj.area.width = (AVAILABLE_WIDTH - INTERNAL_MARGIN) / 2; choiceButtons[i]->obj.area.height = SMALL_BUTTON_HEIGHT; choiceButtons[i]->radius = RADIUS_32_PIXELS; choiceButtons[i]->fontId = SMALL_BOLD_1BPP_FONT; - choiceButtons[i]->icon = NULL; - if ((i % 2) == 0) { -#ifdef TARGET_STAX - choiceButtons[i]->obj.alignmentMarginX = BORDER_MARGIN; - // second row 8px under the first one - if (i != 0) { - choiceButtons[i]->obj.alignmentMarginY = INTERNAL_MARGIN; - } - choiceButtons[i]->obj.alignment = NO_ALIGNMENT; -#else // TARGET_STAX - choiceButtons[i]->obj.alignmentMarginX = BORDER_MARGIN + INTERNAL_MARGIN; - if (i == 0) { - choiceButtons[i]->obj.alignment = TOP_LEFT; - } -#endif // TARGET_STAX - } - else { - choiceButtons[i]->obj.alignmentMarginX = INTERNAL_MARGIN; - choiceButtons[i]->obj.alignment = MID_RIGHT; - choiceButtons[i]->obj.alignTo = (nbgl_obj_t *) choiceButtons[i - 1]; - } - choiceButtons[i]->text = buttonTexts[i]; - choiceButtons[i]->obj.touchMask = (1 << TOUCHED); - choiceButtons[i]->obj.touchId = CONTROLS_ID + i; + choiceButtons[i]->text = buttonTexts[i]; + choiceButtons[i]->obj.touchMask = (1 << TOUCHED); + choiceButtons[i]->obj.touchId = CONTROLS_ID + i; // some buttons may not be visible if (i < MIN(NB_MAX_VISIBLE_SUGGESTION_BUTTONS, nbActiveButtons)) { suggestionsContainer->children[i + FIRST_BUTTON_INDEX] = (nbgl_obj_t *) choiceButtons[i]; } } -#ifdef TARGET_FLEX - // on Flex, the first child is used by the progress indicator, if more that 2 buttons + // The first child is used by the progress indicator, if more that + // NB_MAX_VISIBLE_SUGGESTION_BUTTONS buttons nbgl_page_indicator_t *indicator = (nbgl_page_indicator_t *) nbgl_objPoolGet(PAGE_INDICATOR, layoutInt->layer); - indicator->activePage = 0; - indicator->nbPages = (nbActiveButtons + 1) / 2; + indicator->activePage = 0; + indicator->nbPages = (nbActiveButtons + NB_MAX_VISIBLE_SUGGESTION_BUTTONS - 1) + / NB_MAX_VISIBLE_SUGGESTION_BUTTONS; indicator->obj.area.width = 184; indicator->obj.alignment = BOTTOM_MIDDLE; indicator->style = CURRENT_INDICATOR; suggestionsContainer->children[PAGE_INDICATOR_INDEX] = (nbgl_obj_t *) indicator; +#ifdef TARGET_FLEX // also allocate the semi disc that may be displayed on the left or right of the full // buttons nbgl_objPoolGetArray(IMAGE, 2, layoutInt->layer, (nbgl_obj_t **) &partialButtonImages); @@ -474,7 +479,7 @@ int nbgl_layoutAddKeyboard(nbgl_layout_t *layout, const nbgl_layoutKbd_t *kbdInf keyboard->obj.area.height += KEYBOARD_KEY_HEIGHT; } #ifdef TARGET_STAX - keyboard->obj.alignmentMarginY = 64; + keyboard->obj.alignmentMarginY = 56; #endif // TARGET_STAX keyboard->obj.alignment = BOTTOM_MIDDLE; keyboard->borderColor = LIGHT_GRAY; @@ -582,138 +587,6 @@ bool nbgl_layoutKeyboardNeedsRefresh(nbgl_layout_t *layout, uint8_t index) return false; } -/** - * @brief Adds up to 4 black suggestion buttons under the previously added object - * @deprecated Use @ref nbgl_layoutAddKeyboardContent instead - * - * @param layout the current layout - * @param nbUsedButtons the number of actually used buttons - * @param buttonTexts array of 4 strings for buttons (last ones can be NULL) - * @param firstButtonToken first token used for buttons, provided in onActionCallback (the next 3 - * values will be used for other buttons) - * @param tuneId tune to play when any button is pressed - * @return >= 0 if OK - */ -int nbgl_layoutAddSuggestionButtons(nbgl_layout_t *layout, - uint8_t nbUsedButtons, - const char *buttonTexts[NB_MAX_SUGGESTION_BUTTONS], - int firstButtonToken, - tune_index_e tuneId) -{ - nbgl_container_t *container; - nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout; - // if a centered info has be used for title, entered text is the second child - uint8_t enteredTextIndex = (layoutInt->container->nbChildren == 2) ? 0 : 1; - - LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddSuggestionButtons():\n"); - if (layout == NULL) { - return -1; - } - - container = addSuggestionButtons( - layoutInt, nbUsedButtons, buttonTexts, firstButtonToken, tuneId, false); - // set this container as 2nd or 3rd child of the main layout container - layoutInt->container->children[enteredTextIndex + 1] = (nbgl_obj_t *) container; - if (layoutInt->container->children[enteredTextIndex] != NULL) { - ((nbgl_container_t *) layoutInt->container->children[enteredTextIndex]) - ->obj.alignmentMarginY - -= (container->obj.area.height + container->obj.alignmentMarginY + 20) / 2; - } -#ifdef TARGET_FLEX - // the main container is swipable on Flex - if (layoutAddCallbackObj(layoutInt, (nbgl_obj_t *) layoutInt->container, 0, NBGL_NO_TUNE) - == NULL) { - return -1; - } - layoutInt->container->obj.touchMask = (1 << SWIPED_LEFT) | (1 << SWIPED_RIGHT); - layoutInt->container->obj.touchId = CONTROLS_ID; - layoutInt->swipeUsage = SWIPE_USAGE_SUGGESTIONS; -#endif // TARGET_FLEX - // set this new container as child of the main container - layoutAddObject(layoutInt, (nbgl_obj_t *) container); - - // return index of container to be modified later on - return (layoutInt->container->nbChildren - 1); -} - -/** - * @brief Updates the number and/or the text suggestion buttons created with @ref - * nbgl_layoutAddSuggestionButtons() - * @deprecated Use @ref nbgl_layoutUpdateKeyboardContent instead - * - * @param layout the current layout - * @param index index returned by @ref nbgl_layoutAddSuggestionButtons() (unused) - * @param nbUsedButtons the number of actually used buttons - * @param buttonTexts array of 4 strings for buttons (last ones can be NULL) - * @return >= 0 if OK - */ -int nbgl_layoutUpdateSuggestionButtons(nbgl_layout_t *layout, - uint8_t index, - uint8_t nbUsedButtons, - const char *buttonTexts[NB_MAX_SUGGESTION_BUTTONS]) -{ - nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout; - nbgl_container_t *container; - uint8_t enteredTextIndex = (layoutInt->container->nbChildren == 2) ? 0 : 1; - - LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutUpdateSuggestionButtons():\n"); - if (layout == NULL) { - return -1; - } - UNUSED(index); - - container = (nbgl_container_t *) layoutInt->container->children[enteredTextIndex + 1]; - if ((container == NULL) || (container->obj.type != CONTAINER)) { - return -1; - } - nbActiveButtons = nbUsedButtons; - container->nbChildren = nbUsedButtons + FIRST_BUTTON_INDEX; - - // update suggestion buttons - for (int i = 0; i < NB_MAX_SUGGESTION_BUTTONS; i++) { - choiceButtons[i]->text = buttonTexts[i]; - // some buttons may not be visible - if (i < MIN(NB_MAX_VISIBLE_SUGGESTION_BUTTONS, nbUsedButtons)) { - if ((i % 2) == 0) { - choiceButtons[i]->obj.alignmentMarginX = BORDER_MARGIN; -#ifdef TARGET_STAX - // second row 8px under the first one - if (i != 0) { - choiceButtons[i]->obj.alignmentMarginY = INTERNAL_MARGIN; - } - choiceButtons[i]->obj.alignment = NO_ALIGNMENT; -#else // TARGET_STAX - if (i == 0) { - choiceButtons[i]->obj.alignment = TOP_LEFT; - } -#endif // TARGET_STAX - } - else { - choiceButtons[i]->obj.alignmentMarginX = INTERNAL_MARGIN; - choiceButtons[i]->obj.alignment = MID_RIGHT; - choiceButtons[i]->obj.alignTo = (nbgl_obj_t *) choiceButtons[i - 1]; - } - container->children[i + FIRST_BUTTON_INDEX] = (nbgl_obj_t *) choiceButtons[i]; - } - else { - container->children[i + FIRST_BUTTON_INDEX] = NULL; - } - } - container->forceClean = true; -#ifndef TARGET_STAX - // on Flex, the first child is used by the progress indicator, if more that 2 buttons - nbgl_page_indicator_t *indicator - = (nbgl_page_indicator_t *) container->children[PAGE_INDICATOR_INDEX]; - indicator->nbPages = (nbUsedButtons + 1) / 2; - indicator->activePage = 0; - updateSuggestionButtons(container, 0, 0); -#endif // TARGET_STAX - - nbgl_redrawObject((nbgl_obj_t *) container, NULL, false); - - return 0; -} - /** * @brief Adds a "text entry" area under the previously entered object. This area can be preceded * (beginning of line) by an index, indicating for example the entered world. A vertical gray line @@ -975,7 +848,6 @@ int nbgl_layoutAddKeyboardContent(nbgl_layout_t *layout, nbgl_layoutKeyboardCont compactMode); // set this container as second child of the main layout container layoutInt->container->children[1] = (nbgl_obj_t *) suggestionsContainer; -#ifdef TARGET_FLEX // the main container is swipable on Flex if (layoutAddCallbackObj(layoutInt, (nbgl_obj_t *) layoutInt->container, 0, NBGL_NO_TUNE) == NULL) { @@ -984,7 +856,6 @@ int nbgl_layoutAddKeyboardContent(nbgl_layout_t *layout, nbgl_layoutKeyboardCont layoutInt->container->obj.touchMask = (1 << SWIPED_LEFT) | (1 << SWIPED_RIGHT); layoutInt->container->obj.touchId = CONTROLS_ID; layoutInt->swipeUsage = SWIPE_USAGE_SUGGESTIONS; -#endif // TARGET_FLEX container->obj.alignmentMarginY -= (suggestionsContainer->obj.area.height + suggestionsContainer->obj.alignmentMarginY + (compactMode ? 12 : 20)) @@ -1055,25 +926,6 @@ int nbgl_layoutUpdateKeyboardContent(nbgl_layout_t *layout, nbgl_layoutKeyboardC choiceButtons[i]->text = content->suggestionButtons.buttons[i]; // some buttons may not be visible if (i < MIN(NB_MAX_VISIBLE_SUGGESTION_BUTTONS, nbActiveButtons)) { - if ((i % 2) == 0) { - choiceButtons[i]->obj.alignmentMarginX = BORDER_MARGIN; -#ifdef TARGET_STAX - // second row 8px under the first one - if (i != 0) { - choiceButtons[i]->obj.alignmentMarginY = INTERNAL_MARGIN; - } - choiceButtons[i]->obj.alignment = NO_ALIGNMENT; -#else // TARGET_STAX - if (i == 0) { - choiceButtons[i]->obj.alignment = TOP_LEFT; - } -#endif // TARGET_STAX - } - else { - choiceButtons[i]->obj.alignmentMarginX = INTERNAL_MARGIN; - choiceButtons[i]->obj.alignment = MID_RIGHT; - choiceButtons[i]->obj.alignTo = (nbgl_obj_t *) choiceButtons[i - 1]; - } suggestionsContainer->children[i + FIRST_BUTTON_INDEX] = (nbgl_obj_t *) choiceButtons[i]; } @@ -1082,14 +934,14 @@ int nbgl_layoutUpdateKeyboardContent(nbgl_layout_t *layout, nbgl_layoutKeyboardC } } suggestionsContainer->forceClean = true; -#ifndef TARGET_STAX - // on Flex, the first child is used by the progress indicator, if more that 2 buttons + // the first child is used by the progress indicator, if more than + // NB_MAX_VISIBLE_SUGGESTION_BUTTONS buttons nbgl_page_indicator_t *indicator = (nbgl_page_indicator_t *) suggestionsContainer->children[PAGE_INDICATOR_INDEX]; - indicator->nbPages = (nbActiveButtons + 1) / 2; + indicator->nbPages = (nbActiveButtons + NB_MAX_VISIBLE_SUGGESTION_BUTTONS - 1) + / NB_MAX_VISIBLE_SUGGESTION_BUTTONS; indicator->activePage = 0; updateSuggestionButtons(suggestionsContainer, 0, 0); -#endif // TARGET_STAX nbgl_redrawObject((nbgl_obj_t *) suggestionsContainer, NULL, false); } diff --git a/lib_nbgl/src/nbgl_layout_keypad.c b/lib_nbgl/src/nbgl_layout_keypad.c index d1e9126e1..b776eb15c 100644 --- a/lib_nbgl/src/nbgl_layout_keypad.c +++ b/lib_nbgl/src/nbgl_layout_keypad.c @@ -377,7 +377,11 @@ int nbgl_layoutAddKeypadContent(nbgl_layout_t *layout, space = 4; } else { +#ifdef TARGET_STAX + space = 10; +#else // TARGET_STAX space = 12; +#endif // TARGET_STAX } // create digits container, to store "discs" @@ -387,12 +391,8 @@ int nbgl_layoutAddKeypadContent(nbgl_layout_t *layout, = nbgl_containerPoolGet(digitsContainer->nbChildren, layoutInt->layer); // pixels between each icon (knowing that the effective round are 18px large and the // icon 24px) - digitsContainer->obj.area.width = nbDigits * DIGIT_ICON.width + (nbDigits - 1) * space; -#ifdef TARGET_STAX - digitsContainer->obj.area.height = 50; -#else // TARGET_STAX + digitsContainer->obj.area.width = nbDigits * DIGIT_ICON.width + (nbDigits - 1) * space; digitsContainer->obj.area.height = 64; -#endif // TARGET_STAX // align at the bottom of title digitsContainer->obj.alignTo = container->children[0]; digitsContainer->obj.alignment = BOTTOM_MIDDLE; @@ -441,9 +441,9 @@ int nbgl_layoutAddKeypadContent(nbgl_layout_t *layout, line = (nbgl_line_t *) nbgl_objPoolGet(LINE, layoutInt->layer); line->lineColor = LIGHT_GRAY; line->obj.alignmentMarginY = 0; - line->obj.alignTo = NULL; + line->obj.alignTo = container->children[1]; line->obj.alignment = BOTTOM_MIDDLE; - line->obj.area.width = container->obj.area.width; + line->obj.area.width = 288; line->obj.area.height = 4; line->direction = HORIZONTAL; line->thickness = 2; diff --git a/lib_nbgl/src/nbgl_layout_navigation.c b/lib_nbgl/src/nbgl_layout_navigation.c index fad6ff34c..05dfb7fad 100644 --- a/lib_nbgl/src/nbgl_layout_navigation.c +++ b/lib_nbgl/src/nbgl_layout_navigation.c @@ -23,18 +23,15 @@ *********************/ #define INTERNAL_SMALL_MARGIN 8 +#define BORDER_COLOR WHITE #ifdef TARGET_STAX -#define BORDER_COLOR LIGHT_GRAY -#define NAVIGATION_HEIGHT (BUTTON_DIAMETER + 2 * BORDER_MARGIN) -#define NAV_BUTTON_HEIGHT BUTTON_DIAMETER -#define NAV_BUTTON_WIDTH 128 -#define NAV_BUTTON_WIDTH_WITHOUT_EXIT 172 +#define NAVIGATION_HEIGHT 92 +#define NAV_BUTTON_HEIGHT 80 +#define NAV_BUTTON_WIDTH 80 #else // TARGET_STAX -#define BORDER_COLOR WHITE -#define NAVIGATION_HEIGHT 96 -#define NAV_BUTTON_HEIGHT NAVIGATION_HEIGHT -#define NAV_BUTTON_WIDTH 104 -#define NAV_BUTTON_WIDTH_WITHOUT_EXIT NAV_BUTTON_WIDTH +#define NAVIGATION_HEIGHT 96 +#define NAV_BUTTON_HEIGHT NAVIGATION_HEIGHT +#define NAV_BUTTON_WIDTH 104 #endif // TARGET_STAX /********************** @@ -51,9 +48,7 @@ enum { /********************** * STATIC VARIABLES **********************/ -#ifndef TARGET_STAX static char navText[11]; // worst case is "ccc of nnn" -#endif // TARGET_STAX /********************** * VARIABLES @@ -153,16 +148,14 @@ void layoutNavigationPopulate(nbgl_container_t *navContainer, nbgl_button_t *button; if (navConfig->withExitKey) { - button = (nbgl_button_t *) nbgl_objPoolGet(BUTTON, layer); - button->innerColor = WHITE; - button->borderColor = BORDER_COLOR; - button->obj.area.width = BUTTON_DIAMETER; - button->obj.area.height = BUTTON_DIAMETER; - button->radius = BUTTON_RADIUS; - button->icon = &CLOSE_ICON; -#ifdef TARGET_FLEX + button = (nbgl_button_t *) nbgl_objPoolGet(BUTTON, layer); + button->innerColor = WHITE; + button->borderColor = BORDER_COLOR; + button->obj.area.width = BUTTON_DIAMETER; + button->obj.area.height = BUTTON_DIAMETER; + button->radius = BUTTON_RADIUS; + button->icon = &CLOSE_ICON; button->obj.alignmentMarginX = (navConfig->nbPages > 1) ? 8 : 0; -#endif // TARGET_FLEX button->obj.alignment = (navConfig->nbPages > 1) ? MID_LEFT : CENTER; button->obj.touchMask = (1 << TOUCHED); @@ -171,66 +164,35 @@ void layoutNavigationPopulate(nbgl_container_t *navContainer, } // create previous page button (back) if (navConfig->withBackKey) { - button = (nbgl_button_t *) nbgl_objPoolGet(BUTTON, layer); - button->innerColor = WHITE; - button->borderColor = BORDER_COLOR; - if (navConfig->withExitKey) { - button->obj.area.width = NAV_BUTTON_WIDTH; - } - else { - button->obj.area.width = NAV_BUTTON_WIDTH_WITHOUT_EXIT; - } + button = (nbgl_button_t *) nbgl_objPoolGet(BUTTON, layer); + button->innerColor = WHITE; + button->borderColor = BORDER_COLOR; + button->obj.area.width = NAV_BUTTON_WIDTH; button->obj.area.height = NAV_BUTTON_HEIGHT; button->radius = BUTTON_RADIUS; -#ifdef TARGET_STAX - button->icon = &LEFT_ARROW_ICON; - // align either on the right of Exit key, or on the inner left of the container - if (navConfig->withExitKey) { - button->obj.alignmentMarginX = INTERNAL_SMALL_MARGIN; - button->obj.alignment = MID_RIGHT; - button->obj.alignTo = navContainer->children[EXIT_BUTTON_INDEX]; - } - else { - button->obj.alignment = MID_LEFT; - } -#else // TARGET_STAX - button->icon = &C_Chevron_Back_40px; + button->icon = &CHEVRON_BACK_ICON; // align on the right of the container, leaving space for "Next" button - button->obj.alignment = MID_RIGHT; - button->obj.alignmentMarginX = NAV_BUTTON_WIDTH; -#endif // TARGET_STAX + button->obj.alignment = MID_RIGHT; + button->obj.alignmentMarginX = NAV_BUTTON_WIDTH; button->obj.touchMask = (1 << TOUCHED); button->obj.touchId = LEFT_BUTTON_ID; navContainer->children[PREVIOUS_PAGE_INDEX] = (nbgl_obj_t *) button; } // create next page button - button = (nbgl_button_t *) nbgl_objPoolGet(BUTTON, layer); - button->innerColor = WHITE; - button->borderColor = BORDER_COLOR; - button->foregroundColor = BLACK; - if (navConfig->withExitKey) { - button->obj.area.width = NAV_BUTTON_WIDTH; - } - else { - button->obj.area.width = NAV_BUTTON_WIDTH_WITHOUT_EXIT; - } - button->obj.area.height = NAV_BUTTON_HEIGHT; - button->radius = BUTTON_RADIUS; -#ifdef TARGET_STAX - button->icon = &RIGHT_ARROW_ICON; - // on Stax, align next button on the right of left one - button->obj.alignmentMarginX = INTERNAL_SMALL_MARGIN; - button->obj.alignTo = navContainer->children[PREVIOUS_PAGE_INDEX]; -#else // TARGET_STAX - button->icon = &C_Chevron_Next_40px; -#endif // TARGET_STAX + button = (nbgl_button_t *) nbgl_objPoolGet(BUTTON, layer); + button->innerColor = WHITE; + button->borderColor = BORDER_COLOR; + button->foregroundColor = BLACK; + button->obj.area.width = NAV_BUTTON_WIDTH; + button->obj.area.height = NAV_BUTTON_HEIGHT; + button->radius = BUTTON_RADIUS; + button->icon = &CHEVRON_NEXT_ICON; button->obj.alignment = MID_RIGHT; button->obj.touchMask = (1 << TOUCHED); button->obj.touchId = RIGHT_BUTTON_ID; navContainer->children[NEXT_PAGE_INDEX] = (nbgl_obj_t *) button; -#ifdef TARGET_FLEX // potentially create page indicator (with a text area, and "page of nb_page") if (navConfig->withPageIndicator) { if (navConfig->visibleIndicator) { @@ -238,9 +200,13 @@ void layoutNavigationPopulate(nbgl_container_t *navContainer, SPRINTF(navText, "%d of %d", navConfig->activePage + 1, navConfig->nbPages); - textArea->obj.alignment = BOTTOM_RIGHT; - textArea->textColor = DARK_GRAY; - textArea->obj.area.width = 109; + textArea->obj.alignment = BOTTOM_RIGHT; + textArea->textColor = DARK_GRAY; +#ifdef TARGET_STAX + textArea->obj.area.width = 109; +#else // TARGET_STAX + textArea->obj.area.width = 89; +#endif // TARGET_STAX textArea->text = navText; textArea->fontId = SMALL_REGULAR_FONT; textArea->obj.area.height = NAV_BUTTON_HEIGHT; @@ -253,7 +219,6 @@ void layoutNavigationPopulate(nbgl_container_t *navContainer, navContainer->children[PREVIOUS_PAGE_INDEX]->alignmentMarginX += 79; } } -#endif // TARGET_FLEX // configure enabling/disabling of button configButtons(navContainer, navConfig->nbPages, navConfig->activePage); diff --git a/lib_nbgl/src/nbgl_obj.c b/lib_nbgl/src/nbgl_obj.c index e07d1b6fc..1dd3cfadb 100644 --- a/lib_nbgl/src/nbgl_obj.c +++ b/lib_nbgl/src/nbgl_obj.c @@ -26,11 +26,7 @@ /********************* * DEFINES *********************/ -#ifdef TARGET_STAX -#define NB_MAX_PAGES_WITH_DASHES 10 -#else // TARGET_STAX #define NB_MAX_PAGES_WITH_DASHES 6 -#endif // TARGET_STAX // max number of letters in TEXT_ENTRY #define NB_MAX_LETTERS 9 @@ -255,10 +251,6 @@ static void compute_relativePosition(nbgl_obj_t *obj, nbgl_obj_t *prevObj) } } } -#ifdef TARGET_STAX - // align on multiples of 4 - obj->rel_y0 &= ~0x3; -#endif // TARGET_STAX } static void compute_position(nbgl_obj_t *obj, nbgl_obj_t *prevObj) @@ -346,6 +338,7 @@ static void draw_button(nbgl_button_t *obj, nbgl_obj_t *prevObj, bool computePos { uint16_t textWidth = 0; const char *text = NULL; +#define ICON_TEXT_SPACE 12 if (computePosition) { compute_position((nbgl_obj_t *) obj, prevObj); @@ -394,8 +387,8 @@ static void draw_button(nbgl_button_t *obj, nbgl_obj_t *prevObj, bool computePos rectArea.y0 += (obj->obj.area.height - rectArea.height) / 2; rectArea.width = obj->obj.area.width; if (obj->icon != NULL) { - rectArea.x0 += obj->icon->width + 8; - rectArea.width -= obj->icon->width + 8; + rectArea.x0 += obj->icon->width + ICON_TEXT_SPACE; + rectArea.width -= obj->icon->width + ICON_TEXT_SPACE; } // Compute the width & number of characters displayed on first line uint16_t textLen; @@ -419,8 +412,8 @@ static void draw_button(nbgl_button_t *obj, nbgl_obj_t *prevObj, bool computePos nbgl_area_t rectArea; if (text != NULL) { - iconX0 - = obj->obj.area.x0 + (obj->obj.area.width - (textWidth + obj->icon->width + 8)) / 2; + iconX0 = obj->obj.area.x0 + + (obj->obj.area.width - (textWidth + obj->icon->width + ICON_TEXT_SPACE)) / 2; } else { iconX0 = obj->obj.area.x0 + (obj->obj.area.width - obj->icon->width) / 2; diff --git a/lib_nbgl/src/nbgl_page.c b/lib_nbgl/src/nbgl_page.c index 7e44ff5cb..2095a935a 100644 --- a/lib_nbgl/src/nbgl_page.c +++ b/lib_nbgl/src/nbgl_page.c @@ -28,6 +28,13 @@ /********************** * STATIC PROTOTYPES **********************/ +static void addEmptyHeader(nbgl_layout_t *layout, uint16_t height) +{ + nbgl_layoutHeader_t headerDesc + = {.type = HEADER_EMPTY, .separationLine = false, .emptySpace.height = height}; + nbgl_layoutAddHeader(layout, &headerDesc); +} + static void addContent(nbgl_pageContent_t *content, nbgl_layout_t *layout, uint16_t availableHeight, @@ -87,27 +94,21 @@ static void addContent(nbgl_pageContent_t *content, } case CENTERED_INFO: if (!headerAdded) { - nbgl_layoutHeader_t headerDesc - = {.type = HEADER_EMPTY, .separationLine = false, .emptySpace.height = 40}; - nbgl_layoutAddHeader(layout, &headerDesc); + addEmptyHeader(layout, SMALL_CENTERING_HEADER); } nbgl_layoutAddCenteredInfo(layout, &content->centeredInfo); break; case TAG_VALUE_LIST: - // add a space of 40px if no header already add + // add a space of 32/40px if no header already added if (!headerAdded) { - nbgl_layoutHeader_t headerDesc - = {.type = HEADER_EMPTY, .separationLine = false, .emptySpace.height = 40}; - nbgl_layoutAddHeader(layout, &headerDesc); + addEmptyHeader(layout, SMALL_CENTERING_HEADER); } nbgl_layoutAddTagValueList(layout, &content->tagValueList); break; case TAG_VALUE_DETAILS: { - // add a space of 40px if no header already add + // add a space of 32/40px if no header already added if (!headerAdded) { - nbgl_layoutHeader_t headerDesc - = {.type = HEADER_EMPTY, .separationLine = false, .emptySpace.height = 40}; - nbgl_layoutAddHeader(layout, &headerDesc); + addEmptyHeader(layout, SMALL_CENTERING_HEADER); } // display a button under tag/value nbgl_layoutButton_t buttonInfo; @@ -126,12 +127,10 @@ static void addContent(nbgl_pageContent_t *content, case TAG_VALUE_CONFIRM: { nbgl_layoutButton_t buttonInfo; if (!headerAdded) { - nbgl_layoutHeader_t headerDesc - = {.type = HEADER_EMPTY, .separationLine = false, .emptySpace.height = 40}; - nbgl_layoutAddHeader(layout, &headerDesc); + addEmptyHeader(layout, SMALL_CENTERING_HEADER); } nbgl_layoutAddTagValueList(layout, &content->tagValueConfirm.tagValueList); - // on Stax, always display the details button as a normal button (full width), + // Always display the details button as a normal button (full width), // even if "Confirm" button is on the same page if (content->tagValueConfirm.detailsButtonText != NULL) { buttonInfo.fittingContent = true; @@ -257,6 +256,7 @@ nbgl_page_t *nbgl_pageDrawLedgerInfo(nbgl_layoutTouchCallback_t onA layoutDescription.ticker.tickerValue = ticker->tickerValue; layout = nbgl_layoutGet(&layoutDescription); + addEmptyHeader(layout, SIMPLE_FOOTER_HEIGHT); nbgl_layoutAddCenteredInfo(layout, ¢eredInfo); nbgl_layoutDraw(layout); @@ -337,9 +337,7 @@ nbgl_page_t *nbgl_pageDrawInfo(nbgl_layoutTouchCallback_t onActionC } // add an empty header if a top-right button is used if (info->topRightStyle != NO_BUTTON_STYLE) { - nbgl_layoutHeader_t headerDesc - = {.type = HEADER_EMPTY, .separationLine = false, .emptySpace.height = 40}; - nbgl_layoutAddHeader(layout, &headerDesc); + addEmptyHeader(layout, SMALL_CENTERING_HEADER); } nbgl_layoutAddCenteredInfo(layout, &info->centeredInfo); @@ -385,18 +383,7 @@ nbgl_page_t *nbgl_pageDrawInfo(nbgl_layoutTouchCallback_t onActionC nbgl_layoutAddChoiceButtons(layout, &buttonsInfo); } else { -#ifdef TARGET_STAX - nbgl_layoutButton_t buttonInfo = {.fittingContent = false, - .icon = NULL, - .onBottom = true, - .style = WHITE_BACKGROUND, - .text = "Quit app", - .token = info->bottomButtonsToken, - .tuneId = info->tuneId}; - nbgl_layoutAddButton(layout, &buttonInfo); -#else // TARGET_STAX nbgl_layoutAddFooter(layout, "Quit app", info->bottomButtonsToken, info->tuneId); -#endif // TARGET_STAX } } else if (info->bottomButtonStyle != NO_BUTTON_STYLE) { @@ -460,9 +447,7 @@ nbgl_page_t *nbgl_pageDrawConfirmation(nbgl_layoutTouchCallback_t .topText = PIC(info->confirmationText), .style = ROUNDED_AND_FOOTER_STYLE, .tuneId = info->tuneId}; - nbgl_layoutHeader_t headerDesc - = {.type = HEADER_EMPTY, .separationLine = false, .emptySpace.height = 64}; - nbgl_layoutAddHeader(layout, &headerDesc); + addEmptyHeader(layout, MEDIUM_CENTERING_HEADER); nbgl_layoutAddChoiceButtons(layout, &buttonsInfo); } nbgl_layoutAddCenteredInfo(layout, &info->centeredInfo); @@ -497,102 +482,62 @@ nbgl_page_t *nbgl_pageDrawGenericContentExt(nbgl_layoutTouchCallback_t onA layoutDescription.onActionCallback = onActionCallback; layoutDescription.ticker.tickerCallback = NULL; - if ((nav != NULL) && (nav->navType == NAV_WITH_TAP)) { - layoutDescription.tapActionText = nav->navWithTap.nextPageText; - layoutDescription.tapActionToken = nav->navWithTap.nextPageToken; - layoutDescription.tapTuneId = nav->tuneId; - } - else { - layoutDescription.tapActionText = NULL; - } + layoutDescription.tapActionText = NULL; layout = nbgl_layoutGet(&layoutDescription); if (nav != NULL) { - if (nav->navType == NAV_WITH_TAP) { - if (nav->skipText == NULL) { - availableHeight -= nbgl_layoutAddFooter( - layout, nav->navWithTap.quitText, nav->quitToken, nav->tuneId); - } - else { - availableHeight -= nbgl_layoutAddSplitFooter(layout, - nav->navWithTap.quitText, - nav->quitToken, - nav->skipText, - nav->skipToken, - nav->tuneId); - } - if (nav->progressIndicator) { - availableHeight -= nbgl_layoutAddProgressIndicator(layout, - nav->activePage, - nav->nbPages, - nav->navWithTap.backButton, - nav->navWithTap.backToken, - nav->tuneId); - headerAdded = true; - } + nbgl_layoutFooter_t footerDesc; + bool drawFooter = true; + + if (nav->skipText != NULL) { + nbgl_layoutHeader_t headerDesc = {.type = HEADER_RIGHT_TEXT, + .separationLine = false, + .rightText.text = nav->skipText, + .rightText.token = nav->skipToken, + .rightText.tuneId = nav->tuneId}; + availableHeight -= nbgl_layoutAddHeader(layout, &headerDesc); + headerAdded = true; } - else if (nav->navType == NAV_WITH_BUTTONS) { - nbgl_layoutFooter_t footerDesc; - bool drawFooter = true; - - if (nav->skipText != NULL) { - nbgl_layoutHeader_t headerDesc = {.type = HEADER_RIGHT_TEXT, - .separationLine = false, - .rightText.text = nav->skipText, - .rightText.token = nav->skipToken, - .rightText.tuneId = nav->tuneId}; - availableHeight -= nbgl_layoutAddHeader(layout, &headerDesc); - headerAdded = true; - } - footerDesc.separationLine = true; - if (nav->nbPages > 1) { - if (nav->navWithButtons.quitText == NULL) { - footerDesc.type = FOOTER_NAV; - footerDesc.navigation.activePage = nav->activePage; - footerDesc.navigation.nbPages = nav->nbPages; - footerDesc.navigation.withExitKey = nav->navWithButtons.quitButton; - footerDesc.navigation.withBackKey = nav->navWithButtons.backButton; - footerDesc.navigation.withPageIndicator = false; - footerDesc.navigation.token = nav->navWithButtons.navToken; - footerDesc.navigation.tuneId = nav->tuneId; - } - else { - footerDesc.type = FOOTER_TEXT_AND_NAV; - footerDesc.textAndNav.text = nav->navWithButtons.quitText; - footerDesc.textAndNav.tuneId = nav->tuneId; - footerDesc.textAndNav.token = nav->quitToken; - footerDesc.textAndNav.navigation.activePage = nav->activePage; - footerDesc.textAndNav.navigation.nbPages = nav->nbPages; - footerDesc.textAndNav.navigation.withExitKey = false; - footerDesc.textAndNav.navigation.withBackKey = nav->navWithButtons.backButton; - footerDesc.textAndNav.navigation.visibleIndicator - = nav->navWithButtons.visiblePageIndicator; - footerDesc.textAndNav.navigation.withPageIndicator = true; - footerDesc.textAndNav.navigation.token = nav->navWithButtons.navToken; - footerDesc.textAndNav.navigation.tuneId = nav->tuneId; - } - } - else if (nav->navWithButtons.quitText != NULL) { - // simple footer - footerDesc.type = FOOTER_SIMPLE_TEXT; - footerDesc.simpleText.text = nav->navWithButtons.quitText; - footerDesc.simpleText.token = nav->quitToken; - footerDesc.simpleText.tuneId = nav->tuneId; + footerDesc.separationLine = true; + if (nav->nbPages > 1) { + if (nav->quitText == NULL) { + footerDesc.type = FOOTER_NAV; + footerDesc.navigation.activePage = nav->activePage; + footerDesc.navigation.nbPages = nav->nbPages; + footerDesc.navigation.withExitKey = nav->quitButton; + footerDesc.navigation.withBackKey = nav->backButton; + footerDesc.navigation.withPageIndicator = false; + footerDesc.navigation.token = nav->navToken; + footerDesc.navigation.tuneId = nav->tuneId; } else { - drawFooter = false; - } - if (drawFooter) { - availableHeight -= nbgl_layoutAddExtendedFooter(layout, &footerDesc); + footerDesc.type = FOOTER_TEXT_AND_NAV; + footerDesc.textAndNav.text = nav->quitText; + footerDesc.textAndNav.tuneId = nav->tuneId; + footerDesc.textAndNav.token = nav->quitToken; + footerDesc.textAndNav.navigation.activePage = nav->activePage; + footerDesc.textAndNav.navigation.nbPages = nav->nbPages; + footerDesc.textAndNav.navigation.withExitKey = false; + footerDesc.textAndNav.navigation.withBackKey = nav->backButton; + footerDesc.textAndNav.navigation.visibleIndicator = nav->visiblePageIndicator; + footerDesc.textAndNav.navigation.withPageIndicator = true; + footerDesc.textAndNav.navigation.token = nav->navToken; + footerDesc.textAndNav.navigation.tuneId = nav->tuneId; } - -#ifdef TARGET_STAX - if (nav->progressIndicator) { - availableHeight -= nbgl_layoutAddProgressIndicator( - layout, nav->activePage, nav->nbPages, false, 0, nav->tuneId); - headerAdded = true; - } -#endif // TARGET_STAX + } + else if (nav->quitText != NULL) { + // simple footer + footerDesc.type = FOOTER_SIMPLE_TEXT; + footerDesc.simpleText.text = nav->quitText; + footerDesc.simpleText.mutedOut = false; + footerDesc.simpleText.token = nav->quitToken; + footerDesc.simpleText.tuneId = nav->tuneId; + } + else { + drawFooter = false; + } + if (drawFooter) { + availableHeight -= nbgl_layoutAddExtendedFooter(layout, &footerDesc); } } addContent(content, layout, availableHeight, headerAdded); diff --git a/lib_nbgl/src/nbgl_use_case.c b/lib_nbgl/src/nbgl_use_case.c index f980f4d1d..4fa80e23d 100644 --- a/lib_nbgl/src/nbgl_use_case.c +++ b/lib_nbgl/src/nbgl_use_case.c @@ -342,26 +342,16 @@ static void prepareNavInfo(bool isReview, uint8_t nbPages, const char *rejectTex navInfo.progressIndicator = isReview; if (isReview == false) { - navInfo.navType = NAV_WITH_BUTTONS; - navInfo.navWithButtons.navToken = NAV_TOKEN; - navInfo.navWithButtons.backButton = true; + navInfo.navToken = NAV_TOKEN; + navInfo.backButton = true; } else { navInfo.quitToken = REJECT_TOKEN; -#ifdef TARGET_STAX - navInfo.navType = NAV_WITH_TAP; - navInfo.navWithTap.nextPageToken = NEXT_TOKEN; - navInfo.navWithTap.quitText = rejectText; - navInfo.navWithTap.backToken = BACK_TOKEN; -#else // TARGET_STAX UNUSED(rejectText); - navInfo.navType = NAV_WITH_BUTTONS; - navInfo.navWithButtons.quitText = "Reject"; - navInfo.navWithButtons.navToken = NAV_TOKEN; - navInfo.navWithButtons.backButton - = ((navType == STREAMING_NAV) && (nbPages < 2)) ? false : true; - navInfo.navWithButtons.visiblePageIndicator = (navType != STREAMING_NAV); -#endif // TARGET_STAX + navInfo.quitText = "Reject"; + navInfo.navToken = NAV_TOKEN; + navInfo.backButton = ((navType == STREAMING_NAV) && (nbPages < 2)) ? false : true; + navInfo.visiblePageIndicator = (navType != STREAMING_NAV); } } @@ -370,14 +360,10 @@ static void prepareReviewFirstPage(nbgl_contentCenteredInfo_t *centeredInfo, const char *reviewTitle, const char *reviewSubTitle) { - centeredInfo->icon = icon; - centeredInfo->text1 = reviewTitle; - centeredInfo->text2 = reviewSubTitle; -#ifdef TARGET_STAX - centeredInfo->text3 = NULL; -#else // TARGET_STAX - centeredInfo->text3 = "Swipe to review"; -#endif // TARGET_STAX + centeredInfo->icon = icon; + centeredInfo->text1 = reviewTitle; + centeredInfo->text2 = reviewSubTitle; + centeredInfo->text3 = "Swipe to review"; centeredInfo->style = LARGE_CASE_GRAY_INFO; centeredInfo->offsetY = 0; } @@ -404,22 +390,8 @@ static void prepareReviewLightLastPage(nbgl_contentInfoButton_t *infoButton, static const char *getRejectReviewText(nbgl_operationType_t operationType) { -#ifdef TARGET_STAX - // clear skip and blind bits - operationType &= ~(SKIPPABLE_OPERATION | BLIND_OPERATION); - if (operationType == TYPE_TRANSACTION) { - return "Reject transaction"; - } - else if (operationType == TYPE_MESSAGE) { - return "Reject message"; - } - else { - return "Reject operation"; - } -#else UNUSED(operationType); return "Reject"; -#endif } // function called when navigating (or exiting) modal details pages @@ -639,29 +611,16 @@ static void displayReviewPage(uint8_t page, bool forceFullRefresh) content.isTouchableTitle = false; content.tuneId = TUNE_TAP_CASUAL; - if (!forwardNavOnly) { - navInfo.navWithTap.backButton = (navInfo.activePage == 0) ? false : true; - } - if (content.type == INFO_LONG_PRESS) { // last page -#ifdef TARGET_STAX - navInfo.navWithTap.nextPageText = NULL; -#else // TARGET_STAX // for forward only review without known length... // if we don't do that we cannot remove the '>' in the navigation bar at the last page - navInfo.nbPages = navInfo.activePage + 1; -#endif // TARGET_STAX + navInfo.nbPages = navInfo.activePage + 1; content.infoLongPress.longPressToken = CONFIRM_TOKEN; if (forwardNavOnly) { // remove the "Skip" button navInfo.skipText = NULL; } } - else { -#ifdef TARGET_STAX - navInfo.navWithTap.nextPageText = "Tap to continue"; -#endif // TARGET_STAX - } // override smallCaseForValue for tag/value types to false if (content.type == TAG_VALUE_DETAILS) { @@ -675,10 +634,6 @@ static void displayReviewPage(uint8_t page, bool forceFullRefresh) } else if (content.type == TAG_VALUE_CONFIRM) { content.tagValueConfirm.tagValueList.smallCaseForValue = false; -#ifdef TARGET_STAX - // no next because confirmation is always the last page - navInfo.navWithTap.nextPageText = NULL; -#endif // TARGET_STAX // use confirm token for black button content.tagValueConfirm.confirmationToken = CONFIRM_TOKEN; } @@ -851,10 +806,8 @@ static bool genericContextPreparePageContent(const nbgl_content_t *p_content, pageContent->type = CENTERED_INFO; prepareReviewFirstPage( &pageContent->centeredInfo, pair->valueIcon, pair->item, pair->value); -#ifdef TARGET_FLEX // use "Swipe to continue" instead of "Swipe to review" for intermediate pages pageContent->centeredInfo.text3 = "Swipe to continue"; -#endif // TARGET_FLEX // Skip population of nbgl_contentTagValueList_t structure p_tagValueList = NULL; @@ -1021,20 +974,6 @@ static void displayGenericContextPage(uint8_t pageIdx, bool forceFullRefresh) return; } -#ifdef TARGET_STAX - // Handle navInfo - if (navInfo.navType == NAV_WITH_TAP) { - navInfo.navWithTap.backButton = (navInfo.activePage == 0) ? false : true; - - if (navInfo.activePage == (navInfo.nbPages - 1)) { - navInfo.navWithTap.nextPageText = NULL; - } - else { - navInfo.navWithTap.nextPageText = "Tap to continue"; - } - } -#endif // TARGET_STAX - pageContext = nbgl_pageDrawGenericContent(&pageCallback, &navInfo, &pageContent); if (forceFullRefresh) { @@ -1073,16 +1012,15 @@ static const char *getDetailsPageAt(uint8_t detailsPage) static void displayDetailsPage(uint8_t detailsPage, bool forceFullRefresh) { static nbgl_layoutTagValue_t currentPair; - nbgl_pageNavigationInfo_t info = {.activePage = detailsPage, - .nbPages = detailsContext.nbPages, - .navType = NAV_WITH_BUTTONS, - .quitToken = QUIT_TOKEN, - .navWithButtons.navToken = NAV_TOKEN, - .navWithButtons.quitButton = true, - .navWithButtons.backButton = true, - .navWithButtons.quitText = NULL, - .progressIndicator = true, - .tuneId = TUNE_TAP_CASUAL}; + nbgl_pageNavigationInfo_t info = {.activePage = detailsPage, + .nbPages = detailsContext.nbPages, + .quitToken = QUIT_TOKEN, + .navToken = NAV_TOKEN, + .quitButton = true, + .backButton = true, + .quitText = NULL, + .progressIndicator = true, + .tuneId = TUNE_TAP_CASUAL}; nbgl_pageContent_t content = {.type = TAG_VALUE_LIST, .topRightIcon = NULL, .tagValueList.nbPairs = 1, @@ -1129,7 +1067,7 @@ static void displayDetailsPage(uint8_t detailsPage, bool forceFullRefresh) } if (info.nbPages == 1) { // if only one page, no navigation bar, and use a footer instead - info.navWithButtons.quitText = "Close"; + info.quitText = "Close"; } modalPageContext = nbgl_pageDrawGenericContentExt(&pageModalCallback, &info, &content, true); @@ -1228,8 +1166,8 @@ static void displayAddressQRCode(void) .withLeftBorder = true, .onActionCallback = &addressLayoutTouchCallbackQR, .tapActionText = NULL}; - nbgl_layoutHeader_t headerDesc - = {.type = HEADER_EMPTY, .separationLine = false, .emptySpace.height = 40}; + nbgl_layoutHeader_t headerDesc = { + .type = HEADER_EMPTY, .separationLine = false, .emptySpace.height = SMALL_CENTERING_HEADER}; nbgl_layoutQRCode_t qrCode = {.url = addressConfirmationContext.tagValuePair.value, .text1 = NULL, .centered = true, @@ -1258,12 +1196,7 @@ static void displayAddressQRCode(void) nbgl_layoutAddQRCode(addressConfirmationContext.modalLayout, &qrCode); -#ifdef TARGET_STAX - nbgl_layoutAddBottomButton( - addressConfirmationContext.modalLayout, &CLOSE_ICON, 0, false, TUNE_TAP_CASUAL); -#else // TARGET_STAX nbgl_layoutAddFooter(addressConfirmationContext.modalLayout, "Close", 0, TUNE_TAP_CASUAL); -#endif // TARGET_STAX nbgl_layoutDraw(addressConfirmationContext.modalLayout); nbgl_refresh(); } @@ -1524,17 +1457,13 @@ static void prepareAddressConfirmationPages(const char *ad #ifdef NBGL_QRCODE tagValueConfirm->detailsButtonIcon = &QRCODE_ICON; -#ifndef TARGET_STAX - // On Flex, only use "Show as QR" when it's not the last page + // only use "Show as QR" when it's not the last page if (tagValueList != NULL) { -#endif // TARGET_STAX tagValueConfirm->detailsButtonText = "Show as QR"; -#ifndef TARGET_STAX } else { tagValueConfirm->detailsButtonText = NULL; } -#endif // TARGET_STAX tagValueConfirm->detailsButtonToken = ADDRESS_QRCODE_BUTTON_TOKEN; #else // NBGL_QRCODE tagValueConfirm->detailsButtonText = NULL; @@ -1568,11 +1497,6 @@ static void prepareAddressConfirmationPages(const char *ad tagValueConfirm->detailsButtonIcon = NULL; tagValueConfirm->tuneId = TUNE_TAP_CASUAL; memcpy(&tagValueConfirm->tagValueList, tagValueList, sizeof(nbgl_contentTagValueList_t)); - -#ifdef TARGET_STAX - // no next page - navInfo.navWithTap.nextPageText = NULL; -#endif // TARGET_STAX } } @@ -1687,8 +1611,12 @@ uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPai uint8_t startIndex, bool *requireSpecificDisplay) { - uint8_t nbPairsInPage = 0; - uint16_t currentHeight = 12; // upper margin + uint8_t nbPairsInPage = 0; +#ifdef TARGET_STAX + uint16_t currentHeight = 24; // upper margin +#else // TARGET_STAX + uint16_t currentHeight = 0; // upper margin +#endif // TARGET_STAX *requireSpecificDisplay = false; while (nbPairsInPage < nbPairs) { @@ -1696,8 +1624,13 @@ uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPai nbgl_font_id_e value_font; // margin between pairs + // 12 or 24 px between each tag/value pair if (nbPairsInPage > 0) { +#ifdef TARGET_STAX currentHeight += 12; +#else // TARGET_STAX + currentHeight += 24; +#endif // TARGET_STAX } // fetch tag/value pair strings. if (tagValueList->pairs != NULL) { @@ -2141,7 +2074,7 @@ void nbgl_useCaseStatus(const char *message, bool isSuccess, nbgl_callback_t qui nbgl_pageInfoDescription_t info = {.bottomButtonStyle = NO_BUTTON_STYLE, .footerText = NULL, .centeredInfo.icon = &C_Denied_Circle_64px, - .centeredInfo.offsetY = 0, + .centeredInfo.offsetY = SMALL_FOOTER_HEIGHT / 2, .centeredInfo.onTop = false, .centeredInfo.style = LARGE_CASE_INFO, .centeredInfo.text1 = message, @@ -2306,15 +2239,10 @@ void nbgl_useCaseReviewStart(const nbgl_icon_details_t *icon, { reset_callbacks(); - nbgl_pageInfoDescription_t info = {.footerText = rejectText, - .footerToken = QUIT_TOKEN, -#ifdef TARGET_STAX - .tapActionText = "Tap to continue", - .isSwipeable = false, -#else // TARGET_STAX - .tapActionText = NULL, - .isSwipeable = true, -#endif // TARGET_STAX + nbgl_pageInfoDescription_t info = {.footerText = rejectText, + .footerToken = QUIT_TOKEN, + .tapActionText = NULL, + .isSwipeable = true, .tapActionToken = CONTINUE_TOKEN, .topRightStyle = NO_BUTTON_STYLE, .actionButtonText = NULL, @@ -2400,13 +2328,9 @@ void nbgl_useCaseForwardOnlyReview(const char *rejectText, // fill navigation structure prepareNavInfo(true, NBGL_NO_PROGRESS_INDICATOR, rejectText); -#ifdef TARGET_STAX - navInfo.skipText = "Skip >>"; -#else navInfo.progressIndicator = false; navInfo.skipText = "Skip"; -#endif - navInfo.skipToken = SKIP_TOKEN; + navInfo.skipToken = SKIP_TOKEN; displayReviewPage(0, true); } @@ -2443,9 +2367,7 @@ void nbgl_useCaseForwardOnlyReviewNoSkip(const char *rejectText, // fill navigation structure prepareNavInfo(true, NBGL_NO_PROGRESS_INDICATOR, rejectText); -#ifndef TARGET_STAX navInfo.progressIndicator = false; -#endif displayReviewPage(0, false); } @@ -2760,10 +2682,8 @@ void nbgl_useCaseReviewStreamingStart(nbgl_operationType_t operationType, bundleNavContext.reviewStreaming.stepPageNb = nbgl_useCaseGetNbPagesForGenericContents(&genericContext.genericContents, 0); prepareNavInfo(true, NBGL_NO_PROGRESS_INDICATOR, getRejectReviewText(operationType)); -#ifdef TARGET_FLEX // no back button on first page - navInfo.navWithButtons.backButton = false; -#endif // TARGET_STAX + navInfo.backButton = false; #ifdef HAVE_PIEZO_SOUND // Play notification sound @@ -2818,14 +2738,9 @@ void nbgl_useCaseReviewStreamingContinueExt(const nbgl_contentTagValueList_t *ta getRejectReviewText(bundleNavContext.reviewStreaming.operationType)); // if the operation is skippable if (bundleNavContext.reviewStreaming.operationType & SKIPPABLE_OPERATION) { -#ifdef TARGET_STAX - navInfo.skipText = "Skip >>"; - navInfo.navWithTap.quitText = "Reject"; -#else navInfo.progressIndicator = false; navInfo.skipText = "Skip"; -#endif - navInfo.skipToken = SKIP_TOKEN; + navInfo.skipToken = SKIP_TOKEN; } displayGenericContextPage(0, true); @@ -2973,11 +2888,7 @@ void nbgl_useCaseAddressConfirmationExt(const char *addres // fill navigation structure, common to all pages uint8_t nbPages = nbgl_useCaseGetNbPagesForGenericContents(&genericContext.genericContents, 0); -#ifdef TARGET_STAX - prepareNavInfo(true, nbPages, "Cancel"); -#else // TARGET_STAX prepareNavInfo(true, nbPages, "Reject"); -#endif // TARGET_STAX displayGenericContextPage(0, true); } @@ -3030,11 +2941,7 @@ void nbgl_useCaseAddressReview(const char *address, // fill navigation structure, common to all pages uint8_t nbPages = nbgl_useCaseGetNbPagesForGenericContents(&genericContext.genericContents, 0); -#ifdef TARGET_STAX - prepareNavInfo(true, nbPages, "Cancel"); -#else // TARGET_STAX prepareNavInfo(true, nbPages, "Reject"); -#endif // TARGET_STAX #ifdef HAVE_PIEZO_SOUND // Play notification sound diff --git a/unit-tests/lib_nbgl/test_nbgl_obj.c b/unit-tests/lib_nbgl/test_nbgl_obj.c index df8661e30..54e856dc7 100644 --- a/unit-tests/lib_nbgl/test_nbgl_obj.c +++ b/unit-tests/lib_nbgl/test_nbgl_obj.c @@ -324,13 +324,13 @@ static void test_draw_obj(void **state __attribute__((unused))) assert_int_equal(indicator->obj.area.y0, 188); assert_int_equal(progress->obj.area.x0, 0); - assert_int_equal(progress->obj.area.y0, 192); + assert_int_equal(progress->obj.area.y0, 220); assert_int_equal(radio->obj.area.x0, 0); - assert_int_equal(radio->obj.area.y0, 224); + assert_int_equal(radio->obj.area.y0, 252); assert_int_equal(spinner->obj.area.x0, 0); - assert_int_equal(spinner->obj.area.y0, 256); + assert_int_equal(spinner->obj.area.y0, 284); } #else // HAVE_SE_TOUCH