Пример #1
0
        public static void DrawProgress(this CommandBuffer _out_, uint state, nk_style_progress style,
                                        RectangleF *bounds, RectangleF *scursor, ulong value, ulong max)
        {
            nk_style_item background;
            nk_style_item cursor;

            if ((state & NK_WIDGET_STATE_ACTIVED) != 0)
            {
                background = style.active;
                cursor     = style.cursor_active;
            }
            else if ((state & NK_WIDGET_STATE_HOVER) != 0)
            {
                background = style.hover;
                cursor     = style.cursor_hover;
            }
            else
            {
                background = style.normal;
                cursor     = style.cursor_normal;
            }

            if (background.type == NK_STYLE_ITEM_COLOR)
            {
                _out_.FillRect(*bounds, style.Rounding, background.Color);
                _out_.StrokeRect(*bounds, style.Rounding, style.border,
                                 style.border_color);
            }
            else
            {
                _out_.DrawImage(*bounds, background.Image, nk_white);
            }

            if (cursor.type == NK_STYLE_ITEM_COLOR)
            {
                _out_.FillRect(*scursor, style.Rounding, cursor.Color);
                _out_.StrokeRect(*scursor, style.Rounding, style.border,
                                 style.border_color);
            }
            else
            {
                _out_.DrawImage(*scursor, cursor.Image, nk_white);
            }
        }
Пример #2
0
        public static ulong DoProgress(ref uint state, CommandBuffer _out_, RectangleF bounds, ulong value,
                                       ulong max,
                                       int modifiable, nk_style_progress style, nk_input _in_)
        {
            float prog_scale;
            ulong prog_value;
            var   cursor = new RectangleF();

            if (_out_ == null || style == null)
            {
                return(0);
            }
            cursor.Width =
                bounds.Width < 2 * style.padding.X + 2 * style.border
                                        ? 2 * style.padding.X + 2 * style.border
                                        : bounds.Width;
            cursor.Height =
                bounds.Height < 2 * style.padding.Y + 2 * style.border
                                        ? 2 * style.padding.Y + 2 * style.border
                                        : bounds.Height;
            cursor =
                RectangleF.nk_pad_rect(bounds,
                                       new Vector2(style.padding.X + style.border,
                                                   style.padding.Y + style.border));
            prog_scale = value / (float)max;
            prog_value = value < max ? value : max;
            prog_value =
                ProgressBehavior(ref state, _in_, bounds, cursor, max,
                                 prog_value,
                                 modifiable);
            cursor.Width = cursor.Width * prog_scale;
            if (style.draw_begin != null)
            {
                style.draw_begin(_out_);
            }
            _out_.DrawProgress(state, style, &bounds, &cursor, value, max);
            if (style.draw_end != null)
            {
                style.draw_end(_out_);
            }
            return(prog_value);
        }