From 8bc3283bd5762b6b652a01a9fa572c258402bd97 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 23 Apr 2018 11:42:55 +0200 Subject: [PATCH] Create menu_display_draw_keyboard --- menu/drivers/materialui.c | 73 ++------------------------------------- menu/drivers/xmb.c | 69 ++---------------------------------- menu/menu_driver.c | 65 ++++++++++++++++++++++++++++++++++ menu/menu_driver.h | 5 +++ 4 files changed, 76 insertions(+), 136 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index abbbb6d218..a3eae3f18c 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -407,75 +407,6 @@ static void materialui_draw_tab( &tab_color[0]); } -/* Draw the onscreen keyboard */ -static void materialui_render_keyboard( - materialui_handle_t *mui, - video_frame_info_t *video_info, - char *grid[], unsigned id) -{ - int ptr_width, ptr_height; - unsigned i; - unsigned width = video_info->width; - unsigned height = video_info->height; - float dark[16] = { - 0.00, 0.00, 0.00, 0.85, - 0.00, 0.00, 0.00, 0.85, - 0.00, 0.00, 0.00, 0.85, - 0.00, 0.00, 0.00, 0.85, - }; - - float white[16] = { - 1.00, 1.00, 1.00, 1.00, - 1.00, 1.00, 1.00, 1.00, - 1.00, 1.00, 1.00, 1.00, - 1.00, 1.00, 1.00, 1.00, - }; - - menu_display_draw_quad( - video_info, - 0, - height/2.0, width, height/2.0, - width, height, - &dark[0]); - - ptr_width = width / 11; - ptr_height = height / 10; - - if (ptr_width >= ptr_height) - ptr_width = ptr_height; - - for (i = 0; i < 44; i++) - { - int line_y = (i / 11)*height/10.0; - uintptr_t texture = mui->textures.list[MUI_TEXTURE_KEY]; - - if (i == id) - { - texture = mui->textures.list[MUI_TEXTURE_KEY_HOVER]; - - menu_display_blend_begin(video_info); - - menu_display_draw_texture( - video_info, - width/2.0 - (11*ptr_width)/2.0 + (i % 11) * ptr_width, - height/2.0 + ptr_height*1.5 + line_y, - ptr_width, ptr_height, - width, height, - &white[0], - texture); - - menu_display_blend_end(video_info); - } - - menu_display_draw_text(mui->font, grid[i], - width/2.0 - (11*ptr_width)/2.0 + (i % 11) - * ptr_width + ptr_width/2.0, - height/2.0 + ptr_height + line_y + mui->font->size / 3, - width, height, 0xffffffff, TEXT_ALIGN_CENTER, 1.0f, - false, 0); - } -} - /* Returns the OSK key at a given position */ static int materialui_osk_ptr_at_pos(void *data, int x, int y, unsigned width, unsigned height) @@ -667,7 +598,9 @@ static void materialui_render_messagebox(materialui_handle_t *mui, } if (menu_input_dialog_get_display_kb()) - materialui_render_keyboard(mui, + menu_display_draw_keyboard( + mui->textures.list[MUI_TEXTURE_KEY_HOVER], + mui->font, video_info, menu_event_get_osk_grid(), menu_event_get_osk_ptr()); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 6aa26e5c81..ea6c3002a3 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -800,71 +800,6 @@ static void xmb_messagebox(void *data, const char *message) xmb->box_message = strdup(message); } -static void xmb_render_keyboard(xmb_handle_t *xmb, - video_frame_info_t *video_info, - char *grid[], unsigned id) -{ - unsigned i; - int ptr_width, ptr_height; - unsigned width = video_info->width; - unsigned height = video_info->height; - float dark[16] = { - 0.00, 0.00, 0.00, 0.85, - 0.00, 0.00, 0.00, 0.85, - 0.00, 0.00, 0.00, 0.85, - 0.00, 0.00, 0.00, 0.85, - }; - - float white[16]= { - 1.00, 1.00, 1.00, 1.00, - 1.00, 1.00, 1.00, 1.00, - 1.00, 1.00, 1.00, 1.00, - 1.00, 1.00, 1.00, 1.00, - }; - - menu_display_draw_quad( - video_info, - 0, height/2.0, width, height/2.0, - width, height, - &dark[0]); - - ptr_width = width / 11; - ptr_height = height / 10; - - if (ptr_width >= ptr_height) - ptr_width = ptr_height; - - for (i = 0; i < 44; i++) - { - int line_y = (i / 11) * height / 10.0; - - if (i == id) - { - uintptr_t texture = xmb->textures.list[XMB_TEXTURE_KEY_HOVER]; - - menu_display_blend_begin(video_info); - - menu_display_draw_texture( - video_info, - width/2.0 - (11*ptr_width)/2.0 + (i % 11) * ptr_width, - height/2.0 + ptr_height*1.5 + line_y, - ptr_width, ptr_height, - width, height, - &white[0], - texture); - - menu_display_blend_end(video_info); - } - - menu_display_draw_text(xmb->font, grid[i], - width/2.0 - (11*ptr_width)/2.0 + (i % 11) - * ptr_width + ptr_width/2.0, - height/2.0 + ptr_height + line_y + xmb->font->size / 3, - width, height, 0xffffffff, TEXT_ALIGN_CENTER, 1.0f, - false, 0); - } -} - /* Returns the OSK key at a given position */ static int xmb_osk_ptr_at_pos(void *data, int x, int y, unsigned width, unsigned height) { @@ -966,7 +901,9 @@ static void xmb_render_messagebox_internal( } if (menu_input_dialog_get_display_kb()) - xmb_render_keyboard(xmb, + menu_display_draw_keyboard( + xmb->textures.list[XMB_TEXTURE_KEY_HOVER], + xmb->font, video_info, menu_event_get_osk_grid(), menu_event_get_osk_ptr()); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 2169895519..f841897635 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -1331,6 +1331,71 @@ void menu_display_snow(int width, int height) } } +void menu_display_draw_keyboard( + uintptr_t hover_texture, + const font_data_t *font, + video_frame_info_t *video_info, + char *grid[], unsigned id) +{ + unsigned i; + int ptr_width, ptr_height; + unsigned width = video_info->width; + unsigned height = video_info->height; + float dark[16] = { + 0.00, 0.00, 0.00, 0.85, + 0.00, 0.00, 0.00, 0.85, + 0.00, 0.00, 0.00, 0.85, + 0.00, 0.00, 0.00, 0.85, + }; + + float white[16]= { + 1.00, 1.00, 1.00, 1.00, + 1.00, 1.00, 1.00, 1.00, + 1.00, 1.00, 1.00, 1.00, + 1.00, 1.00, 1.00, 1.00, + }; + + menu_display_draw_quad( + video_info, + 0, height/2.0, width, height/2.0, + width, height, + &dark[0]); + + ptr_width = width / 11; + ptr_height = height / 10; + + if (ptr_width >= ptr_height) + ptr_width = ptr_height; + + for (i = 0; i < 44; i++) + { + int line_y = (i / 11) * height / 10.0; + + if (i == id) + { + menu_display_blend_begin(video_info); + + menu_display_draw_texture( + video_info, + width/2.0 - (11*ptr_width)/2.0 + (i % 11) * ptr_width, + height/2.0 + ptr_height*1.5 + line_y, + ptr_width, ptr_height, + width, height, + &white[0], + hover_texture); + + menu_display_blend_end(video_info); + } + + menu_display_draw_text(font, grid[i], + width/2.0 - (11*ptr_width)/2.0 + (i % 11) + * ptr_width + ptr_width/2.0, + height/2.0 + ptr_height + line_y + font->size / 3, + width, height, 0xffffffff, TEXT_ALIGN_CENTER, 1.0f, + false, 0); + } +} + /* Draw text on top of the screen. */ void menu_display_draw_text( diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 6cf794de48..10f0a88e46 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -675,6 +675,11 @@ void menu_display_clear_color(menu_display_ctx_clearcolor_t *color, video_frame_info_t *video_info); void menu_display_draw(menu_display_ctx_draw_t *draw, video_frame_info_t *video_info); +void menu_display_draw_keyboard( + uintptr_t hover_texture, + const font_data_t *font, + video_frame_info_t *video_info, + char *grid[], unsigned id); void menu_display_draw_pipeline(menu_display_ctx_draw_t *draw, video_frame_info_t *video_info);