mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
commit
59d8b0702c
@ -35,10 +35,8 @@
|
||||
typedef struct glui_handle
|
||||
{
|
||||
unsigned line_height;
|
||||
unsigned glyph_width;
|
||||
unsigned margin;
|
||||
unsigned term_width;
|
||||
unsigned term_height;
|
||||
unsigned ticker_limit;
|
||||
char box_message[PATH_MAX_LENGTH];
|
||||
struct
|
||||
{
|
||||
@ -49,7 +47,7 @@ typedef struct glui_handle
|
||||
} bg;
|
||||
} textures;
|
||||
|
||||
gl_font_raster_block_t raster_block;
|
||||
gl_font_raster_block_t list_block;
|
||||
bool use_blocks;
|
||||
} glui_handle_t;
|
||||
|
||||
@ -81,7 +79,7 @@ static int glui_entry_iterate(unsigned action)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void glui_blit_line(gl_t *gl, float x, float y, const char *message, uint32_t color)
|
||||
static void glui_blit_line(gl_t *gl, float x, float y, const char *message, uint32_t color, enum text_alignment text_align)
|
||||
{
|
||||
struct font_params params = {0};
|
||||
|
||||
@ -90,6 +88,7 @@ static void glui_blit_line(gl_t *gl, float x, float y, const char *message, uint
|
||||
params.scale = 1.0;
|
||||
params.color = color;
|
||||
params.full_screen = true;
|
||||
params.text_align = text_align;
|
||||
|
||||
video_driver_set_osd_msg(message, ¶ms, NULL);
|
||||
}
|
||||
@ -160,9 +159,9 @@ static void glui_render_background(settings_t *settings,
|
||||
gl->coords.color = gl->white_color_ptr;
|
||||
}
|
||||
|
||||
static void glui_draw_cursor(gl_t *gl, float x, float y)
|
||||
static void glui_render_quad(gl_t *gl, int x, int y, int w, int h,
|
||||
float r, float g, float b, float a)
|
||||
{
|
||||
struct gl_coords coords;
|
||||
static const GLfloat vertex[] = {
|
||||
0, 0,
|
||||
1, 0,
|
||||
@ -176,14 +175,17 @@ static void glui_draw_cursor(gl_t *gl, float x, float y)
|
||||
0, 0,
|
||||
1, 0,
|
||||
};
|
||||
|
||||
struct gl_coords coords;
|
||||
|
||||
GLfloat color[] = {
|
||||
1.0f, 1.0f, 1.0f, 1.0f,
|
||||
1.0f, 1.0f, 1.0f, 1.0f,
|
||||
1.0f, 1.0f, 1.0f, 1.0f,
|
||||
1.0f, 1.0f, 1.0f, 1.0f,
|
||||
r, g, b, a,
|
||||
r, g, b, a,
|
||||
r, g, b, a,
|
||||
r, g, b, a,
|
||||
};
|
||||
|
||||
glViewport(x - 5, gl->win_height - y + 5, 11, 11);
|
||||
glViewport(x, gl->win_height - y - h, w, h);
|
||||
|
||||
coords.vertices = 4;
|
||||
coords.vertex = vertex;
|
||||
@ -204,6 +206,11 @@ static void glui_draw_cursor(gl_t *gl, float x, float y)
|
||||
gl->coords.color = gl->white_color_ptr;
|
||||
}
|
||||
|
||||
static void glui_draw_cursor(gl_t *gl, float x, float y)
|
||||
{
|
||||
glui_render_quad(gl, x-5, y-5, 10, 10, 1, 1, 1, 1);
|
||||
}
|
||||
|
||||
static void glui_get_message(const char *message)
|
||||
{
|
||||
glui_handle_t *glui = NULL;
|
||||
@ -253,8 +260,8 @@ static void glui_render_messagebox(const char *message)
|
||||
if (list->elems == 0)
|
||||
goto end;
|
||||
|
||||
x = gl->win_width / 2 - strlen(list->elems[0].data) * glui->glyph_width / 2;
|
||||
y = gl->win_height / 2 - list->size * glui->line_height / 2;
|
||||
x = gl->win_width / 2;
|
||||
y = gl->win_height / 2 - list->size * settings->video.font_size / 2;
|
||||
|
||||
normal_color = FONT_COLOR_ARGB_TO_RGBA(settings->menu.entry_normal_color);
|
||||
|
||||
@ -262,7 +269,7 @@ static void glui_render_messagebox(const char *message)
|
||||
{
|
||||
const char *msg = list->elems[i].data;
|
||||
if (msg)
|
||||
glui_blit_line(gl, x, y + i * glui->line_height, msg, normal_color);
|
||||
glui_blit_line(gl, x, y + i * settings->video.font_size, msg, normal_color, TEXT_ALIGN_CENTER);
|
||||
}
|
||||
|
||||
end:
|
||||
@ -271,6 +278,7 @@ end:
|
||||
|
||||
static void glui_render(void)
|
||||
{
|
||||
int bottom;
|
||||
glui_handle_t *glui = NULL;
|
||||
gl_t *gl = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
@ -289,46 +297,121 @@ static void glui_render(void)
|
||||
if (!gl)
|
||||
return;
|
||||
|
||||
glui->line_height = settings->video.font_size * 4 / 3;
|
||||
glui->glyph_width = glui->line_height / 2;
|
||||
glui->margin = gl->win_width / 20 ;
|
||||
glui->term_width = (gl->win_width - glui->margin * 2) / glui->glyph_width;
|
||||
glui->term_height = (gl->win_height - glui->margin * 2) / glui->line_height - 2;
|
||||
|
||||
menu->frame_buf.width = gl->win_width;
|
||||
menu->frame_buf.height = gl->win_height;
|
||||
|
||||
menu->mouse.ptr = (menu->mouse.y - glui->margin) /
|
||||
glui->line_height - 2 + menu->begin;
|
||||
if (settings->menu.pointer.enable)
|
||||
{
|
||||
menu->pointer.ptr =
|
||||
(menu->pointer.y - glui->line_height + menu->scroll_y - 16)
|
||||
/ glui->line_height;
|
||||
|
||||
if (menu->mouse.wheeldown && menu->begin
|
||||
< menu_list_get_size(menu->menu_list) - glui->term_height)
|
||||
menu->begin++;
|
||||
if (menu->pointer.dragging)
|
||||
menu->scroll_y -= menu->pointer.dy;
|
||||
}
|
||||
|
||||
if (menu->mouse.wheelup && menu->begin > 0)
|
||||
menu->begin--;
|
||||
if (settings->menu.mouse.enable)
|
||||
{
|
||||
if (menu->mouse.scrolldown)
|
||||
menu->scroll_y += 10;
|
||||
|
||||
/* Do not scroll if all items are visible. */
|
||||
if (menu_list_get_size(menu->menu_list) <= glui->term_height)
|
||||
menu->begin = 0;
|
||||
if (menu->mouse.scrollup)
|
||||
menu->scroll_y -= 10;
|
||||
|
||||
menu->mouse.ptr =
|
||||
(menu->mouse.y - glui->line_height + menu->scroll_y - 16)
|
||||
/ glui->line_height;
|
||||
}
|
||||
|
||||
if (menu->scroll_y < 0)
|
||||
menu->scroll_y = 0;
|
||||
|
||||
bottom = (menu_list_get_size(menu->menu_list)-1) * glui->line_height
|
||||
- gl->win_height + menu->header_height * 2;
|
||||
if (menu->scroll_y > bottom)
|
||||
menu->scroll_y = bottom;
|
||||
|
||||
if ((menu_list_get_size(menu->menu_list)-1) * glui->line_height
|
||||
< gl->win_height - menu->header_height*2)
|
||||
menu->scroll_y = 0;
|
||||
}
|
||||
|
||||
static void glui_render_menu_list(runloop_t *runloop, gl_t *gl, glui_handle_t *glui,
|
||||
menu_handle_t *menu, const char *label, uint32_t normal_color,
|
||||
uint32_t hover_color)
|
||||
{
|
||||
const struct font_renderer *font_driver = (const struct font_renderer *)gl->font_driver;
|
||||
size_t i = 0;
|
||||
|
||||
if (glui->use_blocks)
|
||||
font_driver->bind_block(gl->font_handle, &glui->list_block);
|
||||
|
||||
if (!menu_display_update_pending())
|
||||
goto draw_text;
|
||||
|
||||
glui->list_block.carr.coords.vertices = 0;
|
||||
|
||||
for (i = 0; i < menu_list_get_size(menu->menu_list); i++)
|
||||
{
|
||||
char message[PATH_MAX_LENGTH], type_str[PATH_MAX_LENGTH],
|
||||
entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH],
|
||||
path_buf[PATH_MAX_LENGTH];
|
||||
const char *path = NULL, *entry_label = NULL;
|
||||
unsigned type = 0, w = 0;
|
||||
bool selected = false;
|
||||
menu_file_list_cbs_t *cbs = NULL;
|
||||
|
||||
menu_list_get_at_offset(menu->menu_list->selection_buf, i, &path,
|
||||
&entry_label, &type);
|
||||
|
||||
cbs = (menu_file_list_cbs_t*)
|
||||
menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, i);
|
||||
|
||||
if (cbs && cbs->action_get_representation)
|
||||
cbs->action_get_representation(menu->menu_list->selection_buf,
|
||||
&w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
|
||||
selected = (i == menu->navigation.selection_ptr);
|
||||
|
||||
menu_animation_ticker_line(entry_title_buf, glui->ticker_limit,
|
||||
runloop->frames.video.count / 100, path_buf, selected);
|
||||
menu_animation_ticker_line(type_str_buf, glui->ticker_limit,
|
||||
runloop->frames.video.count / 100, type_str, selected);
|
||||
|
||||
strlcpy(message, entry_title_buf, sizeof(message));
|
||||
|
||||
unsigned y = menu->header_height - menu->scroll_y + (glui->line_height * i);
|
||||
|
||||
glui_blit_line(gl, glui->margin, y, message,
|
||||
selected ? hover_color : normal_color, TEXT_ALIGN_LEFT);
|
||||
|
||||
glui_blit_line(gl, gl->win_width - glui->margin, y, type_str_buf,
|
||||
selected ? hover_color : normal_color, TEXT_ALIGN_RIGHT);
|
||||
}
|
||||
|
||||
draw_text:
|
||||
if (glui->use_blocks)
|
||||
{
|
||||
font_driver->flush(gl->font_handle);
|
||||
font_driver->bind_block(gl->font_handle, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void glui_frame(void)
|
||||
{
|
||||
unsigned x, y;
|
||||
size_t i;
|
||||
char title[PATH_MAX_LENGTH], title_buf[PATH_MAX_LENGTH],
|
||||
title_msg[PATH_MAX_LENGTH];
|
||||
char timedate[PATH_MAX_LENGTH];
|
||||
const char *dir = NULL;
|
||||
const char *label = NULL;
|
||||
unsigned menu_type = 0;
|
||||
size_t end;
|
||||
gl_t *gl = NULL;
|
||||
glui_handle_t *glui = NULL;
|
||||
const char *core_name = NULL;
|
||||
const char *core_version = NULL;
|
||||
const struct font_renderer *font_driver = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
const uint32_t normal_color = FONT_COLOR_ARGB_TO_RGBA(settings->menu.entry_normal_color);
|
||||
@ -345,8 +428,6 @@ static void glui_frame(void)
|
||||
if (!gl)
|
||||
return;
|
||||
|
||||
font_driver = (const struct font_renderer*)gl->font_driver;
|
||||
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
|
||||
if (!glui)
|
||||
@ -361,34 +442,34 @@ static void glui_frame(void)
|
||||
|
||||
glui_render_background(settings, gl, glui, false);
|
||||
|
||||
if (glui->use_blocks)
|
||||
{
|
||||
font_driver->bind_block(gl->font_handle, &glui->raster_block);
|
||||
menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type);
|
||||
|
||||
if (!menu_display_update_pending())
|
||||
goto draw_text;
|
||||
}
|
||||
get_title(label, dir, menu_type, title, sizeof(title));
|
||||
|
||||
glui->raster_block.carr.coords.vertices = 0;
|
||||
glui_render_quad(gl, 0,
|
||||
menu->header_height - menu->scroll_y + glui->line_height *
|
||||
menu->navigation.selection_ptr - glui->line_height / 2 - 4,
|
||||
gl->win_width, glui->line_height, 1, 1, 1, 0.1);
|
||||
|
||||
glui_render_menu_list(runloop, gl, glui, menu, label, normal_color, hover_color);
|
||||
|
||||
runloop->frames.video.current.menu.animation.is_active = false;
|
||||
runloop->frames.video.current.menu.label.is_updated = false;
|
||||
runloop->frames.video.current.menu.framebuf.dirty = false;
|
||||
|
||||
end = (menu->begin + glui->term_height <=
|
||||
menu_list_get_size(menu->menu_list)) ?
|
||||
menu->begin + glui->term_height :
|
||||
menu_list_get_size(menu->menu_list);
|
||||
glui_render_quad(gl, 0, 0, gl->win_width,
|
||||
menu->header_height - glui->line_height/2 - 4, 0.2, 0.2, 0.2, 1);
|
||||
|
||||
menu_animation_ticker_line(title_buf, glui->ticker_limit,
|
||||
runloop->frames.video.count / 100, title, true);
|
||||
glui_blit_line(gl, gl->win_width/2, glui->line_height, title_buf, title_color, TEXT_ALIGN_CENTER);
|
||||
|
||||
menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type);
|
||||
glui_blit_line(gl, glui->margin, glui->line_height, "BACK", title_color, TEXT_ALIGN_LEFT);
|
||||
|
||||
get_title(label, dir, menu_type, title, sizeof(title));
|
||||
|
||||
menu_animation_ticker_line(title_buf, glui->term_width - 3,
|
||||
runloop->frames.video.count / glui->margin, title, true);
|
||||
glui_blit_line(gl, glui->margin * 2, glui->margin + glui->line_height,
|
||||
title_buf, title_color);
|
||||
glui_render_quad(gl, 0,
|
||||
gl->win_height - (menu->header_height - glui->line_height/2 + 4),
|
||||
gl->win_width, menu->header_height - glui->line_height/2 + 4,
|
||||
0.2, 0.2, 0.2, 1);
|
||||
|
||||
core_name = global->menu.info.library_name;
|
||||
if (!core_name)
|
||||
@ -407,69 +488,16 @@ static void glui_frame(void)
|
||||
snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION,
|
||||
core_name, core_version);
|
||||
|
||||
glui_blit_line(gl,
|
||||
glui->margin * 2,
|
||||
glui->margin + glui->term_height * glui->line_height
|
||||
+ glui->line_height * 2, title_msg, title_color);
|
||||
glui_blit_line(gl, glui->margin, gl->win_height - glui->line_height, title_msg,
|
||||
title_color, TEXT_ALIGN_LEFT);
|
||||
}
|
||||
|
||||
if (settings->menu.timedate_enable)
|
||||
{
|
||||
disp_timedate_set_label(timedate, sizeof(timedate), 0);
|
||||
glui_blit_line(gl,
|
||||
glui->margin * 14,
|
||||
glui->margin + glui->term_height * glui->line_height
|
||||
+ glui->line_height * 2, timedate, hover_color);
|
||||
}
|
||||
|
||||
x = glui->margin;
|
||||
y = glui->margin + glui->line_height * 2;
|
||||
|
||||
for (i = menu->begin; i < end; i++, y += glui->line_height)
|
||||
{
|
||||
char message[PATH_MAX_LENGTH], type_str[PATH_MAX_LENGTH],
|
||||
entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH],
|
||||
path_buf[PATH_MAX_LENGTH];
|
||||
const char *path = NULL, *entry_label = NULL;
|
||||
unsigned type = 0, w = 0;
|
||||
bool selected = false;
|
||||
menu_file_list_cbs_t *cbs = NULL;
|
||||
|
||||
menu_list_get_at_offset(menu->menu_list->selection_buf, i, &path,
|
||||
&entry_label, &type);
|
||||
|
||||
cbs = (menu_file_list_cbs_t*)
|
||||
menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf,
|
||||
i);
|
||||
|
||||
if (cbs && cbs->action_get_representation)
|
||||
cbs->action_get_representation(menu->menu_list->selection_buf,
|
||||
&w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
|
||||
selected = (i == menu->navigation.selection_ptr);
|
||||
|
||||
menu_animation_ticker_line(entry_title_buf, glui->term_width - (w + 1 + 2),
|
||||
runloop->frames.video.count / glui->margin, path_buf, selected);
|
||||
menu_animation_ticker_line(type_str_buf, w,
|
||||
runloop->frames.video.count / glui->margin, type_str, selected);
|
||||
|
||||
strlcpy(message, entry_title_buf, sizeof(message));
|
||||
|
||||
glui_blit_line(gl, x, y, message, selected ? hover_color : normal_color);
|
||||
|
||||
glui_blit_line(gl, gl->win_width - glui->glyph_width * w - glui->margin ,
|
||||
y, type_str_buf, selected ? hover_color : normal_color);
|
||||
}
|
||||
|
||||
draw_text:
|
||||
|
||||
if (glui->use_blocks)
|
||||
{
|
||||
font_driver->flush(gl->font_handle);
|
||||
font_driver->bind_block(gl->font_handle, NULL);
|
||||
glui_blit_line(gl, gl->win_width - glui->margin,
|
||||
gl->win_height - glui->line_height, timedate, hover_color,
|
||||
TEXT_ALIGN_RIGHT);
|
||||
}
|
||||
|
||||
if (menu->keyboard.display)
|
||||
@ -512,7 +540,7 @@ static void *glui_init(void)
|
||||
}
|
||||
|
||||
font_driver = (const struct font_renderer*)gl->font_driver;
|
||||
menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
||||
menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
||||
|
||||
if (!menu)
|
||||
goto error;
|
||||
@ -522,7 +550,12 @@ static void *glui_init(void)
|
||||
if (!menu->userdata)
|
||||
goto error;
|
||||
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
|
||||
glui->line_height = 44;
|
||||
glui->margin = 22;
|
||||
glui->ticker_limit = 44;
|
||||
menu->header_height = 88;
|
||||
glui->textures.bg.id = 0;
|
||||
|
||||
if (font_driver->bind_block && font_driver->flush)
|
||||
@ -548,7 +581,7 @@ static void glui_free(void *data)
|
||||
if (!glui)
|
||||
return;
|
||||
|
||||
gl_coord_array_free(&glui->raster_block.carr);
|
||||
gl_coord_array_free(&glui->list_block.carr);
|
||||
|
||||
font_driver = (const struct font_renderer*)gl->font_driver;
|
||||
|
||||
@ -562,8 +595,6 @@ static void glui_free(void *data)
|
||||
free(menu->userdata);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void glui_context_destroy(void)
|
||||
{
|
||||
glui_handle_t *glui = NULL;
|
||||
@ -606,14 +637,18 @@ static bool glui_load_wallpaper(void *data)
|
||||
static void glui_navigation_clear(bool pending_push)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
if (menu)
|
||||
menu->begin = 0;
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
menu->begin = 0;
|
||||
menu->scroll_y = 0;
|
||||
}
|
||||
|
||||
static void glui_navigation_set(bool scroll)
|
||||
{
|
||||
glui_handle_t *glui = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
gl_t *gl = (gl_t*)video_driver_get_ptr(NULL);
|
||||
|
||||
if (!menu)
|
||||
return;
|
||||
@ -625,16 +660,12 @@ static void glui_navigation_set(bool scroll)
|
||||
if (!scroll)
|
||||
return;
|
||||
|
||||
if (menu->navigation.selection_ptr < glui->term_height/2)
|
||||
menu->begin = 0;
|
||||
else if (menu->navigation.selection_ptr >= glui->term_height/2
|
||||
&& menu->navigation.selection_ptr <
|
||||
menu_list_get_size(menu->menu_list) - glui->term_height/2)
|
||||
menu->begin = menu->navigation.selection_ptr - glui->term_height/2;
|
||||
else if (menu->navigation.selection_ptr >=
|
||||
menu_list_get_size(menu->menu_list) - glui->term_height/2)
|
||||
menu->begin = menu_list_get_size(menu->menu_list)
|
||||
- glui->term_height;
|
||||
int half = (gl->win_height / glui->line_height) / 2;
|
||||
|
||||
if (menu->navigation.selection_ptr < half)
|
||||
menu->scroll_y = 0;
|
||||
else
|
||||
menu->scroll_y = ((menu->navigation.selection_ptr + 2 - half) * glui->line_height);
|
||||
}
|
||||
|
||||
static void glui_navigation_set_last(void)
|
||||
|
@ -349,6 +349,7 @@ static void rgui_blit_cursor(menu_handle_t *menu)
|
||||
static void rgui_render(void)
|
||||
{
|
||||
size_t i, end;
|
||||
int bottom;
|
||||
char title[256], title_buf[256], title_msg[64];
|
||||
char timedate[PATH_MAX_LENGTH];
|
||||
unsigned x, y, menu_type = 0;
|
||||
@ -383,19 +384,39 @@ static void rgui_render(void)
|
||||
runloop->frames.video.current.menu.animation.is_active = false;
|
||||
runloop->frames.video.current.menu.label.is_updated = false;
|
||||
|
||||
menu->mouse.ptr = menu->mouse.y / 11 - 2 + menu->begin;
|
||||
if (settings->menu.pointer.enable)
|
||||
{
|
||||
menu->pointer.ptr = menu->pointer.y / 11 - 2 + menu->begin;
|
||||
|
||||
if (menu->mouse.scrolldown && menu->begin
|
||||
< menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT)
|
||||
menu->begin++;
|
||||
if (menu->pointer.dragging)
|
||||
{
|
||||
menu->scroll_y += menu->pointer.dy;
|
||||
menu->begin = -menu->scroll_y / 11 + 2;
|
||||
if (menu->scroll_y > 0)
|
||||
menu->scroll_y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (settings->menu.mouse.enable)
|
||||
{
|
||||
if (menu->mouse.scrolldown && menu->begin
|
||||
< menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT)
|
||||
menu->begin++;
|
||||
|
||||
if (menu->mouse.scrollup && menu->begin > 0)
|
||||
menu->begin--;
|
||||
if (menu->mouse.scrollup && menu->begin > 0)
|
||||
menu->begin--;
|
||||
|
||||
menu->mouse.ptr = menu->mouse.y / 11 - 2 + menu->begin;
|
||||
}
|
||||
|
||||
/* Do not scroll if all items are visible. */
|
||||
if (menu_list_get_size(menu->menu_list) <= RGUI_TERM_HEIGHT)
|
||||
menu->begin = 0;
|
||||
|
||||
bottom = menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT;
|
||||
if (menu->begin > bottom)
|
||||
menu->begin = bottom;
|
||||
|
||||
end = (menu->begin + RGUI_TERM_HEIGHT <=
|
||||
menu_list_get_size(menu->menu_list)) ?
|
||||
menu->begin + RGUI_TERM_HEIGHT :
|
||||
@ -546,6 +567,7 @@ static void *rgui_init(void)
|
||||
|
||||
menu->frame_buf.width = 320;
|
||||
menu->frame_buf.height = 240;
|
||||
menu->header_height = 11;
|
||||
menu->begin = 0;
|
||||
menu->frame_buf.pitch = menu->frame_buf.width * sizeof(uint16_t);
|
||||
|
||||
@ -608,8 +630,11 @@ static void rgui_set_texture(void)
|
||||
static void rgui_navigation_clear(bool pending_push)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
if (menu)
|
||||
menu->begin = 0;
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
menu->begin = 0;
|
||||
menu->scroll_y = 0;
|
||||
}
|
||||
|
||||
static void rgui_navigation_set(bool scroll)
|
||||
|
@ -112,6 +112,8 @@ typedef struct
|
||||
} delay;
|
||||
|
||||
size_t begin;
|
||||
unsigned header_height;
|
||||
int scroll_y;
|
||||
|
||||
menu_list_t *menu_list;
|
||||
menu_navigation_t navigation;
|
||||
@ -175,13 +177,20 @@ typedef struct
|
||||
|
||||
struct
|
||||
{
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t dx;
|
||||
int16_t dy;
|
||||
int16_t old_x;
|
||||
int16_t old_y;
|
||||
bool pressed[2];
|
||||
bool oldpressed[2];
|
||||
bool back;
|
||||
bool oldback;
|
||||
bool cancel;
|
||||
int16_t start_x;
|
||||
int16_t start_y;
|
||||
bool pressed[2];
|
||||
bool oldpressed[2];
|
||||
bool dragging;
|
||||
bool back;
|
||||
bool oldback;
|
||||
unsigned ptr;
|
||||
} pointer;
|
||||
|
||||
struct
|
||||
|
@ -504,6 +504,7 @@ static int action_iterate_main(const char *label, unsigned action)
|
||||
menu_file_list_cbs_t *cbs = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
if (!menu)
|
||||
return 0;
|
||||
|
||||
|
@ -667,7 +667,7 @@ static int menu_input_mouse(unsigned *action)
|
||||
|
||||
static int menu_input_pointer(unsigned *action)
|
||||
{
|
||||
int pointer_device, pointer_x, pointer_y, screen_x, screen_y;
|
||||
int pointer_device, pointer_x, pointer_y;
|
||||
const struct retro_keybind *binds[MAX_USERS];
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
runloop_t *runloop = rarch_main_get_ptr();
|
||||
@ -683,11 +683,6 @@ static int menu_input_pointer(unsigned *action)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(HAVE_XMB)
|
||||
if (driver->menu_ctx == &menu_ctx_xmb)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
pointer_device = driver->menu_ctx->set_texture?
|
||||
RETRO_DEVICE_POINTER : RARCH_DEVICE_POINTER_SCREEN;
|
||||
|
||||
@ -701,65 +696,13 @@ static int menu_input_pointer(unsigned *action)
|
||||
pointer_x = input_driver_state(binds, 0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_X);
|
||||
pointer_y = input_driver_state(binds, 0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_Y);
|
||||
|
||||
/* by multiple presses, the main press will be the one closest to the previous coordinates */
|
||||
if(menu->pointer.pressed[1])
|
||||
{
|
||||
int pointer_x2, pointer_y2, dist1, dist2;
|
||||
menu->pointer.x = ((pointer_x + 0x7fff) * (int)menu->frame_buf.width) / 0xFFFF;
|
||||
menu->pointer.y = ((pointer_y + 0x7fff) * (int)menu->frame_buf.height) / 0xFFFF;
|
||||
|
||||
pointer_x2 = input_driver_state(binds, 0, pointer_device, 1, RETRO_DEVICE_ID_POINTER_X);
|
||||
pointer_y2 = input_driver_state(binds, 0, pointer_device, 1, RETRO_DEVICE_ID_POINTER_Y);
|
||||
|
||||
dist1 = (pointer_x - menu->pointer.old_x) * (pointer_x - menu->pointer.old_x) +
|
||||
(pointer_y - menu->pointer.old_y) * (pointer_y - menu->pointer.old_y);
|
||||
dist2 = (pointer_x2 - menu->pointer.old_x) * (pointer_x2 - menu->pointer.old_x) +
|
||||
(pointer_y2 - menu->pointer.old_y) * (pointer_y2 - menu->pointer.old_y);
|
||||
|
||||
if (dist2 < dist1)
|
||||
{
|
||||
int temp;
|
||||
pointer_x = pointer_x2;
|
||||
pointer_y = pointer_y2;
|
||||
temp = menu->pointer.pressed[0];
|
||||
menu->pointer.pressed[0] = menu->pointer.pressed[1];
|
||||
menu->pointer.pressed[1] = temp;
|
||||
}
|
||||
}
|
||||
menu->pointer.old_x = pointer_x;
|
||||
menu->pointer.old_y = pointer_y;
|
||||
|
||||
screen_x = ((pointer_x + 0x7fff) * (int)menu->frame_buf.width) / 0xFFFF;
|
||||
screen_y = ((pointer_y + 0x7fff) * (int)menu->frame_buf.height) / 0xFFFF;
|
||||
|
||||
if (menu->pointer.pressed[0])
|
||||
{
|
||||
menu->mouse.x = screen_x;
|
||||
menu->mouse.y = screen_y;
|
||||
if (menu->mouse.x < 5)
|
||||
menu->mouse.x = 5;
|
||||
if (menu->mouse.y < 5)
|
||||
menu->mouse.y = 5;
|
||||
if (menu->mouse.x > (int)menu->frame_buf.width - 5)
|
||||
menu->mouse.x = menu->frame_buf.width - 5;
|
||||
if (menu->mouse.y > (int)menu->frame_buf.height - 5)
|
||||
menu->mouse.y = menu->frame_buf.height - 5;
|
||||
|
||||
menu->mouse.scrollup = (menu->mouse.y == 5);
|
||||
menu->mouse.scrolldown = (menu->mouse.y == (int)menu->frame_buf.height - 5);
|
||||
|
||||
menu->pointer.cancel = false;
|
||||
|
||||
if(menu->pointer.oldpressed[1] && !menu->pointer.pressed[1])
|
||||
menu->pointer.back = true;
|
||||
}
|
||||
else
|
||||
menu->pointer.cancel = screen_x < 5 || screen_x > (int)menu->frame_buf.width - 5
|
||||
|| screen_x < 5 || screen_x > (int)menu->frame_buf.height - 5;
|
||||
|
||||
menu->pointer.oldpressed[1] = menu->pointer.pressed[1];
|
||||
|
||||
|
||||
if (menu->pointer.pressed[0] || menu->pointer.back || menu->mouse.x != screen_x || menu->mouse.y != screen_y)
|
||||
runloop->frames.video.current.menu.animation.is_active = true;
|
||||
if (menu->pointer.pressed[0] || menu->pointer.oldpressed[0]
|
||||
|| menu->pointer.back || menu->pointer.dragging
|
||||
|| menu->pointer.dy != 0 || menu->pointer.dx != 0)
|
||||
runloop->frames.video.current.menu.animation.is_active = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -842,61 +785,88 @@ static int menu_input_mouse_post_iterate(menu_file_list_cbs_t *cbs,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pointer_tap(menu_file_list_cbs_t *cbs, const char *path,
|
||||
const char *label, unsigned type, unsigned action)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
|
||||
driver_t *driver = driver_get_ptr();
|
||||
rarch_setting_t *setting =
|
||||
(rarch_setting_t*)setting_find_setting
|
||||
(driver->menu->list_settings,
|
||||
driver->menu->menu_list->selection_buf->list[menu->navigation.selection_ptr].label);
|
||||
|
||||
if (menu->pointer.ptr == menu->navigation.selection_ptr
|
||||
&& cbs && cbs->action_toggle && setting &&
|
||||
(setting->type == ST_BOOL || setting->type == ST_UINT
|
||||
|| setting->type == ST_FLOAT || setting->type == ST_STRING))
|
||||
return cbs->action_toggle(type, label, MENU_ACTION_RIGHT, true);
|
||||
else if (menu->pointer.ptr == menu->navigation.selection_ptr)
|
||||
return cbs->action_ok(path, label, type, menu->navigation.selection_ptr);
|
||||
else
|
||||
menu->navigation.selection_ptr = menu->pointer.ptr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs,
|
||||
const char *path,
|
||||
const char *label, unsigned type, unsigned action)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
int ret = 0;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
return -1;
|
||||
|
||||
if (!settings->menu.pointer.enable
|
||||
#ifdef HAVE_OVERLAY
|
||||
|| (settings->input.overlay_enable && driver && driver->overlay)
|
||||
#endif
|
||||
)
|
||||
if (!settings->menu.pointer.enable || settings->input.overlay_enable)
|
||||
return 0;
|
||||
|
||||
#if defined(HAVE_XMB)
|
||||
if (driver->menu_ctx == &menu_ctx_xmb)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
if (menu->pointer.pressed[0])
|
||||
{
|
||||
if (menu->pointer.oldpressed[0])
|
||||
if (!menu->pointer.oldpressed[0])
|
||||
{
|
||||
if (menu->mouse.ptr <= menu_list_get_size(menu->menu_list)-1)
|
||||
menu_navigation_set(&menu->navigation, menu->mouse.ptr, false);
|
||||
}
|
||||
else
|
||||
menu->pointer.start_x = menu->pointer.x;
|
||||
menu->pointer.start_y = menu->pointer.y;
|
||||
menu->pointer.old_x = menu->pointer.x;
|
||||
menu->pointer.old_y = menu->pointer.y;
|
||||
menu->pointer.oldpressed[0] = true;
|
||||
}
|
||||
else if (menu->pointer.x != menu->pointer.start_x
|
||||
&& menu->pointer.y != menu->pointer.start_y)
|
||||
{
|
||||
menu->pointer.dragging = true;
|
||||
menu->pointer.dx = menu->pointer.x - menu->pointer.old_x;
|
||||
menu->pointer.dy = menu->pointer.y - menu->pointer.old_y;
|
||||
menu->pointer.old_x = menu->pointer.x;
|
||||
menu->pointer.old_y = menu->pointer.y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (menu->pointer.oldpressed[0])
|
||||
{
|
||||
rarch_setting_t *setting = NULL;
|
||||
|
||||
if (!menu->pointer.dragging)
|
||||
{
|
||||
if (menu->pointer.start_y < menu->header_height)
|
||||
{
|
||||
menu_list_pop_stack(menu->menu_list);
|
||||
}
|
||||
else if (menu->pointer.ptr <= menu_list_get_size(menu->menu_list)-1)
|
||||
{
|
||||
menu->pointer.oldpressed[0] = false;
|
||||
ret = pointer_tap(cbs, path, label, type, action);
|
||||
}
|
||||
}
|
||||
menu->pointer.oldpressed[0] = false;
|
||||
setting = (rarch_setting_t*)setting_find_setting
|
||||
(menu->list_settings,
|
||||
menu->menu_list->selection_buf->list[menu->navigation.selection_ptr].label);
|
||||
|
||||
if (menu->mouse.ptr == menu->navigation.selection_ptr && !menu->pointer.cancel
|
||||
&& cbs && cbs->action_toggle && setting &&
|
||||
(setting->type == ST_BOOL || setting->type == ST_UINT || setting->type == ST_FLOAT
|
||||
|| setting->type == ST_STRING))
|
||||
return cbs->action_toggle(type, label, MENU_ACTION_RIGHT, true);
|
||||
if (menu->mouse.ptr == menu->navigation.selection_ptr && !menu->pointer.cancel
|
||||
&& cbs && cbs->action_ok)
|
||||
return cbs->action_ok(path, label, type,
|
||||
menu->navigation.selection_ptr);
|
||||
else if (menu->mouse.ptr <= menu_list_get_size(menu->menu_list) - 1)
|
||||
menu_navigation_set(&menu->navigation, menu->mouse.ptr, false);
|
||||
menu->pointer.start_x = 0;
|
||||
menu->pointer.start_y = 0;
|
||||
menu->pointer.old_x = 0;
|
||||
menu->pointer.old_y = 0;
|
||||
menu->pointer.dx = 0;
|
||||
menu->pointer.dy = 0;
|
||||
menu->pointer.dragging = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -910,14 +880,18 @@ static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs,
|
||||
}
|
||||
menu->pointer.oldback = menu->pointer.back;
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void menu_input_post_iterate(int *ret, menu_file_list_cbs_t *cbs, const char *path,
|
||||
const char *label, unsigned type, unsigned action)
|
||||
{
|
||||
*ret = menu_input_mouse_post_iterate (cbs, path, label, type, action);
|
||||
*ret |= menu_input_pointer_post_iterate(cbs, path, label, type, action);
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (settings->menu.mouse.enable)
|
||||
*ret = menu_input_mouse_post_iterate (cbs, path, label, type, action);
|
||||
if (settings->menu.pointer.enable)
|
||||
*ret |= menu_input_pointer_post_iterate(cbs, path, label, type, action);
|
||||
}
|
||||
|
||||
unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input)
|
||||
@ -934,6 +908,7 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input)
|
||||
| (1ULL << RETRO_DEVICE_ID_JOYPAD_R);
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!menu || !driver)
|
||||
return 0;
|
||||
@ -1002,8 +977,11 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input)
|
||||
else
|
||||
ret = MENU_ACTION_NOOP;
|
||||
|
||||
menu_input_mouse(&ret);
|
||||
menu_input_pointer(&ret);
|
||||
if (settings->menu.mouse.enable)
|
||||
menu_input_mouse(&ret);
|
||||
|
||||
if (settings->menu.pointer.enable)
|
||||
menu_input_pointer(&ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user