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)
{
#ifdef HAVE_LCD_BITMAP
if(icon==0)/* Don't display invalid icons */
return;
int xpos, ypos;
xpos = x*CURSOR_WIDTH;
ypos = y*display->char_height + display->getymargin();
if ( display->char_height > CURSOR_HEIGHT )/* center the cursor */
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
display->putc(x, y, icon);
if(icon==-1)
display->putc(x, y, ' ');
else
display->putc(x, y, icon);
#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
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
screen_put_iconxy(display, x, y, CURSOR_CHAR);
screen_put_iconxy(display, x, y, on?CURSOR_CHAR:-1);
#endif
}

View File

@ -31,16 +31,20 @@
#define CURSOR_CHAR 0x92
#define CURSOR_WIDTH 6
#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
* - 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
* (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
* - x, y : the position, in character, not in pixel !!
* - icon : the icon to put

View File

@ -40,10 +40,8 @@
void gui_list_init(struct gui_list * gui_list,
void (*callback_get_item_icon)
(int selected_item, void * data, ICON * icon),
char * (*callback_get_item_name)
(int selected_item, void * data, char *buffer),
list_get_icon callback_get_item_icon,
list_get_name callback_get_item_name,
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;
int selected_line=gui_list->selected_item-gui_list->start_item;
#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;
if (global_settings.invert_cursor)
{
int line_xpos=display->getxmargin();
display->set_drawmode(DRMODE_COMPLEMENT);
display->fillrect(line_xpos, line_ypos, display->width,
display->char_height);
@ -88,19 +85,14 @@ void gui_list_flash(struct gui_list * gui_list)
}
else
{
if(gui_list->cursor_flash_state)
screen_clear_area(display, cursor_xpos*SCROLLBAR_WIDTH, line_ypos,
CURSOR_WIDTH, CURSOR_HEIGHT);
else
screen_put_cursorxy(display, cursor_xpos, selected_line);
int cursor_xpos=(global_settings.scrollbar &&
display->nb_lines < gui_list->nb_items)?1:0;
screen_put_cursorxy(display, cursor_xpos, selected_line, gui_list->cursor_flash_state);
}
display->update_rect(0, line_ypos,display->width,
display->char_height);
#else
if(gui_list->cursor_flash_state)
display->putc(0, selected_line, ' ');
else
screen_put_cursorxy(display, 0, selected_line);
screen_put_cursorxy(display, 0, selected_line, gui_list->cursor_flash_state);
gui_textarea_update(display);
#endif
}
@ -199,7 +191,7 @@ void gui_list_draw(struct gui_list * gui_list)
#endif
if(draw_cursor)
screen_put_cursorxy(display, cursor_pos, i);
screen_put_cursorxy(display, cursor_pos, i, true);
}
else
{/* normal item */
@ -371,10 +363,8 @@ void gui_list_del_item(struct gui_list * gui_list)
*/
void gui_synclist_init(
struct gui_synclist * lists,
void (*callback_get_item_icon)
(int selected_item, void * data, ICON * icon),
char * (*callback_get_item_name)
(int selected_item, void * data, char *buffer),
list_get_icon callback_get_item_icon,
list_get_name callback_get_item_name,
void * data
)
{
@ -472,7 +462,7 @@ void gui_synclist_flash(struct gui_synclist * lists)
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);
switch(button)
@ -489,7 +479,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
#endif
gui_synclist_select_previous(lists);
gui_synclist_draw(lists);
return true;
return LIST_PREV;
case LIST_NEXT:
#ifdef LIST_RC_NEXT
@ -504,7 +494,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
#endif
gui_synclist_select_next(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 which the user pressed the key since for example, remote and main screen doesn't
* 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:
gui_synclist_select_previous_page(lists, SCREEN_MAIN);
gui_synclist_draw(lists);
return true;
return LIST_NEXT;
#endif
#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:
gui_synclist_select_previous_page(lists, SCREEN_REMOTE);
gui_synclist_draw(lists);
return true;
return LIST_NEXT;
#endif
#ifdef LIST_PGDN
@ -532,7 +522,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
case LIST_PGDN | BUTTON_REPEAT:
gui_synclist_select_next_page(lists, SCREEN_MAIN);
gui_synclist_draw(lists);
return true;
return LIST_PREV;
#endif
#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:
gui_synclist_select_next_page(lists, SCREEN_REMOTE);
gui_synclist_draw(lists);
return true;
return LIST_PREV;
#endif
}
return false;
return 0;
}

