summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-10-04 23:22:21 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-11-15 14:20:31 +0000
commit73b1e30bb04d87144c4106ff7a9457507d191491 (patch)
tree377a307a2ba7f3065fa60cf316c20c01d03a2725
parent45bd4c7220280e3eafdd2722cc17c8db8617b676 (diff)
downloadrockbox-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
-rw-r--r--apps/gui/skin_engine/skin_display.c8
-rw-r--r--apps/gui/skin_engine/skin_engine.h15
-rw-r--r--apps/gui/skin_engine/skin_touchsupport.c8
-rw-r--r--apps/gui/skin_engine/wps_internals.h9
-rw-r--r--apps/gui/statusbar-skinned.c10
-rw-r--r--apps/gui/statusbar-skinned.h2
-rw-r--r--apps/gui/wps.c19
-rw-r--r--apps/radio/radio_skin.c14
8 files changed, 46 insertions, 39 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
712bool skin_has_sbs(enum screen_type screen, struct wps_data *data) 712bool 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
41struct skin_stats; 41struct skin_stats;
42struct skin_viewport; 42struct skin_viewport;
43struct wps_data; 43struct gui_wps;
44 44
45#ifdef HAVE_TOUCHSCREEN 45#ifdef HAVE_TOUCHSCREEN
46int skin_get_touchaction(struct wps_data *data, int* edge_offset); 46int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset);
47void skin_disarm_touchregions(struct wps_data *data); 47void 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 */
51void skin_update(enum skinnable_screens skin, enum screen_type screen, 51void skin_update(enum skinnable_screens skin, enum screen_type screen,
52 unsigned int update_type); 52 unsigned int update_type);
53 53
54/* 54bool 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 */
58bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
59 const char *buf, bool isfile, struct skin_stats *stats);
60
61bool 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. */
38void skin_disarm_touchregions(struct wps_data *data) 38void 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 */
55int skin_get_touchaction(struct wps_data *data, int* edge_offset) 56int 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
34struct wps_data;
35
34struct skin_stats { 36struct 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))
43bool skin_backdrop_get_debug(int index, char **path, int *ref_count, size_t *size); 45bool 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 */
51bool 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
33struct wps_data;
34
33char* sb_create_from_settings(enum screen_type screen); 35char* sb_create_from_settings(enum screen_type screen);
34void sb_skin_init(void) INIT_ATTR; 36void sb_skin_init(void) INIT_ATTR;
35struct viewport *sb_skin_get_info_vp(enum screen_type screen); 37struct 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
159static int skintouch_to_wps(struct wps_data *data) 159static 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. */
diff --git a/apps/radio/radio_skin.c b/apps/radio/radio_skin.c
index 0b8781ecd6..dc38faa31a 100644
--- a/apps/radio/radio_skin.c
+++ b/apps/radio/radio_skin.c
@@ -63,12 +63,12 @@ void fms_fix_displays(enum fms_exiting toggle_state)
63{ 63{
64 FOR_NB_SCREENS(i) 64 FOR_NB_SCREENS(i)
65 { 65 {
66 struct wps_data *data = skin_get_gwps(FM_SCREEN, i)->data; 66 struct gui_wps *gwps = skin_get_gwps(FM_SCREEN, i);
67 if (toggle_state == FMS_ENTER) 67 if (toggle_state == FMS_ENTER)
68 { 68 {
69 viewportmanager_theme_enable(i, skin_has_sbs(i, data), NULL); 69 viewportmanager_theme_enable(i, skin_has_sbs(gwps), NULL);
70#ifdef HAVE_BACKDROP_IMAGE 70#ifdef HAVE_BACKDROP_IMAGE
71 skin_backdrop_show(data->backdrop_id); 71 skin_backdrop_show(gwps->data->backdrop_id);
72#endif 72#endif
73 screens[i].clear_display(); 73 screens[i].clear_display();
74 /* force statusbar/skin update since we just cleared the whole screen */ 74 /* force statusbar/skin update since we just cleared the whole screen */
@@ -80,10 +80,10 @@ void fms_fix_displays(enum fms_exiting toggle_state)
80#ifdef HAVE_BACKDROP_IMAGE 80#ifdef HAVE_BACKDROP_IMAGE
81 skin_backdrop_show(sb_get_backdrop(i)); 81 skin_backdrop_show(sb_get_backdrop(i));
82#endif 82#endif
83 viewportmanager_theme_undo(i, skin_has_sbs(i, data)); 83 viewportmanager_theme_undo(i, skin_has_sbs(gwps));
84 } 84 }
85#ifdef HAVE_TOUCHSCREEN 85#ifdef HAVE_TOUCHSCREEN
86 if (i==SCREEN_MAIN && !data->touchregions) 86 if (i==SCREEN_MAIN && !gwps->data->touchregions)
87 touchscreen_set_mode(toggle_state == FMS_ENTER ? 87 touchscreen_set_mode(toggle_state == FMS_ENTER ?
88 TOUCHSCREEN_BUTTON : global_settings.touch_mode); 88 TOUCHSCREEN_BUTTON : global_settings.touch_mode);
89#endif 89#endif
@@ -96,10 +96,10 @@ int fms_do_button_loop(bool update_screen)
96 int button = skin_wait_for_action(FM_SCREEN, CONTEXT_FM|ALLOW_SOFTLOCK, 96 int button = skin_wait_for_action(FM_SCREEN, CONTEXT_FM|ALLOW_SOFTLOCK,
97 update_screen ? TIMEOUT_NOBLOCK : HZ/5); 97 update_screen ? TIMEOUT_NOBLOCK : HZ/5);
98#ifdef HAVE_TOUCHSCREEN 98#ifdef HAVE_TOUCHSCREEN
99 struct gui_wps *gwps = skin_get_gwps(FM_SCREEN, SCREEN_MAIN);
99 int offset; 100 int offset;
100 if (button == ACTION_TOUCHSCREEN) 101 if (button == ACTION_TOUCHSCREEN)
101 button = skin_get_touchaction(skin_get_gwps(FM_SCREEN, SCREEN_MAIN)->data, 102 button = skin_get_touchaction(gwps, &offset);
102 &offset);
103 switch (button) 103 switch (button)
104 { 104 {
105 case ACTION_WPS_STOP: 105 case ACTION_WPS_STOP: