Пример #1
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);
     }
 }
Пример #2
0
        public static NkWindow nk_create_window(NkContext ctx)
        {
            var result = new NkWindow {
                Seq = ctx.Seq
            };

            return(result);
        }
Пример #3
0
        public static void nk_free_window(NkContext ctx, NkWindow win)
        {
            nk_table it = win.Tables;

            if (win.Popup.win != null)
            {
                nk_free_window(ctx, win.Popup.win);
                win.Popup.win = null;
            }

            win.Next = null;
            win.Prev = null;
            while (it != null)
            {
                var n = it.next;
                nk_remove_table(win, it);
                if (it == win.Tables)
                {
                    win.Tables = n;
                }
                it = n;
            }
        }
Пример #4
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));
        }
Пример #5
0
 public void PanelAllocRow(NkWindow win)
 {
     Nk.nk_panel_alloc_row(_ctx, win);
 }
Пример #6
0
 public void PanelLayout(NkWindow win, float height, int cols)
 {
     Nk.nk_panel_layout(_ctx, win, height, cols);
 }
Пример #7
0
 public void RemoveWindow(NkWindow win)
 {
     Nk.nk_remove_window(_ctx, win);
 }
Пример #8
0
 public void InsertWindow(NkWindow win, int loc)
 {
     Nk.nk_insert_window(_ctx, win, loc);
 }
Пример #9
0
 public uint *AddValue(NkWindow win, uint name, uint value)
 {
     return(Nk.nk_add_value(_ctx, win, name, value));
 }
Пример #10
0
 public void Start(NkWindow win)
 {
     Nk.nk_start(_ctx, win);
 }
Пример #11
0
 public bool ComboBegin(NkWindow win, NkVec2 size, int is_clicked, NkRect header)
 {
     return(Nk.nk_combo_begin(_ctx, win, size, is_clicked, header) != 0);
 }
Пример #12
0
 public NkChartEvent ChartPushColumn(NkWindow win, NkChart chart, float value, int slot)
 {
     return(Nk.nk_chart_push_column(_ctx, win, chart, value, slot));
 }
Пример #13
0
 public NkChartEvent ChartPushLine(NkWindow win, NkChart g, float value, int slot)
 {
     return(Nk.nk_chart_push_line(_ctx, win, g, value, slot));
 }