(Zahrand) Rename wimp.c to zahrand

This commit is contained in:
twinaphex 2016-02-25 21:29:38 +01:00
parent c6dc2b6c3e
commit 816539f9df
6 changed files with 313 additions and 278 deletions

View File

@ -382,9 +382,9 @@ ifeq ($(HW_CONTEXT_MENU_DRIVERS), 1)
HAVE_MATERIALUI = 1
endif
ifeq ($(HAVE_WIMP),)
HAVE_WIMP = 1
endif
#ifeq ($(HAVE_ZAHRAND),)
#HAVE_ZAHRAND = 1
#endif
ifeq ($(HAVE_XMB),)
HAVE_XMB = 1
@ -392,7 +392,7 @@ ifeq ($(HW_CONTEXT_MENU_DRIVERS), 1)
else
HAVE_ZARCH = 0
HAVE_MATERIALUI = 0
HAVE_WIMP = 0
#HAVE_ZAHRAND = 0
HAVE_XMB = 0
endif
@ -404,10 +404,10 @@ ifeq ($(HAVE_MATERIALUI), 1)
OBJ += menu/drivers/materialui.o
DEFINES += -DHAVE_MATERIALUI
endif
ifeq ($(HAVE_WIMP), 1)
ifeq ($(HAVE_ZAHRAND), 1)
OBJ += deps/zahnrad/zahnrad.o
OBJ += menu/drivers/wimp.o
DEFINES += -DHAVE_WIMP
OBJ += menu/drivers/zr.o
DEFINES += -DHAVE_ZAHRAND
endif
ifeq ($(HAVE_ZARCH), 1)
OBJ += menu/drivers/zarch.o

View File

@ -869,9 +869,9 @@ MENU
#include "../menu/drivers/materialui.c"
#endif
#ifdef HAVE_WIMP
#ifdef HAVE_ZAHRAND
#include "../deps/zahnrad/zahnrad.c"
#include "../menu/drivers/wimp.c"
#include "../menu/drivers/zr.c"
#endif
#ifdef HAVE_ZARCH

View File

@ -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,
};

View File

@ -45,8 +45,8 @@ static const menu_ctx_driver_t *menu_ctx_drivers[] = {
#if defined(HAVE_MATERIALUI)
&menu_ctx_mui,
#endif
#if defined(HAVE_WIMP)
&menu_ctx_wimp,
#if defined(HAVE_ZAHRAND)
&menu_ctx_zr,
#endif
#if defined(HAVE_XMB)
&menu_ctx_xmb,

View File

@ -448,7 +448,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data);
extern menu_ctx_driver_t menu_ctx_xui;
extern menu_ctx_driver_t menu_ctx_rgui;
extern menu_ctx_driver_t menu_ctx_mui;
extern menu_ctx_driver_t menu_ctx_wimp;
extern menu_ctx_driver_t menu_ctx_zr;
extern menu_ctx_driver_t menu_ctx_xmb;
extern menu_ctx_driver_t menu_ctx_zarch;
extern menu_ctx_driver_t menu_ctx_null;

View File

@ -3,6 +3,7 @@ HAVE_RGUI=yes # Disable RGUI menu
HAVE_MATERIALUI=auto # Enable MaterialUI menu
HAVE_CHEEVOS=no # Enable Cheevos (achievements)
HAVE_XMB=auto # Enable XMB menu
HAVE_ZAHRAND=no # Enable Zahrand menu
HAVE_DYNAMIC=yes # Disable dynamic loading of libretro library
HAVE_SDL=auto # SDL support
HAVE_SDL2=auto # SDL2 support (disables SDL 1.x)