mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
Get rid of some of the code duplication from checkwps, it still duplicates a lot though.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22695 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
541dd6fda5
commit
c0f1c49178
6 changed files with 83 additions and 192 deletions
|
@ -24,18 +24,10 @@
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "lcd-remote.h"
|
#include "lcd-remote.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "sprintf.h"
|
|
||||||
#include "string.h"
|
|
||||||
#include "settings.h"
|
|
||||||
#include "kernel.h"
|
|
||||||
#include "system.h"
|
|
||||||
#include "misc.h"
|
|
||||||
#include "viewport.h"
|
#include "viewport.h"
|
||||||
#include "statusbar.h"
|
|
||||||
#include "screen_access.h"
|
#include "screen_access.h"
|
||||||
#include "appevents.h"
|
#include "settings.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
|
||||||
/*some short cuts for fg/bg/line selector handling */
|
/*some short cuts for fg/bg/line selector handling */
|
||||||
#ifdef HAVE_LCD_COLOR
|
#ifdef HAVE_LCD_COLOR
|
||||||
|
@ -54,6 +46,17 @@
|
||||||
#define BG_FALLBACK LCD_DEFAULT_BG
|
#define BG_FALLBACK LCD_DEFAULT_BG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* all below isn't needed for pc tools (i.e. checkwps/wps editor)
|
||||||
|
* only viewport_parse_viewport() is */
|
||||||
|
#ifndef __PCTOOL__
|
||||||
|
#include "sprintf.h"
|
||||||
|
#include "string.h"
|
||||||
|
#include "kernel.h"
|
||||||
|
#include "system.h"
|
||||||
|
#include "statusbar.h"
|
||||||
|
#include "appevents.h"
|
||||||
|
|
||||||
|
|
||||||
static int statusbar_enabled = 0;
|
static int statusbar_enabled = 0;
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
@ -295,12 +298,55 @@ bool viewport_ui_vp_get_state(enum screen_type screen)
|
||||||
return ui_vp_info.active[screen];
|
return ui_vp_info.active[screen];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (re)parse the UI vp from the settings
|
||||||
|
* - Returns
|
||||||
|
* 0 if no UI vp is used at all
|
||||||
|
* else the bit for the screen (1<<screen) is set
|
||||||
|
*/
|
||||||
|
static unsigned viewport_init_ui_vp(void)
|
||||||
|
{
|
||||||
|
int screen;
|
||||||
|
unsigned ret = 0;
|
||||||
|
char *setting;
|
||||||
|
FOR_NB_SCREENS(screen)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_REMOTE_LCD
|
||||||
|
if ((screen == SCREEN_REMOTE))
|
||||||
|
setting = global_settings.remote_ui_vp_config;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
setting = global_settings.ui_vp_config;
|
||||||
|
|
||||||
|
|
||||||
|
if (!(viewport_parse_viewport(&custom_vp[screen], screen,
|
||||||
|
setting, ',')))
|
||||||
|
viewport_set_fullscreen(&custom_vp[screen], screen);
|
||||||
|
else
|
||||||
|
ret |= BIT_N(screen);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_TOUCHSCREEN
|
||||||
|
/* check if a point (x and y coordinates) are within a viewport */
|
||||||
|
bool viewport_point_within_vp(const struct viewport *vp, int x, int y)
|
||||||
|
{
|
||||||
|
bool is_x = (x >= vp->x && x < (vp->x + vp->width));
|
||||||
|
bool is_y = (y >= vp->y && y < (vp->y + vp->height));
|
||||||
|
return (is_x && is_y);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_TOUCHSCREEN */
|
||||||
|
#endif /* HAVE_LCD_BITMAP */
|
||||||
|
#endif /* __PCTOOL__ */
|
||||||
|
|
||||||
#ifdef HAVE_LCD_COLOR
|
#ifdef HAVE_LCD_COLOR
|
||||||
#define ARG_STRING(_depth) ((_depth) == 2 ? "dddddgg":"dddddcc")
|
#define ARG_STRING(_depth) ((_depth) == 2 ? "dddddgg":"dddddcc")
|
||||||
#else
|
#else
|
||||||
#define ARG_STRING(_depth) "dddddgg"
|
#define ARG_STRING(_depth) "dddddgg"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
const char* viewport_parse_viewport(struct viewport *vp,
|
const char* viewport_parse_viewport(struct viewport *vp,
|
||||||
enum screen_type screen,
|
enum screen_type screen,
|
||||||
const char *bufptr,
|
const char *bufptr,
|
||||||
|
@ -386,44 +432,4 @@ const char* viewport_parse_viewport(struct viewport *vp,
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (re)parse the UI vp from the settings
|
|
||||||
* - Returns
|
|
||||||
* 0 if no UI vp is used at all
|
|
||||||
* else the bit for the screen (1<<screen) is set
|
|
||||||
*/
|
|
||||||
static unsigned viewport_init_ui_vp(void)
|
|
||||||
{
|
|
||||||
int screen;
|
|
||||||
unsigned ret = 0;
|
|
||||||
char *setting;
|
|
||||||
FOR_NB_SCREENS(screen)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_REMOTE_LCD
|
|
||||||
if ((screen == SCREEN_REMOTE))
|
|
||||||
setting = global_settings.remote_ui_vp_config;
|
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
setting = global_settings.ui_vp_config;
|
|
||||||
|
|
||||||
|
|
||||||
if (!(viewport_parse_viewport(&custom_vp[screen], screen,
|
|
||||||
setting, ',')))
|
|
||||||
viewport_set_fullscreen(&custom_vp[screen], screen);
|
|
||||||
else
|
|
||||||
ret |= BIT_N(screen);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_TOUCHSCREEN
|
|
||||||
/* check if a point (x and y coordinates) are within a viewport */
|
|
||||||
bool viewport_point_within_vp(const struct viewport *vp, int x, int y)
|
|
||||||
{
|
|
||||||
bool is_x = (x >= vp->x && x < (vp->x + vp->width));
|
|
||||||
bool is_y = (y >= vp->y && y < (vp->y + vp->height));
|
|
||||||
return (is_x && is_y);
|
|
||||||
}
|
|
||||||
#endif /* HAVE_TOUCHSCREEN */
|
|
||||||
#endif /* HAVE_LCD_BITMAP */
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ void viewport_set_defaults(struct viewport *vp, enum screen_type screen);
|
||||||
#define VP_SB_IGNORE_SETTING(screen) BIT_N(4+screen)
|
#define VP_SB_IGNORE_SETTING(screen) BIT_N(4+screen)
|
||||||
#define VP_SB_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1))
|
#define VP_SB_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1))
|
||||||
|
|
||||||
|
#ifndef __PCTOOL__
|
||||||
/*
|
/*
|
||||||
* Initialize the viewportmanager, which in turns initializes the UI vp and
|
* Initialize the viewportmanager, which in turns initializes the UI vp and
|
||||||
* statusbar stuff
|
* statusbar stuff
|
||||||
|
@ -85,25 +86,6 @@ void viewport_set_fullscreen(struct viewport *vp, enum screen_type screen);
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
|
||||||
/*
|
|
||||||
* Parse a viewport definition (vp_def), which looks like:
|
|
||||||
*
|
|
||||||
* Screens with depth > 1:
|
|
||||||
* X|Y|width|height|font|foregorund color|background color
|
|
||||||
* Screens with depth = 1:
|
|
||||||
* X|Y|width|height|font
|
|
||||||
*
|
|
||||||
* | is a separator and can be specified via the parameter
|
|
||||||
*
|
|
||||||
* Returns the pointer to the char after the last character parsed
|
|
||||||
* if everything went OK or NULL if an error happened (some values
|
|
||||||
* not specified in the definition)
|
|
||||||
*/
|
|
||||||
const char* viewport_parse_viewport(struct viewport *vp,
|
|
||||||
enum screen_type screen,
|
|
||||||
const char *vp_def,
|
|
||||||
const char separator);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns a pointer to the current viewport
|
* Returns a pointer to the current viewport
|
||||||
* - That could be the UI vp, or a viewport passed to do_menu() or the like
|
* - That could be the UI vp, or a viewport passed to do_menu() or the like
|
||||||
|
@ -129,4 +111,28 @@ bool viewport_point_within_vp(const struct viewport *vp, int x, int y);
|
||||||
#define viewport_set_current_vp(a)
|
#define viewport_set_current_vp(a)
|
||||||
#define viewport_get_current_vp() NULL
|
#define viewport_get_current_vp() NULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* __PCTOOL__ */
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parse a viewport definition (vp_def), which looks like:
|
||||||
|
*
|
||||||
|
* Screens with depth > 1:
|
||||||
|
* X|Y|width|height|font|foregorund color|background color
|
||||||
|
* Screens with depth = 1:
|
||||||
|
* X|Y|width|height|font
|
||||||
|
*
|
||||||
|
* | is a separator and can be specified via the parameter
|
||||||
|
*
|
||||||
|
* Returns the pointer to the char after the last character parsed
|
||||||
|
* if everything went OK or NULL if an error happened (some values
|
||||||
|
* not specified in the definition)
|
||||||
|
*/
|
||||||
|
const char* viewport_parse_viewport(struct viewport *vp,
|
||||||
|
enum screen_type screen,
|
||||||
|
const char *vp_def,
|
||||||
|
const char separator);
|
||||||
|
#endif /* HAVE_LCD_BITMAP */
|
||||||
#endif /* __VIEWPORT_H__ */
|
#endif /* __VIEWPORT_H__ */
|
||||||
|
|
|
@ -62,13 +62,11 @@
|
||||||
* must be available at system startup.
|
* must be available at system startup.
|
||||||
* Fonts are specified in firmware/font.c.
|
* Fonts are specified in firmware/font.c.
|
||||||
*/
|
*/
|
||||||
#ifndef __PCTOOL__
|
|
||||||
enum {
|
enum {
|
||||||
FONT_SYSFIXED, /* system fixed pitch font*/
|
FONT_SYSFIXED, /* system fixed pitch font*/
|
||||||
FONT_UI, /* system porportional font*/
|
FONT_UI, /* system porportional font*/
|
||||||
MAXFONTS
|
MAXFONTS
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* .fnt loadable font file format definition
|
* .fnt loadable font file format definition
|
||||||
|
|
|
@ -7,4 +7,5 @@ checkwps.c
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
../../apps/recorder/bmp.c
|
../../apps/recorder/bmp.c
|
||||||
|
../../apps/gui/viewport.c
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "wps.h"
|
#include "wps.h"
|
||||||
#include "wps_internals.h"
|
#include "wps_internals.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "viewport.h"
|
||||||
|
|
||||||
bool debug_wps = true;
|
bool debug_wps = true;
|
||||||
int wps_verbose_level = 0;
|
int wps_verbose_level = 0;
|
||||||
|
@ -294,125 +295,6 @@ struct skin_viewport* find_viewport(char label, struct wps_data *data)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* From viewport.c & misc.h */
|
|
||||||
#define LIST_VALUE_PARSED(setvals, position) ((setvals) & BIT_N(position))
|
|
||||||
|
|
||||||
/*some short cuts for fg/bg/line selector handling */
|
|
||||||
#ifdef HAVE_LCD_COLOR
|
|
||||||
#define LINE_SEL_FROM_SETTINGS(vp) \
|
|
||||||
do { \
|
|
||||||
vp->lss_pattern = global_settings.lss_color; \
|
|
||||||
vp->lse_pattern = global_settings.lse_color; \
|
|
||||||
vp->lst_pattern = global_settings.lst_color; \
|
|
||||||
} while (0)
|
|
||||||
#define FG_FALLBACK global_settings.fg_color
|
|
||||||
#define BG_FALLBACK global_settings.bg_color
|
|
||||||
#else
|
|
||||||
/* mono/greyscale doesn't have most of the above */
|
|
||||||
#define LINE_SEL_FROM_SETTINGS(vp)
|
|
||||||
#define FG_FALLBACK LCD_DEFAULT_FG
|
|
||||||
#define BG_FALLBACK LCD_DEFAULT_BG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_LCD_COLOR
|
|
||||||
#define ARG_STRING(_depth) ((_depth) == 2 ? "dddddgg":"dddddcc")
|
|
||||||
#else
|
|
||||||
#define ARG_STRING(_depth) "dddddgg"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern const char* parse_list(const char *fmt, uint32_t *set_vals,
|
|
||||||
const char sep, const char* str, ...);
|
|
||||||
|
|
||||||
const char* viewport_parse_viewport(struct viewport *vp,
|
|
||||||
enum screen_type screen,
|
|
||||||
const char *bufptr,
|
|
||||||
const char separator)
|
|
||||||
{
|
|
||||||
/* parse the list to the viewport struct */
|
|
||||||
const char *ptr = bufptr;
|
|
||||||
int depth;
|
|
||||||
uint32_t set = 0;
|
|
||||||
|
|
||||||
enum {
|
|
||||||
PL_X = 0,
|
|
||||||
PL_Y,
|
|
||||||
PL_WIDTH,
|
|
||||||
PL_HEIGHT,
|
|
||||||
PL_FONT,
|
|
||||||
PL_FG,
|
|
||||||
PL_BG,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Work out the depth of this display */
|
|
||||||
depth = screens[screen].depth;
|
|
||||||
#if (LCD_DEPTH == 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 1)
|
|
||||||
if (depth == 1)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
if (!(ptr = parse_list("ddddd", &set, separator, ptr,
|
|
||||||
&vp->x, &vp->y, &vp->width, &vp->height, &vp->font)))
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
|
|
||||||
if (depth >= 2)
|
|
||||||
{
|
|
||||||
if (!(ptr = parse_list(ARG_STRING(depth), &set, separator, ptr,
|
|
||||||
&vp->x, &vp->y, &vp->width, &vp->height, &vp->font,
|
|
||||||
&vp->fg_pattern,&vp->bg_pattern)))
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{}
|
|
||||||
#undef ARG_STRING
|
|
||||||
|
|
||||||
/* X and Y *must* be set */
|
|
||||||
if (!LIST_VALUE_PARSED(set, PL_X) || !LIST_VALUE_PARSED(set, PL_Y))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* fix defaults */
|
|
||||||
if (!LIST_VALUE_PARSED(set, PL_WIDTH))
|
|
||||||
vp->width = screens[screen].lcdwidth - vp->x;
|
|
||||||
if (!LIST_VALUE_PARSED(set, PL_HEIGHT))
|
|
||||||
vp->height = screens[screen].lcdheight - vp->y;
|
|
||||||
|
|
||||||
#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
|
|
||||||
if (!LIST_VALUE_PARSED(set, PL_FG))
|
|
||||||
vp->fg_pattern = FG_FALLBACK;
|
|
||||||
if (!LIST_VALUE_PARSED(set, PL_BG))
|
|
||||||
vp->bg_pattern = BG_FALLBACK;
|
|
||||||
#endif /* LCD_DEPTH > 1 || LCD_REMOTE_DEPTH > 1 */
|
|
||||||
|
|
||||||
LINE_SEL_FROM_SETTINGS(vp);
|
|
||||||
|
|
||||||
/* Validate the viewport dimensions - we know that the numbers are
|
|
||||||
non-negative integers, ignore bars and assume the viewport takes them
|
|
||||||
* into account */
|
|
||||||
if ((vp->x >= screens[screen].lcdwidth) ||
|
|
||||||
((vp->x + vp->width) > screens[screen].lcdwidth) ||
|
|
||||||
(vp->y >= screens[screen].lcdheight) ||
|
|
||||||
((vp->y + vp->height) > screens[screen].lcdheight))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
/* Default to using the user font if the font was an invalid number or '-'*/
|
|
||||||
if (((vp->font != FONT_SYSFIXED) && (vp->font != FONT_UI))
|
|
||||||
|| !LIST_VALUE_PARSED(set, PL_FONT)
|
|
||||||
)
|
|
||||||
vp->font = FONT_UI;
|
|
||||||
|
|
||||||
/* Set the defaults for fields not user-specified */
|
|
||||||
vp->drawmode = DRMODE_SOLID;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define FONT_SYSFIXED 0
|
|
||||||
#define FONT_UI 1
|
|
||||||
#define SYSFONT_HEIGHT 8
|
#define SYSFONT_HEIGHT 8
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue