Пример #1
0
 internal UICursor(UINodeSet <T> nodes)
 {
     NodeSet = nodes;
     if (NodeSet.Any() && NodeSet.ActiveNode != null)
     {
         force_loc(NodeSet.ActiveNode.loc);
     }
 }
Пример #2
0
        private void UpdateMouse <T>(
            UINodeSet <T> nodes,
            ControlSet input,
            Vector2 draw_offset) where T : UINode
        {
            if (input.HasEnumFlag(ControlSet.MouseButtons))
            {
                bool input_used = update_mouse_input(
                    ref LeftMouseDown, MouseButtons.Left, draw_offset);
                if (RightClickActive && !input_used)
                {
                    update_mouse_input(
                        ref RightMouseDown, MouseButtons.Right, draw_offset);
                }
            }

            if (input.HasEnumFlag(ControlSet.MouseMove))
            {
                if (OnScreenBounds(draw_offset).Contains(
                        (int)Global.Input.mousePosition.X,
                        (int)Global.Input.mousePosition.Y))
                {
                    if (nodes != null)
                    {
                        nodes.MouseMove(this as T);
                    }

                    if (LeftMouseDown || RightMouseDown)
                    {
                        mouse_click_graphic();
                    }
                    else
                    {
                        mouse_highlight_graphic();
                    }
                }
            }

            if (input.HasEnumFlag(ControlSet.Mouse))
            {
                if (IsSlider && LeftMouseDown &&
                    OnScreenBounds(draw_offset).Contains(
                        (int)Global.Input.mousePosition.X,
                        (int)Global.Input.mousePosition.Y))
                {
                    TouchTriggers.Add(TouchGestures.Scrubbing);
                    SliderValue = slide(Global.Input.mousePosition, draw_offset);
                }
            }
        }
Пример #3
0
        internal void Update <T>(UINodeSet <T> nodes, ControlSet input,
                                 Vector2 draw_offset = default(Vector2)) where T : UINode
        {
            // If wrong type
            if (!(this is T))
            {
                return;
            }
            // If not in node set
            if (nodes != null && !nodes.Contains(this as T))
            {
                return;
            }

            bool active_node = false;

            if (!input.HasFlag(ControlSet.Disabled))
            {
                mouse_off_graphic();
                if (Enabled)
                {
                    if (Input.IsControllingOnscreenMouse)
                    {
                        UpdateMouse <T>(nodes, input, draw_offset);
                    }
                    else if (Input.ControlScheme == ControlSchemes.Touch)
                    {
                        UpdateTouch <T>(nodes, input, draw_offset);
                    }
                    else if (is_active_node <T>(nodes))
                    {
                        UpdateButtons <T>(input);
                    }
                }

                active_node = is_active_node <T>(nodes);
            }
            update_graphics(active_node);
        }
Пример #4
0
 internal void Update <T>(UINodeSet <T> nodes, bool input,
                          Vector2 draw_offset = default(Vector2)) where T : UINode
 {
     Update(nodes, input ? ControlSet.All : ControlSet.None, draw_offset);
 }
Пример #5
0
        private void UpdateTouch <T>(
            UINodeSet <T> nodes,
            ControlSet input,
            Vector2 draw_offset) where T : UINode
        {
            if (input.HasEnumFlag(ControlSet.Touch))
            {
                if (Global.Input.gesture_rectangle(
                        TouchGestures.Tap, OnScreenBounds(draw_offset)))
                {
                    if (nodes != null)
                    {
                        nodes.TouchMove(this as T, TouchGestures.Tap);
                    }
                    TouchTriggers.Add(TouchGestures.Tap);
                }
                else if (Global.Input.gesture_rectangle(
                             TouchGestures.LongPress, OnScreenBounds(draw_offset)))
                {
                    if (nodes != null)
                    {
                        nodes.TouchMove(this as T, TouchGestures.LongPress);
                    }
                    TouchTriggers.Add(TouchGestures.LongPress);
                }
                else if (Global.Input.touch_rectangle(
                             Services.Input.InputStates.Pressed,
                             OnScreenBounds(draw_offset),
                             false))
                {
                    if (nodes != null)
                    {
                        nodes.TouchMove(this as T, TouchGestures.ShortPress);
                    }
                    mouse_click_graphic();
                }

                if (IsSlider)
                {
                    if (!Global.Input.touch_pressed(false))
                    {
                        TouchPressing = false;
                    }
                    else
                    {
                        bool pressed = OnScreenBounds(draw_offset).Contains(
                            (int)Global.Input.touchPressPosition.X,
                            (int)Global.Input.touchPressPosition.Y);
                        if (pressed && Global.Input.touch_triggered(false))
                        {
                            TouchPressing = true;
                        }

                        if (pressed && TouchPressing)
                        {
                            TouchTriggers.Add(TouchGestures.Scrubbing);
                            SliderValue = slide(Global.Input.touchPressPosition, draw_offset);
                        }
                    }
                }
            }
        }
Пример #6
0
 private bool is_active_node <T>(UINodeSet <T> nodes) where T : UINode
 {
     return(nodes == null || nodes.ActiveNode == this);
 }