1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 by Jonathan Gordon
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 ****************************************************************************/
25 #include "lcd-remote.h"
34 #include "statusbar.h"
35 #include "screen_access.h"
36 #include "appevents.h"
38 static int statusbar_enabled
= 0;
40 int viewport_get_nb_lines(struct viewport
*vp
)
42 #ifdef HAVE_LCD_BITMAP
43 return vp
->height
/font_get(vp
->font
)->height
;
50 static bool showing_bars(enum screen_type screen
)
52 bool ignore
= statusbar_enabled
& VP_SB_IGNORE_SETTING(screen
);
53 if (statusbar_enabled
& VP_SB_ONSCREEN(screen
))
55 #ifdef HAVE_LCD_BITMAP
56 #ifdef HAVE_REMOTE_LCD
57 if (screen
== SCREEN_REMOTE
)
58 return global_settings
.remote_statusbar
|| ignore
;
60 return global_settings
.statusbar
|| ignore
;
68 void viewport_set_defaults(struct viewport
*vp
, enum screen_type screen
)
70 bool bar_at_top
= true;
72 vp
->width
= screens
[screen
].lcdwidth
;
74 #ifdef HAVE_LCD_BITMAP
75 vp
->drawmode
= DRMODE_SOLID
;
76 vp
->font
= FONT_UI
; /* default to UI to discourage SYSFONT use */
77 #ifdef HAVE_REMOTE_LCD
78 if (screen
== SCREEN_REMOTE
)
79 bar_at_top
= global_settings
.remote_statusbar
!= STATUSBAR_BOTTOM
;
82 bar_at_top
= global_settings
.statusbar
!= STATUSBAR_BOTTOM
;
84 vp
->height
= screens
[screen
].lcdheight
;
85 if (bar_at_top
&& showing_bars(screen
))
86 vp
->y
= STATUSBAR_HEIGHT
;
92 vp
->height
= screens
[screen
].lcdheight
- (showing_bars(screen
)?STATUSBAR_HEIGHT
:0);
94 #ifdef HAVE_REMOTE_LCD
95 /* We only need this test if there is a remote LCD */
96 if (screen
== SCREEN_MAIN
)
100 vp
->fg_pattern
= global_settings
.fg_color
;
101 vp
->bg_pattern
= global_settings
.bg_color
;
102 vp
->lss_pattern
= global_settings
.lss_color
;
103 vp
->lse_pattern
= global_settings
.lse_color
;
104 vp
->lst_pattern
= global_settings
.lst_color
;
106 vp
->fg_pattern
= LCD_DEFAULT_FG
;
107 vp
->bg_pattern
= LCD_DEFAULT_BG
;
111 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
112 if (screen
== SCREEN_REMOTE
)
114 vp
->fg_pattern
= LCD_REMOTE_DEFAULT_FG
;
115 vp
->bg_pattern
= LCD_REMOTE_DEFAULT_BG
;
121 int viewportmanager_set_statusbar(int enabled
)
123 int old
= statusbar_enabled
;
124 statusbar_enabled
= enabled
;
131 gui_statusbar_draw(&statusbars
.statusbars
[i
], true);
133 add_event(GUI_EVENT_ACTIONUPDATE
, false, viewportmanager_draw_statusbars
);
137 remove_event(GUI_EVENT_ACTIONUPDATE
, viewportmanager_draw_statusbars
);
142 void viewportmanager_draw_statusbars(void* data
)
149 gui_statusbar_draw(&statusbars
.statusbars
[i
], (bool)data
);
153 void viewportmanager_statusbar_changed(void* data
)
156 statusbar_enabled
= 0;
157 if (global_settings
.statusbar
!= STATUSBAR_OFF
)
158 statusbar_enabled
= VP_SB_ONSCREEN(SCREEN_MAIN
);
159 #ifdef HAVE_REMOTE_LCD
160 if (global_settings
.remote_statusbar
!= STATUSBAR_OFF
)
161 statusbar_enabled
|= VP_SB_ONSCREEN(SCREEN_REMOTE
);
163 viewportmanager_set_statusbar(statusbar_enabled
);