transition_anim.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * @file transition_anim.h
  3. *
  4. */
  5. #ifndef _TRANSIMITION_ANIM_H
  6. #define _TRANSIMITION_ANIM_H
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /*********************
  11. * INCLUDES
  12. *********************/
  13. #include <stdint.h>
  14. #include <stdbool.h>
  15. #include <stddef.h>
  16. #include <ui_manager.h>
  17. #include <lvgl/lvgl_res_loader.h>
  18. #define TRANSITION_ANIMATION_DURATION 500
  19. typedef enum {
  20. TRANSITION_ANIM_NONE,
  21. TRANSITION_ANIM_OVER_LEFT,
  22. TRANSITION_ANIM_OVER_RIGHT,
  23. TRANSITION_ANIM_OVER_TOP,
  24. TRANSITION_ANIM_OVER_BOTTOM,
  25. TRANSITION_ANIM_MOVE_LEFT,
  26. TRANSITION_ANIM_MOVE_RIGHT,
  27. TRANSITION_ANIM_MOVE_TOP,
  28. TRANSITION_ANIM_MOVE_BOTTOM,
  29. TRANSITION_ANIM_FADE_IN,
  30. TRANSITION_ANIM_FADE_ON = TRANSITION_ANIM_FADE_IN, /*For backward compatibility*/
  31. TRANSITION_ANIM_FADE_OUT,
  32. TRANSITION_ANIM_OUT_LEFT,
  33. TRANSITION_ANIM_OUT_RIGHT,
  34. TRANSITION_ANIM_OUT_TOP,
  35. TRANSITION_ANIM_OUT_BOTTOM,
  36. } transition_anim_type_t;
  37. /** Describes an animation*/
  38. typedef struct _transition_anim_t {
  39. // lv obj of exit view image
  40. lv_obj_t *exit_view_image;
  41. // img dsc for exit view screen shot
  42. lv_img_dsc_t exit_view_image_dsc;
  43. // data offset to keep image data aligned
  44. uint8_t exit_view_image_data_ofs;
  45. // flag for animation prepared
  46. uint8_t transition_anim_prepared:1;
  47. } transition_anim_t;
  48. /**
  49. * @brief prepare for transition animation
  50. *
  51. * @param exit_view_data view data of exit view
  52. *
  53. * @return N/A
  54. */
  55. void transition_anim_prepare(view_data_t *exit_view_data);
  56. /**
  57. * @brief cleanup the prepared transition animation
  58. *
  59. * @return N/A
  60. */
  61. void transition_anim_unprepare(void);
  62. /**
  63. * @brief prepare for transition animation
  64. *
  65. * @param view_data view data of enter view
  66. * @param exit_anim_type animation type of exit view
  67. * @param enter_anim_type animation type of enter view
  68. *
  69. * @return N/A
  70. */
  71. void transition_anim_start(view_data_t *view_data, transition_anim_type_t exit_anim_type, transition_anim_type_t enter_anim_type);
  72. #ifdef __cplusplus
  73. } /*extern "C"*/
  74. #endif
  75. #endif /*transition_ANIM_H*/