-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
16 changed files
with
360 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
|
||
#pragma once | ||
|
||
#include <input/input.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
45 changes: 45 additions & 0 deletions
45
applications/services/gui/modules/widget_elements/widget_element_circle.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#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; | ||
} |
48 changes: 0 additions & 48 deletions
48
applications/services/gui/modules/widget_elements/widget_element_frame.c
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
applications/services/gui/modules/widget_elements/widget_element_line.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "widget_element_i.h" | ||
|
||
typedef struct { | ||
uint8_t x1; | ||
uint8_t y1; | ||
uint8_t x2; | ||
uint8_t y2; | ||
} GuiLineModel; | ||
|
||
static void gui_line_draw(Canvas* canvas, WidgetElement* element) { | ||
furi_assert(canvas); | ||
furi_assert(element); | ||
GuiLineModel* model = element->model; | ||
canvas_draw_line(canvas, model->x1, model->y1, model->x2, model->y2); | ||
} | ||
|
||
static void gui_line_free(WidgetElement* gui_line) { | ||
furi_assert(gui_line); | ||
|
||
free(gui_line->model); | ||
free(gui_line); | ||
} | ||
|
||
WidgetElement* widget_element_line_create(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) { | ||
// Allocate and init model | ||
GuiLineModel* model = malloc(sizeof(GuiLineModel)); | ||
model->x1 = x1; | ||
model->y1 = y1; | ||
model->x2 = x2; | ||
model->y2 = y2; | ||
|
||
// Allocate and init Element | ||
WidgetElement* gui_line = malloc(sizeof(WidgetElement)); | ||
gui_line->parent = NULL; | ||
gui_line->input = NULL; | ||
gui_line->draw = gui_line_draw; | ||
gui_line->free = gui_line_free; | ||
gui_line->model = model; | ||
|
||
return gui_line; | ||
} |
55 changes: 55 additions & 0 deletions
55
applications/services/gui/modules/widget_elements/widget_element_rect.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "widget_element_i.h" | ||
|
||
typedef struct { | ||
uint8_t x; | ||
uint8_t y; | ||
uint8_t width; | ||
uint8_t height; | ||
uint8_t radius; | ||
bool fill; | ||
} GuiRectModel; | ||
|
||
static void gui_rect_draw(Canvas* canvas, WidgetElement* element) { | ||
furi_assert(canvas); | ||
furi_assert(element); | ||
GuiRectModel* model = element->model; | ||
if(model->fill) { | ||
canvas_draw_rbox(canvas, model->x, model->y, model->width, model->height, model->radius); | ||
} else { | ||
canvas_draw_rframe(canvas, model->x, model->y, model->width, model->height, model->radius); | ||
} | ||
} | ||
|
||
static void gui_rect_free(WidgetElement* gui_rect) { | ||
furi_assert(gui_rect); | ||
|
||
free(gui_rect->model); | ||
free(gui_rect); | ||
} | ||
|
||
WidgetElement* widget_element_rect_create( | ||
uint8_t x, | ||
uint8_t y, | ||
uint8_t width, | ||
uint8_t height, | ||
uint8_t radius, | ||
bool fill) { | ||
// Allocate and init model | ||
GuiRectModel* model = malloc(sizeof(GuiRectModel)); | ||
model->x = x; | ||
model->y = y; | ||
model->width = width; | ||
model->height = height; | ||
model->radius = radius; | ||
model->fill = fill; | ||
|
||
// Allocate and init Element | ||
WidgetElement* gui_rect = malloc(sizeof(WidgetElement)); | ||
gui_rect->parent = NULL; | ||
gui_rect->input = NULL; | ||
gui_rect->draw = gui_rect_draw; | ||
gui_rect->free = gui_rect_free; | ||
gui_rect->model = model; | ||
|
||
return gui_rect; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.