Example #1
0
		public MouseScrolledEventArgs (long timestamp, double x, double y, ScrollDirection direction)
		{
			X = x;
			Y = y;
			Timestamp  = timestamp;
			Direction = direction;
		}
Example #2
0
 public LScrollView()
 {
     direction = ScrollDirection.BOTH;
     lastMovePoint = Vector2.zero;
     bounceable = true;
     scrollDistance = Vector2.zero;
     dragable = true;
     maxOffset = Vector2.zero;
     minOffset = Vector2.zero;
 }
 public override bool HandleKeyPress(KeyInput e)
 {
     switch (e.KeyName)
     {
         case "up": Keyboard = Keyboard.Set(ScrollDirection.Up, (e.Event == KeyInputEvent.Down)); return true;
         case "down": Keyboard = Keyboard.Set(ScrollDirection.Down, (e.Event == KeyInputEvent.Down)); return true;
         case "left": Keyboard = Keyboard.Set(ScrollDirection.Left, (e.Event == KeyInputEvent.Down)); return true;
         case "right": Keyboard = Keyboard.Set(ScrollDirection.Right, (e.Event == KeyInputEvent.Down)); return true;
     }
     return false;
 }
        public static string GetScrollCursor(Widget w, ScrollDirection edge, int2 pos)
        {
            if (!Game.Settings.Game.ViewportEdgeScroll || Ui.MouseOverWidget != w)
                return null;

            var blockedDirections = Game.viewport.GetBlockedDirections();

            foreach (var dir in directions)
                if (edge.Includes(dir.Key))
                    return dir.Value + (blockedDirections.Includes(dir.Key) ? "-blocked" : "");

            return null;
        }
Example #5
0
 public static Gdk.ScrollDirection ConvertScrollDirection(ScrollDirection d)
 {
     switch (d) {
     case ScrollDirection.Up:
         return Gdk.ScrollDirection.Up;
     case ScrollDirection.Down:
         return Gdk.ScrollDirection.Down;
     case ScrollDirection.Left:
         return Gdk.ScrollDirection.Left;
     case ScrollDirection.Right:
         return Gdk.ScrollDirection.Right;
     }
     throw new InvalidOperationException("Invalid mouse scroll direction value: " + d);
 }
Example #6
0
        private void OnPointChanged() {
            if (_scrolledDirection != ScrollDirection.None
                && PointChanged != null) {

                if (_scrolledDirection.HasFlag(ScrollDirection.Horizontal)) {
                    EnsureXPositions();
                }
                if (_scrolledDirection.HasFlag(ScrollDirection.Vertical)) {
                    EnsureYPositions();
                }

                PointChanged(this, new PointChangedEventArgs(_scrolledDirection));
            }

            _scrolledDirection = ScrollDirection.None;
        }
		protected override void OnScrolled (ScrollDirection direction, ModifierType mod)
		{
			if ((mod & ModifierType.ShiftMask) != ModifierType.ShiftMask)
				return;
			
			int shift = HueShift;
			
			if (direction == Gdk.ScrollDirection.Up)
				shift += 5;
			else if (direction == Gdk.ScrollDirection.Down)
				shift -= 5;
			
			if (shift < 0)
				shift += 360;
			shift %= 360;
			
			HueShift = shift;
		}
Example #8
0
        void TSC_VerifyViewSize(ScrollDirection direction, CodeBinaryOperatorType codeType, double CompareValue, CheckType ct)
        {
            double viewSize = 0;
            switch (direction)
            {
                case ScrollDirection.Horizontal:
                    {
                        viewSize = pattern_getHorizontalViewSize;
                        Comment("Current HorizontalViewSize = " + viewSize + "(" + viewSize.GetType().ToString() + ")");
                        switch (codeType)
                        {
                            case CodeBinaryOperatorType.GreaterThan:
                                {
                                    if (viewSize <= CompareValue)
                                        ThrowMe(ct);

                                    break;
                                }

                            case CodeBinaryOperatorType.LessThan:
                                {
                                    if (viewSize >= CompareValue)
                                        ThrowMe(ct);
                                    break;
                                }

                            case CodeBinaryOperatorType.IdentityEquality:
                                {
                                    if (Math.Abs(viewSize - CompareValue) > _ACCURACY)
                                        ThrowMe(ct);
                                    break;
                                }

                            default:
                                {
                                    throw new NotImplementedException();
                                }
                        }
                    }
                    break;

                case ScrollDirection.Vertical:
                    {
                        viewSize = pattern_getVerticalViewSize;
                        Comment("Current VerticalViewSize = " + viewSize + "(" + viewSize.GetType().ToString() + ")");
                        switch (codeType)
                        {
                            case CodeBinaryOperatorType.GreaterThan:
                                {
                                    if (viewSize <= CompareValue)
                                        ThrowMe(ct);

                                    break;
                                }

                            case CodeBinaryOperatorType.LessThan:
                                {
                                    if (viewSize >= CompareValue)
                                        ThrowMe(ct);

                                    break;
                                }

                            case CodeBinaryOperatorType.IdentityEquality:
                                {
                                    if (Math.Abs(viewSize - CompareValue) > _ACCURACY)
                                        ThrowMe(ct);
                                    break;
                                }

                            default:
                                {
                                    throw new NotImplementedException();
                                }
                        }
                    }
                    break;
            }
            m_TestStep++;
        }
