overview.c 64 KB

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