public bool MenuBeginImageLabel(string title, Alignment align, NkImage img, NkVec2 size)
 {
     fixed(char *title_ptr = title)
     {
         return(Nk.nk_menu_begin_image_label(_ctx, title_ptr, align, img, size) != 0);
     }
 }
        public static void nk_textedit_layout_row(nk_text_edit_row *r, nk_text_edit edit, int line_start_id, float row_height,
                                                  NkUserFont font)
        {
            int   glyphs = (int)(0);
            char *remaining;
            int   len = (int)(edit._string_.Len);

            fixed(char *str2 = edit._string_.Str)
            {
                char *end = str2 + len;

                char * text = str2 + line_start_id;
                NkVec2 size =
                    (NkVec2)
                    (nk_text_calculate_text_bounds(font, text, (int)(end - text), (float)(row_height), &remaining, null, &glyphs,
                                                   true));

                r->x0 = (float)(0.0f);
                r->x1 = (float)(size.x);
                r->baseline_y_delta = (float)(size.y);
                r->ymin             = (float)(0.0f);
                r->ymax             = (float)(size.y);
                r->num_chars        = (int)(glyphs);
            }
        }
 public bool ComboBeginImageLabel(string selected, NkImage img, NkVec2 size)
 {
     fixed(char *selected_ptr = selected)
     {
         return(Nk.nk_combo_begin_image_label(_ctx, selected_ptr, img, size) != 0);
     }
 }
 public bool ComboBeginSymbolLabel(string selected, NkSymbolType type, NkVec2 size)
 {
     fixed(char *selected_ptr = selected)
     {
         return(Nk.nk_combo_begin_symbol_label(_ctx, selected_ptr, type, size) != 0);
     }
 }
 public bool ComboBeginSymbolText(string selected, NkSymbolType symbol, NkVec2 size)
 {
     fixed(char *selected_ptr = selected)
     {
         return(Nk.nk_combo_begin_symbol_text(_ctx, selected_ptr, selected.Length, symbol, size) != 0);
     }
 }
 public bool MenuBeginSymbolLabel(string title, Alignment align, int sym, NkVec2 size)
 {
     fixed(char *title_ptr = title)
     {
         return(Nk.nk_menu_begin_symbol_label(_ctx, title_ptr, align, sym, size) != 0);
     }
 }
 public bool MenuBeginImage(string id, NkImage img, NkVec2 size)
 {
     fixed(char *id_ptr = id)
     {
         return(Nk.nk_menu_begin_image(_ctx, id_ptr, img, size) != 0);
     }
 }
 public bool MenuBeginText(string title, Alignment align, NkVec2 size)
 {
     fixed(char *title_ptr = title)
     {
         return(Nk.nk_menu_begin_text(_ctx, title_ptr, title.Length, align, size) != 0);
     }
 }
 public bool MenuBeginLabel(string text, Alignment align, NkVec2 size)
 {
     fixed(char *text_ptr = text)
     {
         return(Nk.nk_menu_begin_label(_ctx, text_ptr, align, size) != 0);
     }
 }
 public bool ComboBeginImageText(string selected, NkImage img, NkVec2 size)
 {
     fixed(char *selected_ptr = selected)
     {
         return(Nk.nk_combo_begin_image_text(_ctx, selected_ptr, selected.Length, img, size) != 0);
     }
 }
 public void WindowSetSize(string name, NkVec2 size)
 {
     fixed(char *name_ptr = name)
     {
         Nk.nk_window_set_size(_ctx, name_ptr, size);
     }
 }
 public bool MenuBeginSymbol(string id, NkSymbolType sym, NkVec2 size)
 {
     fixed(char *id_ptr = id)
     {
         return(Nk.nk_menu_begin_symbol(_ctx, id_ptr, sym, size) != 0);
     }
 }
 public void WindowSetPosition(string name, NkVec2 pos)
 {
     fixed(char *name_ptr = name)
     {
         Nk.nk_window_set_position(_ctx, name_ptr, pos);
     }
 }
        public void ComboboxCallback(NkComboCallback item_getter, IntPtr userdata, ref int selected, int count,
                                     int item_height, NkVec2 size)
        {
            int s = selected;

            Nk.nk_combobox_callback(_ctx, item_getter, userdata.ToPointer(), &s, count, item_height, size);
            selected = s;
        }
 public bool ComboString(string items_separated_by_zeros, int selected, int count, int item_height,
                         NkVec2 size)
 {
     fixed(char *items_separated_by_zeros_ptr = items_separated_by_zeros)
     {
         return(Nk.nk_combo_string(_ctx, items_separated_by_zeros_ptr, selected, count, item_height, size) != 0);
     }
 }
Beispiel #16
0
        public static NkVec2 nk_rect_size(NkRect r)
        {
            NkVec2 ret = new NkVec2();

            ret.x = (float)(r.w);
            ret.y = (float)(r.h);
            return((NkVec2)(ret));
        }
