Beispiel #1
0
        public override bool HandleInput()
        {
            bool captured = false;

            if (!Visible || !CanScroll())
            {
                return(captured);
            }

            var  absolutePosition = OwnerControl.GetPositionAbsoluteCenter() + Position;
            bool mouseOverThis    = MyGuiControlBase.CheckMouseOver(Size, absolutePosition, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            bool mouseOverOwner   = OwnerControl.IsMouseOver;

            IsOverCaret = MyGuiControlBase.CheckMouseOver(CaretSize, absolutePosition + GetCarretPosition(), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);

            switch (State)
            {
            case StateEnum.Ready:
                if (MyInput.Static.IsNewPrimaryButtonPressed() && IsOverCaret)
                {
                    captured    = true;
                    State       = StateEnum.Drag;
                    m_dragClick = MyGuiManager.MouseCursorPosition;
                }
                break;

            case StateEnum.Drag:
                if (!MyInput.Static.IsPrimaryButtonPressed())
                {
                    State = StateEnum.Ready;
                }
                else
                {
                    ChangeValue((MyGuiManager.MouseCursorPosition.Y - m_dragClick.Y) * (Max - Page) / (Size.Y - CaretSize.Y));
                    m_dragClick = MyGuiManager.MouseCursorPosition;
                }
                captured = true;
                break;
            }

            if (mouseOverThis || mouseOverOwner)
            {
                var scrolled = MyInput.Static.DeltaMouseScrollWheelValue();
                if (scrolled != 0 && scrolled != -MyInput.Static.PreviousMouseScrollWheelValue())
                {
                    captured = true;
                    ChangeValue((scrolled / -120f) * Page * 0.25f);
                }
            }

            return(captured);
        }
Beispiel #2
0
        public override void Draw(Color colorMask)
        {
            if (!Visible)
            {
                return;
            }

            var leftTopPosition = OwnerControl.GetPositionAbsoluteCenter() + Position;

            m_backgroundTexture.Draw(leftTopPosition, Size, colorMask);

            if (CanScroll())
            {
                var carretPosition = GetCarretPosition();
                Texture.Draw(leftTopPosition + carretPosition,
                             CaretSize,
                             colorMask);
            }
        }