protected internal override void MouseMove(GUIMouseMoveEventArgs args)
        {
            base.MouseMove(args);

            if (ResizeMode == SplitResizeMode.NotResizable)
            {
                return;
            }

            if (_dragging)
            {
                var newOffset = Vertical ? args.RelativePosition.Y : args.RelativePosition.X;

                _splitCenter       = ClampSplitCenter(newOffset);
                DefaultCursorShape = Vertical ? CursorShape.VResize : CursorShape.HResize;
                ForceRunLayoutUpdate();
            }
            else
            {
                // on mouseover, check if they are over the split and change the cursor accordingly
                var cursor = CursorShape.Arrow;
                if (CanDragAt(args.RelativePosition))
                {
                    cursor = Vertical ? CursorShape.VResize : CursorShape.HResize;
                }

                DefaultCursorShape = cursor;
            }
        }
        protected override void MouseMove(GUIMouseMoveEventArgs args)
        {
            base.MouseMove(args);

            if (Parent == null)
            {
                return;
            }

            if (_currentDrag == DragMode.None)
            {
                var cursor          = CursorShape.Arrow;
                var previewDragMode = GetDragModeFor(args.RelativePosition);
                switch (previewDragMode)
                {
                case DragMode.Bottom:
                    cursor = CursorShape.VResize;
                    break;

                case DragMode.Left:
                    cursor = CursorShape.HResize;
                    break;

                case DragMode.Bottom | DragMode.Left:
                    cursor = CursorShape.Crosshair;
                    break;
                }

                DefaultCursorShape = cursor;
            }
            else
            {
                var top    = Rect.Top;
                var bottom = Rect.Bottom;
                var left   = Rect.Left;
                var right  = Rect.Right;
                var(minSizeX, minSizeY) = MinSize;
                if ((_currentDrag & DragMode.Bottom) == DragMode.Bottom)
                {
                    bottom = Math.Max(args.GlobalPosition.Y + _dragOffsetBottomRight.Y, top + minSizeY);
                }

                if ((_currentDrag & DragMode.Left) == DragMode.Left)
                {
                    var maxX = right - minSizeX;
                    left = Math.Min(args.GlobalPosition.X - _dragOffsetTopLeft.X, maxX);
                }

                ClampSize(left, bottom);
            }
        }
Example #3
0
        protected internal override void MouseMove(GUIMouseMoveEventArgs args)
        {
            base.MouseMove(args);

            for (var idx = 0; idx < _itemList.Count; idx++)
            {
                var item = _itemList[idx];
                if (item.Region == null)
                {
                    continue;
                }
                if (!item.Region.Value.Contains(args.RelativePosition))
                {
                    continue;
                }
                OnItemHover?.Invoke(new ItemListHoverEventArgs(idx, this));
                break;
            }
        }
Example #4
0
        protected override void MouseMove(GUIMouseMoveEventArgs args)
        {
            base.MouseMove(args);

            if (CurrentDrag == DragMode.Move)
            {
                var globalPos = args.GlobalPosition;
                globalPos = Vector2.Clamp(globalPos, Vector2.Zero, Godot.OS.GetWindowSize().Convert());
                Position  = globalPos - DragOffsetTopLeft;
                return;
            }

            if (!Resizable)
            {
                return;
            }

            if (CurrentDrag == DragMode.None)
            {
                var cursor          = CursorShape.Arrow;
                var previewDragMode = GetDragModeFor(args.RelativePosition);
                switch (previewDragMode)
                {
                case DragMode.Top:
                case DragMode.Bottom:
                    cursor = CursorShape.VSplit;
                    break;

                case DragMode.Left:
                case DragMode.Right:
                    cursor = CursorShape.HSplit;
                    break;

                case DragMode.Bottom | DragMode.Left:
                case DragMode.Top | DragMode.Right:
                    cursor = CursorShape.BDiagSize;
                    break;

                case DragMode.Bottom | DragMode.Right:
                case DragMode.Top | DragMode.Left:
                    cursor = CursorShape.FDiagSize;
                    break;
                }

                DefaultCursorShape = cursor;
            }
            else
            {
                var top     = Rect.Top;
                var bottom  = Rect.Bottom;
                var left    = Rect.Left;
                var right   = Rect.Right;
                var minsize = CombinedMinimumSize;
                if ((CurrentDrag & DragMode.Top) == DragMode.Top)
                {
                    var MaxY = bottom - minsize.Y;
                    top = Math.Min(args.GlobalPosition.Y - DragOffsetTopLeft.Y, MaxY);
                }
                else if ((CurrentDrag & DragMode.Bottom) == DragMode.Bottom)
                {
                    bottom = Math.Max(args.GlobalPosition.Y + DragOffsetBottomRight.Y, top + minsize.Y);
                }

                if ((CurrentDrag & DragMode.Left) == DragMode.Left)
                {
                    var MaxX = right - minsize.X;
                    left = Math.Min(args.GlobalPosition.X - DragOffsetTopLeft.X, MaxX);
                }
                else if ((CurrentDrag & DragMode.Right) == DragMode.Right)
                {
                    right = Math.Max(args.GlobalPosition.X + DragOffsetBottomRight.X, left + minsize.X);
                }

                Position = new Vector2(left, top);
                var rect = new Box2(left, top, right, bottom);
                Size = new Vector2(rect.Width, rect.Height);
            }
        }
