1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-05 09:48:42 +00:00

update nuklear.h

fix window clipping
remove dead code
This commit is contained in:
radius 2017-07-09 17:07:59 -05:00
parent ab45670738
commit 5ccdc8811c
15 changed files with 2429 additions and 1524 deletions

2
.gitignore vendored
View File

@ -110,3 +110,5 @@ obj-unix/
/pkg/msvc/msvc-2010/Release Cg/*.obj
/pkg/msvc/msvc-2010/Release Cg/*.res
/pkg/msvc/msvc-2010/Release Cg/*.pdb
retroarch.cfg

View File

@ -112,7 +112,7 @@ Skipped this one.
- VITA: Add cheevos support
- VITA: Add support for external USB if mounted
- WAYLAND: Fix menu mouse input
- WII: Add support for single-port 'PS1/PS2 to USB controller adapter'
- WII: Add support for single-port 'PS1/PS2 to USB controller adapter
# 1.6.0
- ANDROID: Allow remotes to retain OK/Cancel position when menu_swap_ok_cancel is enabled

View File

@ -729,10 +729,7 @@ endif
ifeq ($(HAVE_NUKLEAR), 1)
OBJ += menu/drivers/nuklear/nk_common.o
OBJ += menu/drivers/nuklear/nk_menu.o
OBJ += menu/drivers/nuklear/nk_wnd_main.o
OBJ += menu/drivers/nuklear/nk_wnd_file_picker.o
OBJ += menu/drivers/nuklear/nk_wnd_shader_parameters.o
OBJ += menu/drivers/nuklear/nk_wnd_settings.o
OBJ += menu/drivers/nuklear/nk_wnd_debug.o
OBJ += menu/drivers/nuklear.o
DEFINES += -DHAVE_NUKLEAR
endif

3245
deps/nuklear/nuklear.h vendored

File diff suppressed because it is too large Load Diff

View File

@ -1113,10 +1113,7 @@ MENU
#ifdef HAVE_NUKLEAR
#include "../menu/drivers/nuklear/nk_common.c"
#include "../menu/drivers/nuklear/nk_menu.c"
#include "../menu/drivers/nuklear/nk_wnd_shader_parameters.c"
#include "../menu/drivers/nuklear/nk_wnd_file_picker.c"
#include "../menu/drivers/nuklear/nk_wnd_settings.c"
#include "../menu/drivers/nuklear/nk_wnd_main.c"
#include "../menu/drivers/nuklear/nk_wnd_debug.c"
#include "../menu/drivers/nuklear.c"
#endif

View File

@ -52,8 +52,8 @@ static void nk_menu_init_device(nk_menu_handle_t *nk)
int w, h;
char buf[PATH_MAX_LENGTH] = {0};
fill_pathname_join(buf, nk->assets_directory,
"DroidSans.ttf", sizeof(buf));
fill_pathname_join(buf, "assets/nuklear",
"font.ttf", sizeof(buf));
nk_alloc.userdata.ptr = NULL;
nk_alloc.alloc = nk_common_mem_alloc;
@ -61,91 +61,26 @@ static void nk_menu_init_device(nk_menu_handle_t *nk)
nk_buffer_init(&device.cmds, &nk_alloc, 1024);
nk_font_atlas_init_default(&atlas);
nk_font_atlas_begin(&atlas);
font = nk_font_atlas_add_default(&atlas, 13.0f, NULL);
struct nk_font *font;
font = nk_font_atlas_add_from_file(&atlas, buf, 16, 0);
image = nk_font_atlas_bake(&atlas, &w, &h, NK_FONT_ATLAS_RGBA32);
device_upload_atlas(&device, image, w, h);
nk_upload_atlas(&device, image, w, h);
nk_font_atlas_end(&atlas, nk_handle_id((int)device.font_tex), &device.null);
nk_init_default(&nk->ctx, &font->handle);
nk_common_device_init(&device);
fill_pathname_join(buf, nk->assets_directory, "folder.png", sizeof(buf));
nk->icons.folder = nk_common_image_load(buf);
fill_pathname_join(buf, nk->assets_directory, "speaker.png", sizeof(buf));
nk->icons.speaker = nk_common_image_load(buf);
fill_pathname_join(buf, nk->assets_directory, "gamepad.png", sizeof(buf));
nk->icons.gamepad = nk_common_image_load(buf);
fill_pathname_join(buf, nk->assets_directory, "monitor.png", sizeof(buf));
nk->icons.monitor = nk_common_image_load(buf);
fill_pathname_join(buf, nk->assets_directory, "settings.png", sizeof(buf));
nk->icons.settings = nk_common_image_load(buf);
fill_pathname_join(buf, nk->assets_directory, "invader.png", sizeof(buf));
nk->icons.invader = nk_common_image_load(buf);
fill_pathname_join(buf, nk->assets_directory, "page_on.png", sizeof(buf));
nk->icons.page_on = nk_common_image_load(buf);
fill_pathname_join(buf, nk->assets_directory, "page_off.png", sizeof(buf));
nk->icons.page_off = nk_common_image_load(buf);
nk->size_changed = true;
nk_common_set_style(&nk->ctx, THEME_BLUE);
}
#define XMB_RIBBON_ROWS 64
#define XMB_RIBBON_COLS 64
#define XMB_RIBBON_VERTICES 2*XMB_RIBBON_COLS*XMB_RIBBON_ROWS-2*XMB_RIBBON_COLS
static void xmb_ribbon_set_vertex(float *ribbon_verts, unsigned idx, unsigned row, unsigned col)
{
ribbon_verts[idx++] = ((float)col) / (XMB_RIBBON_COLS-1) * 2.0f - 1.0f;
ribbon_verts[idx++] = ((float)row) / (XMB_RIBBON_ROWS-1) * 2.0f - 1.0f;
}
static void xmb_init_ribbon(nk_menu_handle_t * xmb)
{
video_coords_t coords;
unsigned vertices_total;
unsigned r, c, col;
unsigned i = 0;
float *ribbon_verts = NULL;
float *dummy = NULL;
video_coord_array_t *ca = menu_display_get_coords_array();
vertices_total = XMB_RIBBON_VERTICES;
dummy = (float*)calloc(4 * vertices_total, sizeof(float));
ribbon_verts = (float*)calloc(2 * vertices_total, sizeof(float));
/* Set up vertices */
for (r = 0; r < XMB_RIBBON_ROWS - 1; r++)
{
for (c = 0; c < XMB_RIBBON_COLS; c++)
{
col = r % 2 ? XMB_RIBBON_COLS - c - 1 : c;
xmb_ribbon_set_vertex(ribbon_verts, i, r, col);
xmb_ribbon_set_vertex(ribbon_verts, i + 2, r + 1, col);
i += 4;
}
}
coords.color = dummy;
coords.vertex = ribbon_verts;
coords.tex_coord = dummy;
coords.lut_tex_coord = dummy;
coords.vertices = vertices_total;
video_coord_array_append(ca, &coords, coords.vertices);
free(dummy);
free(ribbon_verts);
nk_common_set_style(&nk->ctx);
}
static void *nk_menu_init(void **userdata, bool video_is_threaded)
{
#if 1
unsigned i;
#endif
settings_t *settings = config_get_ptr();
nk_menu_handle_t *nk = NULL;
menu_handle_t *menu = (menu_handle_t*)
@ -170,14 +105,8 @@ static void *nk_menu_init(void **userdata, bool video_is_threaded)
"nuklear", sizeof(nk->assets_directory));
nk_menu_init_device(nk);
/* for demo purposes only, opens all windows */
#if 1
for (i = 0; i < NK_WND_LAST; i++)
for (i = 0; i < NK_WND_LAST; i++)
nk->window[i].open = true;
#else
nk->window[NK_WND_MAIN].open = true;
#endif
xmb_init_ribbon(nk);
return menu;
error:
@ -219,8 +148,9 @@ static void nk_menu_input_mouse_movement(struct nk_context *ctx)
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
nk_input_motion(ctx, mouse_x, mouse_y);
nk_input_scroll(ctx, menu_input_mouse_state(MENU_MOUSE_WHEEL_UP) -
menu_input_mouse_state(MENU_MOUSE_WHEEL_DOWN));
struct nk_vec2 scroll = {0 ,menu_input_mouse_state(MENU_MOUSE_WHEEL_UP) -
menu_input_mouse_state(MENU_MOUSE_WHEEL_DOWN)};
nk_input_scroll(ctx, scroll);
}
static void nk_menu_input_mouse_button(struct nk_context *ctx)
@ -251,42 +181,6 @@ static void nk_menu_get_message(void *data, const char *message)
strlcpy(nk->box_message, message, sizeof(nk->box_message));
}
static void nk_draw_bg(
nk_menu_handle_t *nk,
video_frame_info_t *video_info,
unsigned width,
unsigned height,
float alpha,
uintptr_t texture_id,
float *coord_black,
float *coord_white)
{
menu_display_ctx_draw_t draw;
settings_t *settings = config_get_ptr();
draw.x = 0;
draw.y = 0;
draw.texture = texture_id;
draw.width = width;
draw.height = height;
draw.color = &coord_black[0];
draw.vertex = NULL;
draw.tex_coord = NULL;
draw.vertex_count = 4;
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
draw.pipeline.id = 0;
menu_display_blend_begin();
menu_display_set_viewport(video_info->width, video_info->height);
draw.pipeline.id = VIDEO_SHADER_MENU_5;
draw.pipeline.active = false;
menu_display_draw_pipeline(&draw);
menu_display_draw(&draw);
menu_display_blend_end();
}
/* this is the main control function, it opens and closes windows and will
control the logic of the whole menu driver */
static void nk_menu_main(nk_menu_handle_t *nk)
@ -294,13 +188,8 @@ static void nk_menu_main(nk_menu_handle_t *nk)
struct nk_context *ctx = &nk->ctx;
if (nk->window[NK_WND_SETTINGS].open)
nk_wnd_settings(nk);
if (nk->window[NK_WND_SHADER_PARAMETERS].open)
nk_wnd_shader_parameters(nk);
if (nk->window[NK_WND_MAIN].open)
nk_wnd_main(nk, "Demo");
if (nk->window[NK_WND_DEBUG].open)
nk_wnd_debug(nk);
nk_buffer_info(&nk->status, &nk->ctx.memory);
}
@ -352,7 +241,6 @@ static void nk_menu_frame(void *data, video_frame_info_t *video_info)
nk_input_end(&nk->ctx);
nk_menu_main(nk);
nk_draw_bg(nk, video_info, width, height, 0.5, nk->textures.bg, coord_black, coord_white);
nk_common_device_draw(&device, &nk->ctx, width, height, NK_ANTI_ALIASING_ON);
menu_display_draw_cursor(
@ -404,7 +292,7 @@ static void nk_menu_context_load_textures(nk_menu_handle_t *nk,
{
image_texture_load(&ti, path);
video_driver_texture_load(&ti,
TEXTURE_FILTER_MIPMAP_LINEAR, &nk->textures.pointer);
TEXTURE_FILTER_MIPMAP_NEAREST, &nk->textures.pointer);
}
fill_pathname_join(path, iconpath,
@ -413,7 +301,7 @@ static void nk_menu_context_load_textures(nk_menu_handle_t *nk,
{
image_texture_load(&ti, path);
video_driver_texture_load(&ti,
TEXTURE_FILTER_MIPMAP_LINEAR, &nk->textures.bg);
TEXTURE_FILTER_MIPMAP_NEAREST, &nk->textures.bg);
}
}

View File

@ -110,7 +110,7 @@ void nk_common_device_init(struct nk_device *dev)
dev->attrib_pos = glGetAttribLocation(dev->prog, "Position");
dev->attrib_uv = glGetAttribLocation(dev->prog, "TexCoord");
dev->attrib_col = glGetAttribLocation(dev->prog, "Color");
glGenBuffers(1, &dev->vbo);
glGenBuffers(1, &dev->ebo);
glGenVertexArrays(1, &dev->vao);
@ -134,7 +134,7 @@ void nk_common_device_init(struct nk_device *dev)
#endif
}
void device_upload_atlas(struct nk_device *dev, const void *image, int width, int height)
void nk_upload_atlas(struct nk_device *dev, const void *image, int width, int height)
{
glGenTextures(1, &dev->font_tex);
glBindTexture(GL_TEXTURE_2D, dev->font_tex);
@ -229,14 +229,19 @@ void nk_common_device_draw(struct nk_device *dev,
#endif
/* fill converting configuration */
memset(&config, 0, sizeof(config));
config.global_alpha = 1.0f;
config.shape_AA = AA;
config.line_AA = AA;
NK_MEMSET(&config, 0, sizeof(config));
config.vertex_layout = vertex_layout;
config.vertex_size = sizeof(struct nk_vertex);
config.vertex_alignment = NK_ALIGNOF(struct nk_vertex);
config.null = dev->null;
config.circle_segment_count = 22;
config.vertex_layout = vertex_layout;
config.vertex_size = sizeof(struct nk_vertex);
config.curve_segment_count = 22;
config.arc_segment_count = 22;
config.global_alpha = 1.0f;
config.shape_AA = AA;
config.line_AA = AA;
#if 0
config.line_thickness = 1.0f;
#endif
@ -262,7 +267,8 @@ void nk_common_device_draw(struct nk_device *dev,
glBindTexture(GL_TEXTURE_2D, (GLuint)cmd->texture.id);
glScissor((GLint)cmd->clip_rect.x,
height - (GLint)(cmd->clip_rect.y + cmd->clip_rect.h),
(GLint)cmd->clip_rect.w, (GLint)cmd->clip_rect.h);
(GLint)cmd->clip_rect.w,
(GLint)cmd->clip_rect.h);
glDrawElements(GL_TRIANGLES, (GLsizei)cmd->elem_count,
GL_UNSIGNED_SHORT, offset);
#endif

View File

@ -15,18 +15,26 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
/* This file is intended for backend code. */
#ifndef _NK_COMMON_H
#define _NK_COMMON_H
/* This file is intended for backend code. */
#define NK_INCLUDE_FIXED_TYPES
#define NK_INCLUDE_STANDARD_IO
#define NK_INCLUDE_STANDARD_VARARGS
#define NK_INCLUDE_DEFAULT_ALLOCATOR
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
#define NK_INCLUDE_FONT_BAKING
#define NK_INCLUDE_DEFAULT_FONT
#define UNUSED(a) (void)a
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a)/sizeof(a)[0])
#define MAX_SIZE 256
#include <string.h>
#include "../../../deps/nuklear/nuklear.h"
#include "../../../deps/stb/stb_image.h"
@ -60,14 +68,13 @@
#endif
};
/* generic nuklear members*/
extern struct nk_font *font;
extern struct nk_font_atlas atlas;
extern struct nk_user_font usrfnt;
extern struct nk_allocator nk_alloc;
extern struct nk_device device;
enum theme {THEME_BLACK, THEME_WHITE, THEME_RED, THEME_BLUE, THEME_DARK};
struct nk_image nk_common_image_load(const char *filename);
char* nk_common_file_load(const char* path, size_t* size);
@ -84,6 +91,8 @@ void* nk_common_mem_alloc(nk_handle a, void *old, nk_size b);
void nk_common_mem_free(nk_handle unused, void *ptr);
void device_upload_atlas(struct nk_device *dev, const void *image, int width, int height);
void nk_upload_atlas(struct nk_device *dev, const void *image, int width, int height);
struct nk_image color_bars, test_entry, test_entry2;
#endif

