Compare commits
40 Commits
demo-overv
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
a315d25b4c | ||
|
a13a60e998 | ||
|
2a4e3fbc92 | ||
|
80805cdfc0 | ||
|
d1821eebc7 | ||
|
7cb39a360d | ||
|
d3ea630a84 | ||
|
2ac678a94d | ||
|
050fbbaf9a | ||
|
3723ca585b | ||
|
abb3e406aa | ||
|
d5969abb86 | ||
|
d123122a27 | ||
|
f169ee68d1 | ||
|
985ddcbccb | ||
|
b6a7791d13 | ||
|
6566d9075d | ||
|
b2ffce5131 | ||
|
748f0dafe7 | ||
|
03198a016b | ||
|
8f45d37cf6 | ||
|
e360f267ed | ||
|
2ad47c08f1 | ||
|
0a28e3002b | ||
|
fa9f257c7b | ||
|
2156b95a5d | ||
|
b6e261b508 | ||
|
964cc81fad | ||
|
5c89e05538 | ||
|
ca8aaf3f65 | ||
|
a02e1824b8 | ||
|
e4901c5358 | ||
|
19dc0131f3 | ||
|
4ffef5eb11 | ||
|
f3de6a0cb3 | ||
|
18f7e7a948 | ||
|
ec113a0f7c | ||
|
4373fd03cc | ||
|
19bb57b893 | ||
|
cb9dc9635a |
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@ docs/xml
|
||||
docs/build
|
||||
docs/src
|
||||
doc/doc*
|
||||
doc/*
|
||||
*.tmp
|
||||
*.swo
|
||||
*.swp
|
||||
|
36
Makefile
Normal file
36
Makefile
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
docs_path:=./doc
|
||||
doxyfile:=$(docs_path)/Doxyfile
|
||||
|
||||
|
||||
|
||||
.PHONY: usage
|
||||
|
||||
usage:
|
||||
echo "make docs to create documentation"
|
||||
echo "make nuke to rebuild the single header nuklear.h from source"
|
||||
echo "make all to re-pack the header and create documentation"
|
||||
echo "make install to "install" man files"
|
||||
|
||||
|
||||
docs: $(docs_path)/html/index.html
|
||||
|
||||
$(docs_path)/html/index.html: $(docs_path)/doxygen-awesome-css/doxygen-awesome.css $(doxyfile)
|
||||
doxygen $(doxyfile)
|
||||
|
||||
$(doxyfile):
|
||||
doxygen -g $@
|
||||
|
||||
$(docs_path)/doxygen-awesome-css/doxygen-awesome.css:
|
||||
git clone https://github.com/jothepro/doxygen-awesome-css.git $(docs_path)/doxygen-awesome-css --branch v2.3.4
|
||||
|
||||
nuke:
|
||||
cd ./src && ./paq.sh
|
||||
|
||||
all: docs nuke
|
||||
|
||||
install:
|
||||
|
||||
clean:
|
||||
rm -rf $(docs_path)/html
|
||||
|
@ -324,7 +324,17 @@ nk_allegro5_render()
|
||||
} break;
|
||||
case NK_COMMAND_IMAGE: {
|
||||
const struct nk_command_image *i = (const struct nk_command_image *)cmd;
|
||||
al_draw_bitmap_region(i->img.handle.ptr, 0, 0, i->w, i->h, i->x, i->y, 0);
|
||||
nk_ushort
|
||||
x = i->img.region[0],
|
||||
y = i->img.region[1],
|
||||
w = i->img.region[2],
|
||||
h = i->img.region[3];
|
||||
if(w == 0 && h == 0)
|
||||
{
|
||||
x = i->x; y = i->y; w = i->w; h = i->h;
|
||||
}
|
||||
al_draw_scaled_bitmap(i->img.handle.ptr,
|
||||
x, y, w, h, i->x, i->y, i->w, i->h, 0);
|
||||
} break;
|
||||
case NK_COMMAND_RECT_MULTI_COLOR:
|
||||
default: break;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <time.h>
|
||||
#include <limits.h> /* INT_MAX */
|
||||
#include <time.h> /* struct tm, localtime */
|
||||
|
||||
static int
|
||||
overview(struct nk_context *ctx)
|
||||
@ -17,7 +18,8 @@ overview(struct nk_context *ctx)
|
||||
|
||||
#ifdef INCLUDE_STYLE
|
||||
/* styles */
|
||||
static const char* themes[] = {"Black", "White", "Red", "Blue", "Dark", "Dracula"};
|
||||
static const char* themes[] = {"Black", "White", "Red", "Blue", "Dark", "Dracula",
|
||||
"Catppucin Latte", "Catppucin Frappe", "Catppucin Macchiato", "Catppucin Mocha"};
|
||||
static int current_theme = 0;
|
||||
#endif
|
||||
|
||||
@ -155,7 +157,7 @@ overview(struct nk_context *ctx)
|
||||
nk_checkbox_flags_label(ctx, "No Scrollbar", &window_flags, NK_WINDOW_NO_SCROLLBAR);
|
||||
nk_checkbox_flags_label(ctx, "Minimizable", &window_flags, NK_WINDOW_MINIMIZABLE);
|
||||
nk_checkbox_flags_label(ctx, "Scale Left", &window_flags, NK_WINDOW_SCALE_LEFT);
|
||||
nk_checkbox_label(ctx, "Disable widgets", &disable_widgets);
|
||||
nk_checkbox_label(ctx, "Disable widgets", &disable_widgets);
|
||||
nk_tree_pop(ctx);
|
||||
}
|
||||
|
||||
|
@ -1,193 +1,441 @@
|
||||
enum theme {THEME_BLACK, THEME_WHITE, THEME_RED, THEME_BLUE, THEME_DARK, THEME_DRACULA};
|
||||
enum theme {
|
||||
THEME_BLACK,
|
||||
THEME_WHITE,
|
||||
THEME_RED,
|
||||
THEME_BLUE,
|
||||
THEME_DARK,
|
||||
THEME_DRACULA,
|
||||
THEME_CATPPUCCIN_LATTE,
|
||||
THEME_CATPPUCCIN_FRAPPE,
|
||||
THEME_CATPPUCCIN_MACCHIATO,
|
||||
THEME_CATPPUCCIN_MOCHA
|
||||
|
||||
};
|
||||
|
||||
static 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);
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
|
||||
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);
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
|
||||
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);
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
|
||||
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);
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
|
||||
nk_style_from_table(ctx, table);
|
||||
} else if (theme == THEME_DRACULA) {
|
||||
struct nk_color background = nk_rgba(40, 42, 54, 255);
|
||||
struct nk_color currentline = nk_rgba(68, 71, 90, 255);
|
||||
struct nk_color foreground = nk_rgba(248, 248, 242, 255);
|
||||
struct nk_color comment = nk_rgba(98, 114, 164, 255);
|
||||
/* struct nk_color cyan = nk_rgba(139, 233, 253, 255); */
|
||||
/* struct nk_color green = nk_rgba(80, 250, 123, 255); */
|
||||
/* struct nk_color orange = nk_rgba(255, 184, 108, 255); */
|
||||
struct nk_color pink = nk_rgba(255, 121, 198, 255);
|
||||
struct nk_color purple = nk_rgba(189, 147, 249, 255);
|
||||
/* struct nk_color red = nk_rgba(255, 85, 85, 255); */
|
||||
/* struct nk_color yellow = nk_rgba(241, 250, 140, 255); */
|
||||
table[NK_COLOR_TEXT] = foreground;
|
||||
table[NK_COLOR_WINDOW] = background;
|
||||
table[NK_COLOR_HEADER] = currentline;
|
||||
table[NK_COLOR_BORDER] = currentline;
|
||||
table[NK_COLOR_BUTTON] = currentline;
|
||||
table[NK_COLOR_BUTTON_HOVER] = comment;
|
||||
table[NK_COLOR_BUTTON_ACTIVE] = purple;
|
||||
table[NK_COLOR_TOGGLE] = currentline;
|
||||
table[NK_COLOR_TOGGLE_HOVER] = comment;
|
||||
table[NK_COLOR_TOGGLE_CURSOR] = pink;
|
||||
table[NK_COLOR_SELECT] = currentline;
|
||||
table[NK_COLOR_SELECT_ACTIVE] = comment;
|
||||
table[NK_COLOR_SLIDER] = background;
|
||||
table[NK_COLOR_SLIDER_CURSOR] = currentline;
|
||||
table[NK_COLOR_SLIDER_CURSOR_HOVER] = comment;
|
||||
table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = comment;
|
||||
table[NK_COLOR_PROPERTY] = currentline;
|
||||
table[NK_COLOR_EDIT] = currentline;
|
||||
table[NK_COLOR_EDIT_CURSOR] = foreground;
|
||||
table[NK_COLOR_COMBO] = currentline;
|
||||
table[NK_COLOR_CHART] = currentline;
|
||||
table[NK_COLOR_CHART_COLOR] = comment;
|
||||
table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = purple;
|
||||
table[NK_COLOR_SCROLLBAR] = background;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR] = currentline;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = comment;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = purple;
|
||||
table[NK_COLOR_TAB_HEADER] = currentline;
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
|
||||
nk_style_from_table(ctx, table);
|
||||
} else {
|
||||
nk_style_default(ctx);
|
||||
}
|
||||
static 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);
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
|
||||
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);
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
|
||||
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);
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
|
||||
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);
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
|
||||
nk_style_from_table(ctx, table);
|
||||
} else if (theme == THEME_DRACULA) {
|
||||
struct nk_color background = nk_rgba(40, 42, 54, 255);
|
||||
struct nk_color currentline = nk_rgba(68, 71, 90, 255);
|
||||
struct nk_color foreground = nk_rgba(248, 248, 242, 255);
|
||||
struct nk_color comment = nk_rgba(98, 114, 164, 255);
|
||||
/* struct nk_color cyan = nk_rgba(139, 233, 253, 255); */
|
||||
/* struct nk_color green = nk_rgba(80, 250, 123, 255); */
|
||||
/* struct nk_color orange = nk_rgba(255, 184, 108, 255); */
|
||||
struct nk_color pink = nk_rgba(255, 121, 198, 255);
|
||||
struct nk_color purple = nk_rgba(189, 147, 249, 255);
|
||||
/* struct nk_color red = nk_rgba(255, 85, 85, 255); */
|
||||
/* struct nk_color yellow = nk_rgba(241, 250, 140, 255); */
|
||||
table[NK_COLOR_TEXT] = foreground;
|
||||
table[NK_COLOR_WINDOW] = background;
|
||||
table[NK_COLOR_HEADER] = currentline;
|
||||
table[NK_COLOR_BORDER] = currentline;
|
||||
table[NK_COLOR_BUTTON] = currentline;
|
||||
table[NK_COLOR_BUTTON_HOVER] = comment;
|
||||
table[NK_COLOR_BUTTON_ACTIVE] = purple;
|
||||
table[NK_COLOR_TOGGLE] = currentline;
|
||||
table[NK_COLOR_TOGGLE_HOVER] = comment;
|
||||
table[NK_COLOR_TOGGLE_CURSOR] = pink;
|
||||
table[NK_COLOR_SELECT] = currentline;
|
||||
table[NK_COLOR_SELECT_ACTIVE] = comment;
|
||||
table[NK_COLOR_SLIDER] = background;
|
||||
table[NK_COLOR_SLIDER_CURSOR] = currentline;
|
||||
table[NK_COLOR_SLIDER_CURSOR_HOVER] = comment;
|
||||
table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = comment;
|
||||
table[NK_COLOR_PROPERTY] = currentline;
|
||||
table[NK_COLOR_EDIT] = currentline;
|
||||
table[NK_COLOR_EDIT_CURSOR] = foreground;
|
||||
table[NK_COLOR_COMBO] = currentline;
|
||||
table[NK_COLOR_CHART] = currentline;
|
||||
table[NK_COLOR_CHART_COLOR] = comment;
|
||||
table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = purple;
|
||||
table[NK_COLOR_SCROLLBAR] = background;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR] = currentline;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = comment;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = purple;
|
||||
table[NK_COLOR_TAB_HEADER] = currentline;
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
|
||||
nk_style_from_table(ctx, table);
|
||||
} else if (theme == THEME_CATPPUCCIN_LATTE) {
|
||||
/*struct nk_color rosewater = nk_rgba(220, 138, 120, 255);*/
|
||||
/*struct nk_color flamingo = nk_rgba(221, 120, 120, 255);*/
|
||||
struct nk_color pink = nk_rgba(234, 118, 203, 255);
|
||||
struct nk_color mauve = nk_rgba(136, 57, 239, 255);
|
||||
/*struct nk_color red = nk_rgba(210, 15, 57, 255);*/
|
||||
/*struct nk_color maroon = nk_rgba(230, 69, 83, 255);*/
|
||||
/*struct nk_color peach = nk_rgba(254, 100, 11, 255);*/
|
||||
struct nk_color yellow = nk_rgba(223, 142, 29, 255);
|
||||
/*struct nk_color green = nk_rgba(64, 160, 43, 255);*/
|
||||
struct nk_color teal = nk_rgba(23, 146, 153, 255);
|
||||
/*struct nk_color sky = nk_rgba(4, 165, 229, 255);*/
|
||||
/*struct nk_color sapphire = nk_rgba(32, 159, 181, 255);*/
|
||||
/*struct nk_color blue = nk_rgba(30, 102, 245, 255);*/
|
||||
/*struct nk_color lavender = nk_rgba(114, 135, 253, 255);*/
|
||||
struct nk_color text = nk_rgba(76, 79, 105, 255);
|
||||
/*struct nk_color subtext1 = nk_rgba(92, 95, 119, 255);*/
|
||||
/*struct nk_color subtext0 = nk_rgba(108, 111, 133, 255);*/
|
||||
struct nk_color overlay2 = nk_rgba(124, 127, 147, 55);
|
||||
/*struct nk_color overlay1 = nk_rgba(140, 143, 161, 255);*/
|
||||
struct nk_color overlay0 = nk_rgba(156, 160, 176, 255);
|
||||
struct nk_color surface2 = nk_rgba(172, 176, 190, 255);
|
||||
struct nk_color surface1 = nk_rgba(188, 192, 204, 255);
|
||||
struct nk_color surface0 = nk_rgba(204, 208, 218, 255);
|
||||
struct nk_color base = nk_rgba(239, 241, 245, 255);
|
||||
struct nk_color mantle = nk_rgba(230, 233, 239, 255);
|
||||
/*struct nk_color crust = nk_rgba(220, 224, 232, 255);*/
|
||||
table[NK_COLOR_TEXT] = text;
|
||||
table[NK_COLOR_WINDOW] = base;
|
||||
table[NK_COLOR_HEADER] = mantle;
|
||||
table[NK_COLOR_BORDER] = mantle;
|
||||
table[NK_COLOR_BUTTON] = surface0;
|
||||
table[NK_COLOR_BUTTON_HOVER] = overlay2;
|
||||
table[NK_COLOR_BUTTON_ACTIVE] = overlay0;
|
||||
table[NK_COLOR_TOGGLE] = surface2;
|
||||
table[NK_COLOR_TOGGLE_HOVER] = overlay2;
|
||||
table[NK_COLOR_TOGGLE_CURSOR] = yellow;
|
||||
table[NK_COLOR_SELECT] = surface0;
|
||||
table[NK_COLOR_SELECT_ACTIVE] = overlay0;
|
||||
table[NK_COLOR_SLIDER] = surface1;
|
||||
table[NK_COLOR_SLIDER_CURSOR] = teal;
|
||||
table[NK_COLOR_SLIDER_CURSOR_HOVER] = teal;
|
||||
table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = teal;
|
||||
table[NK_COLOR_PROPERTY] = surface0;
|
||||
table[NK_COLOR_EDIT] = surface0;
|
||||
table[NK_COLOR_EDIT_CURSOR] = mauve;
|
||||
table[NK_COLOR_COMBO] = surface0;
|
||||
table[NK_COLOR_CHART] = surface0;
|
||||
table[NK_COLOR_CHART_COLOR] = teal;
|
||||
table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = mauve;
|
||||
table[NK_COLOR_SCROLLBAR] = surface0;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR] = overlay0;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = mauve;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = mauve;
|
||||
table[NK_COLOR_TAB_HEADER] = surface0;
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = pink;
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = pink;
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = pink;
|
||||
nk_style_from_table(ctx, table);
|
||||
} else if (theme == THEME_CATPPUCCIN_FRAPPE) {
|
||||
/*struct nk_color rosewater = nk_rgba(242, 213, 207, 255);*/
|
||||
/*struct nk_color flamingo = nk_rgba(238, 190, 190, 255);*/
|
||||
struct nk_color pink = nk_rgba(244, 184, 228, 255);
|
||||
/*struct nk_color mauve = nk_rgba(202, 158, 230, 255);*/
|
||||
/*struct nk_color red = nk_rgba(231, 130, 132, 255);*/
|
||||
/*struct nk_color maroon = nk_rgba(234, 153, 156, 255);*/
|
||||
/*struct nk_color peach = nk_rgba(239, 159, 118, 255);*/
|
||||
/*struct nk_color yellow = nk_rgba(229, 200, 144, 255);*/
|
||||
struct nk_color green = nk_rgba(166, 209, 137, 255);
|
||||
/*struct nk_color teal = nk_rgba(129, 200, 190, 255);*/
|
||||
/*struct nk_color sky = nk_rgba(153, 209, 219, 255);*/
|
||||
/*struct nk_color sapphire = nk_rgba(133, 193, 220, 255);*/
|
||||
/*struct nk_color blue = nk_rgba(140, 170, 238, 255);*/
|
||||
struct nk_color lavender = nk_rgba(186, 187, 241, 255);
|
||||
struct nk_color text = nk_rgba(198, 208, 245, 255);
|
||||
/*struct nk_color subtext1 = nk_rgba(181, 191, 226, 255);*/
|
||||
/*struct nk_color subtext0 = nk_rgba(165, 173, 206, 255);*/
|
||||
struct nk_color overlay2 = nk_rgba(148, 156, 187, 255);
|
||||
struct nk_color overlay1 = nk_rgba(131, 139, 167, 255);
|
||||
struct nk_color overlay0 = nk_rgba(115, 121, 148, 255);
|
||||
struct nk_color surface2 = nk_rgba(98, 104, 128, 255);
|
||||
struct nk_color surface1 = nk_rgba(81, 87, 109, 255);
|
||||
struct nk_color surface0 = nk_rgba(65, 69, 89, 255);
|
||||
struct nk_color base = nk_rgba(48, 52, 70, 255);
|
||||
struct nk_color mantle = nk_rgba(41, 44, 60, 255);
|
||||
/*struct nk_color crust = nk_rgba(35, 38, 52, 255);*/
|
||||
table[NK_COLOR_TEXT] = text;
|
||||
table[NK_COLOR_WINDOW] = base;
|
||||
table[NK_COLOR_HEADER] = mantle;
|
||||
table[NK_COLOR_BORDER] = mantle;
|
||||
table[NK_COLOR_BUTTON] = surface0;
|
||||
table[NK_COLOR_BUTTON_HOVER] = overlay1;
|
||||
table[NK_COLOR_BUTTON_ACTIVE] = overlay0;
|
||||
table[NK_COLOR_TOGGLE] = surface2;
|
||||
table[NK_COLOR_TOGGLE_HOVER] = overlay2;
|
||||
table[NK_COLOR_TOGGLE_CURSOR] = pink;
|
||||
table[NK_COLOR_SELECT] = surface0;
|
||||
table[NK_COLOR_SELECT_ACTIVE] = overlay0;
|
||||
table[NK_COLOR_SLIDER] = surface1;
|
||||
table[NK_COLOR_SLIDER_CURSOR] = green;
|
||||
table[NK_COLOR_SLIDER_CURSOR_HOVER] = green;
|
||||
table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = green;
|
||||
table[NK_COLOR_PROPERTY] = surface0;
|
||||
table[NK_COLOR_EDIT] = surface0;
|
||||
table[NK_COLOR_EDIT_CURSOR] = pink;
|
||||
table[NK_COLOR_COMBO] = surface0;
|
||||
table[NK_COLOR_CHART] = surface0;
|
||||
table[NK_COLOR_CHART_COLOR] = lavender;
|
||||
table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = pink;
|
||||
table[NK_COLOR_SCROLLBAR] = surface0;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR] = overlay0;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = lavender;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = lavender;
|
||||
table[NK_COLOR_TAB_HEADER] = surface0;
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = pink;
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = pink;
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = pink;
|
||||
nk_style_from_table(ctx, table);
|
||||
} else if (theme == THEME_CATPPUCCIN_MACCHIATO) {
|
||||
/*struct nk_color rosewater = nk_rgba(244, 219, 214, 255);*/
|
||||
/*struct nk_color flamingo = nk_rgba(240, 198, 198, 255);*/
|
||||
struct nk_color pink = nk_rgba(245, 189, 230, 255);
|
||||
/*struct nk_color mauve = nk_rgba(198, 160, 246, 255);*/
|
||||
/*struct nk_color red = nk_rgba(237, 135, 150, 255);*/
|
||||
/*struct nk_color maroon = nk_rgba(238, 153, 160, 255);*/
|
||||
/*struct nk_color peach = nk_rgba(245, 169, 127, 255);*/
|
||||
struct nk_color yellow = nk_rgba(238, 212, 159, 255);
|
||||
struct nk_color green = nk_rgba(166, 218, 149, 255);
|
||||
/*struct nk_color teal = nk_rgba(139, 213, 202, 255);*/
|
||||
/*struct nk_color sky = nk_rgba(145, 215, 227, 255);*/
|
||||
/*struct nk_color sapphire = nk_rgba(125, 196, 228, 255);*/
|
||||
/*struct nk_color blue = nk_rgba(138, 173, 244, 255);*/
|
||||
struct nk_color lavender = nk_rgba(183, 189, 248, 255);
|
||||
struct nk_color text = nk_rgba(202, 211, 245, 255);
|
||||
/*struct nk_color subtext1 = nk_rgba(184, 192, 224, 255);*/
|
||||
/*struct nk_color subtext0 = nk_rgba(165, 173, 203, 255);*/
|
||||
struct nk_color overlay2 = nk_rgba(147, 154, 183, 255);
|
||||
struct nk_color overlay1 = nk_rgba(128, 135, 162, 255);
|
||||
struct nk_color overlay0 = nk_rgba(110, 115, 141, 255);
|
||||
struct nk_color surface2 = nk_rgba(91, 96, 120, 255);
|
||||
struct nk_color surface1 = nk_rgba(73, 77, 100, 255);
|
||||
struct nk_color surface0 = nk_rgba(54, 58, 79, 255);
|
||||
struct nk_color base = nk_rgba(36, 39, 58, 255);
|
||||
struct nk_color mantle = nk_rgba(30, 32, 48, 255);
|
||||
/*struct nk_color crust = nk_rgba(24, 25, 38, 255);*/
|
||||
table[NK_COLOR_TEXT] = text;
|
||||
table[NK_COLOR_WINDOW] = base;
|
||||
table[NK_COLOR_HEADER] = mantle;
|
||||
table[NK_COLOR_BORDER] = mantle;
|
||||
table[NK_COLOR_BUTTON] = surface0;
|
||||
table[NK_COLOR_BUTTON_HOVER] = overlay1;
|
||||
table[NK_COLOR_BUTTON_ACTIVE] = overlay0;
|
||||
table[NK_COLOR_TOGGLE] = surface2;
|
||||
table[NK_COLOR_TOGGLE_HOVER] = overlay2;
|
||||
table[NK_COLOR_TOGGLE_CURSOR] = yellow;
|
||||
table[NK_COLOR_SELECT] = surface0;
|
||||
table[NK_COLOR_SELECT_ACTIVE] = overlay0;
|
||||
table[NK_COLOR_SLIDER] = surface1;
|
||||
table[NK_COLOR_SLIDER_CURSOR] = green;
|
||||
table[NK_COLOR_SLIDER_CURSOR_HOVER] = green;
|
||||
table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = green;
|
||||
table[NK_COLOR_PROPERTY] = surface0;
|
||||
table[NK_COLOR_EDIT] = surface0;
|
||||
table[NK_COLOR_EDIT_CURSOR] = pink;
|
||||
table[NK_COLOR_COMBO] = surface0;
|
||||
table[NK_COLOR_CHART] = surface0;
|
||||
table[NK_COLOR_CHART_COLOR] = lavender;
|
||||
table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = yellow;
|
||||
table[NK_COLOR_SCROLLBAR] = surface0;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR] = overlay0;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = lavender;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = lavender;
|
||||
table[NK_COLOR_TAB_HEADER] = surface0;
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = pink;
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = pink;
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = pink;
|
||||
nk_style_from_table(ctx, table);
|
||||
} else if (theme == THEME_CATPPUCCIN_MOCHA) {
|
||||
/*struct nk_color rosewater = nk_rgba(245, 224, 220, 255);*/
|
||||
/*struct nk_color flamingo = nk_rgba(242, 205, 205, 255);*/
|
||||
struct nk_color pink = nk_rgba(245, 194, 231, 255);
|
||||
/*struct nk_color mauve = nk_rgba(203, 166, 247, 255);*/
|
||||
/*struct nk_color red = nk_rgba(243, 139, 168, 255);*/
|
||||
/*struct nk_color maroon = nk_rgba(235, 160, 172, 255);*/
|
||||
/*struct nk_color peach = nk_rgba(250, 179, 135, 255);*/
|
||||
/*struct nk_color yellow = nk_rgba(249, 226, 175, 255);*/
|
||||
struct nk_color green = nk_rgba(166, 227, 161, 255);
|
||||
/*struct nk_color teal = nk_rgba(148, 226, 213, 255);*/
|
||||
/*struct nk_color sky = nk_rgba(137, 220, 235, 255);*/
|
||||
/*struct nk_color sapphire = nk_rgba(116, 199, 236, 255);*/
|
||||
/*struct nk_color blue = nk_rgba(137, 180, 250, 255);*/
|
||||
struct nk_color lavender = nk_rgba(180, 190, 254, 255);
|
||||
struct nk_color text = nk_rgba(205, 214, 244, 255);
|
||||
/*struct nk_color subtext1 = nk_rgba(186, 194, 222, 255);*/
|
||||
/*struct nk_color subtext0 = nk_rgba(166, 173, 200, 255);*/
|
||||
struct nk_color overlay2 = nk_rgba(147, 153, 178, 255);
|
||||
struct nk_color overlay1 = nk_rgba(127, 132, 156, 255);
|
||||
struct nk_color overlay0 = nk_rgba(108, 112, 134, 255);
|
||||
struct nk_color surface2 = nk_rgba(88, 91, 112, 255);
|
||||
struct nk_color surface1 = nk_rgba(69, 71, 90, 255);
|
||||
struct nk_color surface0 = nk_rgba(49, 50, 68, 255);
|
||||
struct nk_color base = nk_rgba(30, 30, 46, 255);
|
||||
struct nk_color mantle = nk_rgba(24, 24, 37, 255);
|
||||
/*struct nk_color crust = nk_rgba(17, 17, 27, 255);*/
|
||||
table[NK_COLOR_TEXT] = text;
|
||||
table[NK_COLOR_WINDOW] = base;
|
||||
table[NK_COLOR_HEADER] = mantle;
|
||||
table[NK_COLOR_BORDER] = mantle;
|
||||
table[NK_COLOR_BUTTON] = surface0;
|
||||
table[NK_COLOR_BUTTON_HOVER] = overlay1;
|
||||
table[NK_COLOR_BUTTON_ACTIVE] = overlay0;
|
||||
table[NK_COLOR_TOGGLE] = surface2;
|
||||
table[NK_COLOR_TOGGLE_HOVER] = overlay2;
|
||||
table[NK_COLOR_TOGGLE_CURSOR] = lavender;
|
||||
table[NK_COLOR_SELECT] = surface0;
|
||||
table[NK_COLOR_SELECT_ACTIVE] = overlay0;
|
||||
table[NK_COLOR_SLIDER] = surface1;
|
||||
table[NK_COLOR_SLIDER_CURSOR] = green;
|
||||
table[NK_COLOR_SLIDER_CURSOR_HOVER] = green;
|
||||
table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = green;
|
||||
table[NK_COLOR_PROPERTY] = surface0;
|
||||
table[NK_COLOR_EDIT] = surface0;
|
||||
table[NK_COLOR_EDIT_CURSOR] = lavender;
|
||||
table[NK_COLOR_COMBO] = surface0;
|
||||
table[NK_COLOR_CHART] = surface0;
|
||||
table[NK_COLOR_CHART_COLOR] = lavender;
|
||||
table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = pink;
|
||||
table[NK_COLOR_SCROLLBAR] = surface0;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR] = overlay0;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = lavender;
|
||||
table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = pink;
|
||||
table[NK_COLOR_TAB_HEADER] = surface0;
|
||||
table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
|
||||
table[NK_COLOR_KNOB_CURSOR] = pink;
|
||||
table[NK_COLOR_KNOB_CURSOR_HOVER] = pink;
|
||||
table[NK_COLOR_KNOB_CURSOR_ACTIVE] = pink;
|
||||
nk_style_from_table(ctx, table);
|
||||
} else {
|
||||
nk_style_default(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -239,6 +239,14 @@ nk_d3d11_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_TAB, down);
|
||||
return 1;
|
||||
|
||||
case VK_UP:
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_UP, down);
|
||||
return 1;
|
||||
|
||||
case VK_DOWN:
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_DOWN, down);
|
||||
return 1;
|
||||
|
||||
case VK_LEFT:
|
||||
if (ctrl)
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_TEXT_WORD_LEFT, down);
|
||||
@ -275,6 +283,20 @@ nk_d3d11_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_SCROLL_UP, down);
|
||||
return 1;
|
||||
|
||||
case 'B':
|
||||
if (ctrl) {
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_TEXT_LINE_START, down);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'E':
|
||||
if (ctrl) {
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_TEXT_LINE_END, down);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
if (ctrl) {
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_COPY, down);
|
||||
|
@ -315,7 +315,7 @@ nk_glfw3_render(struct nk_glfw* glfw, enum nk_anti_aliasing AA, int max_vertex_b
|
||||
NK_API void
|
||||
nk_glfw3_char_callback(GLFWwindow *win, unsigned int codepoint)
|
||||
{
|
||||
struct nk_glfw* glfw = glfwGetWindowUserPointer(win);
|
||||
struct nk_glfw* glfw = (struct nk_glfw *)glfwGetWindowUserPointer(win);
|
||||
if (glfw->text_len < NK_GLFW_TEXT_MAX)
|
||||
glfw->text[glfw->text_len++] = codepoint;
|
||||
}
|
||||
@ -323,7 +323,7 @@ nk_glfw3_char_callback(GLFWwindow *win, unsigned int codepoint)
|
||||
NK_API void
|
||||
nk_gflw3_scroll_callback(GLFWwindow *win, double xoff, double yoff)
|
||||
{
|
||||
struct nk_glfw* glfw = glfwGetWindowUserPointer(win);
|
||||
struct nk_glfw* glfw = (struct nk_glfw *)glfwGetWindowUserPointer(win);
|
||||
(void)xoff;
|
||||
glfw->scroll.x += (float)xoff;
|
||||
glfw->scroll.y += (float)yoff;
|
||||
@ -332,7 +332,7 @@ nk_gflw3_scroll_callback(GLFWwindow *win, double xoff, double yoff)
|
||||
NK_API void
|
||||
nk_glfw3_mouse_button_callback(GLFWwindow* win, int button, int action, int mods)
|
||||
{
|
||||
struct nk_glfw* glfw = glfwGetWindowUserPointer(win);
|
||||
struct nk_glfw* glfw = (struct nk_glfw *)glfwGetWindowUserPointer(win);
|
||||
double x, y;
|
||||
NK_UNUSED(mods);
|
||||
if (button != GLFW_MOUSE_BUTTON_LEFT) return;
|
||||
|
@ -139,8 +139,19 @@ struct vulkan_demo {
|
||||
VkDeviceMemory demo_texture_memory;
|
||||
|
||||
VkFence render_fence;
|
||||
|
||||
bool framebuffer_resized;
|
||||
};
|
||||
|
||||
static void glfw_framebuffer_resize_callback(GLFWwindow* window, int width, int height) {
|
||||
struct vulkan_demo* demo;
|
||||
|
||||
(void)width;
|
||||
(void)height;
|
||||
demo = glfwGetWindowUserPointer(window);
|
||||
demo->framebuffer_resized = true;
|
||||
}
|
||||
|
||||
static void glfw_error_callback(int e, const char *d) {
|
||||
fprintf(stderr, "Error %d: %s\n", e, d);
|
||||
}
|
||||
@ -299,7 +310,7 @@ bool create_instance(struct vulkan_demo *demo) {
|
||||
if (i > 0) {
|
||||
printf(", ");
|
||||
}
|
||||
printf(enabled_extensions[i]);
|
||||
printf("%s\n", enabled_extensions[i]);
|
||||
}
|
||||
printf("\n");
|
||||
for (i = 0; i < enabled_extension_count; i++) {
|
||||
@ -1227,8 +1238,8 @@ bool create_graphics_pipeline(struct vulkan_demo *demo) {
|
||||
bool ret = false;
|
||||
char *vert_shader_code = NULL;
|
||||
char *frag_shader_code = NULL;
|
||||
VkShaderModule vert_shader_module;
|
||||
VkShaderModule frag_shader_module;
|
||||
VkShaderModule vert_shader_module = VK_NULL_HANDLE;
|
||||
VkShaderModule frag_shader_module = VK_NULL_HANDLE;
|
||||
FILE *fp;
|
||||
size_t file_len;
|
||||
VkPipelineShaderStageCreateInfo vert_shader_stage_info;
|
||||
@ -1246,8 +1257,9 @@ bool create_graphics_pipeline(struct vulkan_demo *demo) {
|
||||
VkPipelineLayoutCreateInfo pipeline_layout_info;
|
||||
VkResult result;
|
||||
VkGraphicsPipelineCreateInfo pipeline_info;
|
||||
size_t read_result;
|
||||
|
||||
fp = fopen("shaders/demo.vert.spv", "r");
|
||||
fp = fopen("shaders/demo.vert.spv", "rb");
|
||||
if (!fp) {
|
||||
fprintf(stderr, "Couldn't open shaders/demo.vert.spv\n");
|
||||
return false;
|
||||
@ -1256,15 +1268,19 @@ bool create_graphics_pipeline(struct vulkan_demo *demo) {
|
||||
file_len = ftell(fp);
|
||||
vert_shader_code = malloc(file_len);
|
||||
fseek(fp, 0, 0);
|
||||
fread(vert_shader_code, 1, file_len, fp);
|
||||
read_result = fread(vert_shader_code, file_len, 1, fp);
|
||||
fclose(fp);
|
||||
if (read_result != 1) {
|
||||
fprintf(stderr, "Could not read fragment shader\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!create_shader_module(demo->device, vert_shader_code, file_len,
|
||||
&vert_shader_module)) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fp = fopen("shaders/demo.frag.spv", "r");
|
||||
fp = fopen("shaders/demo.frag.spv", "rb");
|
||||
if (!fp) {
|
||||
fprintf(stderr, "Couldn't open shaders/demo.frag.spv\n");
|
||||
return false;
|
||||
@ -1273,8 +1289,12 @@ bool create_graphics_pipeline(struct vulkan_demo *demo) {
|
||||
file_len = ftell(fp);
|
||||
frag_shader_code = malloc(file_len);
|
||||
fseek(fp, 0, 0);
|
||||
fread(frag_shader_code, 1, file_len, fp);
|
||||
read_result = fread(frag_shader_code, file_len, 1, fp);
|
||||
fclose(fp);
|
||||
if (read_result != 1) {
|
||||
fprintf(stderr, "Could not read fragment shader\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!create_shader_module(demo->device, frag_shader_code, file_len,
|
||||
&frag_shader_module)) {
|
||||
@ -1862,6 +1882,8 @@ bool create_vulkan_demo(struct vulkan_demo *demo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
demo->framebuffer_resized = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1876,6 +1898,9 @@ bool recreate_swap_chain(struct vulkan_demo *demo) {
|
||||
update_descriptor_sets(demo);
|
||||
nk_glfw3_resize(demo->swap_chain_image_extent.width,
|
||||
demo->swap_chain_image_extent.height);
|
||||
|
||||
demo->framebuffer_resized = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1961,7 +1986,7 @@ bool render(struct vulkan_demo *demo, struct nk_colorf *bg,
|
||||
|
||||
result = vkQueuePresentKHR(demo->present_queue, &present_info);
|
||||
|
||||
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR) {
|
||||
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || demo->framebuffer_resized) {
|
||||
recreate_swap_chain(demo);
|
||||
} else if (result != VK_SUCCESS) {
|
||||
fprintf(stderr, "vkQueuePresentKHR failed: %d\n", result);
|
||||
@ -2073,6 +2098,8 @@ int main(void) {
|
||||
memset(&demo, 0, sizeof(struct vulkan_demo));
|
||||
demo.win =
|
||||
glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Demo", NULL, NULL);
|
||||
glfwSetWindowUserPointer(demo.win, &demo);
|
||||
glfwSetFramebufferSizeCallback(demo.win, glfw_framebuffer_resize_callback);
|
||||
|
||||
if (!create_vulkan_demo(&demo)) {
|
||||
fprintf(stderr, "failed to create vulkan demo!\n");
|
||||
@ -2192,6 +2219,10 @@ int main(void) {
|
||||
demo.image_available, NULL, &image_index);
|
||||
|
||||
if (result == VK_ERROR_OUT_OF_DATE_KHR) {
|
||||
recreate_swap_chain(&demo);
|
||||
|
||||
/* If vkAcquireNextImageKHR does not successfully acquire an image,
|
||||
* semaphore and fence are unaffected. */
|
||||
continue;
|
||||
}
|
||||
if (result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR) {
|
||||
|
@ -372,7 +372,6 @@ static struct nk_glfw {
|
||||
struct nk_glfw_device vulkan;
|
||||
struct nk_context ctx;
|
||||
struct nk_font_atlas atlas;
|
||||
struct nk_vec2 fb_scale;
|
||||
unsigned int text[NK_GLFW_TEXT_MAX];
|
||||
int text_len;
|
||||
struct nk_vec2 scroll;
|
||||
@ -1179,8 +1178,6 @@ NK_API void nk_glfw3_resize(uint32_t framebuffer_width,
|
||||
struct nk_glfw_device *dev = &glfw.vulkan;
|
||||
glfwGetWindowSize(glfw.win, &glfw.width, &glfw.height);
|
||||
glfwGetFramebufferSize(glfw.win, &glfw.display_width, &glfw.display_height);
|
||||
glfw.fb_scale.x = (float)glfw.display_width / (float)glfw.width;
|
||||
glfw.fb_scale.y = (float)glfw.display_height / (float)glfw.height;
|
||||
|
||||
nk_glfw3_destroy_render_resources(dev);
|
||||
nk_glfw3_create_render_resources(dev, framebuffer_width,
|
||||
@ -1264,7 +1261,7 @@ NK_API void nk_glfw3_new_frame(void) {
|
||||
for (i = 0; i < glfw.text_len; ++i)
|
||||
nk_input_unicode(ctx, glfw.text[i]);
|
||||
|
||||
#ifdef NK_GLFW_GL4_MOUSE_GRABBING
|
||||
#ifdef NK_GLFW_VULKAN_MOUSE_GRABBING
|
||||
/* optional grabbing behavior */
|
||||
if (ctx->input.mouse.grab)
|
||||
glfwSetInputMode(glfw.win, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||
@ -1332,7 +1329,7 @@ NK_API void nk_glfw3_new_frame(void) {
|
||||
|
||||
glfwGetCursorPos(win, &x, &y);
|
||||
nk_input_motion(ctx, (int)x, (int)y);
|
||||
#ifdef NK_GLFW_GL4_MOUSE_GRABBING
|
||||
#ifdef NK_GLFW_VULKAN_MOUSE_GRABBING
|
||||
if (ctx->input.mouse.grabbed) {
|
||||
glfwSetCursorPos(glfw.win, ctx->input.mouse.prev.x,
|
||||
ctx->input.mouse.prev.y);
|
||||
|
@ -24,6 +24,7 @@ unsigned char nuklearshaders_nuklear_frag_spv[] = {};
|
||||
unsigned int nuklearshaders_nuklear_frag_spv_len = 0;
|
||||
// NUKLEAR_SHADERS_END
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
@ -71,7 +72,6 @@ NK_API void nk_glfw3_mouse_button_callback(GLFWwindow *win, int button,
|
||||
*/
|
||||
#ifdef NK_GLFW_VULKAN_IMPLEMENTATION
|
||||
#undef NK_GLFW_VULKAN_IMPLEMENTATION
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef NK_GLFW_TEXT_MAX
|
||||
@ -149,13 +149,13 @@ static struct nk_glfw {
|
||||
struct nk_glfw_device vulkan;
|
||||
struct nk_context ctx;
|
||||
struct nk_font_atlas atlas;
|
||||
struct nk_vec2 fb_scale;
|
||||
unsigned int text[NK_GLFW_TEXT_MAX];
|
||||
int text_len;
|
||||
struct nk_vec2 scroll;
|
||||
double last_button_click;
|
||||
int is_double_click_down;
|
||||
struct nk_vec2 double_click_pos;
|
||||
float delta_time_seconds_last;
|
||||
} glfw;
|
||||
|
||||
struct Mat4f {
|
||||
@ -955,8 +955,6 @@ NK_API void nk_glfw3_resize(uint32_t framebuffer_width,
|
||||
struct nk_glfw_device *dev = &glfw.vulkan;
|
||||
glfwGetWindowSize(glfw.win, &glfw.width, &glfw.height);
|
||||
glfwGetFramebufferSize(glfw.win, &glfw.display_width, &glfw.display_height);
|
||||
glfw.fb_scale.x = (float)glfw.display_width / (float)glfw.width;
|
||||
glfw.fb_scale.y = (float)glfw.display_height / (float)glfw.height;
|
||||
|
||||
nk_glfw3_destroy_render_resources(dev);
|
||||
nk_glfw3_create_render_resources(dev, framebuffer_width,
|
||||
@ -1031,11 +1029,16 @@ NK_API void nk_glfw3_new_frame(void) {
|
||||
struct nk_context *ctx = &glfw.ctx;
|
||||
struct GLFWwindow *win = glfw.win;
|
||||
|
||||
/* update the timer */
|
||||
float delta_time_now = (float)glfwGetTime();
|
||||
glfw.ctx.delta_time_seconds = delta_time_now - glfw.delta_time_seconds_last;
|
||||
glfw.delta_time_seconds_last = delta_time_now;
|
||||
|
||||
nk_input_begin(ctx);
|
||||
for (i = 0; i < glfw.text_len; ++i)
|
||||
nk_input_unicode(ctx, glfw.text[i]);
|
||||
|
||||
#ifdef NK_GLFW_GL4_MOUSE_GRABBING
|
||||
#ifdef NK_GLFW_VULKAN_MOUSE_GRABBING
|
||||
/* optional grabbing behavior */
|
||||
if (ctx->input.mouse.grab)
|
||||
glfwSetInputMode(glfw.win, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||
@ -1103,7 +1106,7 @@ NK_API void nk_glfw3_new_frame(void) {
|
||||
|
||||
glfwGetCursorPos(win, &x, &y);
|
||||
nk_input_motion(ctx, (int)x, (int)y);
|
||||
#ifdef NK_GLFW_GL4_MOUSE_GRABBING
|
||||
#ifdef NK_GLFW_VULKAN_MOUSE_GRABBING
|
||||
if (ctx->input.mouse.grabbed) {
|
||||
glfwSetCursorPos(glfw.win, ctx->input.mouse.prev.x,
|
||||
ctx->input.mouse.prev.y);
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Install
|
||||
BIN = zahnrad
|
||||
BIN = demo
|
||||
|
||||
# Flags
|
||||
CFLAGS += -std=c89 -Wall -Wextra -pedantic -Wno-unused-function -O2
|
||||
|
@ -2,7 +2,7 @@
|
||||
BIN = demo
|
||||
|
||||
# Flags
|
||||
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2
|
||||
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2 -DSDL_DISABLE_IMMINTRIN_H
|
||||
|
||||
SRC = main.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
@ -34,7 +34,7 @@
|
||||
* ===============================================================*/
|
||||
/* 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 defines */
|
||||
/*#define INCLUDE_ALL */
|
||||
#define INCLUDE_ALL
|
||||
/*#define INCLUDE_STYLE */
|
||||
/*#define INCLUDE_CALCULATOR */
|
||||
/*#define INCLUDE_CANVAS */
|
||||
|
@ -2,7 +2,7 @@
|
||||
BIN = demo
|
||||
|
||||
# Flags
|
||||
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2
|
||||
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2 -DSDL_DISABLE_IMMINTRIN_H
|
||||
|
||||
SRC = main.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
@ -2,7 +2,7 @@
|
||||
BIN = demo
|
||||
|
||||
# Flags
|
||||
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2
|
||||
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2 -DSDL_DISABLE_IMMINTRIN_H
|
||||
|
||||
SRC = main.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
@ -2,7 +2,7 @@
|
||||
BIN = demo
|
||||
|
||||
# Flags
|
||||
CFLAGS += -std=c89 -pedantic -O0
|
||||
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2 -DSDL_DISABLE_IMMINTRIN_H
|
||||
CFLAGS += `sdl2-config --cflags`
|
||||
|
||||
SRC = main.c
|
||||
|
3
demo/sdl_vulkan/.gitignore
vendored
Normal file
3
demo/sdl_vulkan/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
src/nuklearshaders/*.spv
|
||||
src/nuklear_sdl_vulkan.h
|
||||
shaders/*.spv
|
30
demo/sdl_vulkan/Makefile
Normal file
30
demo/sdl_vulkan/Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
# Install
|
||||
BIN = demo
|
||||
|
||||
# Flags
|
||||
CFLAGS += -std=c89 -Wall -Wextra -pedantic -fsanitize=address -O2
|
||||
CFLAGS += -DSDL_DISABLE_IMMINTRIN_H
|
||||
|
||||
SRC = main.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
BIN := $(BIN).exe
|
||||
LIBS = -lsdl2 -lvulkan -lm
|
||||
else
|
||||
UNAME_S := $(shell uname -s)
|
||||
SDL2 := $(shell pkg-config --libs sdl2)
|
||||
LIBS = $(SDL2) -lvulkan -lm
|
||||
endif
|
||||
|
||||
|
||||
$(BIN): shaders/demo.vert.spv shaders/demo.frag.spv
|
||||
@mkdir -p bin
|
||||
rm -f bin/$(BIN) $(OBJS)
|
||||
$(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) $(LIBS)
|
||||
|
||||
shaders/demo.vert.spv: shaders/demo.vert
|
||||
glslc --target-env=vulkan shaders/demo.vert -o shaders/demo.vert.spv
|
||||
|
||||
shaders/demo.frag.spv: shaders/demo.frag
|
||||
glslc --target-env=vulkan shaders/demo.frag -o shaders/demo.frag.spv
|
52
demo/sdl_vulkan/README.md
Normal file
52
demo/sdl_vulkan/README.md
Normal file
@ -0,0 +1,52 @@
|
||||
# nuklear sdl vulkan
|
||||
|
||||
## Theory of operation
|
||||
|
||||
The nuklear SDL vulkan integration creates an independent graphics pipeline that will render the nuklear UI to separate render targets.
|
||||
The application is responsible to fully manage these render targets. So it must ensure they are properly sized (and resized when requested).
|
||||
|
||||
Furthermore it is assumed that you will have a swap chain in place and the number of nuklear overlay images and number of swap chain images match.
|
||||
|
||||
This is how you can integrate it in your application:
|
||||
|
||||
```
|
||||
/*
|
||||
Setup: overlay_images have been created and their number match with the number
|
||||
of the swap_chain_images of your application. The overlay_images in this
|
||||
example have the same format as your swap_chain images (optional)
|
||||
*/
|
||||
struct nk_context *ctx = nk_sdl_init(
|
||||
demo.win, demo.device, demo.physical_device, demo.indices.graphics,
|
||||
demo.overlay_image_views, demo.swap_chain_images_len,
|
||||
demo.swap_chain_image_format, 0,
|
||||
MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER);
|
||||
[...]
|
||||
/*
|
||||
in your draw loop draw you can then render to the overlay image at
|
||||
`image_index`
|
||||
your own application can then wait for the semaphore and produce
|
||||
the swap_chain_image at `image_index`
|
||||
this should simply sample from the overlay_image (see example)
|
||||
*/
|
||||
nk_semaphore semaphore =
|
||||
nk_sdl_render(demo.graphics_queue, image_index,
|
||||
demo.image_available, NK_ANTI_ALIASING_ON);
|
||||
if (!render(&demo, &bg, nk_semaphore, image_index)) {
|
||||
fprintf(stderr, "render failed\n");
|
||||
return false;
|
||||
}
|
||||
```
|
||||
|
||||
You must call `nk_sdl_resize` whenever the size of the overlay_images resize.
|
||||
|
||||
## Using images
|
||||
|
||||
Images can be used by providing a VkImageView as an nk_image_ptr to nuklear:
|
||||
|
||||
```
|
||||
img = nk_image_ptr(demo.demo_texture_image_view);
|
||||
```
|
||||
|
||||
Note that they must have SHADER_READ_OPTIMAL layout
|
||||
|
||||
It is currently not possible to specify how they are being sampled. The nuklear SDL vulkan integration uses a fixed sampler that does linear filtering.
|
2251
demo/sdl_vulkan/main.c
Normal file
2251
demo/sdl_vulkan/main.c
Normal file
File diff suppressed because it is too large
Load Diff
1648
demo/sdl_vulkan/nuklear_sdl_vulkan.h
Normal file
1648
demo/sdl_vulkan/nuklear_sdl_vulkan.h
Normal file
File diff suppressed because it is too large
Load Diff
12
demo/sdl_vulkan/shaders/demo.frag
Normal file
12
demo/sdl_vulkan/shaders/demo.frag
Normal file
@ -0,0 +1,12 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(binding = 0) uniform sampler2D overlay;
|
||||
|
||||
layout(location = 0) in vec2 inUV;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
outColor = texture(overlay, inUV);
|
||||
}
|
10
demo/sdl_vulkan/shaders/demo.vert
Normal file
10
demo/sdl_vulkan/shaders/demo.vert
Normal file
@ -0,0 +1,10 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout (location = 0) out vec2 outUV;
|
||||
|
||||
void main()
|
||||
{
|
||||
outUV = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
|
||||
gl_Position = vec4(outUV * 2.0f + -1.0f, 0.0f, 1.0f);
|
||||
}
|
11
demo/sdl_vulkan/src/Makefile
Normal file
11
demo/sdl_vulkan/src/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
create_shader_inlined_header: nuklearshaders/nuklear.vert.spv nuklearshaders/nuklear.frag.spv
|
||||
awk -v st='// NUKLEAR_SHADERS_START' -v et='// NUKLEAR_SHADERS_END' -v repl="$$(xxd -i nuklearshaders/nuklear.vert.spv && xxd -i nuklearshaders/nuklear.frag.spv)" '$$0 == st{del=1} $$0 == et{$$0 = repl; del=0} !del' nuklear_sdl_vulkan.in.h > nuklear_sdl_vulkan.h
|
||||
|
||||
nuklearshaders/nuklear.vert.spv: nuklearshaders/nuklear.vert
|
||||
glslc --target-env=vulkan nuklearshaders/nuklear.vert -o nuklearshaders/nuklear.vert.spv
|
||||
|
||||
nuklearshaders/nuklear.frag.spv: nuklearshaders/nuklear.frag
|
||||
glslc --target-env=vulkan nuklearshaders/nuklear.frag -o nuklearshaders/nuklear.frag.spv
|
||||
|
||||
clean:
|
||||
rm nuklearshaders/nuklear.vert.spv nuklearshaders/nuklear.frag.spv nuklear_sdl_vulkan.h
|
5
demo/sdl_vulkan/src/README.md
Normal file
5
demo/sdl_vulkan/src/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
Contrary to OpenGL Vulkan needs precompiled shaders in the SPIR-V format which makes it a bit more difficult to inline the shadercode.
|
||||
|
||||
After executing `make` the result should be a self contained `nuklear_sdl_vulkan.h`. Copy the result file to the parent directory and the "release" should be done.
|
||||
|
||||
You will need to have `xxd`, `glslc` and `awk` installed for this.
|
1425
demo/sdl_vulkan/src/nuklear_sdl_vulkan.in.h
Normal file
1425
demo/sdl_vulkan/src/nuklear_sdl_vulkan.in.h
Normal file
File diff suppressed because it is too large
Load Diff
13
demo/sdl_vulkan/src/nuklearshaders/nuklear.frag
Normal file
13
demo/sdl_vulkan/src/nuklearshaders/nuklear.frag
Normal file
@ -0,0 +1,13 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(binding = 0, set = 1) uniform sampler2D currentTexture;
|
||||
|
||||
layout(location = 0) in vec4 fragColor;
|
||||
layout(location = 1) in vec2 fragUv;
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec4 texColor = texture(currentTexture, fragUv);
|
||||
outColor = fragColor * texColor;
|
||||
}
|
23
demo/sdl_vulkan/src/nuklearshaders/nuklear.vert
Normal file
23
demo/sdl_vulkan/src/nuklearshaders/nuklear.vert
Normal file
@ -0,0 +1,23 @@
|
||||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
layout(binding = 0) uniform UniformBufferObject {
|
||||
mat4 projection;
|
||||
} ubo;
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
layout(location = 1) in vec2 uv;
|
||||
layout(location = 2) in uvec4 color;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 1) out vec2 fragUv;
|
||||
|
||||
void main() {
|
||||
gl_Position = ubo.projection * vec4(position, 0.0, 1.0);
|
||||
gl_Position.y = -gl_Position.y;
|
||||
fragColor = vec4(color[0]/255.0, color[1]/255.0, color[2]/255.0, color[3]/255.0);
|
||||
fragUv = uv;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
# Install
|
||||
BIN = zahnrad
|
||||
BIN = demo
|
||||
|
||||
# Flags
|
||||
CFLAGS += -std=c89 -Wall -Wextra -pedantic -Wno-unused-function -O2
|
||||
|
@ -2,7 +2,7 @@
|
||||
BIN = demo
|
||||
|
||||
# Compiler
|
||||
CC = clang
|
||||
CC ?= clang
|
||||
DCC = gcc
|
||||
|
||||
# Flags
|
||||
@ -13,11 +13,11 @@ OBJ = $(SRC:.c=.o)
|
||||
|
||||
# Modes
|
||||
.PHONY: gcc
|
||||
gcc: CC = gcc
|
||||
gcc: CC ?= gcc
|
||||
gcc: $(BIN)
|
||||
|
||||
.PHONY: clang
|
||||
clang: CC = clang
|
||||
clang: CC ?= clang
|
||||
clang: $(BIN)
|
||||
|
||||
$(BIN):
|
||||
|
@ -2,7 +2,7 @@
|
||||
BIN = demo
|
||||
|
||||
# Compiler
|
||||
CC = clang
|
||||
CC ?= clang
|
||||
DCC = gcc
|
||||
|
||||
# Flags
|
||||
@ -13,11 +13,11 @@ OBJ = $(SRC:.c=.o)
|
||||
|
||||
# Modes
|
||||
.PHONY: gcc
|
||||
gcc: CC = gcc
|
||||
gcc: CC ?= gcc
|
||||
gcc: $(BIN)
|
||||
|
||||
.PHONY: clang
|
||||
clang: CC = clang
|
||||
clang: CC ?= clang
|
||||
clang: $(BIN)
|
||||
|
||||
$(BIN):
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Install
|
||||
BIN = zahnrad
|
||||
BIN = demo
|
||||
|
||||
# Flags
|
||||
CFLAGS += -std=c89 -Wall -Wextra -pedantic -Wno-unused-function -O2
|
||||
|
@ -789,9 +789,9 @@ NK_API int nk_cairo_render(struct nk_cairo_context *cairo_ctx, struct nk_context
|
||||
cairo_format_t format = CAIRO_FORMAT_ARGB32;
|
||||
int stride = cairo_format_stride_for_width(format, im->img.w);
|
||||
|
||||
if (!im->img.handle.ptr) return;
|
||||
if (!im->img.handle.ptr) return nk_false;
|
||||
img_surf = cairo_image_surface_create_for_data(im->img.handle.ptr, format, im->img.w, im->img.h, stride);
|
||||
if (!img_surf) return;
|
||||
if (!img_surf) return nk_false;
|
||||
cairo_save(cr);
|
||||
|
||||
cairo_rectangle(cr, im->x, im->y, im->w, im->h);
|
||||
|
2739
doc/Doxyfile
Normal file
2739
doc/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
26
doc/Makefile
26
doc/Makefile
@ -1,26 +0,0 @@
|
||||
# Install
|
||||
BIN = doc
|
||||
|
||||
# Flags
|
||||
CFLAGS += -std=c99 -pedantic -O2
|
||||
|
||||
SRC = stddoc.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
BIN := $(BIN).exe
|
||||
LIBS =
|
||||
else
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
LIBS =
|
||||
else
|
||||
LIBS =
|
||||
endif
|
||||
endif
|
||||
|
||||
$(BIN): clean
|
||||
$(CC) $(SRC) $(CFLAGS) -o $(BIN)
|
||||
|
||||
clean:
|
||||
rm -f $(BIN) $(OBJS)
|
@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
cat ../nuklear.h|./doc > index.html
|
2974
doc/index.html
2974
doc/index.html
File diff suppressed because it is too large
Load Diff
@ -1,11 +0,0 @@
|
||||
<!--
|
||||
This page is here in order to allow redirecting the old nuklear.html URL over to index.html
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=index.html" />
|
||||
</head>
|
||||
<body>
|
||||
<p>If you are not redirected in five seconds, <a href="index.html">click here</a>.</p>
|
||||
</body>
|
||||
</html>
|
141
doc/stddoc.c
141
doc/stddoc.c
@ -1,141 +0,0 @@
|
||||
/// ## About
|
||||
/// - _stddoc.c_ is a tiny documentation generator for 60 programming languages.
|
||||
/// - This page sample was auto-generated from the code comments found in `stddoc.c` file.
|
||||
///
|
||||
/// ## How does it work?
|
||||
/// - Markdeep code comments are extracted from stdin and printed into stdout as a HTML file.
|
||||
///
|
||||
/// ## Supported languages
|
||||
/// - `/// Three slashes comment` [ActionScript, AngelScript, C (C99), C#, C++, ChaiScript, D,
|
||||
/// GameMonkey, GML, Go, Java, JavaScript, JetScript, jtc, Jx9, Kotlin, Neko, Object Pascal (Delphi),
|
||||
/// Objective-C, Pawn, PHP, QuakeC, Rust, SASS, Scala, Squirrel, Swift, Vala, Wren, Xojo].
|
||||
/// - `--- Three dashes comment` [Ada, AppleScript, Eiffel, Euphoria, Haskell, Lua, Occam,
|
||||
/// PL/SQL, PSL, SGML, SPARK, SQL, Terra, TSQL, VHDL].
|
||||
/// - `### Three hashes comment` [AWK, Bash, Bourne shell, C shell, Cobra, Maple, Maple,
|
||||
/// Perl, Perl6, PowerShell, Python, R, Ruby, Seed7, Tcl].
|
||||
///
|
||||
/// ## Usage
|
||||
/// - `stddoc < source.code > documentation.html`
|
||||
///
|
||||
/// ## Changelog
|
||||
/// 2018/01/07
|
||||
/// : Initial version (_v1.0.0_)
|
||||
///
|
||||
/// ## License
|
||||
/// - rlyeh, unlicensed (~public domain).
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("%s\n", "<meta charset='utf-8' emacsmode='-*- markdown -*-'>");
|
||||
printf("%s\n", "<link rel='stylesheet' href='https://casual-effects.com/markdeep/latest/apidoc.css?'>");
|
||||
|
||||
for( int fsm_S = 0, fsm_D = 0, fsm_H = 0; !feof(stdin); ) {
|
||||
int chr = getc(stdin);
|
||||
if( fsm_S > 3 || fsm_D > 3 || fsm_H > 3 ) {
|
||||
putc(chr, stdout);
|
||||
if( chr != '\r' && chr != '\n' ) continue;
|
||||
}
|
||||
/**/ if( fsm_S <= 2 && chr == '/' && !fsm_D && !fsm_H ) fsm_S++;
|
||||
else if( fsm_S == 3 && chr == ' ' && !fsm_D && !fsm_H ) fsm_S++;
|
||||
else if( fsm_D <= 2 && chr == '-' && !fsm_S && !fsm_H ) fsm_D++;
|
||||
else if( fsm_D == 3 && chr == ' ' && !fsm_S && !fsm_H ) fsm_D++;
|
||||
else if( fsm_H <= 2 && chr == '#' && !fsm_S && !fsm_D ) fsm_H++;
|
||||
else if( fsm_H == 3 && chr == ' ' && !fsm_S && !fsm_D ) fsm_H++;
|
||||
else fsm_S = fsm_D = fsm_H = 0;
|
||||
}
|
||||
|
||||
printf("%s\n", "<script>markdeepOptions={tocStyle:'medium'};</script>");
|
||||
printf("%s\n", "<!-- Markdeep: --><script src='https://casual-effects.com/markdeep/latest/markdeep.min.js?'></script>");
|
||||
}
|
||||
|
||||
///
|
||||
/// ## **Example page!**
|
||||
///
|
||||
/// Imaginary documentation page. Here would be some introduction text.
|
||||
///
|
||||
/// The table of contents that Markdeep produces is stuffed on the right side,
|
||||
/// if the browser window is wide enough. Otherwise it is hidden.
|
||||
///
|
||||
/// ### Basic Markdeep
|
||||
///
|
||||
/// Regular styling like **bold**, _italics_, ~~strikethrough~~, `inline code`, etc. Lists as:
|
||||
///
|
||||
/// * A
|
||||
/// * Bullet
|
||||
/// * List
|
||||
///
|
||||
/// And:
|
||||
///
|
||||
/// 1. A
|
||||
/// 1. Numbered
|
||||
/// 1. List!
|
||||
///
|
||||
/// Symbol substitutions: a 45-degree turn; some x -> y arrows; some whoa ==> fancy <==> arrows.
|
||||
///
|
||||
/// Is this a definition list?
|
||||
/// : Looks like one to me
|
||||
/// Is that right?
|
||||
/// : Possibly!
|
||||
///
|
||||
/// And a code listing:
|
||||
///
|
||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/// int main()
|
||||
/// {
|
||||
/// return 1;
|
||||
/// }
|
||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
///
|
||||
///
|
||||
/// ### Tables
|
||||
///
|
||||
/// Thing Name | Description |Notes
|
||||
/// ------------------------|--------------------|-----
|
||||
/// Yes | Yup! |
|
||||
/// No | Nope :( |
|
||||
/// FileNotFound | Doesn't find files | Pass `-sFIND_FILE=maybe` to maybe find them
|
||||
///
|
||||
///
|
||||
/// ### Diagrams
|
||||
///
|
||||
/// ******************************************* Here's a text to the right of the diagram,
|
||||
/// * +-----------------+ .-. * ain't that fancy. Pretty fancy indeed, I
|
||||
/// * |\ | .-+ | * must say! Markdeep diagrams are generally
|
||||
/// * | \ A-B *---+--> .--+ '--. * enclosed into a rectangle full made of `*`
|
||||
/// * | \ | | Cloud! | * symbols; and are "drawn" using ASCII-art
|
||||
/// * +---+-------------+ '-------------' * style, with `- | + / \ * o` etc.
|
||||
/// ******************************************* Suh-weet!
|
||||
///
|
||||
/// Another random diagram, just because:
|
||||
///
|
||||
/// ********************
|
||||
/// * +-+-+-+-*-o *
|
||||
/// * / / ^ / *
|
||||
/// * / v / / *
|
||||
/// * +-+-+-+ *
|
||||
/// ********************
|
||||
///
|
||||
/// ### Special notes
|
||||
///
|
||||
/// !!! Note
|
||||
/// Hey I'm a note. Don't mind me, I'm just sitting here.
|
||||
///
|
||||
/// !!! WARNING
|
||||
/// I'm a warning, perhaps. *Something might happen!*
|
||||
///
|
||||
/// !!! Error: Never Pass `nullptr` to a Shader
|
||||
/// Invoking a shader with a null argument can seg fault.
|
||||
/// This is a multi-line admonition.
|
||||
///
|
||||
/// Seriously, don't call shaders like that.
|
||||
///
|
||||
/// ### Embedding HTML
|
||||
///
|
||||
/// <pre>
|
||||
/// This is an embedded html node by the way!
|
||||
/// </pre>
|
||||
///
|
||||
/// ## Credits
|
||||
/// - API doc style created by [Aras Pranckevičius](https://github.com/aras-p)
|
||||
/// - Markdeep by [Morgan McGuire](https://casual-effects.com/markdeep/).
|
216
src/HEADER
216
src/HEADER
@ -1,216 +0,0 @@
|
||||
/// # Nuklear
|
||||
/// ![](https://cloud.githubusercontent.com/assets/8057201/11761525/ae06f0ca-a0c6-11e5-819d-5610b25f6ef4.gif)
|
||||
///
|
||||
/// ## Contents
|
||||
/// 1. About section
|
||||
/// 2. Highlights section
|
||||
/// 3. Features section
|
||||
/// 4. Usage section
|
||||
/// 1. Flags section
|
||||
/// 2. Constants section
|
||||
/// 3. Dependencies section
|
||||
/// 5. Example section
|
||||
/// 6. API section
|
||||
/// 1. Context section
|
||||
/// 2. Input section
|
||||
/// 3. Drawing section
|
||||
/// 4. Window section
|
||||
/// 5. Layouting section
|
||||
/// 6. Groups section
|
||||
/// 7. Tree section
|
||||
/// 8. Properties section
|
||||
/// 7. License section
|
||||
/// 8. Changelog section
|
||||
/// 9. Gallery section
|
||||
/// 10. Credits section
|
||||
///
|
||||
/// ## About
|
||||
/// 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.
|
||||
///
|
||||
/// ## Highlights
|
||||
/// - Graphical user interface toolkit
|
||||
/// - Single header library
|
||||
/// - Written in C89 (a.k.a. ANSI C or ISO C90)
|
||||
/// - Small codebase (~18kLOC)
|
||||
/// - 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
|
||||
/// - [Code available on github](https://github.com/Immediate-Mode-UI/Nuklear/)
|
||||
///
|
||||
/// ## Features
|
||||
/// - Absolutely no platform dependent code
|
||||
/// - Memory management control ranging from/to
|
||||
/// - Ease of use by allocating everything from standard library
|
||||
/// - Control every byte of memory inside the library
|
||||
/// - Font handling control ranging from/to
|
||||
/// - Use your own font implementation for everything
|
||||
/// - Use this libraries internal font baking and handling API
|
||||
/// - Drawing output control ranging from/to
|
||||
/// - Simple shapes for more high level APIs which already have drawing capabilities
|
||||
/// - Hardware accessible anti-aliased vertex buffer output
|
||||
/// - Customizable colors and properties ranging from/to
|
||||
/// - Simple changes to color by filling a simple color table
|
||||
/// - Complete control with ability to use skinning to decorate widgets
|
||||
/// - Bendable UI library with widget ranging from/to
|
||||
/// - Basic widgets like buttons, checkboxes, slider, ...
|
||||
/// - Advanced widget like abstract comboboxes, contextual menus,...
|
||||
/// - Compile time configuration to only compile what you need
|
||||
/// - Subset which can be used if you do not want to link or use the standard library
|
||||
/// - Can be easily modified to only update on user input instead of frame updates
|
||||
///
|
||||
/// ## Usage
|
||||
/// 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. <br /><br />
|
||||
///
|
||||
/// The implementation mode requires to define the preprocessor macro
|
||||
/// NK_IMPLEMENTATION in *one* .c/.cpp file before #including this file, e.g.:
|
||||
///
|
||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~C
|
||||
/// #define NK_IMPLEMENTATION
|
||||
/// #include "nuklear.h"
|
||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
///
|
||||
/// Also optionally define the symbols listed in the section "OPTIONAL DEFINES"
|
||||
/// below in header and implementation mode if you want to use additional functionality
|
||||
/// or need more control over the library.
|
||||
///
|
||||
/// !!! WARNING
|
||||
/// Every time nuklear is included define the same compiler flags. This very important not doing so could lead to compiler errors or even worse stack corruptions.
|
||||
///
|
||||
/// ### Flags
|
||||
/// Flag | Description
|
||||
/// --------------------------------|------------------------------------------
|
||||
/// NK_PRIVATE | If defined declares all functions as static, so they can only be accessed inside the file that contains the implementation
|
||||
/// NK_INCLUDE_FIXED_TYPES | If defined it will include header `<stdint.h>` for fixed sized types otherwise nuklear tries to select the correct type. If that fails it will throw a compiler error and you have to select the correct types yourself.
|
||||
/// NK_INCLUDE_DEFAULT_ALLOCATOR | If defined it will include header `<stdlib.h>` and provide additional functions to use this library without caring for memory allocation control and therefore ease memory management.
|
||||
/// NK_INCLUDE_STANDARD_IO | If defined it will include header `<stdio.h>` and provide additional functions depending on file loading.
|
||||
/// NK_INCLUDE_STANDARD_VARARGS | If defined it will include header <stdarg.h> and provide additional functions depending on file loading.
|
||||
/// NK_INCLUDE_STANDARD_BOOL | If defined it will include header `<stdbool.h>` for nk_bool otherwise nuklear defines nk_bool as int.
|
||||
/// NK_INCLUDE_VERTEX_BUFFER_OUTPUT | Defining this adds a vertex draw command list backend to this library, which allows you to convert queue commands into vertex draw commands. This is mainly if you need a hardware accessible format for OpenGL, DirectX, Vulkan, Metal,...
|
||||
/// NK_INCLUDE_FONT_BAKING | Defining this adds `stb_truetype` and `stb_rect_pack` implementation to this library and provides font baking and rendering. If you already have font handling or do not want to use this font handler you don't have to define it.
|
||||
/// NK_INCLUDE_DEFAULT_FONT | Defining this adds the default font: ProggyClean.ttf into this library which can be loaded into a font atlas and allows using this library without having a truetype font
|
||||
/// NK_INCLUDE_COMMAND_USERDATA | Defining this adds a userdata pointer into each command. Can be useful for example if you want to provide custom shaders depending on the used widget. Can be combined with the style structures.
|
||||
/// NK_BUTTON_TRIGGER_ON_RELEASE | Different platforms require button clicks occurring either on buttons being pressed (up to down) or released (down to up). By default this library will react on buttons being pressed, but if you define this it will only trigger if a button is released.
|
||||
/// NK_ZERO_COMMAND_MEMORY | Defining this will zero out memory for each drawing command added to a drawing queue (inside nk_command_buffer_push). Zeroing command memory is very useful for fast checking (using memcmp) if command buffers are equal and avoid drawing frames when nothing on screen has changed since previous frame.
|
||||
/// NK_UINT_DRAW_INDEX | Defining this will set the size of vertex index elements when using NK_VERTEX_BUFFER_OUTPUT to 32bit instead of the default of 16bit
|
||||
/// NK_KEYSTATE_BASED_INPUT | Define this if your backend uses key state for each frame rather than key press/release events
|
||||
///
|
||||
/// !!! WARNING
|
||||
/// The following flags will pull in the standard C library:
|
||||
/// - NK_INCLUDE_DEFAULT_ALLOCATOR
|
||||
/// - NK_INCLUDE_STANDARD_IO
|
||||
/// - NK_INCLUDE_STANDARD_VARARGS
|
||||
///
|
||||
/// !!! WARNING
|
||||
/// The following flags if defined need to be defined for both header and implementation:
|
||||
/// - NK_INCLUDE_FIXED_TYPES
|
||||
/// - NK_INCLUDE_DEFAULT_ALLOCATOR
|
||||
/// - NK_INCLUDE_STANDARD_VARARGS
|
||||
/// - NK_INCLUDE_STANDARD_BOOL
|
||||
/// - NK_INCLUDE_VERTEX_BUFFER_OUTPUT
|
||||
/// - NK_INCLUDE_FONT_BAKING
|
||||
/// - NK_INCLUDE_DEFAULT_FONT
|
||||
/// - NK_INCLUDE_STANDARD_VARARGS
|
||||
/// - NK_INCLUDE_COMMAND_USERDATA
|
||||
/// - NK_UINT_DRAW_INDEX
|
||||
///
|
||||
/// ### Constants
|
||||
/// Define | Description
|
||||
/// --------------------------------|---------------------------------------
|
||||
/// NK_BUFFER_DEFAULT_INITIAL_SIZE | Initial buffer size allocated by all buffers while using the default allocator functions included by defining NK_INCLUDE_DEFAULT_ALLOCATOR. If you don't want to allocate the default 4k memory then redefine it.
|
||||
/// NK_MAX_NUMBER_BUFFER | Maximum buffer size for the conversion buffer between float and string Under normal circumstances this should be more than sufficient.
|
||||
/// NK_INPUT_MAX | Defines the max number of bytes which can be added as text input in one frame. Under normal circumstances this should be more than sufficient.
|
||||
///
|
||||
/// !!! WARNING
|
||||
/// The following constants if defined need to be defined for both header and implementation:
|
||||
/// - NK_MAX_NUMBER_BUFFER
|
||||
/// - NK_BUFFER_DEFAULT_INITIAL_SIZE
|
||||
/// - NK_INPUT_MAX
|
||||
///
|
||||
/// ### Dependencies
|
||||
/// Function | Description
|
||||
/// ------------|---------------------------------------------------------------
|
||||
/// NK_ASSERT | If you don't define this, nuklear will use <assert.h> with assert().
|
||||
/// NK_MEMSET | You can define this to 'memset' or your own memset implementation replacement. If not nuklear will use its own version.
|
||||
/// NK_MEMCPY | You can define this to 'memcpy' or your own memcpy implementation replacement. If not nuklear will use its own version.
|
||||
/// NK_INV_SQRT | You can define this to your own inverse sqrt implementation replacement. If not nuklear will use its own slow and not highly accurate version.
|
||||
/// NK_SIN | You can define this to 'sinf' or your own sine implementation replacement. If not nuklear will use its own approximation implementation.
|
||||
/// NK_COS | You can define this to 'cosf' or your own cosine implementation replacement. If not nuklear will use its own approximation implementation.
|
||||
/// NK_STRTOD | You can define this to `strtod` or your own string to double conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!).
|
||||
/// NK_DTOA | You can define this to `dtoa` or your own double to string conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!).
|
||||
/// NK_VSNPRINTF| If you define `NK_INCLUDE_STANDARD_VARARGS` as well as `NK_INCLUDE_STANDARD_IO` and want to be safe define this to `vsnprintf` on compilers supporting later versions of C or C++. By default nuklear will check for your stdlib version in C as well as compiler version in C++. if `vsnprintf` is available it will define it to `vsnprintf` directly. If not defined and if you have older versions of C or C++ it will be defined to `vsprintf` which is unsafe.
|
||||
///
|
||||
/// !!! WARNING
|
||||
/// The following dependencies will pull in the standard C library if not redefined:
|
||||
/// - NK_ASSERT
|
||||
///
|
||||
/// !!! WARNING
|
||||
/// The following dependencies if defined need to be defined for both header and implementation:
|
||||
/// - NK_ASSERT
|
||||
///
|
||||
/// !!! WARNING
|
||||
/// The following dependencies if defined need to be defined only for the implementation part:
|
||||
/// - NK_MEMSET
|
||||
/// - NK_MEMCPY
|
||||
/// - NK_SQRT
|
||||
/// - NK_SIN
|
||||
/// - NK_COS
|
||||
/// - NK_STRTOD
|
||||
/// - NK_DTOA
|
||||
/// - NK_VSNPRINTF
|
||||
///
|
||||
/// ## Example
|
||||
///
|
||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
||||
/// // init gui state
|
||||
/// enum {EASY, HARD};
|
||||
/// static int op = EASY;
|
||||
/// static float value = 0.6f;
|
||||
/// static int i = 20;
|
||||
/// struct nk_context ctx;
|
||||
///
|
||||
/// nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);
|
||||
/// 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);
|
||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
///
|
||||
/// ![](https://cloud.githubusercontent.com/assets/8057201/10187981/584ecd68-675c-11e5-897c-822ef534a876.png)
|
||||
///
|
||||
/// ## API
|
||||
///
|
216
src/HEADER.md
Normal file
216
src/HEADER.md
Normal file
@ -0,0 +1,216 @@
|
||||
# Nuklear
|
||||
![](https://cloud.githubusercontent.com/assets/8057201/11761525/ae06f0ca-a0c6-11e5-819d-5610b25f6ef4.gif)
|
||||
|
||||
## Contents
|
||||
1. About section
|
||||
2. Highlights section
|
||||
3. Features section
|
||||
4. Usage section
|
||||
1. Flags section
|
||||
2. Constants section
|
||||
3. Dependencies section
|
||||
5. Example section
|
||||
6. API section
|
||||
1. Context section
|
||||
2. Input section
|
||||
3. Drawing section
|
||||
4. Window section
|
||||
5. Layouting section
|
||||
6. Groups section
|
||||
7. Tree section
|
||||
8. Properties section
|
||||
7. License section
|
||||
8. Changelog section
|
||||
9. Gallery section
|
||||
10. Credits section
|
||||
|
||||
## About
|
||||
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.
|
||||
|
||||
## Highlights
|
||||
- Graphical user interface toolkit
|
||||
- Single header library
|
||||
- Written in C89 (a.k.a. ANSI C or ISO C90)
|
||||
- Small codebase (~18kLOC)
|
||||
- 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
|
||||
- [Code available on github](https://github.com/Immediate-Mode-UI/Nuklear/)
|
||||
|
||||
## Features
|
||||
- Absolutely no platform dependent code
|
||||
- Memory management control ranging from/to
|
||||
- Ease of use by allocating everything from standard library
|
||||
- Control every byte of memory inside the library
|
||||
- Font handling control ranging from/to
|
||||
- Use your own font implementation for everything
|
||||
- Use this libraries internal font baking and handling API
|
||||
- Drawing output control ranging from/to
|
||||
- Simple shapes for more high level APIs which already have drawing capabilities
|
||||
- Hardware accessible anti-aliased vertex buffer output
|
||||
- Customizable colors and properties ranging from/to
|
||||
- Simple changes to color by filling a simple color table
|
||||
- Complete control with ability to use skinning to decorate widgets
|
||||
- Bendable UI library with widget ranging from/to
|
||||
- Basic widgets like buttons, checkboxes, slider, ...
|
||||
- Advanced widget like abstract comboboxes, contextual menus,...
|
||||
- Compile time configuration to only compile what you need
|
||||
- Subset which can be used if you do not want to link or use the standard library
|
||||
- Can be easily modified to only update on user input instead of frame updates
|
||||
|
||||
## Usage
|
||||
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. <br /><br />
|
||||
|
||||
The implementation mode requires to define the preprocessor macro
|
||||
NK_IMPLEMENTATION in *one* .c/.cpp file before #including this file, e.g.:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~C
|
||||
#define NK_IMPLEMENTATION
|
||||
#include "nuklear.h"
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Also optionally define the symbols listed in the section "OPTIONAL DEFINES"
|
||||
below in header and implementation mode if you want to use additional functionality
|
||||
or need more control over the library.
|
||||
|
||||
!!! WARNING
|
||||
Every time nuklear is included define the same compiler flags. This very important not doing so could lead to compiler errors or even worse stack corruptions.
|
||||
|
||||
### Flags
|
||||
Flag | Description
|
||||
--------------------------------|------------------------------------------
|
||||
NK_PRIVATE | If defined declares all functions as static, so they can only be accessed inside the file that contains the implementation
|
||||
NK_INCLUDE_FIXED_TYPES | If defined it will include header `<stdint.h>` for fixed sized types otherwise nuklear tries to select the correct type. If that fails it will throw a compiler error and you have to select the correct types yourself.
|
||||
NK_INCLUDE_DEFAULT_ALLOCATOR | If defined it will include header `<stdlib.h>` and provide additional functions to use this library without caring for memory allocation control and therefore ease memory management.
|
||||
NK_INCLUDE_STANDARD_IO | If defined it will include header `<stdio.h>` and provide additional functions depending on file loading.
|
||||
NK_INCLUDE_STANDARD_VARARGS | If defined it will include header <stdarg.h> and provide additional functions depending on file loading.
|
||||
NK_INCLUDE_STANDARD_BOOL | If defined it will include header `<stdbool.h>` for nk_bool otherwise nuklear defines nk_bool as int.
|
||||
NK_INCLUDE_VERTEX_BUFFER_OUTPUT | Defining this adds a vertex draw command list backend to this library, which allows you to convert queue commands into vertex draw commands. This is mainly if you need a hardware accessible format for OpenGL, DirectX, Vulkan, Metal,...
|
||||
NK_INCLUDE_FONT_BAKING | Defining this adds `stb_truetype` and `stb_rect_pack` implementation to this library and provides font baking and rendering. If you already have font handling or do not want to use this font handler you don't have to define it.
|
||||
NK_INCLUDE_DEFAULT_FONT | Defining this adds the default font: ProggyClean.ttf into this library which can be loaded into a font atlas and allows using this library without having a truetype font
|
||||
NK_INCLUDE_COMMAND_USERDATA | Defining this adds a userdata pointer into each command. Can be useful for example if you want to provide custom shaders depending on the used widget. Can be combined with the style structures.
|
||||
NK_BUTTON_TRIGGER_ON_RELEASE | Different platforms require button clicks occurring either on buttons being pressed (up to down) or released (down to up). By default this library will react on buttons being pressed, but if you define this it will only trigger if a button is released.
|
||||
NK_ZERO_COMMAND_MEMORY | Defining this will zero out memory for each drawing command added to a drawing queue (inside nk_command_buffer_push). Zeroing command memory is very useful for fast checking (using memcmp) if command buffers are equal and avoid drawing frames when nothing on screen has changed since previous frame.
|
||||
NK_UINT_DRAW_INDEX | Defining this will set the size of vertex index elements when using NK_VERTEX_BUFFER_OUTPUT to 32bit instead of the default of 16bit
|
||||
NK_KEYSTATE_BASED_INPUT | Define this if your backend uses key state for each frame rather than key press/release events
|
||||
|
||||
!!! WARNING
|
||||
The following flags will pull in the standard C library:
|
||||
- NK_INCLUDE_DEFAULT_ALLOCATOR
|
||||
- NK_INCLUDE_STANDARD_IO
|
||||
- NK_INCLUDE_STANDARD_VARARGS
|
||||
|
||||
!!! WARNING
|
||||
The following flags if defined need to be defined for both header and implementation:
|
||||
- NK_INCLUDE_FIXED_TYPES
|
||||
- NK_INCLUDE_DEFAULT_ALLOCATOR
|
||||
- NK_INCLUDE_STANDARD_VARARGS
|
||||
- NK_INCLUDE_STANDARD_BOOL
|
||||
- NK_INCLUDE_VERTEX_BUFFER_OUTPUT
|
||||
- NK_INCLUDE_FONT_BAKING
|
||||
- NK_INCLUDE_DEFAULT_FONT
|
||||
- NK_INCLUDE_STANDARD_VARARGS
|
||||
- NK_INCLUDE_COMMAND_USERDATA
|
||||
- NK_UINT_DRAW_INDEX
|
||||
|
||||
### Constants
|
||||
Define | Description
|
||||
--------------------------------|---------------------------------------
|
||||
NK_BUFFER_DEFAULT_INITIAL_SIZE | Initial buffer size allocated by all buffers while using the default allocator functions included by defining NK_INCLUDE_DEFAULT_ALLOCATOR. If you don't want to allocate the default 4k memory then redefine it.
|
||||
NK_MAX_NUMBER_BUFFER | Maximum buffer size for the conversion buffer between float and string Under normal circumstances this should be more than sufficient.
|
||||
NK_INPUT_MAX | Defines the max number of bytes which can be added as text input in one frame. Under normal circumstances this should be more than sufficient.
|
||||
|
||||
!!! WARNING
|
||||
The following constants if defined need to be defined for both header and implementation:
|
||||
- NK_MAX_NUMBER_BUFFER
|
||||
- NK_BUFFER_DEFAULT_INITIAL_SIZE
|
||||
- NK_INPUT_MAX
|
||||
|
||||
### Dependencies
|
||||
Function | Description
|
||||
------------|---------------------------------------------------------------
|
||||
NK_ASSERT | If you don't define this, nuklear will use <assert.h> with assert().
|
||||
NK_MEMSET | You can define this to 'memset' or your own memset implementation replacement. If not nuklear will use its own version.
|
||||
NK_MEMCPY | You can define this to 'memcpy' or your own memcpy implementation replacement. If not nuklear will use its own version.
|
||||
NK_INV_SQRT | You can define this to your own inverse sqrt implementation replacement. If not nuklear will use its own slow and not highly accurate version.
|
||||
NK_SIN | You can define this to 'sinf' or your own sine implementation replacement. If not nuklear will use its own approximation implementation.
|
||||
NK_COS | You can define this to 'cosf' or your own cosine implementation replacement. If not nuklear will use its own approximation implementation.
|
||||
NK_STRTOD | You can define this to `strtod` or your own string to double conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!).
|
||||
NK_DTOA | You can define this to `dtoa` or your own double to string conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!).
|
||||
NK_VSNPRINTF| If you define `NK_INCLUDE_STANDARD_VARARGS` as well as `NK_INCLUDE_STANDARD_IO` and want to be safe define this to `vsnprintf` on compilers supporting later versions of C or C++. By default nuklear will check for your stdlib version in C as well as compiler version in C++. if `vsnprintf` is available it will define it to `vsnprintf` directly. If not defined and if you have older versions of C or C++ it will be defined to `vsprintf` which is unsafe.
|
||||
|
||||
!!! WARNING
|
||||
The following dependencies will pull in the standard C library if not redefined:
|
||||
- NK_ASSERT
|
||||
|
||||
!!! WARNING
|
||||
The following dependencies if defined need to be defined for both header and implementation:
|
||||
- NK_ASSERT
|
||||
|
||||
!!! WARNING
|
||||
The following dependencies if defined need to be defined only for the implementation part:
|
||||
- NK_MEMSET
|
||||
- NK_MEMCPY
|
||||
- NK_SQRT
|
||||
- NK_SIN
|
||||
- NK_COS
|
||||
- NK_STRTOD
|
||||
- NK_DTOA
|
||||
- NK_VSNPRINTF
|
||||
|
||||
## Example
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
||||
// init gui state
|
||||
enum {EASY, HARD};
|
||||
static int op = EASY;
|
||||
static float value = 0.6f;
|
||||
static int i = 20;
|
||||
struct nk_context ctx;
|
||||
|
||||
nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);
|
||||
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);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/8057201/10187981/584ecd68-675c-11e5-897c-822ef534a876.png)
|
||||
|
||||
## API
|
||||
|
6175
src/nuklear.h
6175
src/nuklear.h
File diff suppressed because it is too large
Load Diff
@ -242,7 +242,7 @@ nk_buffer_free(struct nk_buffer *b)
|
||||
b->pool.free(b->pool.userdata, b->memory.ptr);
|
||||
}
|
||||
NK_API void
|
||||
nk_buffer_info(struct nk_memory_status *s, struct nk_buffer *b)
|
||||
nk_buffer_info(struct nk_memory_status *s, const struct nk_buffer *b)
|
||||
{
|
||||
NK_ASSERT(b);
|
||||
NK_ASSERT(s);
|
||||
@ -268,10 +268,9 @@ nk_buffer_memory_const(const struct nk_buffer *buffer)
|
||||
return buffer->memory.ptr;
|
||||
}
|
||||
NK_API nk_size
|
||||
nk_buffer_total(struct nk_buffer *buffer)
|
||||
nk_buffer_total(const struct nk_buffer *buffer)
|
||||
{
|
||||
NK_ASSERT(buffer);
|
||||
if (!buffer) return 0;
|
||||
return buffer->memory.size;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ nk_parse_hex(const char *p, int length)
|
||||
return i;
|
||||
}
|
||||
NK_API struct nk_color
|
||||
nk_rgb_factor(struct nk_color col, const float factor)
|
||||
nk_rgb_factor(struct nk_color col, float factor)
|
||||
{
|
||||
if (factor == 1.0f)
|
||||
return col;
|
||||
@ -246,7 +246,7 @@ nk_hsva_colorf(float h, float s, float v, float a)
|
||||
return out;
|
||||
}
|
||||
NK_API struct nk_colorf
|
||||
nk_hsva_colorfv(float *c)
|
||||
nk_hsva_colorfv(const float *c)
|
||||
{
|
||||
return nk_hsva_colorf(c[0], c[1], c[2], c[3]);
|
||||
}
|
||||
@ -421,4 +421,3 @@ nk_color_hsv_bv(nk_byte *out, struct nk_color in)
|
||||
out[1] = (nk_byte)tmp[1];
|
||||
out[2] = (nk_byte)tmp[2];
|
||||
}
|
||||
|
||||
|
@ -702,7 +702,7 @@ NK_API void nk_combo_close(struct nk_context *ctx)
|
||||
nk_contextual_close(ctx);
|
||||
}
|
||||
NK_API int
|
||||
nk_combo(struct nk_context *ctx, const char **items, int count,
|
||||
nk_combo(struct nk_context *ctx, const char *const *items, int count,
|
||||
int selected, int item_height, struct nk_vec2 size)
|
||||
{
|
||||
int i = 0;
|
||||
@ -820,7 +820,7 @@ nk_combo_callback(struct nk_context *ctx, void(*item_getter)(void*, int, const c
|
||||
} return selected;
|
||||
}
|
||||
NK_API void
|
||||
nk_combobox(struct nk_context *ctx, const char **items, int count,
|
||||
nk_combobox(struct nk_context *ctx, const char *const *items, int count,
|
||||
int *selected, int item_height, struct nk_vec2 size)
|
||||
{
|
||||
*selected = nk_combo(ctx, items, count, *selected, item_height, size);
|
||||
@ -845,4 +845,3 @@ nk_combobox_callback(struct nk_context *ctx,
|
||||
{
|
||||
*selected = nk_combo_callback(ctx, item_getter, userdata, *selected, count, item_height, size);
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ nk_fill_triangle(struct nk_command_buffer *b, float x0, float y0, float x1,
|
||||
cmd->color = c;
|
||||
}
|
||||
NK_API void
|
||||
nk_stroke_polygon(struct nk_command_buffer *b, float *points, int point_count,
|
||||
nk_stroke_polygon(struct nk_command_buffer *b, const float *points, int point_count,
|
||||
float line_thickness, struct nk_color col)
|
||||
{
|
||||
int i;
|
||||
@ -350,7 +350,7 @@ nk_stroke_polygon(struct nk_command_buffer *b, float *points, int point_count,
|
||||
}
|
||||
}
|
||||
NK_API void
|
||||
nk_fill_polygon(struct nk_command_buffer *b, float *points, int point_count,
|
||||
nk_fill_polygon(struct nk_command_buffer *b, const float *points, int point_count,
|
||||
struct nk_color col)
|
||||
{
|
||||
int i;
|
||||
@ -371,7 +371,7 @@ nk_fill_polygon(struct nk_command_buffer *b, float *points, int point_count,
|
||||
}
|
||||
}
|
||||
NK_API void
|
||||
nk_stroke_polyline(struct nk_command_buffer *b, float *points, int point_count,
|
||||
nk_stroke_polyline(struct nk_command_buffer *b, const float *points, int point_count,
|
||||
float line_thickness, struct nk_color col)
|
||||
{
|
||||
int i;
|
||||
@ -555,4 +555,3 @@ nk_draw_text(struct nk_command_buffer *b, struct nk_rect r,
|
||||
NK_MEMCPY(cmd->string, string, (nk_size)length);
|
||||
cmd->string[length] = '\0';
|
||||
}
|
||||
|
||||
|
@ -504,7 +504,7 @@ nk_font_query_font_glyph(nk_handle handle, float height,
|
||||
}
|
||||
#endif
|
||||
NK_API const struct nk_font_glyph*
|
||||
nk_font_find_glyph(struct nk_font *font, nk_rune unicode)
|
||||
nk_font_find_glyph(const struct nk_font *font, nk_rune unicode)
|
||||
{
|
||||
int i = 0;
|
||||
int count;
|
||||
@ -567,8 +567,8 @@ nk_font_init(struct nk_font *font, float pixel_height,
|
||||
*
|
||||
* ProggyClean.ttf
|
||||
* Copyright (c) 2004, 2005 Tristan Grimmer
|
||||
* MIT license (see License.txt in http://www.upperbounds.net/download/ProggyClean.ttf.zip)
|
||||
* Download and more information at http://upperbounds.net
|
||||
* MIT license https://github.com/bluescan/proggyfonts/blob/master/LICENSE
|
||||
* Download and more information at https://github.com/bluescan/proggyfonts
|
||||
*-----------------------------------------------------------------------------*/
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
@ -1370,4 +1370,3 @@ nk_font_atlas_clear(struct nk_font_atlas *atlas)
|
||||
nk_zero_struct(*atlas);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -118,6 +118,7 @@ NK_LIB int nk_ifloord(double x);
|
||||
NK_LIB int nk_ifloorf(float x);
|
||||
NK_LIB int nk_iceilf(float x);
|
||||
NK_LIB int nk_log10(double n);
|
||||
NK_LIB float nk_roundf(float x);
|
||||
|
||||
/* util */
|
||||
enum {NK_DO_NOT_STOP_ON_NEW_LINE, NK_STOP_ON_NEW_LINE};
|
||||
@ -185,7 +186,7 @@ enum nk_window_insert_location {
|
||||
NK_LIB void *nk_create_window(struct nk_context *ctx);
|
||||
NK_LIB void nk_remove_window(struct nk_context*, struct nk_window*);
|
||||
NK_LIB void nk_free_window(struct nk_context *ctx, struct nk_window *win);
|
||||
NK_LIB struct nk_window *nk_find_window(struct nk_context *ctx, nk_hash hash, const char *name);
|
||||
NK_LIB struct nk_window *nk_find_window(const struct nk_context *ctx, nk_hash hash, const char *name);
|
||||
NK_LIB void nk_insert_window(struct nk_context *ctx, struct nk_window *win, enum nk_window_insert_location loc);
|
||||
|
||||
/* pool */
|
||||
@ -205,7 +206,7 @@ NK_LIB void nk_remove_table(struct nk_window *win, struct nk_table *tbl);
|
||||
NK_LIB void nk_free_table(struct nk_context *ctx, struct nk_table *tbl);
|
||||
NK_LIB void nk_push_table(struct nk_window *win, struct nk_table *tbl);
|
||||
NK_LIB nk_uint *nk_add_value(struct nk_context *ctx, struct nk_window *win, nk_hash name, nk_uint value);
|
||||
NK_LIB nk_uint *nk_find_value(struct nk_window *win, nk_hash name);
|
||||
NK_LIB nk_uint *nk_find_value(const struct nk_window *win, nk_hash name);
|
||||
|
||||
/* panel */
|
||||
NK_LIB void *nk_create_panel(struct nk_context *ctx);
|
||||
@ -226,7 +227,7 @@ NK_LIB void nk_row_layout(struct nk_context *ctx, enum nk_layout_format fmt, flo
|
||||
NK_LIB void nk_panel_alloc_row(const struct nk_context *ctx, struct nk_window *win);
|
||||
NK_LIB void nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx, struct nk_window *win, int modify);
|
||||
NK_LIB void nk_panel_alloc_space(struct nk_rect *bounds, const struct nk_context *ctx);
|
||||
NK_LIB void nk_layout_peek(struct nk_rect *bounds, struct nk_context *ctx);
|
||||
NK_LIB void nk_layout_peek(struct nk_rect *bounds, const struct nk_context *ctx);
|
||||
|
||||
/* popup */
|
||||
NK_LIB nk_bool nk_nonblock_begin(struct nk_context *ctx, nk_flags flags, struct nk_rect body, struct nk_rect header, enum nk_panel_type panel_type);
|
||||
@ -374,4 +375,3 @@ nk_stbtt_free(void *ptr, void *user_data) {
|
||||
#endif /* NK_INCLUDE_FONT_BAKING */
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -134,7 +134,7 @@ nk_row_layout(struct nk_context *ctx, enum nk_layout_format fmt,
|
||||
win->layout->row.item_width = (float)width;
|
||||
}
|
||||
NK_API float
|
||||
nk_layout_ratio_from_pixel(struct nk_context *ctx, float pixel_width)
|
||||
nk_layout_ratio_from_pixel(const struct nk_context *ctx, float pixel_width)
|
||||
{
|
||||
struct nk_window *win;
|
||||
NK_ASSERT(ctx);
|
||||
@ -463,7 +463,7 @@ nk_layout_space_push(struct nk_context *ctx, struct nk_rect rect)
|
||||
layout->row.item = rect;
|
||||
}
|
||||
NK_API struct nk_rect
|
||||
nk_layout_space_bounds(struct nk_context *ctx)
|
||||
nk_layout_space_bounds(const struct nk_context *ctx)
|
||||
{
|
||||
struct nk_rect ret;
|
||||
struct nk_window *win;
|
||||
@ -482,7 +482,7 @@ nk_layout_space_bounds(struct nk_context *ctx)
|
||||
return ret;
|
||||
}
|
||||
NK_API struct nk_rect
|
||||
nk_layout_widget_bounds(struct nk_context *ctx)
|
||||
nk_layout_widget_bounds(const struct nk_context *ctx)
|
||||
{
|
||||
struct nk_rect ret;
|
||||
struct nk_window *win;
|
||||
@ -501,7 +501,7 @@ nk_layout_widget_bounds(struct nk_context *ctx)
|
||||
return ret;
|
||||
}
|
||||
NK_API struct nk_vec2
|
||||
nk_layout_space_to_screen(struct nk_context *ctx, struct nk_vec2 ret)
|
||||
nk_layout_space_to_screen(const struct nk_context *ctx, struct nk_vec2 ret)
|
||||
{
|
||||
struct nk_window *win;
|
||||
struct nk_panel *layout;
|
||||
@ -517,7 +517,7 @@ nk_layout_space_to_screen(struct nk_context *ctx, struct nk_vec2 ret)
|
||||
return ret;
|
||||
}
|
||||
NK_API struct nk_vec2
|
||||
nk_layout_space_to_local(struct nk_context *ctx, struct nk_vec2 ret)
|
||||
nk_layout_space_to_local(const struct nk_context *ctx, struct nk_vec2 ret)
|
||||
{
|
||||
struct nk_window *win;
|
||||
struct nk_panel *layout;
|
||||
@ -533,7 +533,7 @@ nk_layout_space_to_local(struct nk_context *ctx, struct nk_vec2 ret)
|
||||
return ret;
|
||||
}
|
||||
NK_API struct nk_rect
|
||||
nk_layout_space_rect_to_screen(struct nk_context *ctx, struct nk_rect ret)
|
||||
nk_layout_space_rect_to_screen(const struct nk_context *ctx, struct nk_rect ret)
|
||||
{
|
||||
struct nk_window *win;
|
||||
struct nk_panel *layout;
|
||||
@ -549,7 +549,7 @@ nk_layout_space_rect_to_screen(struct nk_context *ctx, struct nk_rect ret)
|
||||
return ret;
|
||||
}
|
||||
NK_API struct nk_rect
|
||||
nk_layout_space_rect_to_local(struct nk_context *ctx, struct nk_rect ret)
|
||||
nk_layout_space_rect_to_local(const struct nk_context *ctx, struct nk_rect ret)
|
||||
{
|
||||
struct nk_window *win;
|
||||
struct nk_panel *layout;
|
||||
@ -601,7 +601,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
|
||||
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
|
||||
layout->bounds.w, layout->row.columns);
|
||||
|
||||
#define NK_FRAC(x) (x - (float)(int)x) /* will be used to remove fookin gaps */
|
||||
#define NK_FRAC(x) (x - (float)(int)nk_roundf(x)) /* will be used to remove fookin gaps */
|
||||
/* calculate the width of one item inside the current layout space */
|
||||
switch (layout->row.type) {
|
||||
case NK_LAYOUT_DYNAMIC_FIXED: {
|
||||
@ -730,7 +730,7 @@ nk_panel_alloc_space(struct nk_rect *bounds, const struct nk_context *ctx)
|
||||
layout->row.index++;
|
||||
}
|
||||
NK_LIB void
|
||||
nk_layout_peek(struct nk_rect *bounds, struct nk_context *ctx)
|
||||
nk_layout_peek(struct nk_rect *bounds, const struct nk_context *ctx)
|
||||
{
|
||||
float y;
|
||||
int index;
|
||||
|
@ -197,6 +197,11 @@ nk_log10(double n)
|
||||
if (neg) exp = -exp;
|
||||
return exp;
|
||||
}
|
||||
NK_LIB float
|
||||
nk_roundf(float x)
|
||||
{
|
||||
return (x >= 0.0) ? nk_ifloorf(x + 0.5) : nk_iceilf(x - 0.5);
|
||||
}
|
||||
NK_API struct nk_rect
|
||||
nk_get_null_rect(void)
|
||||
{
|
||||
|
@ -230,7 +230,7 @@ nk_popup_end(struct nk_context *ctx)
|
||||
nk_push_scissor(&win->buffer, win->layout->clip);
|
||||
}
|
||||
NK_API void
|
||||
nk_popup_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
|
||||
nk_popup_get_scroll(const struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
|
||||
{
|
||||
struct nk_window *popup;
|
||||
|
||||
|
@ -419,14 +419,14 @@ nk_str_get_const(const struct nk_str *s)
|
||||
return (const char*)s->buffer.memory.ptr;
|
||||
}
|
||||
NK_API int
|
||||
nk_str_len(struct nk_str *s)
|
||||
nk_str_len(const struct nk_str *s)
|
||||
{
|
||||
NK_ASSERT(s);
|
||||
if (!s || !s->len || !s->buffer.allocated) return 0;
|
||||
return s->len;
|
||||
}
|
||||
NK_API int
|
||||
nk_str_len_char(struct nk_str *s)
|
||||
nk_str_len_char(const struct nk_str *s)
|
||||
{
|
||||
NK_ASSERT(s);
|
||||
if (!s || !s->len || !s->buffer.allocated) return 0;
|
||||
@ -446,4 +446,3 @@ nk_str_free(struct nk_str *str)
|
||||
nk_buffer_free(&str->buffer);
|
||||
str->len = 0;
|
||||
}
|
||||
|
||||
|
@ -850,7 +850,7 @@ nk_style_load_cursor(struct nk_context *ctx, enum nk_style_cursor cursor,
|
||||
style->cursors[cursor] = c;
|
||||
}
|
||||
NK_API void
|
||||
nk_style_load_all_cursors(struct nk_context *ctx, struct nk_cursor *cursors)
|
||||
nk_style_load_all_cursors(struct nk_context *ctx, const struct nk_cursor *cursors)
|
||||
{
|
||||
int i = 0;
|
||||
struct nk_style *style;
|
||||
@ -861,4 +861,3 @@ nk_style_load_all_cursors(struct nk_context *ctx, struct nk_cursor *cursors)
|
||||
style->cursors[i] = &cursors[i];
|
||||
style->cursor_visible = nk_true;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ nk_add_value(struct nk_context *ctx, struct nk_window *win,
|
||||
return &win->tables->values[win->tables->size++];
|
||||
}
|
||||
NK_LIB nk_uint*
|
||||
nk_find_value(struct nk_window *win, nk_hash name)
|
||||
nk_find_value(const struct nk_window *win, nk_hash name)
|
||||
{
|
||||
struct nk_table *iter = win->tables;
|
||||
while (iter) {
|
||||
@ -87,4 +87,3 @@ nk_find_value(struct nk_window *win, nk_hash name)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ nk_strlen(const char *str)
|
||||
return siz;
|
||||
}
|
||||
NK_API int
|
||||
nk_strtoi(const char *str, const char **endptr)
|
||||
nk_strtoi(const char *str, char **endptr)
|
||||
{
|
||||
int neg = 1;
|
||||
const char *p = str;
|
||||
@ -161,15 +161,15 @@ nk_strtoi(const char *str, const char **endptr)
|
||||
p++;
|
||||
}
|
||||
if (endptr)
|
||||
*endptr = p;
|
||||
*endptr = (char *)p;
|
||||
return neg*value;
|
||||
}
|
||||
NK_API double
|
||||
nk_strtod(const char *str, const char **endptr)
|
||||
nk_strtod(const char *str, char **endptr)
|
||||
{
|
||||
double m;
|
||||
double neg = 1.0;
|
||||
const char *p = str;
|
||||
char *p = (char *)str;
|
||||
double value = 0;
|
||||
double number = 0;
|
||||
|
||||
@ -222,7 +222,7 @@ nk_strtod(const char *str, const char **endptr)
|
||||
return number;
|
||||
}
|
||||
NK_API float
|
||||
nk_strtof(const char *str, const char **endptr)
|
||||
nk_strtof(const char *str, char **endptr)
|
||||
{
|
||||
float float_value;
|
||||
double double_value;
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
* ===============================================================*/
|
||||
NK_API struct nk_rect
|
||||
nk_widget_bounds(struct nk_context *ctx)
|
||||
nk_widget_bounds(const struct nk_context *ctx)
|
||||
{
|
||||
struct nk_rect bounds;
|
||||
NK_ASSERT(ctx);
|
||||
@ -18,7 +18,7 @@ nk_widget_bounds(struct nk_context *ctx)
|
||||
return bounds;
|
||||
}
|
||||
NK_API struct nk_vec2
|
||||
nk_widget_position(struct nk_context *ctx)
|
||||
nk_widget_position(const struct nk_context *ctx)
|
||||
{
|
||||
struct nk_rect bounds;
|
||||
NK_ASSERT(ctx);
|
||||
@ -30,7 +30,7 @@ nk_widget_position(struct nk_context *ctx)
|
||||
return nk_vec2(bounds.x, bounds.y);
|
||||
}
|
||||
NK_API struct nk_vec2
|
||||
nk_widget_size(struct nk_context *ctx)
|
||||
nk_widget_size(const struct nk_context *ctx)
|
||||
{
|
||||
struct nk_rect bounds;
|
||||
NK_ASSERT(ctx);
|
||||
@ -42,7 +42,7 @@ nk_widget_size(struct nk_context *ctx)
|
||||
return nk_vec2(bounds.w, bounds.h);
|
||||
}
|
||||
NK_API float
|
||||
nk_widget_width(struct nk_context *ctx)
|
||||
nk_widget_width(const struct nk_context *ctx)
|
||||
{
|
||||
struct nk_rect bounds;
|
||||
NK_ASSERT(ctx);
|
||||
@ -54,7 +54,7 @@ nk_widget_width(struct nk_context *ctx)
|
||||
return bounds.w;
|
||||
}
|
||||
NK_API float
|
||||
nk_widget_height(struct nk_context *ctx)
|
||||
nk_widget_height(const struct nk_context *ctx)
|
||||
{
|
||||
struct nk_rect bounds;
|
||||
NK_ASSERT(ctx);
|
||||
@ -66,7 +66,7 @@ nk_widget_height(struct nk_context *ctx)
|
||||
return bounds.h;
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_widget_is_hovered(struct nk_context *ctx)
|
||||
nk_widget_is_hovered(const struct nk_context *ctx)
|
||||
{
|
||||
struct nk_rect c, v;
|
||||
struct nk_rect bounds;
|
||||
@ -88,7 +88,7 @@ nk_widget_is_hovered(struct nk_context *ctx)
|
||||
return nk_input_is_mouse_hovering_rect(&ctx->input, bounds);
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_widget_is_mouse_clicked(struct nk_context *ctx, enum nk_buttons btn)
|
||||
nk_widget_is_mouse_clicked(const struct nk_context *ctx, enum nk_buttons btn)
|
||||
{
|
||||
struct nk_rect c, v;
|
||||
struct nk_rect bounds;
|
||||
@ -110,7 +110,7 @@ nk_widget_is_mouse_clicked(struct nk_context *ctx, enum nk_buttons btn)
|
||||
return nk_input_mouse_clicked(&ctx->input, btn, bounds);
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_widget_has_mouse_click_down(struct nk_context *ctx, enum nk_buttons btn, nk_bool down)
|
||||
nk_widget_has_mouse_click_down(const struct nk_context *ctx, enum nk_buttons btn, nk_bool down)
|
||||
{
|
||||
struct nk_rect c, v;
|
||||
struct nk_rect bounds;
|
||||
@ -182,7 +182,7 @@ nk_widget(struct nk_rect *bounds, const struct nk_context *ctx)
|
||||
return NK_WIDGET_VALID;
|
||||
}
|
||||
NK_API enum nk_widget_layout_states
|
||||
nk_widget_fitting(struct nk_rect *bounds, struct nk_context *ctx,
|
||||
nk_widget_fitting(struct nk_rect *bounds, const struct nk_context *ctx,
|
||||
struct nk_vec2 item_padding)
|
||||
{
|
||||
/* update the bounds to stand without padding */
|
||||
|
@ -43,7 +43,7 @@ nk_free_window(struct nk_context *ctx, struct nk_window *win)
|
||||
nk_free_page_element(ctx, pe);}
|
||||
}
|
||||
NK_LIB struct nk_window*
|
||||
nk_find_window(struct nk_context *ctx, nk_hash hash, const char *name)
|
||||
nk_find_window(const struct nk_context *ctx, nk_hash hash, const char *name)
|
||||
{
|
||||
struct nk_window *iter;
|
||||
iter = ctx->begin;
|
||||
@ -352,7 +352,7 @@ nk_window_get_height(const struct nk_context *ctx)
|
||||
return ctx->current->bounds.h;
|
||||
}
|
||||
NK_API struct nk_rect
|
||||
nk_window_get_content_region(struct nk_context *ctx)
|
||||
nk_window_get_content_region(const struct nk_context *ctx)
|
||||
{
|
||||
NK_ASSERT(ctx);
|
||||
NK_ASSERT(ctx->current);
|
||||
@ -360,7 +360,7 @@ nk_window_get_content_region(struct nk_context *ctx)
|
||||
return ctx->current->layout->clip;
|
||||
}
|
||||
NK_API struct nk_vec2
|
||||
nk_window_get_content_region_min(struct nk_context *ctx)
|
||||
nk_window_get_content_region_min(const struct nk_context *ctx)
|
||||
{
|
||||
NK_ASSERT(ctx);
|
||||
NK_ASSERT(ctx->current);
|
||||
@ -369,7 +369,7 @@ nk_window_get_content_region_min(struct nk_context *ctx)
|
||||
return nk_vec2(ctx->current->layout->clip.x, ctx->current->layout->clip.y);
|
||||
}
|
||||
NK_API struct nk_vec2
|
||||
nk_window_get_content_region_max(struct nk_context *ctx)
|
||||
nk_window_get_content_region_max(const struct nk_context *ctx)
|
||||
{
|
||||
NK_ASSERT(ctx);
|
||||
NK_ASSERT(ctx->current);
|
||||
@ -379,7 +379,7 @@ nk_window_get_content_region_max(struct nk_context *ctx)
|
||||
ctx->current->layout->clip.y + ctx->current->layout->clip.h);
|
||||
}
|
||||
NK_API struct nk_vec2
|
||||
nk_window_get_content_region_size(struct nk_context *ctx)
|
||||
nk_window_get_content_region_size(const struct nk_context *ctx)
|
||||
{
|
||||
NK_ASSERT(ctx);
|
||||
NK_ASSERT(ctx->current);
|
||||
@ -388,7 +388,7 @@ nk_window_get_content_region_size(struct nk_context *ctx)
|
||||
return nk_vec2(ctx->current->layout->clip.w, ctx->current->layout->clip.h);
|
||||
}
|
||||
NK_API struct nk_command_buffer*
|
||||
nk_window_get_canvas(struct nk_context *ctx)
|
||||
nk_window_get_canvas(const struct nk_context *ctx)
|
||||
{
|
||||
NK_ASSERT(ctx);
|
||||
NK_ASSERT(ctx->current);
|
||||
@ -397,7 +397,7 @@ nk_window_get_canvas(struct nk_context *ctx)
|
||||
return &ctx->current->buffer;
|
||||
}
|
||||
NK_API struct nk_panel*
|
||||
nk_window_get_panel(struct nk_context *ctx)
|
||||
nk_window_get_panel(const struct nk_context *ctx)
|
||||
{
|
||||
NK_ASSERT(ctx);
|
||||
NK_ASSERT(ctx->current);
|
||||
@ -405,7 +405,7 @@ nk_window_get_panel(struct nk_context *ctx)
|
||||
return ctx->current->layout;
|
||||
}
|
||||
NK_API void
|
||||
nk_window_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
|
||||
nk_window_get_scroll(const struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
|
||||
{
|
||||
struct nk_window *win;
|
||||
NK_ASSERT(ctx);
|
||||
@ -428,7 +428,7 @@ nk_window_has_focus(const struct nk_context *ctx)
|
||||
return ctx->current == ctx->active;
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_window_is_hovered(struct nk_context *ctx)
|
||||
nk_window_is_hovered(const struct nk_context *ctx)
|
||||
{
|
||||
NK_ASSERT(ctx);
|
||||
NK_ASSERT(ctx->current);
|
||||
@ -443,7 +443,7 @@ nk_window_is_hovered(struct nk_context *ctx)
|
||||
}
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_window_is_any_hovered(struct nk_context *ctx)
|
||||
nk_window_is_any_hovered(const struct nk_context *ctx)
|
||||
{
|
||||
struct nk_window *iter;
|
||||
NK_ASSERT(ctx);
|
||||
@ -470,14 +470,14 @@ nk_window_is_any_hovered(struct nk_context *ctx)
|
||||
return 0;
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_item_is_any_active(struct nk_context *ctx)
|
||||
nk_item_is_any_active(const struct nk_context *ctx)
|
||||
{
|
||||
int any_hovered = nk_window_is_any_hovered(ctx);
|
||||
int any_active = (ctx->last_widget_state & NK_WIDGET_STATE_MODIFIED);
|
||||
return any_hovered || any_active;
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_window_is_collapsed(struct nk_context *ctx, const char *name)
|
||||
nk_window_is_collapsed(const struct nk_context *ctx, const char *name)
|
||||
{
|
||||
int title_len;
|
||||
nk_hash title_hash;
|
||||
@ -492,7 +492,7 @@ nk_window_is_collapsed(struct nk_context *ctx, const char *name)
|
||||
return win->flags & NK_WINDOW_MINIMIZED;
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_window_is_closed(struct nk_context *ctx, const char *name)
|
||||
nk_window_is_closed(const struct nk_context *ctx, const char *name)
|
||||
{
|
||||
int title_len;
|
||||
nk_hash title_hash;
|
||||
@ -507,7 +507,7 @@ nk_window_is_closed(struct nk_context *ctx, const char *name)
|
||||
return (win->flags & NK_WINDOW_CLOSED);
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_window_is_hidden(struct nk_context *ctx, const char *name)
|
||||
nk_window_is_hidden(const struct nk_context *ctx, const char *name)
|
||||
{
|
||||
int title_len;
|
||||
nk_hash title_hash;
|
||||
@ -522,7 +522,7 @@ nk_window_is_hidden(struct nk_context *ctx, const char *name)
|
||||
return (win->flags & NK_WINDOW_HIDDEN);
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_window_is_active(struct nk_context *ctx, const char *name)
|
||||
nk_window_is_active(const struct nk_context *ctx, const char *name)
|
||||
{
|
||||
int title_len;
|
||||
nk_hash title_hash;
|
||||
@ -537,7 +537,7 @@ nk_window_is_active(struct nk_context *ctx, const char *name)
|
||||
return win == ctx->active;
|
||||
}
|
||||
NK_API struct nk_window*
|
||||
nk_window_find(struct nk_context *ctx, const char *name)
|
||||
nk_window_find(const struct nk_context *ctx, const char *name)
|
||||
{
|
||||
int title_len;
|
||||
nk_hash title_hash;
|
||||
|
@ -1 +1 @@
|
||||
build.py --macro NK --intro HEADER --pub nuklear.h --priv1 nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c --extern stb_rect_pack.h,stb_truetype.h --priv2 nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_9slice.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_knob.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro LICENSE,CHANGELOG,CREDITS > ..\nuklear.h
|
||||
build.py --macro NK --intro HEADER.md --pub nuklear.h --priv1 nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c --extern stb_rect_pack.h,stb_truetype.h --priv2 nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_9slice.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_knob.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro LICENSE,CHANGELOG,CREDITS > ..\nuklear.h
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/bin/sh
|
||||
python build.py --macro NK --intro HEADER --pub nuklear.h --priv1 nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c --extern stb_rect_pack.h,stb_truetype.h --priv2 nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_9slice.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_knob.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro LICENSE,CHANGELOG,CREDITS > ../nuklear.h
|
||||
python3 build.py --macro NK --intro HEADER.md --pub nuklear.h --priv1 nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c --extern stb_rect_pack.h,stb_truetype.h --priv2 nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_9slice.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_knob.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro LICENSE,CHANGELOG,CREDITS > ../nuklear.h
|
||||
|
Loading…
Reference in New Issue
Block a user