Exemplo n.º 1
0
        /// <summary>
        ///     This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(_background);

            // TODO: Add your drawing code here
            if (_nuklearContext.BeginTitled("demo2", "demo2", new RectangleF(50, 50, 200, 200),
                                            Nuklear.NK_WINDOW_BORDER | Nuklear.NK_WINDOW_MOVABLE | Nuklear.NK_WINDOW_SCALABLE |
                                            Nuklear.NK_WINDOW_MINIMIZABLE | Nuklear.NK_WINDOW_TITLE))
            {
                _nuklearContext.LayoutRowStatic(30, 80, 1);
                _nuklearContext.LayoutRowDynamic(30, 1);
                _nuklearContext.ButtonText("Button");
                _nuklearContext.LayoutRowDynamic(30, 2);
                if (_nuklearContext.OptionLabel("Tea", _isTea))
                {
                    _isTea = true;
                }

                if (_nuklearContext.OptionLabel("Coffee", !_isTea))
                {
                    _isTea = false;
                }

                _nuklearContext.ButtonColor(Color.Red);
                _nuklearContext.LayoutRowDynamic(30, 1);
                _nuklearContext.LayoutRowDynamic(30, 2);
                _nuklearContext.LabelColored("background", nk_text_align.NK_TEXT_LEFT, _background);

                if (_nuklearContext.ComboBeginColor(_background, new Vector2(_nuklearContext.WidgetWidth(), 400)))
                {
                    _nuklearContext.LayoutRowDynamic(120, 1);
                    _background = _nuklearContext.ColorPicker(_background.ToColorf(), 0).ToColor();
                    _nuklearContext.LayoutRowDynamic(25, 1);
                    _background.R = (byte)_nuklearContext.Propertyi("#R", 0, _background.R, 255, 1, 1);
                    _background.G = (byte)_nuklearContext.Propertyi("#G", 0, _background.G, 255, 1, 1);
                    _background.B = (byte)_nuklearContext.Propertyi("#B", 0, _background.B, 255, 1, 1);
                    _background.A = (byte)_nuklearContext.Propertyi("#A", 0, _background.A, 255, 1, 1);
                    _nuklearContext.ComboEnd();
                }

                _nuklearContext.LayoutRowDynamic(30, 1);
                _nuklearContext.LabelColored("Native Allocations: " + NativeMemory.Allocations, nk_text_align.NK_TEXT_LEFT, _background);
            }

            _nuklearContext.End();

            _nuklearContext.Draw();

            _perfGraph.Update(gameTime.ElapsedGameTime.TotalSeconds);

            _nvgContext.BeginFrame(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight, 1.0f);
            _perfGraph.Render(_nvgContext, 5, 5);
            _nvgContext.EndFrame();

            /*			_spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
             * _spriteBatch.Draw(_nuklearContext.Textures[0], Vector2.Zero, Color.White);
             * _spriteBatch.End();*/

            base.Draw(gameTime);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(_background);

            // TODO: Add your drawing code here
            if (_nuklearContext.BeginTitled("demo2", "demo2", new Rectangle(50, 50, 200, 200),
                                            Nuklear.NK_WINDOW_BORDER | Nuklear.NK_WINDOW_MOVABLE | Nuklear.NK_WINDOW_SCALABLE |
                                            Nuklear.NK_WINDOW_MINIMIZABLE | Nuklear.NK_WINDOW_TITLE))
            {
                _nuklearContext.LayoutRowStatic(30, 80, 1);
                _nuklearContext.LayoutRowDynamic(30, 1);
                _nuklearContext.ButtonText("Button");
                _nuklearContext.LayoutRowDynamic(30, 2);
                if (_nuklearContext.OptionLabel("Tea", _isTea))
                {
                    _isTea = true;
                }

                if (_nuklearContext.OptionLabel("Coffee", !_isTea))
                {
                    _isTea = false;
                }

                _nuklearContext.ButtonColor(Color.Red);
                _nuklearContext.LayoutRowDynamic(30, 1);
                _nuklearContext.LayoutRowDynamic(30, 2);
                _nuklearContext.LabelColored("background", Nuklear.NK_TEXT_LEFT, _background);

                if (_nuklearContext.ComboBeginColor(_background, new Vector2(_nuklearContext.WidgetWidth(), 400)))
                {
                    _nuklearContext.LayoutRowDynamic(120, 1);
                    _background = _nuklearContext.ColorPicker(_background, 0);
                    _nuklearContext.LayoutRowDynamic(25, 1);
                    _background.R = (byte)_nuklearContext.Propertyi("#R", 0, _background.R, 255, 1, 1);
                    _background.G = (byte)_nuklearContext.Propertyi("#G", 0, _background.G, 255, 1, 1);
                    _background.B = (byte)_nuklearContext.Propertyi("#B", 0, _background.B, 255, 1, 1);
                    _background.A = (byte)_nuklearContext.Propertyi("#A", 0, _background.A, 255, 1, 1);
                    _nuklearContext.ComboEnd();
                }

                _nuklearContext.LayoutRowDynamic(30, 1);
                _nuklearContext.LabelColored("Sichem Allocated: " + Pointer.AllocatedTotal, Nuklear.NK_TEXT_LEFT, _background);
            }
            _nuklearContext.End();

            _nuklearContext.Draw();

