diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-10-04 23:22:21 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-11-15 14:20:31 +0000 |
commit | 73b1e30bb04d87144c4106ff7a9457507d191491 (patch) | |
tree | 377a307a2ba7f3065fa60cf316c20c01d03a2725 /apps/gui | |
parent | 45bd4c7220280e3eafdd2722cc17c8db8617b676 (diff) | |
download | rockbox-73b1e30bb04d87144c4106ff7a9457507d191491.tar.gz rockbox-73b1e30bb04d87144c4106ff7a9457507d191491.zip |
skin engine: Reduce scope of internal wps_data struct
A bunch of public API calls take a wps_data struct argument,
but that's an internal type that doesn't have a direct getter.
Instead the skin engine provides a gui_wps struct as a way
to refer to a particular skin instance. Use that instead of
wps_data in the public API.
Change-Id: I13e1aa8df7f08ccfb789bb728d493ac8d7de1a9b
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 8 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_engine.h | 15 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_touchsupport.c | 8 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 9 | ||||
-rw-r--r-- | apps/gui/statusbar-skinned.c | 10 | ||||
-rw-r--r-- | apps/gui/statusbar-skinned.h | 2 | ||||
-rw-r--r-- | apps/gui/wps.c | 19 |
7 files changed, 39 insertions, 32 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 3ff804263b..1a012dc1a6 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c | |||
@@ -709,14 +709,14 @@ void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear) | |||
709 | } | 709 | } |
710 | #endif | 710 | #endif |
711 | 711 | ||
712 | bool skin_has_sbs(enum screen_type screen, struct wps_data *data) | 712 | bool skin_has_sbs(struct gui_wps *gwps) |
713 | { | 713 | { |
714 | (void)screen; | 714 | struct wps_data *data = gwps->data; |
715 | (void)data; | 715 | |
716 | bool draw = false; | 716 | bool draw = false; |
717 | if (data->wps_sb_tag) | 717 | if (data->wps_sb_tag) |
718 | draw = data->show_sb_on_wps; | 718 | draw = data->show_sb_on_wps; |
719 | else if (statusbar_position(screen) != STATUSBAR_OFF) | 719 | else if (statusbar_position(gwps->display->screen_type) != STATUSBAR_OFF) |
720 | draw = true; | 720 | draw = true; |
721 | return draw; | 721 | return draw; |
722 | } | 722 | } |
diff --git a/apps/gui/skin_engine/skin_engine.h b/apps/gui/skin_engine/skin_engine.h index b56674112c..d04c873e84 100644 --- a/apps/gui/skin_engine/skin_engine.h +++ b/apps/gui/skin_engine/skin_engine.h | |||
@@ -40,25 +40,18 @@ enum skinnable_screens { | |||
40 | 40 | ||
41 | struct skin_stats; | 41 | struct skin_stats; |
42 | struct skin_viewport; | 42 | struct skin_viewport; |
43 | struct wps_data; | 43 | struct gui_wps; |
44 | 44 | ||
45 | #ifdef HAVE_TOUCHSCREEN | 45 | #ifdef HAVE_TOUCHSCREEN |
46 | int skin_get_touchaction(struct wps_data *data, int* edge_offset); | 46 | int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset); |
47 | void skin_disarm_touchregions(struct wps_data *data); | 47 | void skin_disarm_touchregions(struct gui_wps *gwps); |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | /* Do a update_type update of the skinned screen */ | 50 | /* Do a update_type update of the skinned screen */ |
51 | void skin_update(enum skinnable_screens skin, enum screen_type screen, | 51 | void skin_update(enum skinnable_screens skin, enum screen_type screen, |
52 | unsigned int update_type); | 52 | unsigned int update_type); |
53 | 53 | ||
54 | /* | 54 | bool skin_has_sbs(struct gui_wps *gwps); |
55 | * setup up the skin-data from a format-buffer (isfile = false) | ||
56 | * or from a skinfile (isfile = true) | ||
57 | */ | ||
58 | bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, | ||
59 | const char *buf, bool isfile, struct skin_stats *stats); | ||
60 | |||
61 | bool skin_has_sbs(enum screen_type screen, struct wps_data *data); | ||
62 | 55 | ||
63 | 56 | ||
64 | /* load a backdrop into the skin buffer. | 57 | /* load a backdrop into the skin buffer. |
diff --git a/apps/gui/skin_engine/skin_touchsupport.c b/apps/gui/skin_engine/skin_touchsupport.c index eba6b82f5b..77ab30d675 100644 --- a/apps/gui/skin_engine/skin_touchsupport.c +++ b/apps/gui/skin_engine/skin_touchsupport.c | |||
@@ -35,8 +35,9 @@ | |||
35 | #include "dsp_misc.h" | 35 | #include "dsp_misc.h" |
36 | 36 | ||
37 | /** Disarms all touchregions. */ | 37 | /** Disarms all touchregions. */ |
38 | void skin_disarm_touchregions(struct wps_data *data) | 38 | void skin_disarm_touchregions(struct gui_wps *gwps) |
39 | { | 39 | { |
40 | struct wps_data *data = gwps->data; | ||
40 | char* skin_buffer = get_skin_buffer(data); | 41 | char* skin_buffer = get_skin_buffer(data); |
41 | struct skin_token_list *regions = SKINOFFSETTOPTR(skin_buffer, data->touchregions); | 42 | struct skin_token_list *regions = SKINOFFSETTOPTR(skin_buffer, data->touchregions); |
42 | while (regions) | 43 | while (regions) |
@@ -52,8 +53,9 @@ void skin_disarm_touchregions(struct wps_data *data) | |||
52 | * egde_offset is a percentage value for the position of the touch | 53 | * egde_offset is a percentage value for the position of the touch |
53 | * inside the bar for regions which arnt WPS_TOUCHREGION_ACTION type. | 54 | * inside the bar for regions which arnt WPS_TOUCHREGION_ACTION type. |
54 | */ | 55 | */ |
55 | int skin_get_touchaction(struct wps_data *data, int* edge_offset) | 56 | int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset) |
56 | { | 57 | { |
58 | struct wps_data *data = gwps->data; | ||
57 | int returncode = ACTION_NONE; | 59 | int returncode = ACTION_NONE; |
58 | short x,y; | 60 | short x,y; |
59 | short vx, vy; | 61 | short vx, vy; |
@@ -161,7 +163,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset) | |||
161 | 163 | ||
162 | /* On release, all regions are disarmed. */ | 164 | /* On release, all regions are disarmed. */ |
163 | if (released) | 165 | if (released) |
164 | skin_disarm_touchregions(data); | 166 | skin_disarm_touchregions(gwps); |
165 | if (temp && temp->press_length == LONG_PRESS) | 167 | if (temp && temp->press_length == LONG_PRESS) |
166 | temp->armed = false; | 168 | temp->armed = false; |
167 | 169 | ||
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 2506688659..f3e4577cc2 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h | |||
@@ -31,6 +31,8 @@ | |||
31 | #include "core_alloc.h" | 31 | #include "core_alloc.h" |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | struct wps_data; | ||
35 | |||
34 | struct skin_stats { | 36 | struct skin_stats { |
35 | size_t buflib_handles; | 37 | size_t buflib_handles; |
36 | size_t tree_size; | 38 | size_t tree_size; |
@@ -42,6 +44,13 @@ struct skin_stats *skin_get_stats(int number, int screen); | |||
42 | #define skin_clear_stats(stats) memset(stats, 0, sizeof(struct skin_stats)) | 44 | #define skin_clear_stats(stats) memset(stats, 0, sizeof(struct skin_stats)) |
43 | bool skin_backdrop_get_debug(int index, char **path, int *ref_count, size_t *size); | 45 | bool skin_backdrop_get_debug(int index, char **path, int *ref_count, size_t *size); |
44 | 46 | ||
47 | /* | ||
48 | * setup up the skin-data from a format-buffer (isfile = false) | ||
49 | * or from a skinfile (isfile = true) | ||
50 | */ | ||
51 | bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, | ||
52 | const char *buf, bool isfile, struct skin_stats *stats); | ||
53 | |||
45 | /* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds | 54 | /* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds |
46 | (possibly with a decimal fraction) but stored as integer values. | 55 | (possibly with a decimal fraction) but stored as integer values. |
47 | E.g. 2.5 is stored as 25. This means 25 tenth of a second, i.e. 25 units. | 56 | E.g. 2.5 is stored as 25. This means 25 tenth of a second, i.e. 25 units. |
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c index d6dddf5cd2..8dd66641dd 100644 --- a/apps/gui/statusbar-skinned.c +++ b/apps/gui/statusbar-skinned.c | |||
@@ -310,13 +310,13 @@ int sb_touch_to_button(int context) | |||
310 | int button, offset; | 310 | int button, offset; |
311 | if (bypass_sb_touchregions) | 311 | if (bypass_sb_touchregions) |
312 | return ACTION_TOUCHSCREEN; | 312 | return ACTION_TOUCHSCREEN; |
313 | 313 | ||
314 | struct gui_wps *gwps = skin_get_gwps(CUSTOM_STATUSBAR, SCREEN_MAIN); | ||
314 | if (last_context != context) | 315 | if (last_context != context) |
315 | skin_disarm_touchregions(skin_get_gwps(CUSTOM_STATUSBAR, SCREEN_MAIN)->data); | 316 | skin_disarm_touchregions(gwps); |
316 | last_context = context; | 317 | last_context = context; |
317 | button = skin_get_touchaction(skin_get_gwps(CUSTOM_STATUSBAR, SCREEN_MAIN)->data, | 318 | |
318 | &offset); | 319 | button = skin_get_touchaction(gwps, &offset); |
319 | |||
320 | switch (button) | 320 | switch (button) |
321 | { | 321 | { |
322 | #ifdef HAVE_VOLUME_IN_LIST | 322 | #ifdef HAVE_VOLUME_IN_LIST |
diff --git a/apps/gui/statusbar-skinned.h b/apps/gui/statusbar-skinned.h index 8050f34235..e8fa14e676 100644 --- a/apps/gui/statusbar-skinned.h +++ b/apps/gui/statusbar-skinned.h | |||
@@ -30,6 +30,8 @@ | |||
30 | #include "icon.h" | 30 | #include "icon.h" |
31 | #include "skin_engine/skin_engine.h" | 31 | #include "skin_engine/skin_engine.h" |
32 | 32 | ||
33 | struct wps_data; | ||
34 | |||
33 | char* sb_create_from_settings(enum screen_type screen); | 35 | char* sb_create_from_settings(enum screen_type screen); |
34 | void sb_skin_init(void) INIT_ATTR; | 36 | void sb_skin_init(void) INIT_ATTR; |
35 | struct viewport *sb_skin_get_info_vp(enum screen_type screen); | 37 | struct viewport *sb_skin_get_info_vp(enum screen_type screen); |
diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 05a64370ac..430746cc8d 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c | |||
@@ -156,11 +156,12 @@ static bool update_onvol_change(enum screen_type screen) | |||
156 | 156 | ||
157 | 157 | ||
158 | #ifdef HAVE_TOUCHSCREEN | 158 | #ifdef HAVE_TOUCHSCREEN |
159 | static int skintouch_to_wps(struct wps_data *data) | 159 | static int skintouch_to_wps(void) |
160 | { | 160 | { |
161 | int offset = 0; | 161 | int offset = 0; |
162 | struct wps_state *gstate = get_wps_state(); | 162 | struct wps_state *gstate = get_wps_state(); |
163 | int button = skin_get_touchaction(data, &offset); | 163 | struct gui_wps *gwps = skin_get_gwps(WPS, SCREEN_MAIN); |
164 | int button = skin_get_touchaction(gwps, &offset); | ||
164 | switch (button) | 165 | switch (button) |
165 | { | 166 | { |
166 | case ACTION_STD_PREV: | 167 | case ACTION_STD_PREV: |
@@ -327,7 +328,7 @@ static bool ffwd_rew(int button, bool seek_from_end) | |||
327 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_BLOCK); | 328 | button = get_action(CONTEXT_WPS|ALLOW_SOFTLOCK,TIMEOUT_BLOCK); |
328 | #ifdef HAVE_TOUCHSCREEN | 329 | #ifdef HAVE_TOUCHSCREEN |
329 | if (button == ACTION_TOUCHSCREEN) | 330 | if (button == ACTION_TOUCHSCREEN) |
330 | button = skintouch_to_wps(skin_get_gwps(WPS, SCREEN_MAIN)->data); | 331 | button = skintouch_to_wps(); |
331 | #endif | 332 | #endif |
332 | if (button != ACTION_WPS_SEEKFWD | 333 | if (button != ACTION_WPS_SEEKFWD |
333 | && button != ACTION_WPS_SEEKBACK | 334 | && button != ACTION_WPS_SEEKBACK |
@@ -517,12 +518,12 @@ static void gwps_leave_wps(void) | |||
517 | { | 518 | { |
518 | FOR_NB_SCREENS(i) | 519 | FOR_NB_SCREENS(i) |
519 | { | 520 | { |
520 | skin_get_gwps(WPS, i)->display->scroll_stop(); | 521 | struct gui_wps *gwps = skin_get_gwps(WPS, i); |
522 | gwps->display->scroll_stop(); | ||
521 | #ifdef HAVE_BACKDROP_IMAGE | 523 | #ifdef HAVE_BACKDROP_IMAGE |
522 | skin_backdrop_show(sb_get_backdrop(i)); | 524 | skin_backdrop_show(sb_get_backdrop(i)); |
523 | #endif | 525 | #endif |
524 | viewportmanager_theme_undo(i, skin_has_sbs(i, skin_get_gwps(WPS, i)->data)); | 526 | viewportmanager_theme_undo(i, skin_has_sbs(gwps)); |
525 | |||
526 | } | 527 | } |
527 | 528 | ||
528 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | 529 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) |
@@ -547,7 +548,7 @@ static void gwps_enter_wps(void) | |||
547 | gwps = skin_get_gwps(WPS, i); | 548 | gwps = skin_get_gwps(WPS, i); |
548 | display = gwps->display; | 549 | display = gwps->display; |
549 | display->scroll_stop(); | 550 | display->scroll_stop(); |
550 | viewportmanager_theme_enable(i, skin_has_sbs(i, skin_get_gwps(WPS, i)->data), NULL); | 551 | viewportmanager_theme_enable(i, skin_has_sbs(gwps), NULL); |
551 | 552 | ||
552 | /* Update the values in the first (default) viewport - in case the user | 553 | /* Update the values in the first (default) viewport - in case the user |
553 | has modified the statusbar or colour settings */ | 554 | has modified the statusbar or colour settings */ |
@@ -574,7 +575,7 @@ static void gwps_enter_wps(void) | |||
574 | } | 575 | } |
575 | #ifdef HAVE_TOUCHSCREEN | 576 | #ifdef HAVE_TOUCHSCREEN |
576 | gwps = skin_get_gwps(WPS, SCREEN_MAIN); | 577 | gwps = skin_get_gwps(WPS, SCREEN_MAIN); |
577 | skin_disarm_touchregions(gwps->data); | 578 | skin_disarm_touchregions(gwps); |
578 | if (gwps->data->touchregions < 0) | 579 | if (gwps->data->touchregions < 0) |
579 | touchscreen_set_mode(TOUCHSCREEN_BUTTON); | 580 | touchscreen_set_mode(TOUCHSCREEN_BUTTON); |
580 | #endif | 581 | #endif |
@@ -655,7 +656,7 @@ long gui_wps_show(void) | |||
655 | exit = true; | 656 | exit = true; |
656 | #ifdef HAVE_TOUCHSCREEN | 657 | #ifdef HAVE_TOUCHSCREEN |
657 | if (button == ACTION_TOUCHSCREEN) | 658 | if (button == ACTION_TOUCHSCREEN) |
658 | button = skintouch_to_wps(skin_get_gwps(WPS, SCREEN_MAIN)->data); | 659 | button = skintouch_to_wps(); |
659 | #endif | 660 | #endif |
660 | /* The iPods/X5/M5 use a single button for the A-B mode markers, | 661 | /* The iPods/X5/M5 use a single button for the A-B mode markers, |
661 | defined as ACTION_WPSAB_SINGLE in their config files. */ | 662 | defined as ACTION_WPSAB_SINGLE in their config files. */ |