[FL-2150] Dolphin animation refactoring (#938)

* Dolphin Animation Refactoring, part 1
* Remove animations from desktop
* Remove excess, first start
* Split animation_manager with callbacks
* allocate view inside animation_view
* Work on ViewComposed
* Draw white rectangles under bubble corners
* Fix bubbles sequence
* RPC: remove obsolete include "status.pb.h"
* Add animations manifest decoding
* Flipper file: add strict mode
* FFF: Animation structures parsing
* Assembling structure of animation
* Lot of view fixes:
  Add multi-line bubbles
  Add support for passive bubbles (frame_order values starts from passive now)
  Add hard-coded delay (active_shift) for active state enabling
  Fix active state handling
  Fix leaks
  Fix parsing uncorrect bubble_animation meta file
  Fix bubble rules of showing
* Animation load/unload & view freeze/unfreeze
* Blocking & system animations, fixes:
  View correct activation
  Refactoring + blocking animation
  Freeze first passive/active frames
  Many insert/eject SD tests fixes
  Add system animations
  Add Loader events app started/finished
  Add system no_sd animation
* Assets: dolphin packer. Scripts: minor refactoring.
* Desktop: update logging tags. Scripts: add metadata to dolphin bundling process, extra sorting for fs traversing. Make: phony assets rules.
* Github: rebuild assets on build
* Docker: add missing dependencies for assets compilation
* Docker: fix run command syntax
* ReadMe: update naming rules with link to source
* Assets: recompile icons
* Loader: add loader event
* Desktop, Gui, Furi Core: const shenanigans macros

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Albert Kharisov
2022-01-03 01:39:56 +04:00
committed by GitHub
parent 065241fe5b
commit a39002ce22
349 changed files with 3531 additions and 1912 deletions

View File

@@ -5,5 +5,4 @@ ADD_SCENE(desktop, debug, Debug)
ADD_SCENE(desktop, first_start, FirstStart)
ADD_SCENE(desktop, hw_mismatch, HwMismatch)
ADD_SCENE(desktop, pinsetup, PinSetup)
ADD_SCENE(desktop, levelup, LevelUp)
ADD_SCENE(desktop, fault, Fault)

View File

@@ -3,7 +3,7 @@
#include <dolphin/dolphin.h>
#include <dolphin/helpers/dolphin_deed.h>
void desktop_scene_debug_callback(DesktopDebugEvent event, void* context) {
void desktop_scene_debug_callback(DesktopEvent event, void* context) {
Desktop* desktop = (Desktop*)context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
}
@@ -33,14 +33,12 @@ bool desktop_scene_debug_on_event(void* context, SceneManagerEvent event) {
case DesktopDebugEventDeed:
dolphin_deed(dolphin, DolphinDeedIButtonEmulate);
desktop_debug_get_dolphin_data(desktop->debug_view);
desktop_start_new_idle_animation(desktop->animation);
consumed = true;
break;
case DesktopDebugEventWrongDeed:
dolphin_deed(dolphin, DolphinDeedWrong);
desktop_debug_get_dolphin_data(desktop->debug_view);
desktop_start_new_idle_animation(desktop->animation);
consumed = true;
break;

View File

@@ -1,7 +1,8 @@
#include "../desktop_i.h"
#include "../views/desktop_first_start.h"
#include "../views/desktop_events.h"
void desktop_scene_first_start_callback(DesktopFirstStartEvent event, void* context) {
void desktop_scene_first_start_callback(DesktopEvent event, void* context) {
Desktop* desktop = (Desktop*)context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
}

View File

@@ -10,18 +10,21 @@ void desktop_scene_hw_mismatch_callback(void* context) {
void desktop_scene_hw_mismatch_on_enter(void* context) {
Desktop* desktop = (Desktop*)context;
furi_assert(desktop);
furi_assert(!desktop->text_buffer);
Popup* popup = desktop->hw_mismatch_popup;
char buffer[256]; // strange but smaller buffer not making it
desktop->text_buffer = furi_alloc(256);
snprintf(
buffer,
sizeof(buffer),
desktop->text_buffer,
256,
"HW target: %d\nFW target: %d",
furi_hal_version_get_hw_target(),
version_get_target(NULL));
popup_set_context(popup, desktop);
popup_set_header(
popup, "!!!! HW Mismatch !!!!", 60, 14 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
popup_set_text(popup, buffer, 60, 37 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
popup_set_text(
popup, desktop->text_buffer, 60, 37 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
popup_set_callback(popup, desktop_scene_hw_mismatch_callback);
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewHwMismatch);
}
@@ -46,9 +49,13 @@ bool desktop_scene_hw_mismatch_on_event(void* context, SceneManagerEvent event)
void desktop_scene_hw_mismatch_on_exit(void* context) {
Desktop* desktop = (Desktop*)context;
furi_assert(desktop);
furi_assert(desktop->text_buffer);
Popup* popup = desktop->hw_mismatch_popup;
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
popup_set_callback(popup, NULL);
popup_set_context(popup, NULL);
free(desktop->text_buffer);
desktop->text_buffer = NULL;
}

View File

@@ -1,79 +0,0 @@
#include "../desktop_i.h"
#include "../views/desktop_main.h"
#include "applications.h"
#include "assets_icons.h"
#include "desktop/desktop.h"
#include "desktop/helpers/desktop_animation.h"
#include "dolphin/dolphin.h"
#include "furi/pubsub.h"
#include "furi/record.h"
#include "storage/storage-glue.h"
#include <loader/loader.h>
#include <m-list.h>
#define LEVELUP_SCENE_PLAYING 0
#define LEVELUP_SCENE_STOPPED 1
static void desktop_scene_levelup_callback(DesktopMainEvent event, void* context) {
Desktop* desktop = (Desktop*)context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
}
static void desktop_scene_levelup_animation_changed_callback(void* context) {
furi_assert(context);
Desktop* desktop = context;
view_dispatcher_send_custom_event(
desktop->view_dispatcher, DesktopMainEventUpdateOneShotAnimation);
}
void desktop_scene_levelup_on_enter(void* context) {
Desktop* desktop = (Desktop*)context;
DesktopMainView* main_view = desktop->main_view;
desktop_main_set_callback(main_view, desktop_scene_levelup_callback, desktop);
desktop_animation_set_animation_changed_callback(
desktop->animation, desktop_scene_levelup_animation_changed_callback, desktop);
desktop_animation_start_oneshot_levelup(desktop->animation);
const Icon* icon = desktop_animation_get_oneshot_frame(desktop->animation);
desktop_main_switch_dolphin_icon(desktop->main_view, icon);
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewMain);
scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneLevelUp, LEVELUP_SCENE_PLAYING);
}
bool desktop_scene_levelup_on_event(void* context, SceneManagerEvent event) {
Desktop* desktop = (Desktop*)context;
bool consumed = false;
DesktopMainEvent main_event = event.event;
if(event.type == SceneManagerEventTypeCustom) {
if(main_event == DesktopMainEventUpdateOneShotAnimation) {
const Icon* icon = desktop_animation_get_oneshot_frame(desktop->animation);
if(icon) {
desktop_main_switch_dolphin_icon(desktop->main_view, icon);
} else {
scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneLevelUp, LEVELUP_SCENE_STOPPED);
}
consumed = true;
} else {
if(scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneLevelUp) ==
LEVELUP_SCENE_STOPPED) {
scene_manager_previous_scene(desktop->scene_manager);
}
}
}
return consumed;
}
void desktop_scene_levelup_on_exit(void* context) {
Desktop* desktop = (Desktop*)context;
Dolphin* dolphin = furi_record_open("dolphin");
dolphin_upgrade_level(dolphin);
furi_record_close("dolphin");
desktop_animation_set_animation_changed_callback(desktop->animation, NULL, NULL);
desktop_start_new_idle_animation(desktop->animation);
}

View File

@@ -3,7 +3,7 @@
#include <toolbox/saved_struct.h>
#include <stdbool.h>
void desktop_scene_lock_menu_callback(DesktopLockMenuEvent event, void* context) {
void desktop_scene_lock_menu_callback(DesktopEvent event, void* context) {
Desktop* desktop = (Desktop*)context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
}

View File

@@ -1,34 +1,28 @@
#include "../desktop_i.h"
#include "../views/desktop_locked.h"
#include "desktop/helpers/desktop_animation.h"
#include "desktop/views/desktop_main.h"
void desktop_scene_locked_callback(DesktopLockedEvent event, void* context) {
void desktop_scene_locked_callback(DesktopEvent event, void* context) {
Desktop* desktop = (Desktop*)context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
}
static void desktop_scene_locked_animation_changed_callback(void* context) {
static void desktop_scene_locked_new_idle_animation_callback(void* context) {
furi_assert(context);
Desktop* desktop = context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopMainEventUpdateAnimation);
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopLockedEventCheckAnimation);
}
void desktop_scene_locked_on_enter(void* context) {
Desktop* desktop = (Desktop*)context;
DesktopLockedView* locked_view = desktop->locked_view;
animation_manager_set_new_idle_callback(
desktop->animation_manager, desktop_scene_locked_new_idle_animation_callback);
desktop_locked_set_callback(locked_view, desktop_scene_locked_callback, desktop);
desktop_locked_reset_door_pos(locked_view);
desktop_locked_update_hint_timeout(locked_view);
desktop_animation_set_animation_changed_callback(
desktop->animation, desktop_scene_locked_animation_changed_callback, desktop);
bool status_bar_background_black = false;
const Icon* icon =
desktop_animation_get_animation(desktop->animation, &status_bar_background_black);
desktop_locked_set_dolphin_animation(locked_view, icon, status_bar_background_black);
uint32_t state = scene_manager_get_scene_state(desktop->scene_manager, DesktopViewLocked);
desktop_locked_with_pin(desktop->locked_view, state == DesktopLockedWithPin);
@@ -39,7 +33,7 @@ void desktop_scene_locked_on_enter(void* context) {
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewLocked);
}
static bool desktop_scene_locked_check_pin(Desktop* desktop, DesktopMainEvent event) {
static bool desktop_scene_locked_check_pin(Desktop* desktop, DesktopEvent event) {
bool match = false;
size_t length = desktop->pincode_buffer.length;
@@ -81,15 +75,10 @@ bool desktop_scene_locked_on_event(void* context, SceneManagerEvent event) {
case DesktopLockedEventInputReset:
desktop->pincode_buffer.length = 0;
break;
case DesktopMainEventUpdateAnimation: {
bool status_bar_background_black = false;
const Icon* icon =
desktop_animation_get_animation(desktop->animation, &status_bar_background_black);
desktop_locked_set_dolphin_animation(
desktop->locked_view, icon, status_bar_background_black);
case DesktopLockedEventCheckAnimation:
animation_manager_check_blocking_process(desktop->animation_manager);
consumed = true;
break;
}
default:
if(desktop_scene_locked_check_pin(desktop, event.event)) {
scene_manager_set_scene_state(
@@ -106,7 +95,7 @@ bool desktop_scene_locked_on_event(void* context, SceneManagerEvent event) {
void desktop_scene_locked_on_exit(void* context) {
Desktop* desktop = (Desktop*)context;
desktop_animation_set_animation_changed_callback(desktop->animation, NULL, NULL);
animation_manager_set_new_idle_callback(desktop->animation_manager, NULL);
desktop_locked_reset_counter(desktop->locked_view);
osTimerStop(desktop->locked_view->timer);
}

View File

@@ -2,14 +2,51 @@
#include "../views/desktop_main.h"
#include "applications.h"
#include "assets_icons.h"
#include "cmsis_os2.h"
#include "desktop/desktop.h"
#include "desktop/views/desktop_events.h"
#include "dolphin/dolphin.h"
#include "furi/pubsub.h"
#include "furi/record.h"
#include "furi/thread.h"
#include "storage/storage-glue.h"
#include <loader/loader.h>
#include <m-list.h>
#define MAIN_VIEW_DEFAULT (0UL)
static void desktop_scene_main_app_started_callback(const void* message, void* context) {
furi_assert(context);
Desktop* desktop = context;
const LoaderEvent* event = message;
if(event->type == LoaderEventTypeApplicationStarted) {
view_dispatcher_send_custom_event(
desktop->view_dispatcher, DesktopMainEventBeforeAppStarted);
osSemaphoreAcquire(desktop->unload_animation_semaphore, osWaitForever);
} else if(event->type == LoaderEventTypeApplicationStopped) {
view_dispatcher_send_custom_event(
desktop->view_dispatcher, DesktopMainEventAfterAppFinished);
}
}
static void desktop_scene_main_new_idle_animation_callback(void* context) {
furi_assert(context);
Desktop* desktop = context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopMainEventNewIdleAnimation);
}
static void desktop_scene_main_check_animation_callback(void* context) {
furi_assert(context);
Desktop* desktop = context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopMainEventCheckAnimation);
}
static void desktop_scene_main_interact_animation_callback(void* context) {
furi_assert(context);
Desktop* desktop = context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopMainEventInteractAnimation);
}
static void desktop_switch_to_app(Desktop* desktop, const FlipperApplication* flipper_app) {
furi_assert(desktop);
furi_assert(flipper_app);
@@ -26,23 +63,31 @@ static void desktop_switch_to_app(Desktop* desktop, const FlipperApplication* fl
furi_thread_set_callback(desktop->scene_thread, flipper_app->app);
furi_thread_start(desktop->scene_thread);
furi_thread_join(desktop->scene_thread);
}
void desktop_scene_main_callback(DesktopMainEvent event, void* context) {
void desktop_scene_main_callback(DesktopEvent event, void* context) {
Desktop* desktop = (Desktop*)context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
}
static void desktop_scene_main_animation_changed_callback(void* context) {
furi_assert(context);
Desktop* desktop = context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopMainEventUpdateAnimation);
}
void desktop_scene_main_on_enter(void* context) {
Desktop* desktop = (Desktop*)context;
DesktopMainView* main_view = desktop->main_view;
animation_manager_set_context(desktop->animation_manager, desktop);
animation_manager_set_new_idle_callback(
desktop->animation_manager, desktop_scene_main_new_idle_animation_callback);
animation_manager_set_check_callback(
desktop->animation_manager, desktop_scene_main_check_animation_callback);
animation_manager_set_interact_callback(
desktop->animation_manager, desktop_scene_main_interact_animation_callback);
furi_assert(osSemaphoreGetCount(desktop->unload_animation_semaphore) == 0);
desktop->app_start_stop_subscription = furi_pubsub_subscribe(
loader_get_pubsub(), desktop_scene_main_app_started_callback, desktop);
desktop_main_set_callback(main_view, desktop_scene_main_callback, desktop);
view_port_enabled_set(desktop->lock_viewport, false);
@@ -51,13 +96,6 @@ void desktop_scene_main_on_enter(void* context) {
desktop_main_unlocked(desktop->main_view);
}
desktop_animation_activate(desktop->animation);
desktop_animation_set_animation_changed_callback(
desktop->animation, desktop_scene_main_animation_changed_callback, desktop);
bool status_bar_background_black = false;
const Icon* icon =
desktop_animation_get_animation(desktop->animation, &status_bar_background_black);
desktop_main_switch_dolphin_animation(desktop->main_view, icon, status_bar_background_black);
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewMain);
}
@@ -84,48 +122,50 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
case DesktopMainEventOpenArchive:
#ifdef APP_ARCHIVE
animation_manager_unload_and_stall_animation(desktop->animation_manager);
desktop_switch_to_app(desktop, &FLIPPER_ARCHIVE);
animation_manager_load_and_continue_animation(desktop->animation_manager);
#endif
consumed = true;
break;
case DesktopMainEventOpenFavorite:
LOAD_DESKTOP_SETTINGS(&desktop->settings);
animation_manager_unload_and_stall_animation(desktop->animation_manager);
if(desktop->settings.favorite < FLIPPER_APPS_COUNT) {
desktop_switch_to_app(desktop, &FLIPPER_APPS[desktop->settings.favorite]);
} else {
FURI_LOG_E("DesktopSrv", "Can't find favorite application");
}
animation_manager_load_and_continue_animation(desktop->animation_manager);
consumed = true;
break;
case DesktopMainEventUpdateAnimation: {
bool status_bar_background_black = false;
const Icon* icon =
desktop_animation_get_animation(desktop->animation, &status_bar_background_black);
desktop_main_switch_dolphin_animation(
desktop->main_view, icon, status_bar_background_black);
case DesktopMainEventCheckAnimation:
animation_manager_check_blocking_process(desktop->animation_manager);
consumed = true;
break;
}
case DesktopMainEventRightShort: {
DesktopAnimationState state = desktop_animation_handle_right(desktop->animation);
if(state == DesktopAnimationStateLevelUpIsPending) {
scene_manager_next_scene(desktop->scene_manager, DesktopSceneLevelUp);
}
case DesktopMainEventNewIdleAnimation:
animation_manager_new_idle_process(desktop->animation_manager);
consumed = true;
break;
case DesktopMainEventInteractAnimation:
animation_manager_interact_process(desktop->animation_manager);
consumed = true;
break;
case DesktopMainEventBeforeAppStarted:
animation_manager_unload_and_stall_animation(desktop->animation_manager);
osSemaphoreRelease(desktop->unload_animation_semaphore);
consumed = true;
break;
case DesktopMainEventAfterAppFinished:
animation_manager_load_and_continue_animation(desktop->animation_manager);
consumed = true;
break;
}
default:
break;
}
if(event.event != DesktopMainEventUpdateAnimation) {
desktop_animation_activate(desktop->animation);
}
} else if(event.type != SceneManagerEventTypeTick) {
desktop_animation_activate(desktop->animation);
}
return consumed;
@@ -134,7 +174,18 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
void desktop_scene_main_on_exit(void* context) {
Desktop* desktop = (Desktop*)context;
desktop_animation_set_animation_changed_callback(desktop->animation, NULL, NULL);
/**
* We're allowed to leave this scene only when any other app & loader
* is finished, that's why we can be sure there is no task waiting
* for start/stop semaphore
*/
furi_pubsub_unsubscribe(loader_get_pubsub(), desktop->app_start_stop_subscription);
furi_assert(osSemaphoreGetCount(desktop->unload_animation_semaphore) == 0);
animation_manager_set_new_idle_callback(desktop->animation_manager, NULL);
animation_manager_set_check_callback(desktop->animation_manager, NULL);
animation_manager_set_interact_callback(desktop->animation_manager, NULL);
animation_manager_set_context(desktop->animation_manager, desktop);
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneMain, MAIN_VIEW_DEFAULT);
desktop_main_reset_hint(desktop->main_view);
}