Ejemplo n.º 1
0
        public static NkCommandBase nk_command_buffer_push(NkCommandBuffer b, NkCommandType t)
        {
            if (b == null || t < 0 || (int)t >= CommandCreators.Length || CommandCreators[(int)t] == null)
            {
                return(null);
            }

            var creator = CommandCreators[(int)t];

            var command = (NkCommandBase)creator();

            command.Header = new nk_command
            {
                type = t
            };

            if (b.Last == null)
            {
                b.First = command;
                b.Last  = command;
            }
            else
            {
                b.Last.Next = command;
                b.Last      = command;
            }

            ++b.Count;

            return(command);
        }
Ejemplo n.º 2
0
 public static void nk_command_buffer_reset(NkCommandBuffer cmdbuf)
 {
     if (cmdbuf == null)
     {
         return;
     }
     cmdbuf.First = cmdbuf.Last = null;
     cmdbuf.Count = 0;
     cmdbuf.Clip  = nk_null_rect;
 }
Ejemplo n.º 3
0
        public static void nk_fill_polygon(NkCommandBuffer b, float *points, int pointCount, NkColor col)
        {
            if (b == null || col.a == 0)
            {
                return;
            }
            var cmd = (NkCommandPolygonFilled)nk_command_buffer_push(b, NkCommandType.POLYGON_FILLED);

            if (cmd == null)
            {
                return;
            }
            cmd.Color      = col;
            cmd.PointCount = (ushort)pointCount;
            cmd.Points     = new NkPoint[pointCount];
            for (var i = 0; i < pointCount; ++i)
            {
                cmd.Points[i].x = (short)points[i * 2 + 0];
                cmd.Points[i].y = (short)points[i * 2 + 1];
            }
        }
Ejemplo n.º 4
0
        public static void nk_stroke_polygon(NkCommandBuffer b, float *points, int pointCount, float lineThickness,
                                             NkColor col)
        {
            if (b == null || col.a == 0 || lineThickness <= 0)
            {
                return;
            }
            var cmd = (NkCommandPolygon)nk_command_buffer_push(b, NkCommandType.POLYGON);

            if (cmd == null)
            {
                return;
            }
            cmd.Color         = col;
            cmd.LineThickness = (ushort)lineThickness;
            cmd.PointCount    = (ushort)pointCount;
            cmd.Points        = new NkPoint[pointCount];
            for (var i = 0; i < pointCount; ++i)
            {
                cmd.Points[i].x = (short)points[i * 2];
                cmd.Points[i].y = (short)points[i * 2 + 1];
            }
        }
Ejemplo n.º 5
0
 public static void nk_command_buffer_init(NkCommandBuffer cmdbuf, bool clip)
 {
     cmdbuf.UseClipping = clip;
     cmdbuf.First       = cmdbuf.Last = null;
     cmdbuf.Count       = 0;
 }
Ejemplo n.º 6
0
 public void StartBuffer(NkCommandBuffer buffer)
 {
     Nk.nk_start_buffer(_ctx, buffer);
 }