Пример #1
0
        /// <inheritdoc />
        public override void OnMouseMove(Vector2 location)
        {
            // Cache mouse
            MousePosition = location;

            // Check if mouse is down
            if (IsMouseLeftButtonDown)
            {
                // Check if mouse is outside the header
                if (!HeaderRectangle.Contains(location))
                {
                    // Clear flag
                    IsMouseLeftButtonDown = false;

                    // Check tab under the mouse
                    if (!IsMouseDownOverCross && MouseDownWindow != null)
                    {
                        StartDrag(MouseDownWindow);
                    }
                    MouseDownWindow = null;
                }
                // Check if has more than one tab to change order
                else if (MouseDownWindow != null && _panel.TabsCount > 1)
                {
                    // Check if mouse left current tab rect
                    Rectangle currWinRect;
                    GetTabRect(MouseDownWindow, out currWinRect);
                    if (!currWinRect.Contains(location))
                    {
                        int index = _panel.GetTabIndex(MouseDownWindow);

                        // Check if move right or left
                        if (location.X < currWinRect.X)
                        {
                            // Move left
                            _panel.MoveTabLeft(index);
                        }
                        else if (_panel.LastTab != MouseDownWindow)
                        {
                            // Move right
                            _panel.MoveTabRight(index);
                        }

                        // Update
                        _panel.PerformLayout();
                    }
                }
            }

            base.OnMouseMove(location);
        }
Пример #2
0
        internal void unlinkWindow(DockWindow window)
        {
            // Call event to the window
            window.OnUnlinkInternal();

            // Prevent this action during disposing (we don't want to modify Windows list)
            if (IsDisposing)
            {
                return;
            }

            // Remove from the windows list
            Windows.Remove(window);
        }
Пример #3
0
        /// <inheritdoc />
        public override bool OnMouseDown(Vector2 location, MouseButton buttons)
        {
            // Check buttons
            if (buttons == MouseButton.Left)
            {
                // Cache data
                IsMouseDown     = true;
                MouseDownWindow = getTabAtPos(location, out IsMouseDownOverCross);
                if (!IsMouseDownOverCross && MouseDownWindow != null)
                {
                    _panel.SelectTab(MouseDownWindow);
                }
            }

            return(base.OnMouseDown(location, buttons));
        }
Пример #4
0
        /// <inheritdoc />
        public override void OnMouseLeave()
        {
            // Check if mouse is down
            if (IsMouseDown)
            {
                // Clear flag
                IsMouseDown = false;

                // Check tabs under mouse position
                if (!IsMouseDownOverCross && MouseDownWindow != null)
                {
                    startDrag(MouseDownWindow);
                }
                MouseDownWindow = null;
            }

            base.OnMouseLeave();
        }
Пример #5
0
        /// <summary>
        /// Docks the window.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <param name="window">The window.</param>
        protected virtual void DockWindow(DockState state, DockWindow window)
        {
            CreateTabsProxy();

            // Check if dock like a tab or not
            if (state == DockState.DockFill)
            {
                // Add tab
                AddTab(window);
            }
            else
            {
                // Create child panel
                var dockPanel = CreateChildPanel(state, DefaultSplitterValue);

                // Dock window as a tab in a child panel
                dockPanel.DockWindow(DockState.DockFill, window);
            }
        }
Пример #6
0
        /// <inheritdoc />
        public override void OnMouseLeave()
        {
            if (IsMouseLeftButtonDown)
            {
                IsMouseLeftButtonDown = false;

                // Check tabs under mouse position
                if (!IsMouseDownOverCross && MouseDownWindow != null)
                {
                    StartDrag(MouseDownWindow);
                }
                MouseDownWindow = null;
            }
            IsMouseRightButtonDown  = false;
            IsMouseMiddleButtonDown = false;
            MousePosition           = Vector2.Minimum;

            base.OnMouseLeave();
        }
Пример #7
0
        private void ShowContextMenu(DockWindow tab, ref Vector2 location)
        {
            var menu = new ContextMenu.ContextMenu();

            menu.Tag = tab;
            tab.OnShowContextMenu(menu);
            menu.AddButton("Close", OnTabMenuCloseClicked);
            menu.AddButton("Close All", OnTabMenuCloseAllClicked);
            menu.AddButton("Close All But This", OnTabMenuCloseAllButThisClicked);
            if (_panel.Tabs.IndexOf(tab) + 1 < _panel.TabsCount)
            {
                menu.AddButton("Close All To The Right", OnTabMenuCloseAllToTheRightClicked);
            }
            if (!_panel.IsFloating)
            {
                menu.AddSeparator();
                menu.AddButton("Undock", OnTabMenuUndockClicked);
            }
            menu.Show(this, location);
        }
Пример #8
0
        /// <inheritdoc />
        public override bool OnMouseUp(Vector2 location, MouseButton button)
        {
            // Check tabs under mouse position at the beginning and at the end
            var tab = GetTabAtPos(location, out var overCross);

            // Check buttons
            if (button == MouseButton.Left && IsMouseLeftButtonDown)
            {
                // Clear flag
                IsMouseLeftButtonDown = false;

                // Check if tabs are the same and cross was pressed
                if (tab != null && tab == MouseDownWindow && IsMouseDownOverCross && overCross)
                {
                    tab.Close(ClosingReason.User);
                }
                MouseDownWindow = null;
            }
            else if (button == MouseButton.Right && IsMouseRightButtonDown)
            {
                // Clear flag
                IsMouseRightButtonDown = false;

                if (tab != null)
                {
                    ShowContextMenu(tab, ref location);
                }
            }
            else if (button == MouseButton.Middle && IsMouseMiddleButtonDown)
            {
                // Clear flag
                IsMouseMiddleButtonDown = false;

                if (tab != null)
                {
                    tab.Close(ClosingReason.User);
                }
            }

            return(base.OnMouseUp(location, button));
        }
