added additional docu
This commit is contained in:
parent
52dcdb2d1e
commit
04cf4f9566
@ -59,56 +59,55 @@ font_get_width(gui_handle handle, const gui_char *text, gui_size len)
|
||||
}
|
||||
|
||||
static void
|
||||
draw_text(NVGcontext *ctx, float x, float y, struct gui_color c,
|
||||
draw_text(NVGcontext *ctx, float x, float y, const gui_byte *c,
|
||||
const gui_char *string, gui_size len)
|
||||
{
|
||||
gui_float height = 0;
|
||||
nvgBeginPath(ctx);
|
||||
nvgTextMetrics(ctx, NULL, NULL, &height);
|
||||
nvgFillColor(ctx, nvgRGBA(c.r, c.g, c.b, c.a));
|
||||
nvgFillColor(ctx, nvgRGBA(c[0], c[1], c[2], c[3]));
|
||||
nvgText(ctx, x, y + height, string, &string[len]);
|
||||
nvgFill(ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_line(NVGcontext *ctx, float x0, float y0, float x1, float y1, struct gui_color c)
|
||||
draw_line(NVGcontext *ctx, float x0, float y0, float x1, float y1, const gui_byte *c)
|
||||
{
|
||||
nvgBeginPath(ctx);
|
||||
nvgMoveTo(ctx, x0, y0);
|
||||
nvgLineTo(ctx, x1, y1);
|
||||
nvgFillColor(ctx, nvgRGBA(c.r, c.g, c.b, c.a));
|
||||
nvgFillColor(ctx, nvgRGBA(c[0], c[1], c[2], c[3]));
|
||||
nvgFill(ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_rect(NVGcontext *ctx, float x, float y, float w, float h, float r, struct gui_color c)
|
||||
draw_rect(NVGcontext *ctx, float x, float y, float w, float h, float r, const gui_byte* c)
|
||||
{
|
||||
nvgBeginPath(ctx);
|
||||
nvgRoundedRect(ctx, x, y, w, h, r);
|
||||
nvgFillColor(ctx, nvgRGBA(c.r, c.g, c.b, c.a));
|
||||
nvgFillColor(ctx, nvgRGBA(c[0], c[1], c[2], c[3]));
|
||||
nvgFill(ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_circle(NVGcontext *ctx, float x, float y, float r, struct gui_color c)
|
||||
draw_circle(NVGcontext *ctx, float x, float y, float r, const gui_byte *c)
|
||||
{
|
||||
NVGpaint bg;
|
||||
nvgBeginPath(ctx);
|
||||
nvgCircle(ctx, x + r, y + r, r);
|
||||
nvgFillColor(ctx, nvgRGBA(c.r, c.g, c.b, c.a));
|
||||
nvgFillColor(ctx, nvgRGBA(c[0], c[1], c[2], c[3]));
|
||||
nvgFill(ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_triangle(NVGcontext *ctx, float x0, float y0, float x1, float y1,
|
||||
float x2, float y2, struct gui_color c)
|
||||
float x2, float y2, const gui_byte *c)
|
||||
{
|
||||
nvgBeginPath(ctx);
|
||||
nvgMoveTo(ctx, x0, y0);
|
||||
nvgLineTo(ctx, x1, y1);
|
||||
nvgLineTo(ctx, x2, y2);
|
||||
nvgLineTo(ctx, x0, y0);
|
||||
nvgFillColor(ctx, nvgRGBA(c.r, c.g, c.b, c.a));
|
||||
nvgFillColor(ctx, nvgRGBA(c[0], c[1], c[2], c[3]));
|
||||
nvgFill(ctx);
|
||||
}
|
||||
|
||||
@ -126,9 +125,7 @@ draw_image(NVGcontext *ctx, gui_handle img, float x, float y, float w, float h,
|
||||
static void
|
||||
execute(NVGcontext *nvg, struct gui_command_buffer *list, int width, int height)
|
||||
{
|
||||
static const struct gui_color col = {255, 0, 0, 255};
|
||||
const struct gui_command *cmd;
|
||||
|
||||
glPushAttrib(GL_ENABLE_BIT|GL_COLOR_BUFFER_BIT);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@ -190,9 +187,7 @@ static void
|
||||
key(struct gui_input *in, SDL_Event *evt, gui_bool down)
|
||||
{
|
||||
SDL_Keycode sym = evt->key.keysym.sym;
|
||||
if (sym == SDLK_LCTRL || sym == SDLK_RCTRL)
|
||||
gui_input_key(in, GUI_KEY_CTRL, down);
|
||||
else if (sym == SDLK_RSHIFT || sym == SDLK_LSHIFT)
|
||||
if (sym == SDLK_RSHIFT || sym == SDLK_LSHIFT)
|
||||
gui_input_key(in, GUI_KEY_SHIFT, down);
|
||||
else if (sym == SDLK_DELETE)
|
||||
gui_input_key(in, GUI_KEY_DEL, down);
|
||||
@ -332,6 +327,7 @@ cleanup:
|
||||
/* Cleanup */
|
||||
free(gui.memory);
|
||||
nvgDeleteGLES2(vg);
|
||||
SDL_GL_DeleteContext(glContext);
|
||||
SDL_DestroyWindow(win);
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
|
21
gui.h
21
gui.h
@ -1035,9 +1035,10 @@ GUI_API gui_size gui_edit(struct gui_command_buffer*, gui_float x, gui_float y,
|
||||
- returns the size of the buffer in bytes after the modification
|
||||
*/
|
||||
GUI_API gui_size gui_edit_filtered(struct gui_command_buffer*, gui_float x, gui_float y,
|
||||
gui_float w, gui_float h, gui_char*, gui_size, gui_size max, gui_bool*,
|
||||
const struct gui_edit*, gui_filter filter, const struct gui_input*,
|
||||
const struct gui_font*);
|
||||
gui_float w, gui_float h, gui_char*, gui_size,
|
||||
gui_size max, gui_bool*, const struct gui_edit*,
|
||||
gui_filter filter, const struct gui_input*,
|
||||
const struct gui_font*);
|
||||
/* this function executes a editbox widget
|
||||
Input:
|
||||
- output command buffer for draw commands
|
||||
@ -1106,7 +1107,7 @@ GUI_API gui_float gui_scroll(struct gui_command_buffer*, gui_float x, gui_float
|
||||
- visual widget style structure describing the selector
|
||||
- input structure to update the slider with
|
||||
Output:
|
||||
- returns the from the user input updated spinner value
|
||||
- returns the from the user input updated scrollbar offset in pixels
|
||||
*/
|
||||
/*
|
||||
* ==============================================================
|
||||
@ -1117,9 +1118,21 @@ GUI_API gui_float gui_scroll(struct gui_command_buffer*, gui_float x, gui_float
|
||||
*/
|
||||
/* CONFIG
|
||||
----------------------------
|
||||
The panel configuration consists of style information that is used for
|
||||
the general style and looks of panel. In addition for temporary modification
|
||||
the configuration structure consists of a stack for pushing and pop either
|
||||
color or property values.
|
||||
|
||||
USAGE
|
||||
----------------------------
|
||||
To use the configuration file you either initial every value yourself besides
|
||||
the internal stack which needs to be initialized to zero or use the default
|
||||
configuration by calling the function gui_config_default.
|
||||
To add and remove temporary configuration states the gui_config_push_xxxx
|
||||
for adding and gui_config_pop_xxxx for removing either color or property values
|
||||
from the stack. To reset all previously modified values the gui_config_reset_xxx
|
||||
were added.
|
||||
|
||||
Configuration function API
|
||||
gui_config_default -- initializes a default panel configuration
|
||||
gui_config_property -- returns the property value from an id
|
||||
|
Loading…
x
Reference in New Issue
Block a user