Rename h100 specific screenshots so they are used again
[kugel-rb.git] / apps / gui / viewport.c
blobdbf9cc4e73058b57786f7a8136801f6e797d5dc0
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
22 #include <stdlib.h>
23 #include "config.h"
24 #include "lcd.h"
25 #include "lcd-remote.h"
26 #include "font.h"
27 #include "sprintf.h"
28 #include "string.h"
29 #include "settings.h"
30 #include "kernel.h"
31 #include "system.h"
32 #include "misc.h"
33 #include "viewport.h"
34 #include "statusbar.h"
35 #include "screen_access.h"
36 #include "appevents.h"
38 static int statusbar_enabled = VP_SB_ALLSCREENS;
40 int viewport_get_nb_lines(struct viewport *vp)
42 #ifdef HAVE_LCD_BITMAP
43 return vp->height/font_get(vp->font)->height;
44 #else
45 (void)vp;
46 return 2;
47 #endif
50 static bool showing_bars(enum screen_type screen)
52 if (statusbar_enabled & VP_SB_ONSCREEN(screen))
53 return global_settings.statusbar ||
54 (statusbar_enabled & VP_SB_IGNORE_SETTING(screen));
55 return false;
58 void viewport_set_defaults(struct viewport *vp, enum screen_type screen)
60 vp->x = 0;
61 vp->width = screens[screen].lcdwidth;
63 vp->y = showing_bars(screen)?STATUSBAR_HEIGHT:0;
64 vp->height = screens[screen].lcdheight - vp->y;
65 #ifdef HAVE_LCD_BITMAP
66 vp->drawmode = DRMODE_SOLID;
67 vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */
68 #endif
70 #ifdef HAVE_REMOTE_LCD
71 /* We only need this test if there is a remote LCD */
72 if (screen == SCREEN_MAIN)
73 #endif
75 #ifdef HAVE_LCD_COLOR
76 vp->fg_pattern = global_settings.fg_color;
77 vp->bg_pattern = global_settings.bg_color;
78 vp->lss_pattern = global_settings.lss_color;
79 vp->lse_pattern = global_settings.lse_color;
80 vp->lst_pattern = global_settings.lst_color;
81 #elif LCD_DEPTH > 1
82 vp->fg_pattern = LCD_DEFAULT_FG;
83 vp->bg_pattern = LCD_DEFAULT_BG;
84 #endif
87 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
88 if (screen == SCREEN_REMOTE)
90 vp->fg_pattern = LCD_REMOTE_DEFAULT_FG;
91 vp->bg_pattern = LCD_REMOTE_DEFAULT_BG;
93 #endif
97 int viewportmanager_set_statusbar(int enabled)
99 int old = statusbar_enabled;
100 if (enabled)
102 int i;
103 FOR_NB_SCREENS(i)
105 if (showing_bars(i))
106 gui_statusbar_draw(&statusbars.statusbars[i], true);
108 add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_draw_statusbars);
110 else
112 remove_event(GUI_EVENT_ACTIONUPDATE, viewportmanager_draw_statusbars);
114 statusbar_enabled = enabled;
115 return old;
118 void viewportmanager_draw_statusbars(void* data)
120 (void)data;
121 int i;
122 FOR_NB_SCREENS(i)
124 if (showing_bars(i))
125 gui_statusbar_draw(&statusbars.statusbars[i], false);
129 void viewportmanager_statusbar_changed(void* data)
131 (void)data;
132 viewportmanager_set_statusbar(statusbar_enabled);