Files
unleashed-firmware/applications/services/gui/modules/widget_elements/widget_element_circle.c
T
WillyJL 404764b660 GUI: Widget view extra options for JS (#4120)
* 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>
2025-02-21 10:47:56 +09:00

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;
}