fixed some small typos
This commit is contained in:
parent
b416e82436
commit
da632a619d
42
Readme.md
42
Readme.md
|
@ -66,7 +66,6 @@ struct gui_memory memory = {...};
|
|||
struct gui_memory_status status;
|
||||
struct gui_command_buffer buffer;
|
||||
struct gui_command_list out;
|
||||
struct gui_command_list list;
|
||||
struct gui_panel panel;
|
||||
|
||||
gui_default_config(&config);
|
||||
|
@ -161,16 +160,16 @@ true immedate mode fashion possible and supported.
|
|||
### Buffering
|
||||
For the purpose of defered drawing or the implementation of overlapping panels
|
||||
the command buffering API was added. The command buffer hereby holds a queue of
|
||||
drawing commands for a number of primitives like line, rectangle, circle,
|
||||
triangle and text. The memory for the command buffer can be provided by the user
|
||||
in three different ways. First a fixed memory block can be given over to the
|
||||
command buffer which fills the memory up until no memory is left. The seond way
|
||||
is still using a fixed size block but rellocating a new block of memory at the
|
||||
end of the frame, if not enough memory was provided. The final way of memory
|
||||
management is by providing allocator callbacks with alloc, realloc and free.
|
||||
In true immediate mode fashion the buffering API is by base around a sequence
|
||||
point API with an begin sequence point `gui_output_begin` and a end sequence
|
||||
point with `gui_output_end` and modification of state between both points. Just
|
||||
drawing commands for a number of primitives eg.: line, rectangle, circle,
|
||||
triangle and text. memory The command buffer memory is provided by the user
|
||||
in three possible ways. First by providing a fixed size memory block which
|
||||
will be filled up until no memory is left.
|
||||
The second way is extending the fixed size memory block by reallocating at the
|
||||
end of the frame if the providided memory size was not sufficient.
|
||||
The final way of memory management is by providing allocator callbacks with alloc, realloc and free.
|
||||
In true immediate mode fashion the buffering API is based around a sequence
|
||||
points with an begin sequence point `gui_output_begin` and a end sequence
|
||||
point `gui_output_end` and modification of state between both points. Just
|
||||
like the input API the buffer modification before the begining or after the end
|
||||
sequence point is undefined behavior.
|
||||
|
||||
|
@ -212,18 +211,17 @@ while (1) {
|
|||
### Panels
|
||||
To further extend the basic widget layer and remove some of the boilerplate
|
||||
code the panel was introduced. The panel groups together a number of
|
||||
widgets but in true immediate mode fashion does not save any widget state from
|
||||
widgets but in true immediate mode fashion does not save any state from
|
||||
widgets that have been added to the panel. In addition the panel enables a
|
||||
number of nice features for a group of widgets like panel movement, scaling,
|
||||
closing and minimizing. An additional use for panels is to further group widgets
|
||||
in panels to tabs, groups and shelfs.
|
||||
The panel is divided into a persistent state struct with `struct gui_panel` with a number
|
||||
of attributes which have a persistent life time outside the frame and the panel layout
|
||||
`struct gui_panel_layout` with a transient frame life time. While the layout
|
||||
state is constantly modifed over the course of the frame the panel struct is
|
||||
only modifed at the immendiate mode sequence points `gui_panel_begin` and
|
||||
`gui_panel_end`. Therefore all changes to the panel struct inside of both
|
||||
sequence points has no effect on the current frame and is only visible in the
|
||||
number of nice features on a group of widgets like movement, scaling,
|
||||
closing and minimizing. An additional use for panel is to further extend the
|
||||
grouping of widgets into tabs, groups and shelfs.
|
||||
The panel is divided into a `struct gui_panel` with persistent life time
|
||||
the `struct gui_panel_layout` structure with a transient frame life time.
|
||||
While the layout state is constantly modifed over the course of
|
||||
the frame, the panel struct is only modified at the immendiate mode sequence points
|
||||
`gui_panel_begin` and `gui_panel_end`. Therefore all changes to the panel struct inside of both
|
||||
sequence points have no effect in the current frame and are only visible in the
|
||||
next frame.
|
||||
|
||||
```c
|
||||
|
|
27
demo/xlib.c
27
demo/xlib.c
|
@ -71,10 +71,10 @@ struct demo {
|
|||
gui_int spinner;
|
||||
gui_bool spin_act;
|
||||
gui_size item_cur;
|
||||
gui_size current;
|
||||
gui_bool tab_minimized;
|
||||
gui_float group_offset;
|
||||
gui_float shelf_offset;
|
||||
gui_size cur;
|
||||
gui_bool tab_min;
|
||||
gui_float group_off;
|
||||
gui_float shelf_off;
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -284,7 +284,7 @@ surface_draw_text(XSurface *surf, float x, float y, float w, float h, const char
|
|||
ty = (int)y + ((int)h / 2) - (th / 2) + font->ascent;
|
||||
XSetForeground(surf->dpy, surf->gc, fg);
|
||||
if(font->set)
|
||||
XmbDrawString(surf->dpy, surf->drawable, font->set, surf->gc, tx, ty, (const char*)text, (int)len);
|
||||
XmbDrawString(surf->dpy,surf->drawable,font->set,surf->gc,tx,ty,(const char*)text,(int)len);
|
||||
else
|
||||
XDrawString(surf->dpy, surf->drawable, surf->gc, tx, ty, (const char*)text, (int)len);
|
||||
}
|
||||
|
@ -416,7 +416,7 @@ demo_panel(struct gui_panel_layout *panel, struct demo *demo)
|
|||
struct gui_panel_layout tab;
|
||||
|
||||
/* Tabs */
|
||||
demo->tab_minimized = gui_panel_tab_begin(panel, &tab, "Difficulty", demo->tab_minimized);
|
||||
demo->tab_min = gui_panel_tab_begin(panel, &tab, "Difficulty", demo->tab_min);
|
||||
gui_panel_row(&tab, 30, 3);
|
||||
for (i = 0; i < (gui_int)LEN(options); i++) {
|
||||
if (gui_panel_option(&tab, options[i], demo->option == i))
|
||||
|
@ -426,17 +426,17 @@ demo_panel(struct gui_panel_layout *panel, struct demo *demo)
|
|||
|
||||
/* Shelf */
|
||||
gui_panel_row(panel, 200, 2);
|
||||
demo->current = gui_panel_shelf_begin(panel, &tab, shelfs, LEN(shelfs), demo->current, demo->shelf_offset);
|
||||
demo->cur = gui_panel_shelf_begin(panel,&tab,shelfs,LEN(shelfs),demo->cur,demo->shelf_off);
|
||||
gui_panel_row(&tab, 100, 1);
|
||||
if (demo->current == HISTO) {
|
||||
if (demo->cur == HISTO) {
|
||||
gui_panel_histo(&tab, values, LEN(values));
|
||||
} else {
|
||||
gui_panel_plot(&tab, values, LEN(values));
|
||||
}
|
||||
demo->shelf_offset = gui_panel_shelf_end(panel, &tab);
|
||||
demo->shelf_off = gui_panel_shelf_end(panel, &tab);
|
||||
|
||||
/* Group */
|
||||
gui_panel_group_begin(panel, &tab, "Options", demo->group_offset);
|
||||
gui_panel_group_begin(panel, &tab, "Options", demo->group_off);
|
||||
gui_panel_row(&tab, 30, 1);
|
||||
if (gui_panel_button_text(&tab, "button", GUI_BUTTON_DEFAULT))
|
||||
fprintf(stdout, "button pressed!\n");
|
||||
|
@ -445,8 +445,9 @@ demo_panel(struct gui_panel_layout *panel, struct demo *demo)
|
|||
demo->prog = gui_panel_progress(&tab, demo->prog, 100, gui_true);
|
||||
demo->item_cur = gui_panel_selector(&tab, items, LEN(items), demo->item_cur);
|
||||
demo->spinner = gui_panel_spinner(&tab, 0, demo->spinner, 250, 10, &demo->spin_act);
|
||||
demo->in_len = gui_panel_input(&tab, demo->in_buf, demo->in_len, MAX_BUFFER, &demo->in_act, GUI_INPUT_DEFAULT);
|
||||
demo->group_offset = gui_panel_group_end(panel, &tab);
|
||||
demo->in_len = gui_panel_input(&tab,demo->in_buf,demo->in_len,
|
||||
MAX_BUFFER,&demo->in_act,GUI_INPUT_DEFAULT);
|
||||
demo->group_off = gui_panel_group_end(panel, &tab);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -511,7 +512,7 @@ main(int argc, char *argv[])
|
|||
|
||||
/* Demo */
|
||||
memset(&demo, 0, sizeof(demo));
|
||||
demo.tab_minimized = gui_true;
|
||||
demo.tab_min = gui_true;
|
||||
demo.spinner = 100;
|
||||
demo.slider = 2.0f;
|
||||
demo.prog = 60;
|
||||
|
|
12
gui.c
12
gui.c
|
@ -1957,7 +1957,7 @@ gui_bool gui_panel_tab_begin(struct gui_panel_layout *parent, struct gui_panel_l
|
|||
gui_panel_alloc_space(&bounds, parent);
|
||||
|
||||
flags = GUI_PANEL_BORDER|GUI_PANEL_MINIMIZABLE|GUI_PANEL_TAB;
|
||||
gui_panel_init(&panel, bounds.x, bounds.y, bounds.w, null_rect.h, flags, parent->config, &parent->font);
|
||||
gui_panel_init(&panel,bounds.x,bounds.y,bounds.w,null_rect.h,flags,parent->config,&parent->font);
|
||||
panel.minimized = minimized;
|
||||
gui_panel_begin(tab, &panel, title, canvas, parent->input);
|
||||
unify(&clip, &parent->clip, tab->clip.x, tab->clip.y, tab->clip.x + tab->clip.w,
|
||||
|
@ -1982,7 +1982,7 @@ gui_panel_tab_end(struct gui_panel_layout *parent, struct gui_panel_layout *tab)
|
|||
gui_panel_end(tab, &panel);
|
||||
parent->at_y += tab->height + tab->config->item_spacing.y;
|
||||
canvas = parent->canvas;
|
||||
canvas->scissor(canvas->userdata, parent->clip.x, parent->clip.y, parent->clip.w, parent->clip.h);
|
||||
canvas->scissor(canvas->userdata, parent->clip.x,parent->clip.y,parent->clip.w,parent->clip.h);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2011,7 +2011,7 @@ gui_panel_group_begin(struct gui_panel_layout *parent, struct gui_panel_layout *
|
|||
canvas = parent->canvas;
|
||||
|
||||
flags = GUI_PANEL_BORDER|GUI_PANEL_SCROLLBAR|GUI_PANEL_TAB;
|
||||
gui_panel_init(&panel, bounds.x, bounds.y, bounds.w, bounds.h, flags, parent->config, &parent->font);
|
||||
gui_panel_init(&panel, bounds.x,bounds.y,bounds.w,bounds.h,flags,parent->config,&parent->font);
|
||||
gui_panel_begin(group, &panel, title, parent->canvas, parent->input);
|
||||
group->offset = offset;
|
||||
unify(&clip, &parent->clip, group->clip.x, group->clip.y, group->clip.x + group->clip.w,
|
||||
|
@ -2039,7 +2039,7 @@ gui_panel_group_end(struct gui_panel_layout *parent, struct gui_panel_layout *gr
|
|||
unify(&clip, &parent->clip, group->clip.x, group->clip.y, group->x+group->w, group->y+group->h);
|
||||
canvas->scissor(canvas->userdata, clip.x, clip.y, clip.w, clip.h);
|
||||
gui_panel_end(group, &panel);
|
||||
canvas->scissor(canvas->userdata, parent->clip.x, parent->clip.y, parent->clip.w, parent->clip.h);
|
||||
canvas->scissor(canvas->userdata, parent->clip.x,parent->clip.y,parent->clip.w,parent->clip.h);
|
||||
return panel.offset;
|
||||
}
|
||||
|
||||
|
@ -2112,7 +2112,7 @@ gui_panel_shelf_begin(struct gui_panel_layout *parent, struct gui_panel_layout *
|
|||
bounds.h -= header_h;
|
||||
|
||||
flags = GUI_PANEL_BORDER|GUI_PANEL_SCROLLBAR|GUI_PANEL_TAB;
|
||||
gui_panel_init(&panel, bounds.x, bounds.y, bounds.w, bounds.h, flags, parent->config, &parent->font);
|
||||
gui_panel_init(&panel, bounds.x,bounds.y,bounds.w,bounds.h,flags,parent->config,&parent->font);
|
||||
gui_panel_begin(shelf, &panel, NULL, parent->canvas, parent->input);
|
||||
shelf->offset = offset;
|
||||
unify(&clip, &parent->clip, shelf->clip.x, shelf->clip.y,
|
||||
|
@ -2141,7 +2141,7 @@ gui_panel_shelf_end(struct gui_panel_layout *parent, struct gui_panel_layout *sh
|
|||
unify(&clip, &parent->clip, shelf->clip.x, shelf->clip.y, shelf->x+shelf->w, shelf->y+shelf->h);
|
||||
canvas->scissor(canvas->userdata, clip.x, clip.y, clip.w, clip.h);
|
||||
gui_panel_end(shelf, &panel);
|
||||
canvas->scissor(canvas->userdata, parent->clip.x, parent->clip.y, parent->clip.w, parent->clip.h);
|
||||
canvas->scissor(canvas->userdata, parent->clip.x,parent->clip.y,parent->clip.w,parent->clip.h);
|
||||
return shelf->offset;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue