Create menu_display_draw_keyboard

This commit is contained in:
twinaphex 2018-04-23 11:42:55 +02:00
parent f8ccf50fd4
commit 8bc3283bd5
4 changed files with 76 additions and 136 deletions

View File

@ -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());

View File

@ -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());

View File

@ -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(

View File

@ -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);