public static int nk_toggle_behavior(nk_input _in_, NkRect select, ref NkWidgetStates state, int active)
        {
            if (((state) & NkWidgetStates.MODIFIED) != 0)
            {
                (state) = (NkWidgetStates.INACTIVE | NkWidgetStates.MODIFIED);
            }
            else
            {
                (state) = (NkWidgetStates.INACTIVE);
            }
            if ((nk_button_behavior(ref state, select, _in_, NkButtonBehavior.Default)) != 0)
            {
                state  = (NkWidgetStates.ACTIVE);
                active = active != 0 ? 0 : 1;
            }

            if (((state & NkWidgetStates.HOVER) != 0) && (nk_input_is_mouse_prev_hovering_rect(_in_, (NkRect)(select)) == 0))
            {
                state |= (NkWidgetStates.ENTERED);
            }
            else if ((nk_input_is_mouse_prev_hovering_rect(_in_, (NkRect)(select))) != 0)
            {
                state |= (NkWidgetStates.LEFT);
            }
            return((int)(active));
        }
Exemplo n.º 2
0
        public static bool DoButtonImage(ref uint state, CommandBuffer _out_, RectangleF bounds, nk_image img,
                                         int b,
                                         nk_style_button style, nk_input _in_)
        {
            bool ret;
            var  content = new RectangleF();

            if (_out_ == null || style == null)
            {
                return(false);
            }
            ret             = DoButton(ref state, _out_, bounds, style, _in_, b, &content);
            content.X      += style.image_padding.X;
            content.Y      += style.image_padding.Y;
            content.Width  -= 2 * style.image_padding.X;
            content.Height -= 2 * style.image_padding.Y;
            if (style.draw_begin != null)
            {
                style.draw_begin(_out_);
            }
            _out_.DrawButtonImage(&bounds, &content, state, style, img);
            if (style.draw_end != null)
            {
                style.draw_end(_out_);
            }
            return(ret);
        }
Exemplo n.º 3
0
        public static void PropertyBehavior(ref uint ws, nk_input _in_, RectangleF property, RectangleF label,
                                            RectangleF edit,
                                            RectangleF empty, ref int state, nk_property_variant *variant, float inc_per_pixel)
        {
            if (_in_ != null && state == NK_PROPERTY_DEFAULT)
            {
                if (ButtonBehavior(ref ws, edit, _in_, NK_BUTTON_DEFAULT))
                {
                    state = NK_PROPERTY_EDIT;
                }
                else if (nk_input_is_mouse_click_down_in_rect(_in_, NK_BUTTON_LEFT, label, true))
                {
                    state = NK_PROPERTY_DRAG;
                }
                else if (nk_input_is_mouse_click_down_in_rect(_in_, NK_BUTTON_LEFT, empty, true))
                {
                    state = NK_PROPERTY_DRAG;
                }
            }

            if (state == NK_PROPERTY_DRAG)
            {
                DrawBehavior(ref ws, _in_, property, variant, inc_per_pixel);
                if ((ws & NK_WIDGET_STATE_ACTIVED) == 0)
                {
                    state = NK_PROPERTY_DEFAULT;
                }
            }
        }
        public static int nk_toggle_behavior(nk_input _in_, nk_rect select, ref uint state, int active)
        {
            if (((state) & NK_WIDGET_STATE_MODIFIED) != 0)
            {
                (state) = (uint)(NK_WIDGET_STATE_INACTIVE | NK_WIDGET_STATE_MODIFIED);
            }
            else
            {
                (state) = (uint)(NK_WIDGET_STATE_INACTIVE);
            }
            if ((nk_button_behavior(ref state, (nk_rect)(select), _in_, (int)(NK_BUTTON_DEFAULT))) != 0)
            {
                state  = (uint)(NK_WIDGET_STATE_ACTIVE);
                active = active != 0 ? 0 : 1;
            }

            if (((state & NK_WIDGET_STATE_HOVER) != 0) && (nk_input_is_mouse_prev_hovering_rect(_in_, (nk_rect)(select)) == 0))
            {
                state |= (uint)(NK_WIDGET_STATE_ENTERED);
            }
            else if ((nk_input_is_mouse_prev_hovering_rect(_in_, (nk_rect)(select))) != 0)
            {
                state |= (uint)(NK_WIDGET_STATE_LEFT);
            }
            return((int)(active));
        }
 public static int nk_input_is_mouse_down(nk_input i, NkButtons id)
 {
     if (i == null)
     {
         return((int)(nk_false));
     }
     return((int)(i.mouse.Buttons[(int)id].down));
 }
