1
0
Fork 0
forked from len0rd/rockbox

Multi screen support for playlist viewer, some fixes in other gui files

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7901 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Kevin Ferrare 2005-11-16 02:12:25 +00:00
parent 5d8c1529a7
commit 8517ed8939
11 changed files with 409 additions and 691 deletions

View file

@ -26,24 +26,30 @@
void screen_put_iconxy(struct screen * display, int x, int y, ICON icon) void screen_put_iconxy(struct screen * display, int x, int y, ICON icon)
{ {
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
if(icon==0)/* Don't display invalid icons */
return;
int xpos, ypos; int xpos, ypos;
xpos = x*CURSOR_WIDTH; xpos = x*CURSOR_WIDTH;
ypos = y*display->char_height + display->getymargin(); ypos = y*display->char_height + display->getymargin();
if ( display->char_height > CURSOR_HEIGHT )/* center the cursor */ if ( display->char_height > CURSOR_HEIGHT )/* center the cursor */
ypos += (display->char_height - CURSOR_HEIGHT) / 2; ypos += (display->char_height - CURSOR_HEIGHT) / 2;
display->mono_bitmap(icon, xpos, ypos, CURSOR_WIDTH, CURSOR_HEIGHT); if(icon==0)/* Don't display invalid icons */
screen_clear_area(display, xpos, ypos, CURSOR_WIDTH, CURSOR_HEIGHT);
else
display->mono_bitmap(icon, xpos, ypos, CURSOR_WIDTH, CURSOR_HEIGHT);
#else #else
display->putc(x, y, icon); if(icon==-1)
display->putc(x, y, ' ');
else
display->putc(x, y, icon);
#endif #endif
} }
void screen_put_cursorxy(struct screen * display, int x, int y) void screen_put_cursorxy(struct screen * display, int x, int y, bool on)
{ {
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
screen_put_iconxy(display, x, y, bitmap_icons_6x8[Icon_Cursor]); screen_put_iconxy(display, x, y, on?bitmap_icons_6x8[Icon_Cursor]:0);
#else #else
screen_put_iconxy(display, x, y, CURSOR_CHAR); screen_put_iconxy(display, x, y, on?CURSOR_CHAR:-1);
#endif #endif
} }

View file

