コード例 #1
0
        public override MyGuiControlBase HandleInput()
        {
            if (DraggedItem != null)
            {
                if (MyInput.Static.IsLeftMousePressed())
                {
                    float dragDistanceSquared = MyGuiManager.GetScreenSizeFromNormalizedSize(StartDragPosition - MyGuiManager.MouseCursorPosition).LengthSquared();
                    if (dragDistanceSquared > 16)   // Drag Detection Sensitivity - 4 pixels
                    {
                        Dragging = m_frameBackDragging = true;
                    }
                }
                else
                {
                    if (Drop != null && Dragging)
                    {
                        Drop(this, EventArgs.Empty);
                    }

                    Dragging    = false;
                    DraggedItem = null;
                }
            }

            return(base.HandleInput());
        }
コード例 #2
0
 public void DeleteItem(MyTreeViewItem item)
 {
     if (m_items.Remove(item))
     {
         item.TreeView = null;
         item.ClearItems();
     }
 }
コード例 #3
0
 public void DeleteItem(MyTreeViewItem item)
 {
     if (m_items.Remove(item))
     {
         item.TreeView = null;
         item.ClearItems();
     }
 }
コード例 #4
0
        public MyTreeViewItem AddItem(StringBuilder text, string icon, Vector2 iconSize, string expandIcon, string collapseIcon, Vector2 expandIconSize)
        {
            //System.Diagnostics.Trace.Assert(m_items.TrueForAll(a => a.GetIconSize() == iconSize));

            var item = new MyTreeViewItem(text, icon, iconSize, expandIcon, collapseIcon, expandIconSize);
            item.TreeView = TreeView;
            m_items.Add(item);
            item.Parent = this;
            return item;
        }
コード例 #5
0
        public MyTreeViewItem AddItem(StringBuilder text, string icon, Vector2 iconSize, string expandIcon, string collapseIcon, Vector2 expandIconSize)
        {
            //System.Diagnostics.Trace.Assert(m_items.TrueForAll(a => a.GetIconSize() == iconSize));

            var item = new MyTreeViewItem(text, icon, iconSize, expandIcon, collapseIcon, expandIconSize);

            item.TreeView = TreeView;
            m_items.Add(item);
            item.Parent = this;
            return(item);
        }
コード例 #6
0
        public void FocusItem(MyTreeViewItem item)
        {
            if (item != null)
            {
                Vector2 offset = MyGUIHelper.GetOffset(m_body.GetPosition(), m_body.GetSize(), item.GetPosition(), item.GetSize());

                m_vScrollbar.ChangeValue(-offset.Y);
                m_hScrollbar.ChangeValue(-offset.X);
            }

            FocusedItem = item;
        }
コード例 #7
0
 private MyTreeViewItem NextVisible(ITreeView iTreeView, MyTreeViewItem focused)
 {
     bool found = false;
     TraverseVisible(m_body, a =>
     {
         if (a == focused)
         {
             found = true;
         }
         else if (found)
         {
             focused = a;
             found = false;
         }
     }
     );
     return focused;
 }
コード例 #8
0
        private MyTreeViewItem PrevVisible(ITreeView iTreeView, MyTreeViewItem focused)
        {
            MyTreeViewItem pred = focused;

            TraverseVisible(m_body, a =>
            {
                if (a == focused)
                {
                    focused = pred;
                }
                else
                {
                    pred = a;
                }
            }
                            );
            return(focused);
        }
コード例 #9
0
 public bool HandleInput(MyTreeViewItem treeViewItem)
 {
     bool captured = false;
     if (DraggedItem == null)
     {
         if (MyGUIHelper.Contains(treeViewItem.GetPosition(), treeViewItem.GetSize(), MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y) &&
             treeViewItem.TreeView.Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y))
         {
             if (MyInput.Static.IsNewLeftMousePressed())
             {
                 Dragging = false;
                 DraggedItem = treeViewItem;
                 StartDragPosition = MyGuiManager.MouseCursorPosition;
                 captured = true;
             }
         }
     }
     return captured;
 }