/*			_spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
 *                      _spriteBatch.Draw(_nuklearContext.Textures[0], Vector2.Zero, Color.White);
 *                      _spriteBatch.End();*/

            base.Draw(gameTime);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Grids the demo.
        /// </summary>
        /// <param name="ctx">Context.</param>
        /// <param name="media">Media.</param>
        public static void grid_demo(this NuklearContext ctx, Media media)
        {
            int i;

            ctx.StyleSetFont(media.font);
            ctx.StyleSetFontSize(20);
            if (ctx.Begin("Grid Demo", new RectangleF(600, 350, 275, 250),
                          Nuklear.NK_WINDOW_TITLE | Nuklear.NK_WINDOW_BORDER | Nuklear.NK_WINDOW_MOVABLE |
                          Nuklear.NK_WINDOW_NO_SCROLLBAR))
            {
                ctx.StyleSetFontSize(18);
                ctx.LayoutRowDynamic(30, 2);
                ctx.Label("String:", nk_text_align.NK_TEXT_RIGHT);
                ctx.EditString(Nuklear.NK_EDIT_FIELD, ref edit_strings[0], 64, Nuklear.nk_filter_default);
                ctx.Label("Floating point:", nk_text_align.NK_TEXT_RIGHT);
                ctx.EditString(Nuklear.NK_EDIT_FIELD, ref edit_strings[1], 64, Nuklear.nk_filter_float);
                ctx.Label("Hexadecimal:", nk_text_align.NK_TEXT_RIGHT);
                ctx.EditString(Nuklear.NK_EDIT_FIELD, ref edit_strings[2], 64, Nuklear.nk_filter_hex);
                ctx.Label("Binary:", nk_text_align.NK_TEXT_RIGHT);
                ctx.EditString(Nuklear.NK_EDIT_FIELD, ref edit_strings[3], 64, Nuklear.nk_filter_binary);
                ctx.Label("Checkbox:", nk_text_align.NK_TEXT_RIGHT);
                ctx.CheckboxLabel("Check me", ref grid_check);
                ctx.Label("Combobox:", nk_text_align.NK_TEXT_RIGHT);
                if (ctx.ComboBeginLabel(items[selectedItem], new Vector2(ctx.WidgetWidth(), 200)))
                {
                    ctx.LayoutRowDynamic(25, 1);
                    for (i = 0; i < 3; ++i)
                    {
                        if (ctx.ComboItemLabel(items[i], nk_text_align.NK_TEXT_LEFT))
                        {
                            selectedItem = i;
                        }
                    }
                    ctx.ComboEnd();
                }
            }

            ctx.End();
            ctx.StyleSetFontSize(14);
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Grids the demo.
        /// </summary>
        /// <param name="ctx">Context.</param>
        /// <param name="media">Media.</param>
        public static void grid_demo(NuklearContext ctx, Media media)
        {
            int i;

            ctx.StyleSetFont(media.Font20.Handle);
            if (ctx.Begin("Grid Demo", Nk.nk_rect_(600, 350, 275, 250),
                          PanelFlags.TITLE | PanelFlags.BORDER | PanelFlags.MOVABLE |
                          PanelFlags.NO_SCROLLBAR))
            {
                ctx.StyleSetFont(media.Font18.Handle);
                ctx.LayoutRowDynamic(30, 2);
                ctx.Label("String:", Alignment.MIDDLERIGHT);
                ctx.EditString(NkEditFlags.FIELD, ref EditStrings[0], 64, Nk.nk_filter_default);
                ctx.Label("Floating point:", Alignment.MIDDLERIGHT);
                ctx.EditString(NkEditFlags.FIELD, ref EditStrings[1], 64, Nk.nk_filter_float);
                ctx.Label("Hexadecimal:", Alignment.MIDDLERIGHT);
                ctx.EditString(NkEditFlags.FIELD, ref EditStrings[2], 64, Nk.nk_filter_hex);
                ctx.Label("Binary:", Alignment.MIDDLERIGHT);
                ctx.EditString(NkEditFlags.FIELD, ref EditStrings[3], 64, Nk.nk_filter_binary);
                ctx.Label("Checkbox:", Alignment.MIDDLERIGHT);
                ctx.CheckboxLabel("Check me", ref _gridCheck);
                ctx.Label("Combobox:", Alignment.MIDDLERIGHT);
                if (ctx.ComboBeginLabel(Items[_selectedItem2], Nk.nk_vec2_(ctx.WidgetWidth(), 200)))
                {
                    ctx.LayoutRowDynamic(25, 1);
                    for (i = 0; i < 3; ++i)
                    {
                        if (ctx.ComboItemLabel(Items[i], Alignment.MIDDLELEFT))
                        {
                            _selectedItem2 = i;
                        }
                    }
                    ctx.ComboEnd();
                }
            }
            ctx.End();
            ctx.StyleSetFont(media.Font14.Handle);
        }
Exemplo n.º 5
0
        public static void basic_demo(this NuklearContext ctx, Media media)
        {
            int i;

            ctx.StyleSetFont(media.font);
            ctx.StyleSetFontSize(20);
            ctx.Begin("Basic Demo", new RectangleF(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", nk_text_align.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, new RectangleF(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], new Vector2(ctx.WidgetWidth(), 200)))
            {
                ctx.LayoutRowDynamic(35, 1);
                for (i = 0; i < 3; ++i)
                {
                    if (ctx.ComboItemLabel(items2[i], nk_text_align.NK_TEXT_LEFT))
                    {
                        selected_item = i;
                    }
                }
                ctx.ComboEnd();
            }

            ui_widget(ctx, media, 40);
            if (ctx.ComboBeginImageLabel(items2[selected_icon], media.images[selected_icon],
                                         new Vector2(ctx.WidgetWidth(), 200)))
            {
                ctx.LayoutRowDynamic(35, 1);
                for (i = 0; i < 3; ++i)
                {
                    if (ctx.ComboItemImageLabel(media.images[i], items2[i], nk_text_align.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.input, Nuklear.NK_BUTTON_RIGHT, ctx.WindowGetBounds(),
                                                             true))
            {
                piemenu_pos    = 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.StyleSetFontSize(14);
            ctx.End();
        }
Exemplo n.º 6
0
        public static void basic_demo(NuklearContext ctx, Media media)
        {
            int i;

            ctx.StyleSetFont(media.Font20.Handle);
            ctx.Begin("Basic Demo", Nk.nk_rect_(320, 50, 275, 610),
                      PanelFlags.BORDER | PanelFlags.MOVABLE | PanelFlags.TITLE);

            ui_header(ctx, media, "Popup & Scrollbar & Images");
            ui_widget(ctx, media, 35);
            if (ctx.ButtonImageLabel(media.Dir, "Images", Alignment.MIDDLECENTERED))
            {
                _imageActive = !_imageActive;
            }

            ui_header(ctx, media, "Selected Image");
            ui_widget_centered(ctx, media, 100);
            ctx.Image(media.Images[_selectedImage]);

            if (_imageActive)
            {
                if (ctx.PopupBegin(NkPopupType.NK_POPUP_STATIC, "Image Popup", 0, Nk.nk_rect_(265, 0, 320, 220)))
                {
                    ctx.LayoutRowStatic(82, 82, 3);
                    for (i = 0; i < 9; ++i)
                    {
                        if (ctx.ButtonImage(media.Images[i]))
                        {
                            _selectedImage = i;
                            _imageActive   = false;
                            ctx.PopupClose();
                        }
                    }
                    ctx.PopupEnd();
                }
            }

            ui_header(ctx, media, "Combo box");
            ui_widget(ctx, media, 40);
            if (ctx.ComboBeginLabel(Items2[_selectedItem1], Nk.nk_vec2_(ctx.WidgetWidth(), 200)))
            {
                ctx.LayoutRowDynamic(35, 1);
                for (i = 0; i < 3; ++i)
                {
                    if (ctx.ComboItemLabel(Items2[i], Alignment.MIDDLELEFT))
                    {
                        _selectedItem1 = i;
                    }
                }
                ctx.ComboEnd();
            }

            ui_widget(ctx, media, 40);
            if (ctx.ComboBeginImageLabel(Items2[_selectedIcon], media.Images[_selectedIcon],
                                         Nk.nk_vec2_(ctx.WidgetWidth(), 200)))
            {
                ctx.LayoutRowDynamic(35, 1);
                for (i = 0; i < 3; ++i)
                {
                    if (ctx.ComboItemImageLabel(media.Images[i], Items2[i], Alignment.MIDDLERIGHT))
                    {
                        _selectedIcon = 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, Nk.nk_true);

            if (Nk.nk_input_is_mouse_click_down_in_rect(ctx.Ctx.Input, NkButtons.RIGHT,
                                                        ctx.WindowGetBounds(), Nk.nk_true) != 0)
            {
                _piemenuPos    = ctx.Ctx.Input.mouse.Pos;
                _piemenuActive = true;
            }

            if (_piemenuActive)
            {
                var ret = ui_piemenu(ctx, _piemenuPos, 140, media.Menu, 6);
                if (ret == -2)
                {
                    _piemenuActive = false;
                }
                if (ret != -1)
                {
                    Console.Write("piemenu selected: {0}\n", ret);
                    _piemenuActive = false;
                }
            }

            ctx.StyleSetFont(media.Font14.Handle);
            ctx.End();
        }