1 module overview;
2 
3 import bindbc.nuklear;
4 
5 import core.stdc..string;
6 import core.stdc.stdlib;
7 import core.stdc.stdio;
8 import core.stdc.math;
9 
10 int
11 overview(nk_context *ctx)
12 {
13     /* window flags */
14     static int show_menu = nk_true;
15     static int titlebar = nk_true;
16     static int border = nk_true;
17     static int resize = nk_true;
18     static int movable = nk_true;
19     static int no_scrollbar = nk_false;
20     static int scale_left = nk_false;
21     static nk_flags window_flags = 0;
22     static int minimizable = nk_true;
23 
24     /* popups */
25     static enum nk_style_header_align header_align = NK_HEADER_RIGHT;
26     static int show_app_about = nk_false;
27 
28     /* window flags */
29     window_flags = 0;
30     ctx.style.window.header.align_ = header_align;
31     if (border) window_flags |= NK_WINDOW_BORDER;
32     if (resize) window_flags |= NK_WINDOW_SCALABLE;
33     if (movable) window_flags |= NK_WINDOW_MOVABLE;
34     if (no_scrollbar) window_flags |= NK_WINDOW_NO_SCROLLBAR;
35     if (scale_left) window_flags |= NK_WINDOW_SCALE_LEFT;
36     if (minimizable) window_flags |= NK_WINDOW_MINIMIZABLE;
37 
38     if (nk_begin(ctx, "Overview", nk_rect(10, 10, 400, 600), window_flags))
39     {
40         if (show_menu)
41         {
42             /* menubar */
43             enum menu_states {MENU_DEFAULT, MENU_WINDOWS}
44             static nk_size mprog = 60;
45             static int mslider = 10;
46             static int mcheck = nk_true;
47             nk_menubar_begin(ctx);
48 
49             /* menu #1 */
50             nk_layout_row_begin(ctx, NK_STATIC, 25, 5);
51             nk_layout_row_push(ctx, 45);
52             if (nk_menu_begin_label(ctx, "MENU", NK_TEXT_LEFT, nk_vec2(120, 200)))
53             {
54                 static size_t prog = 40;
55                 static int slider = 10;
56                 static int check = nk_true;
57                 nk_layout_row_dynamic(ctx, 25, 1);
58                 if (nk_menu_item_label(ctx, "Hide", NK_TEXT_LEFT))
59                     show_menu = nk_false;
60                 if (nk_menu_item_label(ctx, "About", NK_TEXT_LEFT))
61                     show_app_about = nk_true;
62                 nk_progress(ctx, &prog, 100, NK_MODIFIABLE);
63                 nk_slider_int(ctx, 0, &slider, 16, 1);
64                 nk_checkbox_label(ctx, "check", &check);
65                 nk_menu_end(ctx);
66             }
67             /* menu #2 */
68             nk_layout_row_push(ctx, 60);
69             if (nk_menu_begin_label(ctx, "ADVANCED", NK_TEXT_LEFT, nk_vec2(200, 600)))
70             {
71                 enum menu_state {MENU_NONE,MENU_FILE, MENU_EDIT,MENU_VIEW,MENU_CHART}
72                 static menu_state menu_state_ = menu_state.MENU_NONE;
73                 nk_collapse_states state;
74 
75                 state = (menu_state_ == menu_state.MENU_FILE) ? NK_MAXIMIZED: NK_MINIMIZED;
76                 if (nk_tree_state_push(ctx, NK_TREE_TAB, "FILE", &state)) {
77                     menu_state_ =menu_state. MENU_FILE;
78                     nk_menu_item_label(ctx, "New", NK_TEXT_LEFT);
79                     nk_menu_item_label(ctx, "Open", NK_TEXT_LEFT);
80                     nk_menu_item_label(ctx, "Save", NK_TEXT_LEFT);
81                     nk_menu_item_label(ctx, "Close", NK_TEXT_LEFT);
82                     nk_menu_item_label(ctx, "Exit", NK_TEXT_LEFT);
83                     nk_tree_pop(ctx);
84                 } else menu_state_ = (menu_state_ == menu_state.MENU_FILE) ? menu_state.MENU_NONE: menu_state_;
85 
86                 state = (menu_state_ == menu_state.MENU_EDIT) ? NK_MAXIMIZED: NK_MINIMIZED;
87                 if (nk_tree_state_push(ctx, NK_TREE_TAB, "EDIT", &state)) {
88                     menu_state_ = menu_state.MENU_EDIT;
89                     nk_menu_item_label(ctx, "Copy", NK_TEXT_LEFT);
90                     nk_menu_item_label(ctx, "Delete", NK_TEXT_LEFT);
91                     nk_menu_item_label(ctx, "Cut", NK_TEXT_LEFT);
92                     nk_menu_item_label(ctx, "Paste", NK_TEXT_LEFT);
93                     nk_tree_pop(ctx);
94                 } else menu_state_ = (menu_state_ == menu_state.MENU_EDIT) ? menu_state.MENU_NONE: menu_state_;
95 
96                 state = (menu_state_ == menu_state.MENU_VIEW) ? NK_MAXIMIZED: NK_MINIMIZED;
97                 if (nk_tree_state_push(ctx, NK_TREE_TAB, "VIEW", &state)) {
98                     menu_state_ = menu_state.MENU_VIEW;
99                     nk_menu_item_label(ctx, "About", NK_TEXT_LEFT);
100                     nk_menu_item_label(ctx, "Options", NK_TEXT_LEFT);
101                     nk_menu_item_label(ctx, "Customize", NK_TEXT_LEFT);
102                     nk_tree_pop(ctx);
103                 } else menu_state_ = (menu_state_ == menu_state.MENU_VIEW) ? menu_state.MENU_NONE: menu_state_;
104 
105                 state = (menu_state_ == menu_state.MENU_CHART) ? NK_MAXIMIZED: NK_MINIMIZED;
106                 if (nk_tree_state_push(ctx, NK_TREE_TAB, "CHART", &state)) {
107                     size_t i = 0;
108                     const(float)[12] values=[26.0f,13.0f,30.0f,15.0f,25.0f,10.0f,20.0f,40.0f,12.0f,8.0f,22.0f,28.0f];
109                     menu_state_ = menu_state.MENU_CHART;
110                     nk_layout_row_dynamic(ctx, 150, 1);
111                     nk_chart_begin(ctx, NK_CHART_COLUMN, cast(int)values.length, 0, 50);
112                     for (i = 0; i < values.length; ++i)
113                         nk_chart_push(ctx, values[i]);
114                     nk_chart_end(ctx);
115                     nk_tree_pop(ctx);
116                 } else menu_state_ = (menu_state_ == menu_state.MENU_CHART) ? menu_state.MENU_NONE: menu_state_;
117                 nk_menu_end(ctx);
118             }
119             /* menu widgets */
120             nk_layout_row_push(ctx, 70);
121             nk_progress(ctx, &mprog, 100, NK_MODIFIABLE);
122             nk_slider_int(ctx, 0, &mslider, 16, 1);
123             nk_checkbox_label(ctx, "check", &mcheck);
124             nk_menubar_end(ctx);
125         }
126 
127         if (show_app_about)
128         {
129             /* about popup */
130             static nk_rect s = {20, 100, 300, 190};
131             if (nk_popup_begin(ctx, NK_POPUP_STATIC, "About", NK_WINDOW_CLOSABLE, s))
132             {
133                 nk_layout_row_dynamic(ctx, 20, 1);
134                 nk_label(ctx, "Nuklear", NK_TEXT_LEFT);
135                 nk_label(ctx, "By Micha Mettke", NK_TEXT_LEFT);
136                 nk_label(ctx, "nuklear is licensed under the public domain License.",  NK_TEXT_LEFT);
137                 nk_popup_end(ctx);
138             } else show_app_about = nk_false;
139         }
140 
141         // window flags
142         if (nk_tree_push(ctx, NK_TREE_TAB, "Window", NK_MINIMIZED)) {
143             nk_layout_row_dynamic(ctx, 30, 2);
144             nk_checkbox_label(ctx, "Titlebar", &titlebar);
145             nk_checkbox_label(ctx, "Menu", &show_menu);
146             nk_checkbox_label(ctx, "Border", &border);
147             nk_checkbox_label(ctx, "Resizable", &resize);
148             nk_checkbox_label(ctx, "Movable", &movable);
149             nk_checkbox_label(ctx, "No Scrollbar", &no_scrollbar);
150             nk_checkbox_label(ctx, "Minimizable", &minimizable);
151             nk_checkbox_label(ctx, "Scale Left", &scale_left);
152             nk_tree_pop(ctx);
153         }
154 
155         if (nk_tree_push(ctx, NK_TREE_TAB, "Widgets", NK_MINIMIZED))
156         {
157             enum options {A,B,C}
158             static int checkbox;
159             static int option;
160             if (nk_tree_push(ctx, NK_TREE_NODE, "Text", NK_MINIMIZED))
161             {
162                 // Text Widgets 
163                 nk_layout_row_dynamic(ctx, 20, 1);
164                 nk_label(ctx, "Label aligned left", NK_TEXT_LEFT);
165                 nk_label(ctx, "Label aligned centered", NK_TEXT_CENTERED);
166                 nk_label(ctx, "Label aligned right", NK_TEXT_RIGHT);
167                 nk_label_colored(ctx, "Blue text", NK_TEXT_LEFT, nk_rgb(0,0,255));
168                 nk_label_colored(ctx, "Yellow text", NK_TEXT_LEFT, nk_rgb(255,255,0));
169                 nk_text(ctx, "Text without /0", 15, NK_TEXT_RIGHT);
170 
171                 nk_layout_row_static(ctx, 100, 200, 1);
172                 nk_label_wrap(ctx, "This is a very long line to hopefully get this text to be wrapped into multiple lines to show line wrapping");
173                 nk_layout_row_dynamic(ctx, 100, 1);
174                 nk_label_wrap(ctx, "This is another long text to show dynamic window changes on multiline text");
175                 nk_tree_pop(ctx);
176             }
177 
178             if (nk_tree_push(ctx, NK_TREE_NODE, "Button", NK_MINIMIZED))
179             {
180                 // Buttons Widgets
181                 nk_layout_row_static(ctx, 30, 100, 3);
182                 if (nk_button_label(ctx, "Button"))
183                     fprintf(stdout, "Button pressed!\n");
184                 nk_button_set_behavior(ctx, NK_BUTTON_REPEATER);
185                 if (nk_button_label(ctx, "Repeater"))
186                     fprintf(stdout, "Repeater is being pressed!\n");
187                 nk_button_set_behavior(ctx, NK_BUTTON_DEFAULT);
188                 nk_button_color(ctx, nk_rgb(0,0,255));
189 
190                 nk_layout_row_static(ctx, 25, 25, 8);
191                 nk_button_symbol(ctx, NK_SYMBOL_CIRCLE_SOLID);
192                 nk_button_symbol(ctx, NK_SYMBOL_CIRCLE_OUTLINE);
193                 nk_button_symbol(ctx, NK_SYMBOL_RECT_SOLID);
194                 nk_button_symbol(ctx, NK_SYMBOL_RECT_OUTLINE);
195                 nk_button_symbol(ctx, NK_SYMBOL_TRIANGLE_UP);
196                 nk_button_symbol(ctx, NK_SYMBOL_TRIANGLE_DOWN);
197                 nk_button_symbol(ctx, NK_SYMBOL_TRIANGLE_LEFT);
198                 nk_button_symbol(ctx, NK_SYMBOL_TRIANGLE_RIGHT);
199 
200                 nk_layout_row_static(ctx, 30, 100, 2);
201                 nk_button_symbol_label(ctx, NK_SYMBOL_TRIANGLE_LEFT, "prev", NK_TEXT_RIGHT);
202                 nk_button_symbol_label(ctx, NK_SYMBOL_TRIANGLE_RIGHT, "next", NK_TEXT_LEFT);
203                 nk_tree_pop(ctx);
204             }
205 
206             if (nk_tree_push(ctx, NK_TREE_NODE, "Basic", NK_MINIMIZED))
207             {
208                 // Basic widgets 
209                 static int int_slider = 5;
210                 static float float_slider = 2.5f;
211                 static size_t prog_value = 40;
212                 static float property_float = 2;
213                 static int property_int = 10;
214                 static int property_neg = 10;
215 
216                 static float range_float_min = 0;
217                 static float range_float_max = 100;
218                 static float range_float_value = 50;
219                 static int range_int_min = 0;
220                 static int range_int_value = 2048;
221                 static int range_int_max = 4096;
222                 static const(float)[2] ratio = [120, 150];
223 
224                 nk_layout_row_static(ctx, 30, 100, 1);
225                 nk_checkbox_label(ctx, "Checkbox", &checkbox);
226 
227                 nk_layout_row_static(ctx, 30, 80, 3);
228                 option = nk_option_label(ctx, "optionA", option == options.A) ? options.A : option;
229                 option = nk_option_label(ctx, "optionB", option == options.B) ? options.B : option;
230                 option = nk_option_label(ctx, "optionC", option == options.C) ? options.C : option;
231 
232                 nk_layout_row(ctx, NK_STATIC, 30, 2, ratio.ptr);
233                 nk_labelf(ctx, NK_TEXT_LEFT, "Slider int");
234                 nk_slider_int(ctx, 0, &int_slider, 10, 1);
235 
236                 nk_label(ctx, "Slider float", NK_TEXT_LEFT);
237                 nk_slider_float(ctx, 0, &float_slider, 5.0, 0.5f);
238                 nk_labelf(ctx, NK_TEXT_LEFT, "Progressbar: %zu" , prog_value);
239                 nk_progress(ctx, &prog_value, 100, NK_MODIFIABLE);
240 
241                 nk_layout_row(ctx, NK_STATIC, 25, 2, ratio.ptr);
242                 nk_label(ctx, "Property float:", NK_TEXT_LEFT);
243                 nk_property_float(ctx, "Float:", 0, &property_float, 64.0f, 0.1f, 0.2f);
244                 nk_label(ctx, "Property int:", NK_TEXT_LEFT);
245                 nk_property_int(ctx, "Int:", 0, &property_int, 100, 1, 1);
246                 nk_label(ctx, "Property neg:", NK_TEXT_LEFT);
247                 nk_property_int(ctx, "Neg:", -10, &property_neg, 10, 1, 1);
248 
249                 nk_layout_row_dynamic(ctx, 25, 1);
250                 nk_label(ctx, "Range:", NK_TEXT_LEFT);
251                 nk_layout_row_dynamic(ctx, 25, 3);
252                 nk_property_float(ctx, "#min:", 0, &range_float_min, range_float_max, 1.0f, 0.2f);
253                 nk_property_float(ctx, "#float:", range_float_min, &range_float_value, range_float_max, 1.0f, 0.2f);
254                 nk_property_float(ctx, "#max:", range_float_min, &range_float_max, 100, 1.0f, 0.2f);
255 
256                 nk_property_int(ctx, "#min:", int.min, &range_int_min, range_int_max, 1, 10);
257                 nk_property_int(ctx, "#neg:", range_int_min, &range_int_value, range_int_max, 1, 10);
258                 nk_property_int(ctx, "#max:", range_int_min, &range_int_max, int.max, 1, 10);
259 
260                 nk_tree_pop(ctx);
261             }
262 
263             if (nk_tree_push(ctx, NK_TREE_NODE, "Inactive", NK_MINIMIZED))
264             {
265                 static int inactive = 1;
266                 nk_layout_row_dynamic(ctx, 30, 1);
267                 nk_checkbox_label(ctx, "Inactive", &inactive);
268 
269                 nk_layout_row_static(ctx, 30, 80, 1);
270                 if (inactive) {
271                     nk_style_button button;
272                     button = ctx.style.button;
273                     ctx.style.button.normal = nk_style_item_color(nk_rgb(40,40,40));
274                     ctx.style.button.hover = nk_style_item_color(nk_rgb(40,40,40));
275                     ctx.style.button.active = nk_style_item_color(nk_rgb(40,40,40));
276                     ctx.style.button.border_color = nk_rgb(60,60,60);
277                     ctx.style.button.text_background = nk_rgb(60,60,60);
278                     ctx.style.button.text_normal = nk_rgb(60,60,60);
279                     ctx.style.button.text_hover = nk_rgb(60,60,60);
280                     ctx.style.button.text_active = nk_rgb(60,60,60);
281                     nk_button_label(ctx, "button");
282                     ctx.style.button = button;
283                 } else if (nk_button_label(ctx, "button"))
284                     fprintf(stdout, "button pressed\n");
285                 nk_tree_pop(ctx);
286             }
287 
288 
289             if (nk_tree_push(ctx, NK_TREE_NODE, "Selectable", NK_MINIMIZED))
290             {
291                 if (nk_tree_push(ctx, NK_TREE_NODE, "List", NK_MINIMIZED))
292                 {
293                     static int[4] selected = [nk_false, nk_false, nk_true, nk_false];
294                     nk_layout_row_static(ctx, 18, 100, 1);
295                     nk_selectable_label(ctx, "Selectable", NK_TEXT_LEFT, &selected[0]);
296                     nk_selectable_label(ctx, "Selectable", NK_TEXT_LEFT, &selected[1]);
297                     nk_label(ctx, "Not Selectable", NK_TEXT_LEFT);
298                     nk_selectable_label(ctx, "Selectable", NK_TEXT_LEFT, &selected[2]);
299                     nk_selectable_label(ctx, "Selectable", NK_TEXT_LEFT, &selected[3]);
300                     nk_tree_pop(ctx);
301                 }
302                 if (nk_tree_push(ctx, NK_TREE_NODE, "Grid", NK_MINIMIZED))
303                 {
304                     int i;
305                     static int[16] selected2 = [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1];
306                     nk_layout_row_static(ctx, 50, 50, 4);
307                     for (i = 0; i < 16; ++i) {
308                         if (nk_selectable_label(ctx, "Z", NK_TEXT_CENTERED, &selected2[i])) {
309                             int x = (i % 4), y = i / 4;
310                             if (x > 0) selected2[i - 1] ^= 1;
311                             if (x < 3) selected2[i + 1] ^= 1;
312                             if (y > 0) selected2[i - 4] ^= 1;
313                             if (y < 3) selected2[i + 4] ^= 1;
314                         }
315                     }
316                     nk_tree_pop(ctx);
317                 }
318                 nk_tree_pop(ctx);
319             }
320 
321             if (nk_tree_push(ctx, NK_TREE_NODE, "Combo", NK_MINIMIZED))
322             {
323                 /* Combobox Widgets
324                 * In this library comboboxes are not limited to being a popup
325                 * list of selectable text. Instead it is a abstract concept of
326                 * having something that is *selected* or displayed, a popup window
327                 * which opens if something needs to be modified and the content
328                 * of the popup which causes the *selected* or displayed value to
329                 * change or if wanted close the combobox.
330                 *
331                 * While strange at first handling comboboxes in a abstract way
332                 * solves the problem of overloaded window content. For example
333                 * changing a color value requires 4 value modifier (slider, property,...)
334                 * for RGBA then you need a label and ways to display the current color.
335                 * If you want to go fancy you even add rgb and hsv ratio boxes.
336                 * While fine for one color if you have a lot of them it because
337                 * tedious to look at and quite wasteful in space. You could add
338                 * a popup which modifies the color but this does not solve the
339                 * fact that it still requires a lot of cluttered space to do.
340                 *
341                 * In these kind of instance abstract comboboxes are quite handy. All
342                 * value modifiers are hidden inside the combobox popup and only
343                 * the color is shown if not open. This combines the clarity of the
344                 * popup with the ease of use of just using the space for modifiers.
345                 *
346                 * Other instances are for example time and especially date picker,
347                 * which only show the currently activated time/data and hide the
348                 * selection logic inside the combobox popup.*/
349 
350                 static float chart_selection = 8.0f;
351                 static int current_weapon = 0;
352                 static int[5] check_values;
353                 static float[3] position;
354                 static nk_color combo_color = {130, 50, 50, 255};
355                 static nk_colorf combo_color2 = {0.509f, 0.705f, 0.2f, 1.0f};
356                 static size_t prog_a =  20, prog_b = 40, prog_c = 10, prog_d = 90;
357                 static const(char)*[5] weapons = ["Fist","Pistol","Shotgun","Plasma","BFG"];
358 
359                 char[64] buffer;
360                 size_t sum = 0;
361 
362                 // default combobox 
363                 nk_layout_row_static(ctx, 25, 200, 1);
364                 current_weapon = nk_combo(ctx, weapons.ptr, cast(int)weapons.length, current_weapon, 25, nk_vec2(200,200));
365 
366                 // slider color combobox 
367                 if (nk_combo_begin_color(ctx, combo_color, nk_vec2(200,200))) {
368                     float[2] ratios = [0.15f, 0.85f];
369                     nk_layout_row(ctx, NK_DYNAMIC, 30, 2, ratios.ptr);
370                     nk_label(ctx, "R:", NK_TEXT_LEFT);
371                     combo_color.r = cast(nk_byte)nk_slide_int(ctx, 0, combo_color.r, 255, 5);
372                     nk_label(ctx, "G:", NK_TEXT_LEFT);
373                     combo_color.g = cast(nk_byte)nk_slide_int(ctx, 0, combo_color.g, 255, 5);
374                     nk_label(ctx, "B:", NK_TEXT_LEFT);
375                     combo_color.b = cast(nk_byte)nk_slide_int(ctx, 0, combo_color.b, 255, 5);
376                     nk_label(ctx, "A:", NK_TEXT_LEFT);
377                     combo_color.a = cast(nk_byte)nk_slide_int(ctx, 0, combo_color.a , 255, 5);
378                     nk_combo_end(ctx);
379                 }
380                 // complex color combobox 
381                 if (nk_combo_begin_color(ctx, nk_rgb_cf(combo_color2), nk_vec2(200,400))) {
382                     enum color_mode {COL_RGB, COL_HSV}
383                     static int col_mode = color_mode.COL_RGB;
384                     //#ifndef DEMO_DO_NOT_USE_COLOR_PICKER
385                     nk_layout_row_dynamic(ctx, 120, 1);
386                     combo_color2 = nk_color_picker(ctx, combo_color2, NK_RGBA);
387                     //#endif
388 
389                     nk_layout_row_dynamic(ctx, 25, 2);
390                     col_mode = nk_option_label(ctx, "RGB", col_mode == color_mode.COL_RGB) ? color_mode.COL_RGB : col_mode;
391                     col_mode = nk_option_label(ctx, "HSV", col_mode == color_mode.COL_HSV) ? color_mode.COL_HSV : col_mode;
392 
393                     nk_layout_row_dynamic(ctx, 25, 1);
394                     if (col_mode == color_mode.COL_RGB) {
395                         combo_color2.r = nk_propertyf(ctx, "#R:", 0, combo_color2.r, 1.0f, 0.01f,0.005f);
396                         combo_color2.g = nk_propertyf(ctx, "#G:", 0, combo_color2.g, 1.0f, 0.01f,0.005f);
397                         combo_color2.b = nk_propertyf(ctx, "#B:", 0, combo_color2.b, 1.0f, 0.01f,0.005f);
398                         combo_color2.a = nk_propertyf(ctx, "#A:", 0, combo_color2.a, 1.0f, 0.01f,0.005f);
399                     } else {
400                         float[4] hsva;
401                         nk_colorf_hsva_fv(hsva.ptr, combo_color2);
402                         hsva[0] = nk_propertyf(ctx, "#H:", 0, hsva[0], 1.0f, 0.01f,0.05f);
403                         hsva[1] = nk_propertyf(ctx, "#S:", 0, hsva[1], 1.0f, 0.01f,0.05f);
404                         hsva[2] = nk_propertyf(ctx, "#V:", 0, hsva[2], 1.0f, 0.01f,0.05f);
405                         hsva[3] = nk_propertyf(ctx, "#A:", 0, hsva[3], 1.0f, 0.01f,0.05f);
406                         combo_color2 = nk_hsva_colorfv(hsva.ptr);
407                     }
408                     nk_combo_end(ctx);
409                 }
410                 // progressbar combobox
411                 sum = prog_a + prog_b + prog_c + prog_d;
412                 sprintf(buffer.ptr, "%lu", sum);
413                 if (nk_combo_begin_label(ctx, buffer.ptr, nk_vec2(200,200))) {
414                     nk_layout_row_dynamic(ctx, 30, 1);
415                     nk_progress(ctx, &prog_a, 100, NK_MODIFIABLE);
416                     nk_progress(ctx, &prog_b, 100, NK_MODIFIABLE);
417                     nk_progress(ctx, &prog_c, 100, NK_MODIFIABLE);
418                     nk_progress(ctx, &prog_d, 100, NK_MODIFIABLE);
419                     nk_combo_end(ctx);
420                 }
421 
422                 // checkbox combobox 
423                 sum = cast(size_t)(check_values[0] + check_values[1] + check_values[2] + check_values[3] + check_values[4]);
424                 sprintf(buffer.ptr, "%lu", sum);
425                 if (nk_combo_begin_label(ctx, buffer.ptr, nk_vec2(200,200))) {
426                     nk_layout_row_dynamic(ctx, 30, 1);
427                     nk_checkbox_label(ctx, weapons[0], &check_values[0]);
428                     nk_checkbox_label(ctx, weapons[1], &check_values[1]);
429                     nk_checkbox_label(ctx, weapons[2], &check_values[2]);
430                     nk_checkbox_label(ctx, weapons[3], &check_values[3]);
431                     nk_combo_end(ctx);
432                 }
433 
434                 // complex text combobox 
435                 sprintf(buffer.ptr, "%.2f, %.2f, %.2f", position[0], position[1],position[2]);
436                 if (nk_combo_begin_label(ctx, buffer.ptr, nk_vec2(200,200))) {
437                     nk_layout_row_dynamic(ctx, 25, 1);
438                     nk_property_float(ctx, "#X:", -1024.0f, &position[0], 1024.0f, 1,0.5f);
439                     nk_property_float(ctx, "#Y:", -1024.0f, &position[1], 1024.0f, 1,0.5f);
440                     nk_property_float(ctx, "#Z:", -1024.0f, &position[2], 1024.0f, 1,0.5f);
441                     nk_combo_end(ctx);
442                 }
443 
444                 // chart combobox
445                 sprintf(buffer.ptr, "%.1f", chart_selection);
446                 if (nk_combo_begin_label(ctx, buffer.ptr, nk_vec2(200,250))) {
447                     size_t i = 0;
448                     static const(float)[13] values=[26.0f,13.0f,30.0f,15.0f,25.0f,10.0f,20.0f,40.0f, 12.0f, 8.0f, 22.0f, 28.0f, 5.0f];
449                     nk_layout_row_dynamic(ctx, 150, 1);
450                     nk_chart_begin(ctx, NK_CHART_COLUMN, cast(int)values.length, 0, 50);
451                     for (i = 0; i < values.length; ++i) {
452                         nk_flags res = nk_chart_push(ctx, values[i]);
453                         if (res & NK_CHART_CLICKED) {
454                             chart_selection = values[i];
455                             nk_combo_close(ctx);
456                         }
457                     }
458                     nk_chart_end(ctx);
459                     nk_combo_end(ctx);
460                 }
461                 nk_tree_pop(ctx);
462             }
463 
464             if (nk_tree_push(ctx, NK_TREE_NODE, "Input", NK_MINIMIZED))
465             {
466                 static const(float)[2] ratio2 = [120, 150];
467                 static char[64] field_buffer;
468                 static char[9][64] text;
469                 static int[9] text_len;
470                 static char[512] box_buffer;
471                 static int field_len;
472                 static int box_len;
473                 nk_flags active;
474 
475                 nk_layout_row(ctx, NK_STATIC, 25, 2, ratio2.ptr);
476                 nk_label(ctx, "Default:", NK_TEXT_LEFT);
477 
478                 nk_edit_string(ctx, NK_EDIT_SIMPLE, text[0].ptr, &text_len[0], 64, nk_filter_default_fptr);
479                 nk_label(ctx, "Int:", NK_TEXT_LEFT);
480                 nk_edit_string(ctx, NK_EDIT_SIMPLE, text[1].ptr, &text_len[1], 64, nk_filter_decimal_fptr);
481                 nk_label(ctx, "Float:", NK_TEXT_LEFT);
482                 nk_edit_string(ctx, NK_EDIT_SIMPLE, text[2].ptr, &text_len[2], 64, nk_filter_float_fptr);
483                 nk_label(ctx, "Hex:", NK_TEXT_LEFT);
484                 nk_edit_string(ctx, NK_EDIT_SIMPLE, text[4].ptr, &text_len[4], 64, nk_filter_hex_fptr);
485                 nk_label(ctx, "Octal:", NK_TEXT_LEFT);
486                 nk_edit_string(ctx, NK_EDIT_SIMPLE, text[5].ptr, &text_len[5], 64, nk_filter_oct_fptr);
487                 nk_label(ctx, "Binary:", NK_TEXT_LEFT);
488                 nk_edit_string(ctx, NK_EDIT_SIMPLE, text[6].ptr, &text_len[6], 64, nk_filter_binary_fptr);
489 
490                 nk_label(ctx, "Password:", NK_TEXT_LEFT);
491                 {
492                     int i = 0;
493                     int old_len = text_len[8];
494                     char[64] buffer;
495                     for (i = 0; i < text_len[8]; ++i) buffer[i] = '*';
496                     nk_edit_string(ctx, NK_EDIT_FIELD, buffer.ptr, &text_len[8], 64, nk_filter_default_fptr);
497                     if (old_len < text_len[8])
498                         memcpy(&text[8][old_len], &buffer[old_len], cast(nk_size)(text_len[8] - old_len));
499                 }
500 
501                 nk_label(ctx, "Field:", NK_TEXT_LEFT);
502                 nk_edit_string(ctx, NK_EDIT_FIELD, field_buffer.ptr, &field_len, 64, nk_filter_default_fptr);
503 
504                 nk_label(ctx, "Box:", NK_TEXT_LEFT);
505                 nk_layout_row_static(ctx, 180, 278, 1);
506                 nk_edit_string(ctx, NK_EDIT_BOX, box_buffer.ptr, &box_len, 512, nk_filter_default_fptr);
507 
508                 nk_layout_row(ctx, NK_STATIC, 25, 2, ratio2.ptr);
509                 active = nk_edit_string(ctx, NK_EDIT_FIELD|NK_EDIT_SIG_ENTER, text[7].ptr, &text_len[7], 64,  nk_filter_ascii_fptr);
510                 if (nk_button_label(ctx, "Submit") ||
511                     (active & NK_EDIT_COMMITED))
512                 {
513                     text[7][text_len[7]] = '\n';
514                     text_len[7]++;
515                     memcpy(&box_buffer[box_len], &text[7], cast(nk_size)text_len[7]);
516                     box_len += text_len[7];
517                     text_len[7] = 0;
518                 }
519                 nk_tree_pop(ctx);
520             }
521 
522             nk_tree_pop(ctx);
523         }
524 
525 
526 
527         if (nk_tree_push(ctx, NK_TREE_TAB, "Chart", NK_MINIMIZED))
528         {
529             /* Chart Widgets
530             * This library has two different rather simple charts. The line and the
531             * column chart. Both provide a simple way of visualizing values and
532             * have a retained mode and immediate mode API version. For the retain
533             * mode version `nk_plot` and `nk_plot_function` you either provide
534             * an array or a callback to call to handle drawing the graph.
535             * For the immediate mode version you start by calling `nk_chart_begin`
536             * and need to provide min and max values for scaling on the Y-axis.
537             * and then call `nk_chart_push` to push values into the chart.
538             * Finally `nk_chart_end` needs to be called to end the process.*/
539             float id = 0;
540             static int col_index = -1;
541             static int line_index = -1;
542             float step = (2*3.141592654f) / 32;
543 
544             int i;
545             int index = -1;
546             nk_rect bounds;
547 
548             // line chart
549             id = 0;
550             index = -1;
551             nk_layout_row_dynamic(ctx, 100, 1);
552             bounds = nk_widget_bounds(ctx);
553             if (nk_chart_begin(ctx, NK_CHART_LINES, 32, -1.0f, 1.0f)) {
554                 for (i = 0; i < 32; ++i) {
555                     nk_flags res = nk_chart_push(ctx, cast(float)cos(id));
556                     if (res & NK_CHART_HOVERING)
557                         index = cast(int)i;
558                     if (res & NK_CHART_CLICKED)
559                         line_index = cast(int)i;
560                     id += step;
561                 }
562                 nk_chart_end(ctx);
563             }
564 
565             if (index != -1)
566                 nk_tooltipf(ctx, "Value: %.2f", cast(float)cos(cast(float)index*step));
567             if (line_index != -1) {
568                 nk_layout_row_dynamic(ctx, 20, 1);
569                 nk_labelf(ctx, NK_TEXT_LEFT, "Selected value: %.2f",cast(float)cos(cast(float)index*step));
570             }
571 
572             // column chart
573             nk_layout_row_dynamic(ctx, 100, 1);
574             bounds = nk_widget_bounds(ctx);
575             if (nk_chart_begin(ctx, NK_CHART_COLUMN, 32, 0.0f, 1.0f)) {
576                 for (i = 0; i < 32; ++i) {
577                     nk_flags res = nk_chart_push(ctx, cast(float)fabs(sin(id)));
578                     if (res & NK_CHART_HOVERING)
579                         index = cast(int)i;
580                     if (res & NK_CHART_CLICKED)
581                         col_index = cast(int)i;
582                     id += step;
583                 }
584                 nk_chart_end(ctx);
585             }
586             if (index != -1)
587                 nk_tooltipf(ctx, "Value: %.2f", cast(float)fabs(sin(step * cast(float)index)));
588             if (col_index != -1) {
589                 nk_layout_row_dynamic(ctx, 20, 1);
590                 nk_labelf(ctx, NK_TEXT_LEFT, "Selected value: %.2f", cast(float)fabs(sin(step * cast(float)col_index)));
591             }
592 
593             // mixed chart
594             nk_layout_row_dynamic(ctx, 100, 1);
595             bounds = nk_widget_bounds(ctx);
596             if (nk_chart_begin(ctx, NK_CHART_COLUMN, 32, 0.0f, 1.0f)) {
597                 nk_chart_add_slot(ctx, NK_CHART_LINES, 32, -1.0f, 1.0f);
598                 nk_chart_add_slot(ctx, NK_CHART_LINES, 32, -1.0f, 1.0f);
599                 for (id = 0, i = 0; i < 32; ++i) {
600                     nk_chart_push_slot(ctx,cast (float)fabs(sin(id)), 0);
601                     nk_chart_push_slot(ctx, cast(float)cos(id), 1);
602                     nk_chart_push_slot(ctx, cast(float)sin(id), 2);
603                     id += step;
604                 }
605             }
606             nk_chart_end(ctx);
607 
608             //* mixed colored chart
609             nk_layout_row_dynamic(ctx, 100, 1);
610             bounds = nk_widget_bounds(ctx);
611             if (nk_chart_begin_colored(ctx, NK_CHART_LINES, nk_rgb(255,0,0), nk_rgb(150,0,0), 32, 0.0f, 1.0f)) {
612                 nk_chart_add_slot_colored(ctx, NK_CHART_LINES, nk_rgb(0,0,255), nk_rgb(0,0,150),32, -1.0f, 1.0f);
613                 nk_chart_add_slot_colored(ctx, NK_CHART_LINES, nk_rgb(0,255,0), nk_rgb(0,150,0), 32, -1.0f, 1.0f);
614                 for (id = 0, i = 0; i < 32; ++i) {
615                     nk_chart_push_slot(ctx, cast(float)fabs(sin(id)), 0);
616                     nk_chart_push_slot(ctx, cast(float)cos(id), 1);
617                     nk_chart_push_slot(ctx, cast(float)sin(id), 2);
618                     id += step;
619                 }
620             }
621             nk_chart_end(ctx);
622             nk_tree_pop(ctx);
623         }
624 
625         if (nk_tree_push(ctx, NK_TREE_TAB, "Popup", NK_MINIMIZED))
626         {
627             static nk_color color = {255,0,0, 255};
628             static int[4] select;
629             static int popup_active;
630             const(nk_input) *in_ = &ctx.input;
631             nk_rect bounds;
632 
633             //* menu contextual
634             nk_layout_row_static(ctx, 30, 160, 1);
635             bounds = nk_widget_bounds(ctx);
636             nk_label(ctx, "Right click me for menu", NK_TEXT_LEFT);
637 
638             if (nk_contextual_begin(ctx, 0, nk_vec2(100, 300), bounds)) {
639                 static size_t prog2 = 40;
640                 static int slider2 = 10;
641 
642                 nk_layout_row_dynamic(ctx, 25, 1);
643                 nk_checkbox_label(ctx, "Menu", &show_menu);
644                 nk_progress(ctx, &prog2, 100, NK_MODIFIABLE);
645                 nk_slider_int(ctx, 0, &slider2, 16, 1);
646                 if (nk_contextual_item_label(ctx, "About", NK_TEXT_CENTERED))
647                     show_app_about = nk_true;
648                 nk_selectable_label(ctx, select[0]?"Unselect":"Select", NK_TEXT_LEFT, &select[0]);
649                 nk_selectable_label(ctx, select[1]?"Unselect":"Select", NK_TEXT_LEFT, &select[1]);
650                 nk_selectable_label(ctx, select[2]?"Unselect":"Select", NK_TEXT_LEFT, &select[2]);
651                 nk_selectable_label(ctx, select[3]?"Unselect":"Select", NK_TEXT_LEFT, &select[3]);
652                 nk_contextual_end(ctx);
653             }
654 
655             //* color contextual
656             nk_layout_row_begin(ctx, NK_STATIC, 30, 2);
657             nk_layout_row_push(ctx, 100);
658             nk_label(ctx, "Right Click here:", NK_TEXT_LEFT);
659             nk_layout_row_push(ctx, 50);
660             bounds = nk_widget_bounds(ctx);
661             nk_button_color(ctx, color);
662             nk_layout_row_end(ctx);
663 
664             if (nk_contextual_begin(ctx, 0, nk_vec2(350, 60), bounds)) {
665                 nk_layout_row_dynamic(ctx, 30, 4);
666                 color.r = cast(nk_byte)nk_propertyi(ctx, "#r", 0, color.r, 255, 1, 1);
667                 color.g = cast(nk_byte)nk_propertyi(ctx, "#g", 0, color.g, 255, 1, 1);
668                 color.b = cast(nk_byte)nk_propertyi(ctx, "#b", 0, color.b, 255, 1, 1);
669                 color.a = cast(nk_byte)nk_propertyi(ctx, "#a", 0, color.a, 255, 1, 1);
670                 nk_contextual_end(ctx);
671             }
672 
673             //* popup
674             nk_layout_row_begin(ctx, NK_STATIC, 30, 2);
675             nk_layout_row_push(ctx, 100);
676             nk_label(ctx, "Popup:", NK_TEXT_LEFT);
677             nk_layout_row_push(ctx, 50);
678             if (nk_button_label(ctx, "Popup"))
679                 popup_active = 1;
680             nk_layout_row_end(ctx);
681 
682             if (popup_active)
683             {
684                 static nk_rect s2 = {20, 100, 220, 90};
685                 if (nk_popup_begin(ctx, NK_POPUP_STATIC, "Error", 0, s2))
686                 {
687                     nk_layout_row_dynamic(ctx, 25, 1);
688                     nk_label(ctx, "A terrible error as occured", NK_TEXT_LEFT);
689                     nk_layout_row_dynamic(ctx, 25, 2);
690                     if (nk_button_label(ctx, "OK")) {
691                         popup_active = 0;
692                         nk_popup_close(ctx);
693                     }
694                     if (nk_button_label(ctx, "Cancel")) {
695                         popup_active = 0;
696                         nk_popup_close(ctx);
697                     }
698                     nk_popup_end(ctx);
699                 } else popup_active = nk_false;
700             }
701 
702             //* tooltip
703             nk_layout_row_static(ctx, 30, 150, 1);
704             bounds = nk_widget_bounds(ctx);
705             nk_label(ctx, "Hover me for tooltip", NK_TEXT_LEFT);
706             if (nk_input_is_mouse_hovering_rect(in_, bounds))
707                 nk_tooltip(ctx, "This is a tooltip");
708 
709             nk_tree_pop(ctx);
710         }
711 
712         if (nk_tree_push(ctx, NK_TREE_TAB, "Layout", NK_MINIMIZED))
713         {
714             if (nk_tree_push(ctx, NK_TREE_NODE, "Widget", NK_MINIMIZED))
715             {
716                 float[3] ratio_two = [0.2f, 0.6f, 0.2f];
717                 float[3] width_two = [100, 200, 50];
718 
719                 nk_layout_row_dynamic(ctx, 30, 1);
720                 nk_label(ctx, "Dynamic fixed column layout with generated position and size:", NK_TEXT_LEFT);
721                 nk_layout_row_dynamic(ctx, 30, 3);
722                 nk_button_label(ctx, "button");
723                 nk_button_label(ctx, "button");
724                 nk_button_label(ctx, "button");
725 
726                 nk_layout_row_dynamic(ctx, 30, 1);
727                 nk_label(ctx, "static fixed column layout with generated position and size:", NK_TEXT_LEFT);
728                 nk_layout_row_static(ctx, 30, 100, 3);
729                 nk_button_label(ctx, "button");
730                 nk_button_label(ctx, "button");
731                 nk_button_label(ctx, "button");
732 
733                 nk_layout_row_dynamic(ctx, 30, 1);
734                 nk_label(ctx, "Dynamic array-based custom column layout with generated position and custom size:",NK_TEXT_LEFT);
735                 nk_layout_row(ctx, NK_DYNAMIC, 30, 3, ratio_two.ptr);
736                 nk_button_label(ctx, "button");
737                 nk_button_label(ctx, "button");
738                 nk_button_label(ctx, "button");
739 
740                 nk_layout_row_dynamic(ctx, 30, 1);
741                 nk_label(ctx, "Static array-based custom column layout with generated position and custom size:",NK_TEXT_LEFT );
742                 nk_layout_row(ctx, NK_STATIC, 30, 3, width_two.ptr);
743                 nk_button_label(ctx, "button");
744                 nk_button_label(ctx, "button");
745                 nk_button_label(ctx, "button");
746 
747                 nk_layout_row_dynamic(ctx, 30, 1);
748                 nk_label(ctx, "Dynamic immediate mode custom column layout with generated position and custom size:",NK_TEXT_LEFT);
749                 nk_layout_row_begin(ctx, NK_DYNAMIC, 30, 3);
750                 nk_layout_row_push(ctx, 0.2f);
751                 nk_button_label(ctx, "button");
752                 nk_layout_row_push(ctx, 0.6f);
753                 nk_button_label(ctx, "button");
754                 nk_layout_row_push(ctx, 0.2f);
755                 nk_button_label(ctx, "button");
756                 nk_layout_row_end(ctx);
757 
758                 nk_layout_row_dynamic(ctx, 30, 1);
759                 nk_label(ctx, "Static immediate mode custom column layout with generated position and custom size:", NK_TEXT_LEFT);
760                 nk_layout_row_begin(ctx, NK_STATIC, 30, 3);
761                 nk_layout_row_push(ctx, 100);
762                 nk_button_label(ctx, "button");
763                 nk_layout_row_push(ctx, 200);
764                 nk_button_label(ctx, "button");
765                 nk_layout_row_push(ctx, 50);
766                 nk_button_label(ctx, "button");
767                 nk_layout_row_end(ctx);
768 
769                 nk_layout_row_dynamic(ctx, 30, 1);
770                 nk_label(ctx, "Static free space with custom position and custom size:", NK_TEXT_LEFT);
771                 nk_layout_space_begin(ctx, NK_STATIC, 60, 4);
772                 nk_layout_space_push(ctx, nk_rect(100, 0, 100, 30));
773                 nk_button_label(ctx, "button");
774                 nk_layout_space_push(ctx, nk_rect(0, 15, 100, 30));
775                 nk_button_label(ctx, "button");
776                 nk_layout_space_push(ctx, nk_rect(200, 15, 100, 30));
777                 nk_button_label(ctx, "button");
778                 nk_layout_space_push(ctx, nk_rect(100, 30, 100, 30));
779                 nk_button_label(ctx, "button");
780                 nk_layout_space_end(ctx);
781 
782                 nk_layout_row_dynamic(ctx, 30, 1);
783                 nk_label(ctx, "Row template:", NK_TEXT_LEFT);
784                 nk_layout_row_template_begin(ctx, 30);
785                 nk_layout_row_template_push_dynamic(ctx);
786                 nk_layout_row_template_push_variable(ctx, 80);
787                 nk_layout_row_template_push_static(ctx, 80);
788                 nk_layout_row_template_end(ctx);
789                 nk_button_label(ctx, "button");
790                 nk_button_label(ctx, "button");
791                 nk_button_label(ctx, "button");
792 
793                 nk_tree_pop(ctx);
794             }
795 
796             if (nk_tree_push(ctx, NK_TREE_NODE, "Group", NK_MINIMIZED))
797             {
798                 static int group_titlebar = nk_false;
799                 static int group_border = nk_true;
800                 static int group_no_scrollbar = nk_false;
801                 static int group_width = 320;
802                 static int group_height = 200;
803 
804                 nk_flags group_flags = 0;
805                 if (group_border) group_flags |= NK_WINDOW_BORDER;
806                 if (group_no_scrollbar) group_flags |= NK_WINDOW_NO_SCROLLBAR;
807                 if (group_titlebar) group_flags |= NK_WINDOW_TITLE;
808 
809                 nk_layout_row_dynamic(ctx, 30, 3);
810                 nk_checkbox_label(ctx, "Titlebar", &group_titlebar);
811                 nk_checkbox_label(ctx, "Border", &group_border);
812                 nk_checkbox_label(ctx, "No Scrollbar", &group_no_scrollbar);
813 
814                 nk_layout_row_begin(ctx, NK_STATIC, 22, 3);
815                 nk_layout_row_push(ctx, 50);
816                 nk_label(ctx, "size:", NK_TEXT_LEFT);
817                 nk_layout_row_push(ctx, 130);
818                 nk_property_int(ctx, "#Width:", 100, &group_width, 500, 10, 1);
819                 nk_layout_row_push(ctx, 130);
820                 nk_property_int(ctx, "#Height:", 100, &group_height, 500, 10, 1);
821                 nk_layout_row_end(ctx);
822 
823                 nk_layout_row_static(ctx, cast(float)group_height, group_width, 2);
824                 if (nk_group_begin(ctx, "Group", group_flags)) {
825                     int i = 0;
826                     static int[16] selected3;
827                     nk_layout_row_static(ctx, 18, 100, 1);
828                     for (i = 0; i < 16; ++i)
829                         nk_selectable_label(ctx, (selected3[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected3[i]);
830                     nk_group_end(ctx);
831                 }
832                 nk_tree_pop(ctx);
833             }
834             if (nk_tree_push(ctx, NK_TREE_NODE, "Tree", NK_MINIMIZED))
835             {
836                 static int root_selected = 0;
837                 int sel = root_selected;
838 
839                 if (nk_tree_element_push(ctx, NK_TREE_NODE, "Root", NK_MINIMIZED, &sel)) {
840                     static int[8] selected0;
841                     int i = 0, node_select = selected0[0];
842                     if (sel != root_selected) {
843                         root_selected = sel;
844                         for (i = 0; i < 8; ++i)
845                             selected0[i] = sel;
846                     }
847                     if (nk_tree_element_push(ctx, NK_TREE_NODE, "Node", NK_MINIMIZED, &node_select)) {
848                         int j = 0;
849                         static int[4] sel_nodes;
850                         if (node_select != selected0[0]) {
851                             selected0[0] = node_select;
852                             for (i = 0; i < 4; ++i)
853                                 sel_nodes[i] = node_select;
854                         }
855                         nk_layout_row_static(ctx, 18, 100, 1);
856                         for (j = 0; j < 4; ++j)
857                             nk_selectable_symbol_label(ctx, NK_SYMBOL_CIRCLE_SOLID, (sel_nodes[j]) ? "Selected": "Unselected", NK_TEXT_RIGHT, &sel_nodes[j]);
858                         nk_tree_element_pop(ctx);
859                     }
860                     nk_layout_row_static(ctx, 18, 100, 1);
861                     for (i = 1; i < 8; ++i)
862                         nk_selectable_symbol_label(ctx, NK_SYMBOL_CIRCLE_SOLID, (selected0[i]) ? "Selected": "Unselected", NK_TEXT_RIGHT, &selected0[i]);
863                     nk_tree_element_pop(ctx);
864                 }
865                 nk_tree_pop(ctx);
866 
867             }
868             if (nk_tree_push(ctx, NK_TREE_NODE, "Notebook", NK_MINIMIZED))
869             {
870                 static int current_tab = 0;
871                 nk_rect bounds;
872                 float step = (2*3.141592654f) / 32;
873                 enum chart_type {CHART_LINE, CHART_HISTO, CHART_MIXED}
874                 const(char) *[3]names = ["Lines", "Columns", "Mixed"];
875                 float id = 0;
876                 int i;
877 
878                 //* Header
879                 nk_style_push_vec2(ctx, &ctx.style.window.spacing, nk_vec2(0,0));
880                 nk_style_push_float(ctx, &ctx.style.button.rounding, 0);
881                 nk_layout_row_begin(ctx, NK_STATIC, 20, 3);
882                 for (i = 0; i < 3; ++i) {
883                     //* make sure button perfectly fits text
884                     const(nk_user_font) *f = ctx.style.font;
885                     float text_width = 80;// f.width(f.userdata, f.height, names[i], nk_strlen(names[i]));
886                     float widget_width = text_width + 3 * ctx.style.button.padding.x;
887                     nk_layout_row_push(ctx, widget_width);
888                     if (current_tab == i) {
889                         //* active tab gets highlighted
890                         nk_style_item button_color = ctx.style.button.normal;
891                         ctx.style.button.normal = ctx.style.button.active;
892                         current_tab = nk_button_label(ctx, names[i]) ? i: current_tab;
893                         ctx.style.button.normal = button_color;
894                     } else current_tab = nk_button_label(ctx, names[i]) ? i: current_tab;
895                 }
896                 nk_style_pop_float(ctx);
897 
898                 //* Body
899                 nk_layout_row_dynamic(ctx, 140, 1);
900                 if (nk_group_begin(ctx, "Notebook", NK_WINDOW_BORDER))
901                 {
902                     nk_style_pop_vec2(ctx);
903                     switch (current_tab) {
904                         default: break;
905                         case chart_type.CHART_LINE:
906                             nk_layout_row_dynamic(ctx, 100, 1);
907                             bounds = nk_widget_bounds(ctx);
908                             if (nk_chart_begin_colored(ctx, NK_CHART_LINES, nk_rgb(255,0,0), nk_rgb(150,0,0), 32, 0.0f, 1.0f)) {
909                                 nk_chart_add_slot_colored(ctx, NK_CHART_LINES, nk_rgb(0,0,255), nk_rgb(0,0,150),32, -1.0f, 1.0f);
910                                 for (i = 0, id = 0; i < 32; ++i) {
911                                     nk_chart_push_slot(ctx,cast (float)fabs(sin(id)), 0);
912                                     nk_chart_push_slot(ctx, cast(float)cos(id), 1);
913                                     id += step;
914                                 }
915                             }
916                             nk_chart_end(ctx);
917                             break;
918                         case chart_type.CHART_HISTO:
919                             nk_layout_row_dynamic(ctx, 100, 1);
920                             bounds = nk_widget_bounds(ctx);
921                             if (nk_chart_begin_colored(ctx, NK_CHART_COLUMN, nk_rgb(255,0,0), nk_rgb(150,0,0), 32, 0.0f, 1.0f)) {
922                                 for (i = 0, id = 0; i < 32; ++i) {
923                                     nk_chart_push_slot(ctx, cast(float)fabs(sin(id)), 0);
924                                     id += step;
925                                 }
926                             }
927                             nk_chart_end(ctx);
928                             break;
929                         case chart_type.CHART_MIXED:
930                             nk_layout_row_dynamic(ctx, 100, 1);
931                             bounds = nk_widget_bounds(ctx);
932                             if (nk_chart_begin_colored(ctx, NK_CHART_LINES, nk_rgb(255,0,0), nk_rgb(150,0,0), 32, 0.0f, 1.0f)) {
933                                 nk_chart_add_slot_colored(ctx, NK_CHART_LINES, nk_rgb(0,0,255), nk_rgb(0,0,150),32, -1.0f, 1.0f);
934                                 nk_chart_add_slot_colored(ctx, NK_CHART_COLUMN, nk_rgb(0,255,0), nk_rgb(0,150,0), 32, 0.0f, 1.0f);
935                                 for (i = 0, id = 0; i < 32; ++i) {
936                                     nk_chart_push_slot(ctx, cast(float)fabs(sin(id)), 0);
937                                     nk_chart_push_slot(ctx, cast(float)fabs(cos(id)), 1);
938                                     nk_chart_push_slot(ctx, cast(float)fabs(sin(id)), 2);
939                                     id += step;
940                                 }
941                             }
942                             nk_chart_end(ctx);
943                             break;
944                     }
945                     nk_group_end(ctx);
946                 } else nk_style_pop_vec2(ctx);
947                 nk_tree_pop(ctx);
948             }
949 
950             if (nk_tree_push(ctx, NK_TREE_NODE, "Simple", NK_MINIMIZED))
951             {
952                 nk_layout_row_dynamic(ctx, 300, 2);
953                 if (nk_group_begin(ctx, "Group_Without_Border", 0)) {
954                     int i = 0;
955                     char[64] buffer;
956                     nk_layout_row_static(ctx, 18, 150, 1);
957                     for (i = 0; i < 64; ++i) {
958                         sprintf(buffer.ptr, "0x%02x", i);
959                         nk_labelf(ctx, NK_TEXT_LEFT, "%s: scrollable region", buffer.ptr);
960                     }
961                     nk_group_end(ctx);
962                 }
963                 if (nk_group_begin(ctx, "Group_With_Border", NK_WINDOW_BORDER)) {
964                     int i = 0;
965                     char[64] buffer;
966                     nk_layout_row_dynamic(ctx, 25, 2);
967                     for (i = 0; i < 64; ++i) {
968                         sprintf(buffer.ptr, "%08d", ((((i%7)*10)^32))+(64+(i%2)*2));
969                         nk_button_label(ctx, buffer.ptr);
970                     }
971                     nk_group_end(ctx);
972                 }
973                 nk_tree_pop(ctx);
974             }
975 
976             if (nk_tree_push(ctx, NK_TREE_NODE, "Complex", NK_MINIMIZED))
977             {
978                 int i;
979                 nk_layout_space_begin(ctx, NK_STATIC, 500, 64);
980                 nk_layout_space_push(ctx, nk_rect(0,0,150,500));
981                 if (nk_group_begin(ctx, "Group_left", NK_WINDOW_BORDER)) {
982                     static int[32] selected4;
983                     nk_layout_row_static(ctx, 18, 100, 1);
984                     for (i = 0; i < 32; ++i)
985                         nk_selectable_label(ctx, (selected4[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected4[i]);
986                     nk_group_end(ctx);
987                 }
988 
989                 nk_layout_space_push(ctx, nk_rect(160,0,150,240));
990                 if (nk_group_begin(ctx, "Group_top", NK_WINDOW_BORDER)) {
991                     nk_layout_row_dynamic(ctx, 25, 1);
992                     nk_button_label(ctx, "#FFAA");
993                     nk_button_label(ctx, "#FFBB");
994                     nk_button_label(ctx, "#FFCC");
995                     nk_button_label(ctx, "#FFDD");
996                     nk_button_label(ctx, "#FFEE");
997                     nk_button_label(ctx, "#FFFF");
998                     nk_group_end(ctx);
999                 }
1000 
1001                 nk_layout_space_push(ctx, nk_rect(160,250,150,250));
1002                 if (nk_group_begin(ctx, "Group_buttom", NK_WINDOW_BORDER)) {
1003                     nk_layout_row_dynamic(ctx, 25, 1);
1004                     nk_button_label(ctx, "#FFAA");
1005                     nk_button_label(ctx, "#FFBB");
1006                     nk_button_label(ctx, "#FFCC");
1007                     nk_button_label(ctx, "#FFDD");
1008                     nk_button_label(ctx, "#FFEE");
1009                     nk_button_label(ctx, "#FFFF");
1010                     nk_group_end(ctx);
1011                 }
1012 
1013                 nk_layout_space_push(ctx, nk_rect(320,0,150,150));
1014                 if (nk_group_begin(ctx, "Group_right_top", NK_WINDOW_BORDER)) {
1015                     static int[4] selected5;
1016                     nk_layout_row_static(ctx, 18, 100, 1);
1017                     for (i = 0; i < 4; ++i)
1018                         nk_selectable_label(ctx, (selected5[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected5[i]);
1019                     nk_group_end(ctx);
1020                 }
1021 
1022                 nk_layout_space_push(ctx, nk_rect(320,160,150,150));
1023                 if (nk_group_begin(ctx, "Group_right_center", NK_WINDOW_BORDER)) {
1024                     static int[4] selected6;
1025                     nk_layout_row_static(ctx, 18, 100, 1);
1026                     for (i = 0; i < 4; ++i)
1027                         nk_selectable_label(ctx, (selected6[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected6[i]);
1028                     nk_group_end(ctx);
1029                 }
1030 
1031                 nk_layout_space_push(ctx, nk_rect(320,320,150,150));
1032                 if (nk_group_begin(ctx, "Group_right_bottom", NK_WINDOW_BORDER)) {
1033                     static int[4] selected7;
1034                     nk_layout_row_static(ctx, 18, 100, 1);
1035                     for (i = 0; i < 4; ++i)
1036                         nk_selectable_label(ctx, (selected7[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected7[i]);
1037                     nk_group_end(ctx);
1038                 }
1039                 nk_layout_space_end(ctx);
1040                 nk_tree_pop(ctx);
1041             }
1042 
1043             if (nk_tree_push(ctx, NK_TREE_NODE, "Splitter", NK_MINIMIZED))
1044             {
1045                 const(nk_input) *in_ = &ctx.input;
1046                 nk_layout_row_static(ctx, 20, 320, 1);
1047                 nk_label(ctx, "Use slider and spinner to change tile size", NK_TEXT_LEFT);
1048                 nk_label(ctx, "Drag the space between tiles to change tile ratio", NK_TEXT_LEFT);
1049 
1050                 if (nk_tree_push(ctx, NK_TREE_NODE, "Vertical", NK_MINIMIZED))
1051                 {
1052                     static float a = 100, b = 100, c = 100;
1053                     nk_rect bounds;
1054 
1055                     float[5] row_layout;
1056                     row_layout[0] = a;
1057                     row_layout[1] = 8;
1058                     row_layout[2] = b;
1059                     row_layout[3] = 8;
1060                     row_layout[4] = c;
1061 
1062                     //* header
1063                     nk_layout_row_static(ctx, 30, 100, 2);
1064                     nk_label(ctx, "left:", NK_TEXT_LEFT);
1065                     nk_slider_float(ctx, 10.0f, &a, 200.0f, 10.0f);
1066 
1067                     nk_label(ctx, "middle:", NK_TEXT_LEFT);
1068                     nk_slider_float(ctx, 10.0f, &b, 200.0f, 10.0f);
1069 
1070                     nk_label(ctx, "right:", NK_TEXT_LEFT);
1071                     nk_slider_float(ctx, 10.0f, &c, 200.0f, 10.0f);
1072 
1073                     //* tiles
1074                     nk_layout_row(ctx, NK_STATIC, 200, 5, row_layout.ptr);
1075 
1076                     //* left space 
1077                     if (nk_group_begin(ctx, "left", NK_WINDOW_NO_SCROLLBAR|NK_WINDOW_BORDER|NK_WINDOW_NO_SCROLLBAR)) {
1078                         nk_layout_row_dynamic(ctx, 25, 1);
1079                         nk_button_label(ctx, "#FFAA");
1080                         nk_button_label(ctx, "#FFBB");
1081                         nk_button_label(ctx, "#FFCC");
1082                         nk_button_label(ctx, "#FFDD");
1083                         nk_button_label(ctx, "#FFEE");
1084                         nk_button_label(ctx, "#FFFF");
1085                         nk_group_end(ctx);
1086                     }
1087 
1088                     //* scaler
1089                     bounds = nk_widget_bounds(ctx);
1090                     nk_spacing(ctx, 1);
1091                     if ((nk_input_is_mouse_hovering_rect(in_, bounds) ||
1092                          nk_input_is_mouse_prev_hovering_rect(in_, bounds)) &&
1093                         nk_input_is_mouse_down(in_, NK_BUTTON_LEFT))
1094                     {
1095                         a = row_layout[0] + in_.mouse.delta.x;
1096                         b = row_layout[2] - in_.mouse.delta.x;
1097                     }
1098 
1099                     //* middle space
1100                     if (nk_group_begin(ctx, "center", NK_WINDOW_BORDER|NK_WINDOW_NO_SCROLLBAR)) {
1101                         nk_layout_row_dynamic(ctx, 25, 1);
1102                         nk_button_label(ctx, "#FFAA");
1103                         nk_button_label(ctx, "#FFBB");
1104                         nk_button_label(ctx, "#FFCC");
1105                         nk_button_label(ctx, "#FFDD");
1106                         nk_button_label(ctx, "#FFEE");
1107                         nk_button_label(ctx, "#FFFF");
1108                         nk_group_end(ctx);
1109                     }
1110 
1111                     //* scaler
1112                     bounds = nk_widget_bounds(ctx);
1113                     nk_spacing(ctx, 1);
1114                     if ((nk_input_is_mouse_hovering_rect(in_, bounds) ||
1115                          nk_input_is_mouse_prev_hovering_rect(in_, bounds)) &&
1116                         nk_input_is_mouse_down(in_, NK_BUTTON_LEFT))
1117                     {
1118                         b = (row_layout[2] + in_.mouse.delta.x);
1119                         c = (row_layout[4] - in_.mouse.delta.x);
1120                     }
1121 
1122                     //* right space
1123                     if (nk_group_begin(ctx, "right", NK_WINDOW_BORDER|NK_WINDOW_NO_SCROLLBAR)) {
1124                         nk_layout_row_dynamic(ctx, 25, 1);
1125                         nk_button_label(ctx, "#FFAA");
1126                         nk_button_label(ctx, "#FFBB");
1127                         nk_button_label(ctx, "#FFCC");
1128                         nk_button_label(ctx, "#FFDD");
1129                         nk_button_label(ctx, "#FFEE");
1130                         nk_button_label(ctx, "#FFFF");
1131                         nk_group_end(ctx);
1132                     }
1133 
1134                     nk_tree_pop(ctx);
1135                 }
1136 
1137                 if (nk_tree_push(ctx, NK_TREE_NODE, "Horizontal", NK_MINIMIZED))
1138                 {
1139                     static float a2 = 100, b2 = 100, c2 = 100;
1140                     nk_rect bounds;
1141 
1142                     //* header
1143                     nk_layout_row_static(ctx, 30, 100, 2);
1144                     nk_label(ctx, "top:", NK_TEXT_LEFT);
1145                     nk_slider_float(ctx, 10.0f, &a2, 200.0f, 10.0f);
1146 
1147                     nk_label(ctx, "middle:", NK_TEXT_LEFT);
1148                     nk_slider_float(ctx, 10.0f, &b2, 200.0f, 10.0f);
1149 
1150                     nk_label(ctx, "bottom:", NK_TEXT_LEFT);
1151                     nk_slider_float(ctx, 10.0f, &c2, 200.0f, 10.0f);
1152 
1153                     //* top space
1154                     nk_layout_row_dynamic(ctx, a2, 1);
1155                     if (nk_group_begin(ctx, "top", NK_WINDOW_NO_SCROLLBAR|NK_WINDOW_BORDER)) {
1156                         nk_layout_row_dynamic(ctx, 25, 3);
1157                         nk_button_label(ctx, "#FFAA");
1158                         nk_button_label(ctx, "#FFBB");
1159                         nk_button_label(ctx, "#FFCC");
1160                         nk_button_label(ctx, "#FFDD");
1161                         nk_button_label(ctx, "#FFEE");
1162                         nk_button_label(ctx, "#FFFF");
1163                         nk_group_end(ctx);
1164                     }
1165 
1166                     //* scaler
1167                     nk_layout_row_dynamic(ctx, 8, 1);
1168                     bounds = nk_widget_bounds(ctx);
1169                     nk_spacing(ctx, 1);
1170                     if ((nk_input_is_mouse_hovering_rect(in_, bounds) ||
1171                          nk_input_is_mouse_prev_hovering_rect(in_, bounds)) &&
1172                         nk_input_is_mouse_down(in_, NK_BUTTON_LEFT))
1173                     {
1174                         a2 = a2 + in_.mouse.delta.y;
1175                         b2 = b2 - in_.mouse.delta.y;
1176                     }
1177 
1178                     //* middle space
1179                     nk_layout_row_dynamic(ctx, b2, 1);
1180                     if (nk_group_begin(ctx, "middle", NK_WINDOW_NO_SCROLLBAR|NK_WINDOW_BORDER)) {
1181                         nk_layout_row_dynamic(ctx, 25, 3);
1182                         nk_button_label(ctx, "#FFAA");
1183                         nk_button_label(ctx, "#FFBB");
1184                         nk_button_label(ctx, "#FFCC");
1185                         nk_button_label(ctx, "#FFDD");
1186                         nk_button_label(ctx, "#FFEE");
1187                         nk_button_label(ctx, "#FFFF");
1188                         nk_group_end(ctx);
1189                     }
1190 
1191                     {
1192                         //* scaler
1193                         nk_layout_row_dynamic(ctx, 8, 1);
1194                         bounds = nk_widget_bounds(ctx);
1195                         if ((nk_input_is_mouse_hovering_rect(in_, bounds) ||
1196                              nk_input_is_mouse_prev_hovering_rect(in_, bounds)) &&
1197                             nk_input_is_mouse_down(in_, NK_BUTTON_LEFT))
1198                         {
1199                             b2 = b2 + in_.mouse.delta.y;
1200                             c2 = c2 - in_.mouse.delta.y;
1201                         }
1202                     }
1203 
1204                     //* bottom space
1205                     nk_layout_row_dynamic(ctx, c2, 1);
1206                     if (nk_group_begin(ctx, "bottom", NK_WINDOW_NO_SCROLLBAR|NK_WINDOW_BORDER)) {
1207                         nk_layout_row_dynamic(ctx, 25, 3);
1208                         nk_button_label(ctx, "#FFAA");
1209                         nk_button_label(ctx, "#FFBB");
1210                         nk_button_label(ctx, "#FFCC");
1211                         nk_button_label(ctx, "#FFDD");
1212                         nk_button_label(ctx, "#FFEE");
1213                         nk_button_label(ctx, "#FFFF");
1214                         nk_group_end(ctx);
1215                     }
1216                     nk_tree_pop(ctx);
1217                 }
1218                 nk_tree_pop(ctx);
1219             }
1220             nk_tree_pop(ctx);
1221         }
1222 
1223     }
1224     nk_end(ctx);
1225     return !nk_window_is_closed(ctx, "Overview");
1226 }