Beispiel #17
0
 public static NkRect nk_pad_rect(NkRect r, NkVec2 pad)
 {
     r.w  = (float)((r.w) < (2 * pad.x) ? (2 * pad.x) : (r.w));
     r.h  = (float)((r.h) < (2 * pad.y) ? (2 * pad.y) : (r.h));
     r.x += (float)(pad.x);
     r.y += (float)(pad.y);
     r.w -= (float)(2 * pad.x);
     r.h -= (float)(2 * pad.y);
     return((NkRect)(r));
 }
Beispiel #18
0
        public static NkVec2 nk_rect_pos(NkRect r)
        {
            NkVec2 ret = new NkVec2
            {
                x = r.x,
                y = r.y
            };

            return(ret);
        }
        public void ComboboxSeparator(string items_separated_by_separator, int separator, ref int selected, int count,
                                      int item_height, NkVec2 size)
        {
            fixed(char *items_separated_by_separator_ptr = items_separated_by_separator)
            {
                int s = selected;

                Nk.nk_combobox_separator(_ctx, items_separated_by_separator_ptr, separator, &s, count, item_height, size);
                selected = s;
            }
        }
Beispiel #20
0
        public static NkWidgetLayoutStates nk_widget_fitting(NkRect *bounds, NkContext ctx, NkVec2 item_padding)
        {
            NkWindow             win;
            NkStyle              style;
            NkPanel              layout;
            NkWidgetLayoutStates state;
            NkVec2 panel_padding = new NkVec2();

            if (((ctx == null) || (ctx.Current == null)) || (ctx.Current.Layout == null))
            {
                return(NkWidgetLayoutStates.NK_WIDGET_INVALID);
            }
            win           = ctx.Current;
            style         = ctx.Style;
            layout        = win.Layout;
            state         = (nk_widget(bounds, ctx));
            panel_padding = (NkVec2)(nk_panel_get_padding(style, (layout.Type)));
            if ((layout.Row.index) == (1))
            {
                bounds->w += (float)(panel_padding.x);
                bounds->x -= (float)(panel_padding.x);
            }
            else
            {
                bounds->x -= (float)(item_padding.x);
            }
            if ((layout.Row.index) == (layout.Row.columns))
            {
                bounds->w += (float)(panel_padding.x);
            }
            else
            {
                bounds->w += (float)(item_padding.x);
            }
            return(state);
        }
