Add more functionality to menu_input_ctl

This commit is contained in:
twinaphex 2015-09-24 20:08:11 +02:00
parent 08f24aae4b
commit c0b46e3003
5 changed files with 52 additions and 17 deletions

View File

@ -351,6 +351,7 @@ static void glui_render_menu_list(glui_handle_t *glui,
static void glui_frame(void)
{
unsigned i;
bool display_kb;
GRfloat coord_color[16];
GRfloat coord_color2[16];
GRfloat black_bg[16];
@ -358,6 +359,7 @@ static void glui_frame(void)
GRfloat highlight_bg[16];
GRfloat white_bg[16];
unsigned width, height, ticker_limit;
char msg[PATH_MAX_LENGTH];
char title[PATH_MAX_LENGTH];
char title_buf[PATH_MAX_LENGTH];
char title_msg[PATH_MAX_LENGTH];
@ -371,7 +373,6 @@ static void glui_frame(void)
menu_navigation_t *nav = menu_navigation_get_ptr();
menu_display_t *disp = menu_display_get_ptr();
settings_t *settings = config_get_ptr();
menu_input_t *menu_input = menu_input_get_ptr();
uint64_t *frame_count = video_driver_get_frame_count();
const uint32_t normal_color = FONT_COLOR_ARGB_TO_RGBA(
settings->menu.entry_normal_color);
@ -390,6 +391,7 @@ static void glui_frame(void)
glui = (glui_handle_t*)menu->userdata;
msg[0] = '\0';
title[0] = '\0';
title_buf[0] = '\0';
title_msg[0] = '\0';
@ -486,16 +488,18 @@ static void glui_frame(void)
TEXT_ALIGN_RIGHT);
}
if (menu_input->keyboard.display)
menu_input_ctl(MENU_CTL_KEYBOARD_DISPLAY, &display_kb);
if (display_kb)
{
char msg[PATH_MAX_LENGTH];
const char *str = *menu_input->keyboard.buffer;
msg[0] = '\0';
const char *str = NULL, *label = NULL;
menu_input_ctl(MENU_CTL_KEYBOARD_BUFF_PTR, &str);
menu_input_ctl(MENU_CTL_KEYBOARD_LABEL, &label);
if (!str)
str = "";
glui_render_quad(gl, 0, 0, width, height, width, height, &black_bg[0]);
snprintf(msg, sizeof(msg), "%s\n%s", menu_input->keyboard.label, str);
snprintf(msg, sizeof(msg), "%s\n%s", label, str);
glui_render_messagebox(msg);
}

View File

@ -382,12 +382,14 @@ static void rgui_blit_cursor(menu_handle_t *menu)
static void rgui_render(void)
{
unsigned x, y;
bool display_kb;
uint16_t hover_color, normal_color;
size_t i, end;
int bottom;
char title[256];
char title_buf[256];
char title_msg[64];
char msg[PATH_MAX_LENGTH];
char timedate[PATH_MAX_LENGTH];
menu_handle_t *menu = menu_driver_get_ptr();
menu_input_t *menu_input = menu_input_get_ptr();
@ -400,6 +402,7 @@ static void rgui_render(void)
uint64_t *frame_count = video_driver_get_frame_count();
rgui_t *rgui = NULL;
msg[0] = '\0';
title[0] = '\0';
title_buf[0] = '\0';
title_msg[0] = '\0';
@ -441,7 +444,8 @@ static void rgui_render(void)
if (settings->menu.pointer.enable)
{
menu_input->pointer.ptr = menu_input->pointer.y / 11 - 2 + menu_entries_get_start();
unsigned new_val = menu_input->pointer.y / 11 - 2 + menu_entries_get_start();
menu_input_ctl(MENU_CTL_POINTER_PTR, &new_val);
if (menu_input->pointer.dragging)
{
@ -580,14 +584,17 @@ static void rgui_render(void)
rgui_render_messagebox( message_queue);
#endif
if (menu_input->keyboard.display)
menu_input_ctl(MENU_CTL_KEYBOARD_DISPLAY, &display_kb);
if (display_kb)
{
char msg[PATH_MAX_LENGTH] = {0};
const char *str = *menu_input->keyboard.buffer;
const char *str = NULL, *label = NULL;
menu_input_ctl(MENU_CTL_KEYBOARD_BUFF_PTR, &str);
menu_input_ctl(MENU_CTL_KEYBOARD_LABEL, &label);
if (!str)
str = "";
snprintf(msg, sizeof(msg), "%s\n%s", menu_input->keyboard.label, str);
snprintf(msg, sizeof(msg), "%s\n%s", label, str);
rgui_render_messagebox(msg);
}

View File

@ -1504,12 +1504,12 @@ static void xmb_frame(void)
GRfloat item_color[16];
GRfloat coord_color[16];
GRfloat coord_color2[16];
bool display_kb;
bool render_background = false;
xmb_handle_t *xmb = NULL;
gl_t *gl = NULL;
const struct font_renderer *font_driver = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
menu_input_t *menu_input = menu_input_get_ptr();
menu_navigation_t *nav = menu_navigation_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
settings_t *settings = config_get_ptr();
@ -1631,14 +1631,17 @@ static void xmb_frame(void)
menu_display_font_flush_block(menu, font_driver);
if (menu_input->keyboard.display)
menu_input_ctl(MENU_CTL_KEYBOARD_DISPLAY, &display_kb);
if (display_kb)
{
const char *str = *menu_input->keyboard.buffer;
const char *str = NULL, *label = NULL;
menu_input_ctl(MENU_CTL_KEYBOARD_BUFF_PTR, &str);
menu_input_ctl(MENU_CTL_KEYBOARD_LABEL, &label);
if (!str)
str = "";
snprintf(msg, sizeof(msg), "%s\n%s",
menu_input->keyboard.label, str);
snprintf(msg, sizeof(msg), "%s\n%s", label, str);
render_background = true;
}

View File

@ -93,6 +93,24 @@ bool menu_input_ctl(enum menu_ctl_state state, void *data)
menu_input->pointer.ptr = *ptr;
}
return true;
case MENU_CTL_KEYBOARD_DISPLAY:
{
bool *ptr = (bool*)data;
*ptr = menu_input->keyboard.display;
}
return true;
case MENU_CTL_KEYBOARD_BUFF_PTR:
{
const char *ptr = (const char *)ptr;
ptr = *menu_input->keyboard.buffer;
}
return true;
case MENU_CTL_KEYBOARD_LABEL:
{
const char *ptr = (const char*)ptr;
ptr = menu_input->keyboard.label;
}
return true;
}
return false;

View File

@ -78,7 +78,10 @@ enum menu_ctl_state
MENU_CTL_MOUSE_SCROLL_DOWN = 0,
MENU_CTL_MOUSE_SCROLL_UP,
MENU_CTL_MOUSE_PTR,
MENU_CTL_POINTER_PTR
MENU_CTL_POINTER_PTR,
MENU_CTL_KEYBOARD_DISPLAY,
MENU_CTL_KEYBOARD_BUFF_PTR,
MENU_CTL_KEYBOARD_LABEL
};
enum mouse_action