Exemplo n.º 6
0
 public static bool nk_input_is_mouse_down(nk_input i, int id)
 {
     if (i == null)
     {
         return(false);
     }
     return(i.mouse.buttons[id].down);
 }
Exemplo n.º 7
0
 public static bool nk_input_is_mouse_released(nk_input i, int id)
 {
     if (i == null)
     {
         return(false);
     }
     return((!i.mouse.buttons[id].down) && ((i.mouse.buttons[id].clicked) != 0));
 }
 public static int nk_input_is_mouse_released(nk_input i, NkButtons id)
 {
     if (i == null)
     {
         return((int)(nk_false));
     }
     return(((i.mouse.Buttons[(int)id].down == 0) && ((i.mouse.Buttons[(int)id].clicked) != 0)) ? 1 : 0);
 }
Exemplo n.º 9
0
        public static ulong ProgressBehavior(ref uint state, nk_input _in_, RectangleF r, RectangleF cursor,
                                             ulong max,
                                             ulong value, int modifiable)
        {
            var left_mouse_down            = false;
            var left_mouse_click_in_cursor = false;

            if ((state & NK_WIDGET_STATE_MODIFIED) != 0)
            {
                state = NK_WIDGET_STATE_INACTIVE | NK_WIDGET_STATE_MODIFIED;
            }
            else
            {
                state = NK_WIDGET_STATE_INACTIVE;
            }
            if (_in_ == null || modifiable == 0)
            {
                return(value);
            }
            left_mouse_down            = _in_ != null && _in_.mouse.buttons[NK_BUTTON_LEFT].down;
            left_mouse_click_in_cursor =
                _in_ != null &&
                nk_input_has_mouse_click_down_in_rect(_in_, NK_BUTTON_LEFT, cursor, true);
            if (nk_input_is_mouse_hovering_rect(_in_, r))
            {
                state = NK_WIDGET_STATE_HOVERED;
            }
            if (_in_ != null && left_mouse_down && left_mouse_click_in_cursor)
            {
                if (left_mouse_down && left_mouse_click_in_cursor)
                {
                    var ratio = (0 < _in_.mouse.pos.X - cursor.X ? _in_.mouse.pos.X - cursor.X : 0) /
                                cursor.Width;
                    value =
                        (ulong)
                        (((float)max * ratio < (float)max ? (float)max * ratio : (float)max) <
                         0
                                                        ? 0
                                                        : (float)max * ratio < (float)max
                                                                ? (float)max * ratio
                                                                : (float)max);
                    _in_.mouse.buttons[NK_BUTTON_LEFT].clicked_pos.X =
                        cursor.X + cursor.Width / 2.0f;
                    state |= NK_WIDGET_STATE_ACTIVE;
                }
            }

            if ((state & NK_WIDGET_STATE_HOVER) != 0 &&
                !nk_input_is_mouse_prev_hovering_rect(_in_, r))
            {
                state |= NK_WIDGET_STATE_ENTERED;
            }
            else if (nk_input_is_mouse_prev_hovering_rect(_in_, r))
            {
                state |= NK_WIDGET_STATE_LEFT;
            }
            return(value);
        }
Exemplo n.º 10
0
 public static bool nk_input_is_mouse_prev_hovering_rect(nk_input i, RectangleF rect)
 {
     if (i == null)
     {
         return(false);
     }
     return((((rect.X) <= (i.mouse.prev.X)) && ((i.mouse.prev.X) < (rect.X + rect.Width))) &&
            (((rect.Y) <= (i.mouse.prev.Y)) && ((i.mouse.prev.Y) < (rect.Y + rect.Height))));
 }
Exemplo n.º 11
0
        public static int nk_input_any_mouse_click_in_rect(nk_input _in_, NkRect b)
        {
            int i;
            int down = (int)(0);

            for (i = (int)(0); (i) < ((int)NkButtons.MAX); ++i)
            {
                down = (int)(((down) != 0) || ((nk_input_is_mouse_click_in_rect(_in_, (NkButtons)(i), (NkRect)(b))) != 0) ? 1 : 0);
            }
            return((int)(down));
        }