Beispiel #21
0
        public static void nk_layout_widget_space(NkRect *bounds, NkContext ctx, NkWindow win, int modify)
        {
            NkPanel layout;
            NkStyle style;
            NkVec2  spacing      = new NkVec2();
            NkVec2  padding      = new NkVec2();
            float   item_offset  = (float)(0);
            float   item_width   = (float)(0);
            float   item_spacing = (float)(0);
            float   panel_space  = (float)(0);

            if (((ctx == null) || (ctx.Current == null)) || (ctx.Current.Layout == null))
            {
                return;
            }
            win         = ctx.Current;
            layout      = win.Layout;
            style       = ctx.Style;
            spacing     = (NkVec2)(style.Window.spacing);
            padding     = (NkVec2)(nk_panel_get_padding(style, (layout.Type)));
            panel_space =
                (float)
                (nk_layout_row_calculate_usable_space(ctx.Style, (layout.Type), (float)(layout.Bounds.w),
                                                      (int)(layout.Row.columns)));
            switch (layout.Row.type)
            {
            case NkPanelRowLayoutType.DYNAMIC_FIXED:
            {
                item_width   = (float)(((1.0f) < (panel_space - 1.0f) ? (panel_space - 1.0f) : (1.0f)) / (float)(layout.Row.columns));
                item_offset  = (float)((float)(layout.Row.index) * item_width);
                item_spacing = (float)((float)(layout.Row.index) * spacing.x);
            }
            break;

            case NkPanelRowLayoutType.DYNAMIC_ROW:
            {
                item_width   = (float)(layout.Row.item_width * panel_space);
                item_offset  = (float)(layout.Row.item_offset);
                item_spacing = (float)(0);
                if ((modify) != 0)
                {
                    layout.Row.item_offset += (float)(item_width + spacing.x);
                    layout.Row.filled      += (float)(layout.Row.item_width);
                    layout.Row.index        = (int)(0);
                }
            }
            break;

            case NkPanelRowLayoutType.DYNAMIC_FREE:
            {
                bounds->x  = (float)(layout.AtX + (layout.Bounds.w * layout.Row.item.x));
                bounds->x -= ((float)(layout.Offset.x));
                bounds->y  = (float)(layout.AtY + (layout.Row.height * layout.Row.item.y));
                bounds->y -= ((float)(layout.Offset.y));
                bounds->w  = (float)(layout.Bounds.w * layout.Row.item.w);
                bounds->h  = (float)(layout.Row.height * layout.Row.item.h);
                return;
            }

            case NkPanelRowLayoutType.DYNAMIC:
            {
                float ratio;
                ratio =
                    (float)
                    (((layout.Row.ratio[layout.Row.index]) < (0)) ? layout.Row.item_width : layout.Row.ratio[layout.Row.index]);
                item_spacing = (float)((float)(layout.Row.index) * spacing.x);
                item_width   = (float)(ratio * panel_space);
                item_offset  = (float)(layout.Row.item_offset);
                if ((modify) != 0)
                {
                    layout.Row.item_offset += (float)(item_width);
                    layout.Row.filled      += (float)(ratio);
                }
            }
            break;

            case NkPanelRowLayoutType.STATIC_FIXED:
            {
                item_width   = (float)(layout.Row.item_width);
                item_offset  = (float)((float)(layout.Row.index) * item_width);
                item_spacing = (float)((float)(layout.Row.index) * spacing.x);
            }
            break;

            case NkPanelRowLayoutType.STATIC_ROW:
            {
                item_width   = (float)(layout.Row.item_width);
                item_offset  = (float)(layout.Row.item_offset);
                item_spacing = (float)((float)(layout.Row.index) * spacing.x);
                if ((modify) != 0)
                {
                    layout.Row.item_offset += (float)(item_width);
                }
            }
            break;

            case NkPanelRowLayoutType.STATIC_FREE:
            {
                bounds->x = (float)(layout.AtX + layout.Row.item.x);
                bounds->w = (float)(layout.Row.item.w);
                if (((bounds->x + bounds->w) > (layout.MaxX)) && ((modify) != 0))
                {
                    layout.MaxX = (float)(bounds->x + bounds->w);
                }
                bounds->x -= ((float)(layout.Offset.x));
                bounds->y  = (float)(layout.AtY + layout.Row.item.y);
                bounds->y -= ((float)(layout.Offset.y));
                bounds->h  = (float)(layout.Row.item.h);
                return;
            }

            case NkPanelRowLayoutType.STATIC:
            {
                item_spacing = (float)((float)(layout.Row.index) * spacing.x);
                item_width   = (float)(layout.Row.ratio[layout.Row.index]);
                item_offset  = (float)(layout.Row.item_offset);
                if ((modify) != 0)
                {
                    layout.Row.item_offset += (float)(item_width);
                }
            }
            break;

            case NkPanelRowLayoutType.TEMPLATE:
            {
                item_width   = (float)(layout.Row.templates[layout.Row.index]);
                item_offset  = (float)(layout.Row.item_offset);
                item_spacing = (float)((float)(layout.Row.index) * spacing.x);
                if ((modify) != 0)
                {
                    layout.Row.item_offset += (float)(item_width);
                }
            }
            break;

            default:
                ;
                break;
            }

            bounds->w = (float)(item_width);
            bounds->h = (float)(layout.Row.height - spacing.y);
            bounds->y = (float)(layout.AtY - (float)(layout.Offset.y));
            bounds->x = (float)(layout.AtX + item_offset + item_spacing + padding.x);
            if (((bounds->x + bounds->w) > (layout.MaxX)) && ((modify) != 0))
            {
                layout.MaxX = (float)(bounds->x + bounds->w);
            }
            bounds->x -= ((float)(layout.Offset.x));
        }
Beispiel #22
0
 public static NkRect nk_recta(NkVec2 pos, NkVec2 size)
 {
     return((NkRect)(nk_rect_((float)(pos.x), (float)(pos.y), (float)(size.x), (float)(size.y))));
 }
 public bool StylePushVec2(NkVec2 *address, NkVec2 value)
 {
     return(Nk.nk_style_push_vec2(_ctx, address, value) != 0);
 }
 public NkVec2 LayoutSpaceToLocal(NkVec2 ret)
 {
     return(Nk.nk_layout_space_to_local(_ctx, ret));
 }
 public NkVec2 LayoutSpaceToScreen(NkVec2 ret)
 {
     return(Nk.nk_layout_space_to_screen(_ctx, ret));
 }
 public void InputScroll(NkVec2 val)
 {
     Nk.nk_input_scroll(_ctx, val);
 }
 public bool ComboCallback(NkComboCallback item_getter, IntPtr userdata, int selected, int count,
                           int item_height, NkVec2 size)
 {
     return(Nk.nk_combo_callback(_ctx, item_getter, userdata.ToPointer(), selected, count, item_height, size) != 0);
 }
 public bool MenuBegin(NkWindow win, string id, int is_clicked, NkRect header, NkVec2 size)
 {
     fixed(char *id_ptr = id)
     {
         return(Nk.nk_menu_begin(_ctx, win, id_ptr, is_clicked, header, size) != 0);
     }
 }
 public bool ComboBeginSymbol(NkSymbolType symbol, NkVec2 size)
 {
     return(Nk.nk_combo_begin_symbol(_ctx, symbol, size) != 0);
 }
 public bool ComboBeginImage(NkImage img, NkVec2 size)
 {
     return(Nk.nk_combo_begin_image(_ctx, img, size) != 0);
 }