View File

@ -15,8 +15,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
/* This file is intended for helper functions, custom controls, etc. */
/* This file is intended for menu functions, custom controls, etc. */
#include "nk_menu.h"
@ -37,130 +36,39 @@ void nk_wnd_get_state(nk_menu_handle_t *nk, const int id,
}
/* sets the theme */
void nk_common_set_style(struct nk_context *ctx, enum theme theme)
{
struct nk_color table[NK_COLOR_COUNT];
if (theme == THEME_WHITE) {
table[NK_COLOR_TEXT] = nk_rgba(70, 70, 70, 255);
table[NK_COLOR_WINDOW] = nk_rgba(175, 175, 175, 255);
table[NK_COLOR_HEADER] = nk_rgba(175, 175, 175, 255);
table[NK_COLOR_BORDER] = nk_rgba(0, 0, 0, 255);
table[NK_COLOR_BUTTON] = nk_rgba(185, 185, 185, 255);
table[NK_COLOR_BUTTON_HOVER] = nk_rgba(170, 170, 170, 255);
table[NK_COLOR_BUTTON_ACTIVE] = nk_rgba(160, 160, 160, 255);
table[NK_COLOR_TOGGLE] = nk_rgba(150, 150, 150, 255);
table[NK_COLOR_TOGGLE_HOVER] = nk_rgba(120, 120, 120, 255);
table[NK_COLOR_TOGGLE_CURSOR] = nk_rgba(175, 175, 175, 255);
table[NK_COLOR_SELECT] = nk_rgba(190, 190, 190, 255);
table[NK_COLOR_SELECT_ACTIVE] = nk_rgba(175, 175, 175, 255);
table[NK_COLOR_SLIDER] = nk_rgba(190, 190, 190, 255);
table[NK_COLOR_SLIDER_CURSOR] = nk_rgba(80, 80, 80, 255);
table[NK_COLOR_SLIDER_CURSOR_HOVER] = nk_rgba(70, 70, 70, 255);
table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = nk_rgba(60, 60, 60, 255);
table[NK_COLOR_PROPERTY] = nk_rgba(175, 175, 175, 255);
table[NK_COLOR_EDIT] = nk_rgba(150, 150, 150, 255);
table[NK_COLOR_EDIT_CURSOR] = nk_rgba(0, 0, 0, 255);
table[NK_COLOR_COMBO] = nk_rgba(175, 175, 175, 255);
table[NK_COLOR_CHART] = nk_rgba(160, 160, 160, 255);
table[NK_COLOR_CHART_COLOR] = nk_rgba(45, 45, 45, 255);
table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = nk_rgba( 255, 0, 0, 255);
table[NK_COLOR_SCROLLBAR] = nk_rgba(180, 180, 180, 255);
table[NK_COLOR_SCROLLBAR_CURSOR] = nk_rgba(140, 140, 140, 255);
table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = nk_rgba(150, 150, 150, 255);
table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = nk_rgba(160, 160, 160, 255);
table[NK_COLOR_TAB_HEADER] = nk_rgba(180, 180, 180, 255);
nk_style_from_table(ctx, table);
} else if (theme == THEME_RED) {
table[NK_COLOR_TEXT] = nk_rgba(190, 190, 190, 255);
table[NK_COLOR_WINDOW] = nk_rgba(30, 33, 40, 215);
table[NK_COLOR_HEADER] = nk_rgba(181, 45, 69, 220);
table[NK_COLOR_BORDER] = nk_rgba(51, 55, 67, 255);
table[NK_COLOR_BUTTON] = nk_rgba(181, 45, 69, 255);
table[NK_COLOR_BUTTON_HOVER] = nk_rgba(190, 50, 70, 255);
table[NK_COLOR_BUTTON_ACTIVE] = nk_rgba(195, 55, 75, 255);
table[NK_COLOR_TOGGLE] = nk_rgba(51, 55, 67, 255);
table[NK_COLOR_TOGGLE_HOVER] = nk_rgba(45, 60, 60, 255);
table[NK_COLOR_TOGGLE_CURSOR] = nk_rgba(181, 45, 69, 255);
table[NK_COLOR_SELECT] = nk_rgba(51, 55, 67, 255);
table[NK_COLOR_SELECT_ACTIVE] = nk_rgba(181, 45, 69, 255);
table[NK_COLOR_SLIDER] = nk_rgba(51, 55, 67, 255);
table[NK_COLOR_SLIDER_CURSOR] = nk_rgba(181, 45, 69, 255);
table[NK_COLOR_SLIDER_CURSOR_HOVER] = nk_rgba(186, 50, 74, 255);
table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = nk_rgba(191, 55, 79, 255);
table[NK_COLOR_PROPERTY] = nk_rgba(51, 55, 67, 255);
table[NK_COLOR_EDIT] = nk_rgba(51, 55, 67, 225);
table[NK_COLOR_EDIT_CURSOR] = nk_rgba(190, 190, 190, 255);
table[NK_COLOR_COMBO] = nk_rgba(51, 55, 67, 255);
table[NK_COLOR_CHART] = nk_rgba(51, 55, 67, 255);
table[NK_COLOR_CHART_COLOR] = nk_rgba(170, 40, 60, 255);
table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = nk_rgba( 255, 0, 0, 255);
table[NK_COLOR_SCROLLBAR] = nk_rgba(30, 33, 40, 255);
table[NK_COLOR_SCROLLBAR_CURSOR] = nk_rgba(64, 84, 95, 255);
table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = nk_rgba(70, 90, 100, 255);
table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = nk_rgba(75, 95, 105, 255);
table[NK_COLOR_TAB_HEADER] = nk_rgba(181, 45, 69, 220);
nk_style_from_table(ctx, table);
} else if (theme == THEME_BLUE) {
table[NK_COLOR_TEXT] = nk_rgba(20, 20, 20, 255);
table[NK_COLOR_WINDOW] = nk_rgba(202, 212, 214, 215);
table[NK_COLOR_HEADER] = nk_rgba(137, 182, 224, 220);
table[NK_COLOR_BORDER] = nk_rgba(140, 159, 173, 255);
table[NK_COLOR_BUTTON] = nk_rgba(137, 182, 224, 255);
table[NK_COLOR_BUTTON_HOVER] = nk_rgba(142, 187, 229, 255);
table[NK_COLOR_BUTTON_ACTIVE] = nk_rgba(147, 192, 234, 255);
table[NK_COLOR_TOGGLE] = nk_rgba(177, 210, 210, 255);
table[NK_COLOR_TOGGLE_HOVER] = nk_rgba(182, 215, 215, 255);
table[NK_COLOR_TOGGLE_CURSOR] = nk_rgba(137, 182, 224, 255);
table[NK_COLOR_SELECT] = nk_rgba(177, 210, 210, 255);
table[NK_COLOR_SELECT_ACTIVE] = nk_rgba(137, 182, 224, 255);
table[NK_COLOR_SLIDER] = nk_rgba(177, 210, 210, 255);
table[NK_COLOR_SLIDER_CURSOR] = nk_rgba(137, 182, 224, 245);
table[NK_COLOR_SLIDER_CURSOR_HOVER] = nk_rgba(142, 188, 229, 255);
table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = nk_rgba(147, 193, 234, 255);
table[NK_COLOR_PROPERTY] = nk_rgba(210, 210, 210, 255);
table[NK_COLOR_EDIT] = nk_rgba(210, 210, 210, 225);
table[NK_COLOR_EDIT_CURSOR] = nk_rgba(20, 20, 20, 255);
table[NK_COLOR_COMBO] = nk_rgba(210, 210, 210, 255);
table[NK_COLOR_CHART] = nk_rgba(210, 210, 210, 255);
table[NK_COLOR_CHART_COLOR] = nk_rgba(137, 182, 224, 255);
table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = nk_rgba( 255, 0, 0, 255);
table[NK_COLOR_SCROLLBAR] = nk_rgba(190, 200, 200, 255);
table[NK_COLOR_SCROLLBAR_CURSOR] = nk_rgba(64, 84, 95, 255);
table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = nk_rgba(70, 90, 100, 255);
table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = nk_rgba(75, 95, 105, 255);
table[NK_COLOR_TAB_HEADER] = nk_rgba(156, 193, 220, 255);
nk_style_from_table(ctx, table);
} else if (theme == THEME_DARK) {
table[NK_COLOR_TEXT] = nk_rgba(210, 210, 210, 255);
table[NK_COLOR_WINDOW] = nk_rgba(57, 67, 71, 215);
table[NK_COLOR_HEADER] = nk_rgba(51, 51, 56, 220);
table[NK_COLOR_BORDER] = nk_rgba(46, 46, 46, 255);
table[NK_COLOR_BUTTON] = nk_rgba(48, 83, 111, 255);
table[NK_COLOR_BUTTON_HOVER] = nk_rgba(58, 93, 121, 255);
table[NK_COLOR_BUTTON_ACTIVE] = nk_rgba(63, 98, 126, 255);
table[NK_COLOR_TOGGLE] = nk_rgba(50, 58, 61, 255);
table[NK_COLOR_TOGGLE_HOVER] = nk_rgba(45, 53, 56, 255);
table[NK_COLOR_TOGGLE_CURSOR] = nk_rgba(48, 83, 111, 255);
table[NK_COLOR_SELECT] = nk_rgba(57, 67, 61, 255);
table[NK_COLOR_SELECT_ACTIVE] = nk_rgba(48, 83, 111, 255);
table[NK_COLOR_SLIDER] = nk_rgba(50, 58, 61, 255);
table[NK_COLOR_SLIDER_CURSOR] = nk_rgba(48, 83, 111, 245);
table[NK_COLOR_SLIDER_CURSOR_HOVER] = nk_rgba(53, 88, 116, 255);
table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = nk_rgba(58, 93, 121, 255);
table[NK_COLOR_PROPERTY] = nk_rgba(50, 58, 61, 255);
table[NK_COLOR_EDIT] = nk_rgba(50, 58, 61, 225);
table[NK_COLOR_EDIT_CURSOR] = nk_rgba(210, 210, 210, 255);
table[NK_COLOR_COMBO] = nk_rgba(50, 58, 61, 255);
table[NK_COLOR_CHART] = nk_rgba(50, 58, 61, 255);
table[NK_COLOR_CHART_COLOR] = nk_rgba(48, 83, 111, 255);
table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = nk_rgba(255, 0, 0, 255);
table[NK_COLOR_SCROLLBAR] = nk_rgba(50, 58, 61, 255);
table[NK_COLOR_SCROLLBAR_CURSOR] = nk_rgba(48, 83, 111, 255);
table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = nk_rgba(53, 88, 116, 255);
table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = nk_rgba(58, 93, 121, 255);
table[NK_COLOR_TAB_HEADER] = nk_rgba(48, 83, 111, 255);
nk_style_from_table(ctx, table);
} else {
nk_style_default(ctx);
}
void nk_common_set_style(struct nk_context *ctx)
{
/* standard nuklear colors */
nk_colors[NK_COLOR_TEXT] = nk_rgba(158, 158, 158, 255);
nk_colors[NK_COLOR_WINDOW] = nk_rgba(57, 67, 71, 215);
nk_colors[NK_COLOR_HEADER] = nk_rgba(51, 51, 56, 220);
nk_colors[NK_COLOR_BORDER] = nk_rgba(46, 46, 46, 255);
nk_colors[NK_COLOR_BUTTON] = nk_rgba(255, 112, 67, 255);
nk_colors[NK_COLOR_BUTTON_HOVER] = nk_rgba(58, 93, 121, 255);
nk_colors[NK_COLOR_BUTTON_ACTIVE] = nk_rgba(63, 98, 126, 255);
nk_colors[NK_COLOR_TOGGLE] = nk_rgba(50, 58, 61, 255);
nk_colors[NK_COLOR_TOGGLE_HOVER] = nk_rgba(45, 53, 56, 255);
nk_colors[NK_COLOR_TOGGLE_CURSOR] = nk_rgba(48, 83, 111, 255);
nk_colors[NK_COLOR_SELECT] = nk_rgba(57, 67, 61, 255);
nk_colors[NK_COLOR_SELECT_ACTIVE] = nk_rgba(48, 83, 111, 255);
nk_colors[NK_COLOR_SLIDER] = nk_rgba(50, 58, 61, 255);
nk_colors[NK_COLOR_SLIDER_CURSOR] = nk_rgba(48, 83, 111, 245);
nk_colors[NK_COLOR_SLIDER_CURSOR_HOVER] = nk_rgba(53, 88, 116, 255);
nk_colors[NK_COLOR_SLIDER_CURSOR_ACTIVE] = nk_rgba(58, 93, 121, 255);
nk_colors[NK_COLOR_PROPERTY] = nk_rgba(50, 58, 61, 255);
nk_colors[NK_COLOR_EDIT] = nk_rgba(50, 58, 61, 225);
nk_colors[NK_COLOR_EDIT_CURSOR] = nk_rgba(210, 210, 210, 255);
nk_colors[NK_COLOR_COMBO] = nk_rgba(50, 58, 61, 255);
nk_colors[NK_COLOR_CHART] = nk_rgba(50, 58, 61, 255);
nk_colors[NK_COLOR_CHART_COLOR] = nk_rgba(48, 83, 111, 255);
nk_colors[NK_COLOR_CHART_COLOR_HIGHLIGHT] = nk_rgba(255, 0, 0, 255);
nk_colors[NK_COLOR_SCROLLBAR] = nk_rgba(50, 58, 61, 0);
nk_colors[NK_COLOR_SCROLLBAR_CURSOR] = nk_rgba(48, 83, 111, 0);
nk_colors[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = nk_rgba(53, 88, 116, 50);
nk_colors[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = nk_rgba(58, 93, 121, 100);
nk_colors[NK_COLOR_TAB_HEADER] = nk_rgba(48, 83, 111, 255);
nk_style_from_table(ctx, nk_colors);
/* style */
ctx->style.button.text_alignment = NK_TEXT_ALIGN_CENTERED;
}

View File

@ -15,7 +15,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
/* This file is intended for helper functions, custom controls, etc. */
/* This file is intended for menu functions, custom controls, etc. */
#ifndef _NK_MENU_H
#define _NK_MENU_H
@ -27,10 +27,7 @@
enum
{
NK_WND_MAIN = 0,
NK_WND_SETTINGS,
NK_WND_FILE_PICKER,
NK_WND_SHADER_PARAMETERS,
NK_WND_DEBUG = 0,
NK_WND_LAST
};
@ -80,14 +77,13 @@ typedef struct nk_menu_handle
video_font_raster_block_t list_block;
} nk_menu_handle_t;
void nk_wnd_shader_parameters(nk_menu_handle_t *nk);
void nk_wnd_main(nk_menu_handle_t *nk, const char* title);
bool nk_wnd_file_picker(nk_menu_handle_t *nk, char* title, char* in, char* out, char* filter);
void nk_wnd_settings(nk_menu_handle_t *nk);
struct nk_color nk_colors[NK_COLOR_COUNT];
void nk_wnd_debug(nk_menu_handle_t *nk);
void nk_wnd_set_state(nk_menu_handle_t *nk, const int id,
struct nk_vec2 pos, struct nk_vec2 size);
void nk_wnd_get_state(nk_menu_handle_t *nk, const int id,
struct nk_vec2 *pos, struct nk_vec2 *size);
void nk_common_set_style(struct nk_context *ctx, enum theme theme);
void nk_common_set_style(struct nk_context *ctx);
#endif

View File

@ -33,17 +33,17 @@
#include "../../../configuration.h"
#include "../../../retroarch.h"
void nk_wnd_shader_parameters(nk_menu_handle_t *nk)
void nk_wnd_debug(nk_menu_handle_t *nk)
{
unsigned i;
video_shader_ctx_t shader_info;
struct nk_panel layout;
struct nk_context *ctx = &nk->ctx;
const int id = NK_WND_SHADER_PARAMETERS;
const int id = NK_WND_DEBUG;
if (nk_begin(ctx, "Shader Parameters", nk_rect(240, 10, 300, 400),
if (nk_begin(ctx, "Debug", nk_rect(10, 10, 400, 500),
NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
NK_WINDOW_SCALABLE|NK_WINDOW_BORDER))
NK_WINDOW_BORDER))
{
nk_layout_row_dynamic(ctx, 30, 1);

View File

@ -1,157 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2017 - Jean-André Santoni
* Copyright (C) 2016-2017- Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <file/file_path.h>
#include <compat/strl.h>
#include <string/stdstring.h>
#include <lists/string_list.h>
#include <lists/dir_list.h>
#include "nk_menu.h"
#include "../../menu_driver.h"
#include "../../frontend/frontend_driver.h"
#include "../../configuration.h"
static bool assets_loaded;
static char path[PATH_MAX_LENGTH];
struct icon_list
{
struct nk_image disk;
struct nk_image folder;
struct nk_image file;
};
struct icon_list icons;
void load_icons(nk_menu_handle_t *nk)
{
char buf[PATH_MAX_LENGTH] = {0};
fill_pathname_join(buf, nk->assets_directory,
"harddisk.png", sizeof(buf));
icons.disk = nk_common_image_load(buf);
fill_pathname_join(buf, nk->assets_directory,
"folder.png", sizeof(buf));
icons.folder = nk_common_image_load(buf);
fill_pathname_join(buf, nk->assets_directory,
"file.png", sizeof(buf));
icons.file = nk_common_image_load(buf);
assets_loaded = true;
}
bool nk_wnd_file_picker(nk_menu_handle_t *nk, char* title, char* in, char* out, char* filter)
{
struct nk_panel layout;
struct nk_context *ctx = &nk->ctx;
const int id = NK_WND_FILE_PICKER;
int i = 0;
static file_list_t *drives = NULL;
static struct string_list *files = NULL;
settings_t *settings = config_get_ptr();
bool ret = false;
if (!drives)
{
drives = (file_list_t*)calloc(1, sizeof(file_list_t));
frontend_driver_parse_drive_list(drives, false);
}
if (!string_is_empty(in) && string_is_empty(path))
{
strlcpy(path, in, sizeof(path));
files = dir_list_new(path, filter, true, settings->bools.show_hidden_files, true, false);
}
if (!assets_loaded)
load_icons(nk);
if (nk_begin(ctx, title, nk_rect(10, 10, 500, 400),
NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
NK_WINDOW_BORDER))
{
nk_layout_row_dynamic(ctx, 30, 4);
if (drives->size == 0)
{
if(nk_button_image_label(ctx, icons.disk, "/",
NK_TEXT_CENTERED))
{
fill_pathname_join(path, "/",
"", sizeof(path));
files = dir_list_new(path, filter, true, settings->bools.show_hidden_files, true, false);
}
}
else
{
for (i = 0; i < drives->size; i++)
{
if(nk_button_image_label(ctx, icons.disk, drives->list[i].path,
NK_TEXT_CENTERED))
{
fill_pathname_join(path, drives->list[i].path,
"", sizeof(path));
files = dir_list_new(path, filter, true, settings->bools.show_hidden_files, true, false);
}
}
}
nk_layout_row_dynamic(ctx, 30, 1);
if (files)
{
for (i = 0; i < files->size; i++)
{
if (nk_button_image_label(ctx, path_is_directory(files->elems[i].data) ?
icons.folder : icons.file, path_basename(files->elems[i].data),
NK_TEXT_RIGHT))
{
strlcpy (path, files->elems[i].data, sizeof(path));
if (path_is_directory (path))
files = dir_list_new(path, filter, true, settings->bools.show_hidden_files, true, false);
}
}
}
nk_layout_row_dynamic(ctx, 30, 1);
{
if (nk_button_text(ctx, "OK", 2))
{
ret = true;
strlcpy(out, path, sizeof(path));
nk->window[NK_WND_FILE_PICKER].open = false;
path[0] = '\0';
}
}
}
/* sort the dir list with directories first */
dir_list_sort(files, true);
/* copy the path variable to out*/
/* save position and size to restore after context reset */
nk_wnd_set_state(nk, id, nk_window_get_position(ctx), nk_window_get_size(ctx));
nk_end(ctx);
return ret;
}

View File

@ -1,107 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2017 - Jean-André Santoni
* Copyright (C) 2016-2017 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "nk_menu.h"
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <file/file_path.h>
#include <compat/strl.h>
#include <string/stdstring.h>
#include <lists/string_list.h>
#include "../../menu_driver.h"
#include "../../configuration.h"
static char* out;
static char core[PATH_MAX_LENGTH] = {0};
static char content[PATH_MAX_LENGTH] = {0};
float ratio[] = {0.85f, 0.15f, 0.0f}; /* TODO: what should this be? */
void nk_wnd_main(nk_menu_handle_t *nk, const char* title)
{
unsigned i;
video_shader_ctx_t shader_info;
struct nk_panel layout;
struct nk_context *ctx = &nk->ctx;
const int id = NK_WND_MAIN;
settings_t *settings = config_get_ptr();
char core_basename[PATH_MAX_LENGTH] = {0};
static char picker_filter[PATH_MAX_LENGTH];
static char picker_title[PATH_MAX_LENGTH];
static char* picker_startup_dir;
int len_core, len_content = 0;
strlcpy(core_basename, path_basename(core), sizeof(core_basename));
if (!out)
out = core;
if (!string_is_empty(core))
len_core = strlen(path_basename(core));
if (!string_is_empty(content))
len_content = strlen(content);
if (nk->window[NK_WND_FILE_PICKER].open)
{
if (nk_wnd_file_picker(nk, picker_title, picker_startup_dir, out, picker_filter))
{
RARCH_LOG ("%s selected\n", out);
nk_window_close(&nk->ctx, picker_title);
}
}
if (nk_begin(ctx, title, nk_rect(240, 10, 600, 400),
NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
NK_WINDOW_SCALABLE|NK_WINDOW_BORDER))
{
nk_layout_row_dynamic(ctx, 30, 1);
nk_label(ctx,"Core:", NK_TEXT_LEFT);
nk_layout_row(ctx, NK_DYNAMIC, 30, 3, ratio);
nk_edit_string(ctx, NK_EDIT_SIMPLE, core_basename, &len_core, 64, nk_filter_default);
if (nk_button_text(ctx, "...", 3))
{
out = core;
strlcpy(picker_title, "Select core", sizeof(picker_title));
strlcpy(picker_filter, ".dll", sizeof(picker_filter));
picker_startup_dir = settings->paths.directory_libretro;
nk->window[NK_WND_FILE_PICKER].open = true;
}
nk_layout_row_dynamic(ctx, 30, 1);
nk_label(ctx,"Content:", NK_TEXT_LEFT);
nk_layout_row(ctx, NK_DYNAMIC, 30, 3, ratio);
nk_edit_string(ctx, NK_EDIT_SIMPLE, content, &len_content, 64, nk_filter_default);
if (nk_button_text(ctx, "...", 3))
{
out = content;
strlcpy(picker_title, "Select content", sizeof(picker_title));
strlcpy(picker_filter, ".zip", sizeof(picker_filter));
picker_startup_dir = settings->paths.directory_menu_content;
nk->window[NK_WND_FILE_PICKER].open = true;
}
}
/* save position and size to restore after context reset */
nk_wnd_set_state(nk, id, nk_window_get_position(ctx), nk_window_get_size(ctx));
nk_end(ctx);
}

View File

@ -1,49 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2017 - Jean-André Santoni
* Copyright (C) 2016-2017 - Andrés Suárez
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "nk_menu.h"
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <file/file_path.h>
#include <string/stdstring.h>
#include <lists/string_list.h>
#include "../../menu_driver.h"
void nk_wnd_settings(nk_menu_handle_t *nk)
{
unsigned i;
video_shader_ctx_t shader_info;
struct nk_panel layout;
struct nk_context *ctx = &nk->ctx;
const int id = NK_WND_SETTINGS;
if (nk_begin(ctx, "Settings", nk_rect(240, 10, 300, 400),
NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
NK_WINDOW_SCALABLE|NK_WINDOW_BORDER))
{
nk_layout_row_dynamic(ctx, 30, 1);
}
/* save position and size to restore after context reset */
nk_wnd_set_state(nk, id, nk_window_get_position(ctx), nk_window_get_size(ctx));
nk_end(ctx);
}

View File

@ -83,6 +83,7 @@ static void menu_display_gl_blend_begin(void)
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_SCISSOR_TEST);
shader_info.data = NULL;
shader_info.idx = VIDEO_SHADER_STOCK_BLEND;
@ -94,6 +95,7 @@ static void menu_display_gl_blend_begin(void)
static void menu_display_gl_blend_end(void)
{
glDisable(GL_BLEND);
glDisable(GL_SCISSOR_TEST);
}
static void menu_display_gl_viewport(void *data)