1
0
Fork 0
forked from len0rd/rockbox

- Fix some reds by implementing lcd_get_dpi().

- Use the list item centering capabilities in the plugin lib
- Bump plugin ABI for the changed viewport struct (sort the API too).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30775 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2011-10-17 18:28:35 +00:00
parent 55f078f4b5
commit a13e9644b5
5 changed files with 49 additions and 67 deletions

View file

@ -518,6 +518,19 @@ static const struct plugin_api rockbox_api = {
utf8length, utf8length,
utf8seek, utf8seek,
/* the buflib memory management library */
buflib_init,
buflib_available,
buflib_alloc,
buflib_alloc_ex,
buflib_alloc_maximum,
buflib_buffer_in,
buflib_buffer_out,
buflib_free,
buflib_shrink,
buflib_get_data,
buflib_get_name,
/* sound */ /* sound */
sound_set, sound_set,
sound_default, sound_default,
@ -732,6 +745,8 @@ static const struct plugin_api rockbox_api = {
#endif #endif
show_logo, show_logo,
tree_get_context, tree_get_context,
tree_get_entries,
tree_get_entry_at,
set_current_file, set_current_file,
set_dirfilter, set_dirfilter,
@ -790,21 +805,6 @@ static const struct plugin_api rockbox_api = {
/* new stuff at the end, sort into place next time /* new stuff at the end, sort into place next time
the API gets incompatible */ the API gets incompatible */
tree_get_entries,
tree_get_entry_at,
/* the buflib memory management library */
buflib_init,
buflib_available,
buflib_alloc,
buflib_alloc_ex,
buflib_alloc_maximum,
buflib_buffer_in,
buflib_buffer_out,
buflib_free,
buflib_shrink,
buflib_get_data,
buflib_get_name,
}; };
int plugin_load(const char* plugin, const void* parameter) int plugin_load(const char* plugin, const void* parameter)

View file

@ -147,12 +147,12 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */ #define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */ /* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 212 #define PLUGIN_API_VERSION 213
/* update this to latest version if a change to the api struct breaks /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */ new function which are "waiting" at the end of the function table) */
#define PLUGIN_MIN_API_VERSION 210 #define PLUGIN_MIN_API_VERSION 213
/* plugin return codes */ /* plugin return codes */
/* internal returns start at 0x100 to make exit(1..255) work */ /* internal returns start at 0x100 to make exit(1..255) work */
@ -601,6 +601,22 @@ struct plugin_api {
unsigned long (*utf8length)(const unsigned char *utf8); unsigned long (*utf8length)(const unsigned char *utf8);
int (*utf8seek)(const unsigned char* utf8, int offset); int (*utf8seek)(const unsigned char* utf8, int offset);
/* the buflib memory management library */
void (*buflib_init)(struct buflib_context* ctx, void* buf, size_t size);
size_t (*buflib_available)(struct buflib_context* ctx);
int (*buflib_alloc)(struct buflib_context* ctx, size_t size);
int (*buflib_alloc_ex)(struct buflib_context* ctx, size_t size,
const char* name, struct buflib_callbacks *ops);
int (*buflib_alloc_maximum)(struct buflib_context* ctx, const char* name,
size_t* size, struct buflib_callbacks *ops);
void (*buflib_buffer_in)(struct buflib_context* ctx, int size);
void* (*buflib_buffer_out)(struct buflib_context* ctx, size_t* size);
int (*buflib_free)(struct buflib_context* ctx, int handle);
bool (*buflib_shrink)(struct buflib_context* ctx, int handle,
void* new_start, size_t new_size);
void* (*buflib_get_data)(struct buflib_context* ctx, int handle);
const char* (*buflib_get_name)(struct buflib_context* ctx, int handle);
/* sound */ /* sound */
void (*sound_set)(int setting, int value); void (*sound_set)(int setting, int value);
int (*sound_default)(int setting); int (*sound_default)(int setting);
@ -862,6 +878,9 @@ struct plugin_api {
#endif #endif
int (*show_logo)(void); int (*show_logo)(void);
struct tree_context* (*tree_get_context)(void); struct tree_context* (*tree_get_context)(void);
struct entry* (*tree_get_entries)(struct tree_context* t);
struct entry* (*tree_get_entry_at)(struct tree_context* t, int index);
void (*set_current_file)(const char* path); void (*set_current_file)(const char* path);
void (*set_dirfilter)(int l_dirfilter); void (*set_dirfilter)(int l_dirfilter);
@ -928,24 +947,6 @@ struct plugin_api {
/* new stuff at the end, sort into place next time /* new stuff at the end, sort into place next time
the API gets incompatible */ the API gets incompatible */
struct entry* (*tree_get_entries)(struct tree_context* t);
struct entry* (*tree_get_entry_at)(struct tree_context* t, int index);
/* the buflib memory management library */
void (*buflib_init)(struct buflib_context* ctx, void* buf, size_t size);
size_t (*buflib_available)(struct buflib_context* ctx);
int (*buflib_alloc)(struct buflib_context* ctx, size_t size);
int (*buflib_alloc_ex)(struct buflib_context* ctx, size_t size,
const char* name, struct buflib_callbacks *ops);
int (*buflib_alloc_maximum)(struct buflib_context* ctx, const char* name,
size_t* size, struct buflib_callbacks *ops);
void (*buflib_buffer_in)(struct buflib_context* ctx, int size);
void* (*buflib_buffer_out)(struct buflib_context* ctx, size_t* size);
int (*buflib_free)(struct buflib_context* ctx, int handle);
bool (*buflib_shrink)(struct buflib_context* ctx, int handle,
void* new_start, size_t new_size);
void* (*buflib_get_data)(struct buflib_context* ctx, int handle);
const char* (*buflib_get_name)(struct buflib_context* ctx, int handle);
}; };

View file

@ -86,8 +86,6 @@ int touchbutton_get(struct touchbutton *data, int button, int num_buttons) {
*/ */
void touchbutton_draw(struct touchbutton *data, int num_buttons) { void touchbutton_draw(struct touchbutton *data, int num_buttons) {
int i; int i;
/* These store the width and height of the title offset */
int title_width, title_height;
struct screen *lcd = rb->screens[SCREEN_MAIN]; struct screen *lcd = rb->screens[SCREEN_MAIN];
/* Loop over all the elements in data */ /* Loop over all the elements in data */
@ -99,35 +97,14 @@ void touchbutton_draw(struct touchbutton *data, int num_buttons) {
*/ */
lcd->set_viewport(&data[i].vp); lcd->set_viewport(&data[i].vp);
/* Get the string size so that the title can be centered. */ /* Set line_height to height, then it'll center for us */
lcd->getstringsize(data[i].title, &title_width, &title_height); data[i].vp.line_height = data[i].vp.height;
data[i].vp.flags |= VP_FLAG_ALIGN_RIGHT;
/* Center the title vertically */
title_height=(data[i].vp.height-title_height)/2;
/* If the above calculation was negative, reset to 0 */
if(title_height<0) {
title_height=0;
}
/* Center the title horizontally */
title_width=(data[i].vp.width-title_width)/2;
/* If the above calculation was negative, reset to 0 */
if(title_width<0) {
title_width=0;
}
/* If the width offset was 0, use a scrolling puts, else center and /* If the width offset was 0, use a scrolling puts, else center and
* print the title. * print the title.
*/ */
if(title_width==0) { lcd->puts_scroll_style(0, 0, data[i].title, STYLE_DEFAULT);
lcd->puts_scroll_style_xyoffset(0, 0, data[i].title,
STYLE_DEFAULT, 0, title_height);
} else {
lcd->putsxy(title_width, title_height, data[i].title);
}
/* Draw bounding box around the button location. */ /* Draw bounding box around the button location. */
lcd->draw_border_viewport(); lcd->draw_border_viewport();
} }

View file

@ -202,15 +202,15 @@ static bool game_finished;
struct touchbutton reversi_buttons[TOUCHBUTTON_COUNT] = struct touchbutton reversi_buttons[TOUCHBUTTON_COUNT] =
{ {
{ {B_MENU_X, B_MENU_Y, B_MENU_W, B_MENU_H, 0, FONT_UI, { {B_MENU_X, B_MENU_Y, B_MENU_W, B_MENU_H, 0, FONT_UI,
STYLE_DEFAULT, 0, 0xFFFF, 0, 0, 0}, -1, STYLE_DEFAULT, 0, 0xFFFF, 0, 0, 0},
false, REVERSI_BUTTON_MENU, false, "Menu", NULL }, false, REVERSI_BUTTON_MENU, false, "Menu", NULL },
{ {B_QUIT_X, B_QUIT_Y, B_QUIT_W, B_QUIT_H, 0, FONT_UI, { {B_QUIT_X, B_QUIT_Y, B_QUIT_W, B_QUIT_H, 0, FONT_UI,
STYLE_DEFAULT, 0, 0xFFFF, 0, 0, 0}, -1, STYLE_DEFAULT, 0, 0xFFFF, 0, 0, 0},
false, REVERSI_BUTTON_QUIT, false, "Quit", NULL }, false, REVERSI_BUTTON_QUIT, false, "Quit", NULL },
{ {0, 0, XOFS+BOARD_WIDTH, YOFS+BOARD_HEIGHT, 0, 0, { {0, 0, XOFS+BOARD_WIDTH, YOFS+BOARD_HEIGHT, 0, 0,
STYLE_DEFAULT, 0, 0xFFFF, 0, 0, 0}, -1, STYLE_DEFAULT, 0, 0xFFFF, 0, 0, 0},
false, REVERSI_BUTTON_MAKE_MOVE, true, NULL, NULL } false, REVERSI_BUTTON_MAKE_MOVE, true, NULL, NULL }
}; };
#endif #endif

View file

@ -556,8 +556,12 @@ extern void lcd_bitmap_transparent(const fb_data *src, int x, int y,
* once needed * once needed
*/ */
#if defined(LCD_DPI) && (LCD_DPI > 0)
/* returns the pixel density of the display */ /* returns the pixel density of the display */
static inline int lcd_get_dpi(void) { return LCD_DPI; }
#else
extern int lcd_get_dpi(void); extern int lcd_get_dpi(void);
#endif #endif /* LCD_DPI */
#endif /* HAVE_TOUCHSCREEN */
#endif /* __LCD_H__ */ #endif /* __LCD_H__ */