Example #9
0
 public void ScrollMouse(ScrollDirection direction)
 {
     switch (direction)
     {
         case ScrollDirection.Down:
             SendMouseEvent(MouseState.ScrollDown);
             break;
         case ScrollDirection.Up:
             SendMouseEvent(MouseState.ScrollUp);
             break;
     }
 }
Example #10
0
 protected abstract bool OnNestedDirectionFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, ScrollDirection scrollDirection);
Example #11
0
 public ScrollChangedArgs(ScrollDirection scrollDirection, int value)
 {
     Direction = scrollDirection;
     Value     = value;
 }
Example #12
0
 public static bool Includes(this ScrollDirection d, ScrollDirection s)
 {
     return (d & s) == s;
 }
 public override bool LoseFocus(MouseInput mi)
 {
     Keyboard = ScrollDirection.None;
     return base.LoseFocus(mi);
 }
 protected override void loadNewItem(ScrollDirection direction)
 {
     CoroutineRunner.Start(loadNewDailyItem(getNextDaily(direction, 2), direction, 2), this, "LoadDailyItem");
 }
Example #15
0
        private static void ScrollPageHorizontal(ScrollViewer scrollViewer, ScrollDirection direction)
        {
            if (scrollViewer == null || direction == ScrollDirection.None)
            {
                return;
            }

            double actualWidth = scrollViewer.ActualWidth;
            double currentOffset = scrollViewer.HorizontalOffset;
            double newWidth = 0;

            if (direction == ScrollDirection.Left)
            {
                newWidth = currentOffset - actualWidth;
            }
            else if (direction == ScrollDirection.Right)
            {
                newWidth = currentOffset + actualWidth;
            }

            if (newWidth > scrollViewer.ExtentWidth)
            {
                newWidth = currentOffset;
            }

            if (newWidth < 0)
            {
                newWidth = 0;
            }

            scrollViewer.ChangeView(newWidth, null, null);
        }