@ -31,16 +31,20 @@
#define CURSOR_CHAR 0x92 #define CURSOR_CHAR 0x92
#define CURSOR_WIDTH 6 #define CURSOR_WIDTH 6
#define CURSOR_HEIGHT 8 #define CURSOR_HEIGHT 8
/* /*
* Draws a cursor at a given position * Draws a cursor at a given position, if th
* - screen : the screen where we put the cursor * - screen : the screen where we put the cursor
* - x, y : the position, in character, not in pixel !! * - x, y : the position, in character, not in pixel !!
* - on : true if the cursor must be shown, false if it must be erased
*/ */
extern void screen_put_cursorxy(struct screen * screen, int x, int y); extern void screen_put_cursorxy(struct screen * screen, int x, int y, bool on);
/* /*
* Put an icon on a screen at a given position * Put an icon on a screen at a given position
* (the position is given in characters) * (the position is given in characters)
* If the given icon is null (HAVE_LCD_BITMAP) or -1 otherwise, the icon
* at the given position will be erased
* - screen : the screen where we put our icon * - screen : the screen where we put our icon
* - x, y : the position, in character, not in pixel !! * - x, y : the position, in character, not in pixel !!
* - icon : the icon to put * - icon : the icon to put

View file

@ -40,10 +40,8 @@
void gui_list_init(struct gui_list * gui_list, void gui_list_init(struct gui_list * gui_list,
void (*callback_get_item_icon) list_get_icon callback_get_item_icon,
(int selected_item, void * data, ICON * icon), list_get_name callback_get_item_name,
char * (*callback_get_item_name)
(int selected_item, void * data, char *buffer),
void * data void * data
) )
{ {
@ -75,11 +73,10 @@ void gui_list_flash(struct gui_list * gui_list)
gui_list->cursor_flash_state=!gui_list->cursor_flash_state; gui_list->cursor_flash_state=!gui_list->cursor_flash_state;
int selected_line=gui_list->selected_item-gui_list->start_item; int selected_line=gui_list->selected_item-gui_list->start_item;
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
int cursor_xpos=global_settings.scrollbar?1:0;
int line_xpos=display->getxmargin();
int line_ypos=display->getymargin()+display->char_height*selected_line; int line_ypos=display->getymargin()+display->char_height*selected_line;
if (global_settings.invert_cursor) if (global_settings.invert_cursor)
{ {
int line_xpos=display->getxmargin();
display->set_drawmode(DRMODE_COMPLEMENT); display->set_drawmode(DRMODE_COMPLEMENT);
display->fillrect(line_xpos, line_ypos, display->width, display->fillrect(line_xpos, line_ypos, display->width,
display->char_height); display->char_height);
@ -88,19 +85,14 @@ void gui_list_flash(struct gui_list * gui_list)
} }
else else
{ {
if(gui_list->cursor_flash_state) int cursor_xpos=(global_settings.scrollbar &&
screen_clear_area(display, cursor_xpos*SCROLLBAR_WIDTH, line_ypos, display->nb_lines < gui_list->nb_items)?1:0;
CURSOR_WIDTH, CURSOR_HEIGHT); screen_put_cursorxy(display, cursor_xpos, selected_line, gui_list->cursor_flash_state);
else
screen_put_cursorxy(display, cursor_xpos, selected_line);
} }
display->update_rect(0, line_ypos,display->width, display->update_rect(0, line_ypos,display->width,
display->char_height); display->char_height);
#else #else
if(gui_list->cursor_flash_state) screen_put_cursorxy(display, 0, selected_line, gui_list->cursor_flash_state);
display->putc(0, selected_line, ' ');
else
screen_put_cursorxy(display, 0, selected_line);
gui_textarea_update(display); gui_textarea_update(display);
#endif #endif
} }
@ -199,7 +191,7 @@ void gui_list_draw(struct gui_list * gui_list)
#endif #endif
if(draw_cursor) if(draw_cursor)
screen_put_cursorxy(display, cursor_pos, i); screen_put_cursorxy(display, cursor_pos, i, true);
} }
else else
{/* normal item */ {/* normal item */
@ -371,10 +363,8 @@ void gui_list_del_item(struct gui_list * gui_list)
*/ */
void gui_synclist_init( void gui_synclist_init(
struct gui_synclist * lists, struct gui_synclist * lists,
void (*callback_get_item_icon) list_get_icon callback_get_item_icon,
(int selected_item, void * data, ICON * icon), list_get_name callback_get_item_name,
char * (*callback_get_item_name)
(int selected_item, void * data, char *buffer),
void * data void * data
) )
{ {
@ -472,7 +462,7 @@ void gui_synclist_flash(struct gui_synclist * lists)
gui_list_flash(&(lists->gui_list[i])); gui_list_flash(&(lists->gui_list[i]));
} }
bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button) unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
{ {
gui_synclist_limit_scroll(lists, true); gui_synclist_limit_scroll(lists, true);
switch(button) switch(button)
@ -489,7 +479,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
#endif #endif
gui_synclist_select_previous(lists); gui_synclist_select_previous(lists);
gui_synclist_draw(lists); gui_synclist_draw(lists);
return true; return LIST_PREV;
case LIST_NEXT: case LIST_NEXT:
#ifdef LIST_RC_NEXT #ifdef LIST_RC_NEXT
@ -504,7 +494,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
#endif #endif
gui_synclist_select_next(lists); gui_synclist_select_next(lists);
gui_synclist_draw(lists); gui_synclist_draw(lists);
return true; return LIST_NEXT;
/* for pgup / pgdown, we are obliged to have a different behaviour depending on the screen /* for pgup / pgdown, we are obliged to have a different behaviour depending on the screen
* for which the user pressed the key since for example, remote and main screen doesn't * for which the user pressed the key since for example, remote and main screen doesn't
* have the same number of lines*/ * have the same number of lines*/
@ -514,7 +504,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
case LIST_PGUP | BUTTON_REPEAT: case LIST_PGUP | BUTTON_REPEAT:
gui_synclist_select_previous_page(lists, SCREEN_MAIN); gui_synclist_select_previous_page(lists, SCREEN_MAIN);
gui_synclist_draw(lists); gui_synclist_draw(lists);
return true; return LIST_NEXT;
#endif #endif
#ifdef LIST_RC_PGUP #ifdef LIST_RC_PGUP
@ -523,7 +513,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
case LIST_RC_PGUP | BUTTON_REPEAT: case LIST_RC_PGUP | BUTTON_REPEAT:
gui_synclist_select_previous_page(lists, SCREEN_REMOTE); gui_synclist_select_previous_page(lists, SCREEN_REMOTE);
gui_synclist_draw(lists); gui_synclist_draw(lists);
return true; return LIST_NEXT;
#endif #endif
#ifdef LIST_PGDN #ifdef LIST_PGDN
@ -532,7 +522,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
case LIST_PGDN | BUTTON_REPEAT: case LIST_PGDN | BUTTON_REPEAT:
gui_synclist_select_next_page(lists, SCREEN_MAIN); gui_synclist_select_next_page(lists, SCREEN_MAIN);
gui_synclist_draw(lists); gui_synclist_draw(lists);
return true; return LIST_PREV;
#endif #endif
#ifdef LIST_RC_PGDN #ifdef LIST_RC_PGDN
@ -541,8 +531,8 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
case LIST_RC_PGDN | BUTTON_REPEAT: case LIST_RC_PGDN | BUTTON_REPEAT:
gui_synclist_select_next_page(lists, SCREEN_REMOTE); gui_synclist_select_next_page(lists, SCREEN_REMOTE);
gui_synclist_draw(lists); gui_synclist_draw(lists);
return true; return LIST_PREV;
#endif #endif
} }
return false; return 0;
} }

