Refactor menu_navigation.c

This commit is contained in:
twinaphex 2015-09-25 19:32:35 +02:00
parent 4c41899e28
commit 4aa96ab2f0
5 changed files with 36 additions and 33 deletions

View File

@ -198,6 +198,7 @@ void menu_free(menu_handle_t *menu)
menu_shader_free(menu);
menu_input_free();
menu_navigation_free();
menu_driver_free(menu);
#ifdef HAVE_DYNAMIC

View File

@ -27,7 +27,6 @@ struct menu_entries
size_t begin;
menu_list_t *menu_list;
rarch_setting_t *list_settings;
menu_navigation_t navigation;
};
static menu_entries_t *menu_entries_get_ptr(void)
@ -56,14 +55,6 @@ menu_list_t *menu_list_get_ptr(void)
return entries->menu_list;
}
menu_navigation_t *menu_navigation_get_ptr(void)
{
menu_entries_t *entries = menu_entries_get_ptr();
if (!entries)
return NULL;
return &entries->navigation;
}
/* Sets the starting index of the menu entry list. */
void menu_entries_set_start(size_t i)
{

View File

@ -21,7 +21,6 @@
#include <boolean.h>
#include "menu_navigation.h"
#include "menu_list.h"
#include "menu_setting.h"
#include "menu_entry.h"
@ -48,8 +47,6 @@ int menu_entries_get_core_title(char *title_msg, size_t title_msg_len);
rarch_setting_t *menu_setting_get_ptr(void);
menu_navigation_t *menu_navigation_get_ptr(void);
bool menu_entries_needs_refresh(void);
void menu_entries_set_refresh(bool nonblocking);

View File

@ -18,6 +18,11 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
#endif
#include <limits.h>
#include <ctype.h>
@ -25,6 +30,29 @@
#include "../configuration.h"
typedef struct menu_navigation
{
struct
{
/* Quick jumping indices with L/R.
* Rebuilt when parsing directory. */
struct
{
size_t list[2 * (26 + 2) + 1];
unsigned size;
} indices;
unsigned acceleration;
} scroll;
size_t selection_ptr;
} menu_navigation_t;
static menu_navigation_t menu_navigation_state;
static menu_navigation_t *menu_navigation_get_ptr(void)
{
return &menu_navigation_state;
}
bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
{
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
@ -229,3 +257,8 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
return false;
}
void menu_navigation_free(void)
{
memset(&menu_navigation_state, 0, sizeof(menu_navigation_t));
}

View File

@ -18,32 +18,11 @@
#define _MENU_NAVIGATION_H
#include <stddef.h>
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct menu_navigation
{
struct
{
/* Quick jumping indices with L/R.
* Rebuilt when parsing directory. */
struct
{
size_t list[2 * (26 + 2) + 1];
unsigned size;
} indices;
unsigned acceleration;
} scroll;
size_t selection_ptr;
} menu_navigation_t;
enum menu_navigation_ctl_state
{
MENU_NAVIGATION_CTL_CLEAR = 0,
@ -63,6 +42,8 @@ enum menu_navigation_ctl_state
bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data);
void menu_navigation_free(void);
#ifdef __cplusplus
}
#endif