Example #16
0
        public ScrollBody(ScrollDirection direction)
        {
            Direction = direction;

            Tnc.AddNode(new ScrollThumb(Direction));
        }
        public override bool HandleKeyPress(KeyInput e)
        {
            var key = Hotkey.FromKeyInput(e);

            Func <HotkeyReference, ScrollDirection, bool> handleMapScrollKey = (hotkey, scrollDirection) =>
            {
                var isHotkey = false;
                var keyValue = hotkey.GetValue();
                if (key.Key == keyValue.Key)
                {
                    isHotkey           = key == keyValue;
                    keyboardDirections = keyboardDirections.Set(scrollDirection, e.Event == KeyInputEvent.Down && (isHotkey || keyValue.Modifiers == Modifiers.None));
                }

                return(isHotkey);
            };

            if (handleMapScrollKey(ScrollUpKey, ScrollDirection.Up) || handleMapScrollKey(ScrollDownKey, ScrollDirection.Down) ||
                handleMapScrollKey(ScrollLeftKey, ScrollDirection.Left) || handleMapScrollKey(ScrollRightKey, ScrollDirection.Right))
            {
                return(true);
            }

            if (e.Event != KeyInputEvent.Down)
            {
                return(false);
            }

            if (ZoomInKey.IsActivatedBy(e))
            {
                worldRenderer.Viewport.AdjustZoom(0.25f);
                return(true);
            }

            if (ZoomOutKey.IsActivatedBy(e))
            {
                worldRenderer.Viewport.AdjustZoom(-0.25f);
                return(true);
            }

            if (JumpToTopEdgeKey.IsActivatedBy(e))
            {
                worldRenderer.Viewport.Center(new WPos(worldRenderer.Viewport.CenterPosition.X, 0, 0));
                return(true);
            }

            if (JumpToBottomEdgeKey.IsActivatedBy(e))
            {
                worldRenderer.Viewport.Center(new WPos(worldRenderer.Viewport.CenterPosition.X, worldRenderer.World.Map.ProjectedBottomRight.Y, 0));
                return(true);
            }

            if (JumpToLeftEdgeKey.IsActivatedBy(e))
            {
                worldRenderer.Viewport.Center(new WPos(0, worldRenderer.Viewport.CenterPosition.Y, 0));
                return(true);
            }

            if (JumpToRightEdgeKey.IsActivatedBy(e))
            {
                worldRenderer.Viewport.Center(new WPos(worldRenderer.World.Map.ProjectedBottomRight.X, worldRenderer.Viewport.CenterPosition.Y, 0));
                return(true);
            }

            for (var i = 0; i < saveBookmarkHotkeys.Length; i++)
            {
                if (saveBookmarkHotkeys[i].IsActivatedBy(e))
                {
                    bookmarkPositions[i] = worldRenderer.Viewport.CenterPosition;
                    return(true);
                }
            }

            for (var i = 0; i < restoreBookmarkHotkeys.Length; i++)
            {
                if (restoreBookmarkHotkeys[i].IsActivatedBy(e))
                {
                    var bookmark = bookmarkPositions[i];
                    if (bookmark.HasValue)
                    {
                        worldRenderer.Viewport.Center(bookmark.Value);
                        return(true);
                    }
                }
            }

            return(world.OrderGenerator.HandleKeyPress(e));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override public void onNestedVerticalScrollConsumed(Android.Support.Design.Widget.CoordinatorLayout coordinatorLayout, V child, @ScrollDirection int scrollDirection, int currentOverScroll, int totalConsumedScroll)
        public override void onNestedVerticalScrollConsumed(CoordinatorLayout coordinatorLayout, V child, ScrollDirection scrollDirection, int currentOverScroll, int totalConsumedScroll)
        {
            handleDirection(coordinatorLayout, child, scrollDirection);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override protected boolean onNestedDirectionFling(Android.Support.Design.Widget.CoordinatorLayout coordinatorLayout, V child, Android.View.View target, float velocityX, float velocityY, boolean consumed, @ScrollDirection int scrollDirection)
        protected override bool onNestedDirectionFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, bool consumed, ScrollDirection scrollDirection)
        {
            //        if (consumed) {
            //            handleDirection(child, scrollDirection);
            //        }
            return(consumed);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override public void onNestedVerticalPreScroll(Android.Support.Design.Widget.CoordinatorLayout coordinatorLayout, V child, Android.View.View target, int dx, int dy, int[] consumed, @ScrollDirection int scrollDirection)
        public override void onNestedVerticalPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed, ScrollDirection scrollDirection)
        {
            //        handleDirection(child, scrollDirection);
        }
        public override void Tick(World world)
        {
            Edge = ScrollDirection.None;
            if (Game.Settings.Game.ViewportEdgeScroll && Game.HasInputFocus)
            {
                // Check for edge-scroll
                if (Viewport.LastMousePos.X < EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Left, true);
                if (Viewport.LastMousePos.Y < EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Up, true);
                if (Viewport.LastMousePos.X >= Game.viewport.Width - EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Right, true);
                if (Viewport.LastMousePos.Y >= Game.viewport.Height - EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Down, true);
            }

            if(Keyboard != ScrollDirection.None || Edge != ScrollDirection.None)
            {
                var scroll = new float2(0, 0);

                // Modified to use the ViewportEdgeScrollStep setting - Gecko
                if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up))
                    scroll += new float2(0, -(Game.Settings.Game.ViewportEdgeScrollStep * 100));
                if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right))
                    scroll += new float2((Game.Settings.Game.ViewportEdgeScrollStep * 100), 0);
                if (Keyboard.Includes(ScrollDirection.Down) || Edge.Includes(ScrollDirection.Down))
                    scroll += new float2(0, (Game.Settings.Game.ViewportEdgeScrollStep * 100));
                if (Keyboard.Includes(ScrollDirection.Left) || Edge.Includes(ScrollDirection.Left))
                    scroll += new float2(-(Game.Settings.Game.ViewportEdgeScrollStep * 100), 0);

                Game.viewport.Scroll(scroll);
            }
        }
        private ClubPenguin.Task.Task getNextDaily(ScrollDirection direction, int aheadCount)
        {
            int nextItemIndex = getNextItemIndex(direction, aheadCount);

            return(dailyChallenges[nextItemIndex]);
        }
Example #23
0
 private void OnOffsetChanged(ScrollDirection direction, int firstRow)
 {
     ScrollReceiver?.ScrollChanged(new ScrollChangedArgs(direction, firstRow));
 }
Example #24
0
 public void SendScrolled(double percent, ScrollDirection direction)
 {
     Scrolled?.Invoke(this, new ScrolledEventArgs {
         NewValue = percent, Direction = direction
     });
 }
        ///////////////////////////////////////////////////////////////////////////
        // Auto Hide Handling
        ///////////////////////////////////////////////////////////////////////////

        //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
        //ORIGINAL LINE: @Override public void onNestedVerticalScrollUnconsumed(Android.Support.Design.Widget.CoordinatorLayout coordinatorLayout, V child, @ScrollDirection int scrollDirection, int currentOverScroll, int totalScroll)

        public override void onNestedVerticalScrollUnconsumed(CoordinatorLayout coordinatorLayout, V child, ScrollDirection scrollDirection, int currentOverScroll, int totalScroll)
        {
            // Empty body
        }
