mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2026-04-30 03:45:54 +00:00
404764b660
* Fill option for widget frame * Add widget circle element * Add widget line element * Fix missing include for InputType * Fix missing comment * Update api symbols * Load .fxbm from file * Fix copy pasta * Add fill param to example * Fix some comments * Bump JS SDK 0.3 * Fix free * Rename widget frame to rect * Gui: add widget_add_frame_element backward compatibility macros Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
#include "widget_element_i.h"
|
|
|
|
typedef struct {
|
|
uint8_t x;
|
|
uint8_t y;
|
|
uint8_t radius;
|
|
bool fill;
|
|
} GuiCircleModel;
|
|
|
|
static void gui_circle_draw(Canvas* canvas, WidgetElement* element) {
|
|
furi_assert(canvas);
|
|
furi_assert(element);
|
|
GuiCircleModel* model = element->model;
|
|
if(model->fill) {
|
|
canvas_draw_disc(canvas, model->x, model->y, model->radius);
|
|
} else {
|
|
canvas_draw_circle(canvas, model->x, model->y, model->radius);
|
|
}
|
|
}
|
|
|
|
static void gui_circle_free(WidgetElement* gui_circle) {
|
|
furi_assert(gui_circle);
|
|
|
|
free(gui_circle->model);
|
|
free(gui_circle);
|
|
}
|
|
|
|
WidgetElement* widget_element_circle_create(uint8_t x, uint8_t y, uint8_t radius, bool fill) {
|
|
// Allocate and init model
|
|
GuiCircleModel* model = malloc(sizeof(GuiCircleModel));
|
|
model->x = x;
|
|
model->y = y;
|
|
model->radius = radius;
|
|
model->fill = fill;
|
|
|
|
// Allocate and init Element
|
|
WidgetElement* gui_circle = malloc(sizeof(WidgetElement));
|
|
gui_circle->parent = NULL;
|
|
gui_circle->input = NULL;
|
|
gui_circle->draw = gui_circle_draw;
|
|
gui_circle->free = gui_circle_free;
|
|
gui_circle->model = model;
|
|
|
|
return gui_circle;
|
|
}
|