reorganization

This commit is contained in:
radius 2017-12-06 14:48:05 -05:00
parent a6c0106afd
commit 4ea402833f
15 changed files with 26 additions and 755 deletions

View File

@ -157,9 +157,9 @@ else
CFLAGS += -std=gnu99
endif
INCLUDES += -I. -I./retro -I./nuklear
INCLUDES += -I. -I./nuklear_soft -I./nuklear
OBJECTS := libretro.o app.o retro/SDL_gfxPrimitives.o retro/retro_surface.o
OBJECTS := libretro.o gui.o nuklear_soft/SDL_gfxPrimitives.o nuklear_soft/retro_surface.o
CFLAGS += -Wall -pedantic $(fpic)

View File

@ -11,7 +11,7 @@
#include <time.h>
#include <libretro.h>
#include "libretro-core.h"
#include <gui.h>
extern retro_log_printf_t log_cb;
@ -26,40 +26,19 @@ extern retro_log_printf_t log_cb;
#include "nuklear.h"
#include "nuklear_retro_soft.h"
// RSDL surface (implementation from RSDL_wrapper)
static RSDL_Surface *screen_surface;
static nk_retro_Font *RSDL_font;
/* macros */
#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])
/* Platform */
float bg[4];
struct nk_color background;
/* GUI */
struct nk_context *ctx;
/* ===============================================================
*
* EXAMPLE
*
* ===============================================================*/
/* This are some code examples to provide a small overview of what can be
* done with this library. To try out an example uncomment the include
* and the corresponding function. */
//#define NO_EXAMPLE
#if !defined(EXAMPLE_CANVAS) && !defined(NO_EXAMPLE)
#include "node_editor.c"
#include "calculator.c"
#include "overview.c"
#endif
@ -79,68 +58,53 @@ int gui_init()
if (!RSDL_font)
return -1;
/* GUI */
ctx = nk_retro_init(RSDL_font,screen_surface,rwidth,rheight);
/* style.c */
/* THEME_BLACK THEME_WHITE THEME_RED THEME_BLUE THEME_DARK */
/* icons */
#if !defined(EXAMPLE_CANVAS) && !defined(NO_EXAMPLE)
background = nk_rgb(28,48,62);
#endif
log_cb(RETRO_LOG_INFO, "Init nuklear %d\n",0);
log_cb(RETRO_LOG_INFO, "Init nuklear %d\n",0);
return 0;
return 0;
}
int gui_free()
{
//FIXME: memory leak here
free(RSDL_font);
nk_retro_shutdown();
Retro_FreeSurface(screen_surface);
return 0;
return 0;
}
int gui_event()
{
int evt;
int evt;
nk_input_begin(ctx);
nk_retro_handle_event(&evt,1);
nk_input_end(ctx);
nk_input_begin(ctx);
nk_retro_handle_event(&evt,1);
nk_input_end(ctx);
return 0;
return 0;
}
int gui_main()
{
/* -------------- EXAMPLES ---------------- */
/* uncomment here and corresponding header */
/* to enable demo example */
#if !defined(EXAMPLE_CANVAS) && !defined(NO_EXAMPLE)
calculator(ctx);
overview(ctx);
node_editor(ctx);
#endif
/* ----------------------------------------- */
/* Draw */
// nk_color_fv(bg, background);
nk_retro_render(nk_rgb(30,30,30));
#if !defined(EXAMPLE_CANVAS) && !defined(NO_EXAMPLE)
overview(ctx);
#endif
nk_retro_render(nk_rgb(30,30,30));
return 0;
}
int gui_frame()
{
gui_event();
gui_main();
gui_event();
gui_main();
return 0;
return 0;
}

View File

@ -19,7 +19,7 @@ endif
GLES_LIB := -lGLESv3 -lEGL
LOCAL_SRC_FILES += $(addprefix ../,$(wildcard *.c) ./libretro.c ./app.c ./libretro-common/glsym/rglgen.c ./libretro-common/glsym/glsym_es2.c)
LOCAL_SRC_FILES += $(addprefix ../,$(wildcard *.c) ./libretro.c ./gui.c ./libretro-common/glsym/rglgen.c ./libretro-common/glsym/glsym_es2.c)
LOCAL_CFLAGS += -O2 -Wall -std=gnu99 -ffast-math -DHAVE_OPENGLES2 -DHAVE_OPENGLES3 -DGLES3 -DGLES -I../libretro-common/include -I../../../example -I../../ -DAND -I/ubuntu14/home/not6/android-ndk-r11c/platforms/android-18/arch-arm/usr/include
LOCAL_LDLIBS += $(GLES_LIB)

