/// <summary>
        /// Hide popup menu and all child menus.
        /// </summary>
        public virtual void Hide()
        {
            if (!Visible)
            {
                return;
            }

            // Lock update
            IsLayoutLocked = true;

            // Close child
            HideChild();

            // Unlink
            _parentCM = null;
            Parent    = null;

            // Close window
            if (_window != null)
            {
                var win = _window;
                _window = null;
                win.Close();
            }

            // Hide
            Visible = false;
            OnHide();
        }
Beispiel #2
0
 private static void HideProxy(ref FlaxEngine.Window win)
 {
     if (win)
     {
         win.Hide();
     }
 }
Beispiel #3
0
            private static void CreateProxy(ref FlaxEngine.Window win, string name)
            {
                if (win != null)
                {
                    return;
                }

                CreateWindowSettings settings = CreateWindowSettings.Default;

                settings.Title                  = name;
                settings.Size                   = new Vector2(HintWindowsSize);
                settings.AllowInput             = false;
                settings.AllowMaximize          = false;
                settings.AllowMinimize          = false;
                settings.HasBorder              = false;
                settings.HasSizingFrame         = false;
                settings.IsRegularWindow        = false;
                settings.SupportsTransparency   = true;
                settings.ShowInTaskbar          = false;
                settings.ActivateWhenFirstShown = false;
                settings.IsTopmost              = true;

                win = FlaxEngine.Window.Create(settings);

                win.Opacity             = 0.6f;
                win.GUI.BackgroundColor = Style.Current.DragWindow;
            }
Beispiel #4
0
            /// <summary>
            /// Inits docking proxy windows.
            /// </summary>
            /// <param name="initSize">Initial size of the proxy window.</param>
            public static void Init(ref Vector2 initSize)
            {
                if (Window == null)
                {
                    // Create proxy window
                    CreateWindowSettings settings = CreateWindowSettings.Default;
                    settings.Title                = "DockHint.Window";
                    settings.Size                 = initSize;
                    settings.AllowInput           = true;
                    settings.AllowMaximize        = false;
                    settings.AllowMinimize        = false;
                    settings.HasBorder            = false;
                    settings.HasSizingFrame       = false;
                    settings.IsRegularWindow      = false;
                    settings.SupportsTransparency = true;
                    settings.ShowInTaskbar        = false;
                    settings.ShowAfterFirstPaint  = true;
                    settings.IsTopmost            = true;

                    Window = FlaxEngine.Window.Create(settings);

                    // Set opacity and background color
                    Window.Opacity             = 0.6f;
                    Window.GUI.BackgroundColor = Style.Current.DragWindow;
                }
                else
                {
                    // Resize proxy
                    Window.ClientSize = initSize;
                }

                InitHitProxy();
            }
Beispiel #5
0
 private static void DisposeProxy(ref FlaxEngine.Window win)
 {
     if (win)
     {
         win.Close(ClosingReason.User);
         win = null;
     }
 }
Beispiel #6
0
        /// <summary>
        /// Hides the popup.
        /// </summary>
        public void Hide()
        {
            if (!Visible)
            {
                return;
            }

            // Unlink
            IsLayoutLocked = true;
            Parent         = null;

            // Close window
            if (_window)
            {
                var win = _window;
                _window = null;
                win.Close();
            }

            // Hide
            Visible = false;
        }
        /// <summary>
        /// Show context menu over given control.
        /// </summary>
        /// <param name="parent">Parent control to attach to it.</param>
        /// <param name="location">Popup menu orgin location in parent control coordinates.</param>
        public virtual void Show(Control parent, Vector2 location)
        {
            Assert.IsNotNull(parent);

            // Ensure to be closed
            Hide();

            // Unlock and perform controls update
            UnlockChildrenRecursive();
            PerformLayout();

            // Calculate popup directinon and initial location
            var parentWin = parent.ParentWindow;

            if (parentWin == null)
            {
                return;
            }
            Vector2 locationWS = parent.PointToWindow(location);
            Vector2 locationSS = parentWin.ClientToScreen(locationWS);

            Location = Vector2.Zero;
            Vector2 screenSize            = Application.VirtualDesktopSize;
            Vector2 rightBottomLocationSS = locationSS + Size;

            if (screenSize.Y < rightBottomLocationSS.Y)
            {
                // Direction: up
                locationSS.Y -= Height;
            }
            if (screenSize.X < rightBottomLocationSS.X)
            {
                // Direction: left
                locationSS.X -= Width;
            }

            // Create window
            var desc = CreateWindowSettings.Default;

            desc.Position               = locationSS;
            desc.StartPosition          = WindowStartPosition.Manual;
            desc.Size                   = Size;
            desc.Fullscreen             = false;
            desc.HasBorder              = false;
            desc.SupportsTransparency   = false;
            desc.ShowInTaskbar          = false;
            desc.ActivateWhenFirstShown = true;
            desc.AllowInput             = true;
            desc.AllowMinimize          = false;
            desc.AllowMaximize          = false;
            desc.AllowDragAndDrop       = false;
            desc.IsTopmost              = true;
            desc.IsRegularWindow        = false;
            desc.HasSizingFrame         = false;
            _window              = FlaxEngine.Window.Create(desc);
            _window.OnLostFocus += onWindowLostFocus;

            // Attach to the window
            _parentCM = parent as ContextMenuBase;
            Parent    = _window.GUI;

            // Show
            Visible = true;
            _window.Show();
            PerformLayout();
            Focus();
            OnShow();
        }