Example #26
0
 public ScrollEventArgs(ScrollDirection direction, Point mousePosition, int value)
 {
     Direction     = direction;
     MousePosition = mousePosition;
     Value         = value;
 }
        public override void Tick()
        {
            Edge = ScrollDirection.None;
            if (Game.Settings.Game.ViewportEdgeScroll && Game.HasInputFocus && Widget.MouseOverWidget == this)
            {
                // Check for edge-scroll
                if (Viewport.LastMousePos.X < EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Left, true);
                if (Viewport.LastMousePos.Y < EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Up, true);
                if (Viewport.LastMousePos.X >= Game.viewport.Width - EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Right, true);
                if (Viewport.LastMousePos.Y >= Game.viewport.Height - EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Down, true);
            }

            if(Keyboard != ScrollDirection.None || Edge != ScrollDirection.None)
            {
                var scroll = new float2(0, 0);

                // Modified to use the ViewportEdgeScrollStep setting - Gecko
                if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up))
                    scroll += new float2(0, -1);
                if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right))
                    scroll += new float2(1, 0);
                if (Keyboard.Includes(ScrollDirection.Down) || Edge.Includes(ScrollDirection.Down))
                    scroll += new float2(0, 1);
                if (Keyboard.Includes(ScrollDirection.Left) || Edge.Includes(ScrollDirection.Left))
                    scroll += new float2(-1, 0);

                float length = Math.Max(1, scroll.Length);
                scroll.X = (scroll.X / length) * Game.Settings.Game.ViewportEdgeScrollStep;
                scroll.Y = (scroll.Y / length) * Game.Settings.Game.ViewportEdgeScrollStep;

                Game.viewport.Scroll(scroll);
            }

            base.Tick();
        }
Example #28
0
 /// <summary>
 ///     Start the display scrollling in the specified direction.
 /// </summary>
 /// <param name="direction">Direction that the display should scroll.</param>
 public void StartScrolling(ScrollDirection direction)
 {
     StartScrolling(direction, 0x00, 0xff);
 }
Example #29
0
        public override void Update(GameTime gameTime)
        {
            _itemsContainer.Position = new Point(Left, Top);
            //MultiTextBox mtb = Parent as MultiTextBox;

            Point lastPosition      = SliderButton.Position;
            Point lastMousePosition = MouseGUI.Position;

            _itemsContainer.Update(gameTime);
            if (MouseGUI.Focus == SliderButton)
            {
                Point delta = MouseGUI.Position - SliderButton.Center;

                direction = delta.Y > 0 ? ScrollDirection.DOWN : delta.Y < 0 ? ScrollDirection.UP : ScrollDirection.NONE;

                if (direction == ScrollDirection.DOWN)
                {
                    if (GetBounds(delta.Y) == 0)
                    {
                        var slider = _itemsContainer[SliderButton].Position;
                        _itemsContainer.UpdateSlot(SliderButton, new Point(slider.X, slider.Y + delta.Y));

                        _scrollEvent.OnScroll(Parent, ScrollDirection.DOWN, delta.Y);
                    }
                    else
                    {
                        var down = _itemsContainer[DownButton].Position;
                        _itemsContainer.UpdateSlot(SliderButton, new Point(down.X, down.Y - SliderButton.Height));
                    }
                }
                else
                {
                    if (direction == ScrollDirection.UP)
                    {
                        if (GetBounds(delta.Y) == 0)
                        {
                            var slider = _itemsContainer[SliderButton].Position;
                            _itemsContainer.UpdateSlot(SliderButton, new Point(slider.X, slider.Y + delta.Y));

                            _scrollEvent.OnScroll(Parent, ScrollDirection.UP, delta.Y);
                        }
                        else
                        {
                            var up = _itemsContainer[UpButton].Position;
                            _itemsContainer.UpdateSlot(SliderButton, new Point(up.X, up.Y + UpButton.Height));
                        }
                    }
                }
            }
            else
            {
                IScrollable parent = (Parent as IScrollable);
                if (parent.NumberOfLines > parent.MaxLinesLength)
                {
                    var slot  = _itemsContainer[SliderButton];
                    int delta = (slot.Position.Y + CurrentScrollValue) - slot.Position.Y;

                    if (delta > 0)
                    {
                        _itemsContainer.UpdateSlot(SliderButton, new Point(slot.Position.X, DownButton.Height + CurrentScrollValue));
                    }
                }
            }

            base.Update(gameTime);
        }
Example #30
0
 private void StartScrolling(ScrollDirection direction)
 {
     Scrolling       = true;
     ScrollTween     = 1f;
     scrollDirection = direction;
 }
 /// <summary>
 /// Adds the bullet, then it will display the bullet screen effect..
 /// </summary>
 /// <param name="textContent">Text content.</param>
 /// <param name="showBox">If set to <c>true</c> show box.</param>
 /// <param name="direction">Direction.</param>
 public void AddBullet(string name, string content, bool showBox = false, ScrollDirection direction = ScrollDirection.RightToLeft,
                       Sprite head = null, Sprite photo = null)
 {
     CombScreenTextElement.Create(this, name, content, showBox, direction, head, photo);
 }
