1
0
mirror of https://github.com/libretro/RetroArch synced 2025-03-23 10:20:57 +00:00

Get rid of menu_input_{get|set}_selection

This commit is contained in:
libretroadmin 2023-05-10 18:45:49 +02:00
parent 38895600dc
commit 1ad253e81a
6 changed files with 62 additions and 88 deletions

@ -3595,6 +3595,7 @@ static void materialui_render(void *data,
gfx_display_t *p_disp = disp_get_ptr();
struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list;
menu_input_t *menu_input = &menu_st->input_state;
file_list_t *list = menu_list ? MENU_LIST_GET_SELECTION(menu_list, 0) : NULL;
size_t entries_end = list ? list->size : 0;
size_t selection = menu_st->selection_ptr;
@ -3818,7 +3819,7 @@ static void materialui_render(void *data,
(pointer_y < (entry_y + node->entry_height)))
{
/* Pointer selection is always updated */
menu_input_set_pointer_selection((unsigned)i);
menu_input->ptr = (unsigned)i;
/* If pointer is pressed and stationary... */
if (mui->pointer.pressed && !mui->pointer.dragged)
@ -5239,6 +5240,7 @@ static void materialui_render_menu_list(
size_t last_entry;
struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list;
menu_input_t *menu_input = &menu_st->input_state;
file_list_t *list = menu_list ? MENU_LIST_GET_SELECTION(menu_list, 0) : NULL;
size_t entries_end = list ? list->size : 0;
unsigned header_height = p_disp->header_height;
@ -5246,7 +5248,7 @@ static void materialui_render_menu_list(
(!mui->scrollbar.dragged)
&& (!(mui->flags & MUI_FLAG_SHOW_FULLSCREEN_THUMBNAILS))
&& (mui->touch_feedback_alpha >= 0.5f)
&& (mui->touch_feedback_selection == menu_input_get_pointer_selection());
&& (mui->touch_feedback_selection == menu_input->ptr);
bool entry_value_enabled = (mui->list_view_type == MUI_LIST_VIEW_DEFAULT);
bool entry_sublabel_enabled =
(mui->list_view_type != MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON) &&
@ -5562,6 +5564,7 @@ static void materialui_render_entry_touch_feedback(
materialui_handle_t *mui,
gfx_display_t *p_disp,
void *userdata,
menu_input_t *menu_input,
unsigned video_width, unsigned video_height,
unsigned header_height, int x_offset,
size_t current_selection)
@ -5580,11 +5583,11 @@ static void materialui_render_entry_touch_feedback(
* or pointer may no longer be held above the entry
* currently selected for feedback animations */
if (pointer_active)
pointer_active = (mui->touch_feedback_selection == menu_input_get_pointer_selection()) &&
(mui->pointer.x > mui->landscape_optimization.border_width) &&
(mui->pointer.x < video_width - mui->landscape_optimization.border_width - mui->nav_bar_layout_width) &&
(mui->pointer.y >= header_height) &&
(mui->pointer.y <= video_height - mui->nav_bar_layout_height - mui->status_bar.height);
pointer_active = (mui->touch_feedback_selection == menu_input->ptr)
&& (mui->pointer.x > mui->landscape_optimization.border_width)
&& (mui->pointer.x < video_width - mui->landscape_optimization.border_width - mui->nav_bar_layout_width)
&& (mui->pointer.y >= header_height)
&& (mui->pointer.y <= video_height - mui->nav_bar_layout_height - mui->status_bar.height);
/* Touch feedback highlight fades in when pointer
* is held stationary on a menu entry */
@ -7018,6 +7021,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
settings_t *settings = config_get_ptr();
gfx_display_t *p_disp = disp_get_ptr();
struct menu_state *menu_st = menu_state_get_ptr();
menu_input_t *menu_input = &menu_st->input_state;
size_t selection = menu_st->selection_ptr;
unsigned header_height = p_disp->header_height;
enum gfx_animation_ticker_type
@ -7122,7 +7126,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
/* Draw 'short press' touch feedback highlight */
materialui_render_entry_touch_feedback(
mui, p_disp, userdata, video_width, video_height,
mui, p_disp, userdata, menu_input, video_width, video_height,
header_height, list_x_offset, selection);
/* Draw 'highlighted entry' selection box */

@ -10073,7 +10073,7 @@ static void ozone_render(void *data,
&& (ozone->pointer.y < entry_y + node->height))
{
/* Pointer selection is always updated */
menu_input_set_pointer_selection((unsigned)i);
menu_input->ptr = (unsigned)i;
/* If pointer is a mouse, then automatically
* select entry under cursor */

@ -4963,6 +4963,7 @@ static void rgui_render(
gfx_animation_t *p_anim = anim_get_ptr();
gfx_display_t *p_disp = disp_get_ptr();
struct menu_state *menu_st = menu_state_get_ptr();
menu_input_t *menu_input = &menu_st->input_state;
menu_list_t *menu_list = menu_st->entries.list;
rgui_t *rgui = (rgui_t*)data;
enum gfx_animation_ticker_type
@ -5108,14 +5109,10 @@ static void rgui_render(
/* Update currently 'highlighted' item */
if (rgui->pointer.y > rgui->term_layout.start_y)
{
unsigned new_ptr;
menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &old_start);
/* NOTE: It's okay for this to go out of range
* (limits are checked in rgui_pointer_up()) */
new_ptr = (unsigned)((rgui->pointer.y - rgui->term_layout.start_y) / rgui->font_height_stride) + old_start;
menu_input_set_pointer_selection(new_ptr);
menu_input->ptr = (unsigned)((rgui->pointer.y - rgui->term_layout.start_y) / rgui->font_height_stride) + old_start;
}
/* Allow drag-scrolling if items are currently off-screen */

@ -4756,6 +4756,7 @@ static void xmb_render(void *data,
xmb_handle_t *xmb = (xmb_handle_t*)data;
settings_t *settings = config_get_ptr();
struct menu_state *menu_st = menu_state_get_ptr();
menu_input_t *menu_input = &menu_st->input_state;
menu_list_t *menu_list = menu_st->entries.list;
size_t end = MENU_LIST_GET_SELECTION(menu_list, 0)->size;
gfx_display_t *p_disp = disp_get_ptr();
@ -4842,7 +4843,7 @@ static void xmb_render(void *data,
if ( (pointer_y > y1)
&& (pointer_y < y2))
{
menu_input_set_pointer_selection((unsigned)i);
menu_input->ptr = (unsigned)i;
break;
}
}

@ -4591,21 +4591,6 @@ void menu_input_get_pointer_state(menu_input_pointer_t *copy_target)
memcpy(copy_target, &menu_input->pointer, sizeof(menu_input_pointer_t));
}
unsigned menu_input_get_pointer_selection(void)
{
struct menu_state *menu_st = &menu_driver_state;
menu_input_t *menu_input = &menu_st->input_state;
return menu_input->ptr;
}
void menu_input_set_pointer_selection(unsigned selection)
{
struct menu_state *menu_st = &menu_driver_state;
menu_input_t *menu_input = &menu_st->input_state;
menu_input->ptr = selection;
}
const char *menu_input_dialog_get_buffer(void)
{
struct menu_state *menu_st = &menu_driver_state;
@ -5081,8 +5066,8 @@ static bool menu_input_key_bind_iterate(
new_binds.timer_hold .timeout_end = current_usec + input_bind_hold_us;
}
#else
if ((new_binds.skip && !_binds->skip) ||
menu_input_key_bind_poll_find_trigger(
if ( (new_binds.skip && !_binds->skip)
|| menu_input_key_bind_poll_find_trigger(
settings->uints.input_max_users,
_binds, &new_binds, &(new_binds.buffer)))
complete = true;
@ -7743,8 +7728,7 @@ int generic_menu_entry_action(
case MENU_ACTION_RIGHT:
case MENU_ACTION_CANCEL:
menu_entries_get_title(title_name, sizeof(title_name));
menu_driver_get_current_menu_label(menu_st, current_label, sizeof(current_label));
break;
/* fall-through */
case MENU_ACTION_UP:
case MENU_ACTION_DOWN:
case MENU_ACTION_SCROLL_UP:
@ -7823,10 +7807,11 @@ int generic_menu_entry_action(
/* If core was launched via a playlist, flush
* to playlist entry menu */
if ( string_is_equal(parent_label,
msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RPL_ENTRY_ACTIONS)) &&
(!string_is_empty(deferred_path) &&
!string_is_empty(content_path) &&
string_is_equal(deferred_path, content_path)))
msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RPL_ENTRY_ACTIONS))
&& (!string_is_empty(deferred_path)
&& !string_is_empty(content_path)
&& string_is_equal(deferred_path, content_path))
)
{
flush_target = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RPL_ENTRY_ACTIONS);
break;
@ -7880,8 +7865,8 @@ bool menu_driver_iterate(
enum menu_action action,
retro_time_t current_time)
{
return (menu_st->driver_data &&
generic_menu_iterate(
return ( menu_st->driver_data
&& generic_menu_iterate(
menu_st,
p_disp,
p_anim,
@ -7893,8 +7878,7 @@ bool menu_driver_iterate(
bool menu_input_dialog_start_search(void)
{
input_driver_state_t
*input_st = input_state_get_ptr();
input_driver_state_t *input_st = input_state_get_ptr();
#ifdef HAVE_ACCESSIBILITY
settings_t *settings = config_get_ptr();
bool accessibility_enable = settings->bools.accessibility_enable;
@ -8024,11 +8008,13 @@ size_t menu_update_fullscreen_thumbnail_label(
if (!string_is_empty(selected_entry.rich_label))
thumbnail_label = selected_entry.rich_label;
/* > State slot label */
else if (is_quick_menu && (
else if ( is_quick_menu
&& (
string_is_equal(selected_entry.label, "state_slot")
|| string_is_equal(selected_entry.label, "loadstate")
|| string_is_equal(selected_entry.label, "savestate")
))
)
)
{
size_t _len = strlcpy(tmpstr, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_STATE_SLOT),
sizeof(tmpstr));
@ -8036,7 +8022,8 @@ size_t menu_update_fullscreen_thumbnail_label(
config_get_ptr()->ints.state_slot);
thumbnail_label = tmpstr;
}
else if (is_quick_menu && (
else if ( is_quick_menu
&& (
string_is_equal(selected_entry.label, "replay_slot")
|| string_is_equal(selected_entry.label, "record_replay")
|| string_is_equal(selected_entry.label, "play_replay")

@ -242,21 +242,6 @@ extern struct key_desc key_descriptors[RARCH_MAX_KEYS];
**/
void menu_input_get_pointer_state(menu_input_pointer_t *copy_target);
/**
* Get the menu item index currently selected or hovered over by the pointer.
*
* @return the selected menu index
**/
unsigned menu_input_get_pointer_selection(void);
/**
* Set the menu item index that is currently selected or hovered over by the
* pointer. Note: Each menu driver is responsible for setting this.
*
* @param selection the selected menu index
**/
void menu_input_set_pointer_selection(unsigned selection);
typedef struct menu_input_ctx_line
{
const char *label;