1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2009 Thomas Martitz
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
26 #include "appevents.h"
28 #include "screen_access.h"
29 #include "skin_engine/skin_engine.h"
30 #include "skin_engine/wps_internals.h"
32 #include "statusbar.h"
33 #include "statusbar-skinned.h"
37 /* currently only one wps_state is needed */
38 extern struct wps_state wps_state
; /* from wps.c */
39 static struct gui_wps sb_skin
[NB_SCREENS
] = {{ .data
= NULL
}};
40 static struct wps_data sb_skin_data
[NB_SCREENS
] = {{ .wps_loaded
= 0 }};
41 static struct wps_sync_data sb_skin_sync_data
= { .do_full_update
= false };
43 /* initial setup of wps_data */
45 static bool loaded_ok
[NB_SCREENS
] = { false };
46 static int update_delay
= DEFAULT_UPDATE_DELAY
;
49 void sb_skin_data_load(enum screen_type screen
, const char *buf
, bool isfile
)
51 struct wps_data
*data
= sb_skin
[screen
].data
;
54 success
= buf
&& skin_data_load(screen
, data
, buf
, isfile
);
57 { /* hide the sb's default viewport because it has nasty effect with stuff
58 * not part of the statusbar,
59 * hence .sbs's without any other vps are unsupported*/
60 struct skin_viewport
*vp
= find_viewport(VP_DEFAULT_LABEL
, data
);
61 struct skin_token_list
*next_vp
= data
->viewports
->next
;
64 { /* no second viewport, let parsing fail */
67 /* hide this viewport, forever */
68 vp
->hidden_flags
= VP_NEVER_VISIBLE
;
71 loaded_ok
[screen
] = success
;
74 /* temporary viewport structs while the non-skinned bar is in the build */
75 static struct viewport inbuilt
[NB_SCREENS
];
76 struct viewport
*sb_skin_get_info_vp(enum screen_type screen
)
78 int bar_setting
= statusbar_position(screen
);
79 if (bar_setting
== STATUSBAR_CUSTOM
)
80 return &find_viewport(VP_INFO_LABEL
, sb_skin
[screen
].data
)->vp
;
81 else if (bar_setting
== STATUSBAR_OFF
)
85 viewport_set_fullscreen(&inbuilt
[screen
], screen
);
86 /* WE need to return the UI area.. NOT the statusbar area! */
87 if (bar_setting
== STATUSBAR_TOP
)
88 inbuilt
[screen
].y
= STATUSBAR_HEIGHT
;
89 inbuilt
[screen
].height
-= STATUSBAR_HEIGHT
;
90 return &inbuilt
[screen
];
94 inline bool sb_skin_get_state(enum screen_type screen
)
96 /* Temp fix untill the hardcoded bar is removed */
97 int bar_setting
= global_settings
.statusbar
;
99 if (screen
== SCREEN_REMOTE
)
100 bar_setting
= global_settings
.remote_statusbar
;
104 case STATUSBAR_CUSTOM
:
105 return loaded_ok
[screen
];
107 case STATUSBAR_BOTTOM
:
112 return false; /* Should never actually get here */
115 void sb_skin_update(enum screen_type screen
, bool force
)
117 static long next_update
= 0;
119 if (TIME_AFTER(current_tick
, next_update
) || force
)
121 if (sb_skin_get_state(i
))
123 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
124 /* currently, all remotes are readable without backlight
125 * so still update those */
126 if (lcd_active() || (i
!= SCREEN_MAIN
))
128 skin_update(&sb_skin
[i
], force
?
129 WPS_REFRESH_ALL
: WPS_REFRESH_NON_STATIC
);
132 next_update
= current_tick
+ update_delay
; /* don't update too often */
133 sb_skin
[SCREEN_MAIN
].sync_data
->do_full_update
= false;
136 void do_sbs_update_callback(void *param
)
139 /* the WPS handles changing the actual id3 data in the id3 pointers
140 * we imported, we just want a full update */
141 sb_skin_sync_data
.do_full_update
= true;
142 /* force timeout in wps main loop, so that the update is instantly */
143 queue_post(&button_queue
, BUTTON_NONE
, 0);
146 void sb_skin_set_update_delay(int delay
)
148 update_delay
= delay
;
152 void sb_skin_init(void)
158 sb_skin_data
[i
].albumart
= NULL
;
159 sb_skin_data
[i
].playback_aa_slot
= -1;
161 sb_skin
[i
].data
= &sb_skin_data
[i
];
162 sb_skin
[i
].display
= &screens
[i
];
163 /* Currently no seperate wps_state needed/possible
164 so use the only available ( "global" ) one */
165 sb_skin
[i
].state
= &wps_state
;
166 sb_skin
[i
].sync_data
= &sb_skin_sync_data
;