Skip to content

Commit

Permalink
Add new sizes of buttons, icons and other objects for Europa
Browse files Browse the repository at this point in the history
  • Loading branch information
nroggeman-ledger committed Jan 31, 2024
1 parent aeee4d9 commit 7d84a9f
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 33 deletions.
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
36 changes: 32 additions & 4 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,27 @@ extern "C" {
#define EXIT_PAGE 0xFF

// external margin in pixels
#ifdef TARGET_STAX
#define BORDER_MARGIN 24
#else // TARGET_STAX
#define BORDER_MARGIN 32
#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 +319,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 +385,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 +402,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
28 changes: 19 additions & 9 deletions lib_nbgl/src/nbgl_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,9 @@ static void draw_button(nbgl_button_t *obj, nbgl_obj_t *prevObj, bool computePos

// inherit background from parent
obj->obj.area.backgroundColor = obj->obj.parent->area.backgroundColor;
// draw the rounded corner rectangle
if (obj->innerColor == obj->borderColor) {
// draw the rounded corner rectangle if necessary
if ((obj->innerColor == obj->borderColor)
&& (obj->innerColor != obj->obj.area.backgroundColor)) {
nbgl_drawRoundedRect((nbgl_area_t *) obj, obj->radius, obj->innerColor);
}
else {
Expand Down Expand Up @@ -404,7 +405,7 @@ static void draw_button(nbgl_button_t *obj, nbgl_obj_t *prevObj, bool computePos
rectArea.height = obj->icon->height;
rectArea.bpp = obj->icon->bpp;

nbgl_drawIcon(&rectArea, obj->foregroundColor, obj->icon);
nbgl_drawIcon(&rectArea, NO_TRANSFORMATION, obj->foregroundColor, obj->icon);
}
}

Expand Down Expand Up @@ -510,7 +511,7 @@ static void draw_image(nbgl_image_t *obj, nbgl_obj_t *prevObj, bool computePosit
colorMap = obj->foregroundColor;
}

nbgl_drawIcon((nbgl_area_t *) obj, colorMap, iconDetails);
nbgl_drawIcon((nbgl_area_t *) obj, obj->transformation, colorMap, iconDetails);
}

#ifdef HAVE_SE_TOUCH
Expand Down Expand Up @@ -575,10 +576,10 @@ static void draw_radioButton(nbgl_radio_t *obj, nbgl_obj_t *prevObj, bool comput
rectArea.backgroundColor = obj->obj.area.backgroundColor;
rectArea.bpp = NBGL_BPP_1;
if (obj->state == OFF_STATE) {
nbgl_drawIcon(&rectArea, obj->borderColor, &C_radio_inactive_32px);
nbgl_drawIcon(&rectArea, NO_TRANSFORMATION, obj->borderColor, &C_radio_inactive_32px);
}
else {
nbgl_drawIcon(&rectArea, obj->activeColor, &C_radio_active_32px);
nbgl_drawIcon(&rectArea, NO_TRANSFORMATION, obj->activeColor, &C_radio_active_32px);
}
}
#endif // HAVE_SE_TOUCH
Expand Down Expand Up @@ -689,8 +690,12 @@ static void draw_pageIndicator(nbgl_page_indicator_t *obj,
nbgl_area_t rectArea;
uint16_t dashWidth;

if (obj->nbPages == 0) {
return;
}

if (obj->nbPages <= NB_MAX_PAGES_WITH_DASHES) {
uint8_t i;
int i;
#define INTER_DASHES 10 // pixels
// force height
obj->obj.area.height = 4;
Expand Down Expand Up @@ -719,10 +724,15 @@ static void draw_pageIndicator(nbgl_page_indicator_t *obj,
rectArea.backgroundColor = obj->obj.area.backgroundColor;
rectArea.bpp = NBGL_BPP_1;
// draw dashes
for (i = 0; i <= obj->activePage; i++) {
nbgl_frontDrawHorizontalLine(&rectArea, 0xF, BLACK);
for (i = 0; i < obj->activePage; i++) {
nbgl_frontDrawHorizontalLine(
&rectArea, 0xF, (obj->style == PROGRESSIVE_INDICATOR) ? BLACK : LIGHT_GRAY);
rectArea.x0 += dashWidth + INTER_DASHES;
}
nbgl_frontDrawHorizontalLine(&rectArea, 0xF, BLACK);
rectArea.x0 += dashWidth + INTER_DASHES;
i++;

for (; i < obj->nbPages; i++) {
nbgl_frontDrawHorizontalLine(&rectArea, 0xF, LIGHT_GRAY);
rectArea.x0 += dashWidth + INTER_DASHES;
Expand Down
20 changes: 14 additions & 6 deletions lib_nbgl/src/nbgl_obj_keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ static void keyboardDrawLetters(nbgl_keyboard_t *keyboard)
nbgl_drawIcon(
&rectArea,
(keyboard->casing != LOWER_CASE) ? WHITE : BLACK,
NO_TRANSFORMATION,
(keyboard->casing != LOCKED_UPPER_CASE) ? (&C_shift_lock32px) : (&C_shift32px));
rectArea.backgroundColor = WHITE;
offsetX = keyboard->obj.area.x0 + SHIFT_KEY_WIDTH;
Expand Down Expand Up @@ -386,7 +387,10 @@ static void keyboardDrawLetters(nbgl_keyboard_t *keyboard)
else {
rectArea.x0 += (BACKSPACE_KEY_WIDTH_LETTERS_ONLY - rectArea.width) / 2;
}
nbgl_drawIcon(&rectArea, (keyboard->keyMask & (1 << 26)) ? WHITE : BLACK, &C_backspace32px);
nbgl_drawIcon(&rectArea,
NO_TRANSFORMATION,
(keyboard->keyMask & (1 << 26)) ? WHITE : BLACK,
&C_backspace32px);

// 4th row, only in Full mode
if (!keyboard->lettersOnly) {
Expand All @@ -395,8 +399,10 @@ static void keyboardDrawLetters(nbgl_keyboard_t *keyboard)
nbgl_drawText(&rectArea, ".?123", 5, SMALL_REGULAR_1BPP_FONT, BLACK);

rectArea.x0 = SWITCH_KEY_WIDTH + (SPACE_KEY_WIDTH - C_space32px.width) / 2;
nbgl_drawIcon(
&rectArea, (keyboard->keyMask & (1 << SPACE_KEY_INDEX)) ? WHITE : BLACK, &C_space32px);
nbgl_drawIcon(&rectArea,
NO_TRANSFORMATION,
(keyboard->keyMask & (1 << SPACE_KEY_INDEX)) ? WHITE : BLACK,
&C_space32px);
}
}

Expand Down Expand Up @@ -477,16 +483,18 @@ static void keyboardDrawDigits(nbgl_keyboard_t *keyboard)
rectArea.y0 = keyboard->obj.area.y0 + KEYBOARD_KEY_HEIGHT * 2
+ (((KEYBOARD_KEY_HEIGHT - rectArea.height) / 2) & 0xFFC);
rectArea.x0 += (BACKSPACE_KEY_WIDTH_DIGITS - rectArea.width) / 2;
nbgl_drawIcon(&rectArea, BLACK, &C_backspace32px);
nbgl_drawIcon(&rectArea, NO_TRANSFORMATION, BLACK, &C_backspace32px);

// 4th row
rectArea.x0 = (SWITCH_KEY_WIDTH - nbgl_getTextWidth(SMALL_REGULAR_1BPP_FONT, "ABC")) / 2;
rectArea.y0 = keyboard->obj.area.y0 + KEYBOARD_KEY_HEIGHT * 3 + LETTER_OFFSET_Y;
nbgl_drawText(&rectArea, "ABC", 3, SMALL_REGULAR_1BPP_FONT, BLACK);

rectArea.x0 = SWITCH_KEY_WIDTH + (SPACE_KEY_WIDTH - C_space32px.width) / 2;
nbgl_drawIcon(
&rectArea, (keyboard->keyMask & (1 << SPACE_KEY_INDEX)) ? WHITE : BLACK, &C_space32px);
nbgl_drawIcon(&rectArea,
NO_TRANSFORMATION,
(keyboard->keyMask & (1 << SPACE_KEY_INDEX)) ? WHITE : BLACK,
&C_space32px);
}

static void keyboardDraw(nbgl_keyboard_t *keyboard)
Expand Down
2 changes: 1 addition & 1 deletion lib_nbgl/src/nbgl_obj_keyboard_nanos.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static void keyboardDrawIcon(int16_t x0, int8_t y0, bool inverted, const nbgl_ic
// center
rectArea.x0 = x0 + (KEYBOARD_KEY_WIDTH - icon->width) / 2;
rectArea.y0 = y0 + (KEYBOARD_KEY_HEIGHT - icon->height) / 2;
nbgl_drawIcon(&rectArea, inverted ? BLACK : WHITE, icon);
nbgl_drawIcon(&rectArea, NO_TRANSFORMATION, inverted ? BLACK : WHITE, icon);
}

static void keyboardDrawChar(int16_t x0, int8_t y0, bool inverted, const char *charPtr)
Expand Down

0 comments on commit 7d84a9f

Please sign in to comment.