コード例 #10
0
        private MyTreeViewItem NextVisible(ITreeView iTreeView, MyTreeViewItem focused)
        {
            bool found = false;

            TraverseVisible(m_body, a =>
            {
                if (a == focused)
                {
                    found = true;
                }
                else if (found)
                {
                    focused = a;
                    found   = false;
                }
            }
                            );
            return(focused);
        }
コード例 #11
0
        public bool HandleInput(MyTreeViewItem treeViewItem)
        {
            bool captured = false;

            if (DraggedItem == null)
            {
                if (MyGUIHelper.Contains(treeViewItem.GetPosition(), treeViewItem.GetSize(), MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y) &&
                    treeViewItem.TreeView.Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y))
                {
                    if (MyInput.Static.IsNewLeftMousePressed())
                    {
                        Dragging          = false;
                        DraggedItem       = treeViewItem;
                        StartDragPosition = MyGuiManager.MouseCursorPosition;
                        captured          = true;
                    }
                }
            }
            return(captured);
        }
コード例 #12
0
        public void DeleteItem(MyTreeViewItem item)
        {
            if (item == FocusedItem)
            {
                int index = item.GetIndex();
                if (index + 1 < GetItemCount())
                {
                    FocusedItem = GetItem(index + 1);
                }
                else if (index - 1 >= 0)
                {
                    FocusedItem = GetItem(index - 1);
                }
                else
                {
                    FocusedItem = FocusedItem.Parent as MyTreeViewItem;
                }
            }

            m_body.DeleteItem(item);
        }
コード例 #13
0
 public int GetIndex(MyTreeViewItem item)
 {
     return(m_items.IndexOf(item));
 }
コード例 #14
0
 public int GetIndex(MyTreeViewItem item)
 {
     return m_items.IndexOf(item);
 }
コード例 #15
0
        public bool HandleInput()
        {
            var oldHooveredItem = HooveredItem;

            HooveredItem = null;

            bool captured = m_body.HandleInput(m_control.HasFocus) ||
                            m_vScrollbar.HandleInput() ||
                            m_hScrollbar.HandleInput();

            if (m_control.HasFocus)
            {
                if (FocusedItem == null &&
                    m_body.GetItemCount() > 0 &&
                    (MyInput.Static.IsNewKeyPressed(MyKeys.Up) ||
                     MyInput.Static.IsNewKeyPressed(MyKeys.Down) ||
                     MyInput.Static.IsNewKeyPressed(MyKeys.Left) ||
                     MyInput.Static.IsNewKeyPressed(MyKeys.Right) ||
                     MyInput.Static.DeltaMouseScrollWheelValue() != 0))
                {
                    FocusItem(m_body[0]);
                }
                else if (FocusedItem != null)
                {
                    if (MyInput.Static.IsNewKeyPressed(MyKeys.Down) || (MyInput.Static.DeltaMouseScrollWheelValue() < 0 && Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y)))
                    {
                        FocusItem(NextVisible(m_body, FocusedItem));
                    }

                    if (MyInput.Static.IsNewKeyPressed(MyKeys.Up) || (MyInput.Static.DeltaMouseScrollWheelValue() > 0 && Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y)))
                    {
                        FocusItem(PrevVisible(m_body, FocusedItem));
                    }

                    if (MyInput.Static.IsNewKeyPressed(MyKeys.Right))
                    {
                        if (FocusedItem.GetItemCount() > 0)
                        {
                            if (!FocusedItem.IsExpanded)
                            {
                                FocusedItem.IsExpanded = true;
                            }
                            else
                            {
                                var next = NextVisible(FocusedItem, FocusedItem);
                                FocusItem(next);
                            }
                        }
                    }

                    if (MyInput.Static.IsNewKeyPressed(MyKeys.Left))
                    {
                        if (FocusedItem.GetItemCount() > 0 && FocusedItem.IsExpanded)
                        {
                            FocusedItem.IsExpanded = false;
                        }
                        else if (FocusedItem.Parent is MyTreeViewItem)
                        {
                            FocusItem(FocusedItem.Parent as MyTreeViewItem);
                        }
                    }

                    if (FocusedItem.GetItemCount() > 0)
                    {
                        if (MyInput.Static.IsNewKeyPressed(MyKeys.Add))
                        {
                            FocusedItem.IsExpanded = true;
                        }

                        if (MyInput.Static.IsNewKeyPressed(MyKeys.Subtract))
                        {
                            FocusedItem.IsExpanded = false;
                        }
                    }
                }

                if (MyInput.Static.IsNewKeyPressed(MyKeys.PageDown))
                {
                    m_vScrollbar.PageDown();
                }

                if (MyInput.Static.IsNewKeyPressed(MyKeys.PageUp))
                {
                    m_vScrollbar.PageUp();
                }

                captured = captured ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.PageDown) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.PageUp) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.Down) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.Up) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.Left) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.Right) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.Add) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.Subtract) ||
                           MyInput.Static.DeltaMouseScrollWheelValue() != 0;
            }

            // Hoovered item changed
            if (HooveredItem != oldHooveredItem)
            {
                m_control.ShowToolTip(HooveredItem == null ? null : HooveredItem.ToolTip);
                MyGuiSoundManager.PlaySound(GuiSounds.MouseOver);
            }

            return(captured);
        }
