Various fixes to fix rendering of text. There will always be 3 lines of log shown. The menu can have long items in it now, rather than being truncated. The log text will be bottom aligned.

Change-Id: I09289e053c8ab673814318da55302efaab0404de

derp

Change-Id: I3fc31f5ea311c73c0ec999aa77d3fa0d01238001
This commit is contained in:
Koushik Dutta 2012-01-26 22:56:00 -08:00
parent ccc1fdb386
commit 3cdfd138fa

34
ui.c
View File

@ -33,6 +33,8 @@
#include "minui/minui.h"
#include "recovery_ui.h"
#include "touch.h"
extern int __system(const char *command);
#ifdef BOARD_HAS_NO_SELECT_BUTTON
@ -47,6 +49,8 @@ static int gShowBackButton = 0;
#define MENU_MAX_COLS 64
#define MENU_MAX_ROWS 250
#define MIN_LOG_ROWS 3
#define CHAR_WIDTH BOARD_RECOVERY_CHAR_WIDTH
#define CHAR_HEIGHT BOARD_RECOVERY_CHAR_HEIGHT
@ -106,6 +110,7 @@ static char menu[MENU_MAX_ROWS][MENU_MAX_COLS];
static int show_menu = 0;
static int menu_top = 0, menu_items = 0, menu_sel = 0;
static int menu_show_start = 0; // this is line which menu display is starting at
static int max_menu_rows;
// Key event input queue
static pthread_mutex_t key_queue_mutex = PTHREAD_MUTEX_INITIALIZER;
@ -219,6 +224,7 @@ static void draw_screen_locked(void)
gr_color(0, 0, 0, 160);
gr_fill(0, 0, gr_fb_width(), gr_fb_height());
int total_rows = gr_fb_height() / CHAR_HEIGHT;
int i = 0;
int j = 0;
int offset = 0; // offset of separating bar under menus
@ -250,6 +256,8 @@ static void draw_screen_locked(void)
draw_text_line(i - menu_show_start, menu[i]);
}
row++;
if (row == max_menu_rows)
break;
}
if (menu_items <= MAX_ROWS)
@ -260,8 +268,17 @@ static void draw_screen_locked(void)
}
gr_color(NORMAL_TEXT_COLOR);
for (; row < text_rows; ++row) {
draw_text_line(row, text[(row+text_top) % text_rows]);
int cur_row = text_row;
int available_rows = total_rows - row - 1;
int start_row = row + 1;
if (available_rows < MAX_ROWS)
cur_row = (cur_row + (MAX_ROWS - available_rows)) % MAX_ROWS;
else
start_row = total_rows - MAX_ROWS;
int r;
for (r = 0; r < (available_rows < MAX_ROWS ? available_rows : MAX_ROWS); r++) {
draw_text_line(start_row + r, text[(cur_row + r) % MAX_ROWS]);
}
}
}
@ -351,6 +368,9 @@ static int input_callback(int fd, short revents, void *data)
if (ret)
return -1;
if (touch_handle_input(ev))
return 0;
if (ev.type == EV_SYN) {
return 0;
} else if (ev.type == EV_REL) {
@ -425,9 +445,11 @@ void ui_init(void)
ui_has_initialized = 1;
gr_init();
ev_init(input_callback, NULL);
touch_init(gr_fb_width(), gr_fb_height(), key_pressed, key_queue, &key_queue_len, &key_queue_mutex, &key_queue_cond);
text_col = text_row = 0;
text_rows = gr_fb_height() / CHAR_HEIGHT;
max_menu_rows = text_rows - MIN_LOG_ROWS;
if (text_rows > MAX_ROWS) text_rows = MAX_ROWS;
text_top = 1;
@ -637,8 +659,8 @@ int ui_start_menu(char** headers, char** items, int initial_selection) {
for (; i < MENU_MAX_ROWS; ++i) {
if (items[i-menu_top] == NULL) break;
strcpy(menu[i], MENU_ITEM_HEADER);
strncpy(menu[i] + MENU_ITEM_HEADER_LENGTH, items[i-menu_top], text_cols-1 - MENU_ITEM_HEADER_LENGTH);
menu[i][text_cols-1] = '\0';
strncpy(menu[i] + MENU_ITEM_HEADER_LENGTH, items[i-menu_top], MENU_MAX_COLS - 1 - MENU_ITEM_HEADER_LENGTH);
menu[i][MENU_MAX_COLS-1] = '\0';
}
if (gShowBackButton && ui_menu_level > 0) {
@ -676,8 +698,8 @@ int ui_menu_select(int sel) {
menu_show_start = menu_sel;
}
if (menu_sel - menu_show_start + menu_top >= text_rows) {
menu_show_start = menu_sel + menu_top - text_rows + 1;
if (menu_sel - menu_show_start + menu_top >= max_menu_rows) {
menu_show_start = menu_sel + menu_top - max_menu_rows + 1;
}
sel = menu_sel;