Exemplo n.º 12
0
        public static bool nk_input_any_mouse_click_in_rect(nk_input _in_, RectangleF b)
        {
            int  i;
            bool down = false;

            for (i = (int)(0); (i) < (NK_BUTTON_MAX); ++i)
            {
                down = (((down)) || ((nk_input_is_mouse_click_in_rect(_in_, (int)(i), (RectangleF)(b)))));
            }
            return(down);
        }
        public static int nk_input_any_mouse_click_in_rect(nk_input _in_, nk_rect b)
        {
            int i;
            int down = (int)(0);

            for (i = (int)(0); (i) < (NK_BUTTON_MAX); ++i)
            {
                down = (int)(((down) != 0) || ((nk_input_is_mouse_click_in_rect(_in_, (int)(i), (nk_rect)(b))) != 0) ? 1 : 0);
            }
            return((int)(down));
        }
Exemplo n.º 14
0
        public static bool nk_input_has_mouse_click(nk_input i, int id)
        {
            nk_mouse_button btn;

            if (i == null)
            {
                return(false);
            }
            btn = i.mouse.buttons[id];
            return(((btn.clicked) != 0) && (!btn.down));
        }
Exemplo n.º 15
0
        public static bool nk_input_has_mouse_click_down_in_rect(nk_input i, int id, RectangleF b, bool down)
        {
            nk_mouse_button btn;

            if (i == null)
            {
                return(false);
            }
            btn = i.mouse.buttons[id];
            return(((nk_input_has_mouse_click_in_rect(i, (int)(id), (RectangleF)(b)))) && ((btn.down) == (down)));
        }
Exemplo n.º 16
0
 public static int nk_input_is_mouse_prev_hovering_rect(nk_input i, NkRect rect)
 {
     if (i == null)
     {
         return((int)(nk_false));
     }
     return((((rect.x) <= (i.mouse.Prev.x)) && ((i.mouse.Prev.x) < (rect.x + rect.w))) &&
            (((rect.y) <= (i.mouse.Prev.y)) && ((i.mouse.Prev.y) < (rect.y + rect.h)))
         ? 1
         : 0);
 }
Exemplo n.º 17
0
        public static int nk_input_has_mouse_click(nk_input i, NkButtons id)
        {
            nk_mouse_button *btn;

            if (i == null)
            {
                return((int)(nk_false));
            }
            btn = (nk_mouse_button *)i.mouse.Buttons + (int)id;
            return((int)((((btn->clicked) != 0) && ((btn->down) == (nk_false))) ? nk_true : nk_false));
        }
Exemplo n.º 18
0
 public static int nk_input_mouse_clicked(nk_input i, NkButtons id, NkRect rect)
 {
     if (i == null)
     {
         return((int)(nk_false));
     }
     if (nk_input_is_mouse_hovering_rect(i, (NkRect)(rect)) == 0)
     {
         return((int)(nk_false));
     }
     return((int)(nk_input_is_mouse_click_in_rect(i, (id), (NkRect)(rect))));
 }
Exemplo n.º 19
0
        public static int nk_input_has_mouse_click_down_in_rect(nk_input i, NkButtons id, NkRect b, int down)
        {
            nk_mouse_button *btn;

            if (i == null)
            {
                return((int)(nk_false));
            }
            btn = (nk_mouse_button *)i.mouse.Buttons + (int)id;
            return
                ((int)(((nk_input_has_mouse_click_in_rect(i, (id), (NkRect)(b))) != 0) && ((btn->down) == (down)) ? 1 : 0));
        }
Exemplo n.º 20
0
 public static bool nk_input_mouse_clicked(nk_input i, int id, RectangleF rect)
 {
     if (i == null)
     {
         return(false);
     }
     if (!nk_input_is_mouse_hovering_rect(i, (RectangleF)(rect)))
     {
         return(false);
     }
     return(nk_input_is_mouse_click_in_rect(i, (int)(id), (RectangleF)(rect)));
 }
Exemplo n.º 21
0
        public static int nk_input_is_key_down(nk_input i, int key)
        {
            nk_key *k;

            if (i == null)
            {
                return((int)(nk_false));
            }
            k = (nk_key *)i.keyboard.Keys + key;
            if ((k->down) != 0)
            {
                return((int)(nk_true));
            }
            return((int)(nk_false));
        }