コード例 #16
0
 public void Init(MyTreeViewItem item, Vector2 startDragPosition)
 {
     Dragging = false;
     DraggedItem = item;
     StartDragPosition = startDragPosition;
 }
コード例 #17
0
 public void Init(MyTreeViewItem item, Vector2 startDragPosition)
 {
     Dragging          = false;
     DraggedItem       = item;
     StartDragPosition = startDragPosition;
 }
コード例 #18
0
 public void DeleteItem(MyTreeViewItem item)
 {
     m_treeView.DeleteItem(item);
 }
コード例 #19
0
 public void DeleteItem(MyTreeViewItem item)
 {
     m_treeView.DeleteItem(item);
 }
コード例 #20
0
 private MyTreeViewItem PrevVisible(ITreeView iTreeView, MyTreeViewItem focused)
 {
     MyTreeViewItem pred = focused;
     TraverseVisible(m_body, a =>
     {
         if (a == focused)
         {
             focused = pred;
         }
         else
         {
             pred = a;
         }
     }
     );
     return focused;
 }
コード例 #21
0
        public void FocusItem(MyTreeViewItem item)
        {
            if (item != null)
            {
                Vector2 offset = MyGUIHelper.GetOffset(m_body.GetPosition(), m_body.GetSize(), item.GetPosition(), item.GetSize());

                m_vScrollbar.ChangeValue(-offset.Y);
                m_hScrollbar.ChangeValue(-offset.X);
            }

            FocusedItem = item;
        }
コード例 #22
0
        public void DeleteItem(MyTreeViewItem item)
        {
            if (item == FocusedItem)
            {
                int index = item.GetIndex();
                if (index + 1 < GetItemCount())
                {
                    FocusedItem = GetItem(index + 1);
                }
                else if (index - 1 >= 0)
                {
                    FocusedItem = GetItem(index - 1);
                }
                else
                {
                    FocusedItem = FocusedItem.Parent as MyTreeViewItem;
                }
            }

            m_body.DeleteItem(item);
        }