View File

@ -1,27 +0,0 @@
#define BASE_WIDTH 1024
#define BASE_HEIGHT 768
#define MAX_WIDTH 2048
#define MAX_HEIGHT 2048
#ifndef M16B
#define M16B
#endif
//#undef M16B
#ifndef M16B
#define PIXEL_TYPE unsigned
#define MPITCH 1
#else
#define PIXEL_TYPE unsigned short
#define MPITCH 2
#endif
extern unsigned rwidth ,rheight;
#ifdef M16B
extern unsigned short int *retroscreen;
#else
extern unsigned int *retroscreen;
#endif

View File

@ -6,7 +6,7 @@
#include <libretro.h>
#include "libretro-core.h"
#include <gui.h>
unsigned rwidth = BASE_WIDTH;
unsigned rheight = BASE_HEIGHT;

View File

@ -1,112 +0,0 @@
[![Build Status](https://travis-ci.org/vurtun/nuklear.svg)](https://travis-ci.org/vurtun/nuklear)
# Nuklear
This is a minimal state immediate mode graphical user interface toolkit
written in ANSI C and licensed under public domain. It was designed as a simple
embeddable user interface for application and does not have any dependencies,
a default renderbackend or OS window and input handling but instead provides a very modular
library approach by using simple input state for input and draw
commands describing primitive shapes as output. So instead of providing a
layered library that tries to abstract over a number of platform and
render backends it only focuses on the actual UI.
## Features
- Immediate mode graphical user interface toolkit
- Single header library
- Written in C89 (ANSI C)
- Small codebase (~15kLOC)
- Focus on portability, efficiency and simplicity
- No dependencies (not even the standard library if not wanted)
- Fully skinnable and customizable
- Low memory footprint with total memory control if needed or wanted
- UTF-8 support
- No global or hidden state
- Customizable library modules (you can compile and use only what you need)
- Optional font baker and vertex buffer output
## Building
This library is self contained in one single header file and can be used either
in header only mode or in implementation mode. The header only mode is used
by default when included and allows including this header in other headers
and does not contain the actual implementation.
The implementation mode requires to define the preprocessor macro
`NK_IMPLEMENTATION` in *one* .c/.cpp file before `#include`ing this file, e.g.:
```c
#define NK_IMPLEMENTATION
#include "nuklear.h"
```
IMPORTANT: Every time you include "nuklear.h" you have to define the same optional flags.
This is very important not doing it either leads to compiler errors or even worse stack corruptions.
## Gallery
![screenshot](https://cloud.githubusercontent.com/assets/8057201/11761525/ae06f0ca-a0c6-11e5-819d-5610b25f6ef4.gif)
![screen](https://cloud.githubusercontent.com/assets/8057201/13538240/acd96876-e249-11e5-9547-5ac0b19667a0.png)
![screen2](https://cloud.githubusercontent.com/assets/8057201/13538243/b04acd4c-e249-11e5-8fd2-ad7744a5b446.png)
![node](https://cloud.githubusercontent.com/assets/8057201/9976995/e81ac04a-5ef7-11e5-872b-acd54fbeee03.gif)
![skinning](https://cloud.githubusercontent.com/assets/8057201/15991632/76494854-30b8-11e6-9555-a69840d0d50b.png)
![gamepad](https://cloud.githubusercontent.com/assets/8057201/14902576/339926a8-0d9c-11e6-9fee-a8b73af04473.png)
## Example
```c
/* init gui state */
struct nk_context ctx;
nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);
enum {EASY, HARD};
int op = EASY;
float value = 0.6f;
int i = 20;
if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220),
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
/* fixed widget pixel width */
nk_layout_row_static(&ctx, 30, 80, 1);
if (nk_button_label(&ctx, "button")) {
/* event handling */
}
/* fixed widget window ratio width */
nk_layout_row_dynamic(&ctx, 30, 2);
if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD;
/* custom widget pixel width */
nk_layout_row_begin(&ctx, NK_STATIC, 30, 2);
{
nk_layout_row_push(&ctx, 50);
nk_label(&ctx, "Volume:", NK_TEXT_LEFT);
nk_layout_row_push(&ctx, 110);
nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f);
}
nk_layout_row_end(&ctx);
}
nk_end(&ctx);
```
![example](https://cloud.githubusercontent.com/assets/8057201/10187981/584ecd68-675c-11e5-897c-822ef534a876.png)
## Bindings:
Java: https://github.com/glegris/nuklear4j
Golang: https://github.com/golang-ui/nuklear
Rust: https://github.com/snuk182/nuklear-rust
Chicken: https://github.com/wasamasa/nuklear
## Credits:
Developed by Micha Mettke and every direct or indirect contributor to the GitHub.
Embeds `stb_texedit`, `stb_truetype` and `stb_rectpack` by Sean Barret (public domain)
Embeds `ProggyClean.ttf` font by Tristan Grimmer (MIT license).
Big thank you to Omar Cornut (ocornut@github) for his [imgui](https://github.com/ocornut/imgui) library and
giving me the inspiration for this library, Casey Muratori for handmade hero
and his original immediate mode graphical user interface idea and Sean
Barret for his amazing single header [libraries](https://github.com/nothings/stb) which restored my faith
in libraries and brought me to create some of my own.
## License:
This software is dual-licensed to the public domain and under the following
license: you are granted a perpetual, irrevocable license to copy, modify,
publish and distribute this file as you see fit.

View File

@ -1,64 +0,0 @@
/* nuklear - v1.00 - public domain */
static void
calculator(struct nk_context *ctx)
{
if (nk_begin(ctx, "Calculator", nk_rect(10, 10, 180, 250),
NK_WINDOW_BORDER|NK_WINDOW_NO_SCROLLBAR|NK_WINDOW_MOVABLE))
{
static int set = 0, prev = 0, op = 0;
static const char numbers[] = "789456123";
static const char ops[] = "+-*/";
static double a = 0, b = 0;
static double *current = &a;
size_t i = 0;
int solve = 0;
{int len; char buffer[256];
nk_layout_row_dynamic(ctx, 35, 1);
len = snprintf(buffer, 256, "%.2f", *current);
nk_edit_string(ctx, NK_EDIT_SIMPLE, buffer, &len, 255, nk_filter_float);
buffer[len] = 0;
*current = atof(buffer);}
nk_layout_row_dynamic(ctx, 35, 4);
for (i = 0; i < 16; ++i) {
if (i >= 12 && i < 15) {
if (i > 12) continue;
if (nk_button_label(ctx, "C")) {
a = b = op = 0; current = &a; set = 0;
} if (nk_button_label(ctx, "0")) {
*current = *current*10.0f; set = 0;
} if (nk_button_label(ctx, "=")) {
solve = 1; prev = op; op = 0;
}
} else if (((i+1) % 4)) {
if (nk_button_text(ctx, &numbers[(i/4)*3+i%4], 1)) {
*current = *current * 10.0f + numbers[(i/4)*3+i%4] - '0';
set = 0;
}
} else if (nk_button_text(ctx, &ops[i/4], 1)) {
if (!set) {
if (current != &b) {
current = &b;
} else {
prev = op;
solve = 1;
}
}
op = ops[i/4];
set = 1;
}
}
if (solve) {
if (prev == '+') a = a + b;
if (prev == '-') a = a - b;
if (prev == '*') a = a * b;
if (prev == '/') a = a / b;
current = &a;
if (set) current = &b;
b = 0; set = 0;
}
}
nk_end(ctx);
}

View File

@ -1,343 +0,0 @@
/* nuklear - v1.00 - public domain */
/* This is a simple node editor just to show a simple implementation and that
* it is possible to achieve it with this library. While all nodes inside this
* example use a simple color modifier as content you could change them
* to have your custom content depending on the node time.
* Biggest difference to most usual implementation is that this example does
* not have connectors on the right position of the property that it links.
* This is mainly done out of laziness and could be implemented as well but
* requires calculating the position of all rows and add connectors.
* In addition adding and removing nodes is quite limited at the
* moment since it is based on a simple fixed array. If this is to be converted
* into something more serious it is probably best to extend it.*/
struct node {
int ID;
char name[32];
struct nk_rect bounds;
float value;
struct nk_color color;
int input_count;
int output_count;
struct node *next;
struct node *prev;
};
struct node_link {
int input_id;
int input_slot;
int output_id;
int output_slot;
struct nk_vec2 in;
struct nk_vec2 out;
};
struct node_linking {
int active;
struct node *node;
int input_id;
int input_slot;
};
struct node_editor {
int initialized;
struct node node_buf[32];
struct node_link links[64];
struct node *begin;
struct node *end;
int node_count;
int link_count;
struct nk_rect bounds;
struct node *selected;
int show_grid;
struct nk_vec2 scrolling;
struct node_linking linking;
};
static struct node_editor nodeEditor;
static void
node_editor_push(struct node_editor *editor, struct node *node)
{
if (!editor->begin) {
node->next = NULL;
node->prev = NULL;
editor->begin = node;
editor->end = node;
} else {
node->prev = editor->end;
if (editor->end)
editor->end->next = node;
node->next = NULL;
editor->end = node;
}
}
static void
node_editor_pop(struct node_editor *editor, struct node *node)
{
if (node->next)
node->next->prev = node->prev;
if (node->prev)
node->prev->next = node->next;
if (editor->end == node)
editor->end = node->prev;
if (editor->begin == node)
editor->begin = node->next;
node->next = NULL;
node->prev = NULL;
}
static struct node*
node_editor_find(struct node_editor *editor, int ID)
{
struct node *iter = editor->begin;
while (iter) {
if (iter->ID == ID)
return iter;
iter = iter->next;
}
return NULL;
}
static void
node_editor_add(struct node_editor *editor, const char *name, struct nk_rect bounds,
struct nk_color col, int in_count, int out_count)
{
static int IDs = 0;
struct node *node;
assert((nk_size)editor->node_count < LEN(editor->node_buf));
node = &editor->node_buf[editor->node_count++];
node->ID = IDs++;
node->value = 0;
node->color = nk_rgb(255, 0, 0);
node->input_count = in_count;
node->output_count = out_count;
node->color = col;
node->bounds = bounds;
strcpy(node->name, name);
node_editor_push(editor, node);
}
static void
node_editor_link(struct node_editor *editor, int in_id, int in_slot,
int out_id, int out_slot)
{
struct node_link *link;
assert((nk_size)editor->link_count < LEN(editor->links));
link = &editor->links[editor->link_count++];
link->input_id = in_id;
link->input_slot = in_slot;
link->output_id = out_id;
link->output_slot = out_slot;
}
static void
node_editor_init(struct node_editor *editor)
{
memset(editor, 0, sizeof(*editor));
editor->begin = NULL;
editor->end = NULL;
node_editor_add(editor, "Source", nk_rect(40, 10, 180, 220), nk_rgb(255, 0, 0), 0, 1);
node_editor_add(editor, "Source", nk_rect(40, 260, 180, 220), nk_rgb(0, 255, 0), 0, 1);
node_editor_add(editor, "Combine", nk_rect(400, 100, 180, 220), nk_rgb(0,0,255), 2, 2);
node_editor_link(editor, 0, 0, 2, 0);
node_editor_link(editor, 1, 0, 2, 1);
editor->show_grid = nk_true;
}
static int
node_editor(struct nk_context *ctx)
{
int n = 0;
struct nk_rect total_space;
const struct nk_input *in = &ctx->input;
struct nk_command_buffer *canvas;
struct node *updated = 0;
struct node_editor *nodedit = &nodeEditor;
if (!nodeEditor.initialized) {
node_editor_init(&nodeEditor);
nodeEditor.initialized = 1;
}
if (nk_begin(ctx, "NodeEdit", nk_rect(0, 0, 800, 600),
NK_WINDOW_BORDER|NK_WINDOW_NO_SCROLLBAR|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE))
{
/* allocate complete window space */
canvas = nk_window_get_canvas(ctx);
total_space = nk_window_get_content_region(ctx);
nk_layout_space_begin(ctx, NK_STATIC, total_space.h, nodedit->node_count);
{
struct node *it = nodedit->begin;
struct nk_rect size = nk_layout_space_bounds(ctx);
if (nodedit->show_grid) {
/* display grid */
float x, y;
const float grid_size = 32.0f;
const struct nk_color grid_color = nk_rgb(50, 50, 50);
for (x = (float)fmod(size.x - nodedit->scrolling.x, grid_size); x < size.w; x += grid_size)
nk_stroke_line(canvas, x+size.x, size.y, x+size.x, size.y+size.h, 1.0f, grid_color);
for (y = (float)fmod(size.y - nodedit->scrolling.y, grid_size); y < size.h; y += grid_size)
nk_stroke_line(canvas, size.x, y+size.y, size.x+size.w, y+size.y, 1.0f, grid_color);
}
/* execute each node as a movable group */
struct nk_panel *node;
while (it) {
/* calculate scrolled node window position and size */
nk_layout_space_push(ctx, nk_rect(it->bounds.x - nodedit->scrolling.x,
it->bounds.y - nodedit->scrolling.y, it->bounds.w, it->bounds.h));
/* execute node window */
if (nk_group_begin(ctx, it->name, NK_WINDOW_MOVABLE|NK_WINDOW_NO_SCROLLBAR|NK_WINDOW_BORDER|NK_WINDOW_TITLE))
{
/* always have last selected node on top */
node = nk_window_get_panel(ctx);
if (nk_input_mouse_clicked(in, NK_BUTTON_LEFT, node->bounds) &&
(!(it->prev && nk_input_mouse_clicked(in, NK_BUTTON_LEFT,
nk_layout_space_rect_to_screen(ctx, node->bounds)))) &&
nodedit->end != it)
{
updated = it;
}
/* ================= NODE CONTENT =====================*/
nk_layout_row_dynamic(ctx, 25, 1);
nk_button_color(ctx, it->color);
it->color.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, it->color.r, 255, 1,1);
it->color.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, it->color.g, 255, 1,1);
it->color.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, it->color.b, 255, 1,1);
it->color.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, it->color.a, 255, 1,1);
/* ====================================================*/
nk_group_end(ctx);
}
{
/* node connector and linking */
float space;
struct nk_rect bounds;
bounds = nk_layout_space_rect_to_local(ctx, node->bounds);
bounds.x += nodedit->scrolling.x;
bounds.y += nodedit->scrolling.y;
it->bounds = bounds;
/* output connector */
space = node->bounds.h / (float)((it->output_count) + 1);
for (n = 0; n < it->output_count; ++n) {
struct nk_rect circle;
circle.x = node->bounds.x + node->bounds.w-4;
circle.y = node->bounds.y + space * (float)(n+1);
circle.w = 8; circle.h = 8;
nk_fill_circle(canvas, circle, nk_rgb(100, 100, 100));
/* start linking process */
if (nk_input_has_mouse_click_down_in_rect(in, NK_BUTTON_LEFT, circle, nk_true)) {
nodedit->linking.active = nk_true;
nodedit->linking.node = it;
nodedit->linking.input_id = it->ID;
nodedit->linking.input_slot = n;
}
/* draw curve from linked node slot to mouse position */
if (nodedit->linking.active && nodedit->linking.node == it &&
nodedit->linking.input_slot == n) {
struct nk_vec2 l0 = nk_vec2(circle.x + 3, circle.y + 3);
struct nk_vec2 l1 = in->mouse.pos;
nk_stroke_curve(canvas, l0.x, l0.y, l0.x + 50.0f, l0.y,
l1.x - 50.0f, l1.y, l1.x, l1.y, 1.0f, nk_rgb(100, 100, 100));
}
}
/* input connector */
space = node->bounds.h / (float)((it->input_count) + 1);
for (n = 0; n < it->input_count; ++n) {
struct nk_rect circle;
circle.x = node->bounds.x-4;
circle.y = node->bounds.y + space * (float)(n+1);
circle.w = 8; circle.h = 8;
nk_fill_circle(canvas, circle, nk_rgb(100, 100, 100));
if (nk_input_is_mouse_released(in, NK_BUTTON_LEFT) &&
nk_input_is_mouse_hovering_rect(in, circle) &&
nodedit->linking.active && nodedit->linking.node != it) {
nodedit->linking.active = nk_false;
node_editor_link(nodedit, nodedit->linking.input_id,
nodedit->linking.input_slot, it->ID, n);
}
}
}
it = it->next;
}
/* reset linking connection */
if (nodedit->linking.active && nk_input_is_mouse_released(in, NK_BUTTON_LEFT)) {
nodedit->linking.active = nk_false;
nodedit->linking.node = NULL;
fprintf(stdout, "linking failed\n");
}
/* draw each link */
for (n = 0; n < nodedit->link_count; ++n) {
struct node_link *link = &nodedit->links[n];
struct node *ni = node_editor_find(nodedit, link->input_id);
struct node *no = node_editor_find(nodedit, link->output_id);
float spacei = node->bounds.h / (float)((ni->output_count) + 1);
float spaceo = node->bounds.h / (float)((no->input_count) + 1);
struct nk_vec2 l0 = nk_layout_space_to_screen(ctx,
nk_vec2(ni->bounds.x + ni->bounds.w, 3.0f + ni->bounds.y + spacei * (float)(link->input_slot+1)));
struct nk_vec2 l1 = nk_layout_space_to_screen(ctx,
nk_vec2(no->bounds.x, 3.0f + no->bounds.y + spaceo * (float)(link->output_slot+1)));
l0.x -= nodedit->scrolling.x;
l0.y -= nodedit->scrolling.y;
l1.x -= nodedit->scrolling.x;
l1.y -= nodedit->scrolling.y;
nk_stroke_curve(canvas, l0.x, l0.y, l0.x + 50.0f, l0.y,
l1.x - 50.0f, l1.y, l1.x, l1.y, 1.0f, nk_rgb(100, 100, 100));
}
if (updated) {
/* reshuffle nodes to have least recently selected node on top */
node_editor_pop(nodedit, updated);
node_editor_push(nodedit, updated);
}
/* node selection */
if (nk_input_mouse_clicked(in, NK_BUTTON_LEFT, nk_layout_space_bounds(ctx))) {
it = nodedit->begin;
nodedit->selected = NULL;
nodedit->bounds = nk_rect(in->mouse.pos.x, in->mouse.pos.y, 100, 200);
while (it) {
struct nk_rect b = nk_layout_space_rect_to_screen(ctx, it->bounds);
b.x -= nodedit->scrolling.x;
b.y -= nodedit->scrolling.y;
if (nk_input_is_mouse_hovering_rect(in, b))
nodedit->selected = it;
it = it->next;
}
}
/* contextual menu */
if (nk_contextual_begin(ctx, 0, nk_vec2(100, 220), nk_window_get_bounds(ctx))) {
const char *grid_option[] = {"Show Grid", "Hide Grid"};
nk_layout_row_dynamic(ctx, 25, 1);
if (nk_contextual_item_label(ctx, "New", NK_TEXT_CENTERED))
node_editor_add(nodedit, "New", nk_rect(400, 260, 180, 220),
nk_rgb(255, 255, 255), 1, 2);
if (nk_contextual_item_label(ctx, grid_option[nodedit->show_grid],NK_TEXT_CENTERED))
nodedit->show_grid = !nodedit->show_grid;
nk_contextual_end(ctx);
}
}
nk_layout_space_end(ctx);
/* window content scrolling */
if (nk_input_is_mouse_hovering_rect(in, nk_window_get_bounds(ctx)) &&
nk_input_is_mouse_down(in, NK_BUTTON_MIDDLE)) {
nodedit->scrolling.x += in->mouse.delta.x;
nodedit->scrolling.y += in->mouse.delta.y;
}
}
nk_end(ctx);
return !nk_window_is_closed(ctx, "NodeEdit");
}

View File

@ -1,132 +0,0 @@
enum theme {THEME_BLACK, THEME_WHITE, THEME_RED, THEME_BLUE, THEME_DARK};
void
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);
}
}

View File

@ -1,11 +1,11 @@
#ifndef NUKLEAR_RSDL_H
#define NUKLEAR_RSDL_H
#include "libretro-core.h"
#include <gui.h>
//RETRO HACK
//#warning just an SDL wrapper for use SDL surface/maprgba in the core.
/* RETRO HACK
* warning just an SDL wrapper for use SDL surface in the core.
*/
#include <stdlib.h>
#include <unistd.h>
@ -35,7 +35,7 @@ typedef unsigned int uint32;
#elif defined(_MSC_VER) /* VC++ */
#define RSDL_HAS_64BIT_TYPE __int64
#endif
#endif /* !__STRICT_ANSI__ */
#endif
#define Uint64 unsigned long long

View File

@ -1,19 +1,6 @@
/*
* Nuklear - v1.17 - public domain
* no warrenty implied; use at your own risk.
* authored from 2015-2016 by Micha Mettke
*/
/*
* ==============================================================
*
* API
*
* ===============================================================
*/
#ifndef NK_RSDL_H_
#define NK_RSDL_H_
// RSDL_surface/RSDL_maprgba (implementation from RSDL_wrapper)
#include "RSDL_wrapper.h"
typedef struct nk_retro_Font nk_retro_Font;
@ -388,9 +375,7 @@ nk_retro_render(struct nk_color clear)
nk_retro_blit(retro.screen_surface);
nk_clear(&retro.ctx);
//FIXME draw only in fullscreen or mouse grabbed or when joypad emulate mouse
if(revent.showpointer==1)draw_cross(retro.screen_surface,revent.gmx,revent.gmy);
if(revent.showpointer==1)draw_cross(retro.screen_surface,revent.gmx,revent.gmy);
}
static void