summaryrefslogtreecommitdiffstats
path: root/apps/gui
diff options
context:
space:
mode:
authorKevin Ferrare <kevin@rockbox.org>2005-11-01 23:56:03 +0000
committerKevin Ferrare <kevin@rockbox.org>2005-11-01 23:56:03 +0000
commit4158ba1ff13d623ee32b91efedd4d1d2212543e4 (patch)
treecccb8c9a6080876bfed126604e1057e627368b1a /apps/gui
parent0b19487898b779b60de8f07ff1a52ef515b8d072 (diff)
downloadrockbox-4158ba1ff13d623ee32b91efedd4d1d2212543e4.tar.gz
rockbox-4158ba1ff13d623ee32b91efedd4d1d2212543e4.zip
Changed back the copyright's name in onplay.c (silly UTF-8, sorry Björn ! ), changed the internal multi-screen API a little bit, in a cleaner way
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7716 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/list.c45
-rw-r--r--apps/gui/textarea.c65
-rw-r--r--apps/gui/textarea.h81
3 files changed, 162 insertions, 29 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 998e7b9522..d566dabfbb 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -29,6 +29,7 @@
#include "list.h"
#include "scrollbar.h"
#include "statusbar.h"
+#include "textarea.h"
#ifdef HAVE_LCD_CHARCELLS
#define SCROLL_LIMIT 1
@@ -70,6 +71,7 @@ void gui_list_set_display(struct gui_list * gui_list, struct screen * display)
void gui_list_put_selection_in_screen(struct gui_list * gui_list,
bool put_from_end)
{
+ gui_textarea_update_nblines(gui_list->display);
int nb_lines=gui_list->display->nb_lines;
if(put_from_end)
{
@@ -103,12 +105,9 @@ void gui_list_draw(struct gui_list * gui_list)
/* Adjust the position of icon, cursor, text */
#ifdef HAVE_LCD_BITMAP
display->setfont(FONT_UI);
- screen_update_nblines(display);
+ gui_textarea_update_nblines(display);
bool draw_scrollbar = (global_settings.scrollbar &&
display->nb_lines < gui_list->nb_items);
- int list_y_start = screen_get_text_y_start(gui_list->display);
- int list_y_end = screen_get_text_y_end(gui_list->display);
-
draw_cursor = !global_settings.invert_cursor;
text_pos = 0; /* here it's in pixels */
if(draw_scrollbar)
@@ -133,18 +132,10 @@ void gui_list_draw(struct gui_list * gui_list)
else
text_pos = 1;
#endif
- /* The drawing part */
+
+ gui_textarea_clear(display);
#ifdef HAVE_LCD_BITMAP
- /* clear the drawing area */
- display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
- display->fillrect(0, list_y_start,
- display->width, list_y_end - list_y_start);
- display->set_drawmode(DRMODE_SOLID);
-
- display->stop_scroll();
- display->setmargins(text_pos, list_y_start);
-#else
- display->clear_display();
+ screen_set_xmargin(display, text_pos);
#endif
for(i = 0;i < display->nb_lines;i++)
@@ -197,20 +188,16 @@ void gui_list_draw(struct gui_list * gui_list)
/* Draw the scrollbar if needed*/
if(draw_scrollbar)
{
+ int y_start = gui_textarea_get_ystart(display);
int scrollbar_y_end = display->char_height *
- display->nb_lines + list_y_start;
- gui_scrollbar_draw(display, 0, list_y_start, SCROLLBAR_WIDTH-1,
- scrollbar_y_end - list_y_start, gui_list->nb_items,
+ display->nb_lines + y_start;
+ gui_scrollbar_draw(display, 0, y_start, SCROLLBAR_WIDTH-1,
+ scrollbar_y_end - y_start, gui_list->nb_items,
gui_list->start_item,
gui_list->start_item + display->nb_lines, VERTICAL);
}
- display->update_rect(0, list_y_start, display->width,
- list_y_end - list_y_start);
-#else
-#ifdef SIMULATOR
- display->update();
-#endif
#endif
+ gui_textarea_update(display);
}
void gui_list_select_item(struct gui_list * gui_list, int item_number)
@@ -251,11 +238,9 @@ void gui_list_select_next(struct gui_list * gui_list)
void gui_list_select_previous(struct gui_list * gui_list)
{
- int item_pos;
- int nb_lines = gui_list->display->nb_lines;
-
if( gui_list->selected_item == 0 )
{
+ int nb_lines = gui_list->display->nb_lines;
if(gui_list->limit_scroll)
return;
gui_list->selected_item--;
@@ -270,6 +255,7 @@ void gui_list_select_previous(struct gui_list * gui_list)
}
else
{
+ int item_pos;
gui_list->selected_item--;
item_pos = gui_list->selected_item - gui_list->start_item;
if( item_pos < SCROLL_LIMIT-1 && gui_list->start_item > 0 )
@@ -321,10 +307,11 @@ void gui_list_add_item(struct gui_list * gui_list)
void gui_list_del_item(struct gui_list * gui_list)
{
- int nb_lines = gui_list->display->nb_lines;
-
if(gui_list->nb_items > 0)
{
+ gui_textarea_update_nblines(gui_list->display);
+ int nb_lines = gui_list->display->nb_lines;
+
int dist_selected_from_end = gui_list->nb_items
- gui_list->selected_item - 1;
int dist_start_from_end = gui_list->nb_items
diff --git a/apps/gui/textarea.c b/apps/gui/textarea.c
new file mode 100644
index 0000000000..c49602611f
--- /dev/null
+++ b/apps/gui/textarea.c
@@ -0,0 +1,65 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2005 by Kevin Ferrare
+ *
+ * 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 "textarea.h"
+
+void gui_textarea_clear(struct screen * display)
+{
+#ifdef HAVE_LCD_BITMAP
+ int y_start = gui_textarea_get_ystart(display);
+ int y_end = gui_textarea_get_yend(display);
+
+ display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
+ display->fillrect(0, y_start, display->width, y_end - y_start);
+ display->set_drawmode(DRMODE_SOLID);
+ display->stop_scroll();
+ screen_set_ymargin(display, y_start);
+#else
+ display->clear_display();
+#endif
+}
+
+#ifdef HAVE_LCD_BITMAP
+void gui_textarea_update(struct screen * display)
+{
+ int y_start = gui_textarea_get_ystart(display);
+ int y_end = gui_textarea_get_yend(display);
+ display->update_rect(0, y_start, display->width, y_end - y_start);
+}
+#endif
+
+void gui_textarea_update_nblines(struct screen * display)
+{
+#ifdef HAVE_LCD_BITMAP
+ int height=display->height;
+ if(global_settings.statusbar)
+ height -= STATUSBAR_HEIGHT;
+#ifdef HAS_BUTTONBAR
+ if(global_settings.buttonbar && display->has_buttonbar)
+ height -= BUTTONBAR_HEIGHT;
+#endif
+ display->getstringsize("A", &display->char_width, &display->char_height);
+ display->nb_lines = height / display->char_height;
+#else
+ display->char_width = 1;
+ display->char_height = 1;
+ /* default on char based player supported by rb */
+ display->nb_lines = MAX_LINES_ON_SCREEN;
+#endif
+}
diff --git a/apps/gui/textarea.h b/apps/gui/textarea.h
new file mode 100644
index 0000000000..5249aed7a5
--- /dev/null
+++ b/apps/gui/textarea.h
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2005 by Kevin Ferrare
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef _GUI_TEXTAREA_H_
+#define _GUI_TEXTAREA_H_
+#include "screen_access.h"
+#include "settings.h"
+#include "statusbar.h"
+
+/*
+ * Clears the area in the screen in which text can be displayed
+ * and sets the y margin properly
+ * - display : the screen structure
+ */
+extern void gui_textarea_clear(struct screen * display);
+
+/*
+ * Updates the area in the screen in which text can be displayed
+ * - display : the screen structure
+ */
+#ifdef HAVE_LCD_BITMAP
+extern void gui_textarea_update(struct screen * display);
+#else
+#ifdef SIMULATOR
+#define gui_textarea_update(display) \
+ (display)->update();
+#else
+#define gui_textarea_update(display)
+#endif
+#endif
+
+/*
+ * Compute the number of text lines the display can draw with the current font
+ * Also updates the char height and width
+ * - display : the screen structure
+ */
+extern void gui_textarea_update_nblines(struct screen * display);
+
+#ifdef HAVE_LCD_BITMAP
+/*
+ * Compute the number of pixels from which text can be displayed
+ * - display : the screen structure
+ * Returns the number of pixels
+ */
+#define gui_textarea_get_ystart(display) \
+ ( (global_settings.statusbar)? STATUSBAR_HEIGHT : 0)
+
+/*
+ * Compute the number of pixels below which text can't be displayed
+ * - display : the screen structure
+ * Returns the number of pixels
+ */
+#ifdef HAS_BUTTONBAR
+#define gui_textarea_get_yend(display) \
+ ( (display)->height - ( (global_settings.buttonbar && \
+ (display)->has_buttonbar)? \
+ BUTTONBAR_HEIGHT : 0) )
+#else
+#define gui_textarea_get_yend(display) \
+ ( (display)->height )
+#endif /* HAS_BUTTONBAR */
+
+#endif /* HAVE_LCD_BITMAP */
+
+#endif /* _GUI_TEXTAREA_H_ */