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-05 02:35:06 +03:00
|
|
|
#include "popup.h"
|
|
|
|
#include <gui/elements.h>
|
|
|
|
#include <furi.h>
|
|
|
|
|
|
|
|
struct Popup {
|
|
|
|
View* view;
|
|
|
|
void* context;
|
|
|
|
PopupCallback callback;
|
|
|
|
|
2022-07-20 13:56:33 +03:00
|
|
|
FuriTimer* timer;
|
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-05 02:35:06 +03:00
|
|
|
uint32_t timer_period_in_ms;
|
|
|
|
bool timer_enabled;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const char* text;
|
|
|
|
uint8_t x;
|
|
|
|
uint8_t y;
|
|
|
|
Align horizontal;
|
|
|
|
Align vertical;
|
|
|
|
} TextElement;
|
|
|
|
|
|
|
|
typedef struct {
|
2021-06-28 17:42:30 +03:00
|
|
|
uint8_t x;
|
|
|
|
uint8_t y;
|
2021-07-07 11:57:49 +03:00
|
|
|
const Icon* icon;
|
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-05 02:35:06 +03:00
|
|
|
} IconElement;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
TextElement header;
|
|
|
|
TextElement text;
|
|
|
|
IconElement icon;
|
|
|
|
} PopupModel;
|
|
|
|
|
|
|
|
static void popup_view_draw_callback(Canvas* canvas, void* _model) {
|
|
|
|
PopupModel* model = _model;
|
|
|
|
|
|
|
|
// Prepare canvas
|
|
|
|
canvas_clear(canvas);
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
|
|
2021-07-07 11:57:49 +03:00
|
|
|
if(model->icon.icon != NULL) {
|
|
|
|
canvas_draw_icon(canvas, model->icon.x, model->icon.y, model->icon.icon);
|
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-05 02:35:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw header
|
|
|
|
if(model->header.text != NULL) {
|
|
|
|
canvas_set_font(canvas, FontPrimary);
|
|
|
|
elements_multiline_text_aligned(
|
|
|
|
canvas,
|
|
|
|
model->header.x,
|
|
|
|
model->header.y,
|
|
|
|
model->header.horizontal,
|
|
|
|
model->header.vertical,
|
|
|
|
model->header.text);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw text
|
|
|
|
if(model->text.text != NULL) {
|
|
|
|
canvas_set_font(canvas, FontSecondary);
|
|
|
|
elements_multiline_text_aligned(
|
|
|
|
canvas,
|
|
|
|
model->text.x,
|
|
|
|
model->text.y,
|
|
|
|
model->text.horizontal,
|
|
|
|
model->text.vertical,
|
|
|
|
model->text.text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void popup_timer_callback(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
Popup* popup = context;
|
|
|
|
|
|
|
|
if(popup->callback) {
|
|
|
|
popup->callback(popup->context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool popup_view_input_callback(InputEvent* event, void* context) {
|
|
|
|
Popup* popup = context;
|
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
// Process key presses only
|
2021-02-10 11:56:05 +03:00
|
|
|
if(event->type == InputTypeShort && popup->callback) {
|
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-05 02:35:06 +03:00
|
|
|
popup->callback(popup->context);
|
|
|
|
consumed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void popup_start_timer(void* context) {
|
|
|
|
Popup* popup = context;
|
|
|
|
if(popup->timer_enabled) {
|
2022-07-20 13:56:33 +03:00
|
|
|
uint32_t timer_period =
|
|
|
|
popup->timer_period_in_ms / (1000.0f / furi_kernel_get_tick_frequency());
|
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-05 02:35:06 +03:00
|
|
|
if(timer_period == 0) timer_period = 1;
|
|
|
|
|
2022-07-20 13:56:33 +03:00
|
|
|
if(furi_timer_start(popup->timer, timer_period) != FuriStatusOk) {
|
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-05 02:35:06 +03:00
|
|
|
furi_assert(0);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void popup_stop_timer(void* context) {
|
|
|
|
Popup* popup = context;
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_timer_stop(popup->timer);
|
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-05 02:35:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Popup* popup_alloc() {
|
2022-02-18 22:53:46 +03:00
|
|
|
Popup* popup = malloc(sizeof(Popup));
|
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-05 02:35:06 +03:00
|
|
|
popup->view = view_alloc();
|
2022-07-20 13:56:33 +03:00
|
|
|
popup->timer = furi_timer_alloc(popup_timer_callback, FuriTimerTypeOnce, popup);
|
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-05 02:35:06 +03:00
|
|
|
furi_assert(popup->timer);
|
|
|
|
popup->timer_period_in_ms = 1000;
|
|
|
|
popup->timer_enabled = false;
|
|
|
|
|
|
|
|
view_set_context(popup->view, popup);
|
2022-12-26 22:46:05 +03:00
|
|
|
view_allocate_model(popup->view, ViewModelTypeLocking, sizeof(PopupModel));
|
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-05 02:35:06 +03:00
|
|
|
view_set_draw_callback(popup->view, popup_view_draw_callback);
|
|
|
|
view_set_input_callback(popup->view, popup_view_input_callback);
|
|
|
|
view_set_enter_callback(popup->view, popup_start_timer);
|
|
|
|
view_set_exit_callback(popup->view, popup_stop_timer);
|
|
|
|
|
|
|
|
with_view_model(
|
2022-10-08 20:38:29 +03:00
|
|
|
popup->view,
|
|
|
|
PopupModel * 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-05 02:35:06 +03:00
|
|
|
model->header.text = NULL;
|
|
|
|
model->header.x = 0;
|
|
|
|
model->header.y = 0;
|
|
|
|
model->header.horizontal = AlignLeft;
|
|
|
|
model->header.vertical = AlignBottom;
|
|
|
|
|
|
|
|
model->text.text = NULL;
|
|
|
|
model->text.x = 0;
|
|
|
|
model->text.y = 0;
|
|
|
|
model->text.horizontal = AlignLeft;
|
|
|
|
model->text.vertical = AlignBottom;
|
|
|
|
|
2021-06-28 17:42:30 +03:00
|
|
|
model->icon.x = 0;
|
|
|
|
model->icon.y = 0;
|
2021-07-07 11:57:49 +03:00
|
|
|
model->icon.icon = NULL;
|
2022-10-08 20:38:29 +03: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-05 02:35:06 +03:00
|
|
|
return popup;
|
|
|
|
}
|
|
|
|
|
|
|
|
void popup_free(Popup* popup) {
|
|
|
|
furi_assert(popup);
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_timer_free(popup->timer);
|
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-05 02:35:06 +03:00
|
|
|
view_free(popup->view);
|
|
|
|
free(popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
View* popup_get_view(Popup* popup) {
|
|
|
|
furi_assert(popup);
|
|
|
|
return popup->view;
|
|
|
|
}
|
|
|
|
|
|
|
|
void popup_set_callback(Popup* popup, PopupCallback callback) {
|
|
|
|
furi_assert(popup);
|
|
|
|
popup->callback = callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
void popup_set_context(Popup* popup, void* context) {
|
|
|
|
furi_assert(popup);
|
|
|
|
popup->context = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
void popup_set_header(
|
|
|
|
Popup* popup,
|
|
|
|
const char* text,
|
|
|
|
uint8_t x,
|
|
|
|
uint8_t y,
|
|
|
|
Align horizontal,
|
|
|
|
Align vertical) {
|
|
|
|
furi_assert(popup);
|
|
|
|
with_view_model(
|
2022-10-08 20:38:29 +03:00
|
|
|
popup->view,
|
|
|
|
PopupModel * 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-05 02:35:06 +03:00
|
|
|
model->header.text = text;
|
|
|
|
model->header.x = x;
|
|
|
|
model->header.y = y;
|
|
|
|
model->header.horizontal = horizontal;
|
|
|
|
model->header.vertical = vertical;
|
2022-10-08 20:38:29 +03: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-05 02:35:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void popup_set_text(
|
|
|
|
Popup* popup,
|
|
|
|
const char* text,
|
|
|
|
uint8_t x,
|
|
|
|
uint8_t y,
|
|
|
|
Align horizontal,
|
|
|
|
Align vertical) {
|
|
|
|
furi_assert(popup);
|
|
|
|
with_view_model(
|
2022-10-08 20:38:29 +03:00
|
|
|
popup->view,
|
|
|
|
PopupModel * 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-05 02:35:06 +03:00
|
|
|
model->text.text = text;
|
|
|
|
model->text.x = x;
|
|
|
|
model->text.y = y;
|
|
|
|
model->text.horizontal = horizontal;
|
|
|
|
model->text.vertical = vertical;
|
2022-10-08 20:38:29 +03: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-05 02:35:06 +03:00
|
|
|
}
|
|
|
|
|
2021-07-07 11:57:49 +03:00
|
|
|
void popup_set_icon(Popup* popup, uint8_t x, uint8_t y, const Icon* icon) {
|
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-05 02:35:06 +03:00
|
|
|
furi_assert(popup);
|
|
|
|
with_view_model(
|
2022-10-08 20:38:29 +03:00
|
|
|
popup->view,
|
|
|
|
PopupModel * 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-05 02:35:06 +03:00
|
|
|
model->icon.x = x;
|
|
|
|
model->icon.y = y;
|
2021-07-07 11:57:49 +03:00
|
|
|
model->icon.icon = icon;
|
2022-10-08 20:38:29 +03: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-05 02:35:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void popup_set_timeout(Popup* popup, uint32_t timeout_in_ms) {
|
|
|
|
furi_assert(popup);
|
|
|
|
popup->timer_period_in_ms = timeout_in_ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
void popup_enable_timeout(Popup* popup) {
|
|
|
|
popup->timer_enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void popup_disable_timeout(Popup* popup) {
|
|
|
|
popup->timer_enabled = false;
|
2022-01-21 20:32:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void popup_reset(Popup* popup) {
|
|
|
|
furi_assert(popup);
|
|
|
|
|
|
|
|
with_view_model(
|
2022-10-08 20:38:29 +03:00
|
|
|
popup->view,
|
|
|
|
PopupModel * model,
|
|
|
|
{
|
2022-01-21 20:32:03 +03:00
|
|
|
memset(&model->header, 0, sizeof(model->header));
|
|
|
|
memset(&model->text, 0, sizeof(model->text));
|
|
|
|
memset(&model->icon, 0, sizeof(model->icon));
|
2022-10-08 20:38:29 +03:00
|
|
|
},
|
|
|
|
false);
|
2022-01-21 20:32:03 +03:00
|
|
|
popup->callback = NULL;
|
|
|
|
popup->context = NULL;
|
|
|
|
popup->timer_enabled = false;
|
|
|
|
popup->timer_period_in_ms = 0;
|
|
|
|
}
|