Exemplo n.º 22
0
        public static bool nk_input_is_key_down(nk_input i, int key)
        {
            nk_key k;

            if (i == null)
            {
                return(false);
            }
            k = i.keyboard.keys[key];
            if (k.down)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 23
0
        public static bool nk_input_is_key_released(nk_input i, int key)
        {
            nk_key k;

            if (i == null)
            {
                return(false);
            }
            k = i.keyboard.keys[key];
            if (((!k.down) && ((k.clicked) != 0)) || ((k.down) && ((k.clicked) >= (2))))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 24
0
        public static bool nk_input_is_mouse_pressed(nk_input i, int id)
        {
            nk_mouse_button b;

            if (i == null)
            {
                return(false);
            }
            b = i.mouse.buttons[id];
            if ((b.down) && ((b.clicked) != 0))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 25
0
        public static int nk_input_is_key_released(nk_input i, int key)
        {
            nk_key *k;

            if (i == null)
            {
                return((int)(nk_false));
            }
            k = (nk_key *)i.keyboard.Keys + key;
            if (((k->down == 0) && ((k->clicked) != 0)) || (((k->down) != 0) && ((k->clicked) >= (2))))
            {
                return((int)(nk_true));
            }
            return((int)(nk_false));
        }
Exemplo n.º 26
0
        public static int nk_input_is_mouse_pressed(nk_input i, NkButtons id)
        {
            nk_mouse_button *b;

            if (i == null)
            {
                return((int)(nk_false));
            }
            b = (nk_mouse_button *)i.mouse.Buttons + (int)id;
            if (((b->down) != 0) && ((b->clicked) != 0))
            {
                return((int)(nk_true));
            }
            return((int)(nk_false));
        }
        public static int nk_input_is_mouse_click_down_in_rect(nk_input i, int id, nk_rect b, int down)
        {
            nk_mouse_button *btn;

            if (i == null)
            {
                return((int)(nk_false));
            }
            btn = (nk_mouse_button *)i.mouse.buttons + id;
            return
                ((int)
                 ((((nk_input_has_mouse_click_down_in_rect(i, (int)(id), (nk_rect)(b), (int)(down))) != 0) &&
                   ((btn->clicked) != 0))
                                                ? nk_true
                                                : nk_false));
        }
Exemplo n.º 28
0
        public static int nk_input_has_mouse_click_in_rect(nk_input i, NkButtons id, NkRect b)
        {
            nk_mouse_button *btn;

            if (i == null)
            {
                return((int)(nk_false));
            }
            btn = (nk_mouse_button *)i.mouse.Buttons + (int)id;
            if (
                !((((b.x) <= (btn->clicked_pos.x)) && ((btn->clicked_pos.x) < (b.x + b.w))) &&
                  (((b.y) <= (btn->clicked_pos.y)) && ((btn->clicked_pos.y) < (b.y + b.h)))))
            {
                return((int)(nk_false));
            }
            return((int)(nk_true));
        }
Exemplo n.º 29
0
        public static bool nk_input_has_mouse_click_in_rect(nk_input i, int id, RectangleF b)
        {
            nk_mouse_button btn;

            if (i == null)
            {
                return(false);
            }
            btn = i.mouse.buttons[id];
            if (
                !((((b.X) <= (btn.clicked_pos.X)) && ((btn.clicked_pos.X) < (b.X + b.Width))) &&
                  (((b.Y) <= (btn.clicked_pos.Y)) && ((btn.clicked_pos.Y) < (b.Y + b.Height)))))
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 30
0
        public static bool DoButton(ref uint state, CommandBuffer _out_, RectangleF r, nk_style_button style,
                                    nk_input _in_, int behavior, RectangleF *content)
        {
            var bounds = new RectangleF();

            if (_out_ == null || style == null)
            {
                return(false);
            }
            content->X      = r.X + style.padding.X + style.border + style.Rounding;
            content->Y      = r.Y + style.padding.Y + style.border + style.Rounding;
            content->Width  = r.Width - (2 * style.padding.X + style.border + style.Rounding * 2);
            content->Height = r.Height - (2 * style.padding.Y + style.border + style.Rounding * 2);
            bounds.X        = r.X - style.touch_padding.X;
            bounds.Y        = r.Y - style.touch_padding.Y;
            bounds.Width    = r.Width + 2 * style.touch_padding.X;
            bounds.Height   = r.Height + 2 * style.touch_padding.Y;
            return(ButtonBehavior(ref state, bounds, _in_, behavior));
        }