Example #32
0
 public override string ToString()
 {
     return(ScrollDirection.ToString());
 }
Example #33
0
 /// <summary>
 /// Ons the direction nested pre scroll.
 /// </summary>
 /// <param name="scrollDirection">Direction of the overscroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN</param>
 public abstract void onDirectionNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed, ScrollDirection scrollDirection);
Example #34
0
 public void didUpdateScrollDirection(ScrollDirection direction)
 {
     new UserScrollNotification(metrics:
                                ScrollMetricsUtils.copyWith(this), context: this.context.notificationContext, direction: direction
                                ).dispatch(this.context.notificationContext);
 }
Example #35
0
        /// -------------------------------------------------------------------
        /// <summary>Changes the position to a new random position if the two are the same</summary>
        /// -------------------------------------------------------------------
        private void VerifyNotSame(ref double positionToChange, string positionToChangeStr, double otherPosition, string otherPositionStr, ArrayList validPositions, ScrollDirection scrollDirection, double min, double max, RandomBoundaries boundaries, CheckType checkType)
        {
            if (positionToChange.Equals(otherPosition))  
            {
                if (validPositions.Count < 4)
                    ThrowMe(CheckType.IncorrectElementConfiguration, validPositions.Count.ToString() + " valid scroll positions, not enough for test (4 minimum). Is your display resolution set too low?");

                for (int i = 0; i < 10 && (positionToChange.Equals(otherPosition)); i++)
                {
                    Comment("\"{0}\"({1}) and \"{2}\"({3}) were found to be the same. Find a new \"{0}\"", positionToChange, positionToChangeStr, otherPosition, otherPositionStr);

                    // false says don't incremenet m_TestStep TSC_RandomPosition
                    positionToChange = TSC_RandomPosition(scrollDirection, min, max, boundaries, false, checkType);
                }
                if (positionToChange.Equals(otherPosition))
                    ThrowMe(CheckType.Verification, "Cannot find a random \"{0}\" position", positionToChangeStr);

                Comment("Found new \"{0}\" position : {1}", positionToChangeStr, positionToChange);
            }
        }
 public void ScrollViewportVerticallyByLines(ScrollDirection direction, int count)
 {
     Console.WriteLine("ScrollViewportVerticallyByLines");
 }
Example #37
0
 /// <summary>
 /// Ons the direction nested pre scroll.
 /// </summary>
 /// <param name="coordinatorLayout">
 /// <param name="child"></param>
 /// <param name="direction">Direction of the overscroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN</param>
 /// <param name="currentOverScroll">Unconsumed value, negative or positive based on the direction</param>
 /// <param name="totalOverScroll">Cumulative value for current direction</param>
 public abstract void onNestedVerticalOverScroll(CoordinatorLayout coordinatorLayout, V child, ScrollDirection direction, int currentOverScroll, int totalOverScroll);
Example #38
0
        private void SetScrollBar(ScrollDirection direction) {
            if (direction.HasFlag(ScrollDirection.Horizontal)) {
                HorizontalScrollBar.ViewportSize = Points.ViewportWidth;
                HorizontalScrollBar.Maximum = Points.HorizontalExtent - Points.ViewportWidth;
                HorizontalScrollBar.Value = Points.HorizontalOffset;
            }

            if (direction.HasFlag(ScrollDirection.Vertical)) {
                VerticalScrollBar.ViewportSize = Points.ViewportHeight;
                VerticalScrollBar.Maximum = Points.VerticalExtent - Points.ViewportHeight;
                VerticalScrollBar.Value = Points.VerticalOffset;
            }
        }
		static double GetWheelDelta (Adjustment adjustment, ScrollDirection direction)
		{
			double delta = adjustment.StepIncrement * 4;
			if (direction == ScrollDirection.Up || direction == ScrollDirection.Left)
				delta = -delta;
			return delta;
		}
Example #40
0
 /// <summary>
 /// Does the programmatic scrolling for this element.
 /// </summary>
 /// <param name="scrollDirection">The direction to scroll.</param>
 /// <param name="scrollAmount">The amount to scroll.</param>
 /// <seealso cref="InitializeProgrammaticScroll"/>
 public override void ScrollProgrammatically(ScrollDirection scrollDirection, ScrollAmount scrollAmount)
 {
     // Should never get called because InitializeProgrammaticScroll() returns false.
     throw new NotSupportedException();
 }
