diff options
Diffstat (limited to 'kon/konui.h')
| -rw-r--r-- | kon/konui.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/kon/konui.h b/kon/konui.h index 9b253ca..98a1f08 100644 --- a/kon/konui.h +++ b/kon/konui.h @@ -71,6 +71,46 @@ int kon_uiWantsKeyboard(const kon_ui_t *ui); int kon_uiBeginPanel(kon_ui_t *ui, const char *title, kon_uiPanel_t *panel); void kon_uiEndPanel(kon_ui_t *ui); +/*** areas ***/ + +/* a fixed part of the window with no title and no dragging, for a layout that stays put: a side bar, a list, a preview. what is inside + is clipped to it and scrolls with the wheel when it is taller than the area. you own this and fill in x, y, w and h, the ui keeps + scroll and contentH. contentH is what the last frame needed, so the scroll bar shows up one frame late */ +typedef struct kon_uiArea { + int x, y, w, h; + int scroll; + int contentH; +} kon_uiArea_t; + +/* returns 0 when it is not drawn (nothing of it is on screen, or it is inside a panel, an area or a menu). always call kon_uiEndArea */ +int kon_uiBeginArea(kon_ui_t *ui, const char *id, kon_uiArea_t *area); +void kon_uiEndArea(kon_ui_t *ui); + +/*** menus ***/ + +/* a bar along the top of the window, kon_uiMenuBarHeight is how tall it is so you can lay the rest out under it. + kon_uiBeginMenu gives 1 while that menu is open, and then its items are kon_uiMenuItem, which gives 1 when one is clicked. + always call kon_uiEndMenu and kon_uiEndMenuBar. what is open is drawn over everything at the end of the frame. + a menu is as long as its items, up to 600 pixels, the rest is cut off + + if (kon_uiBeginMenuBar(ui)) { + if (kon_uiBeginMenu(ui, "File")) { + if (kon_uiMenuItem(ui, "Open", "Ctrl+O")) open(); + kon_uiMenuSeparator(ui); + if (kon_uiMenuItem(ui, "Quit", NULL)) quit(); + } + kon_uiEndMenu(ui); + } + kon_uiEndMenuBar(ui); +*/ +int kon_uiBeginMenuBar(kon_ui_t *ui); +void kon_uiEndMenuBar(kon_ui_t *ui); +int kon_uiMenuBarHeight(const kon_ui_t *ui); +int kon_uiBeginMenu(kon_ui_t *ui, const char *label); +int kon_uiMenuItem(kon_ui_t *ui, const char *label, const char *shortcut); +void kon_uiMenuSeparator(kon_ui_t *ui); +void kon_uiEndMenu(kon_ui_t *ui); + /* anything after ## in a label is part of the id but not drawn, so "ok##a" and "ok##b" are different buttons */ void kon_uiLabel(kon_ui_t *ui, const char *text); void kon_uiLabelf(kon_ui_t *ui, const char *format, ...); @@ -83,6 +123,14 @@ int kon_uiSelectable(kon_ui_t *ui, const char *label, int selected); /* returns 1 when enter is pressed. label is shown while the field is empty */ int kon_uiTextInput(kon_ui_t *ui, const char *label, char *buffer, size_t size); +/* a row of tabs, current is the one shown. returns 1 when another one was clicked */ +int kon_uiTabs(kon_ui_t *ui, const char *const *labels, int count, int *current); + +/* a line with a + or - in front that opens and closes. returns the new open state, show what is inside when it is 1 and use + kon_uiIndent to push it in */ +int kon_uiTreeNode(kon_ui_t *ui, const char *label, int *open); +void kon_uiIndent(kon_ui_t *ui, int amount); + void kon_uiSeparator(kon_ui_t *ui); void kon_uiSameLine(kon_ui_t *ui); void kon_uiPushId(kon_ui_t *ui, int id); |
