//---------------------------------------------------------------------- protected internal override bool OnMouseDown(Point _hitPoint, int _iButton) { if (_iButton != Screen.Game.InputMgr.PrimaryMouseButton) { return(false); } mbIsDragging = true; bool bShift = Screen.Game.InputMgr.KeyboardState.IsKeyDown(Keys.LeftShift, true) || Screen.Game.InputMgr.KeyboardState.IsKeyDown(Keys.RightShift, true); if (HasFocus && bShift) { int iOffset = GetCaretOffsetAtX(Math.Max(0, _hitPoint.X - (LayoutRect.X + Padding.Left))); SelectionOffset = iOffset - miCaretOffset; } else { CaretOffset = GetCaretOffsetAtX(Math.Max(0, _hitPoint.X - (LayoutRect.X + Padding.Left))); } Screen.Focus(this); return(true); }
//---------------------------------------------------------------------- protected internal override bool OnMouseDown(Point _hitPoint, int _iButton) { if (_iButton != Screen.Game.InputMgr.PrimaryMouseButton) { return(false); } Screen.Focus(this); if (IsOpen && mDropDownHitBox.Contains(_hitPoint)) { } else { miHoveredItemIndex = SelectedItemIndex; if (miHoveredItemIndex < ScrollItemOffset) { ScrollItemOffset = miHoveredItemIndex; } else if (miHoveredItemIndex >= ScrollItemOffset + siMaxLineDisplayed) { ScrollItemOffset = Math.Min(miHoveredItemIndex - siMaxLineDisplayed + 1, Items.Count - siMaxLineDisplayed); } mScrollbar.LerpOffset = mScrollbar.Offset; IsOpen = !IsOpen; mPressedAnim.SetTime(0f); } return(true); }
protected internal override void OnMouseUp(Point _hitPoint, int _iButton) { if (_iButton == Screen.Game.InputMgr.PrimaryMouseButton) { if (mNotebook.DraggedTab == this) { mNotebook.DropTab(); DragOffset = 0; } if (_hitPoint.Y < mNotebook.LayoutRect.Y + mNotebook.Style.TabHeight /* && IsInTab */) { if (_hitPoint.X > LayoutRect.X && _hitPoint.X < LayoutRect.Right) { OnActivateUp(); } } } else if (_iButton == 1) { if (IsClosable && HitBox.Contains(_hitPoint)) { Close(); Screen.Focus(mNotebook); if (mNotebook.TabClosedHandler != null) { mNotebook.TabClosedHandler(this); } } } }
//---------------------------------------------------------------------- public NotebookTab(Notebook _notebook, string _strText, Texture2D _iconTex) : base(_notebook.Screen) { mNotebook = _notebook; Parent = _notebook; mLabel = new Label(Screen, "", Anchor.Start, Screen.Style.DefaultTextColor); mIcon = new Image(Screen, _iconTex); mTooltip = new Tooltip(Screen, ""); mCloseButton = new Button(Screen, new Button.ButtonStyle(5, null, null, mNotebook.Style.TabCloseHover, mNotebook.Style.TabCloseDown, null, 0, 0), "", mNotebook.Style.TabClose, Anchor.Center); mCloseButton.Parent = this; mCloseButton.Padding = new Box(0); mCloseButton.ClickHandler = delegate { mNotebook.Tabs.Remove(this); Screen.Focus(mNotebook); if (mNotebook.TabClosedHandler != null) { mNotebook.TabClosedHandler(this); } }; Text = _strText; PageGroup = new Group(Screen); PageGroup.Parent = this; }
//---------------------------------------------------------------------- protected internal override bool OnMouseDown(Point _hitPoint, int _iButton) { if (_iButton != Screen.Game.InputMgr.PrimaryMouseButton) { return(false); } mHoverPoint = _hitPoint; if (mHoveredActionButton != null) { mHoveredActionButton.OnActivateDown(); mbIsHoveredActionButtonDown = true; } else { mbIsMouseDown = true; mMouseDownPoint = new Point(_hitPoint.X, _hitPoint.Y + (int)Scrollbar.LerpOffset); Screen.Focus(this); int iFocusedRowIndex = Math.Max(0, (_hitPoint.Y - (LayoutRect.Y + Padding.Top + (DisplayColumnHeaders ? Style.RowHeight : 0)) + (int)Scrollbar.LerpOffset) / (Style.RowHeight + Style.RowSpacing)); if (iFocusedRowIndex > Rows.Count - 1) { iFocusedRowIndex = -1; } FocusedRow = (iFocusedRowIndex != -1) ? Rows[iFocusedRowIndex] : null; } return(true); }
//---------------------------------------------------------------------- public void Open(int _iWidth, int _iHeight) { AnchoredRect.Width = _iWidth; AnchoredRect.Height = _iHeight; Manager.PushPopup(this); Screen.Focus(GetFirstFocusableDescendant(Direction.Down)); mSpinningWheel.Reset(); }
//---------------------------------------------------------------------- protected internal override bool OnMouseDown(Point _hitPoint, int _iButton) { if (_iButton != Screen.Game.InputMgr.PrimaryMouseButton) { return(false); } Screen.Focus(this); return(true); }
//---------------------------------------------------------------------- public void Close(bool _bTriggerCloseHandler = false) { mNotebook.Tabs.Remove(this); if (HasFocus) { Screen.Focus(mNotebook); } if (_bTriggerCloseHandler && mNotebook.TabClosedHandler != null) { mNotebook.TabClosedHandler(this); } }
protected internal virtual void OnPadMove(Direction _direction) { Widget widget = GetSibling(_direction, this); if (widget != null) { Widget focusableWidget = widget.GetFirstFocusableDescendant(_direction); if (focusableWidget != null) { Screen.Focus(focusableWidget); } } }
//---------------------------------------------------------------------- protected internal override void OnKeyPress(Keys _key) { bool bShortcutKey = Screen.Game.InputMgr.IsShortcutKeyDown(); bool bCtrl = Screen.Game.InputMgr.KeyboardState.IsKeyDown(Keys.LeftControl, true) || Screen.Game.InputMgr.KeyboardState.IsKeyDown(Keys.RightControl, true); bool bShift = Screen.Game.InputMgr.KeyboardState.IsKeyDown(Keys.LeftShift, true) || Screen.Game.InputMgr.KeyboardState.IsKeyDown(Keys.RightShift, true); var activeTab = Tabs[ActiveTabIndex]; if (bShortcutKey && _key == Keys.W && activeTab.IsClosable) { activeTab.Close(); Screen.Focus(this); if (TabClosedHandler != null) { TabClosedHandler(activeTab); } } else if (bCtrl && _key == Keys.Tab) { if (bShift) { int iActiveTabIndex = ActiveTabIndex - 1; if (iActiveTabIndex == -1) { iActiveTabIndex = Tabs.Count - 1; } ActiveTabIndex = iActiveTabIndex; } else { ActiveTabIndex = (ActiveTabIndex + 1) % Tabs.Count; } Tabs[ActiveTabIndex].IsUnread = false; Screen.Focus(Tabs[ActiveTabIndex]); } else { base.OnKeyPress(_key); } }
protected internal virtual void OnOSKeyPress(OSKey _key) { bool bCtrl = Screen.Game.InputMgr.KeyboardState.IsKeyDown(Keys.LeftControl, true) || Screen.Game.InputMgr.KeyboardState.IsKeyDown(Keys.RightControl, true); if (!bCtrl && _key == OSKey.Tab) { List <Direction> directions = new List <Direction>(); if (Screen.Game.InputMgr.KeyboardState.Native.IsKeyDown(Keys.LeftShift) || Screen.Game.InputMgr.KeyboardState.Native.IsKeyDown(Keys.RightShift)) { directions.Add(Direction.Left); directions.Add(Direction.Up); } else { directions.Add(Direction.Right); directions.Add(Direction.Down); } foreach (Direction direction in directions) { Widget widget = GetSibling(direction, this); if (widget != null) { Widget focusableWidget = widget.GetFirstFocusableDescendant(direction); if (focusableWidget != null) { Screen.Focus(focusableWidget); break; } } } } else { if (Parent != null) { Parent.OnOSKeyPress(_key); } } }
protected internal override void OnPadMove(Direction _direction) { int iTabIndex = mNotebook.Tabs.IndexOf(this); if (_direction == Direction.Left && iTabIndex > 0) { NotebookTab tab = mNotebook.Tabs[iTabIndex - 1]; Screen.Focus(tab); } else if (_direction == Direction.Right && iTabIndex < mNotebook.Tabs.Count - 1) { NotebookTab tab = mNotebook.Tabs[iTabIndex + 1]; Screen.Focus(tab); } else { base.OnPadMove(_direction); } }
protected internal override bool OnMouseDown(Point _hitPoint, int _iButton) { if (_iButton == Screen.Game.InputMgr.PrimaryMouseButton) { Screen.Focus(this); if (IsClosable) { mNotebook.DraggedTab = this; DragOffset = _hitPoint.X - LayoutRect.X; } } else if (_iButton == 1) { Screen.Focus(this); } return(true); }
protected internal override bool OnMouseDown(Point _hitPoint, int _iButton) { if (_iButton != Screen.Game.InputMgr.PrimaryMouseButton || !Enabled) { return(false); } if (Collapsable) { mbIsDragging = true; } else { mbIsDragging = true; switch (mDirection) { case Direction.Left: miDragOffset = SplitterOffset - _hitPoint.X; break; case Direction.Right: miDragOffset = SplitterOffset + _hitPoint.X; break; case Direction.Up: miDragOffset = SplitterOffset - _hitPoint.Y; break; case Direction.Down: miDragOffset = SplitterOffset + _hitPoint.Y; break; } } Screen.Focus(this); return(true); }
//---------------------------------------------------------------------- protected internal override bool OnMouseDown(Point _hitPoint, int _iButton) { if (_iButton != Screen.Game.InputMgr.PrimaryMouseButton) { return(false); } Screen.Focus(this); mbIsPressed = true; mTooltip.DisplayNow(); int iWidth = LayoutRect.Width - Screen.Style.SliderHandleSize; int iX = _hitPoint.X - LayoutRect.X - Screen.Style.SliderHandleSize / 2; float fProgress = (float)iX / iWidth; Value = MinValue + (int)Math.Floor(fProgress * (MaxValue - MinValue) / Step + 0.5f) * Step; if (ChangeHandler != null) { ChangeHandler(); } return(true); }