Skip to content

Commit

Permalink
Historize animation transition
Browse files Browse the repository at this point in the history
Saving animation parameter ensure consistency between jump and
jump back.
  • Loading branch information
guyou committed May 12, 2021
1 parent 4b9bed4 commit 3b02cec
Show file tree
Hide file tree
Showing 29 changed files with 42 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/app/alarm_clock/alarm_clock_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static void enter_alarm_clock_setup_event_cb( lv_obj_t * obj, lv_event_t event )
static void exit_alarm_clock_main_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ):
mainbar_jump_back( LV_ANIM_OFF ); // user action (return back) will be performed first
mainbar_jump_back( ); // user action (return back) will be performed first
break;
}
}
2 changes: 1 addition & 1 deletion src/app/alarm_clock/alarm_clock_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void alarm_clock_setup_setup( uint32_t tile_num ) {
static void exit_alarm_clock_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ):
mainbar_jump_back( LV_ANIM_ON );
mainbar_jump_back();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/alarm_clock/alarm_in_progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static void alarm_task_function(lv_task_t * task){
}
else{
display_set_brightness(brightness);
mainbar_jump_back( LV_ANIM_OFF );
mainbar_jump_back();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/gps_status/gps_status_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static void enter_gps_status_setup_event_cb(lv_obj_t *obj, lv_event_t event) {
static void exit_gps_status_main_event_cb(lv_obj_t *obj, lv_event_t event) {
switch (event) {
case (LV_EVENT_CLICKED):
mainbar_jump_back(LV_ANIM_OFF);
mainbar_jump_back();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/gps_status/gps_status_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static void gps_status_foobar_switch_event_cb( lv_obj_t * obj, lv_event_t event

static void exit_gps_status_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_ON );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
break;
}
}
2 changes: 1 addition & 1 deletion src/app/osmand/osmand_app_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void osmand_app_main_tile_time_update_task( lv_task_t * task ) {
static void exit_osmand_app_main_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ):
mainbar_jump_back( LV_ANIM_OFF );
mainbar_jump_back();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/osmmap/osmmap_app_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ static void exit_osmmap_app_main_event_cb( lv_obj_t * obj, lv_event_t event ) {
/**
* exit to mainbar
*/
mainbar_jump_back( LV_ANIM_OFF );
mainbar_jump_back();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/powermeter/powermeter_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static void enter_powermeter_setup_event_cb( lv_obj_t * obj, lv_event_t event )

static void exit_powermeter_main_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/powermeter/powermeter_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static void exit_powermeter_widget_setup_event_cb( lv_obj_t * obj, lv_event_t ev
strlcpy( powermeter_config->topic, lv_textarea_get_text( powermeter_topic_textfield ), sizeof( powermeter_config->topic ) );
powermeter_config->port = atoi(lv_textarea_get_text( powermeter_port_textfield ));
powermeter_save_config();
mainbar_jump_back( LV_ANIM_ON );
mainbar_jump_back();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/sailing/sailing_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static void enter_sailing_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {

static void exit_sailing_main_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
display_set_timeout( 15 );
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/sailing/sailing_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void sailing_track_switch_event_cb( lv_obj_t * obj, lv_event_t event ) {

static void exit_sailing_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_ON );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
statusbar_hide( false );
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/stopwatch/stopwatch_app_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static void reset_stopwatch_app_main_event_cb( lv_obj_t * obj, lv_event_t event

static void exit_stopwatch_app_main_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/weather/weather_forecast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ bool weather_forecast_wifictl_event_cb( EventBits_t event, void *arg ) {

static void exit_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/weather/weather_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static void exit_weather_widget_setup_event_cb( lv_obj_t * obj, lv_event_t event
strlcpy( weather_config->lat, lv_textarea_get_text( weather_lat_textfield ), sizeof( weather_config->lat ) );
strlcpy( weather_config->lon, lv_textarea_get_text( weather_lon_textfield ), sizeof( weather_config->lon ) );
weather_save_config();
mainbar_jump_back( LV_ANIM_OFF );
mainbar_jump_back();
break;
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/gui/mainbar/mainbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void mainbar_setup( void ) {
mainbar_clear_history();
}

void mainbar_add_current_tile_to_history( void ) {
void mainbar_add_current_tile_to_history( lv_anim_enable_t anim ) {
lv_coord_t x,y;
/*
* check if mainbar already initialized
Expand All @@ -100,7 +100,8 @@ void mainbar_add_current_tile_to_history( void ) {
mainbar_history.tile[ mainbar_history.entrys ].x = x;
mainbar_history.tile[ mainbar_history.entrys ].y = y;
mainbar_history.statusbar[ mainbar_history.entrys ] = statusbar_get_hidden_state();
MAINBAR_INFO_LOG("store tile to history: %d, %d, %d", x, y, statusbar_get_hidden_state() );
mainbar_history.anim[ mainbar_history.entrys ] = anim;
MAINBAR_INFO_LOG("store tile to history: %d, %d, %d, %d", x, y, statusbar_get_hidden_state(), anim );
}
}
}
Expand All @@ -121,7 +122,7 @@ void mainbar_clear_history( void ) {
MAINBAR_INFO_LOG("clear mainbar history");
}

void mainbar_jump_back( lv_anim_enable_t anim ) {
void mainbar_jump_back( void ) {
lv_coord_t x,y;
/*
* check if mainbar already initialized
Expand All @@ -140,7 +141,7 @@ void mainbar_jump_back( lv_anim_enable_t anim ) {
* jump back
*/
MAINBAR_INFO_LOG("jump back to tile: %d, %d, %d", mainbar_history.tile[ mainbar_history.entrys ].x, mainbar_history.tile[ mainbar_history.entrys ].y, mainbar_history.statusbar[ mainbar_history.entrys ] );
lv_tileview_set_tile_act( mainbar, mainbar_history.tile[ mainbar_history.entrys ].x, mainbar_history.tile[ mainbar_history.entrys ].y, anim );
lv_tileview_set_tile_act( mainbar, mainbar_history.tile[ mainbar_history.entrys ].x, mainbar_history.tile[ mainbar_history.entrys ].y, mainbar_history.anim[ mainbar_history.entrys ] );
statusbar_hide( mainbar_history.statusbar[ mainbar_history.entrys ] );
gui_force_redraw( true );
/**
Expand Down Expand Up @@ -397,7 +398,7 @@ void mainbar_jump_to_tilenumber( uint32_t tile_number, lv_anim_enable_t anim, bo
* store current tile and statusbar state
*/
if ( tile_number != current_tile ) {
mainbar_add_current_tile_to_history();
mainbar_add_current_tile_to_history( anim );
}
statusbar_hide( statusbar );
/**
Expand Down Expand Up @@ -453,7 +454,7 @@ void mainbar_jump_to_tilenumber( uint32_t tile_number, lv_anim_enable_t anim ) {
* store current tile and statusbar state
*/
if ( tile_number != current_tile ) {
mainbar_add_current_tile_to_history();
mainbar_add_current_tile_to_history( anim );
}
/**
* jump into tile
Expand Down
9 changes: 5 additions & 4 deletions src/gui/mainbar/mainbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
#define STATUSBAR_SHOW false

typedef struct {
uint32_t entrys;
lv_point_t tile[ MAINBAR_MAX_HISTORY ];
bool statusbar[ MAINBAR_MAX_HISTORY ];
uint32_t entrys;
lv_point_t tile[ MAINBAR_MAX_HISTORY ];
bool statusbar[ MAINBAR_MAX_HISTORY ];
lv_anim_enable_t anim[ MAINBAR_MAX_HISTORY ];
} mainbar_history_t;

typedef struct {
Expand Down Expand Up @@ -137,6 +138,6 @@
/**
* jump back in tile history
*/
void mainbar_jump_back( lv_anim_enable_t anim );
void mainbar_jump_back( void );

#endif // _MAINBAR_H
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static void enter_bluetooth_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {

static void exit_bluetooth_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ static void down_display_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {

static void up_display_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_ON );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
break;
}

}

static void exit_display_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
display_save_config();
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/mainbar/setup_tile/move_settings/move_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static void enter_move_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {

static void exit_move_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static void enter_sdcard_settings_event_cb(lv_obj_t *obj, lv_event_t event) {
static void exit_sdcard_settings_event_cb(lv_obj_t *obj, lv_event_t event) {
switch (event) {
case (LV_EVENT_CLICKED):
mainbar_jump_back( LV_ANIM_OFF );
mainbar_jump_back();
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static void enter_sound_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {

static void exit_sound_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
sound_save_config();
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/mainbar/setup_tile/time_settings/time_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ static void enter_time_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
static void exit_time_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): time_settings_set_timezone_timerule();
mainbar_jump_back( LV_ANIM_OFF );
mainbar_jump_back();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/mainbar/setup_tile/update/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static void enter_update_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
static void exit_update_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ):
mainbar_jump_back( LV_ANIM_OFF );
mainbar_jump_back();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/mainbar/setup_tile/update/update_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static void update_check_autosync_onoff_event_handler( lv_obj_t * obj, lv_event_

static void exit_update_check_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( false );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
strlcpy( update_config->updateurl , lv_textarea_get_text( update_check_url_textfield ), sizeof( update_config->updateurl ) );
update_save_config();
break;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/mainbar/setup_tile/utilities/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static void enter_utilities_event_cb( lv_obj_t * obj, lv_event_t event ) {

static void exit_utilities_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void watchface_manager_theme_install_task( lv_task_t * task ) {
static void exit_watchface_manager_app_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch ( event ) {
case LV_EVENT_CLICKED:
mainbar_jump_back( LV_ANIM_OFF );
mainbar_jump_back();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/mainbar/setup_tile/watchface/watchface_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static void exit_watchface_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
/**
* exit to mainbar
*/
mainbar_jump_back( LV_ANIM_OFF );
mainbar_jump_back();
break;
}
}
2 changes: 1 addition & 1 deletion src/gui/mainbar/setup_tile/watchface/watchface_tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void watchface_reload_and_test( void ) {

static void exit_watchface_app_tile_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_SHORT_CLICKED ): mainbar_jump_back( LV_ANIM_OFF );
case( LV_EVENT_SHORT_CLICKED ): mainbar_jump_back();
break;
case( LV_EVENT_LONG_PRESSED ): mainbar_jump_to_tilenumber( watchface_manager_get_setup_tile_num(), LV_ANIM_OFF );
break;
Expand Down
6 changes: 3 additions & 3 deletions src/gui/mainbar/setup_tile/wlan_settings/wlan_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static void enter_wifi_settings_event_cb( lv_obj_t * obj, lv_event_t event ) {

static void exit_wifi_settings_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
break;
}
}
Expand Down Expand Up @@ -250,7 +250,7 @@ static void wlan_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
static void exit_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): keyboard_hide();
mainbar_jump_back( LV_ANIM_ON );
mainbar_jump_back();
break;
}
}
Expand Down Expand Up @@ -329,7 +329,7 @@ static void enter_wifi_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {

static void exit_wifi_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_back( LV_ANIM_ON );
case( LV_EVENT_CLICKED ): mainbar_jump_back();
break;
}
}
Expand Down

0 comments on commit 3b02cec

Please sign in to comment.