Exemplo n.º 1
0
        public HitBox HitTest()
        {
            var delta = UiState.ScrollDelta;

            if (delta != 0 && _parent.Bounds.Contains(UiState.Mouse.Position) && KeyboardManager.IsModifierDown(_modifier))
            {
                if (delta > 0)
                {
                    OnScrollBackward?.Invoke(delta / 120);
                }
                else
                {
                    OnScrollForward?.Invoke(delta / 120);
                }
                OnScroll?.Invoke(delta / 120);
                return(HitBox.Hit(_parent));
            }

            return(HitBox.Miss);
        }
        public override HitBox HitTest()
        {
            HitBox hit;

            if (_draggable.HitTest().IsHit)
            {
                var delta  = (int)(_draggable.GetHorizontalMoveDelta() * _dragMultiplier);
                var parent = (ICanHaveHorizontalScrollBar)Parent;
                parent.HorizontalScroll(-delta);
                _draggable.InvalidateDelta();
                return(HitBox.Hit(this));
            }
            else if (MouseManager.IsDown(MouseButton.Left) &&
                     _bgHitBox.Contains(UiState.Mouse.Position))
            {
                var parent             = (ICanHaveHorizontalScrollBar)Parent;
                var hitBoxX            = UiState.Mouse.Position.X - _bgHitBox.Left;
                var scrollPercent      = (float)hitBoxX / _bgHitBox.Width;
                var scrollIndexAtClick = Math.Min((int)(parent.HorizontalMaxScrollIndex * scrollPercent),
                                                  parent.HorizontalMaxScrollIndex);
                parent.HorizontalScrollTo(scrollIndexAtClick);
            }
            else if ((hit = _leftArrow.HitTest()).IsHit)
            {
                return(hit);
            }
            else if ((hit = _rightArrow.HitTest()).IsHit)
            {
                return(hit);
            }
            else if ((hit = _mouseScrollable.HitTest()).IsHit)
            {
                return(hit);
            }

            return(HitBox.Miss);
        }