Welcome to mirror list, hosted at ThFree Co, Russian Federation.

widget_element_frame.c « widget_elements « modules « gui « applications - github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a7265348ed271cf7351655190c6ede1409992f8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "widget_element_i.h"

typedef struct {
    uint8_t x;
    uint8_t y;
    uint8_t width;
    uint8_t height;
    uint8_t radius;
} GuiFrameModel;

static void gui_frame_draw(Canvas* canvas, WidgetElement* element) {
    furi_assert(canvas);
    furi_assert(element);
    GuiFrameModel* model = element->model;
    canvas_draw_rframe(canvas, model->x, model->y, model->width, model->height, model->radius);
}

static void gui_frame_free(WidgetElement* gui_frame) {
    furi_assert(gui_frame);

    free(gui_frame->model);
    free(gui_frame);
}

WidgetElement* widget_element_frame_create(
    uint8_t x,
    uint8_t y,
    uint8_t width,
    uint8_t height,
    uint8_t radius) {
    // Allocate and init model
    GuiFrameModel* model = malloc(sizeof(GuiFrameModel));
    model->x = x;
    model->y = y;
    model->width = width;
    model->height = height;
    model->radius = radius;

    // Allocate and init Element
    WidgetElement* gui_frame = malloc(sizeof(WidgetElement));
    gui_frame->parent = NULL;
    gui_frame->input = NULL;
    gui_frame->draw = gui_frame_draw;
    gui_frame->free = gui_frame_free;
    gui_frame->model = model;

    return gui_frame;
}