View File

@ -33,24 +33,33 @@
#define LIST_PREV BUTTON_UP
#define LIST_PGUP (BUTTON_ON | BUTTON_UP)
#define LIST_PGDN (BUTTON_ON | BUTTON_DOWN)
#ifdef CONFIG_REMOTE_KEYPAD
#define LIST_RC_NEXT BUTTON_RC_FF
#define LIST_RC_PREV BUTTON_RC_REW
#define LIST_RC_PGUP BUTTON_RC_SOURCE
#define LIST_RC_PGDN BUTTON_RC_BITRATE
#endif /* CONFIG_REMOTE_KEYPAD */
#elif CONFIG_KEYPAD == RECORDER_PAD
#define LIST_NEXT BUTTON_DOWN
#define LIST_PREV BUTTON_UP
#define LIST_PGUP (BUTTON_ON | BUTTON_UP)
#define LIST_PGDN (BUTTON_ON | BUTTON_DOWN)
#ifdef CONFIG_REMOTE_KEYPAD
#define LIST_RC_NEXT BUTTON_RC_RIGHT
#define LIST_RC_PREV BUTTON_RC_LEFT
#endif /* CONFIG_REMOTE_KEYPAD */
#elif CONFIG_KEYPAD == PLAYER_PAD
#define LIST_NEXT BUTTON_RIGHT
#define LIST_PREV BUTTON_LEFT
#ifdef CONFIG_REMOTE_KEYPAD
#define LIST_RC_NEXT BUTTON_RC_RIGHT
#define LIST_RC_PREV BUTTON_RC_LEFT
#endif /* CONFIG_REMOTE_KEYPAD */
#elif CONFIG_KEYPAD == ONDIO_PAD
#define LIST_NEXT BUTTON_DOWN
@ -73,8 +82,21 @@
* tells it what to display.
* There are two callback function :
* 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
* - 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
@ -84,15 +106,11 @@
* the return value of the function in all cases to avoid filling
* a buffer when it's not necessary)
* 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
{
int nb_items;
@ -100,13 +118,10 @@ struct gui_list
bool cursor_flash_state;
int start_item; /* the item that is displayed at the top of the screen */
void (*callback_get_item_icon)
(int selected_item, void * data, ICON * icon);
char * (*callback_get_item_name)
(int selected_item, void * data, char *buffer);
list_get_icon *callback_get_item_icon;
list_get_name *callback_get_item_name;
struct screen * display;
int line_scroll_limit;
/* defines wether the list should stop when reaching the top/bottom
* or should continue (by going to bottom/top) */
bool limit_scroll;
@ -123,10 +138,8 @@ struct gui_list
* to a given item number
*/
extern void gui_list_init(struct gui_list * gui_list,
void (*callback_get_item_icon)
(int selected_item, void * data, ICON * icon),
char * (*callback_get_item_name)
(int selected_item, void * data, char *buffer),
list_get_icon callback_get_item_icon,
list_get_name callback_get_item_name,
void * data
);
@ -264,10 +277,8 @@ struct gui_synclist
extern void gui_synclist_init(
struct gui_synclist * lists,
void (*callback_get_item_icon)
(int selected_item, void * data, ICON * icon),
char * (*callback_get_item_name)
(int selected_item, void * data, char *buffer),
list_get_icon callback_get_item_icon,
list_get_name callback_get_item_name,
void * data
);
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,
* returns true if something has been done, false otherwise
* returns the action taken if any, 0 else
* - lists : the synchronized lists
* - 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_ */

View File

@ -17,12 +17,10 @@
*
****************************************************************************/
#include "config.h"
#include "lcd.h"
#ifdef HAVE_LCD_BITMAP
#include "limits.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,
int width, int height, int items,

View File

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

View File

@ -28,6 +28,8 @@
#ifdef HAVE_LCD_CHARCELLS
enum {
Icon_Queued = 'Q',
Icon_Moving = 'M',
Icon_Unknown = 0x90,
Icon_Bookmark = 0x16,
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 */
{ 0x0a, 0x0a, 0x5f, 0x4e, 0x24, 0x18 }, /* Plugin 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] =

View File

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

View File

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