initial custom statusbar commit
[kugel-rb.git] / apps / gui / statusbar-skinned.c
blobbb77a5088c3bdb27f22f95bfbd82a65e722a9315
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
21 #include <stdio.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include "config.h"
26 #include "system.h"
27 #include "settings.h"
28 #include "appevents.h"
29 #include "screens.h"
30 #include "screen_access.h"
31 #include "skin_engine/skin_engine.h"
32 #include "skin_engine/wps_internals.h"
33 #include "debug.h"
36 /* currently only one wps_state is needed */
37 extern struct wps_state wps_state;
38 static struct gui_wps sb_skin[NB_SCREENS];
39 static struct wps_data sb_skin_data[NB_SCREENS];
41 /* initial setup of wps_data */
42 static void sb_skin_update(void*);
43 static bool loaded_ok = false;
45 void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile)
48 loaded_ok = buf && skin_data_load(sb_skin[screen].data,
49 &screens[screen], buf, isfile);
52 if (loaded_ok)
53 add_event(GUI_EVENT_ACTIONUPDATE, false, sb_skin_update);
54 else
55 remove_event(GUI_EVENT_ACTIONUPDATE, sb_skin_update);
57 #ifdef HAVE_REMOVE_LCD
58 sb_skin[screen].data->remote_wps = !(screen == SCREEN_MAIN);
59 #endif
62 void sb_skin_data_init(enum screen_type screen)
64 skin_data_init(sb_skin[screen].data);
67 bool sb_skin_active(void)
69 return loaded_ok;
72 void sb_skin_update(void* param)
74 int i;
75 (void)param;
76 FOR_NB_SCREENS(i)
78 skin_update(&sb_skin[i], wps_state.do_full_update?
79 WPS_REFRESH_ALL : WPS_REFRESH_NON_STATIC);
83 void sb_skin_init(void)
85 int i;
86 FOR_NB_SCREENS(i)
88 skin_data_init(&sb_skin_data[i]);
89 #ifdef HAVE_ALBUMART
90 sb_skin_data[i].wps_uses_albumart = 0;
91 #endif
92 #ifdef HAVE_REMOTE_LCD
93 sb_skin_data[i].remote_wps = (i == SCREEN_REMOTE);
94 #endif
95 sb_skin[i].data = &sb_skin_data[i];
96 sb_skin[i].display = &screens[i];
97 sb_skin[i].data->debug = true;
98 DEBUGF("data in init: %p, debug: %d\n", &sb_skin_data[i], sb_skin_data[i].debug);
99 /* Currently no seperate wps_state needed/possible
100 so use the only available ( "global" ) one */
101 sb_skin[i].state = &wps_state;
103 #ifdef HAVE_LCD_BITMAP
105 add_event(GUI_EVENT_STATUSBAR_TOGGLE, false, statusbar_toggle_handler);
107 #endif
110 #ifdef HAVE_ALBUMART
111 bool sb_skin_uses_statusbar(int *width, int *height)
113 int i;
114 FOR_NB_SCREENS(i) {
115 struct gui_wps *gwps = &sb_skin[i];
116 if (gwps->data && (gwps->data->wps_uses_albumart != WPS_ALBUMART_NONE))
118 if (width)
119 *width = sb_skin[0].data->albumart_max_width;
120 if (height)
121 *height = sb_skin[0].data->albumart_max_height;
122 return true;
125 return false;
127 #endif