Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt NBGL to europa design rules #519

Merged
merged 4 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile.defines
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ DEFINES += NBGL_USE_CASE
else
DEFINES += HAVE_BAGL
endif
ifeq ($(TARGET_NAME),TARGET_NANOS)
DEFINES += BAGL_HEIGHT=32
endif
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_NANOS2))
ifndef USE_NBGL
DEFINES += HAVE_UX_FLOW
Expand Down
2 changes: 1 addition & 1 deletion lib_nbgl/fonts/config-Inter-Medium36-1bpp.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ loaded_baseline=30
# This font can display characters at y=-1 => we need to compensate that
baseline_offset=1
fontSize=36
lineSize=44
lineSize=40
firstChar=0x20
lastChar=0x7E
firstLine=5
Expand Down
2 changes: 1 addition & 1 deletion lib_nbgl/fonts/config-Inter-Medium36.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ loaded_baseline=28
# This font can display characters at y=-1 => we need to compensate that
baseline_offset=1
fontSize=36
lineSize=44
lineSize=40
firstChar=0x20
lastChar=0x7E
firstLine=5
Expand Down
Binary file added lib_nbgl/glyphs/ic_denied_64.bmp
Binary file not shown.
Binary file added lib_nbgl/glyphs/ic_success_64.bmp
Binary file not shown.
Binary file added lib_nbgl/glyphs/ic_warning_64.bmp
Binary file not shown.
Binary file added lib_nbgl/glyphs/leftArrow40px.bmp
Binary file not shown.
Binary file added lib_nbgl/glyphs/left_half_64px_nocomp.bmp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added lib_nbgl/glyphs/rightArrow40px.bmp
Binary file not shown.
5 changes: 4 additions & 1 deletion lib_nbgl/include/nbgl_draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ extern "C" {
* GLOBAL PROTOTYPES
**********************/

void nbgl_drawIcon(nbgl_area_t *area, nbgl_color_map_t color_map, const nbgl_icon_details_t *icon);
void nbgl_drawIcon(nbgl_area_t *area,
nbgl_transformation_t transformation,
nbgl_color_map_t color_map,
const nbgl_icon_details_t *icon);
void nbgl_drawRoundedRect(const nbgl_area_t *area, nbgl_radius_t radius, color_t innerColor);
void nbgl_drawRoundedBorderedRect(const nbgl_area_t *area,
nbgl_radius_t radius,
Expand Down
2 changes: 1 addition & 1 deletion lib_nbgl/include/nbgl_font_inter_medium_36.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,7 @@ __attribute__ ((section("._nbgl_fonts_"))) const nbgl_font_t fontINTER_MEDIUM_36
BAGL_FONT_INTER_MEDIUM_36px, // font id
(uint8_t) NBGL_BPP_4, // bpp
48, // height of all characters in pixels
44, // line height in pixels
40, // line height in pixels
0, // kerning
1, // crop enabled (1) or not (0)
0, // Most top Y coordinate of any char
Expand Down
2 changes: 1 addition & 1 deletion lib_nbgl/include/nbgl_font_inter_medium_36_1bpp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ __attribute__ ((section("._nbgl_fonts_"))) const nbgl_font_t fontINTER_MEDIUM_36
BAGL_FONT_INTER_MEDIUM_36px_1bpp, // font id
(uint8_t) NBGL_BPP_1, // bpp
48, // height of all characters in pixels
44, // line height in pixels
40, // line height in pixels
0, // kerning
1, // crop enabled (1) or not (0)
0, // Most top Y coordinate of any char
Expand Down
9 changes: 8 additions & 1 deletion lib_nbgl/include/nbgl_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ extern "C" {
#define NO_MORE_OBJ_ERROR -3
#define NBGL_NO_TUNE NB_TUNES

#ifdef HAVE_SE_TOUCH
#define NB_MAX_SUGGESTION_BUTTONS 4
#ifdef TARGET_STAX
#define NB_MAX_VISIBLE_SUGGESTION_BUTTONS NB_MAX_SUGGESTION_BUTTONS
#else // TARGET_STAX
#define NB_MAX_VISIBLE_SUGGESTION_BUTTONS 2
#endif // TARGET_STAX

#ifdef HAVE_SE_TOUCH
#define AVAILABLE_WIDTH (SCREEN_WIDTH - 2 * BORDER_MARGIN)
#else // HAVE_SE_TOUCH
// 7 pixels on each side
Expand Down Expand Up @@ -297,6 +302,8 @@ typedef struct {
const char *url; ///< URL for QR code
const char *text1; ///< first text (can be null)
const char *text2; ///< second text (can be null)
int16_t offsetY; ///< vertical shift to apply to this info (if > 0, shift to bottom)
bool centered; ///< if set to true, center vertically
bool largeText1; ///< if set to true, use 32px font for text1
} nbgl_layoutQRCode_t;

Expand Down
40 changes: 35 additions & 5 deletions lib_nbgl/include/nbgl_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ extern "C" {

// for Keyboard
#ifdef HAVE_SE_TOUCH
#ifdef TARGET_STAX
#define KEYBOARD_KEY_HEIGHT 60
#else // HAVE_SE_TOUCH
#else // TARGET_STAX
#define KEYBOARD_KEY_HEIGHT 72
#endif // TARGET_STAX
#else // HAVE_SE_TOUCH
#define KEYBOARD_KEY_WIDTH 14
#define KEYBOARD_KEY_HEIGHT 14
#define KEYBOARD_WIDTH (5 * KEYBOARD_KEY_WIDTH)
Expand All @@ -53,14 +57,29 @@ extern "C" {
#define EXIT_PAGE 0xFF

// external margin in pixels
#define BORDER_MARGIN 24
#ifdef TARGET_STAX
#define BORDER_MARGIN 24
#define BOTTOM_BORDER_MARGIN 24
#else // TARGET_STAX
#define BORDER_MARGIN 32
#define BOTTOM_BORDER_MARGIN 24
#endif // TARGET_STAX

// Back button header height
#ifdef TARGET_STAX
#define BACK_BUTTON_HEADER_HEIGHT 88
#else // TARGET_STAX
#define BACK_BUTTON_HEADER_HEIGHT 96
#endif // TARGET_STAX

// common dimensions for buttons
#ifdef TARGET_STAX
#define BUTTON_RADIUS RADIUS_40_PIXELS
#define BUTTON_DIAMETER 80
#else // TARGET_STAX
#define BUTTON_RADIUS RADIUS_44_PIXELS
#define BUTTON_DIAMETER 88
#endif // TARGET_STAX
#endif // HAVE_SE_TOUCH

/**********************
Expand Down Expand Up @@ -302,6 +321,7 @@ typedef struct PACKED__ nbgl_image_s {
nbgl_obj_t obj; // common part
color_t foregroundColor; ///< color set to '1' bits, for 1PBB images. '0' are set to background
///< color.
nbgl_transformation_t transformation; ///< usually NO_TRANSFORMATION
const nbgl_icon_details_t *buffer; ///< buffer containing bitmap, with exact same size as
///< object (width*height*bpp/8 bytes)
onImageDrawCallback_t onDrawCallback; ///< function called if buffer is NULL, with above token
Expand Down Expand Up @@ -367,6 +387,15 @@ typedef struct PACKED__ nbgl_progress_bar_s {
color_t foregroundColor; ///< color of the inner progress bar and border (if applicable)
} nbgl_progress_bar_t;

/**
* @brief Style to apply to @ref nbgl_page_indicator_t
*
*/
typedef enum {
PROGRESSIVE_INDICATOR = 0, ///< all dashes before active page are black
CURRENT_INDICATOR ///< only current page dash is black
} nbgl_page_indicator_style_t;

/**
* @brief struct to represent a navigation bar (@ref PAGE_INDICATOR type)
* There can be up to 5 page indicators, whose shape is fixed.
Expand All @@ -375,9 +404,10 @@ typedef struct PACKED__ nbgl_progress_bar_s {
* @note height is fixed
*/
typedef struct PACKED__ nbgl_navigation_bar_s {
nbgl_obj_t obj; ///< common part
uint8_t nbPages; ///< number of pages.
uint8_t activePage; ///< index of active page (from 0 to nbPages-1).
nbgl_obj_t obj; ///< common part
uint8_t nbPages; ///< number of pages.
uint8_t activePage; ///< index of active page (from 0 to nbPages-1).
nbgl_page_indicator_style_t style; ///< Style to apply
} nbgl_page_indicator_t;

/**
Expand Down
7 changes: 6 additions & 1 deletion lib_nbgl/include/nbgl_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,13 @@ typedef enum nbgl_post_refresh_t {
typedef enum {
#ifdef SCREEN_SIZE_WALLET
RADIUS_32_PIXELS = 0, ///< 32 pixels
RADIUS_40_PIXELS, ///< 48 pixels
#ifdef TARGET_STAX
RADIUS_40_PIXELS, ///< 40 pixels
RADIUS_MAX = RADIUS_40_PIXELS,
#else // TARGET_STAX
RADIUS_44_PIXELS, ///< 44 pixels
RADIUS_MAX = RADIUS_44_PIXELS,
#endif // TARGET_STAX
#else // SCREEN_SIZE_WALLET
RADIUS_1_PIXEL = 0, ///< 1 pixel
RADIUS_3_PIXELS, ///< 3 pixels
Expand Down
55 changes: 44 additions & 11 deletions lib_nbgl/src/nbgl_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ static const uint8_t quarter_circle_3px_270_1bpp[] = {0x58, 0x00};
static const uint8_t radiusValues[] = {
#ifdef SCREEN_SIZE_WALLET
32,
40
#ifdef TARGET_STAX
40,
#else // TARGET_STAX
44
#endif // TARGET_STAX
#else // SCREEN_SIZE_WALLET
1,
3
Expand All @@ -80,18 +84,42 @@ static const uint8_t radiusValues[] = {

#ifdef SCREEN_SIZE_WALLET
// indexed by nbgl_radius_t (except RADIUS_0_PIXELS)
static const uint8_t *topQuarterDiscs[]
= {C_quarter_disc_top_left_32px_1bpp_bitmap, C_quarter_disc_top_left_40px_1bpp_bitmap};
static const uint8_t *topQuarterDiscs[] = {
C_quarter_disc_top_left_32px_1bpp_bitmap,
#ifdef TARGET_STAX
C_quarter_disc_top_left_40px_1bpp_bitmap,
#else // TARGET_STAX
C_quarter_disc_top_left_44px_1bpp_bitmap
#endif // TARGET_STAX
};

static const uint8_t *bottomQuarterDiscs[]
= {C_quarter_disc_bottom_left_32px_1bpp_bitmap, C_quarter_disc_bottom_left_40px_1bpp_bitmap};
static const uint8_t *bottomQuarterDiscs[] = {
C_quarter_disc_bottom_left_32px_1bpp_bitmap,
#ifdef TARGET_STAX
C_quarter_disc_bottom_left_40px_1bpp_bitmap,
#else // TARGET_STAX
C_quarter_disc_bottom_left_44px_1bpp_bitmap
#endif // TARGET_STAX
};

// indexed by nbgl_radius_t (except RADIUS_0_PIXELS)
static const uint8_t *topQuarterCircles[]
= {C_quarter_circle_top_left_32px_1bpp_bitmap, C_quarter_circle_top_left_40px_1bpp_bitmap};
static const uint8_t *topQuarterCircles[] = {
C_quarter_circle_top_left_32px_1bpp_bitmap,
#ifdef TARGET_STAX
C_quarter_circle_top_left_40px_1bpp_bitmap,
#else // TARGET_STAX
C_quarter_circle_top_left_44px_1bpp_bitmap
#endif // TARGET_STAX
};

static const uint8_t *bottomQuarterCircles[] = {C_quarter_circle_bottom_left_32px_1bpp_bitmap,
C_quarter_circle_bottom_left_40px_1bpp_bitmap};
static const uint8_t *bottomQuarterCircles[] = {
C_quarter_circle_bottom_left_32px_1bpp_bitmap,
#ifdef TARGET_STAX
C_quarter_circle_bottom_left_40px_1bpp_bitmap,
#else // TARGET_STAX
C_quarter_circle_bottom_left_44px_1bpp_bitmap
#endif // TARGET_STAX
};
#endif // SCREEN_SIZE_WALLET

#ifdef NBGL_QRCODE
Expand Down Expand Up @@ -453,16 +481,21 @@ void nbgl_drawRoundedBorderedRect(const nbgl_area_t *area,
* No transformation is applied to the icon.
*
* @param area Area of drawing
* @param transformation Transformation to apply to this icon (only available for raw image, not
* image file)
* @param color_map Color map applied to icon
* @param icon Icon details structure to draw
*/
void nbgl_drawIcon(nbgl_area_t *area, nbgl_color_map_t color_map, const nbgl_icon_details_t *icon)
void nbgl_drawIcon(nbgl_area_t *area,
nbgl_transformation_t transformation,
nbgl_color_map_t color_map,
const nbgl_icon_details_t *icon)
{
if (icon->isFile) {
nbgl_frontDrawImageFile(area, icon->bitmap, color_map, ramBuffer);
}
else {
nbgl_frontDrawImage(area, icon->bitmap, NO_TRANSFORMATION, color_map);
nbgl_frontDrawImage(area, icon->bitmap, transformation, color_map);
}
}

Expand Down
Loading
Loading