コード例 #23
0
        public bool HandleInput()
        {
            var oldHooveredItem = HooveredItem;
            HooveredItem = null;

            bool captured = m_body.HandleInput(m_control.HasFocus) ||
                            m_vScrollbar.HandleInput() ||
                            m_hScrollbar.HandleInput();

            if (m_control.HasFocus)
            {
                if (FocusedItem == null &&
                    m_body.GetItemCount() > 0 &&
                    (MyInput.Static.IsNewKeyPressed(MyKeys.Up) ||
                     MyInput.Static.IsNewKeyPressed(MyKeys.Down) ||
                     MyInput.Static.IsNewKeyPressed(MyKeys.Left) ||
                     MyInput.Static.IsNewKeyPressed(MyKeys.Right) ||
                     MyInput.Static.DeltaMouseScrollWheelValue() != 0))
                {
                    FocusItem(m_body[0]);
                }
                else if (FocusedItem != null)
                {
                    if (MyInput.Static.IsNewKeyPressed(MyKeys.Down) || (MyInput.Static.DeltaMouseScrollWheelValue() < 0 && Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y)))
                    {
                        FocusItem(NextVisible(m_body, FocusedItem));
                    }

                    if (MyInput.Static.IsNewKeyPressed(MyKeys.Up) || (MyInput.Static.DeltaMouseScrollWheelValue() > 0 && Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y)))
                    {
                        FocusItem(PrevVisible(m_body, FocusedItem));
                    }

                    if (MyInput.Static.IsNewKeyPressed(MyKeys.Right))
                    {
                        if (FocusedItem.GetItemCount() > 0)
                        {
                            if (!FocusedItem.IsExpanded)
                            {
                                FocusedItem.IsExpanded = true;
                            }
                            else
                            {
                                var next = NextVisible(FocusedItem, FocusedItem);
                                FocusItem(next);
                            }
                        }
                    }

                    if (MyInput.Static.IsNewKeyPressed(MyKeys.Left))
                    {
                        if (FocusedItem.GetItemCount() > 0 && FocusedItem.IsExpanded)
                        {
                            FocusedItem.IsExpanded = false;
                        }
                        else if (FocusedItem.Parent is MyTreeViewItem)
                        {
                            FocusItem(FocusedItem.Parent as MyTreeViewItem);
                        }
                    }

                    if (FocusedItem.GetItemCount() > 0)
                    {
                        if (MyInput.Static.IsNewKeyPressed(MyKeys.Add))
                        {
                            FocusedItem.IsExpanded = true;
                        }

                        if (MyInput.Static.IsNewKeyPressed(MyKeys.Subtract))
                        {
                            FocusedItem.IsExpanded = false;
                        }
                    }
                }

                if (MyInput.Static.IsNewKeyPressed(MyKeys.PageDown))
                {
                    m_vScrollbar.PageDown();
                }

                if (MyInput.Static.IsNewKeyPressed(MyKeys.PageUp))
                {
                    m_vScrollbar.PageUp();
                }

                captured = captured ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.PageDown) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.PageUp) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.Down) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.Up) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.Left) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.Right) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.Add) ||
                           MyInput.Static.IsNewKeyPressed(MyKeys.Subtract) ||
                           MyInput.Static.DeltaMouseScrollWheelValue() != 0;
            }

            // Hoovered item changed
            if (HooveredItem != oldHooveredItem)
            {
                m_control.ShowToolTip(HooveredItem == null ? null : HooveredItem.ToolTip);
                MyGuiSoundManager.PlaySound(GuiSounds.MouseOver);
            }

            return captured;
        }
コード例 #24
0
        public override MyGuiControlBase HandleInput()
        {
            if (DraggedItem != null)
            {
                if (MyInput.Static.IsLeftMousePressed())
                {
                    float dragDistanceSquared = MyGuiManager.GetScreenSizeFromNormalizedSize(StartDragPosition - MyGuiManager.MouseCursorPosition).LengthSquared();
                    if (dragDistanceSquared > 16)   // Drag Detection Sensitivity - 4 pixels
                    {
                        Dragging = m_frameBackDragging = true;
                    }
                }
                else
                {
                    if (Drop != null && Dragging)
                    {
                        Drop(this, EventArgs.Empty);
                    }

                    Dragging = false;
                    DraggedItem = null;
                }
            }

            return base.HandleInput();
        }