2005-10-28 00:00:00 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2005-10-30 01:24:35 +00:00
|
|
|
* Copyright (C) 2005 by Kevin Ferrare
|
2005-10-28 00:00:00 +00:00
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "font.h"
|
|
|
|
#include "button.h"
|
|
|
|
#include "sprintf.h"
|
2006-08-15 08:14:46 +00:00
|
|
|
#include "string.h"
|
2005-10-28 00:00:00 +00:00
|
|
|
#include "settings.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
#include "action.h"
|
2005-10-28 00:00:00 +00:00
|
|
|
#include "screen_access.h"
|
|
|
|
#include "list.h"
|
|
|
|
#include "scrollbar.h"
|
|
|
|
#include "statusbar.h"
|
2005-11-01 23:56:03 +00:00
|
|
|
#include "textarea.h"
|
2005-10-28 00:00:00 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
#define SCROLL_LIMIT 1
|
|
|
|
#else
|
|
|
|
#define SCROLL_LIMIT 2
|
|
|
|
#endif
|
|
|
|
|
2006-01-22 04:24:26 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
static int offset_step = 16; /* pixels per screen scroll step */
|
|
|
|
/* should lines scroll out of the screen */
|
|
|
|
static bool offset_out_of_view = false;
|
|
|
|
#endif
|
|
|
|
|
2006-12-09 12:27:04 +00:00
|
|
|
#define SHOW_LIST_TITLE ((gui_list->title != NULL) && \
|
|
|
|
(gui_list->display->nb_lines > 1))
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
static void gui_list_put_selection_in_screen(struct gui_list * gui_list,
|
|
|
|
bool put_from_end);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initializes a scrolling list
|
|
|
|
* - gui_list : the list structure to initialize
|
|
|
|
* - callback_get_item_icon : pointer to a function that associates an icon
|
|
|
|
* to a given item number
|
|
|
|
* - callback_get_item_name : pointer to a function that associates a label
|
|
|
|
* to a given item number
|
|
|
|
* - data : extra data passed to the list callback
|
|
|
|
*/
|
|
|
|
static void gui_list_init(struct gui_list * gui_list,
|
2005-11-16 02:12:25 +00:00
|
|
|
list_get_name callback_get_item_name,
|
2006-07-02 12:28:27 +00:00
|
|
|
void * data,
|
|
|
|
bool scroll_all,
|
|
|
|
int selected_size
|
2005-10-29 02:33:19 +00:00
|
|
|
)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2005-11-16 17:23:49 +00:00
|
|
|
gui_list->callback_get_item_icon = NULL;
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list->callback_get_item_name = callback_get_item_name;
|
|
|
|
gui_list->display = NULL;
|
|
|
|
gui_list_set_nb_items(gui_list, 0);
|
|
|
|
gui_list->selected_item = 0;
|
|
|
|
gui_list->start_item = 0;
|
2005-10-29 02:33:19 +00:00
|
|
|
gui_list->limit_scroll = false;
|
|
|
|
gui_list->data=data;
|
2005-11-09 01:17:57 +00:00
|
|
|
gui_list->cursor_flash_state=false;
|
2006-01-22 04:24:26 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
gui_list->offset_position = 0;
|
|
|
|
#endif
|
2006-07-02 12:28:27 +00:00
|
|
|
gui_list->scroll_all=scroll_all;
|
|
|
|
gui_list->selected_size=selected_size;
|
2006-08-15 08:14:46 +00:00
|
|
|
gui_list->title = NULL;
|
2006-08-15 12:23:55 +00:00
|
|
|
gui_list->title_width = 0;
|
2006-08-23 20:02:06 +00:00
|
|
|
gui_list->title_icon = NOICON;
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
/*
|
|
|
|
* Attach the scrolling list to a screen
|
|
|
|
* (The previous screen attachement is lost)
|
|
|
|
* - gui_list : the list structure
|
|
|
|
* - display : the screen to attach
|
|
|
|
*/
|
|
|
|
static void gui_list_set_display(struct gui_list * gui_list, struct screen * display)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
if(gui_list->display != 0) /* we switched from a previous display */
|
|
|
|
gui_list->display->stop_scroll();
|
|
|
|
gui_list->display = display;
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
display->double_height(false);
|
|
|
|
#endif
|
|
|
|
gui_list_put_selection_in_screen(gui_list, false);
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
/*
|
|
|
|
* One call on 2, the selected lune will either blink the cursor or
|
|
|
|
* invert/display normal the selected line
|
|
|
|
* - gui_list : the list structure
|
|
|
|
*/
|
|
|
|
static void gui_list_flash(struct gui_list * gui_list)
|
2005-11-09 01:17:57 +00:00
|
|
|
{
|
|
|
|
struct screen * display=gui_list->display;
|
|
|
|
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 line_ypos=display->getymargin()+display->char_height*selected_line;
|
|
|
|
if (global_settings.invert_cursor)
|
|
|
|
{
|
2005-11-16 02:12:25 +00:00
|
|
|
int line_xpos=display->getxmargin();
|
2005-11-09 01:17:57 +00:00
|
|
|
display->set_drawmode(DRMODE_COMPLEMENT);
|
|
|
|
display->fillrect(line_xpos, line_ypos, display->width,
|
|
|
|
display->char_height);
|
|
|
|
display->set_drawmode(DRMODE_SOLID);
|
|
|
|
display->invertscroll(0, selected_line);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-11-16 02:12:25 +00:00
|
|
|
int cursor_xpos=(global_settings.scrollbar &&
|
|
|
|
display->nb_lines < gui_list->nb_items)?1:0;
|
2006-12-09 10:02:09 +00:00
|
|
|
screen_put_cursorxy(display, cursor_xpos, selected_line,
|
|
|
|
gui_list->cursor_flash_state);
|
2005-11-09 01:17:57 +00:00
|
|
|
}
|
|
|
|
display->update_rect(0, line_ypos,display->width,
|
|
|
|
display->char_height);
|
|
|
|
#else
|
2006-12-09 10:02:09 +00:00
|
|
|
screen_put_cursorxy(display, 0, selected_line,
|
|
|
|
gui_list->cursor_flash_state);
|
2005-11-09 01:17:57 +00:00
|
|
|
gui_textarea_update(display);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
/*
|
|
|
|
* Puts the selection in the screen
|
|
|
|
* - gui_list : the list structure
|
|
|
|
* - put_from_end : if true, selection will be put as close from
|
|
|
|
* the end of the list as possible, else, it's
|
|
|
|
* from the beginning
|
|
|
|
*/
|
|
|
|
static void gui_list_put_selection_in_screen(struct gui_list * gui_list,
|
2005-10-28 00:00:00 +00:00
|
|
|
bool put_from_end)
|
|
|
|
{
|
2006-03-09 22:26:22 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-03-09 22:03:13 +00:00
|
|
|
gui_list->display->setfont(FONT_UI);
|
2006-03-09 22:26:22 +00:00
|
|
|
#endif
|
2005-11-01 23:56:03 +00:00
|
|
|
gui_textarea_update_nblines(gui_list->display);
|
2005-10-29 02:33:19 +00:00
|
|
|
int nb_lines=gui_list->display->nb_lines;
|
2006-12-09 12:27:04 +00:00
|
|
|
if (SHOW_LIST_TITLE)
|
2006-08-15 08:14:46 +00:00
|
|
|
nb_lines--;
|
2005-10-28 00:00:00 +00:00
|
|
|
if(put_from_end)
|
|
|
|
{
|
2005-12-29 00:21:55 +00:00
|
|
|
int list_end = gui_list->selected_item + SCROLL_LIMIT;
|
|
|
|
|
|
|
|
if(list_end-1 == gui_list->nb_items)
|
|
|
|
list_end--;
|
2005-10-28 00:00:00 +00:00
|
|
|
if(list_end > gui_list->nb_items)
|
2005-10-29 02:33:19 +00:00
|
|
|
list_end = nb_lines;
|
|
|
|
gui_list->start_item = list_end - nb_lines;
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int list_start = gui_list->selected_item - SCROLL_LIMIT + 1;
|
2005-10-29 02:33:19 +00:00
|
|
|
if(list_start + nb_lines > gui_list->nb_items)
|
|
|
|
list_start = gui_list->nb_items - nb_lines;
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list->start_item = list_start;
|
|
|
|
}
|
|
|
|
if(gui_list->start_item < 0)
|
|
|
|
gui_list->start_item = 0;
|
|
|
|
}
|
|
|
|
|
2006-08-23 20:02:06 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-12-25 14:01:47 +00:00
|
|
|
static int gui_list_get_item_offset(struct gui_list * gui_list, int item_width,
|
2006-08-23 20:02:06 +00:00
|
|
|
int text_pos)
|
|
|
|
{
|
|
|
|
struct screen * display=gui_list->display;
|
|
|
|
int item_offset;
|
|
|
|
|
|
|
|
if (offset_out_of_view)
|
|
|
|
{
|
|
|
|
item_offset = gui_list->offset_position;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* if text is smaller then view */
|
|
|
|
if (item_width <= display->width - text_pos)
|
|
|
|
{
|
|
|
|
item_offset = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* if text got out of view */
|
|
|
|
if (gui_list->offset_position >
|
|
|
|
item_width - (display->width - text_pos))
|
|
|
|
item_offset = item_width - (display->width - text_pos);
|
|
|
|
else
|
|
|
|
item_offset = gui_list->offset_position;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return item_offset;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
/*
|
|
|
|
* Draws the list on the attached screen
|
|
|
|
* - gui_list : the list structure
|
|
|
|
*/
|
|
|
|
static void gui_list_draw(struct gui_list * gui_list)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
struct screen * display=gui_list->display;
|
|
|
|
int cursor_pos = 0;
|
|
|
|
int icon_pos = 1;
|
|
|
|
int text_pos;
|
2007-03-01 18:25:13 +00:00
|
|
|
bool draw_icons = (gui_list->callback_get_item_icon != NULL && global_settings.show_icons);
|
2005-10-28 00:00:00 +00:00
|
|
|
bool draw_cursor;
|
|
|
|
int i;
|
2006-08-15 08:14:46 +00:00
|
|
|
int lines;
|
2006-08-23 20:02:06 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
int item_offset;
|
2007-03-03 13:42:12 +00:00
|
|
|
int old_margin = display->getxmargin();
|
2006-08-23 20:02:06 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
gui_textarea_clear(display);
|
2005-10-28 23:52:49 +00:00
|
|
|
|
2006-08-23 20:02:06 +00:00
|
|
|
/* position and draw the list title & icon */
|
2006-12-09 12:27:04 +00:00
|
|
|
if (SHOW_LIST_TITLE)
|
2006-08-15 08:14:46 +00:00
|
|
|
{
|
|
|
|
i = 1;
|
|
|
|
lines = display->nb_lines - 1;
|
2006-08-23 20:02:06 +00:00
|
|
|
|
2007-03-01 18:25:13 +00:00
|
|
|
if (gui_list->title_icon != NOICON && draw_icons)
|
2006-08-23 20:02:06 +00:00
|
|
|
{
|
|
|
|
screen_put_iconxy(display, 0, 0, gui_list->title_icon);
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
text_pos = 8; /* pixels */
|
|
|
|
#else
|
|
|
|
text_pos = 1; /* chars */
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
text_pos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
screen_set_xmargin(display, text_pos); /* margin for title */
|
|
|
|
item_offset = gui_list_get_item_offset(gui_list, gui_list->title_width,
|
|
|
|
text_pos);
|
|
|
|
if (item_offset > gui_list->title_width - (display->width - text_pos))
|
|
|
|
display->puts_offset(0, 0, gui_list->title, item_offset);
|
|
|
|
else
|
|
|
|
display->puts_scroll_offset(0, 0, gui_list->title, item_offset);
|
|
|
|
#else
|
|
|
|
display->puts_scroll(text_pos, 0, gui_list->title);
|
|
|
|
#endif
|
2006-08-15 08:14:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i = 0;
|
|
|
|
lines = display->nb_lines;
|
|
|
|
}
|
2006-08-23 20:02:06 +00:00
|
|
|
|
|
|
|
/* Adjust the position of icon, cursor, text for the list */
|
2005-10-28 00:00:00 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-10-30 22:34:51 +00:00
|
|
|
display->setfont(FONT_UI);
|
2005-11-01 23:56:03 +00:00
|
|
|
gui_textarea_update_nblines(display);
|
2006-08-15 08:14:46 +00:00
|
|
|
bool draw_scrollbar;
|
2006-08-23 20:02:06 +00:00
|
|
|
|
2006-08-15 08:14:46 +00:00
|
|
|
draw_scrollbar = (global_settings.scrollbar &&
|
|
|
|
lines < gui_list->nb_items);
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
draw_cursor = !global_settings.invert_cursor;
|
|
|
|
text_pos = 0; /* here it's in pixels */
|
2006-12-09 12:27:04 +00:00
|
|
|
if(draw_scrollbar || SHOW_LIST_TITLE) /* indent if there's
|
|
|
|
a title */
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2005-10-29 02:33:19 +00:00
|
|
|
cursor_pos++;
|
|
|
|
icon_pos++;
|
2005-10-28 00:00:00 +00:00
|
|
|
text_pos += SCROLLBAR_WIDTH;
|
|
|
|
}
|
|
|
|
if(!draw_cursor)
|
2005-10-29 02:33:19 +00:00
|
|
|
icon_pos--;
|
2005-10-28 00:00:00 +00:00
|
|
|
else
|
|
|
|
text_pos += CURSOR_WIDTH;
|
2005-10-28 23:52:49 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
if(draw_icons)
|
|
|
|
text_pos += 8;
|
|
|
|
#else
|
|
|
|
draw_cursor = true;
|
|
|
|
if(draw_icons)
|
|
|
|
text_pos = 2; /* here it's in chars */
|
|
|
|
else
|
|
|
|
text_pos = 1;
|
|
|
|
#endif
|
|
|
|
|
2005-11-01 23:56:03 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-08-23 20:02:06 +00:00
|
|
|
screen_set_xmargin(display, text_pos); /* margin for list */
|
2005-10-28 00:00:00 +00:00
|
|
|
#endif
|
|
|
|
|
2006-08-15 08:14:46 +00:00
|
|
|
while (i < display->nb_lines)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
char entry_buffer[MAX_PATH];
|
2005-12-05 23:37:14 +00:00
|
|
|
unsigned char *entry_name;
|
2006-12-09 10:02:09 +00:00
|
|
|
int current_item = gui_list->start_item +
|
2006-12-09 12:27:04 +00:00
|
|
|
(SHOW_LIST_TITLE ? i-1 : i);
|
2005-10-28 23:52:49 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* When there are less items to display than the
|
|
|
|
* current available space on the screen, we stop*/
|
|
|
|
if(current_item >= gui_list->nb_items)
|
|
|
|
break;
|
|
|
|
entry_name = gui_list->callback_get_item_name(current_item,
|
2005-10-29 02:33:19 +00:00
|
|
|
gui_list->data,
|
2005-10-28 00:00:00 +00:00
|
|
|
entry_buffer);
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-01-22 04:24:26 +00:00
|
|
|
/* position the string at the correct offset place */
|
|
|
|
int item_width,h;
|
|
|
|
display->getstringsize(entry_name, &item_width, &h);
|
2006-08-23 20:02:06 +00:00
|
|
|
item_offset = gui_list_get_item_offset(gui_list, item_width, text_pos);
|
2006-01-22 04:24:26 +00:00
|
|
|
#endif
|
2006-08-23 20:02:06 +00:00
|
|
|
|
|
|
|
if(current_item >= gui_list->selected_item &&
|
|
|
|
current_item < gui_list->selected_item + gui_list->selected_size)
|
2006-07-02 12:28:27 +00:00
|
|
|
{/* The selected item must be displayed scrolling */
|
2006-01-22 01:42:05 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-01-22 04:24:26 +00:00
|
|
|
if (global_settings.invert_cursor)/* Display inverted-line-style*/
|
2006-01-22 01:42:05 +00:00
|
|
|
/* if text got out of view */
|
2006-01-22 04:24:26 +00:00
|
|
|
if (item_offset > item_width - (display->width - text_pos))
|
2006-01-22 01:42:05 +00:00
|
|
|
/* don't scroll */
|
2006-12-09 10:02:09 +00:00
|
|
|
display->puts_style_offset(0, i, entry_name,
|
|
|
|
STYLE_INVERT,item_offset);
|
2006-01-22 01:42:05 +00:00
|
|
|
else
|
2006-12-09 10:02:09 +00:00
|
|
|
display->puts_scroll_style_offset(0, i, entry_name,
|
|
|
|
STYLE_INVERT,
|
|
|
|
item_offset);
|
2006-01-22 01:42:05 +00:00
|
|
|
|
2006-01-22 04:24:26 +00:00
|
|
|
else /* if (!global_settings.invert_cursor) */
|
|
|
|
if (item_offset > item_width - (display->width - text_pos))
|
|
|
|
display->puts_offset(0, i, entry_name,item_offset);
|
|
|
|
else
|
|
|
|
display->puts_scroll_offset(0, i, entry_name,item_offset);
|
2005-10-28 00:00:00 +00:00
|
|
|
#else
|
|
|
|
display->puts_scroll(text_pos, i, entry_name);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(draw_cursor)
|
2005-11-16 02:12:25 +00:00
|
|
|
screen_put_cursorxy(display, cursor_pos, i, true);
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{/* normal item */
|
2006-07-02 12:28:27 +00:00
|
|
|
if(gui_list->scroll_all)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
display->puts_scroll_offset(0, i, entry_name,item_offset);
|
|
|
|
#else
|
|
|
|
display->puts_scroll(text_pos, i, entry_name);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-28 00:00:00 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-07-02 12:28:27 +00:00
|
|
|
display->puts_offset(0, i, entry_name,item_offset);
|
2005-10-28 00:00:00 +00:00
|
|
|
#else
|
2006-07-02 12:28:27 +00:00
|
|
|
display->puts(text_pos, i, entry_name);
|
2005-10-28 00:00:00 +00:00
|
|
|
#endif
|
2006-07-02 12:28:27 +00:00
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
/* Icons display */
|
|
|
|
if(draw_icons)
|
|
|
|
{
|
|
|
|
ICON icon;
|
2005-10-29 02:33:19 +00:00
|
|
|
gui_list->callback_get_item_icon(current_item,
|
|
|
|
gui_list->data,
|
|
|
|
&icon);
|
2005-11-09 01:17:57 +00:00
|
|
|
if(icon)
|
|
|
|
screen_put_iconxy(display, icon_pos, i, icon);
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
2006-08-15 08:14:46 +00:00
|
|
|
i++;
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
2006-08-15 08:14:46 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-10-28 00:00:00 +00:00
|
|
|
/* Draw the scrollbar if needed*/
|
|
|
|
if(draw_scrollbar)
|
|
|
|
{
|
2005-11-01 23:56:03 +00:00
|
|
|
int y_start = gui_textarea_get_ystart(display);
|
2006-12-09 12:27:04 +00:00
|
|
|
if (SHOW_LIST_TITLE)
|
2006-08-15 08:14:46 +00:00
|
|
|
y_start += display->char_height;
|
2005-10-28 00:00:00 +00:00
|
|
|
int scrollbar_y_end = display->char_height *
|
2006-08-15 08:14:46 +00:00
|
|
|
lines + y_start;
|
2005-11-01 23:56:03 +00:00
|
|
|
gui_scrollbar_draw(display, 0, y_start, SCROLLBAR_WIDTH-1,
|
|
|
|
scrollbar_y_end - y_start, gui_list->nb_items,
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list->start_item,
|
2006-11-01 12:03:27 +00:00
|
|
|
gui_list->start_item + lines, VERTICAL);
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
2007-03-03 13:42:12 +00:00
|
|
|
screen_set_xmargin(display, old_margin);
|
2006-08-15 12:23:55 +00:00
|
|
|
#endif
|
2006-08-23 20:02:06 +00:00
|
|
|
|
2005-11-01 23:56:03 +00:00
|
|
|
gui_textarea_update(display);
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
/*
|
|
|
|
* Selects an item in the list
|
|
|
|
* - gui_list : the list structure
|
|
|
|
* - item_number : the number of the item which will be selected
|
|
|
|
*/
|
|
|
|
static void gui_list_select_item(struct gui_list * gui_list, int item_number)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
if( item_number > gui_list->nb_items-1 || item_number < 0 )
|
|
|
|
return;
|
|
|
|
gui_list->selected_item = item_number;
|
|
|
|
gui_list_put_selection_in_screen(gui_list, false);
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
/*
|
|
|
|
* Selects the next item in the list
|
|
|
|
* (Item 0 gets selected if the end of the list is reached)
|
|
|
|
* - gui_list : the list structure
|
|
|
|
*/
|
|
|
|
static void gui_list_select_next(struct gui_list * gui_list)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2006-07-02 12:28:27 +00:00
|
|
|
if( gui_list->selected_item+gui_list->selected_size >= gui_list->nb_items )
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2005-10-28 23:52:49 +00:00
|
|
|
if(gui_list->limit_scroll)
|
|
|
|
return;
|
2005-10-28 00:00:00 +00:00
|
|
|
/* we have already reached the bottom of the list */
|
|
|
|
gui_list->selected_item = 0;
|
|
|
|
gui_list->start_item = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-07-02 12:28:27 +00:00
|
|
|
gui_list->selected_item+=gui_list->selected_size;
|
2005-10-28 23:52:49 +00:00
|
|
|
int nb_lines = gui_list->display->nb_lines;
|
2006-12-09 12:27:04 +00:00
|
|
|
if (SHOW_LIST_TITLE)
|
2006-08-15 08:14:46 +00:00
|
|
|
nb_lines--;
|
2006-07-02 12:28:27 +00:00
|
|
|
int item_pos = gui_list->selected_item - gui_list->start_item;
|
|
|
|
int end_item = gui_list->start_item + nb_lines;
|
2006-08-15 08:14:46 +00:00
|
|
|
|
2006-02-13 19:39:48 +00:00
|
|
|
if (global_settings.scroll_paginated)
|
|
|
|
{
|
|
|
|
/* When we reach the bottom of the list
|
|
|
|
* we jump to a new page if there are more items*/
|
2006-12-09 10:02:09 +00:00
|
|
|
if( (item_pos > nb_lines-gui_list->selected_size) &&
|
|
|
|
(end_item < gui_list->nb_items) )
|
2006-02-13 20:48:44 +00:00
|
|
|
{
|
2006-02-13 19:39:48 +00:00
|
|
|
gui_list->start_item = gui_list->selected_item;
|
2006-02-13 20:48:44 +00:00
|
|
|
if ( gui_list->start_item > gui_list->nb_items-nb_lines )
|
|
|
|
gui_list->start_item = gui_list->nb_items-nb_lines;
|
|
|
|
}
|
2006-02-13 19:39:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* we start scrolling vertically when reaching the line
|
|
|
|
* (nb_lines-SCROLL_LIMIT)
|
|
|
|
* and when we are not in the last part of the list*/
|
2006-12-09 10:02:09 +00:00
|
|
|
if( (item_pos > nb_lines-SCROLL_LIMIT) &&
|
|
|
|
(end_item < gui_list->nb_items) )
|
2006-07-02 12:28:27 +00:00
|
|
|
gui_list->start_item+=gui_list->selected_size;
|
2006-02-13 19:39:48 +00:00
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
/*
|
|
|
|
* Selects the previous item in the list
|
|
|
|
* (Last item in the list gets selected if the list beginning is reached)
|
|
|
|
* - gui_list : the list structure
|
|
|
|
*/
|
|
|
|
static void gui_list_select_previous(struct gui_list * gui_list)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2006-08-15 14:06:29 +00:00
|
|
|
int nb_lines = gui_list->display->nb_lines;
|
2006-12-09 12:27:04 +00:00
|
|
|
if (SHOW_LIST_TITLE)
|
2006-08-15 14:06:29 +00:00
|
|
|
nb_lines--;
|
2006-07-02 12:28:27 +00:00
|
|
|
if( gui_list->selected_item-gui_list->selected_size < 0 )
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2005-10-28 23:52:49 +00:00
|
|
|
if(gui_list->limit_scroll)
|
|
|
|
return;
|
2005-10-28 00:00:00 +00:00
|
|
|
/* we have aleady reached the top of the list */
|
|
|
|
int start;
|
2006-07-02 12:28:27 +00:00
|
|
|
gui_list->selected_item = gui_list->nb_items-gui_list->selected_size;
|
2005-10-28 00:00:00 +00:00
|
|
|
start = gui_list->nb_items-nb_lines;
|
|
|
|
if( start < 0 )
|
|
|
|
gui_list->start_item = 0;
|
|
|
|
else
|
|
|
|
gui_list->start_item = start;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-11-01 23:56:03 +00:00
|
|
|
int item_pos;
|
2006-07-02 12:28:27 +00:00
|
|
|
gui_list->selected_item-=gui_list->selected_size;
|
2005-10-28 00:00:00 +00:00
|
|
|
item_pos = gui_list->selected_item - gui_list->start_item;
|
2006-02-13 19:39:48 +00:00
|
|
|
if (global_settings.scroll_paginated)
|
|
|
|
{
|
|
|
|
/* When we reach the top of the list
|
|
|
|
* we jump to a new page if there are more items*/
|
2006-07-02 12:28:27 +00:00
|
|
|
if( item_pos < 0)
|
2006-12-09 10:02:09 +00:00
|
|
|
gui_list->start_item = gui_list->selected_item - nb_lines +
|
|
|
|
gui_list->selected_size;
|
2006-02-13 19:39:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* we start scrolling vertically when reaching the line
|
|
|
|
* (nb_lines-SCROLL_LIMIT)
|
|
|
|
* and when we are not in the last part of the list*/
|
2006-07-02 12:28:27 +00:00
|
|
|
if( item_pos < SCROLL_LIMIT-1)
|
|
|
|
gui_list->start_item-=gui_list->selected_size;
|
2006-02-13 19:39:48 +00:00
|
|
|
}
|
2006-07-02 12:28:27 +00:00
|
|
|
if( gui_list->start_item < 0 )
|
|
|
|
gui_list->start_item = 0;
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
/*
|
|
|
|
* Go to next page if any, else selects the last item in the list
|
|
|
|
* - gui_list : the list structure
|
|
|
|
* - nb_lines : the number of lines to try to move the cursor
|
|
|
|
*/
|
|
|
|
static void gui_list_select_next_page(struct gui_list * gui_list, int nb_lines)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2006-07-02 12:28:27 +00:00
|
|
|
if(gui_list->selected_item == gui_list->nb_items-gui_list->selected_size)
|
2005-10-28 23:52:49 +00:00
|
|
|
{
|
|
|
|
if(gui_list->limit_scroll)
|
|
|
|
return;
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list->selected_item = 0;
|
2005-10-28 23:52:49 +00:00
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
else
|
|
|
|
{
|
2006-12-09 12:27:04 +00:00
|
|
|
if (SHOW_LIST_TITLE)
|
2006-08-15 08:14:46 +00:00
|
|
|
nb_lines--;
|
2006-07-02 12:28:27 +00:00
|
|
|
nb_lines-=nb_lines%gui_list->selected_size;
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list->selected_item += nb_lines;
|
|
|
|
if(gui_list->selected_item > gui_list->nb_items-1)
|
|
|
|
gui_list->selected_item = gui_list->nb_items-1;
|
|
|
|
}
|
|
|
|
gui_list_put_selection_in_screen(gui_list, true);
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
/*
|
|
|
|
* Go to previous page if any, else selects the first item in the list
|
|
|
|
* - gui_list : the list structure
|
|
|
|
* - nb_lines : the number of lines to try to move the cursor
|
|
|
|
*/
|
|
|
|
static void gui_list_select_previous_page(struct gui_list * gui_list, int nb_lines)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
if(gui_list->selected_item == 0)
|
2005-10-28 23:52:49 +00:00
|
|
|
{
|
|
|
|
if(gui_list->limit_scroll)
|
|
|
|
return;
|
2006-07-02 12:28:27 +00:00
|
|
|
gui_list->selected_item = gui_list->nb_items - gui_list->selected_size;
|
2005-10-28 23:52:49 +00:00
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
else
|
|
|
|
{
|
2006-12-09 12:27:04 +00:00
|
|
|
if (SHOW_LIST_TITLE)
|
2006-08-15 08:14:46 +00:00
|
|
|
nb_lines--;
|
2006-07-02 12:28:27 +00:00
|
|
|
nb_lines-=nb_lines%gui_list->selected_size;
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list->selected_item -= nb_lines;
|
|
|
|
if(gui_list->selected_item < 0)
|
|
|
|
gui_list->selected_item = 0;
|
|
|
|
}
|
|
|
|
gui_list_put_selection_in_screen(gui_list, false);
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
/*
|
|
|
|
* Adds an item to the list (the callback will be asked for one more item)
|
|
|
|
* - gui_list : the list structure
|
|
|
|
*/
|
|
|
|
static void gui_list_add_item(struct gui_list * gui_list)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2005-10-29 02:33:19 +00:00
|
|
|
gui_list->nb_items++;
|
2005-10-28 00:00:00 +00:00
|
|
|
/* if only one item in the list, select it */
|
|
|
|
if(gui_list->nb_items == 1)
|
|
|
|
gui_list->selected_item = 0;
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
/*
|
|
|
|
* Removes an item to the list (the callback will be asked for one less item)
|
|
|
|
* - gui_list : the list structure
|
|
|
|
*/
|
|
|
|
static void gui_list_del_item(struct gui_list * gui_list)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
if(gui_list->nb_items > 0)
|
|
|
|
{
|
2005-11-01 23:56:03 +00:00
|
|
|
gui_textarea_update_nblines(gui_list->display);
|
|
|
|
int nb_lines = gui_list->display->nb_lines;
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
int dist_selected_from_end = gui_list->nb_items
|
|
|
|
- gui_list->selected_item - 1;
|
|
|
|
int dist_start_from_end = gui_list->nb_items
|
|
|
|
- gui_list->start_item - 1;
|
|
|
|
if(dist_selected_from_end == 0)
|
|
|
|
{
|
|
|
|
/* Oops we are removing the selected item,
|
|
|
|
select the previous one */
|
2005-10-29 02:33:19 +00:00
|
|
|
gui_list->selected_item--;
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
2005-10-29 02:33:19 +00:00
|
|
|
gui_list->nb_items--;
|
2005-10-28 23:52:49 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/* scroll the list if needed */
|
|
|
|
if( (dist_start_from_end < nb_lines) && (gui_list->start_item != 0) )
|
2005-10-29 02:33:19 +00:00
|
|
|
gui_list->start_item--;
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-22 04:24:26 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2007-02-23 21:52:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Makes all the item in the list scroll by one step to the right.
|
|
|
|
* Should stop increasing the value when reaching the widest item value
|
|
|
|
* in the list.
|
|
|
|
*/
|
|
|
|
static void gui_list_scroll_right(struct gui_list * gui_list)
|
2006-01-22 04:24:26 +00:00
|
|
|
{
|
|
|
|
/* FIXME: This is a fake right boundry limiter. there should be some
|
|
|
|
* callback function to find the longest item on the list in pixels,
|
|
|
|
* to stop the list from scrolling past that point */
|
|
|
|
gui_list->offset_position+=offset_step;
|
|
|
|
if (gui_list->offset_position > 1000)
|
|
|
|
gui_list->offset_position = 1000;
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
/*
|
|
|
|
* Makes all the item in the list scroll by one step to the left.
|
|
|
|
* stops at starting position.
|
|
|
|
*/
|
|
|
|
static void gui_list_scroll_left(struct gui_list * gui_list)
|
2006-01-22 04:24:26 +00:00
|
|
|
{
|
|
|
|
gui_list->offset_position-=offset_step;
|
|
|
|
if (gui_list->offset_position < 0)
|
|
|
|
gui_list->offset_position = 0;
|
|
|
|
}
|
|
|
|
void gui_list_screen_scroll_step(int ofs)
|
|
|
|
{
|
|
|
|
offset_step = ofs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_list_screen_scroll_out_of_view(bool enable)
|
|
|
|
{
|
|
|
|
if (enable)
|
|
|
|
offset_out_of_view = true;
|
|
|
|
else
|
|
|
|
offset_out_of_view = false;
|
|
|
|
}
|
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
2006-08-15 12:23:55 +00:00
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
/*
|
|
|
|
* Set the title and title icon of the list. Setting title to NULL disables
|
|
|
|
* both the title and icon. Use NOICON if there is no icon.
|
|
|
|
*/
|
|
|
|
static void gui_list_set_title(struct gui_list * gui_list, char * title, ICON icon)
|
2006-08-15 08:14:46 +00:00
|
|
|
{
|
|
|
|
gui_list->title = title;
|
2006-08-23 20:02:06 +00:00
|
|
|
gui_list->title_icon = icon;
|
2006-08-15 22:14:35 +00:00
|
|
|
if (title) {
|
2006-08-15 12:23:55 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-08-15 22:14:35 +00:00
|
|
|
gui_list->display->getstringsize(title, &gui_list->title_width, NULL);
|
2006-08-15 12:23:55 +00:00
|
|
|
#else
|
2006-08-15 22:14:35 +00:00
|
|
|
gui_list->title_width = strlen(title);
|
2006-08-15 12:23:55 +00:00
|
|
|
#endif
|
2006-08-15 22:14:35 +00:00
|
|
|
} else {
|
|
|
|
gui_list->title_width = 0;
|
|
|
|
}
|
2006-08-15 08:14:46 +00:00
|
|
|
}
|
2006-08-15 12:23:55 +00:00
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
/*
|
|
|
|
* Synchronized lists stuffs
|
|
|
|
*/
|
|
|
|
void gui_synclist_init(
|
|
|
|
struct gui_synclist * lists,
|
2005-11-16 02:12:25 +00:00
|
|
|
list_get_name callback_get_item_name,
|
2006-07-02 12:28:27 +00:00
|
|
|
void * data,
|
|
|
|
bool scroll_all,
|
|
|
|
int selected_size
|
2005-10-28 00:00:00 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2005-10-29 02:33:19 +00:00
|
|
|
gui_list_init(&(lists->gui_list[i]),
|
|
|
|
callback_get_item_name,
|
2006-07-02 12:28:27 +00:00
|
|
|
data, scroll_all, selected_size);
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list_set_display(&(lists->gui_list[i]), &(screens[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items)
|
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
gui_list_set_nb_items(&(lists->gui_list[i]), nb_items);
|
2006-01-22 04:24:26 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
lists->gui_list[i].offset_position = 0;
|
|
|
|
#endif
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-03 08:51:08 +00:00
|
|
|
int gui_synclist_get_nb_items(struct gui_synclist * lists)
|
|
|
|
{
|
|
|
|
return gui_list_get_nb_items(&((lists)->gui_list[0]));
|
|
|
|
}
|
|
|
|
int gui_synclist_get_sel_pos(struct gui_synclist * lists)
|
|
|
|
{
|
|
|
|
return gui_list_get_sel_pos(&((lists)->gui_list[0]));
|
|
|
|
}
|
2006-12-09 10:02:09 +00:00
|
|
|
void gui_synclist_set_icon_callback(struct gui_synclist * lists,
|
|
|
|
list_get_icon icon_callback)
|
2005-11-16 17:23:49 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
gui_list_set_icon_callback(&(lists->gui_list[i]), icon_callback);
|
|
|
|
}
|
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
|
|
|
|
void gui_synclist_draw(struct gui_synclist * lists)
|
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list_draw(&(lists->gui_list[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_synclist_select_item(struct gui_synclist * lists, int item_number)
|
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list_select_item(&(lists->gui_list[i]), item_number);
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
static void gui_synclist_select_next(struct gui_synclist * lists)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list_select_next(&(lists->gui_list[i]));
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
static void gui_synclist_select_previous(struct gui_synclist * lists)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list_select_previous(&(lists->gui_list[i]));
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
static void gui_synclist_select_next_page(struct gui_synclist * lists,
|
2005-10-28 00:00:00 +00:00
|
|
|
enum screen_type screen)
|
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list_select_next_page(&(lists->gui_list[i]),
|
|
|
|
screens[screen].nb_lines);
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
static void gui_synclist_select_previous_page(struct gui_synclist * lists,
|
2005-10-28 00:00:00 +00:00
|
|
|
enum screen_type screen)
|
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list_select_previous_page(&(lists->gui_list[i]),
|
|
|
|
screens[screen].nb_lines);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_synclist_add_item(struct gui_synclist * lists)
|
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list_add_item(&(lists->gui_list[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_synclist_del_item(struct gui_synclist * lists)
|
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_list_del_item(&(lists->gui_list[i]));
|
|
|
|
}
|
|
|
|
|
2005-10-28 23:52:49 +00:00
|
|
|
void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll)
|
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-10-28 23:52:49 +00:00
|
|
|
gui_list_limit_scroll(&(lists->gui_list[i]), scroll);
|
|
|
|
}
|
|
|
|
|
2006-12-09 10:02:09 +00:00
|
|
|
void gui_synclist_set_title(struct gui_synclist * lists,
|
|
|
|
char * title, ICON icon)
|
2006-08-15 08:14:46 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
FOR_NB_SCREENS(i)
|
2006-08-23 20:02:06 +00:00
|
|
|
gui_list_set_title(&(lists->gui_list[i]), title, icon);
|
2006-08-15 08:14:46 +00:00
|
|
|
}
|
|
|
|
|
2005-11-09 01:17:57 +00:00
|
|
|
void gui_synclist_flash(struct gui_synclist * lists)
|
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-11-09 01:17:57 +00:00
|
|
|
gui_list_flash(&(lists->gui_list[i]));
|
|
|
|
}
|
|
|
|
|
2006-01-22 04:24:26 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2007-02-23 21:52:45 +00:00
|
|
|
static void gui_synclist_scroll_right(struct gui_synclist * lists)
|
2006-01-22 04:24:26 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
gui_list_scroll_right(&(lists->gui_list[i]));
|
|
|
|
}
|
|
|
|
|
2007-02-23 21:52:45 +00:00
|
|
|
static void gui_synclist_scroll_left(struct gui_synclist * lists)
|
2006-01-22 04:24:26 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
gui_list_scroll_left(&(lists->gui_list[i]));
|
|
|
|
}
|
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
|
|
|
|
2006-11-06 10:11:51 +00:00
|
|
|
unsigned gui_synclist_do_button(struct gui_synclist * lists,
|
|
|
|
unsigned button,enum list_wrap wrap)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
2006-09-25 11:06:54 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-09-25 10:56:38 +00:00
|
|
|
static bool scrolling_left = false;
|
2006-09-25 11:06:54 +00:00
|
|
|
#endif
|
2006-09-25 10:56:38 +00:00
|
|
|
|
2006-11-06 10:11:51 +00:00
|
|
|
switch (wrap)
|
|
|
|
{
|
|
|
|
case LIST_WRAP_ON:
|
|
|
|
gui_synclist_limit_scroll(lists, false);
|
|
|
|
break;
|
|
|
|
case LIST_WRAP_OFF:
|
|
|
|
gui_synclist_limit_scroll(lists, true);
|
|
|
|
break;
|
|
|
|
case LIST_WRAP_UNLESS_HELD:
|
|
|
|
if (button == ACTION_STD_PREVREPEAT ||
|
|
|
|
button == ACTION_STD_NEXTREPEAT)
|
|
|
|
gui_synclist_limit_scroll(lists, true);
|
|
|
|
else gui_synclist_limit_scroll(lists, false);
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
2005-10-28 00:00:00 +00:00
|
|
|
switch(button)
|
|
|
|
{
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_PREV:
|
|
|
|
case ACTION_STD_PREVREPEAT:
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_synclist_select_previous(lists);
|
|
|
|
gui_synclist_draw(lists);
|
2006-02-19 13:34:12 +00:00
|
|
|
yield();
|
2006-08-15 12:27:07 +00:00
|
|
|
return ACTION_STD_PREV;
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_NEXT:
|
|
|
|
case ACTION_STD_NEXTREPEAT:
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_synclist_select_next(lists);
|
|
|
|
gui_synclist_draw(lists);
|
2006-02-19 13:34:12 +00:00
|
|
|
yield();
|
2006-08-15 12:27:07 +00:00
|
|
|
return ACTION_STD_NEXT;
|
2006-01-22 04:24:26 +00:00
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-09-25 10:56:38 +00:00
|
|
|
case ACTION_TREE_ROOT_INIT:
|
2006-12-09 10:02:09 +00:00
|
|
|
/* After this button press ACTION_TREE_PGLEFT is allowed
|
|
|
|
to skip to root. ACTION_TREE_ROOT_INIT must be defined in the
|
|
|
|
keymaps as a repeated button press (the same as the repeated
|
|
|
|
ACTION_TREE_PGLEFT) with the pre condition being the non-repeated
|
|
|
|
button press */
|
2006-09-25 10:56:38 +00:00
|
|
|
if (lists->gui_list[0].offset_position == 0)
|
|
|
|
{
|
|
|
|
scrolling_left = false;
|
|
|
|
return ACTION_STD_CANCEL;
|
|
|
|
}
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_TREE_PGRIGHT:
|
2006-07-02 12:28:27 +00:00
|
|
|
gui_synclist_scroll_right(lists);
|
|
|
|
gui_synclist_draw(lists);
|
2006-08-15 12:27:07 +00:00
|
|
|
return ACTION_TREE_PGRIGHT;
|
|
|
|
case ACTION_TREE_PGLEFT:
|
2006-09-25 10:56:38 +00:00
|
|
|
if(!scrolling_left && (lists->gui_list[0].offset_position == 0))
|
2006-09-17 08:30:17 +00:00
|
|
|
return ACTION_STD_CANCEL;
|
2006-07-02 12:28:27 +00:00
|
|
|
gui_synclist_scroll_left(lists);
|
|
|
|
gui_synclist_draw(lists);
|
2006-12-09 10:02:09 +00:00
|
|
|
scrolling_left = true; /* stop ACTION_TREE_PAGE_LEFT
|
|
|
|
skipping to root */
|
2006-08-15 12:27:07 +00:00
|
|
|
return ACTION_TREE_PGLEFT;
|
2006-01-22 01:42:05 +00:00
|
|
|
#endif
|
|
|
|
|
2006-12-09 10:02:09 +00:00
|
|
|
/* 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 */
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_LISTTREE_PGUP:
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_synclist_select_previous_page(lists, SCREEN_MAIN);
|
|
|
|
gui_synclist_draw(lists);
|
2006-06-04 17:14:17 +00:00
|
|
|
yield();
|
2006-08-15 12:27:07 +00:00
|
|
|
return ACTION_STD_NEXT;
|
|
|
|
|
|
|
|
case ACTION_LISTTREE_PGDOWN:
|
|
|
|
gui_synclist_select_next_page(lists, SCREEN_MAIN);
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_synclist_draw(lists);
|
2006-06-04 17:14:17 +00:00
|
|
|
yield();
|
2006-08-15 12:27:07 +00:00
|
|
|
return ACTION_STD_PREV;
|
2007-02-17 21:54:17 +00:00
|
|
|
#ifdef REMOTE_BUTTON
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_LISTTREE_RC_PGUP:
|
|
|
|
gui_synclist_select_previous_page(lists, SCREEN_REMOTE);
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_synclist_draw(lists);
|
2006-06-04 17:14:17 +00:00
|
|
|
yield();
|
2006-08-15 12:27:07 +00:00
|
|
|
return ACTION_STD_NEXT;
|
|
|
|
|
|
|
|
case ACTION_LISTTREE_RC_PGDOWN:
|
2005-10-28 00:00:00 +00:00
|
|
|
gui_synclist_select_next_page(lists, SCREEN_REMOTE);
|
|
|
|
gui_synclist_draw(lists);
|
2006-06-04 17:14:17 +00:00
|
|
|
yield();
|
2006-08-15 12:27:07 +00:00
|
|
|
return ACTION_STD_PREV;
|
2005-10-28 00:00:00 +00:00
|
|
|
#endif
|
|
|
|
}
|
2005-11-16 02:12:25 +00:00
|
|
|
return 0;
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|