Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. #define NK_IMPLEMENTATION
  5. #include "nuklear.h"
  6.  
  7. int main(int argc, char *argv[]) {
  8. /* init gui state */
  9. struct nk_context ctx;
  10. const struct nk_user_font *font = ctx.style.font;
  11. nk_init_fixed(&ctx, calloc(1, 200), 200, font);
  12.  
  13. enum {EASY, HARD};
  14. static int op = EASY;
  15. static float value = 0.6f;
  16. static int i = 20;
  17.  
  18. if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220),
  19. NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
  20. /* fixed widget pixel width */
  21. nk_layout_row_static(&ctx, 30, 80, 1);
  22. if (nk_button_label(&ctx, "button")) {
  23. /* event handling */
  24. }
  25.  
  26. /* fixed widget window ratio width */
  27. nk_layout_row_dynamic(&ctx, 30, 2);
  28. if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY;
  29. if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD;
  30.  
  31. /* custom widget pixel width */
  32. nk_layout_row_begin(&ctx, NK_STATIC, 30, 2);
  33. {
  34. nk_layout_row_push(&ctx, 50);
  35. nk_label(&ctx, "Volume:", NK_TEXT_LEFT);
  36. nk_layout_row_push(&ctx, 110);
  37. nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f);
  38. }
  39. nk_layout_row_end(&ctx);
  40. }
  41. nk_end(&ctx);
  42. puts("All ok!");
  43. return EXIT_SUCCESS;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement