(RGUI) Cleanups

This commit is contained in:
twinaphex 2015-09-27 01:23:49 +02:00
parent 6ce4b96d12
commit e354200909

View File

@ -97,9 +97,9 @@ static uint16_t gray_filler(unsigned x, unsigned y)
{ {
unsigned col; unsigned col;
x >>= 1; x >>= 1;
y >>= 1; y >>= 1;
col = ((x + y) & 1) + 1; col = ((x + y) & 1) + 1;
#if defined(GEKKO) || defined(PSP) #if defined(GEKKO) || defined(PSP)
return (6 << 12) | (col << 8) | (col << 4) | (col << 0); return (6 << 12) | (col << 8) | (col << 4) | (col << 0);
@ -112,9 +112,9 @@ static uint16_t green_filler(unsigned x, unsigned y)
{ {
unsigned col; unsigned col;
x >>= 1; x >>= 1;
y >>= 1; y >>= 1;
col = ((x + y) & 1) + 1; col = ((x + y) & 1) + 1;
#if defined(GEKKO) || defined(PSP) #if defined(GEKKO) || defined(PSP)
return (6 << 12) | (col << 8) | (col << 5) | (col << 0); return (6 << 12) | (col << 8) | (col << 5) | (col << 0);
#else #else
@ -167,15 +167,20 @@ static uint32_t string_walk(const char **string)
uint8_t first = string_walkbyte(string); uint8_t first = string_walkbyte(string);
uint32_t ret; uint32_t ret;
if (first<128) return first; if (first<128)
return first;
ret = 0; ret = 0;
ret = (ret<<6) | (string_walkbyte(string)&0x3F); ret = (ret<<6) | (string_walkbyte(string) & 0x3F);
if (first >= 0xE0) ret = (ret<<6) | (string_walkbyte(string)&0x3F); if (first >= 0xE0)
if (first >= 0xF0) ret = (ret<<6) | (string_walkbyte(string)&0x3F); ret = (ret<<6) | (string_walkbyte(string) & 0x3F);
if (first >= 0xF0)
ret = (ret<<6) | (string_walkbyte(string) & 0x3F);
if (first >= 0xF0) return ret | (first&31)<<18; if (first >= 0xF0)
if (first >= 0xE0) return ret | (first&15)<<12; return ret | (first&31)<<18;
if (first >= 0xE0)
return ret | (first&15)<<12;
return ret | (first&7)<<6; return ret | (first&7)<<6;
} }
#else #else
@ -217,8 +222,8 @@ static void blit_line(uint16_t *data,
static bool init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf) static bool init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf)
{ {
unsigned i; unsigned i;
uint8_t *font = (uint8_t *) calloc(1, FONT_OFFSET(256));
bool fb_font_inited = true; bool fb_font_inited = true;
uint8_t *font = (uint8_t *)calloc(1, FONT_OFFSET(256));
if (!font) if (!font)
return false; return false;
@ -284,7 +289,6 @@ static void rgui_render_background(void)
dst += pitch_in_pixels * 4; dst += pitch_in_pixels * 4;
} }
fill_rect(fb_data, fb_pitch, 5, 5, fb_width - 10, 5, green_filler); fill_rect(fb_data, fb_pitch, 5, 5, fb_width - 10, 5, green_filler);
fill_rect(fb_data, fb_pitch, 5, fb_height - 10, fb_width - 10, 5, green_filler); fill_rect(fb_data, fb_pitch, 5, fb_height - 10, fb_width - 10, 5, green_filler);
@ -378,6 +382,7 @@ static void rgui_render_messagebox(const char *message)
const char *msg = list->elems[i].data; const char *msg = list->elems[i].data;
int offset_x = FONT_WIDTH_STRIDE * (glyphs_width - strlen(msg)) / 2; int offset_x = FONT_WIDTH_STRIDE * (glyphs_width - strlen(msg)) / 2;
int offset_y = FONT_HEIGHT_STRIDE * i; int offset_y = FONT_HEIGHT_STRIDE * i;
blit_line(fb_data, fb_pitch, blit_line(fb_data, fb_pitch,
x + 8 + offset_x, y + 8 + offset_y, msg, color); x + 8 + offset_x, y + 8 + offset_y, msg, color);
} }
@ -388,7 +393,7 @@ end:
static void rgui_blit_cursor(menu_handle_t *menu) static void rgui_blit_cursor(menu_handle_t *menu)
{ {
size_t fb_pitch; size_t fb_pitch;
unsigned fb_width, fb_height; unsigned fb_width, fb_height;
uint16_t *fb_data = NULL; uint16_t *fb_data = NULL;
int16_t x = menu_input_mouse_state(MENU_MOUSE_X_AXIS); int16_t x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
@ -473,7 +478,9 @@ static void rgui_render(void)
if (settings->menu.pointer.enable) if (settings->menu.pointer.enable)
{ {
bool pointer_dragged = false; bool pointer_dragged = false;
unsigned new_val = menu_input_pointer_state(MENU_POINTER_Y_AXIS) / 11 - 2 + menu_entries_get_start(); unsigned new_val = menu_input_pointer_state(MENU_POINTER_Y_AXIS)
/ 11 - 2 + menu_entries_get_start();
menu_input_ctl(MENU_INPUT_CTL_POINTER_PTR, &new_val); menu_input_ctl(MENU_INPUT_CTL_POINTER_PTR, &new_val);
menu_input_ctl(MENU_INPUT_CTL_POINTER_DRAGGING, &pointer_dragged); menu_input_ctl(MENU_INPUT_CTL_POINTER_DRAGGING, &pointer_dragged);
@ -541,8 +548,10 @@ static void rgui_render(void)
TITLE_COLOR(settings)); TITLE_COLOR(settings));
blit_line(fb_data, fb_pitch, blit_line(fb_data, fb_pitch,
RGUI_TERM_START_X(fb_width) + (RGUI_TERM_WIDTH(fb_width) - strlen(title_buf)) * FONT_WIDTH_STRIDE / 2, RGUI_TERM_START_X(fb_width) + (RGUI_TERM_WIDTH(fb_width)
RGUI_TERM_START_X(fb_width), title_buf, TITLE_COLOR(settings)); - strlen(title_buf)) * FONT_WIDTH_STRIDE / 2,
RGUI_TERM_START_X(fb_width),
title_buf, TITLE_COLOR(settings));
if (menu_entries_get_core_title(title_msg, sizeof(title_msg)) == 0) if (menu_entries_get_core_title(title_msg, sizeof(title_msg)) == 0)
blit_line(fb_data, fb_pitch, blit_line(fb_data, fb_pitch,
@ -572,8 +581,8 @@ static void rgui_render(void)
char message[PATH_MAX_LENGTH]; char message[PATH_MAX_LENGTH];
char entry_title_buf[PATH_MAX_LENGTH]; char entry_title_buf[PATH_MAX_LENGTH];
char type_str_buf[PATH_MAX_LENGTH]; char type_str_buf[PATH_MAX_LENGTH];
unsigned entry_spacing = menu_entry_get_spacing(i); unsigned entry_spacing = menu_entry_get_spacing(i);
bool entry_selected = menu_entry_is_currently_selected(i); bool entry_selected = menu_entry_is_currently_selected(i);
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
continue; continue;
@ -590,8 +599,11 @@ static void rgui_render(void)
menu_entry_get_value(i, entry_value, sizeof(entry_value)); menu_entry_get_value(i, entry_value, sizeof(entry_value));
menu_entry_get_path(i, entry_path, sizeof(entry_path)); menu_entry_get_path(i, entry_path, sizeof(entry_path));
menu_animation_ticker_str(entry_title_buf, RGUI_TERM_WIDTH(fb_width) - (entry_spacing + 1 + 2), menu_animation_ticker_str(entry_title_buf,
*frame_count / RGUI_TERM_START_X(fb_width), entry_path, entry_selected); RGUI_TERM_WIDTH(fb_width) - (entry_spacing + 1 + 2),
*frame_count / RGUI_TERM_START_X(fb_width),
entry_path,
entry_selected);
menu_animation_ticker_str(type_str_buf, entry_spacing, menu_animation_ticker_str(type_str_buf, entry_spacing,
*frame_count / RGUI_TERM_START_X(fb_width), *frame_count / RGUI_TERM_START_X(fb_width),
entry_value, entry_selected); entry_value, entry_selected);
@ -604,7 +616,8 @@ static void rgui_render(void)
entry_spacing, entry_spacing,
type_str_buf); type_str_buf);
blit_line(fb_data, fb_pitch, x, y, message, entry_selected ? hover_color : normal_color); blit_line(fb_data, fb_pitch, x, y, message,
entry_selected ? hover_color : normal_color);
} }
#ifdef GEKKO #ifdef GEKKO
@ -756,12 +769,7 @@ static void rgui_set_texture(void)
menu_display_ctl(MENU_DISPLAY_CTL_FB_DATA, &fb_data); menu_display_ctl(MENU_DISPLAY_CTL_FB_DATA, &fb_data);
menu_display_ctl(MENU_DISPLAY_CTL_UNSET_FRAMEBUFFER_DIRTY_FLAG, NULL); menu_display_ctl(MENU_DISPLAY_CTL_UNSET_FRAMEBUFFER_DIRTY_FLAG, NULL);
video_driver_set_texture_frame( video_driver_set_texture_frame(fb_data, false, fb_width, fb_height, 1.0f);
fb_data,
false,
fb_width,
fb_height,
1.0f);
} }
static void rgui_navigation_clear(bool pending_push) static void rgui_navigation_clear(bool pending_push)