Example #41
0
        private static void ScrollPageVertical(ScrollViewer scrollViewer, ScrollDirection direction)
        {
            if (scrollViewer == null || direction == ScrollDirection.None)
            {
                return;
            }

            double actualHeight = scrollViewer.ActualHeight;
            double currentOffset = scrollViewer.VerticalOffset;
            double newHeight = 0;

            if (direction == ScrollDirection.Up)
            {
                newHeight = currentOffset - actualHeight;
            }
            else if (direction == ScrollDirection.Down)
            {
                newHeight = currentOffset + actualHeight;
            }

            if (newHeight > scrollViewer.ExtentHeight)
            {
                newHeight = currentOffset;
            }

            if (newHeight < 0)
            {
                newHeight = 0;
            }

            scrollViewer.ChangeView(null, newHeight, null);
        }
        public override void Tick()
        {
            edgeDirections = ScrollDirection.None;
            if (Game.Settings.Game.ViewportEdgeScroll && Game.HasInputFocus)
                edgeDirections = CheckForDirections();

            if (keyboardDirections != ScrollDirection.None || edgeDirections != ScrollDirection.None)
            {
                var scroll = float2.Zero;

                foreach (var kv in ScrollOffsets)
                    if (keyboardDirections.Includes(kv.Key) || edgeDirections.Includes(kv.Key))
                        scroll += kv.Value;

                var length = Math.Max(1, scroll.Length);
                scroll *= (1f / length) * Game.Settings.Game.ViewportEdgeScrollStep;

                worldRenderer.Viewport.Scroll(scroll, false);
            }
        }
Example #43
0
 /// <summary>
 ///     Calculates the position of the Hit Object with a position offset.
 /// </summary>
 /// <returns></returns>
 public float GetSpritePosition(long offset) => HitPosition + ((InitialTrackPosition - offset) * (ScrollDirection.Equals(ScrollDirection.Down) ? -HitObjectManagerKeys.ScrollSpeed : HitObjectManagerKeys.ScrollSpeed) / HitObjectManagerKeys.TrackRounding);
Example #44
0
 public Layout(ScrollDirection direction, Widget content, Widget slider) : base(direction, content)
 {
     this.slider = slider;
 }
 public bool ScrollViewportVerticallyByPage(ScrollDirection direction)
 {
     throw new NotImplementedException();
 }
Example #46
0
        /// <summary>
        ///     Updates the HitObject sprite positions
        /// </summary>
        public void UpdateSpritePositions(long offset)
        {
            // Update Sprite position with regards to LN's state
            //
            // If the LN end is not drawn, don't move the LN start up with time since it ends up sliding above the LN in
            // the end.
            if (CurrentlyBeingHeld && SkinManager.Skin.Keys[Ruleset.Mode].DrawLongNoteEnd)
            {
                if (offset > InitialTrackPosition)
                {
                    UpdateLongNoteSize(offset);
                    SpritePosition = HitPosition;
                }
                else
                {
                    CurrentLongNoteSize = InitialLongNoteSize;
                    SpritePosition      = GetSpritePosition(offset);
                }
            }
            else
            {
                SpritePosition = GetSpritePosition(offset);
            }

            // Update HitBody
            HitObjectSprite.Y = SpritePosition;

            // Disregard the rest if it isn't a long note.
            if (!Info.IsLongNote)
            {
                return;
            }

            // Don't draw the body if the length is <= 0. Note that this does not mean that the LN should be hidden
            // altogether: very short LNs, including zero-size on some SV maps after SV adjustment, have this below zero
            // because CurrentLongNoteSize does not include half of the HitObjectSprite and half of the
            // LongNoteEndSprite.
            if (CurrentLongNoteSize <= 0)
            {
                LongNoteBodySprite.Visible = false;
            }

            // However, if the LN end is drawn and the actual LN size is <= 0, we can stop drawing the LN end as it has
            // probably been completely overlapped by the LN start at this point (and is sliding below the receptors).
            if (CurrentLongNoteSize + LongNoteSizeDifference <= 0)
            {
                LongNoteEndSprite.Visible = false;
            }

            //Update HoldBody Position and Size
            LongNoteBodySprite.Height = CurrentLongNoteSize;

            if (ScrollDirection.Equals(ScrollDirection.Down))
            {
                LongNoteBodySprite.Y = SpritePosition + LongNoteBodyOffset - CurrentLongNoteSize;
                LongNoteEndSprite.Y  = SpritePosition + LongNoteBodyOffset - CurrentLongNoteSize - LongNoteEndOffset;
            }
            else
            {
                LongNoteBodySprite.Y = SpritePosition + LongNoteBodyOffset;
                LongNoteEndSprite.Y  = SpritePosition + LongNoteBodyOffset + CurrentLongNoteSize - LongNoteEndOffset;
            }
        }
