Exemplo n.º 1
0
 public static bool IsKeyPressed(NkKeys Key)
 {
     //Nuklear.nk_input_is_key_pressed()
     return(Nuklear.nk_input_is_key_pressed(&Ctx->input, Key) != 0);
 }
Exemplo n.º 2
0
 public static void WindowClose(string Name)
 {
     Nuklear.nk_window_close(Ctx, Name);
 }
Exemplo n.º 3
0
 public static NkRect WindowGetBounds()
 {
     return(Nuklear.nk_window_get_bounds(Ctx));
 }
Exemplo n.º 4
0
 public static NkEditEvents EditString(NkEditTypes EditType, StringBuilder Buffer, nk_plugin_filter_t Filter)
 {
     return((NkEditEvents)Nuklear.nk_edit_string_zero_terminated(Ctx, (uint)EditType, Buffer, Buffer.MaxCapacity, Filter));
 }
Exemplo n.º 5
0
 public static void LabelColored(string Txt, NkColor Clr, NkTextAlign TextAlign = (NkTextAlign)NkTextAlignment.NK_TEXT_LEFT)
 {
     Nuklear.nk_label_colored(Ctx, Txt, (uint)TextAlign, Clr);
 }
Exemplo n.º 6
0
 public static void LabelColoredWrap(string Txt, NkColor Clr)
 {
     Nuklear.nk_label_colored_wrap(Ctx, Txt, Clr);
 }
Exemplo n.º 7
0
 public static void Label(string Txt, NkTextAlign TextAlign = (NkTextAlign)NkTextAlignment.NK_TEXT_LEFT)
 {
     Nuklear.nk_label(Ctx, Txt, (uint)TextAlign);
 }
Exemplo n.º 8
0
 public static void LabelWrap(string Txt)
 {
     //Nuklear.nk_label(Ctx, Txt, (uint)TextAlign);
     Nuklear.nk_label_wrap(Ctx, Txt);
 }
Exemplo n.º 9
0
 public static void LayoutRowStatic(float Height, int ItemWidth, int Cols)
 {
     Nuklear.nk_layout_row_static(Ctx, Height, ItemWidth, Cols);
 }
Exemplo n.º 10
0
 public static void LayoutRowDynamic(float Height = 0, int Cols = 1)
 {
     Nuklear.nk_layout_row_dynamic(Ctx, Height, Cols);
 }
Exemplo n.º 11
0
 public static bool ButtonText(string Text)
 {
     return(Nuklear.nk_button_text(Ctx, Text));
 }
Exemplo n.º 12
0
 public static bool ButtonLabel(string Label)
 {
     return(Nuklear.nk_button_label(Ctx, Label) != 0);
 }
Exemplo n.º 13
0
 public static bool WindowIsCollapsed(string Name) => Nuklear.nk_window_is_collapsed(Ctx, Name) != 0;
Exemplo n.º 14
0
 public static bool WindowIsHidden(string Name) => Nuklear.nk_window_is_hidden(Ctx, Name) != 0;
Exemplo n.º 15
0
        static void Render(bool HadInput)
        {
            if (HadInput)
            {
                bool Dirty = true;

                if (FrameBuffered != null)
                {
                    Dirty = false;

                    IntPtr MemoryBuffer = Nuklear.nk_buffer_memory(&Ctx->memory);
                    if ((int)Ctx->memory.allocated == 0)
                    {
                        Dirty = true;
                    }

                    if (!Dirty)
                    {
                        if (LastMemory == null || LastMemory.Length < (int)Ctx->memory.allocated)
                        {
                            LastMemory = new byte[(int)Ctx->memory.allocated];
                            Dirty      = true;
                        }
                    }

                    if (!Dirty)
                    {
                        fixed(byte *LastMemoryPtr = LastMemory)
                        if (MemCmp(new IntPtr(LastMemoryPtr), MemoryBuffer, Ctx->memory.allocated) != 0)
                        {
                            Dirty = true;
                            Marshal.Copy(MemoryBuffer, LastMemory, 0, (int)Ctx->memory.allocated);
                        }
                    }
                }

                if (Dirty)
                {
                    NkConvertResult R = (NkConvertResult)Nuklear.nk_convert(Ctx, Commands, Vertices, Indices, ConvertCfg);
                    if (R != NkConvertResult.Success)
                    {
                        throw new Exception(R.ToString());
                    }

                    NkVertex[] NkVerts  = new NkVertex[(int)Vertices->needed / sizeof(NkVertex)];
                    NkVertex * VertsPtr = (NkVertex *)Vertices->memory.ptr;

                    for (int i = 0; i < NkVerts.Length; i++)
                    {
                        //NkVertex* V = &VertsPtr[i];
                        //NkVerts[i] = new NkVertex() { Position = new NkVector2f() { X = (int)V->Position.X, Y = (int)V->Position.Y }, Color = V->Color, UV = V->UV };

                        NkVerts[i] = VertsPtr[i];
                    }

                    ushort[] NkIndices  = new ushort[(int)Indices->needed / sizeof(ushort)];
                    ushort * IndicesPtr = (ushort *)Indices->memory.ptr;
                    for (int i = 0; i < NkIndices.Length; i++)
                    {
                        NkIndices[i] = IndicesPtr[i];
                    }

                    Dev.SetBuffer(NkVerts, NkIndices);
                    FrameBuffered?.BeginBuffering();

                    uint Offset = 0;
                    Nuklear.nk_draw_foreach(Ctx, Commands, (Cmd) => {
                        if (Cmd->elem_count == 0)
                        {
                            return;
                        }

                        Dev.Render(Cmd->userdata, Cmd->texture.id, Cmd->clip_rect, Offset, Cmd->elem_count);
                        Offset += Cmd->elem_count;
                    });

                    FrameBuffered?.EndBuffering();
                }

                Nuklear.nk_clear(Ctx);
            }

            FrameBuffered?.RenderFinal();
        }