Skip to content

Commit 7b04631

Browse files
committed
gui: add icon type to icon nodes
1 parent 3d9d870 commit 7b04631

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

main/gui.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,13 +1142,14 @@ void gui_make_icon(gui_view_node_t** ptr, const Icon* icon, color_t color, const
11421142
// background color is set to foreground color to imply transparency
11431143
data->bg_color = bg_color ? *bg_color : color;
11441144

1145-
// and top-left
1146-
data->halign = GUI_ALIGN_LEFT;
1147-
data->valign = GUI_ALIGN_TOP;
1148-
11491145
// without animation
11501146
data->animation = NULL;
11511147

1148+
// and top-left, normal icon
1149+
data->halign = GUI_ALIGN_LEFT;
1150+
data->valign = GUI_ALIGN_TOP;
1151+
data->icon_type = ICON_PLAIN;
1152+
11521153
// also set free_view_node_icon_data as destructor to free any animation data
11531154
make_view_node(ptr, ICON, data, free_view_node_icon_data);
11541155
}
@@ -1210,6 +1211,12 @@ void gui_set_icon_animation(gui_view_node_t* node, Icon* icons, const size_t num
12101211
}
12111212
}
12121213

1214+
void gui_set_icon_to_qr(gui_view_node_t* node)
1215+
{
1216+
JADE_ASSERT(node);
1217+
node->icon->icon_type = ICON_QR;
1218+
}
1219+
12131220
void gui_make_picture(gui_view_node_t** ptr, const Picture* picture)
12141221
{
12151222
JADE_INIT_OUT_PPTR(ptr);

main/gui.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ struct view_node_button_data {
264264
void* args;
265265
};
266266

267+
enum __attribute__((__packed__)) icon_node_kind { ICON_PLAIN, ICON_QR };
268+
267269
// Data for an icon node
268270
// NOTE: animated icons ARE owned here
269271
struct view_node_icon_animation_data {
@@ -285,11 +287,12 @@ struct view_node_icon_data {
285287
// background color is set to foreground color to imply transparency
286288
color_t bg_color;
287289

288-
enum gui_horizontal_align halign;
289-
enum gui_vertical_align valign;
290-
291290
// if != NULL the icon will be regularly updated and so appear animated
292291
struct view_node_icon_animation_data* animation;
292+
293+
enum gui_horizontal_align halign;
294+
enum gui_vertical_align valign;
295+
enum icon_node_kind icon_type;
293296
};
294297

295298
// Data for a picture node
@@ -439,6 +442,7 @@ void gui_set_colors(gui_view_node_t* node, color_t color, color_t selected_color
439442
void gui_set_color(gui_view_node_t* node, color_t color);
440443
void gui_set_align(gui_view_node_t* node, enum gui_horizontal_align halign, enum gui_vertical_align valign);
441444
void gui_set_icon_animation(gui_view_node_t* node, Icon* icons, size_t num_icons, size_t frames_per_icon);
445+
void gui_set_icon_to_qr(gui_view_node_t* node);
442446
void gui_set_text_scroll(gui_view_node_t* node, color_t background_color);
443447
void gui_set_text_scroll_selected(
444448
gui_view_node_t* node, bool only_when_selected, color_t background_color, color_t selected_background_color);

main/ui/qrmode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ static void make_qrcode(gui_view_node_t* parent, Icon* icons, const size_t num_i
1414
gui_set_align(icon, GUI_ALIGN_CENTER, GUI_ALIGN_MIDDLE);
1515
gui_set_parent(icon, fill);
1616
gui_set_icon_animation(icon, icons, num_icons, frames_per_qr_icon);
17+
gui_set_icon_to_qr(icon);
1718
}
1819

1920
gui_activity_t* make_show_xpub_qr_activity(

0 commit comments

Comments
 (0)