Example #47
0
 /// <summary>
 /// Gets the amount scrolled in percentage.
 /// </summary>
 /// <param name="srollDirection">The direction for which data is required.</param>
 /// <param name="scrollElement">The element which is either the vertical or horizontal scroll bar.</param>
 /// <returns>The amount in percentage.</returns>
 /// <seealso cref="InitializeProgrammaticScroll"/>
 public override int GetScrolledPercentage(ScrollDirection scrollDirection, IUITechnologyElement scrollElement)
 {
     // Should never get called because InitializeProgrammaticScroll() returns false.
     throw new NotSupportedException();
 }
        void OnScroll(ScrollDirection value, double xCoordinate)
        {
            ITextViewLine line;
            SnapshotPoint lineStart;

            switch (value)
            {
            case ScrollDirection.Left:
                line = wpfTextView.Caret.ContainingTextViewLine;
                if (line.TextLeft >= wpfTextView.ViewportLeft)
                {
                    StopScrolling();
                }
                else if (wpfTextView.Caret.InVirtualSpace || wpfTextView.Caret.Position.BufferPosition != line.Start)
                {
                    editorOperations.MoveToPreviousCharacter(true);
                }
                else
                {
                    wpfTextView.ViewportLeft = line.TextLeft;
                    StopScrolling();
                }
                break;

            case ScrollDirection.Right:
                line = wpfTextView.Caret.ContainingTextViewLine;
                if (line.TextRight <= wpfTextView.ViewportRight)
                {
                    StopScrolling();
                }
                else if (wpfTextView.Caret.InVirtualSpace || wpfTextView.Caret.Position.BufferPosition < line.End)
                {
                    editorOperations.MoveToNextCharacter(true);
                }
                else
                {
                    wpfTextView.ViewportLeft = Math.Max(0, line.TextRight - wpfTextView.ViewportWidth);
                    StopScrolling();
                }
                break;

            case ScrollDirection.Up:
                line = wpfTextView.TextViewLines.FirstVisibleLine;
                if (line.VisibilityState == VisibilityState.FullyVisible && !line.IsFirstDocumentLine())
                {
                    line = wpfTextView.GetTextViewLineContainingBufferPosition(line.Start - 1);
                }
                lineStart = line.Start;
                if (line.VisibilityState != VisibilityState.FullyVisible)
                {
                    wpfTextView.DisplayTextLineContainingBufferPosition(line.Start, 0, ViewRelativePosition.Top);
                }
                if (!line.IsValid)
                {
                    line = wpfTextView.GetTextViewLineContainingBufferPosition(lineStart);
                }
                if (line.IsFirstDocumentLine())
                {
                    StopScrolling();
                }
                editorOperations.MoveCaret(line, xCoordinate, true);
                break;

            case ScrollDirection.Down:
                line = wpfTextView.TextViewLines.LastVisibleLine;
                if (line.VisibilityState == VisibilityState.FullyVisible && !line.IsLastDocumentLine())
                {
                    line = wpfTextView.GetTextViewLineContainingBufferPosition(line.GetPointAfterLineBreak());
                }
                lineStart = line.Start;
                if (line.VisibilityState != VisibilityState.FullyVisible)
                {
                    wpfTextView.DisplayTextLineContainingBufferPosition(line.Start, 0, ViewRelativePosition.Bottom);
                }
                if (!line.IsValid)
                {
                    line = wpfTextView.GetTextViewLineContainingBufferPosition(lineStart);
                }
                if (line.IsLastDocumentLine())
                {
                    StopScrolling();
                }
                editorOperations.MoveCaret(line, xCoordinate, true);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(value));
            }

            wpfTextView.Caret.EnsureVisible();
        }
        public override bool HandleKeyPress(KeyInput e)
        {
            var key = Hotkey.FromKeyInput(e);
            var ks = Game.Settings.Keys;

            if (key == ks.MapScrollUp)
            {
                keyboardDirections = keyboardDirections.Set(ScrollDirection.Up, e.Event == KeyInputEvent.Down);
                return true;
            }

            if (key == ks.MapScrollDown)
            {
                keyboardDirections = keyboardDirections.Set(ScrollDirection.Down, e.Event == KeyInputEvent.Down);
                return true;
            }

            if (key == ks.MapScrollLeft)
            {
                keyboardDirections = keyboardDirections.Set(ScrollDirection.Left, e.Event == KeyInputEvent.Down);
                return true;
            }

            if (key == ks.MapScrollRight)
            {
                keyboardDirections = keyboardDirections.Set(ScrollDirection.Right, e.Event == KeyInputEvent.Down);
                return true;
            }

            return false;
        }
Example #50
0
 public static bool Includes(this ScrollDirection d, ScrollDirection s)
 {
     // PERF: Enum.HasFlag is slower and requires allocations.
     return((d & s) == s);
 }
 public override bool YieldKeyboardFocus()
 {
     keyboardDirections = ScrollDirection.None;
     return base.YieldKeyboardFocus();
 }
Example #52
0
 public static ScrollDirection Set(this ScrollDirection d, ScrollDirection s, bool val)
 {
     return((d.Includes(s) != val) ? d ^ s : d);
 }