View file

@ -33,24 +33,33 @@
#define LIST_PREV BUTTON_UP #define LIST_PREV BUTTON_UP
#define LIST_PGUP (BUTTON_ON | BUTTON_UP) #define LIST_PGUP (BUTTON_ON | BUTTON_UP)
#define LIST_PGDN (BUTTON_ON | BUTTON_DOWN) #define LIST_PGDN (BUTTON_ON | BUTTON_DOWN)
#ifdef CONFIG_REMOTE_KEYPAD
#define LIST_RC_NEXT BUTTON_RC_FF #define LIST_RC_NEXT BUTTON_RC_FF
#define LIST_RC_PREV BUTTON_RC_REW #define LIST_RC_PREV BUTTON_RC_REW
#define LIST_RC_PGUP BUTTON_RC_SOURCE #define LIST_RC_PGUP BUTTON_RC_SOURCE
#define LIST_RC_PGDN BUTTON_RC_BITRATE #define LIST_RC_PGDN BUTTON_RC_BITRATE
#endif /* CONFIG_REMOTE_KEYPAD */
#elif CONFIG_KEYPAD == RECORDER_PAD #elif CONFIG_KEYPAD == RECORDER_PAD
#define LIST_NEXT BUTTON_DOWN #define LIST_NEXT BUTTON_DOWN
#define LIST_PREV BUTTON_UP #define LIST_PREV BUTTON_UP
#define LIST_PGUP (BUTTON_ON | BUTTON_UP) #define LIST_PGUP (BUTTON_ON | BUTTON_UP)
#define LIST_PGDN (BUTTON_ON | BUTTON_DOWN) #define LIST_PGDN (BUTTON_ON | BUTTON_DOWN)
#ifdef CONFIG_REMOTE_KEYPAD
#define LIST_RC_NEXT BUTTON_RC_RIGHT #define LIST_RC_NEXT BUTTON_RC_RIGHT
#define LIST_RC_PREV BUTTON_RC_LEFT #define LIST_RC_PREV BUTTON_RC_LEFT
#endif /* CONFIG_REMOTE_KEYPAD */
#elif CONFIG_KEYPAD == PLAYER_PAD #elif CONFIG_KEYPAD == PLAYER_PAD
#define LIST_NEXT BUTTON_RIGHT #define LIST_NEXT BUTTON_RIGHT
#define LIST_PREV BUTTON_LEFT #define LIST_PREV BUTTON_LEFT
#ifdef CONFIG_REMOTE_KEYPAD
#define LIST_RC_NEXT BUTTON_RC_RIGHT #define LIST_RC_NEXT BUTTON_RC_RIGHT
#define LIST_RC_PREV BUTTON_RC_LEFT #define LIST_RC_PREV BUTTON_RC_LEFT
#endif /* CONFIG_REMOTE_KEYPAD */
#elif CONFIG_KEYPAD == ONDIO_PAD #elif CONFIG_KEYPAD == ONDIO_PAD
#define LIST_NEXT BUTTON_DOWN #define LIST_NEXT BUTTON_DOWN
@ -73,8 +82,21 @@
* tells it what to display. * tells it what to display.
* There are two callback function : * There are two callback function :
* one to get the text and one to get the icon * one to get the text and one to get the icon
* Callback interface : */
*
/*
* Icon callback
* - selected_item : an integer that tells the number of the item to display
* - data : a void pointer to the data you gave to the list when
* you initialized it
* - icon : a pointer to the icon, the value inside it is used to display
* the icon after the function returns.
* Note : we use the ICON type because the real type depends of the plateform
*/
typedef void list_get_icon(int selected_item,
void * data,
ICON * icon);
/*
* Text callback * Text callback
* - selected_item : an integer that tells the number of the item to display * - selected_item : an integer that tells the number of the item to display
* - data : a void pointer to the data you gave to the list when * - data : a void pointer to the data you gave to the list when
@ -84,15 +106,11 @@
* the return value of the function in all cases to avoid filling * the return value of the function in all cases to avoid filling
* a buffer when it's not necessary) * a buffer when it's not necessary)
* Returns a pointer to a string that contains the text to display * Returns a pointer to a string that contains the text to display
*
* Icon callback
* - selected_item : an integer that tells the number of the item to display
* - data : a void pointer to the data you gave to the list when
* you initialized it
* - icon : a pointer to the icon, the value inside it is used to display
* the icon after the function returns.
* Note : we use the ICON type because the real type depends of the plateform
*/ */
typedef char * list_get_name(int selected_item,
void * data,
char *buffer);
struct gui_list struct gui_list
{ {
int nb_items; int nb_items;
@ -100,13 +118,10 @@ struct gui_list
bool cursor_flash_state; bool cursor_flash_state;
int start_item; /* the item that is displayed at the top of the screen */ int start_item; /* the item that is displayed at the top of the screen */
void (*callback_get_item_icon) list_get_icon *callback_get_item_icon;
(int selected_item, void * data, ICON * icon); list_get_name *callback_get_item_name;
char * (*callback_get_item_name)
(int selected_item, void * data, char *buffer);
struct screen * display; struct screen * display;
int line_scroll_limit;
/* defines wether the list should stop when reaching the top/bottom /* defines wether the list should stop when reaching the top/bottom
* or should continue (by going to bottom/top) */ * or should continue (by going to bottom/top) */
bool limit_scroll; bool limit_scroll;
@ -123,10 +138,8 @@ struct gui_list
* to a given item number * to a given item number
*/ */
extern void gui_list_init(struct gui_list * gui_list, extern void gui_list_init(struct gui_list * gui_list,
void (*callback_get_item_icon) list_get_icon callback_get_item_icon,
(int selected_item, void * data, ICON * icon), list_get_name callback_get_item_name,
char * (*callback_get_item_name)
(int selected_item, void * data, char *buffer),
void * data void * data
); );
@ -264,10 +277,8 @@ struct gui_synclist
extern void gui_synclist_init( extern void gui_synclist_init(
struct gui_synclist * lists, struct gui_synclist * lists,
void (*callback_get_item_icon) list_get_icon callback_get_item_icon,
(int selected_item, void * data, ICON * icon), list_get_name callback_get_item_name,
char * (*callback_get_item_name)
(int selected_item, void * data, char *buffer),
void * data void * data
); );
extern void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items); extern void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items);
@ -295,10 +306,13 @@ extern void gui_synclist_flash(struct gui_synclist * lists);
/* /*
* Do the action implied by the given button, * Do the action implied by the given button,
* returns true if something has been done, false otherwise * returns the action taken if any, 0 else
* - lists : the synchronized lists * - lists : the synchronized lists
* - button : the keycode of a pressed button * - button : the keycode of a pressed button
* returned value :
* - LIST_NEXT when moving forward (next item or pgup)
* - LIST_PREV when moving backward (previous item or pgdown)
*/ */
extern bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button); extern unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button);
#endif /* _GUI_LIST_H_ */ #endif /* _GUI_LIST_H_ */