Пример #9
0
        private DockWindow GetTabAtPos(Vector2 position, out bool closeButton)
        {
            DockWindow result = null;

            closeButton = false;

            var tabsCount = _panel.TabsCount;

            if (tabsCount == 1)
            {
                var crossRect = new Rectangle(Width - DockPanel.DefaultButtonsSize - DockPanel.DefaultButtonsMargin, (DockPanel.DefaultHeaderHeight - DockPanel.DefaultButtonsSize) / 2, DockPanel.DefaultButtonsSize, DockPanel.DefaultButtonsSize);
                if (HeaderRectangle.Contains(position))
                {
                    closeButton = crossRect.Contains(position);
                    result      = _panel.GetTab(0);
                }
            }
            else
            {
                float x = 0;
                for (int i = 0; i < tabsCount; i++)
                {
                    var tab         = _panel.GetTab(i);
                    var titleSize   = tab.TitleSize;
                    var iconWidth   = tab.Icon.IsValid ? DockPanel.DefaultButtonsSize + DockPanel.DefaultLeftTextMargin : 0;
                    var width       = titleSize.X + DockPanel.DefaultButtonsSize + 2 * DockPanel.DefaultButtonsMargin + DockPanel.DefaultLeftTextMargin + DockPanel.DefaultRightTextMargin + iconWidth;
                    var tabRect     = new Rectangle(x, 0, width, DockPanel.DefaultHeaderHeight);
                    var isMouseOver = tabRect.Contains(position);
                    if (isMouseOver)
                    {
                        var crossRect = new Rectangle(x + width - DockPanel.DefaultButtonsSize - DockPanel.DefaultButtonsMargin, (DockPanel.DefaultHeaderHeight - DockPanel.DefaultButtonsSize) / 2, DockPanel.DefaultButtonsSize, DockPanel.DefaultButtonsSize);
                        closeButton = crossRect.Contains(position);
                        result      = tab;
                        break;
                    }
                    x += width;
                }
            }

            return(result);
        }
Пример #10
0
        /// <summary>
        /// Creates the new dragging hit window.
        /// </summary>
        /// <param name="toMove">Dock window to move.</param>
        /// <returns>The dock hint window object.</returns>
        public static DockHintWindow Create(DockWindow toMove)
        {
            if (toMove == null)
            {
                throw new ArgumentNullException();
            }

            // Show floating
            toMove.ShowFloating();

            // Move window to the mouse position (with some offset for caption bar)
            var     window = (WindowRootControl)toMove.Root;
            Vector2 mouse  = FlaxEngine.Input.MouseScreenPosition;

            window.Window.Position = mouse - new Vector2(8, 8);

            // Get floating panel
            var floatingPanelToMove = window.GetChild(0) as FloatWindowDockPanel;

            return(new DockHintWindow(floatingPanelToMove));
        }
Пример #11
0
        /// <inheritdoc />
        public override bool OnMouseUp(Vector2 location, MouseButton buttons)
        {
            // Check buttons
            if (buttons == MouseButton.Left && IsMouseDown)
            {
                // Clear flag
                IsMouseDown = false;

                // Check tabs under mouse position at the begining and at the end
                bool overCross;
                var  tab = getTabAtPos(location, out overCross);

                // Check if tabs are the same and cross was pressed
                if (tab != null && tab == MouseDownWindow && IsMouseDownOverCross && overCross)
                {
                    tab.Close(ClosingReason.User);
                }
                MouseDownWindow = null;
            }

            return(base.OnMouseUp(location, buttons));
        }
Пример #12
0
        /// <summary>
        /// Undocks the window.
        /// </summary>
        /// <param name="window">The window.</param>
        protected virtual void UndockWindow(DockWindow window)
        {
            var index = GetTabIndex(window);

            if (index == -1)
            {
                throw new IndexOutOfRangeException();
            }

            // Check if tab was selected
            if (window == SelectedTab)
            {
                // Change selection
                if (index == 0 && TabsCount > 1)
                {
                    SelectTab(1);
                }
                else
                {
                    SelectTab(index - 1);
                }
            }

            // Undock
            _tabs.RemoveAt(index);
            window.ParentDockPanel = null;

            // Check if has no more tabs
            if (_tabs.Count == 0)
            {
                OnLastTabRemoved();
            }
            else
            {
                // Update
                PerformLayout();
            }
        }
Пример #13
0
 internal void UndockWindowInternal(DockWindow window)
 {
     UndockWindow(window);
 }
Пример #14
0
 internal virtual void DockWindowInternal(DockState state, DockWindow window)
 {
     DockWindow(state, window);
 }
Пример #15
0
 /// <summary>
 /// Determines whether panel contains the specified tab.
 /// </summary>
 /// <param name="tab">The tab.</param>
 /// <returns>
 ///   <c>true</c> if panel contains the specified tab; otherwise, <c>false</c>.
 /// </returns>
 public bool ContainsTab(DockWindow tab)
 {
     return(_tabs.Contains(tab));
 }
Пример #16
0
 /// <summary>
 /// Gets tab at the given index.
 /// </summary>
 /// <param name="tab">The tab page.</param>
 /// <returns>The index of the given tab.</returns>
 public int GetTabIndex(DockWindow tab)
 {
     return(_tabs.IndexOf(tab));
 }
Пример #17
0
 internal void linkWindow(DockWindow window)
 {
     // Add to the windows list
     Windows.Add(window);
 }