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()); }
public void DeleteItem(MyTreeViewItem item) { if (m_items.Remove(item)) { item.TreeView = null; item.ClearItems(); } }
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; }
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); }
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; }
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; }
private MyTreeViewItem PrevVisible(ITreeView iTreeView, MyTreeViewItem focused) { MyTreeViewItem pred = focused; TraverseVisible(m_body, a => { if (a == focused) { focused = pred; } else { pred = a; } } ); return(focused); }
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; }
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); }
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); }
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); }
public int GetIndex(MyTreeViewItem item) { return(m_items.IndexOf(item)); }
public int GetIndex(MyTreeViewItem item) { return m_items.IndexOf(item); }
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); }
public void Init(MyTreeViewItem item, Vector2 startDragPosition) { Dragging = false; DraggedItem = item; StartDragPosition = startDragPosition; }
public void DeleteItem(MyTreeViewItem item) { m_treeView.DeleteItem(item); }
private MyTreeViewItem PrevVisible(ITreeView iTreeView, MyTreeViewItem focused) { MyTreeViewItem pred = focused; TraverseVisible(m_body, a => { if (a == focused) { focused = pred; } else { pred = a; } } ); return focused; }
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; }
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(); }