Beispiel #8
0
        /// <summary>
        /// Shows tooltip over given control.
        /// </summary>
        /// <param name="target">The parent control to attach to it.</param>
        /// <param name="location">Popup menu orgin location in parent cntrol coordinates.</param>
        /// <param name="targetArea">Tooltip target area or intrest.</param>
        public void Show(Control target, Vector2 location, Rectangle targetArea)
        {
            if (target == null)
            {
                throw new ArgumentNullException();
            }

            // Ensure to be closed
            Hide();

            // Unlock and perform controls update
            UnlockChildrenRecursive();
            PerformLayout();

            // Calculate popup directinon and initial location
            var parentWin = target.ParentWindow;

            if (parentWin == null)
            {
                return;
            }
            Vector2 locationWS            = target.PointToWindow(location);
            Vector2 locationSS            = parentWin.ClientToScreen(locationWS);
            Vector2 screenSize            = Application.VirtualDesktopSize;
            Vector2 rightBottomLocationSS = locationSS + Size;

            if (screenSize.Y < rightBottomLocationSS.Y)
            {
                // Direction: up
                locationSS.Y -= Height;
            }
            if (screenSize.X < rightBottomLocationSS.X)
            {
                // Direction: left
                locationSS.X -= Width;
            }

            // Create window
            var desc = CreateWindowSettings.Default;

            desc.StartPosition          = WindowStartPosition.Manual;
            desc.Position               = locationSS;
            desc.Size                   = Size;
            desc.Fullscreen             = false;
            desc.HasBorder              = false;
            desc.SupportsTransparency   = false;
            desc.ShowInTaskbar          = false;
            desc.ActivateWhenFirstShown = false;
            desc.AllowInput             = true;
            desc.AllowMinimize          = false;
            desc.AllowMaximize          = false;
            desc.AllowDragAndDrop       = false;
            desc.IsTopmost              = true;
            desc.IsRegularWindow        = false;
            desc.HasSizingFrame         = false;
            _window = FlaxEngine.Window.Create(desc);
            if (_window == null)
            {
                throw new InvalidOperationException("Failed to create tooltip window.");
            }

            // Attach to the window and focus
            Parent  = _window.GUI;
            Visible = true;
            _window.Show();

            // Cache mouse safe movement area
            _mouseMovementRange = new Rectangle(target.ClientToScreen(targetArea.Location), targetArea.Size);
        }
Beispiel #9
0
        /// <summary>
        /// Show context menu over given control.
        /// </summary>
        /// <param name="parent">Parent control to attach to it.</param>
        /// <param name="location">Popup menu origin location in parent control coordinates.</param>
        public virtual void Show(Control parent, Vector2 location)
        {
            Assert.IsNotNull(parent);

            // Ensure to be closed
            Hide();

            // Unlock and perform controls update
            UnlockChildrenRecursive();
            PerformLayout();

            // Calculate popup direction and initial location (fit on a single monitor)
            var parentWin = parent.RootWindow;

            if (parentWin == null)
            {
                return;
            }
            Vector2 locationWS = parent.PointToWindow(location);
            Vector2 locationSS = parentWin.ClientToScreen(locationWS);

            Location = Vector2.Zero;
            Rectangle monitorBounds = Application.GetMonitorBounds(locationSS);
            Vector2   rightBottomLocationSS = locationSS + Size;
            bool      isUp = false, isLeft = false;

            if (monitorBounds.Bottom < rightBottomLocationSS.Y)
            {
                // Direction: up
                isUp          = true;
                locationSS.Y -= Height;
            }
            if (monitorBounds.Right < rightBottomLocationSS.X)
            {
                // Direction: left
                isLeft        = true;
                locationSS.X -= Width;
            }

            // Update direction flag
            if (isUp)
            {
                _direction = isLeft ? ContextMenuDirection.LeftUp : ContextMenuDirection.RightUp;
            }
            else
            {
                _direction = isLeft ? ContextMenuDirection.LeftDown : ContextMenuDirection.RightDown;
            }

            // Create window
            var desc = CreateWindowSettings.Default;

            desc.Position               = locationSS;
            desc.StartPosition          = WindowStartPosition.Manual;
            desc.Size                   = Size;
            desc.Fullscreen             = false;
            desc.HasBorder              = false;
            desc.SupportsTransparency   = false;
            desc.ShowInTaskbar          = false;
            desc.ActivateWhenFirstShown = true;
            desc.AllowInput             = true;
            desc.AllowMinimize          = false;
            desc.AllowMaximize          = false;
            desc.AllowDragAndDrop       = false;
            desc.IsTopmost              = true;
            desc.IsRegularWindow        = false;
            desc.HasSizingFrame         = false;
            _window              = FlaxEngine.Window.Create(desc);
            _window.OnLostFocus += onWindowLostFocus;

            // Attach to the window
            _parentCM = parent as ContextMenuBase;
            Parent    = _window.GUI;

            // Show
            Visible = true;
            _window.Show();
            PerformLayout();
            Focus();
            OnShow();
        }