Example #5
0
        protected internal override void MouseMove(GUIMouseMoveEventArgs args)
        {
            base.MouseMove(args);

            if (Parent == null)
            {
                return;
            }

            if (CurrentDrag == DragMode.Move)
            {
                var globalPos = args.GlobalPosition;
                globalPos = Vector2.Clamp(globalPos, Vector2.Zero, Parent.Size);
                LayoutContainer.SetPosition(this, globalPos - DragOffsetTopLeft);
                return;
            }

            if (!Resizable)
            {
                return;
            }

            if (CurrentDrag == DragMode.None)
            {
                var cursor          = CursorShape.Arrow;
                var previewDragMode = GetDragModeFor(args.RelativePosition);
                switch (previewDragMode)
                {
                case DragMode.Top:
                case DragMode.Bottom:
                    cursor = CursorShape.VResize;
                    break;

                case DragMode.Left:
                case DragMode.Right:
                    cursor = CursorShape.HResize;
                    break;

                case DragMode.Bottom | DragMode.Left:
                case DragMode.Top | DragMode.Right:
                    cursor = CursorShape.Crosshair;
                    break;

                case DragMode.Bottom | DragMode.Right:
                case DragMode.Top | DragMode.Left:
                    cursor = CursorShape.Crosshair;
                    break;
                }

                DefaultCursorShape = cursor;
            }
            else
            {
                var(left, top)     = Position;
                var(right, bottom) = Position + SetSize;

                if (float.IsNaN(SetSize.X))
                {
                    right = Position.X + Size.X;
                }
                if (float.IsNaN(SetSize.Y))
                {
                    bottom = Position.Y + Size.Y;
                }

                if ((CurrentDrag & DragMode.Top) == DragMode.Top)
                {
                    top = Math.Min(args.GlobalPosition.Y - DragOffsetTopLeft.Y, Math.Min(bottom, bottom - MinSize.Y));
                }
                else if ((CurrentDrag & DragMode.Bottom) == DragMode.Bottom)
                {
                    bottom = Math.Max(args.GlobalPosition.Y + DragOffsetBottomRight.Y, Math.Max(top, top + MinSize.Y));
                }

                if ((CurrentDrag & DragMode.Left) == DragMode.Left)
                {
                    left = Math.Min(args.GlobalPosition.X - DragOffsetTopLeft.X, Math.Min(right, right - MinSize.X));
                }
                else if ((CurrentDrag & DragMode.Right) == DragMode.Right)
                {
                    right = Math.Max(args.GlobalPosition.X + DragOffsetBottomRight.X, Math.Max(left, left + MinSize.X));
                }

                var rect = new UIBox2(left, top, right, bottom);
                LayoutContainer.SetPosition(this, rect.TopLeft);
                SetSize = rect.Size;

                /*
                 * var timing = IoCManager.Resolve<IGameTiming>();
                 *
                 * var l = GetValue<float>(LayoutContainer.MarginLeftProperty);
                 * var t = GetValue<float>(LayoutContainer.MarginTopProperty);
                 *
                 * Logger.Debug($"{timing.CurFrame}: {rect.TopLeft}/({l}, {t}), {rect.Size}/{SetSize}");
                 */
            }
        }
Example #6
0
        protected internal override void MouseMove(GUIMouseMoveEventArgs args)
        {
            base.MouseMove(args);

            if (Parent == null)
            {
                return;
            }

            if (CurrentDrag == DragMode.Move)
            {
                var globalPos = args.GlobalPosition;
                globalPos = Vector2.Clamp(globalPos, Vector2.Zero, Parent.Size);
                LayoutContainer.SetPosition(this, globalPos - DragOffsetTopLeft);
                return;
            }

            if (!Resizable)
            {
                return;
            }

            if (CurrentDrag == DragMode.None)
            {
                var cursor          = CursorShape.Arrow;
                var previewDragMode = GetDragModeFor(args.RelativePosition);
                switch (previewDragMode)
                {
                case DragMode.Top:
                case DragMode.Bottom:
                    cursor = CursorShape.VResize;
                    break;

                case DragMode.Left:
                case DragMode.Right:
                    cursor = CursorShape.HResize;
                    break;

                case DragMode.Bottom | DragMode.Left:
                case DragMode.Top | DragMode.Right:
                    cursor = CursorShape.Crosshair;
                    break;

                case DragMode.Bottom | DragMode.Right:
                case DragMode.Top | DragMode.Left:
                    cursor = CursorShape.Crosshair;
                    break;
                }

                DefaultCursorShape = cursor;
            }
            else
            {
                var top    = Rect.Top;
                var bottom = Rect.Bottom;
                var left   = Rect.Left;
                var right  = Rect.Right;
                var(minSizeX, minSizeY) = CombinedMinimumSize;
                if ((CurrentDrag & DragMode.Top) == DragMode.Top)
                {
                    var maxY = bottom - minSizeY;
                    top = Math.Min(args.GlobalPosition.Y - DragOffsetTopLeft.Y, maxY);
                }
                else if ((CurrentDrag & DragMode.Bottom) == DragMode.Bottom)
                {
                    bottom = Math.Max(args.GlobalPosition.Y + DragOffsetBottomRight.Y, top + minSizeY);
                }

                if ((CurrentDrag & DragMode.Left) == DragMode.Left)
                {
                    var maxX = right - minSizeX;
                    left = Math.Min(args.GlobalPosition.X - DragOffsetTopLeft.X, maxX);
                }
                else if ((CurrentDrag & DragMode.Right) == DragMode.Right)
                {
                    right = Math.Max(args.GlobalPosition.X + DragOffsetBottomRight.X, left + minSizeX);
                }

                var rect = new UIBox2(left, top, right, bottom);
                LayoutContainer.SetPosition(this, rect.TopLeft);
                LayoutContainer.SetSize(this, rect.Size);
            }
        }
 public void MouseMove(GUIMouseMoveEventArgs args)
 {
 }