public static void basic_demo(NuklearContext ctx, Media media) { int i; ctx.StyleSetFont(media.font_20.handle); ctx.Begin("Basic Demo", Nuklear.nk_rect_(320, 50, 275, 610), Nuklear.NK_WINDOW_BORDER | Nuklear.NK_WINDOW_MOVABLE | Nuklear.NK_WINDOW_TITLE); ui_header(ctx, media, "Popup & Scrollbar & Images"); ui_widget(ctx, media, 35); if (ctx.ButtonImageLabel(media.dir, "Images", Nuklear.NK_TEXT_CENTERED)) { image_active = !image_active; } ui_header(ctx, media, "Selected Image"); ui_widget_centered(ctx, media, 100); ctx.Image(media.images[selected_image]); if (image_active) { if (ctx.PopupBegin(Nuklear.NK_POPUP_STATIC, "Image Popup", 0, Nuklear.nk_rect_(265, 0, 320, 220))) { ctx.LayoutRowStatic(82, 82, 3); for (i = 0; i < 9; ++i) { if (ctx.ButtonImage(media.images[i])) { selected_image = i; image_active = false; ctx.PopupClose(); } } ctx.PopupEnd(); } } ui_header(ctx, media, "Combo box"); ui_widget(ctx, media, 40); if (ctx.ComboBeginLabel(items2[selected_item], Nuklear.nk_vec2_(ctx.WidgetWidth(), 200))) { ctx.LayoutRowDynamic(35, 1); for (i = 0; i < 3; ++i) { if (ctx.ComboItemLabel(items2[i], Nuklear.NK_TEXT_LEFT)) { selected_item = i; } } ctx.ComboEnd(); } ui_widget(ctx, media, 40); if (ctx.ComboBeginImageLabel(items2[selected_icon], media.images[selected_icon], Nuklear.nk_vec2_(ctx.WidgetWidth(), 200))) { ctx.LayoutRowDynamic(35, 1); for (i = 0; i < 3; ++i) { if (ctx.ComboItemImageLabel(media.images[i], items2[i], Nuklear.NK_TEXT_RIGHT)) { selected_icon = i; } } ctx.ComboEnd(); } ui_header(ctx, media, "Checkbox"); ui_widget(ctx, media, 30); ctx.CheckboxLabel("Flag 1", ref check0); ui_widget(ctx, media, 30); ctx.CheckboxLabel("Flag 2", ref check1); ui_header(ctx, media, "Progressbar"); ui_widget(ctx, media, 35); ctx.Progress(ref prog, 100, Nuklear.nk_true); if (Nuklear.nk_input_is_mouse_click_down_in_rect(ctx.Ctx.input, Nuklear.NK_BUTTON_RIGHT, ctx.WindowGetBounds(), Nuklear.nk_true) != 0) { piemenu_pos = ctx.Ctx.input.mouse.pos; piemenu_active = true; } if (piemenu_active) { var ret = ui_piemenu(ctx, piemenu_pos, 140, media.menu, 6); if (ret == -2) { piemenu_active = false; } if (ret != -1) { Console.Write("piemenu selected: {0}\n", ret); piemenu_active = false; } } ctx.StyleSetFont(media.font_14.handle); ctx.End(); }
public static void ui_widget_centered(NuklearContext ctx, Media media, float height) { ctx.StyleSetFont(media.font_22.handle); ctx.LayoutRow(Nuklear.NK_DYNAMIC, height, 3, ratio2); ctx.Spacing(1); }
public static void button_demo(NuklearContext ctx, Media media) { ctx.StyleSetFont(media.font_20.handle); ctx.Begin("Button Demo", Nuklear.nk_rect_(50, 50, 255, 610), Nuklear.NK_WINDOW_BORDER | Nuklear.NK_WINDOW_MOVABLE | Nuklear.NK_WINDOW_TITLE); /*------------------------------------------------ * MENU *------------------------------------------------*/ ctx.MenubarBegin(); { /* toolbar */ ctx.LayoutRowStatic(40, 40, 4); if (ctx.MenuBeginImage("Music", media.play, Nuklear.nk_vec2_(110, 120))) { /* settings */ ctx.LayoutRowDynamic(25, 1); ctx.MenuItemImageLabel(media.play, "Play", Nuklear.NK_TEXT_RIGHT); ctx.MenuItemImageLabel(media.stop, "Stop", Nuklear.NK_TEXT_RIGHT); ctx.MenuItemImageLabel(media.pause, "Pause", Nuklear.NK_TEXT_RIGHT); ctx.MenuItemImageLabel(media.next, "Next", Nuklear.NK_TEXT_RIGHT); ctx.MenuItemImageLabel(media.prev, "Prev", Nuklear.NK_TEXT_RIGHT); ctx.MenuEnd(); } ctx.ButtonImage(media.tools); ctx.ButtonImage(media.cloud); ctx.ButtonImage(media.pen); } ctx.MenubarEnd(); /*------------------------------------------------ * BUTTON *------------------------------------------------*/ ui_header(ctx, media, "Push buttons"); ui_widget(ctx, media, 35); if (ctx.ButtonLabel("Push me")) { Console.Write("pushed!\n"); } ui_widget(ctx, media, 35); if (ctx.ButtonImageLabel(media.rocket, "Styled", Nuklear.NK_TEXT_CENTERED)) { Console.Write("rocket!\n"); } /*------------------------------------------------ * REPEATER *------------------------------------------------*/ ui_header(ctx, media, "Repeater"); ui_widget(ctx, media, 35); if (ctx.ButtonLabel("Press me")) { Console.Write("pressed!\n"); } /*------------------------------------------------ * TOGGLE *------------------------------------------------*/ ui_header(ctx, media, "Toggle buttons"); ui_widget(ctx, media, 35); if (ctx.ButtonImageLabel(toggle0 ? media.checkd : media.uncheckd, "Toggle", Nuklear.NK_TEXT_LEFT)) { toggle0 = !toggle0; } ui_widget(ctx, media, 35); if (ctx.ButtonImageLabel(toggle1 ? media.checkd : media.uncheckd, "Toggle", Nuklear.NK_TEXT_LEFT)) { toggle1 = !toggle1; } ui_widget(ctx, media, 35); if (ctx.ButtonImageLabel(toggle2 ? media.checkd : media.uncheckd, "Toggle", Nuklear.NK_TEXT_LEFT)) { toggle2 = !toggle2; } /*------------------------------------------------ * RADIO *------------------------------------------------*/ ui_header(ctx, media, "Radio buttons"); ui_widget(ctx, media, 35); if (ctx.ButtonSymbolLabel(option == 0 ? Nuklear.NK_SYMBOL_CIRCLE_OUTLINE : Nuklear.NK_SYMBOL_CIRCLE_SOLID, "Select", Nuklear.NK_TEXT_LEFT)) { option = 0; } ui_widget(ctx, media, 35); if (ctx.ButtonSymbolLabel(option == 1 ? Nuklear.NK_SYMBOL_CIRCLE_OUTLINE : Nuklear.NK_SYMBOL_CIRCLE_SOLID, "Select", Nuklear.NK_TEXT_LEFT)) { option = 1; } ui_widget(ctx, media, 35); if (ctx.ButtonSymbolLabel(option == 2 ? Nuklear.NK_SYMBOL_CIRCLE_OUTLINE : Nuklear.NK_SYMBOL_CIRCLE_SOLID, "Select", Nuklear.NK_TEXT_LEFT)) { option = 2; } /*------------------------------------------------ * CONTEXTUAL *------------------------------------------------*/ ctx.StyleSetFont(media.font_18.handle); if (ctx.ContextualBegin(Nuklear.NK_WINDOW_NO_SCROLLBAR, Nuklear.nk_vec2_(150, 300), ctx.WindowGetBounds())) { ctx.LayoutRowDynamic(30, 1); if (ctx.ContextualItemImageLabel(media.copy, "Clone", Nuklear.NK_TEXT_RIGHT)) { Console.Write("pressed clone!\n"); } if (ctx.ContextualItemImageLabel(media.del, "Delete", Nuklear.NK_TEXT_RIGHT)) { Console.Write("pressed delete!\n"); } if (ctx.ContextualItemImageLabel(media.convert, "Convert", Nuklear.NK_TEXT_RIGHT)) { Console.Write("pressed convert!\n"); } if (ctx.ContextualItemImageLabel(media.edit, "Edit", Nuklear.NK_TEXT_RIGHT)) { Console.Write("pressed edit!\n"); } ctx.ContextualEnd(); } ctx.StyleSetFont(media.font_14.handle); ctx.End(); }
public static void ui_header(NuklearContext ctx, Media media, string title) { ctx.StyleSetFont(media.font_18.handle); ctx.LayoutRowDynamic(20, 1); ctx.Label(title, Nuklear.NK_TEXT_LEFT); }