[FL-2284] IR: Show universal remote loading (#1004)
* [FL-2131] IR: Show universal remote loading * Remove unused hal rtc. Gui: cleanup loading module. Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#include <irda.h>
|
||||
#include <furi.h>
|
||||
#include "scene/irda_app_scene.h"
|
||||
#include "irda_app_event.h"
|
||||
#include "scene/irda_app_scene.h"
|
||||
#include "irda_app_view_manager.h"
|
||||
#include "irda_app_remote_manager.h"
|
||||
@@ -11,6 +10,7 @@
|
||||
#include <stdint.h>
|
||||
#include <notification/notification_messages.h>
|
||||
#include <irda_worker.h>
|
||||
#include "irda_app_view_manager.h"
|
||||
|
||||
class IrdaApp {
|
||||
public:
|
||||
|
@@ -1,8 +1,13 @@
|
||||
#include <furi.h>
|
||||
#include <gui/modules/button_menu.h>
|
||||
#include <gui/view_stack.h>
|
||||
#include <gui/modules/loading.h>
|
||||
#include <gui/modules/button_panel.h>
|
||||
#include <gui/modules/dialog_ex.h>
|
||||
#include <furi.h>
|
||||
#include <callback-connector.h>
|
||||
|
||||
#include "irda/irda_app_view_manager.h"
|
||||
#include "irda/view/irda_progress_view.h"
|
||||
#include "irda_app.h"
|
||||
#include "irda/irda_app_event.h"
|
||||
|
||||
@@ -21,16 +26,20 @@ IrdaAppViewManager::IrdaAppViewManager() {
|
||||
dialog_ex = dialog_ex_alloc();
|
||||
text_input = text_input_alloc();
|
||||
button_panel = button_panel_alloc();
|
||||
popup_brut = popup_brut_alloc();
|
||||
progress_view = irda_progress_view_alloc();
|
||||
loading_view = loading_alloc();
|
||||
universal_view_stack = view_stack_alloc();
|
||||
view_stack_add_view(universal_view_stack, button_panel_get_view(button_panel));
|
||||
view_set_orientation(view_stack_get_view(universal_view_stack), ViewOrientationVertical);
|
||||
|
||||
add_view(ViewType::ButtonPanel, button_panel_get_view(button_panel));
|
||||
add_view(ViewType::UniversalRemote, view_stack_get_view(universal_view_stack));
|
||||
add_view(ViewType::ButtonMenu, button_menu_get_view(button_menu));
|
||||
add_view(ViewType::Submenu, submenu_get_view(submenu));
|
||||
add_view(ViewType::Popup, popup_get_view(popup));
|
||||
add_view(ViewType::DialogEx, dialog_ex_get_view(dialog_ex));
|
||||
add_view(ViewType::TextInput, text_input_get_view(text_input));
|
||||
|
||||
view_set_previous_callback(button_panel_get_view(button_panel), callback);
|
||||
view_set_previous_callback(view_stack_get_view(universal_view_stack), callback);
|
||||
view_set_previous_callback(button_menu_get_view(button_menu), callback);
|
||||
view_set_previous_callback(submenu_get_view(submenu), callback);
|
||||
view_set_previous_callback(popup_get_view(popup), callback);
|
||||
@@ -40,7 +49,7 @@ IrdaAppViewManager::IrdaAppViewManager() {
|
||||
|
||||
IrdaAppViewManager::~IrdaAppViewManager() {
|
||||
view_dispatcher_remove_view(
|
||||
view_dispatcher, static_cast<uint32_t>(IrdaAppViewManager::ViewType::ButtonPanel));
|
||||
view_dispatcher, static_cast<uint32_t>(IrdaAppViewManager::ViewType::UniversalRemote));
|
||||
view_dispatcher_remove_view(
|
||||
view_dispatcher, static_cast<uint32_t>(IrdaAppViewManager::ViewType::ButtonMenu));
|
||||
view_dispatcher_remove_view(
|
||||
@@ -52,13 +61,16 @@ IrdaAppViewManager::~IrdaAppViewManager() {
|
||||
view_dispatcher_remove_view(
|
||||
view_dispatcher, static_cast<uint32_t>(IrdaAppViewManager::ViewType::Popup));
|
||||
|
||||
view_stack_remove_view(universal_view_stack, button_panel_get_view(button_panel));
|
||||
view_stack_free(universal_view_stack);
|
||||
button_panel_free(button_panel);
|
||||
submenu_free(submenu);
|
||||
popup_free(popup);
|
||||
button_panel_free(button_panel);
|
||||
button_menu_free(button_menu);
|
||||
dialog_ex_free(dialog_ex);
|
||||
text_input_free(text_input);
|
||||
popup_brut_free(popup_brut);
|
||||
irda_progress_view_free(progress_view);
|
||||
loading_free(loading_view);
|
||||
|
||||
view_dispatcher_free(view_dispatcher);
|
||||
furi_record_close("gui");
|
||||
@@ -93,8 +105,16 @@ ButtonPanel* IrdaAppViewManager::get_button_panel() {
|
||||
return button_panel;
|
||||
}
|
||||
|
||||
IrdaAppPopupBrut* IrdaAppViewManager::get_popup_brut() {
|
||||
return popup_brut;
|
||||
IrdaProgressView* IrdaAppViewManager::get_progress() {
|
||||
return progress_view;
|
||||
}
|
||||
|
||||
Loading* IrdaAppViewManager::get_loading() {
|
||||
return loading_view;
|
||||
}
|
||||
|
||||
ViewStack* IrdaAppViewManager::get_universal_view_stack() {
|
||||
return universal_view_stack;
|
||||
}
|
||||
|
||||
osMessageQueueId_t IrdaAppViewManager::get_event_queue() {
|
||||
@@ -126,7 +146,6 @@ void IrdaAppViewManager::send_event(IrdaAppEvent* event) {
|
||||
}
|
||||
|
||||
osMessageQueuePut(event_queue, event, 0, timeout);
|
||||
/* furi_check(result == osOK); */
|
||||
}
|
||||
|
||||
uint32_t IrdaAppViewManager::previous_view_callback(void* context) {
|
||||
|
@@ -1,14 +1,17 @@
|
||||
#pragma once
|
||||
#include "gui/modules/button_menu.h"
|
||||
#include "gui/modules/text_input.h"
|
||||
#include <gui/modules/button_menu.h>
|
||||
#include <gui/modules/text_input.h>
|
||||
#include <gui/view_stack.h>
|
||||
#include <gui/modules/button_panel.h>
|
||||
#include <furi.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/modules/dialog_ex.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <gui/modules/popup.h>
|
||||
#include "irda_app.h"
|
||||
#include "view/irda_app_brut_view.h"
|
||||
#include "gui/modules/button_panel.h"
|
||||
#include <gui/modules/loading.h>
|
||||
|
||||
#include "irda_app_event.h"
|
||||
#include "view/irda_progress_view.h"
|
||||
|
||||
class IrdaAppViewManager {
|
||||
public:
|
||||
@@ -17,7 +20,7 @@ public:
|
||||
TextInput,
|
||||
Submenu,
|
||||
ButtonMenu,
|
||||
ButtonPanel,
|
||||
UniversalRemote,
|
||||
Popup,
|
||||
};
|
||||
|
||||
@@ -36,7 +39,9 @@ public:
|
||||
TextInput* get_text_input();
|
||||
ButtonMenu* get_button_menu();
|
||||
ButtonPanel* get_button_panel();
|
||||
IrdaAppPopupBrut* get_popup_brut();
|
||||
ViewStack* get_universal_view_stack();
|
||||
IrdaProgressView* get_progress();
|
||||
Loading* get_loading();
|
||||
|
||||
osMessageQueueId_t get_event_queue();
|
||||
|
||||
@@ -51,7 +56,9 @@ private:
|
||||
Popup* popup;
|
||||
ButtonMenu* button_menu;
|
||||
ButtonPanel* button_panel;
|
||||
IrdaAppPopupBrut* popup_brut;
|
||||
ViewStack* universal_view_stack;
|
||||
IrdaProgressView* progress_view;
|
||||
Loading* loading_view;
|
||||
|
||||
osMessageQueueId_t event_queue;
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
#include "../irda_app.h"
|
||||
#include "gui/modules/button_menu.h"
|
||||
#include "input/input.h"
|
||||
#include "irda_worker.h"
|
||||
#include <gui/modules/button_menu.h>
|
||||
#include <input/input.h>
|
||||
#include <irda_worker.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
#include "../irda_app.h"
|
||||
#include "../irda_app_view_manager.h"
|
||||
|
||||
typedef enum {
|
||||
ButtonIndexPlus = -2,
|
||||
|
@@ -1,13 +1,14 @@
|
||||
#include "../irda_app.h"
|
||||
#include "assets_icons.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
#include "gui/modules/button_menu.h"
|
||||
#include "gui/modules/button_panel.h"
|
||||
#include "../view/irda_app_brut_view.h"
|
||||
#include "gui/view.h"
|
||||
#include <gui/modules/button_menu.h>
|
||||
#include <gui/modules/button_panel.h>
|
||||
#include <gui/view.h>
|
||||
#include <gui/view_stack.h>
|
||||
|
||||
#include "../irda_app.h"
|
||||
#include "irda/irda_app_event.h"
|
||||
#include "irda/irda_app_view_manager.h"
|
||||
#include "irda/scene/irda_app_scene.h"
|
||||
#include "../view/irda_progress_view.h"
|
||||
|
||||
void IrdaAppSceneUniversalCommon::irda_app_item_callback(void* context, uint32_t index) {
|
||||
IrdaApp* app = static_cast<IrdaApp*>(context);
|
||||
@@ -19,42 +20,34 @@ void IrdaAppSceneUniversalCommon::irda_app_item_callback(void* context, uint32_t
|
||||
app->get_view_manager()->send_event(&event);
|
||||
}
|
||||
|
||||
static bool irda_popup_brut_input_callback(InputEvent* event, void* context) {
|
||||
static void irda_progress_back_callback(void* context) {
|
||||
furi_assert(context);
|
||||
furi_assert(event);
|
||||
auto app = static_cast<IrdaApp*>(context);
|
||||
bool consumed = false;
|
||||
|
||||
if((event->type == InputTypeShort) && (event->key == InputKeyBack)) {
|
||||
consumed = true;
|
||||
IrdaAppEvent irda_event;
|
||||
|
||||
irda_event.type = IrdaAppEvent::Type::Back;
|
||||
app->get_view_manager()->send_event(&irda_event);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
IrdaAppEvent irda_event = {
|
||||
.type = IrdaAppEvent::Type::Back,
|
||||
};
|
||||
app->get_view_manager()->clear_events();
|
||||
app->get_view_manager()->send_event(&irda_event);
|
||||
}
|
||||
|
||||
void IrdaAppSceneUniversalCommon::remove_popup(IrdaApp* app) {
|
||||
auto button_panel = app->get_view_manager()->get_button_panel();
|
||||
button_panel_set_popup_draw_callback(button_panel, NULL, NULL);
|
||||
button_panel_set_popup_input_callback(button_panel, NULL, NULL);
|
||||
auto stack_view = app->get_view_manager()->get_universal_view_stack();
|
||||
auto progress_view = app->get_view_manager()->get_progress();
|
||||
view_stack_remove_view(stack_view, irda_progress_view_get_view(progress_view));
|
||||
}
|
||||
|
||||
void IrdaAppSceneUniversalCommon::show_popup(IrdaApp* app, int record_amount) {
|
||||
auto button_panel = app->get_view_manager()->get_button_panel();
|
||||
auto popup_brut = app->get_view_manager()->get_popup_brut();
|
||||
popup_brut_set_progress_max(popup_brut, record_amount);
|
||||
button_panel_set_popup_draw_callback(button_panel, popup_brut_draw_callback, popup_brut);
|
||||
button_panel_set_popup_input_callback(button_panel, irda_popup_brut_input_callback, app);
|
||||
auto stack_view = app->get_view_manager()->get_universal_view_stack();
|
||||
auto progress_view = app->get_view_manager()->get_progress();
|
||||
irda_progress_view_set_progress_total(progress_view, record_amount);
|
||||
irda_progress_view_set_back_callback(progress_view, irda_progress_back_callback, app);
|
||||
view_stack_add_view(stack_view, irda_progress_view_get_view(progress_view));
|
||||
}
|
||||
|
||||
bool IrdaAppSceneUniversalCommon::progress_popup(IrdaApp* app) {
|
||||
bool result = popup_brut_increase_progress(app->get_view_manager()->get_popup_brut());
|
||||
auto button_panel = app->get_view_manager()->get_button_panel();
|
||||
with_view_model_cpp(button_panel_get_view(button_panel), void*, model, { return true; });
|
||||
return result;
|
||||
auto progress_view = app->get_view_manager()->get_progress();
|
||||
return irda_progress_view_increase_progress(progress_view);
|
||||
}
|
||||
|
||||
bool IrdaAppSceneUniversalCommon::on_event(IrdaApp* app, IrdaAppEvent* event) {
|
||||
|
@@ -1,3 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <gui/modules/loading.h>
|
||||
#include <gui/view_stack.h>
|
||||
#include "irda/scene/irda_app_scene.h"
|
||||
#include "irda/irda_app.h"
|
||||
|
||||
@@ -80,9 +83,32 @@ void IrdaAppSceneUniversalTV::on_enter(IrdaApp* app) {
|
||||
button_panel_add_label(button_panel, 9, 64, FontSecondary, "Vol");
|
||||
button_panel_add_label(button_panel, 43, 64, FontSecondary, "Ch");
|
||||
|
||||
view_manager->switch_to(IrdaAppViewManager::ViewType::ButtonPanel);
|
||||
view_manager->switch_to(IrdaAppViewManager::ViewType::UniversalRemote);
|
||||
|
||||
if(!brute_force.calculate_messages()) {
|
||||
auto stack_view = app->get_view_manager()->get_universal_view_stack();
|
||||
auto loading_view = app->get_view_manager()->get_loading();
|
||||
view_stack_add_view(stack_view, loading_get_view(loading_view));
|
||||
|
||||
/**
|
||||
* Problem: Update events are not handled in Loading View, because:
|
||||
* 1) Timer task has least prio
|
||||
* 2) Storage service uses drivers that capture whole CPU time
|
||||
* to handle SD communication
|
||||
*
|
||||
* Ugly workaround, but it works for current situation:
|
||||
* raise timer task prio for DB scanning period.
|
||||
*/
|
||||
TaskHandle_t timer_task = xTaskGetHandle(configTIMER_SERVICE_TASK_NAME);
|
||||
TaskHandle_t storage_task = xTaskGetHandle("StorageSrv");
|
||||
uint32_t timer_prio = uxTaskPriorityGet(timer_task);
|
||||
uint32_t storage_prio = uxTaskPriorityGet(storage_task);
|
||||
vTaskPrioritySet(timer_task, storage_prio + 1);
|
||||
bool result = brute_force.calculate_messages();
|
||||
vTaskPrioritySet(timer_task, timer_prio);
|
||||
|
||||
view_stack_remove_view(stack_view, loading_get_view(loading_view));
|
||||
|
||||
if(!result) {
|
||||
app->switch_to_previous_scene();
|
||||
}
|
||||
}
|
||||
|
@@ -1,84 +0,0 @@
|
||||
#include "furi_hal_resources.h"
|
||||
#include "assets_icons.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/view.h"
|
||||
#include "input/input.h"
|
||||
#include <gui/elements.h>
|
||||
#include <furi.h>
|
||||
#include "irda_app_brut_view.h"
|
||||
#include "gui/modules/button_panel.h"
|
||||
#include <stdint.h>
|
||||
|
||||
struct IrdaAppPopupBrut {
|
||||
uint16_t progress;
|
||||
uint16_t progress_max;
|
||||
char percents_string_storage[8];
|
||||
};
|
||||
|
||||
bool popup_brut_increase_progress(IrdaAppPopupBrut* popup_brut) {
|
||||
furi_assert(popup_brut);
|
||||
|
||||
if(popup_brut->progress < popup_brut->progress_max)
|
||||
++popup_brut->progress;
|
||||
else
|
||||
furi_assert(0);
|
||||
|
||||
return popup_brut->progress < popup_brut->progress_max;
|
||||
}
|
||||
|
||||
void popup_brut_draw_callback(Canvas* canvas, void* context) {
|
||||
furi_assert(canvas);
|
||||
furi_assert(context);
|
||||
IrdaAppPopupBrut* popup_brut = (IrdaAppPopupBrut*)context;
|
||||
uint8_t x = 0;
|
||||
uint8_t width = 64;
|
||||
uint8_t x_max = x + width - 1;
|
||||
uint8_t y = 36;
|
||||
uint8_t height = 59;
|
||||
uint8_t y_max = y + height - 1;
|
||||
|
||||
canvas_invert_color(canvas);
|
||||
canvas_draw_rbox(canvas, x + 1, y + 1, width - 2, height - 2, 3);
|
||||
canvas_invert_color(canvas);
|
||||
canvas_draw_rframe(canvas, x, y, width, height, 3);
|
||||
canvas_draw_rframe(canvas, x + 1, y + 1, width - 2, height - 2, 3);
|
||||
canvas_draw_line(canvas, x + 2, y + 1, x + 2, y + 3);
|
||||
canvas_draw_line(canvas, x + 1, y + 2, x + 3, y + 2);
|
||||
canvas_draw_line(canvas, x_max - 2, y + 1, x_max - 2, y + 3);
|
||||
canvas_draw_line(canvas, x_max - 1, y + 2, x_max - 3, y + 2);
|
||||
canvas_draw_line(canvas, x + 2, y_max - 1, x + 2, y_max - 3);
|
||||
canvas_draw_line(canvas, x + 1, y_max - 2, x + 3, y_max - 2);
|
||||
canvas_draw_line(canvas, x_max - 2, y_max - 1, x_max - 2, y_max - 3);
|
||||
canvas_draw_line(canvas, x_max - 1, y_max - 2, x_max - 3, y_max - 2);
|
||||
|
||||
elements_progress_bar(
|
||||
canvas, x + 4, y + 19, x_max - 7, popup_brut->progress, popup_brut->progress_max);
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str(canvas, x + 15, y + 12, "Sending ...");
|
||||
canvas_draw_icon(canvas, x + 11, y_max - 14, &I_Back_15x10);
|
||||
|
||||
uint8_t percent_value = 100 * popup_brut->progress / popup_brut->progress_max;
|
||||
snprintf(
|
||||
popup_brut->percents_string_storage,
|
||||
sizeof(popup_brut->percents_string_storage),
|
||||
"%d%%",
|
||||
percent_value);
|
||||
elements_multiline_text_aligned(
|
||||
canvas, x + 32, y + 40, AlignCenter, AlignBottom, popup_brut->percents_string_storage);
|
||||
canvas_draw_str(canvas, x + 30, y_max - 5, "= stop");
|
||||
}
|
||||
|
||||
void popup_brut_set_progress_max(IrdaAppPopupBrut* popup_brut, uint16_t progress_max) {
|
||||
furi_assert(popup_brut);
|
||||
popup_brut->progress = 0;
|
||||
popup_brut->progress_max = progress_max;
|
||||
}
|
||||
|
||||
IrdaAppPopupBrut* popup_brut_alloc(void) {
|
||||
return (IrdaAppPopupBrut*)malloc(sizeof(IrdaAppPopupBrut));
|
||||
}
|
||||
|
||||
void popup_brut_free(IrdaAppPopupBrut* popup_brut) {
|
||||
free(popup_brut);
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct IrdaAppPopupBrut IrdaAppPopupBrut;
|
||||
|
||||
bool popup_brut_increase_progress(IrdaAppPopupBrut* popup_brut);
|
||||
IrdaAppPopupBrut* popup_brut_alloc();
|
||||
void popup_brut_free(IrdaAppPopupBrut* popup_brut);
|
||||
void popup_brut_draw_callback(Canvas* canvas, void* model);
|
||||
void popup_brut_set_progress_max(IrdaAppPopupBrut* popup_brut, uint16_t progress_max);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
119
applications/irda/view/irda_progress_view.c
Normal file
119
applications/irda/view/irda_progress_view.c
Normal file
@@ -0,0 +1,119 @@
|
||||
#include "furi/check.h"
|
||||
#include "furi_hal_resources.h"
|
||||
#include "assets_icons.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/view.h"
|
||||
#include "input/input.h"
|
||||
#include "m-string.h"
|
||||
#include <gui/elements.h>
|
||||
#include <furi.h>
|
||||
#include "irda_progress_view.h"
|
||||
#include "gui/modules/button_panel.h"
|
||||
#include <stdint.h>
|
||||
|
||||
struct IrdaProgressView {
|
||||
View* view;
|
||||
IrdaProgressViewBackCallback back_callback;
|
||||
void* context;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
size_t progress;
|
||||
size_t progress_total;
|
||||
} IrdaProgressViewModel;
|
||||
|
||||
bool irda_progress_view_increase_progress(IrdaProgressView* progress) {
|
||||
furi_assert(progress);
|
||||
bool result = false;
|
||||
|
||||
IrdaProgressViewModel* model = view_get_model(progress->view);
|
||||
if(model->progress < model->progress_total) {
|
||||
++model->progress;
|
||||
result = model->progress < model->progress_total;
|
||||
}
|
||||
view_commit_model(progress->view, true);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void irda_progress_view_draw_callback(Canvas* canvas, void* _model) {
|
||||
IrdaProgressViewModel* model = (IrdaProgressViewModel*)_model;
|
||||
|
||||
uint8_t x = 0;
|
||||
uint8_t y = 36;
|
||||
uint8_t width = 63;
|
||||
uint8_t height = 59;
|
||||
|
||||
elements_bold_rounded_frame(canvas, x, y, width, height);
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
elements_multiline_text_aligned(
|
||||
canvas, x + 34, y + 9, AlignCenter, AlignCenter, "Sending ...");
|
||||
|
||||
float progress_value = (float)model->progress / model->progress_total;
|
||||
elements_progress_bar(canvas, x + 4, y + 19, width - 7, progress_value);
|
||||
|
||||
uint8_t percent_value = 100 * model->progress / model->progress_total;
|
||||
char percents_string[10] = {0};
|
||||
snprintf(percents_string, sizeof(percents_string), "%d%%", percent_value);
|
||||
elements_multiline_text_aligned(
|
||||
canvas, x + 33, y + 37, AlignCenter, AlignCenter, percents_string);
|
||||
|
||||
canvas_draw_icon(canvas, x + 11, y + height - 15, &I_Back_15x10);
|
||||
canvas_draw_str(canvas, x + 30, y + height - 6, "= stop");
|
||||
}
|
||||
|
||||
void irda_progress_view_set_progress_total(IrdaProgressView* progress, uint16_t progress_total) {
|
||||
furi_assert(progress);
|
||||
IrdaProgressViewModel* model = view_get_model(progress->view);
|
||||
model->progress = 0;
|
||||
model->progress_total = progress_total;
|
||||
view_commit_model(progress->view, false);
|
||||
}
|
||||
|
||||
bool irda_progress_view_input_callback(InputEvent* event, void* context) {
|
||||
IrdaProgressView* instance = context;
|
||||
|
||||
if((event->type == InputTypeShort) && (event->key == InputKeyBack)) {
|
||||
if(instance->back_callback) {
|
||||
instance->back_callback(instance->context);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
IrdaProgressView* irda_progress_view_alloc(void) {
|
||||
IrdaProgressView* instance = malloc(sizeof(IrdaProgressView));
|
||||
instance->view = view_alloc();
|
||||
view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(IrdaProgressViewModel));
|
||||
IrdaProgressViewModel* model = view_get_model(instance->view);
|
||||
model->progress = 0;
|
||||
model->progress_total = 0;
|
||||
view_commit_model(instance->view, false);
|
||||
view_set_draw_callback(instance->view, irda_progress_view_draw_callback);
|
||||
view_set_input_callback(instance->view, irda_progress_view_input_callback);
|
||||
view_set_context(instance->view, instance);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void irda_progress_view_free(IrdaProgressView* progress) {
|
||||
view_free(progress->view);
|
||||
free(progress);
|
||||
}
|
||||
|
||||
void irda_progress_view_set_back_callback(
|
||||
IrdaProgressView* instance,
|
||||
IrdaProgressViewBackCallback callback,
|
||||
void* context) {
|
||||
furi_assert(instance);
|
||||
instance->back_callback = callback;
|
||||
instance->context = context;
|
||||
}
|
||||
|
||||
View* irda_progress_view_get_view(IrdaProgressView* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->view);
|
||||
return instance->view;
|
||||
}
|
25
applications/irda/view/irda_progress_view.h
Normal file
25
applications/irda/view/irda_progress_view.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct IrdaProgressView IrdaProgressView;
|
||||
|
||||
typedef void (*IrdaProgressViewBackCallback)(void*);
|
||||
|
||||
IrdaProgressView* irda_progress_view_alloc();
|
||||
void irda_progress_view_free(IrdaProgressView* progress);
|
||||
View* irda_progress_view_get_view(IrdaProgressView* progress);
|
||||
|
||||
bool irda_progress_view_increase_progress(IrdaProgressView* progress);
|
||||
void irda_progress_view_set_progress_total(IrdaProgressView* progress, uint16_t progress_max);
|
||||
void irda_progress_view_set_back_callback(
|
||||
IrdaProgressView* instance,
|
||||
IrdaProgressViewBackCallback callback,
|
||||
void* context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user