Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
#include "submenu.h"
|
2021-09-28 13:10:13 +00:00
|
|
|
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
#include <gui/elements.h>
|
2021-09-28 13:10:13 +00:00
|
|
|
#include <furi.h>
|
2023-02-07 16:33:05 +00:00
|
|
|
#include <m-array.h>
|
2021-09-28 13:10:13 +00:00
|
|
|
|
|
|
|
struct Submenu {
|
|
|
|
View* view;
|
|
|
|
};
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
|
2021-09-28 13:10:13 +00:00
|
|
|
typedef struct {
|
2022-12-30 03:44:07 +00:00
|
|
|
FuriString* label;
|
2021-03-05 09:47:27 +00:00
|
|
|
uint32_t index;
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
SubmenuItemCallback callback;
|
|
|
|
void* callback_context;
|
2021-09-28 13:10:13 +00:00
|
|
|
} SubmenuItem;
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
|
2022-12-30 03:44:07 +00:00
|
|
|
static void SubmenuItem_init(SubmenuItem* item) {
|
|
|
|
item->label = furi_string_alloc();
|
|
|
|
item->index = 0;
|
|
|
|
item->callback = NULL;
|
|
|
|
item->callback_context = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SubmenuItem_init_set(SubmenuItem* item, const SubmenuItem* src) {
|
|
|
|
item->label = furi_string_alloc_set(src->label);
|
|
|
|
item->index = src->index;
|
|
|
|
item->callback = src->callback;
|
|
|
|
item->callback_context = src->callback_context;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SubmenuItem_set(SubmenuItem* item, const SubmenuItem* src) {
|
|
|
|
furi_string_set(item->label, src->label);
|
|
|
|
item->index = src->index;
|
|
|
|
item->callback = src->callback;
|
|
|
|
item->callback_context = src->callback_context;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SubmenuItem_clear(SubmenuItem* item) {
|
|
|
|
furi_string_free(item->label);
|
|
|
|
}
|
|
|
|
|
|
|
|
ARRAY_DEF(
|
|
|
|
SubmenuItemArray,
|
|
|
|
SubmenuItem,
|
|
|
|
(INIT(API_2(SubmenuItem_init)),
|
|
|
|
SET(API_6(SubmenuItem_set)),
|
|
|
|
INIT_SET(API_6(SubmenuItem_init_set)),
|
|
|
|
CLEAR(API_2(SubmenuItem_clear))))
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
SubmenuItemArray_t items;
|
2022-12-30 03:44:07 +00:00
|
|
|
FuriString* header;
|
2022-12-10 18:05:52 +00:00
|
|
|
size_t position;
|
|
|
|
size_t window_position;
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
} SubmenuModel;
|
|
|
|
|
|
|
|
static void submenu_process_up(Submenu* submenu);
|
|
|
|
static void submenu_process_down(Submenu* submenu);
|
|
|
|
static void submenu_process_ok(Submenu* submenu);
|
|
|
|
|
|
|
|
static void submenu_view_draw_callback(Canvas* canvas, void* _model) {
|
|
|
|
SubmenuModel* model = _model;
|
|
|
|
|
|
|
|
const uint8_t item_height = 16;
|
|
|
|
const uint8_t item_width = 123;
|
|
|
|
|
|
|
|
canvas_clear(canvas);
|
|
|
|
|
2022-12-30 03:44:07 +00:00
|
|
|
if(!furi_string_empty(model->header)) {
|
2021-06-09 13:04:49 +00:00
|
|
|
canvas_set_font(canvas, FontPrimary);
|
2022-12-30 03:44:07 +00:00
|
|
|
canvas_draw_str(canvas, 4, 11, furi_string_get_cstr(model->header));
|
2021-06-02 15:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
canvas_set_font(canvas, FontSecondary);
|
2022-12-10 18:05:52 +00:00
|
|
|
|
|
|
|
size_t position = 0;
|
|
|
|
SubmenuItemArray_it_t it;
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
for(SubmenuItemArray_it(it, model->items); !SubmenuItemArray_end_p(it);
|
|
|
|
SubmenuItemArray_next(it)) {
|
2022-12-10 18:05:52 +00:00
|
|
|
const size_t item_position = position - model->window_position;
|
2022-12-30 03:44:07 +00:00
|
|
|
const size_t items_on_screen = furi_string_empty(model->header) ? 4 : 3;
|
|
|
|
uint8_t y_offset = furi_string_empty(model->header) ? 0 : 16;
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
|
2021-06-09 13:04:49 +00:00
|
|
|
if(item_position < items_on_screen) {
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
if(position == model->position) {
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
2021-06-02 15:16:05 +00:00
|
|
|
elements_slightly_rounded_box(
|
|
|
|
canvas,
|
|
|
|
0,
|
|
|
|
y_offset + (item_position * item_height) + 1,
|
|
|
|
item_width,
|
|
|
|
item_height - 2);
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
canvas_set_color(canvas, ColorWhite);
|
|
|
|
} else {
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
|
}
|
2021-09-02 09:02:34 +00:00
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
FuriString* disp_str;
|
|
|
|
disp_str = furi_string_alloc_set(SubmenuItemArray_cref(it)->label);
|
2021-09-02 09:02:34 +00:00
|
|
|
elements_string_fit_width(canvas, disp_str, item_width - 20);
|
|
|
|
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
canvas_draw_str(
|
|
|
|
canvas,
|
|
|
|
6,
|
2021-06-02 15:16:05 +00:00
|
|
|
y_offset + (item_position * item_height) + item_height - 4,
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_get_cstr(disp_str));
|
2021-09-02 09:02:34 +00:00
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_free(disp_str);
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
position++;
|
|
|
|
}
|
|
|
|
|
|
|
|
elements_scrollbar(canvas, model->position, SubmenuItemArray_size(model->items));
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool submenu_view_input_callback(InputEvent* event, void* context) {
|
|
|
|
Submenu* submenu = context;
|
|
|
|
furi_assert(submenu);
|
|
|
|
bool consumed = false;
|
|
|
|
|
2021-02-10 08:56:05 +00:00
|
|
|
if(event->type == InputTypeShort) {
|
|
|
|
switch(event->key) {
|
|
|
|
case InputKeyUp:
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
consumed = true;
|
|
|
|
submenu_process_up(submenu);
|
|
|
|
break;
|
2021-02-10 08:56:05 +00:00
|
|
|
case InputKeyDown:
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
consumed = true;
|
|
|
|
submenu_process_down(submenu);
|
|
|
|
break;
|
2021-02-10 08:56:05 +00:00
|
|
|
case InputKeyOk:
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
consumed = true;
|
|
|
|
submenu_process_ok(submenu);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2022-01-21 16:55:44 +00:00
|
|
|
} else if(event->type == InputTypeRepeat) {
|
|
|
|
if(event->key == InputKeyUp) {
|
|
|
|
consumed = true;
|
|
|
|
submenu_process_up(submenu);
|
|
|
|
} else if(event->key == InputKeyDown) {
|
|
|
|
consumed = true;
|
|
|
|
submenu_process_down(submenu);
|
|
|
|
}
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
Submenu* submenu_alloc() {
|
2022-02-18 19:53:46 +00:00
|
|
|
Submenu* submenu = malloc(sizeof(Submenu));
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
submenu->view = view_alloc();
|
|
|
|
view_set_context(submenu->view, submenu);
|
|
|
|
view_allocate_model(submenu->view, ViewModelTypeLocking, sizeof(SubmenuModel));
|
|
|
|
view_set_draw_callback(submenu->view, submenu_view_draw_callback);
|
|
|
|
view_set_input_callback(submenu->view, submenu_view_input_callback);
|
|
|
|
|
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
submenu->view,
|
|
|
|
SubmenuModel * model,
|
|
|
|
{
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
SubmenuItemArray_init(model->items);
|
|
|
|
model->position = 0;
|
2021-03-05 09:47:27 +00:00
|
|
|
model->window_position = 0;
|
2022-12-30 03:44:07 +00:00
|
|
|
model->header = furi_string_alloc();
|
2022-10-08 17:38:29 +00:00
|
|
|
},
|
|
|
|
true);
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
|
|
|
|
return submenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
void submenu_free(Submenu* submenu) {
|
|
|
|
furi_assert(submenu);
|
|
|
|
|
|
|
|
with_view_model(
|
2022-12-30 03:44:07 +00:00
|
|
|
submenu->view,
|
|
|
|
SubmenuModel * model,
|
|
|
|
{
|
|
|
|
furi_string_free(model->header);
|
|
|
|
SubmenuItemArray_clear(model->items);
|
|
|
|
},
|
|
|
|
true);
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
view_free(submenu->view);
|
|
|
|
free(submenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
View* submenu_get_view(Submenu* submenu) {
|
|
|
|
furi_assert(submenu);
|
|
|
|
return submenu->view;
|
|
|
|
}
|
|
|
|
|
2021-09-28 13:10:13 +00:00
|
|
|
void submenu_add_item(
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
Submenu* submenu,
|
|
|
|
const char* label,
|
2021-03-05 09:47:27 +00:00
|
|
|
uint32_t index,
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
SubmenuItemCallback callback,
|
|
|
|
void* callback_context) {
|
|
|
|
SubmenuItem* item = NULL;
|
|
|
|
furi_assert(label);
|
|
|
|
furi_assert(submenu);
|
|
|
|
|
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
submenu->view,
|
|
|
|
SubmenuModel * model,
|
|
|
|
{
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
item = SubmenuItemArray_push_new(model->items);
|
2022-12-30 03:44:07 +00:00
|
|
|
furi_string_set_str(item->label, label);
|
2021-03-05 09:47:27 +00:00
|
|
|
item->index = index;
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
item->callback = callback;
|
|
|
|
item->callback_context = callback_context;
|
2022-10-08 17:38:29 +00:00
|
|
|
},
|
|
|
|
true);
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
}
|
|
|
|
|
2022-01-21 17:32:03 +00:00
|
|
|
void submenu_reset(Submenu* submenu) {
|
2021-03-05 09:47:27 +00:00
|
|
|
furi_assert(submenu);
|
|
|
|
|
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
submenu->view,
|
|
|
|
SubmenuModel * model,
|
|
|
|
{
|
2021-11-15 17:09:40 +00:00
|
|
|
SubmenuItemArray_reset(model->items);
|
2021-03-05 09:47:27 +00:00
|
|
|
model->position = 0;
|
|
|
|
model->window_position = 0;
|
2022-12-30 03:44:07 +00:00
|
|
|
furi_string_reset(model->header);
|
2022-10-08 17:38:29 +00:00
|
|
|
},
|
|
|
|
true);
|
2021-03-05 09:47:27 +00:00
|
|
|
}
|
|
|
|
|
2021-05-25 11:04:22 +00:00
|
|
|
void submenu_set_selected_item(Submenu* submenu, uint32_t index) {
|
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
submenu->view,
|
|
|
|
SubmenuModel * model,
|
|
|
|
{
|
2022-12-10 18:05:52 +00:00
|
|
|
size_t position = 0;
|
2021-05-25 11:04:22 +00:00
|
|
|
SubmenuItemArray_it_t it;
|
|
|
|
for(SubmenuItemArray_it(it, model->items); !SubmenuItemArray_end_p(it);
|
|
|
|
SubmenuItemArray_next(it)) {
|
|
|
|
if(index == SubmenuItemArray_cref(it)->index) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
position++;
|
|
|
|
}
|
|
|
|
|
2022-12-10 18:05:52 +00:00
|
|
|
const size_t items_size = SubmenuItemArray_size(model->items);
|
|
|
|
|
|
|
|
if(position >= items_size) {
|
2021-05-25 11:04:22 +00:00
|
|
|
position = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
model->position = position;
|
|
|
|
model->window_position = position;
|
|
|
|
|
|
|
|
if(model->window_position > 0) {
|
|
|
|
model->window_position -= 1;
|
|
|
|
}
|
|
|
|
|
2022-12-30 03:44:07 +00:00
|
|
|
const size_t items_on_screen = furi_string_empty(model->header) ? 4 : 3;
|
2021-06-09 13:04:49 +00:00
|
|
|
|
2022-12-10 18:05:52 +00:00
|
|
|
if(items_size <= items_on_screen) {
|
2021-05-25 11:04:22 +00:00
|
|
|
model->window_position = 0;
|
2022-12-26 12:13:30 +00:00
|
|
|
} else {
|
|
|
|
const size_t pos = items_size - items_on_screen;
|
|
|
|
if(model->window_position > pos) {
|
|
|
|
model->window_position = pos;
|
|
|
|
}
|
2021-05-25 11:04:22 +00:00
|
|
|
}
|
2022-10-08 17:38:29 +00:00
|
|
|
},
|
|
|
|
true);
|
2021-05-25 11:04:22 +00:00
|
|
|
}
|
|
|
|
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
void submenu_process_up(Submenu* submenu) {
|
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
submenu->view,
|
|
|
|
SubmenuModel * model,
|
|
|
|
{
|
2022-12-30 03:44:07 +00:00
|
|
|
const size_t items_on_screen = furi_string_empty(model->header) ? 4 : 3;
|
2022-12-10 18:05:52 +00:00
|
|
|
const size_t items_size = SubmenuItemArray_size(model->items);
|
|
|
|
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
if(model->position > 0) {
|
|
|
|
model->position--;
|
2022-12-26 12:13:30 +00:00
|
|
|
if((model->position == model->window_position) && (model->window_position > 0)) {
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
model->window_position--;
|
|
|
|
}
|
|
|
|
} else {
|
2022-12-10 18:05:52 +00:00
|
|
|
model->position = items_size - 1;
|
|
|
|
if(model->position > items_on_screen - 1) {
|
2021-06-09 13:04:49 +00:00
|
|
|
model->window_position = model->position - (items_on_screen - 1);
|
2021-03-05 09:47:27 +00:00
|
|
|
}
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
}
|
2022-10-08 17:38:29 +00:00
|
|
|
},
|
|
|
|
true);
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void submenu_process_down(Submenu* submenu) {
|
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
submenu->view,
|
|
|
|
SubmenuModel * model,
|
|
|
|
{
|
2022-12-30 03:44:07 +00:00
|
|
|
const size_t items_on_screen = furi_string_empty(model->header) ? 4 : 3;
|
2022-12-10 18:05:52 +00:00
|
|
|
const size_t items_size = SubmenuItemArray_size(model->items);
|
|
|
|
|
|
|
|
if(model->position < items_size - 1) {
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
model->position++;
|
2022-12-10 18:05:52 +00:00
|
|
|
if((model->position - model->window_position > items_on_screen - 2) &&
|
|
|
|
(model->window_position < items_size - items_on_screen)) {
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
model->window_position++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
model->position = 0;
|
|
|
|
model->window_position = 0;
|
|
|
|
}
|
2022-10-08 17:38:29 +00:00
|
|
|
},
|
|
|
|
true);
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void submenu_process_ok(Submenu* submenu) {
|
|
|
|
SubmenuItem* item = NULL;
|
|
|
|
|
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
submenu->view,
|
|
|
|
SubmenuModel * model,
|
|
|
|
{
|
2022-12-10 18:05:52 +00:00
|
|
|
const size_t items_size = SubmenuItemArray_size(model->items);
|
|
|
|
if(model->position < items_size) {
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
item = SubmenuItemArray_get(model->items, model->position);
|
|
|
|
}
|
2022-10-08 17:38:29 +00:00
|
|
|
},
|
|
|
|
true);
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
|
|
|
|
if(item && item->callback) {
|
2021-03-05 09:47:27 +00:00
|
|
|
item->callback(item->callback_context, item->index);
|
Implementation of some widgets based on real use cases and designs [FL-392][FL-809] (#315)
* gui test app
* aligned string draw functions
* add canvas_invert_color, canvas_draw_button_left, canvas_draw_button_right
* use new str and button fns in dialog
* real dialog mockup
* add new gui test app recipe
* submenu module init
* delete unused variable
* move buttons to element, add canvas_string_width fn, new center button element
* button icons
* submenu module
* use submenu module, switch views
* keyboard buttons img
* new font for keyboard
* text input (keyboard) module
* add text input to gui test app
* add gui tesst app to release build, fix flags
* handle transition from start and end position, fix input switch
* add long text support to text input
* canvas_string_width and the underlying u8g2_GetStrWidth now return uint16_t
* remove deprecated libs and apps
* canvas_font_max_height fn
* new element, aligned multiline text
* use multiline text instead of plain string
* fix second keyboard row, rename uppercase fn
* qwerty-like keyboard layout
* new icons for iButton app
* better dialog text position and events handling
* remove confusing comment
* new extended dialog module
* extended dialog module usage
* update docs
* new gui module, popup with timeout
* popup usage
* canvas, remove outdated canvas_font_max_height, use canvas_current_font_height
* use furi check
* use new view_enter and view_exit callback for timers
* add DrZlo to gui tester codeowner
Co-authored-by: aanper <mail@s3f.ru>
2021-02-04 23:35:06 +00:00
|
|
|
}
|
2021-05-19 09:43:15 +00:00
|
|
|
}
|
2021-06-02 15:16:05 +00:00
|
|
|
|
|
|
|
void submenu_set_header(Submenu* submenu, const char* header) {
|
|
|
|
furi_assert(submenu);
|
|
|
|
|
|
|
|
with_view_model(
|
2022-12-30 03:44:07 +00:00
|
|
|
submenu->view,
|
|
|
|
SubmenuModel * model,
|
|
|
|
{
|
|
|
|
if(header == NULL) {
|
|
|
|
furi_string_reset(model->header);
|
|
|
|
} else {
|
|
|
|
furi_string_set_str(model->header, header);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
true);
|
2021-06-02 15:16:05 +00:00
|
|
|
}
|