예제 #1
0
        public static void nk_layout_peek(NkRect *bounds, NkContext ctx)
        {
            float    y;
            int      index;
            NkWindow win;
            NkPanel  layout;

            if (((ctx == null) || (ctx.Current == null)) || (ctx.Current.Layout == null))
            {
                return;
            }
            win    = ctx.Current;
            layout = win.Layout;
            y      = (float)(layout.AtY);
            index  = (int)(layout.Row.index);
            if ((layout.Row.index) >= (layout.Row.columns))
            {
                layout.AtY      += (float)(layout.Row.height);
                layout.Row.index = (int)(0);
            }

            nk_layout_widget_space(bounds, ctx, win, (int)(nk_false));
            if (layout.Row.index == 0)
            {
                bounds->x -= (float)(layout.Row.item_offset);
            }

            layout.AtY       = (float)(y);
            layout.Row.index = (int)(index);
        }
예제 #2
0
        public static void nk_panel_alloc_space(NkRect *bounds, NkContext ctx)
        {
            NkWindow win;
            NkPanel  layout;

            if (((ctx == null) || (ctx.Current == null)) || (ctx.Current.Layout == null))
            {
                return;
            }
            win    = ctx.Current;
            layout = win.Layout;
            if ((layout.Row.index) >= (layout.Row.columns))
            {
                nk_panel_alloc_row(ctx, win);
            }
            nk_layout_widget_space(bounds, ctx, win, (int)(nk_true));
            layout.Row.index++;
        }
예제 #3
0
        public static NkWidgetLayoutStates nk_widget(NkRect *bounds, NkContext ctx)
        {
            NkRect   c = new NkRect();
            NkRect   v = new NkRect();
            NkWindow win;
            NkPanel  layout;
            nk_input _in_;

            if (((ctx == null) || (ctx.Current == null)) || (ctx.Current.Layout == null))
            {
                return(NkWidgetLayoutStates.NK_WIDGET_INVALID);
            }
            nk_panel_alloc_space(bounds, ctx);
            win       = ctx.Current;
            layout    = win.Layout;
            _in_      = ctx.Input;
            c         = (NkRect)(layout.Clip);
            bounds->x = ((float)((int)(bounds->x)));
            bounds->y = ((float)((int)(bounds->y)));
            bounds->w = ((float)((int)(bounds->w)));
            bounds->h = ((float)((int)(bounds->h)));
            c.x       = ((float)((int)(c.x)));
            c.y       = ((float)((int)(c.y)));
            c.w       = ((float)((int)(c.w)));
            c.h       = ((float)((int)(c.h)));
            nk_unify(ref v, ref c, (float)(bounds->x), (float)(bounds->y), (float)(bounds->x + bounds->w),
                     (float)(bounds->y + bounds->h));
            if (
                !(!(((((bounds->x) > (c.x + c.w)) || ((bounds->x + bounds->w) < (c.x))) || ((bounds->y) > (c.y + c.h))) ||
                    ((bounds->y + bounds->h) < (c.y)))))
            {
                return(NkWidgetLayoutStates.NK_WIDGET_INVALID);
            }
            if (
                !((((v.x) <= (_in_.mouse.Pos.x)) && ((_in_.mouse.Pos.x) < (v.x + v.w))) &&
                  (((v.y) <= (_in_.mouse.Pos.y)) && ((_in_.mouse.Pos.y) < (v.y + v.h)))))
            {
                return(NkWidgetLayoutStates.NK_WIDGET_ROM);
            }
            return(NkWidgetLayoutStates.NK_WIDGET_VALID);
        }
예제 #4
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);
        }
예제 #5
0
 public static extern nk_widget_layout_states nk_widget_fitting(NkRect *r, nk_context *ctx, nk_vec2 v);
예제 #6
0
 public static extern nk_widget_layout_states nk_widget(NkRect *r, nk_context *ctx);
예제 #7
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));
        }