|
|
|
@ -21,7 +21,9 @@
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#include <retro_assert.h>
|
|
|
|
|
#include <compat/posix_string.h>
|
|
|
|
|
#include <file/file_path.h>
|
|
|
|
|
#include <formats/image.h>
|
|
|
|
@ -45,11 +47,10 @@
|
|
|
|
|
#include "../../verbosity.h"
|
|
|
|
|
#include "../../tasks/tasks_internal.h"
|
|
|
|
|
|
|
|
|
|
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
|
|
|
|
#include "../../gfx/common/gl_common.h"
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "../../deps/zahnrad/zahnrad.h"
|
|
|
|
|
|
|
|
|
|
#define MAX_VERTEX_MEMORY 512 * 1024
|
|
|
|
@ -58,12 +59,15 @@
|
|
|
|
|
#ifndef MIN
|
|
|
|
|
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef MAX
|
|
|
|
|
#define MAX(a,b) ((a) < (b) ? (b) : (a))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef CLAMP
|
|
|
|
|
#define CLAMP(i,v,x) (MAX(MIN(v,x), i))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define LEN(a) (sizeof(a)/sizeof(a)[0])
|
|
|
|
|
#define UNUSED(a) ((void)(a))
|
|
|
|
|
|
|
|
|
@ -73,6 +77,66 @@
|
|
|
|
|
#define WINDOW_WIDTH 1200
|
|
|
|
|
#define WINDOW_HEIGHT 800
|
|
|
|
|
|
|
|
|
|
enum theme
|
|
|
|
|
{
|
|
|
|
|
THEME_BLACK = 0,
|
|
|
|
|
THEME_WHITE,
|
|
|
|
|
THEME_RED,
|
|
|
|
|
THEME_BLUE,
|
|
|
|
|
THEME_DARK
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct wimp
|
|
|
|
|
{
|
|
|
|
|
void *memory;
|
|
|
|
|
struct zr_context ctx;
|
|
|
|
|
enum theme theme;
|
|
|
|
|
struct zr_memory_status status;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct device
|
|
|
|
|
{
|
|
|
|
|
struct zr_buffer cmds;
|
|
|
|
|
struct zr_draw_null_texture null;
|
|
|
|
|
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
|
|
|
|
GLuint vbo, vao, ebo;
|
|
|
|
|
|
|
|
|
|
GLuint prog;
|
|
|
|
|
GLuint vert_shdr;
|
|
|
|
|
GLuint frag_shdr;
|
|
|
|
|
|
|
|
|
|
GLint attrib_pos;
|
|
|
|
|
GLint attrib_uv;
|
|
|
|
|
GLint attrib_col;
|
|
|
|
|
|
|
|
|
|
GLint uniform_tex;
|
|
|
|
|
GLint uniform_proj;
|
|
|
|
|
GLuint font_tex;
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
wimp_TEXTURE_POINTER = 0,
|
|
|
|
|
wimp_TEXTURE_BACK,
|
|
|
|
|
wimp_TEXTURE_SWITCH_ON,
|
|
|
|
|
wimp_TEXTURE_SWITCH_OFF,
|
|
|
|
|
wimp_TEXTURE_TAB_MAIN_ACTIVE,
|
|
|
|
|
wimp_TEXTURE_TAB_PLAYLISTS_ACTIVE,
|
|
|
|
|
wimp_TEXTURE_TAB_SETTINGS_ACTIVE,
|
|
|
|
|
wimp_TEXTURE_TAB_MAIN_PASSIVE,
|
|
|
|
|
wimp_TEXTURE_TAB_PLAYLISTS_PASSIVE,
|
|
|
|
|
wimp_TEXTURE_TAB_SETTINGS_PASSIVE,
|
|
|
|
|
wimp_TEXTURE_LAST
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
wimp_SYSTEM_TAB_MAIN = 0,
|
|
|
|
|
wimp_SYSTEM_TAB_PLAYLISTS,
|
|
|
|
|
wimp_SYSTEM_TAB_SETTINGS
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int z =0 ;
|
|
|
|
|
|
|
|
|
|
bool zr_checkbox_bool(struct zr_context* cx, const char* text, bool *active)
|
|
|
|
@ -95,11 +159,12 @@ static void zr_labelf(struct zr_context *ctx, enum zr_text_align align, const ch
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* zahnrad code */
|
|
|
|
|
enum theme {THEME_BLACK, THEME_WHITE, THEME_RED, THEME_BLUE, THEME_DARK};
|
|
|
|
|
|
|
|
|
|
static void set_style(struct zr_context *ctx, enum theme theme)
|
|
|
|
|
{
|
|
|
|
|
if (theme == THEME_WHITE) {
|
|
|
|
|
switch (theme)
|
|
|
|
|
{
|
|
|
|
|
case THEME_WHITE:
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TEXT] = zr_rgba(70, 70, 70, 255);
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TEXT_HOVERING] = zr_rgba(10, 10, 10, 255);
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TEXT_ACTIVE] = zr_rgba(20, 20, 20, 255);
|
|
|
|
@ -143,7 +208,8 @@ static void set_style(struct zr_context *ctx, enum theme theme)
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TABLE_LINES] = zr_rgba(100, 100, 100, 255);
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TAB_HEADER] = zr_rgba(180, 180, 180, 255);
|
|
|
|
|
ctx->style.colors[ZR_COLOR_SCALER] = zr_rgba(100, 100, 100, 255);
|
|
|
|
|
} else if (theme == THEME_RED) {
|
|
|
|
|
break;
|
|
|
|
|
case THEME_RED:
|
|
|
|
|
ctx->style.rounding[ZR_ROUNDING_SCROLLBAR] = 0;
|
|
|
|
|
ctx->style.properties[ZR_PROPERTY_SCROLLBAR_SIZE] = zr_vec2(10,10);
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TEXT] = zr_rgba(190, 190, 190, 255);
|
|
|
|
@ -189,7 +255,8 @@ static void set_style(struct zr_context *ctx, enum theme theme)
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TABLE_LINES] = zr_rgba(100, 100, 100, 255);
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TAB_HEADER] = zr_rgba(181, 45, 69, 220);
|
|
|
|
|
ctx->style.colors[ZR_COLOR_SCALER] = zr_rgba(100, 100, 100, 255);
|
|
|
|
|
} else if (theme == THEME_BLUE) {
|
|
|
|
|
break;
|
|
|
|
|
case THEME_BLUE:
|
|
|
|
|
ctx->style.rounding[ZR_ROUNDING_SCROLLBAR] = 0;
|
|
|
|
|
ctx->style.properties[ZR_PROPERTY_SCROLLBAR_SIZE] = zr_vec2(10,10);
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TEXT] = zr_rgba(20, 20, 20, 255);
|
|
|
|
@ -235,7 +302,8 @@ static void set_style(struct zr_context *ctx, enum theme theme)
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TABLE_LINES] = zr_rgba(100, 100, 100, 255);
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TAB_HEADER] = zr_rgba(156, 193, 220, 255);
|
|
|
|
|
ctx->style.colors[ZR_COLOR_SCALER] = zr_rgba(100, 100, 100, 255);
|
|
|
|
|
} else if (theme == THEME_DARK) {
|
|
|
|
|
break;
|
|
|
|
|
case THEME_DARK:
|
|
|
|
|
ctx->style.rounding[ZR_ROUNDING_SCROLLBAR] = 0;
|
|
|
|
|
ctx->style.properties[ZR_PROPERTY_SCROLLBAR_SIZE] = zr_vec2(10,10);
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TEXT] = zr_rgba(210, 210, 210, 255);
|
|
|
|
@ -281,20 +349,13 @@ static void set_style(struct zr_context *ctx, enum theme theme)
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TABLE_LINES] = zr_rgba(100, 100, 100, 255);
|
|
|
|
|
ctx->style.colors[ZR_COLOR_TAB_HEADER] = zr_rgba(48, 83, 111, 255);
|
|
|
|
|
ctx->style.colors[ZR_COLOR_SCALER] = zr_rgba(100, 100, 100, 255);
|
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
zr_load_default_style(ctx, ZR_DEFAULT_ALL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wimp {
|
|
|
|
|
void *memory;
|
|
|
|
|
struct zr_context ctx;
|
|
|
|
|
enum theme theme;
|
|
|
|
|
struct zr_memory_status status;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int wimp_control(struct zr_context *ctx, int width, int height, struct wimp *gui)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
@ -471,26 +532,10 @@ static char* file_load(const char* path, size_t* siz)
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct device {
|
|
|
|
|
struct zr_buffer cmds;
|
|
|
|
|
struct zr_draw_null_texture null;
|
|
|
|
|
GLuint vbo, vao, ebo;
|
|
|
|
|
|
|
|
|
|
GLuint prog;
|
|
|
|
|
GLuint vert_shdr;
|
|
|
|
|
GLuint frag_shdr;
|
|
|
|
|
|
|
|
|
|
GLint attrib_pos;
|
|
|
|
|
GLint attrib_uv;
|
|
|
|
|
GLint attrib_col;
|
|
|
|
|
|
|
|
|
|
GLint uniform_tex;
|
|
|
|
|
GLint uniform_proj;
|
|
|
|
|
GLuint font_tex;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void device_init(struct device *dev)
|
|
|
|
|
{
|
|
|
|
|
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
|
|
|
|
GLint status;
|
|
|
|
|
static const GLchar *vertex_shader =
|
|
|
|
|
"#version 300 es\n"
|
|
|
|
@ -567,6 +612,7 @@ static void device_init(struct device *dev)
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
|
|
|
|
glBindVertexArray(0);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct zr_user_font font_bake_and_upload(struct device *dev, struct zr_font *font,
|
|
|
|
@ -624,7 +670,8 @@ static struct zr_user_font font_bake_and_upload(struct device *dev, struct zr_fo
|
|
|
|
|
free(img);
|
|
|
|
|
img = img_rgba;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
|
|
|
|
/* upload baked font image */
|
|
|
|
|
glGenTextures(1, &dev->font_tex);
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, dev->font_tex);
|
|
|
|
@ -632,7 +679,8 @@ static struct zr_user_font font_bake_and_upload(struct device *dev, struct zr_fo
|
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)img_width, (GLsizei)img_height, 0,
|
|
|
|
|
GL_RGBA, GL_UNSIGNED_BYTE, img);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
free(ttf_blob);
|
|
|
|
|
free(tmp);
|
|
|
|
|
free(img);
|
|
|
|
@ -654,6 +702,7 @@ static struct zr_user_font font_bake_and_upload(struct device *dev, struct zr_fo
|
|
|
|
|
|
|
|
|
|
static void device_shutdown(struct device *dev)
|
|
|
|
|
{
|
|
|
|
|
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
|
|
|
|
glDetachShader(dev->prog, dev->vert_shdr);
|
|
|
|
|
glDetachShader(dev->prog, dev->frag_shdr);
|
|
|
|
|
glDeleteShader(dev->vert_shdr);
|
|
|
|
@ -662,11 +711,14 @@ static void device_shutdown(struct device *dev)
|
|
|
|
|
glDeleteTextures(1, &dev->font_tex);
|
|
|
|
|
glDeleteBuffers(1, &dev->vbo);
|
|
|
|
|
glDeleteBuffers(1, &dev->ebo);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void device_draw(struct device *dev, struct zr_context *ctx, int width, int height,
|
|
|
|
|
static void device_draw(struct device *dev,
|
|
|
|
|
struct zr_context *ctx, int width, int height,
|
|
|
|
|
enum zr_anti_aliasing AA)
|
|
|
|
|
{
|
|
|
|
|
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
|
|
|
|
GLint last_prog, last_tex;
|
|
|
|
|
GLint last_ebo, last_vbo, last_vao;
|
|
|
|
|
GLfloat ortho[4][4] = {
|
|
|
|
@ -759,6 +811,7 @@ static void device_draw(struct device *dev, struct zr_context *ctx, int width, i
|
|
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, (GLuint)last_ebo);
|
|
|
|
|
glBindVertexArray((GLuint)last_vao);
|
|
|
|
|
glDisable(GL_SCISSOR_TEST);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void* mem_alloc(zr_handle unused, size_t size)
|
|
|
|
@ -794,33 +847,14 @@ static void wimp_input_button(struct zr_context *ctx)
|
|
|
|
|
int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
|
|
|
|
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
|
|
|
|
|
|
|
|
|
zr_input_button(ctx, ZR_BUTTON_LEFT, mouse_x, mouse_y, menu_input_mouse_state(MENU_MOUSE_LEFT_BUTTON));
|
|
|
|
|
zr_input_button(ctx, ZR_BUTTON_RIGHT, mouse_x, mouse_y, menu_input_mouse_state(MENU_MOUSE_RIGHT_BUTTON));
|
|
|
|
|
zr_input_button(ctx, ZR_BUTTON_LEFT,
|
|
|
|
|
mouse_x, mouse_y, menu_input_mouse_state(MENU_MOUSE_LEFT_BUTTON));
|
|
|
|
|
zr_input_button(ctx, ZR_BUTTON_RIGHT,
|
|
|
|
|
mouse_x, mouse_y, menu_input_mouse_state(MENU_MOUSE_RIGHT_BUTTON));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* zahnrad code */
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
wimp_TEXTURE_POINTER = 0,
|
|
|
|
|
wimp_TEXTURE_BACK,
|
|
|
|
|
wimp_TEXTURE_SWITCH_ON,
|
|
|
|
|
wimp_TEXTURE_SWITCH_OFF,
|
|
|
|
|
wimp_TEXTURE_TAB_MAIN_ACTIVE,
|
|
|
|
|
wimp_TEXTURE_TAB_PLAYLISTS_ACTIVE,
|
|
|
|
|
wimp_TEXTURE_TAB_SETTINGS_ACTIVE,
|
|
|
|
|
wimp_TEXTURE_TAB_MAIN_PASSIVE,
|
|
|
|
|
wimp_TEXTURE_TAB_PLAYLISTS_PASSIVE,
|
|
|
|
|
wimp_TEXTURE_TAB_SETTINGS_PASSIVE,
|
|
|
|
|
wimp_TEXTURE_LAST
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
wimp_SYSTEM_TAB_MAIN = 0,
|
|
|
|
|
wimp_SYSTEM_TAB_PLAYLISTS,
|
|
|
|
|
wimp_SYSTEM_TAB_SETTINGS
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define wimp_SYSTEM_TAB_END wimp_SYSTEM_TAB_SETTINGS
|
|
|
|
|
|
|
|
|
@ -2332,7 +2366,7 @@ static int wimp_pointer_tap(void *userdata,
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
menu_ctx_driver_t menu_ctx_wimp = {
|
|
|
|
|
menu_ctx_driver_t menu_ctx_zr = {
|
|
|
|
|
NULL,
|
|
|
|
|
wimp_get_message,
|
|
|
|
|
generic_menu_iterate,
|
|
|
|
@ -2363,7 +2397,7 @@ menu_ctx_driver_t menu_ctx_wimp = {
|
|
|
|
|
wimp_list_set_selection,
|
|
|
|
|
NULL,
|
|
|
|
|
wimp_load_image,
|
|
|
|
|
"wimp",
|
|
|
|
|
"zahrand",
|
|
|
|
|
wimp_environ,
|
|
|
|
|
wimp_pointer_tap,
|
|
|
|
|
};
|