mfc_editor_app.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "mfc_editor_app_i.h"
  2. MfcEditorApp* mfc_editor_app_alloc() {
  3. MfcEditorApp* instance = malloc(sizeof(MfcEditorApp));
  4. instance->view_dispatcher = view_dispatcher_alloc();
  5. instance->scene_manager = scene_manager_alloc(&mfc_editor_scene_handlers, instance);
  6. view_dispatcher_enable_queue(instance->view_dispatcher);
  7. view_dispatcher_set_event_callback_context(instance->view_dispatcher, instance);
  8. instance->gui = furi_record_open(RECORD_GUI);
  9. view_dispatcher_attach_to_gui(
  10. instance->view_dispatcher, instance->gui, ViewDispatcherTypeFullscreen);
  11. instance->nfc_device = nfc_device_alloc();
  12. return instance;
  13. }
  14. void mfc_editor_app_free(MfcEditorApp* instance) {
  15. furi_assert(instance);
  16. view_dispatcher_free(instance->view_dispatcher);
  17. scene_manager_free(instance->scene_manager);
  18. furi_record_close(RECORD_GUI);
  19. instance->gui = NULL;
  20. nfc_device_free(instance->nfc_device);
  21. free(instance);
  22. }
  23. int32_t mfc_editor_app(void* p) {
  24. UNUSED(p);
  25. MfcEditorApp* instance = mfc_editor_app_alloc();
  26. scene_manager_next_scene(instance->scene_manager, MfcEditorSceneStart);
  27. view_dispatcher_run(instance->view_dispatcher);
  28. mfc_editor_app_free(instance);
  29. return 0;
  30. }