View file

@ -17,12 +17,10 @@
* *
****************************************************************************/ ****************************************************************************/
#include "config.h"
#include "lcd.h"
#ifdef HAVE_LCD_BITMAP
#include "limits.h"
#include "scrollbar.h" #include "scrollbar.h"
#include "screen_access.h" #ifdef HAVE_LCD_BITMAP
#include "config.h"
#include "limits.h"
void gui_scrollbar_draw(struct screen * screen, int x, int y, void gui_scrollbar_draw(struct screen * screen, int x, int y,
int width, int height, int items, int width, int height, int items,

View file

@ -19,10 +19,9 @@
#ifndef _GUI_SCROLLBAR_H_ #ifndef _GUI_SCROLLBAR_H_
#define _GUI_SCROLLBAR_H_ #define _GUI_SCROLLBAR_H_
#include <lcd.h> #include "screen_access.h"
#ifdef HAVE_LCD_BITMAP
struct screen; #ifdef HAVE_LCD_BITMAP
enum orientation { enum orientation {
VERTICAL, VERTICAL,

View file

@ -28,6 +28,8 @@
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
enum { enum {
Icon_Queued = 'Q',
Icon_Moving = 'M',
Icon_Unknown = 0x90, Icon_Unknown = 0x90,
Icon_Bookmark = 0x16, Icon_Bookmark = 0x16,
Icon_Plugin, Icon_Plugin,

File diff suppressed because it is too large Load diff

View file

@ -47,6 +47,8 @@ const unsigned char bitmap_icons_6x8[LastIcon][6] =
{ 0x4e, 0x51, 0x51, 0x40, 0x55, 0x55 }, /* Config file */ { 0x4e, 0x51, 0x51, 0x40, 0x55, 0x55 }, /* Config file */
{ 0x0a, 0x0a, 0x5f, 0x4e, 0x24, 0x18 }, /* Plugin file */ { 0x0a, 0x0a, 0x5f, 0x4e, 0x24, 0x18 }, /* Plugin file */
{ 0xff, 0x81, 0xaf, 0xaa, 0x8c, 0xf8 }, /* Bookmark file */ { 0xff, 0x81, 0xaf, 0xaa, 0x8c, 0xf8 }, /* Bookmark file */
{ 0x77, 0x55, 0x55, 0x55, 0x55, 0x77 }, /* Queued Item */
{ 0x3e, 0x41, 0x3e, 0x1c, 0x1c, 0x08 }, /* Moving Item */
}; };
const unsigned char bitmap_icons_7x8[][7] = const unsigned char bitmap_icons_7x8[][7] =

View file

@ -44,6 +44,8 @@ enum icons_6x8 {
Icon_Config, Icon_Config,
Icon_Plugin, Icon_Plugin,
Icon_Bookmark, Icon_Bookmark,
Icon_Queued,
Icon_Moving,
LastIcon LastIcon
}; };

View file

@ -150,13 +150,6 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
gui_textarea_update_nblines(screen); gui_textarea_update_nblines(screen);
} }
void screen_access_init(void)
{
int i;
FOR_NB_SCREENS(i)
screen_init(&screens[i], i);
}
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
void screen_clear_area(struct screen * display, int xstart, int ystart, void screen_clear_area(struct screen * display, int xstart, int ystart,
int width, int height) int width, int height)
@ -166,3 +159,10 @@ void screen_clear_area(struct screen * display, int xstart, int ystart,
display->set_drawmode(DRMODE_SOLID); display->set_drawmode(DRMODE_SOLID);
} }
#endif #endif
void screen_access_init(void)
{
int i;
FOR_NB_SCREENS(i)
screen_init(&screens[i], i);
}