Example #53
0
 public static ScrollDirection Set(this ScrollDirection d, ScrollDirection s, bool val)
 {
     return (d.Includes(s) != val) ? d ^ s : d;
 }
 public override bool YieldKeyboardFocus()
 {
     keyboardDirections = ScrollDirection.None;
     return(base.YieldKeyboardFocus());
 }
Example #55
0
 public ScrollEvent(ScrollDirection direction)
 {
     Direction = direction;
 }
Example #56
0
        public bool ScrollViewportVerticallyByPage(ScrollDirection direction)
        {
            bool hasFullyVisibleLines = textView.TextViewLines.Any(a => a.VisibilityState == VisibilityState.FullyVisible);

            if (direction == ScrollDirection.Up)
            {
                var firstVisibleLine = textView.TextViewLines.FirstVisibleLine;
                if (firstVisibleLine.Height > textView.ViewportHeight)
                {
                    ScrollViewportVerticallyByPixels(textView.ViewportHeight);
                    return(hasFullyVisibleLines);
                }
                double top;
                if (firstVisibleLine.VisibilityState == VisibilityState.FullyVisible)
                {
                    if (firstVisibleLine.IsFirstDocumentLine())
                    {
                        return(hasFullyVisibleLines);
                    }
                    top = firstVisibleLine.Top;
                }
                else
                {
                    top = firstVisibleLine.Bottom;                     // Top of next line, which is possibly not in TextViewLines so we can't use its Top prop
                }
                var line = firstVisibleLine;
                // Top is only valid if the line is in TextViewLines, so use this variable to track the correct line top value
                double lineTop  = line.Top;
                var    prevLine = line;
                // Cache this since prevLine could've been disposed when we need to access this property
                var prevLineStart = prevLine.Start;
                while (lineTop + textView.ViewportHeight > top)
                {
                    prevLine      = line;
                    prevLineStart = prevLine.Start;
                    if (line.IsFirstDocumentLine())
                    {
                        break;
                    }
                    line = textView.GetTextViewLineContainingBufferPosition(line.Start - 1);
                    if (line.VisibilityState == VisibilityState.Unattached)
                    {
                        // Height is only fully initialized once it's been shown on the screen
                        // (its LineTransform property is used to calculate Height)
                        var lineStart = line.Start;
                        textView.DisplayTextLineContainingBufferPosition(lineStart, 0, ViewRelativePosition.Bottom);
                        line = textView.GetTextViewLineContainingBufferPosition(lineStart);
                        Debug.Assert(line.VisibilityState != VisibilityState.Unattached);
                    }
                    lineTop -= line.Height;
                }
                textView.DisplayTextLineContainingBufferPosition(prevLineStart, 0, ViewRelativePosition.Top);
            }
            else
            {
                Debug.Assert(direction == ScrollDirection.Down);
                double pixels          = textView.ViewportHeight;
                var    lastVisibleLine = textView.TextViewLines.LastVisibleLine;
                if (lastVisibleLine.Height > textView.ViewportHeight)
                {
                    // This line intentionally left blank
                }
                else if (lastVisibleLine.VisibilityState == VisibilityState.FullyVisible)
                {
                    if (lastVisibleLine.IsLastDocumentLine())
                    {
                        textView.DisplayTextLineContainingBufferPosition(lastVisibleLine.Start, 0, ViewRelativePosition.Top);
                        return(hasFullyVisibleLines);
                    }
                }
                else
                {
                    pixels -= textView.ViewportBottom - lastVisibleLine.Top;
                }
                ScrollViewportVerticallyByPixels(-pixels);
            }

            return(hasFullyVisibleLines);
        }
 public override void Tick()
 {
     Edge = ScrollDirection.None;
     if (Game.Settings.Game.ViewportEdgeScroll && Game.HasInputFocus)
     {
         Edge = CheckForDirections();
         Scroll();
     }
 }
Example #58
0
 public void ScrollViewportVerticallyByLine(ScrollDirection direction) => ScrollViewportVerticallyByLines(direction, 1);
Example #59
0
		static double GetWheelDelta (Scrollbar scrollbar, ScrollDirection direction)
		{
			double delta = System.Math.Pow (scrollbar.Adjustment.PageSize, 2.0 / 3.0);
			if (direction == ScrollDirection.Up || direction == ScrollDirection.Left)
				delta = -delta;
			if (scrollbar.Inverted)
				delta = -delta;
			return delta;
		}
Example #60
0
 public override bool OnNestedFling(CoordinatorLayout coordinatorLayout, Java.Lang.Object child, View target, float velocityX, float velocityY, bool consumed)
 {
     base.OnNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
     _scrollDirection = velocityY > 0 ? ScrollDirection.SCROLL_DIRECTION_UP : ScrollDirection.SCROLL_DIRECTION_DOWN;
     return(OnNestedDirectionFling(coordinatorLayout, (V)child, target, velocityX, velocityY, _scrollDirection));
 }