diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gui/gwps-common.c | 45 | ||||
-rw-r--r-- | apps/gui/gwps.h | 1 | ||||
-rw-r--r-- | apps/gui/wps_parser.c | 35 |
3 files changed, 67 insertions, 14 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 00505afbed..f1486461c9 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c | |||
@@ -1352,6 +1352,13 @@ static char *get_token_value(struct gui_wps *gwps, | |||
1352 | return NULL; | 1352 | return NULL; |
1353 | #endif | 1353 | #endif |
1354 | 1354 | ||
1355 | #ifdef HAVE_LCD_BITMAP | ||
1356 | case WPS_TOKEN_ALIGN_SCROLLMARGIN: | ||
1357 | gwps->display->setmargins(token->value.i, | ||
1358 | gwps->display->getymargin()); | ||
1359 | return NULL; | ||
1360 | #endif | ||
1361 | |||
1355 | default: | 1362 | default: |
1356 | return NULL; | 1363 | return NULL; |
1357 | } | 1364 | } |
@@ -1454,6 +1461,11 @@ static bool get_line(struct gui_wps *gwps, | |||
1454 | align->center = NULL; | 1461 | align->center = NULL; |
1455 | align->right = NULL; | 1462 | align->right = NULL; |
1456 | 1463 | ||
1464 | #ifdef HAVE_LCD_BITMAP | ||
1465 | /* Reset margins - only bitmap targets modify them */ | ||
1466 | gwps->display->setmargins(0, gwps->display->getymargin()); | ||
1467 | #endif | ||
1468 | |||
1457 | /* Process all tokens of the desired subline */ | 1469 | /* Process all tokens of the desired subline */ |
1458 | last_token_idx = wps_last_token_index(data, line, subline); | 1470 | last_token_idx = wps_last_token_index(data, line, subline); |
1459 | for (i = wps_first_token_index(data, line, subline); | 1471 | for (i = wps_first_token_index(data, line, subline); |
@@ -1677,12 +1689,13 @@ static void write_line(struct screen *display, | |||
1677 | bool scroll) | 1689 | bool scroll) |
1678 | { | 1690 | { |
1679 | 1691 | ||
1680 | int left_width = 0; /* left_xpos would always be 0 */ | 1692 | int left_width = 0, left_xpos; |
1681 | int center_width = 0, center_xpos; | 1693 | int center_width = 0, center_xpos; |
1682 | int right_width = 0, right_xpos; | 1694 | int right_width = 0, right_xpos; |
1683 | int ypos; | 1695 | int ypos; |
1684 | int space_width; | 1696 | int space_width; |
1685 | int string_height; | 1697 | int string_height; |
1698 | int scroll_width; | ||
1686 | 1699 | ||
1687 | /* calculate different string sizes and positions */ | 1700 | /* calculate different string sizes and positions */ |
1688 | display->getstringsize((unsigned char *)" ", &space_width, &string_height); | 1701 | display->getstringsize((unsigned char *)" ", &space_width, &string_height); |
@@ -1691,19 +1704,21 @@ static void write_line(struct screen *display, | |||
1691 | &left_width, &string_height); | 1704 | &left_width, &string_height); |
1692 | } | 1705 | } |
1693 | 1706 | ||
1694 | if (format_align->center != 0) { | ||
1695 | display->getstringsize((unsigned char *)format_align->center, | ||
1696 | ¢er_width, &string_height); | ||
1697 | } | ||
1698 | |||
1699 | center_xpos=(display->width - center_width) / 2; | ||
1700 | |||
1701 | if (format_align->right != 0) { | 1707 | if (format_align->right != 0) { |
1702 | display->getstringsize((unsigned char *)format_align->right, | 1708 | display->getstringsize((unsigned char *)format_align->right, |
1703 | &right_width, &string_height); | 1709 | &right_width, &string_height); |
1704 | } | 1710 | } |
1705 | 1711 | ||
1712 | if (format_align->center != 0) { | ||
1713 | display->getstringsize((unsigned char *)format_align->center, | ||
1714 | ¢er_width, &string_height); | ||
1715 | } | ||
1716 | |||
1717 | left_xpos = display->getxmargin(); | ||
1706 | right_xpos = (display->width - right_width); | 1718 | right_xpos = (display->width - right_width); |
1719 | center_xpos = (display->width + left_xpos - center_width) / 2; | ||
1720 | |||
1721 | scroll_width = display->width - left_xpos; | ||
1707 | 1722 | ||
1708 | /* Checks for overlapping strings. | 1723 | /* Checks for overlapping strings. |
1709 | If needed the overlapping strings will be merged, separated by a | 1724 | If needed the overlapping strings will be merged, separated by a |
@@ -1712,7 +1727,7 @@ static void write_line(struct screen *display, | |||
1712 | /* CASE 1: left and centered string overlap */ | 1727 | /* CASE 1: left and centered string overlap */ |
1713 | /* there is a left string, need to merge left and center */ | 1728 | /* there is a left string, need to merge left and center */ |
1714 | if ((left_width != 0 && center_width != 0) && | 1729 | if ((left_width != 0 && center_width != 0) && |
1715 | (left_width + space_width > center_xpos)) { | 1730 | (left_xpos + left_width + space_width > center_xpos)) { |
1716 | /* replace the former separator '\0' of left and | 1731 | /* replace the former separator '\0' of left and |
1717 | center string with a space */ | 1732 | center string with a space */ |
1718 | *(--format_align->center) = ' '; | 1733 | *(--format_align->center) = ' '; |
@@ -1723,7 +1738,7 @@ static void write_line(struct screen *display, | |||
1723 | } | 1738 | } |
1724 | /* there is no left string, move center to left */ | 1739 | /* there is no left string, move center to left */ |
1725 | if ((left_width == 0 && center_width != 0) && | 1740 | if ((left_width == 0 && center_width != 0) && |
1726 | (left_width > center_xpos)) { | 1741 | (left_xpos + left_width > center_xpos)) { |
1727 | /* move the center string to the left string */ | 1742 | /* move the center string to the left string */ |
1728 | format_align->left = format_align->center; | 1743 | format_align->left = format_align->center; |
1729 | /* calculate the new width and position of the string */ | 1744 | /* calculate the new width and position of the string */ |
@@ -1764,7 +1779,7 @@ static void write_line(struct screen *display, | |||
1764 | was one or it has been merged in case 1 or 2 */ | 1779 | was one or it has been merged in case 1 or 2 */ |
1765 | /* there is a left string, need to merge left and right */ | 1780 | /* there is a left string, need to merge left and right */ |
1766 | if ((left_width != 0 && center_width == 0 && right_width != 0) && | 1781 | if ((left_width != 0 && center_width == 0 && right_width != 0) && |
1767 | (left_width + space_width > right_xpos)) { | 1782 | (left_xpos + left_width + space_width > right_xpos)) { |
1768 | /* replace the former separator '\0' of left and | 1783 | /* replace the former separator '\0' of left and |
1769 | right string with a space */ | 1784 | right string with a space */ |
1770 | *(--format_align->right) = ' '; | 1785 | *(--format_align->right) = ' '; |
@@ -1787,7 +1802,9 @@ static void write_line(struct screen *display, | |||
1787 | ypos = (line * string_height) + display->getymargin(); | 1802 | ypos = (line * string_height) + display->getymargin(); |
1788 | 1803 | ||
1789 | 1804 | ||
1790 | if (scroll && left_width > display->width) | 1805 | if (scroll && ((left_width > scroll_width) || |
1806 | (center_width > scroll_width) || | ||
1807 | (right_width > scroll_width))) | ||
1791 | { | 1808 | { |
1792 | display->puts_scroll(0, line, | 1809 | display->puts_scroll(0, line, |
1793 | (unsigned char *)format_align->left); | 1810 | (unsigned char *)format_align->left); |
@@ -1797,7 +1814,7 @@ static void write_line(struct screen *display, | |||
1797 | #ifdef HAVE_LCD_BITMAP | 1814 | #ifdef HAVE_LCD_BITMAP |
1798 | /* clear the line first */ | 1815 | /* clear the line first */ |
1799 | display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 1816 | display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
1800 | display->fillrect(0, ypos, display->width, string_height); | 1817 | display->fillrect(left_xpos, ypos, display->width, string_height); |
1801 | display->set_drawmode(DRMODE_SOLID); | 1818 | display->set_drawmode(DRMODE_SOLID); |
1802 | #endif | 1819 | #endif |
1803 | 1820 | ||
@@ -1808,7 +1825,7 @@ static void write_line(struct screen *display, | |||
1808 | /* print aligned strings */ | 1825 | /* print aligned strings */ |
1809 | if (left_width != 0) | 1826 | if (left_width != 0) |
1810 | { | 1827 | { |
1811 | display->putsxy(0, ypos, | 1828 | display->putsxy(left_xpos, ypos, |
1812 | (unsigned char *)format_align->left); | 1829 | (unsigned char *)format_align->left); |
1813 | } | 1830 | } |
1814 | if (center_width != 0) | 1831 | if (center_width != 0) |
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h index f57656b0ae..94c2836e4e 100644 --- a/apps/gui/gwps.h +++ b/apps/gui/gwps.h | |||
@@ -124,6 +124,7 @@ enum wps_token_type { | |||
124 | WPS_TOKEN_ALIGN_LEFT, | 124 | WPS_TOKEN_ALIGN_LEFT, |
125 | WPS_TOKEN_ALIGN_CENTER, | 125 | WPS_TOKEN_ALIGN_CENTER, |
126 | WPS_TOKEN_ALIGN_RIGHT, | 126 | WPS_TOKEN_ALIGN_RIGHT, |
127 | WPS_TOKEN_ALIGN_SCROLLMARGIN, | ||
127 | 128 | ||
128 | /* Sublines */ | 129 | /* Sublines */ |
129 | WPS_TOKEN_SUBLINE_TIMEOUT, | 130 | WPS_TOKEN_SUBLINE_TIMEOUT, |
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 84e1b185dc..0d86a5a3a2 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c | |||
@@ -115,6 +115,8 @@ static int parse_dir_level(const char *wps_bufptr, | |||
115 | struct wps_token *token, struct wps_data *wps_data); | 115 | struct wps_token *token, struct wps_data *wps_data); |
116 | 116 | ||
117 | #ifdef HAVE_LCD_BITMAP | 117 | #ifdef HAVE_LCD_BITMAP |
118 | static int parse_scrollmargin(const char *wps_bufptr, | ||
119 | struct wps_token *token, struct wps_data *wps_data); | ||
118 | static int parse_image_special(const char *wps_bufptr, | 120 | static int parse_image_special(const char *wps_bufptr, |
119 | struct wps_token *token, struct wps_data *wps_data); | 121 | struct wps_token *token, struct wps_data *wps_data); |
120 | static int parse_statusbar_enable(const char *wps_bufptr, | 122 | static int parse_statusbar_enable(const char *wps_bufptr, |
@@ -277,7 +279,12 @@ static const struct wps_tag all_tags[] = { | |||
277 | { WPS_TOKEN_CROSSFADE, "xf", WPS_REFRESH_DYNAMIC, NULL }, | 279 | { WPS_TOKEN_CROSSFADE, "xf", WPS_REFRESH_DYNAMIC, NULL }, |
278 | #endif | 280 | #endif |
279 | 281 | ||
282 | #ifdef HAVE_LCD_BITMAP | ||
283 | { WPS_TOKEN_ALIGN_SCROLLMARGIN, "s", WPS_REFRESH_SCROLL, | ||
284 | parse_scrollmargin }, | ||
285 | #else | ||
280 | { WPS_NO_TOKEN, "s", WPS_REFRESH_SCROLL, NULL }, | 286 | { WPS_NO_TOKEN, "s", WPS_REFRESH_SCROLL, NULL }, |
287 | #endif | ||
281 | { WPS_TOKEN_SUBLINE_TIMEOUT, "t", 0, parse_subline_timeout }, | 288 | { WPS_TOKEN_SUBLINE_TIMEOUT, "t", 0, parse_subline_timeout }, |
282 | 289 | ||
283 | #ifdef HAVE_LCD_BITMAP | 290 | #ifdef HAVE_LCD_BITMAP |
@@ -832,6 +839,34 @@ static int parse_albumart_conditional(const char *wps_bufptr, | |||
832 | }; | 839 | }; |
833 | #endif /* HAVE_ALBUMART */ | 840 | #endif /* HAVE_ALBUMART */ |
834 | 841 | ||
842 | #ifdef HAVE_LCD_BITMAP | ||
843 | static int parse_scrollmargin(const char *wps_bufptr, struct wps_token *token, | ||
844 | struct wps_data *wps_data) | ||
845 | { | ||
846 | const char* p; | ||
847 | const char* pend; | ||
848 | |||
849 | (void)wps_data; /* Kill the warning */ | ||
850 | |||
851 | /* valid tag looks like %s or %s|12| */ | ||
852 | if(*wps_bufptr == '|') | ||
853 | { | ||
854 | p = wps_bufptr + 1; | ||
855 | |||
856 | if(isdigit(*p) && (pend = strchr(p, '|'))) | ||
857 | { | ||
858 | token->value.i = atoi(p); | ||
859 | return(pend - wps_bufptr + 1); | ||
860 | } | ||
861 | } else { | ||
862 | token->value.i = 0; | ||
863 | } | ||
864 | |||
865 | return(0); | ||
866 | } | ||
867 | #endif | ||
868 | |||
869 | |||
835 | /* Parse a generic token from the given string. Return the length read */ | 870 | /* Parse a generic token from the given string. Return the length read */ |
836 | static int parse_token(const char *wps_bufptr, struct wps_data *wps_data) | 871 | static int parse_token(const char *wps_bufptr, struct wps_data *wps_data) |
837 | { | 872 | { |