unleashed-firmware/applications/gui/modules/widget_elements/widget_element_icon.c
gornekich 3f640e8f1c
[FL-1549] Gui Widget module (#598)
* gui_widget: rework with mlib container
* widget: rename gui_widget-> widget; gui_element->widget_element
* gui: move widget from nfc to gui/modules
* nfc: rework widget usage
* nfc: return to ReadEmvAppSuccess scene after ReadEmvDataSuccess exit

Co-authored-by: あく <alleteam@gmail.com>
2021-07-23 16:09:34 +03:00

46 lines
1.0 KiB
C

#include "widget_element_i.h"
#include <m-string.h>
typedef struct {
uint8_t x;
uint8_t y;
const Icon* icon;
} GuiIconModel;
static void gui_icon_draw(Canvas* canvas, WidgetElement* element) {
furi_assert(canvas);
furi_assert(element);
GuiIconModel* model = element->model;
if(model->icon) {
canvas_draw_icon(canvas, model->x, model->y, model->icon);
}
}
static void gui_icon_free(WidgetElement* gui_icon) {
furi_assert(gui_icon);
free(gui_icon->model);
free(gui_icon);
}
WidgetElement* widget_element_icon_create(uint8_t x, uint8_t y, const Icon* icon) {
furi_assert(icon);
// Allocate and init model
GuiIconModel* model = furi_alloc(sizeof(GuiIconModel));
model->x = x;
model->y = y;
model->icon = icon;
// Allocate and init Element
WidgetElement* gui_icon = furi_alloc(sizeof(WidgetElement));
gui_icon->parent = NULL;
gui_icon->input = NULL;
gui_icon->draw = gui_icon_draw;
gui_icon->free = gui_icon_free;
gui_icon->model = model;
return gui_icon;
}