summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/gwps-common.c23
-rw-r--r--apps/gui/gwps.c69
-rw-r--r--apps/gui/gwps.h1
-rw-r--r--apps/gui/icon.c2
-rw-r--r--apps/gui/statusbar.h5
-rw-r--r--apps/gui/viewport.c2
-rw-r--r--apps/gui/wps_debug.c5
-rw-r--r--apps/gui/wps_parser.c69
8 files changed, 59 insertions, 117 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 6e159b88b4..b53d68d6ba 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -345,7 +345,6 @@ bool gui_wps_display(void)
345 /* Update the values in the first (default) viewport - in case the user 345 /* Update the values in the first (default) viewport - in case the user
346 has modified the statusbar or colour settings */ 346 has modified the statusbar or colour settings */
347#ifdef HAVE_LCD_BITMAP 347#ifdef HAVE_LCD_BITMAP
348 gui_wps[i].data->viewports[0].vp.ymargin = gui_wps[i].display->getymargin();
349#if LCD_DEPTH > 1 348#if LCD_DEPTH > 1
350 if (gui_wps[i].display->depth > 1) 349 if (gui_wps[i].display->depth > 1)
351 { 350 {
@@ -1408,14 +1407,6 @@ static char *get_token_value(struct gui_wps *gwps,
1408 else 1407 else
1409 return NULL; 1408 return NULL;
1410#endif 1409#endif
1411
1412#ifdef HAVE_LCD_BITMAP
1413 case WPS_TOKEN_LEFTMARGIN:
1414 gwps->display->setmargins(token->value.i,
1415 gwps->display->getymargin());
1416 return NULL;
1417#endif
1418
1419 default: 1410 default:
1420 return NULL; 1411 return NULL;
1421 } 1412 }
@@ -1529,11 +1520,6 @@ static bool get_line(struct gui_wps *gwps,
1529 align->center = NULL; 1520 align->center = NULL;
1530 align->right = NULL; 1521 align->right = NULL;
1531 1522
1532#ifdef HAVE_LCD_BITMAP
1533 /* Reset margins - only bitmap targets modify them */
1534 gwps->display->setmargins(0, gwps->display->getymargin());
1535#endif
1536
1537 /* Process all tokens of the desired subline */ 1523 /* Process all tokens of the desired subline */
1538 last_token_idx = wps_last_token_index(data, line, subline); 1524 last_token_idx = wps_last_token_index(data, line, subline);
1539 for (i = wps_first_token_index(data, line, subline); 1525 for (i = wps_first_token_index(data, line, subline);
@@ -1800,7 +1786,7 @@ static void write_line(struct screen *display,
1800 &center_width, &string_height); 1786 &center_width, &string_height);
1801 } 1787 }
1802 1788
1803 left_xpos = display->getxmargin(); 1789 left_xpos = 0;
1804 right_xpos = (display->getwidth() - right_width); 1790 right_xpos = (display->getwidth() - right_width);
1805 center_xpos = (display->getwidth() + left_xpos - center_width) / 2; 1791 center_xpos = (display->getwidth() + left_xpos - center_width) / 2;
1806 1792
@@ -1885,7 +1871,7 @@ static void write_line(struct screen *display,
1885 right_width = 0; 1871 right_width = 0;
1886 } 1872 }
1887 1873
1888 ypos = (line * string_height) + display->getymargin(); 1874 ypos = (line * string_height);
1889 1875
1890 1876
1891 if (scroll && ((left_width > scroll_width) || 1877 if (scroll && ((left_width > scroll_width) ||
@@ -1968,7 +1954,8 @@ bool gui_wps_refresh(struct gui_wps *gwps,
1968 /* reset to first subline if refresh all flag is set */ 1954 /* reset to first subline if refresh all flag is set */
1969 if (refresh_mode == WPS_REFRESH_ALL) 1955 if (refresh_mode == WPS_REFRESH_ALL)
1970 { 1956 {
1971 display->clear_display(); 1957 display->set_viewport(&data->viewports[0].vp);
1958 display->clear_viewport();
1972 1959
1973 for (i = 0; i <= data->num_lines; i++) 1960 for (i = 0; i <= data->num_lines; i++)
1974 { 1961 {
@@ -2063,7 +2050,7 @@ bool gui_wps_refresh(struct gui_wps *gwps,
2063 update_line = false; 2050 update_line = false;
2064 2051
2065 int h = font_get(data->viewports[v].vp.font)->height; 2052 int h = font_get(data->viewports[v].vp.font)->height;
2066 int peak_meter_y = display->getymargin() + (line - data->viewports[v].first_line)* h; 2053 int peak_meter_y = (line - data->viewports[v].first_line)* h;
2067 2054
2068 /* The user might decide to have the peak meter in the last 2055 /* The user might decide to have the peak meter in the last
2069 line so that it is only displayed if no status bar is 2056 line so that it is only displayed if no status bar is
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index 5426c937c0..31b1989786 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -77,19 +77,6 @@ static void gui_wps_set_disp(struct gui_wps *gui_wps, struct screen *display);
77/* connects a wps with a statusbar*/ 77/* connects a wps with a statusbar*/
78static void gui_wps_set_statusbar(struct gui_wps *gui_wps, struct gui_statusbar *statusbar); 78static void gui_wps_set_statusbar(struct gui_wps *gui_wps, struct gui_statusbar *statusbar);
79 79
80#ifdef HAVE_LCD_BITMAP
81static void gui_wps_set_margin(struct gui_wps *gwps)
82{
83 int offset = 0;
84 struct wps_data *data = gwps->data;
85 if(data->wps_sb_tag && data->show_sb_on_wps)
86 offset = STATUSBAR_HEIGHT;
87 else if ( global_settings.statusbar && !data->wps_sb_tag)
88 offset = STATUSBAR_HEIGHT;
89 gwps->display->setmargins(0, offset);
90}
91#endif
92
93static void prev_track(unsigned skip_thresh) 80static void prev_track(unsigned skip_thresh)
94{ 81{
95 if (!wps_state.id3 || (wps_state.id3->elapsed < skip_thresh*1000)) { 82 if (!wps_state.id3 || (wps_state.id3->elapsed < skip_thresh*1000)) {
@@ -152,10 +139,6 @@ long gui_wps_show(void)
152 status_set_audio(true); 139 status_set_audio(true);
153 status_set_param(false); 140 status_set_param(false);
154#else 141#else
155 FOR_NB_SCREENS(i)
156 {
157 gui_wps_set_margin(&gui_wps[i]);
158 }
159#if LCD_DEPTH > 1 142#if LCD_DEPTH > 1
160 show_wps_backdrop(); 143 show_wps_backdrop();
161#endif /* LCD_DEPTH > 1 */ 144#endif /* LCD_DEPTH > 1 */
@@ -299,12 +282,6 @@ long gui_wps_show(void)
299#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 282#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
300 show_remote_wps_backdrop(); 283 show_remote_wps_backdrop();
301#endif 284#endif
302#ifdef HAVE_LCD_BITMAP
303 FOR_NB_SCREENS(i)
304 {
305 gui_wps_set_margin(&gui_wps[i]);
306 }
307#endif
308 restore = true; 285 restore = true;
309 break; 286 break;
310 287
@@ -558,12 +535,6 @@ long gui_wps_show(void)
558#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 535#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
559 show_remote_wps_backdrop(); 536 show_remote_wps_backdrop();
560#endif 537#endif
561#ifdef HAVE_LCD_BITMAP
562 FOR_NB_SCREENS(i)
563 {
564 gui_wps_set_margin(&gui_wps[i]);
565 }
566#endif
567 restore = true; 538 restore = true;
568 break; 539 break;
569#endif /* HAVE_QUICKSCREEN */ 540#endif /* HAVE_QUICKSCREEN */
@@ -579,12 +550,6 @@ long gui_wps_show(void)
579#endif 550#endif
580 if (quick_screen_f3(BUTTON_F3)) 551 if (quick_screen_f3(BUTTON_F3))
581 return SYS_USB_CONNECTED; 552 return SYS_USB_CONNECTED;
582#ifdef HAVE_LCD_BITMAP
583 FOR_NB_SCREENS(i)
584 {
585 gui_wps_set_margin(&gui_wps[i]);
586 }
587#endif
588 restore = true; 553 restore = true;
589 break; 554 break;
590#endif /* BUTTON_F3 */ 555#endif /* BUTTON_F3 */
@@ -643,12 +608,6 @@ long gui_wps_show(void)
643#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 608#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
644 show_remote_wps_backdrop(); 609 show_remote_wps_backdrop();
645#endif 610#endif
646#ifdef HAVE_LCD_BITMAP
647 FOR_NB_SCREENS(i)
648 {
649 gui_wps_set_margin(&gui_wps[i]);
650 }
651#endif
652 restore = true; 611 restore = true;
653 break; 612 break;
654 613
@@ -812,7 +771,32 @@ void gui_sync_wps_screen_init(void)
812 FOR_NB_SCREENS(i) 771 FOR_NB_SCREENS(i)
813 gui_wps_set_disp(&gui_wps[i], &screens[i]); 772 gui_wps_set_disp(&gui_wps[i], &screens[i]);
814} 773}
774#ifdef HAVE_LCD_BITMAP
775static void statusbar_toggle_handler(void *data)
776{
777 (void)data;
778 int i;
779 bool draw = global_settings.statusbar;
815 780
781 FOR_NB_SCREENS(i)
782 {
783 struct wps_viewport *vp = &gui_wps[i].data->viewports[0];
784 if (gui_wps[i].data->wps_sb_tag)
785 draw = gui_wps[i].data->show_sb_on_wps;
786 if (!global_settings.statusbar && !draw)
787 {
788 vp->vp.y = 0;
789 vp->vp.height = screens[i].height;
790 }
791 else
792 {
793 vp->vp.y = STATUSBAR_HEIGHT;
794 vp->vp.height = screens[i].height - STATUSBAR_HEIGHT;
795 }
796 }
797}
798#endif
799
816void gui_sync_wps_init(void) 800void gui_sync_wps_init(void)
817{ 801{
818 int i; 802 int i;
@@ -826,6 +810,9 @@ void gui_sync_wps_init(void)
826 gui_wps_set_data(&gui_wps[i], &wps_datas[i]); 810 gui_wps_set_data(&gui_wps[i], &wps_datas[i]);
827 gui_wps_set_statusbar(&gui_wps[i], &statusbars.statusbars[i]); 811 gui_wps_set_statusbar(&gui_wps[i], &statusbars.statusbars[i]);
828 } 812 }
813#ifdef HAVE_LCD_BITMAP
814 add_event(STATUSBAR_TOGGLE_EVENT, false, statusbar_toggle_handler);
815#endif
829#if LCD_DEPTH > 1 816#if LCD_DEPTH > 1
830 unload_wps_backdrop(); 817 unload_wps_backdrop();
831#endif 818#endif
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h
index 25cfc08505..ad0c4a53c4 100644
--- a/apps/gui/gwps.h
+++ b/apps/gui/gwps.h
@@ -136,7 +136,6 @@ enum wps_token_type {
136 WPS_TOKEN_ALIGN_LEFT, 136 WPS_TOKEN_ALIGN_LEFT,
137 WPS_TOKEN_ALIGN_CENTER, 137 WPS_TOKEN_ALIGN_CENTER,
138 WPS_TOKEN_ALIGN_RIGHT, 138 WPS_TOKEN_ALIGN_RIGHT,
139 WPS_TOKEN_LEFTMARGIN,
140 139
141 /* Sublines */ 140 /* Sublines */
142 WPS_TOKEN_SUBLINE_TIMEOUT, 141 WPS_TOKEN_SUBLINE_TIMEOUT,
diff --git a/apps/gui/icon.c b/apps/gui/icon.c
index 968d83548f..c8ac48de92 100644
--- a/apps/gui/icon.c
+++ b/apps/gui/icon.c
@@ -103,7 +103,7 @@ void screen_put_icon_with_offset(struct screen * display,
103 int screen = display->screen_type; 103 int screen = display->screen_type;
104 display->getstringsize((unsigned char *)"M", &width, &height); 104 display->getstringsize((unsigned char *)"M", &width, &height);
105 xpos = x*ICON_WIDTH(screen) + off_x; 105 xpos = x*ICON_WIDTH(screen) + off_x;
106 ypos = y*height + display->getymargin() + off_y; 106 ypos = y*height + off_y;
107 107
108 if ( height > ICON_HEIGHT(screen) )/* center the cursor */ 108 if ( height > ICON_HEIGHT(screen) )/* center the cursor */
109 ypos += (height - ICON_HEIGHT(screen)) / 2; 109 ypos += (height - ICON_HEIGHT(screen)) / 2;
diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h
index 989d1cbe3c..57be2b1873 100644
--- a/apps/gui/statusbar.h
+++ b/apps/gui/statusbar.h
@@ -22,11 +22,16 @@
22 22
23#include "status.h" 23#include "status.h"
24#include "screen_access.h" 24#include "screen_access.h"
25#include "events.h"
25 26
26#define STATUSBAR_X_POS 0 27#define STATUSBAR_X_POS 0
27#define STATUSBAR_Y_POS 0 /* MUST be a multiple of 8 */ 28#define STATUSBAR_Y_POS 0 /* MUST be a multiple of 8 */
28#define STATUSBAR_HEIGHT 8 29#define STATUSBAR_HEIGHT 8
29 30
31/* possibly a horrible misuse of the event system.
32 This is triggered when the statusbar setting changes */
33#define STATUSBAR_TOGGLE_EVENT (EVENT_CLASS_GUI|1)
34
30struct status_info { 35struct status_info {
31 int battlevel; 36 int battlevel;
32 int batt_charge_step; 37 int batt_charge_step;
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index fbf520eed7..8f9998b2d6 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -45,8 +45,6 @@ int viewport_get_nb_lines(struct viewport *vp)
45 45
46void viewport_set_defaults(struct viewport *vp, enum screen_type screen) 46void viewport_set_defaults(struct viewport *vp, enum screen_type screen)
47{ 47{
48 vp->xmargin = 0;
49 vp->ymargin = 0;
50 vp->x = 0; 48 vp->x = 0;
51 vp->width = screens[screen].width; 49 vp->width = screens[screen].width;
52 50
diff --git a/apps/gui/wps_debug.c b/apps/gui/wps_debug.c
index 4fa12167f2..f5ac27ade3 100644
--- a/apps/gui/wps_debug.c
+++ b/apps/gui/wps_debug.c
@@ -79,11 +79,6 @@ static char *get_token_desc(struct wps_token *token, struct wps_data *data,
79 case WPS_TOKEN_ALIGN_RIGHT: 79 case WPS_TOKEN_ALIGN_RIGHT:
80 snprintf(buf, bufsize, "align right"); 80 snprintf(buf, bufsize, "align right");
81 break; 81 break;
82
83 case WPS_TOKEN_LEFTMARGIN:
84 snprintf(buf, bufsize, "left margin, value: %d",
85 token->value.i);
86 break;
87#endif 82#endif
88 83
89 case WPS_TOKEN_SUBLINE_TIMEOUT: 84 case WPS_TOKEN_SUBLINE_TIMEOUT:
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c
index c6b0d447e9..805379152f 100644
--- a/apps/gui/wps_parser.c
+++ b/apps/gui/wps_parser.c
@@ -133,8 +133,6 @@ static int parse_viewport_display(const char *wps_bufptr,
133 struct wps_token *token, struct wps_data *wps_data); 133 struct wps_token *token, struct wps_data *wps_data);
134static int parse_viewport(const char *wps_bufptr, 134static int parse_viewport(const char *wps_bufptr,
135 struct wps_token *token, struct wps_data *wps_data); 135 struct wps_token *token, struct wps_data *wps_data);
136static int parse_leftmargin(const char *wps_bufptr,
137 struct wps_token *token, struct wps_data *wps_data);
138static int parse_statusbar_enable(const char *wps_bufptr, 136static int parse_statusbar_enable(const char *wps_bufptr,
139 struct wps_token *token, struct wps_data *wps_data); 137 struct wps_token *token, struct wps_data *wps_data);
140static int parse_statusbar_disable(const char *wps_bufptr, 138static int parse_statusbar_disable(const char *wps_bufptr,
@@ -273,10 +271,6 @@ static const struct wps_tag all_tags[] = {
273 { WPS_TOKEN_PLAYBACK_STATUS, "mp", WPS_REFRESH_DYNAMIC, NULL }, 271 { WPS_TOKEN_PLAYBACK_STATUS, "mp", WPS_REFRESH_DYNAMIC, NULL },
274 272
275#ifdef HAVE_LCD_BITMAP 273#ifdef HAVE_LCD_BITMAP
276 { WPS_TOKEN_LEFTMARGIN, "m", 0, parse_leftmargin },
277#endif
278
279#ifdef HAVE_LCD_BITMAP
280 { WPS_TOKEN_PEAKMETER, "pm", WPS_REFRESH_PEAK_METER, NULL }, 274 { WPS_TOKEN_PEAKMETER, "pm", WPS_REFRESH_PEAK_METER, NULL },
281#else 275#else
282 { WPS_TOKEN_PLAYER_PROGRESSBAR, "pf", 276 { WPS_TOKEN_PLAYER_PROGRESSBAR, "pf",
@@ -368,6 +362,11 @@ static int parse_statusbar_enable(const char *wps_bufptr,
368 (void)token; /* Kill warnings */ 362 (void)token; /* Kill warnings */
369 wps_data->wps_sb_tag = true; 363 wps_data->wps_sb_tag = true;
370 wps_data->show_sb_on_wps = true; 364 wps_data->show_sb_on_wps = true;
365 if (wps_data->viewports[0].vp.y == 0)
366 {
367 wps_data->viewports[0].vp.y = STATUSBAR_HEIGHT;
368 wps_data->viewports[0].vp.height -= STATUSBAR_HEIGHT;
369 }
371 return skip_end_of_line(wps_bufptr); 370 return skip_end_of_line(wps_bufptr);
372} 371}
373 372
@@ -378,6 +377,11 @@ static int parse_statusbar_disable(const char *wps_bufptr,
378 (void)token; /* Kill warnings */ 377 (void)token; /* Kill warnings */
379 wps_data->wps_sb_tag = true; 378 wps_data->wps_sb_tag = true;
380 wps_data->show_sb_on_wps = false; 379 wps_data->show_sb_on_wps = false;
380 if (wps_data->viewports[0].vp.y == STATUSBAR_HEIGHT)
381 {
382 wps_data->viewports[0].vp.y = 0;
383 wps_data->viewports[0].vp.height += STATUSBAR_HEIGHT;
384 }
381 return skip_end_of_line(wps_bufptr); 385 return skip_end_of_line(wps_bufptr);
382} 386}
383 387
@@ -616,8 +620,6 @@ static int parse_viewport(const char *wps_bufptr,
616 620
617 /* Set the defaults for fields not user-specified */ 621 /* Set the defaults for fields not user-specified */
618 vp->drawmode = DRMODE_SOLID; 622 vp->drawmode = DRMODE_SOLID;
619 vp->xmargin = 0;
620 vp->ymargin = 0;
621 623
622 /* Work out the depth of this display */ 624 /* Work out the depth of this display */
623#ifdef HAVE_REMOTE_LCD 625#ifdef HAVE_REMOTE_LCD
@@ -818,16 +820,6 @@ static int parse_progressbar(const char *wps_bufptr,
818 int line_y_pos = font_height*(wps_data->num_lines - 820 int line_y_pos = font_height*(wps_data->num_lines -
819 wps_data->viewports[wps_data->num_viewports].first_line); 821 wps_data->viewports[wps_data->num_viewports].first_line);
820 822
821 /** Remove this bit when the remove lcd margins patch goes in **/
822 bool draw_sb = global_settings.statusbar;
823
824 if (wps_data->wps_sb_tag)
825 draw_sb = wps_data->show_sb_on_wps;
826
827 if (wps_data->num_viewports == 0 && draw_sb)
828 line_y_pos += STATUSBAR_HEIGHT;
829 /** Remove the above bit when the remove lcd margins patch goes in **/
830
831 if (wps_data->progressbar_count +1 >= MAX_PROGRESSBARS) 823 if (wps_data->progressbar_count +1 >= MAX_PROGRESSBARS)
832 return WPS_ERROR_INVALID_PARAM; 824 return WPS_ERROR_INVALID_PARAM;
833 825
@@ -1106,33 +1098,6 @@ static int parse_albumart_conditional(const char *wps_bufptr,
1106}; 1098};
1107#endif /* HAVE_ALBUMART */ 1099#endif /* HAVE_ALBUMART */
1108 1100
1109#ifdef HAVE_LCD_BITMAP
1110static int parse_leftmargin(const char *wps_bufptr, struct wps_token *token,
1111 struct wps_data *wps_data)
1112{
1113 const char* p;
1114 const char* pend;
1115 const char *newline;
1116
1117 (void)wps_data; /* Kill the warning */
1118
1119 /* valid tag looks like %m|12| */
1120 if(*wps_bufptr == '|')
1121 {
1122 p = wps_bufptr + 1;
1123 newline = strchr(wps_bufptr, '\n');
1124 if(isdigit(*p) && (pend = strchr(p, '|')) && pend < newline)
1125 {
1126 token->value.i = atoi(p);
1127 return pend - wps_bufptr + 1;
1128 }
1129 }
1130
1131 /* invalid tag syntax */
1132 return WPS_ERROR_INVALID_PARAM;
1133}
1134#endif
1135
1136 1101
1137/* Parse a generic token from the given string. Return the length read */ 1102/* Parse a generic token from the given string. Return the length read */
1138static int parse_token(const char *wps_bufptr, struct wps_data *wps_data) 1103static int parse_token(const char *wps_bufptr, struct wps_data *wps_data)
@@ -1583,15 +1548,21 @@ bool wps_data_load(struct wps_data *wps_data,
1583 1548
1584 /* Initialise the first (default) viewport */ 1549 /* Initialise the first (default) viewport */
1585 wps_data->viewports[0].vp.x = 0; 1550 wps_data->viewports[0].vp.x = 0;
1586 wps_data->viewports[0].vp.y = 0;
1587 wps_data->viewports[0].vp.width = display->width; 1551 wps_data->viewports[0].vp.width = display->width;
1588 wps_data->viewports[0].vp.height = display->height; 1552 if (!global_settings.statusbar)
1553 {
1554 wps_data->viewports[0].vp.y = 0;
1555 wps_data->viewports[0].vp.height = display->height;
1556 }
1557 else
1558 {
1559 wps_data->viewports[0].vp.y = STATUSBAR_HEIGHT;
1560 wps_data->viewports[0].vp.height = display->height - STATUSBAR_HEIGHT;
1561 }
1589#ifdef HAVE_LCD_BITMAP 1562#ifdef HAVE_LCD_BITMAP
1590 wps_data->viewports[0].vp.font = FONT_UI; 1563 wps_data->viewports[0].vp.font = FONT_UI;
1591 wps_data->viewports[0].vp.drawmode = DRMODE_SOLID; 1564 wps_data->viewports[0].vp.drawmode = DRMODE_SOLID;
1592#endif 1565#endif
1593 wps_data->viewports[0].vp.xmargin = display->getxmargin();
1594 wps_data->viewports[0].vp.ymargin = display->getymargin();
1595#if LCD_DEPTH > 1 1566#if LCD_DEPTH > 1
1596 if (display->depth > 1) 1567 if (display->depth > 1)
1597 { 1568 {