Ejemplo n.º 1
0
        protected override bool OnScrollEvent(EventScroll evnt)
        {
            if ((evnt.State & ModifierType.ShiftMask) == 0)              //no shift, let's zoom
            {
                ZoomAboutPoint((evnt.Direction == ScrollDirection.Up || evnt.Direction == ScrollDirection.Right) ? ZOOM_FACTOR : 1.0 / ZOOM_FACTOR,
                               (int)evnt.X, (int)evnt.Y);
                return(true);
            }

            int x_incr = (int)Hadjustment.PageIncrement / 4;
            int y_incr = (int)Vadjustment.PageIncrement / 4;

            if ((evnt.State & ModifierType.ControlMask) == 0)              //no control scroll
            {
                ScrollBy((evnt.Direction == ScrollDirection.Left) ? -x_incr : (evnt.Direction == ScrollDirection.Right) ? x_incr : 0,
                         (evnt.Direction == ScrollDirection.Up) ? -y_incr : (evnt.Direction == ScrollDirection.Down) ? y_incr : 0);
                return(true);
            }
            else                 //invert x and y for scrolling
            {
                ScrollBy((evnt.Direction == ScrollDirection.Up) ? -y_incr : (evnt.Direction == ScrollDirection.Down) ? y_incr : 0,
                         (evnt.Direction == ScrollDirection.Left) ? -x_incr : (evnt.Direction == ScrollDirection.Right) ? x_incr : 0);
                return(true);
            }
        }
Ejemplo n.º 2
0
        protected override bool OnScrollEvent(EventScroll evnt)
        {
            double step  = 1;
            var    delta = new Vector();

            if (evnt.Direction == ScrollDirection.Down)
            {
                delta = new Vector(0, -step);
            }
            else if (evnt.Direction == ScrollDirection.Up)
            {
                delta = new Vector(0, step);
            }
            else if (evnt.Direction == ScrollDirection.Right)
            {
                delta = new Vector(-step, 0);
            }
            if (evnt.Direction == ScrollDirection.Left)
            {
                delta = new Vector(step, 0);
            }
            var e = new RawMouseWheelEventArgs(GtkMouseDevice.Instance, evnt.Time, _inputRoot, new Point(evnt.X, evnt.Y), delta, GetModifierKeys(evnt.State));

            Input(e);
            return(base.OnScrollEvent(evnt));
        }
Ejemplo n.º 3
0
        protected override bool OnScrollEvent(EventScroll e)
        {
            int delta;

#if NETFRAMEWORK
            delta = e.Direction == Gdk.ScrollDirection.Down ? -120 : 120;
#else
            if (e.Direction == Gdk.ScrollDirection.Smooth)
            {
                delta = e.DeltaY < 0 ? mouseWheelScrollRows : -mouseWheelScrollRows;
            }
            else
            {
                delta = e.Direction == Gdk.ScrollDirection.Down ? -mouseWheelScrollRows : mouseWheelScrollRows;
            }
#endif
            if (delta < 0)
            {
                ScrollDown();
            }
            else
            {
                ScrollUp();
            }
            Refresh();
            return(true);
        }
Ejemplo n.º 4
0
 protected override bool OnScrollEvent(EventScroll evnt)
 {
     if (!this.IsFocus)
     {
         return(false);
     }
     return(base.OnScrollEvent(evnt));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates the mouse wheel event arguments.
 /// </summary>
 /// <param name="e">The scroll event args.</param>
 /// <returns>Mouse event arguments.</returns>
 public static OxyMouseWheelEventArgs ToMouseWheelEventArgs(this EventScroll e)
 {
     return(new OxyMouseWheelEventArgs
     {
         Delta = e.Direction == ScrollDirection.Down ? -120 : 120,
         Position = new ScreenPoint(e.X, e.Y),
         ModifierKeys = GetModifiers(e.State)
     });
 }
Ejemplo n.º 6
0
 protected override bool OnScrollEvent(EventScroll evnt)
 {
     if (string.IsNullOrEmpty(this.Text) || !this.IsFocus)
     {
         return(false);
     }
     this.KeyScroll(evnt.Direction == ScrollDirection.Up ? 0 : 1);
     return(true);
 }
Ejemplo n.º 7
0
        protected override bool OnScrollEvent(EventScroll evnt)
        {
            Scrollbar scrollWidget = (evnt.Direction == ScrollDirection.Up || evnt.Direction == ScrollDirection.Down) ? (Scrollbar)vScrollBar : leftHScrollBar;

            if (scrollWidget.Visible)
            {
                double newValue = scrollWidget.Adjustment.Value + GetWheelDelta(scrollWidget, evnt.Direction);
                newValue = System.Math.Max(System.Math.Min(scrollWidget.Adjustment.Upper - scrollWidget.Adjustment.PageSize, newValue), scrollWidget.Adjustment.Lower);
                scrollWidget.Adjustment.Value = newValue;
            }
            return(base.OnScrollEvent(evnt));
        }
Ejemplo n.º 8
0
        protected override bool OnScrollEvent(EventScroll evnt)
        {
            var adjustment = (evnt.Direction == ScrollDirection.Up || evnt.Direction == ScrollDirection.Down) ? vAdjustment : hAdjustment;

            if (adjustment.PageSize < adjustment.Upper)
            {
                double newValue = adjustment.Value + GetWheelDelta(adjustment, evnt.Direction);
                newValue         = System.Math.Max(System.Math.Min(adjustment.Upper - adjustment.PageSize, newValue), adjustment.Lower);
                adjustment.Value = newValue;
            }
            return(base.OnScrollEvent(evnt));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Called when [scroll event].
        /// </summary>
        /// <param name="evnt">The evnt.</param>
        /// <returns></returns>
        protected override bool OnScrollEvent(EventScroll evnt)
        {
            if (evnt.Direction == ScrollDirection.Up)
            {
                WaveServices.Input.MouseState.Wheel += 1;
            }
            else if (evnt.Direction == ScrollDirection.Down)
            {
                WaveServices.Input.MouseState.Wheel -= 1;
            }

            return(base.OnScrollEvent(evnt));
        }
Ejemplo n.º 10
0
        protected override bool OnScrollEvent(EventScroll evnt)
        {
            var scrollWidget = (evnt.Direction == ScrollDirection.Up || evnt.Direction == ScrollDirection.Down) ? vScrollBar : hScrollBar;
            var adj          = (evnt.Direction == ScrollDirection.Up || evnt.Direction == ScrollDirection.Down) ? vAdjustment : hAdjustment;

            if (scrollWidget.Visible)
            {
                double newValue = adj.Value + GetWheelDelta(adj, evnt.Direction, scrollWidget is Scrollbar ?  ((Scrollbar)scrollWidget).Inverted : false);
                newValue  = System.Math.Max(System.Math.Min(adj.Upper - adj.PageSize, newValue), adj.Lower);
                adj.Value = newValue;
            }
            return(base.OnScrollEvent(evnt));
        }
Ejemplo n.º 11
0
        private static bool GetContact(Event evt)
        {
            var state = evt switch
            {
                EventMotion motion => motion.State,
                EventButton button when button.Type == EventType.ButtonPress => ModifierType.Button1Mask,
                EventScroll scroll => scroll.State,
                _ => ModifierType.None,
            };

            return
                (state.HasFlag(ModifierType.Button1Mask) ||
                 state.HasFlag(ModifierType.Button2Mask) ||
                 state.HasFlag(ModifierType.Button3Mask));
        }
Ejemplo n.º 12
0
            private void ProcessEventScroll(EventScroll ev)
            {
                var windowReg = FindWindow(ev.Window);

                if (windowReg == null)
                {
                    return;
                }

                var eventArgs = new MouseWheelEventArgs(
                    ((float)ev.XOffset, (float)ev.YOffset),
                    new ScreenCoordinates(windowReg.LastMousePos, windowReg.Id));

                _clyde.SendScroll(eventArgs);
            }
Ejemplo n.º 13
0
        //MOUSE WHEEL
        protected override bool OnScrollEvent(EventScroll evnt)
        {
            //daca este inainte este pozitiva, daca este inapoi este negativa valoarea delta
            int delta = 120;

            if (evnt.Direction == ScrollDirection.Down)
            {
                delta = 0 - delta;
            }
            GcMouseEventArgs args = new GcMouseEventArgs(this, 0, delta, (int)evnt.X, (int)evnt.Y, MouseButton.None);

            if (MouseWheel != null)
            {
                MouseWheel(this, args);
            }
            return(base.OnScrollEvent(evnt));
        }
Ejemplo n.º 14
0
 protected override bool OnScrollEvent(EventScroll evnt)
 {
     if ((evnt.State & Gdk.ModifierType.ControlMask) == Gdk.ModifierType.ControlMask)
     {
         if (evnt.Direction == ScrollDirection.Down)
         {
             Options.ZoomIn();
         }
         else
         {
             Options.ZoomOut();
         }
         this.Repaint();
         return(true);
     }
     return(base.OnScrollEvent(evnt));
 }
Ejemplo n.º 15
0
        protected override bool OnScrollEvent(EventScroll evnt)
        {
            var    alloc = Allocation;
            double dx, dy;

            evnt.GetPageScrollPixelDeltas(alloc.Width, alloc.Height, out dx, out dy);

            if (dx != 0.0 && hScrollBar.Visible)
            {
                hAdjustment.AddValueClamped(dx);
            }

            if (dy != 0.0 && vScrollBar.Visible)
            {
                vAdjustment.AddValueClamped(dy);
            }

            return((dx != 0.0 || dy != 0.0) || base.OnScrollEvent(evnt));
        }
Ejemplo n.º 16
0
        protected override bool OnScrollEvent(EventScroll evnt)
        {
            // Allow the user to zoom in/out with Ctrl-Mousewheel
            if (FilterModifierKeys(evnt.State) == ModifierType.ControlMask)
            {
                switch (evnt.Direction)
                {
                case ScrollDirection.Down:
                case ScrollDirection.Right:
                    PintaCore.Workspace.ActiveWorkspace.ZoomOutFromMouseScroll(new Cairo.PointD(evnt.X, evnt.Y));
                    return(true);

                case ScrollDirection.Left:
                case ScrollDirection.Up:
                    PintaCore.Workspace.ActiveWorkspace.ZoomInFromMouseScroll(new Cairo.PointD(evnt.X, evnt.Y));
                    return(true);
                }
            }

            return(base.OnScrollEvent(evnt));
        }
Ejemplo n.º 17
0
        // FIXME: if the editors have different adjustment ranges, the pixel deltas
        // don't really feel quite right since they're applied after scaling via the
        // linked adjustment
        protected override bool OnScrollEvent(EventScroll evnt)
        {
            //using the size of an editor for the calculations means pixel deltas apply better
            var alloc = editors[0].Allocation;

            double dx, dy;

            evnt.GetPageScrollPixelDeltas(alloc.Width, alloc.Height, out dx, out dy);

            if (dx != 0.0 && hAdjustment.PageSize < (hAdjustment.Upper - hAdjustment.Lower))
            {
                hAdjustment.AddValueClamped(dx / (alloc.Width / hAdjustment.PageSize));
            }

            if (dy != 0.0 && vAdjustment.PageSize < (vAdjustment.Upper - vAdjustment.Lower))
            {
                vAdjustment.AddValueClamped(dy / (alloc.Height / vAdjustment.PageSize));
            }

            return((dx != 0.0 || dy != 0.0) || base.OnScrollEvent(evnt));
        }
Ejemplo n.º 18
0
        protected override bool OnScrollEvent(EventScroll scroll)
        {
            if ((scroll.State & ModifierType.ControlMask) != 0)
            {
                switch (scroll.Direction)
                {
                case ScrollDirection.Up:
                    ZoomIn();
                    break;

                case ScrollDirection.Down:
                    ZoomOut();
                    break;

                case (ScrollDirection)4:      // GDK_SCROLL_SMOOTH
                    double delta_x;
                    double delta_y;
                    gdk_event_get_scroll_deltas(scroll.Handle, out delta_x, out delta_y);
                    smooth_scroll_size += delta_y;

                    if (smooth_scroll_size < -1)
                    {
                        ZoomIn();
                        smooth_scroll_size += 1;
                    }
                    else if (smooth_scroll_size > 1)
                    {
                        ZoomOut();
                        smooth_scroll_size -= 1;
                    }
                    break;

                default:
                    return(base.OnScrollEvent(scroll));
                }
                return(true);
            }
            return(base.OnScrollEvent(scroll));
        }
Ejemplo n.º 19
0
        protected override bool OnScrollEvent(EventScroll evnt)
        {
            // Allow the user to zoom in/out with Ctrl-Mousewheel
            if (evnt.State.FilterModifierKeys() == ModifierType.ControlMask)
            {
                switch (evnt.Direction)
                {
                case ScrollDirection.Down:
                case ScrollDirection.Right:
                    document.Workspace.ZoomOutFromMouseScroll(new Cairo.PointD(evnt.X, evnt.Y));
                    return(true);

                case ScrollDirection.Left:
                case ScrollDirection.Up:
                    document.Workspace.ZoomInFromMouseScroll(new Cairo.PointD(evnt.X, evnt.Y));
                    return(true);
                }
            }

            // Allow the user to scroll left/right with Shift-Mousewheel
            if (evnt.State.FilterModifierKeys() == ModifierType.ShiftMask)
            {
                switch (evnt.Direction)
                {
                case ScrollDirection.Down:
                case ScrollDirection.Right:
                    document.Workspace.ScrollCanvas(hScrollAmount, 0);
                    return(true);

                case ScrollDirection.Up:
                case ScrollDirection.Left:
                    document.Workspace.ScrollCanvas(-hScrollAmount, 0);
                    return(true);
                }
            }

            return(base.OnScrollEvent(evnt));
        }
Ejemplo n.º 20
0
        protected override bool OnScrollEvent(EventScroll args)
        {
            float shift = 1.0f;

            if ((args.State & Gdk.ModifierType.ShiftMask) > 0)
            {
                shift = 6f;
            }

            switch (args.Direction)
            {
            case ScrollDirection.Up:
            case ScrollDirection.Right:
                Position -= shift;
                return(true);

            case Gdk.ScrollDirection.Down:
            case Gdk.ScrollDirection.Left:
                Position += shift;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 21
0
        protected override bool OnScrollEvent(EventScroll e)
        {
            try
            {
                int delta;

                if (e.Direction == Gdk.ScrollDirection.Smooth)
                {
                    delta = e.DeltaY < 0 ? mouseWheelScrollRows : -mouseWheelScrollRows;
                }
                else
                {
                    delta = e.Direction == Gdk.ScrollDirection.Down ? -mouseWheelScrollRows : mouseWheelScrollRows;
                }

                sheet.InvokeScroll(delta);
            }
            catch (Exception err)
            {
                ViewBase.MasterView.ShowError(err);
            }
            return(true);
        }
Ejemplo n.º 22
0
        protected override bool OnScrollEvent(EventScroll evnt)
        {
            float shift = 1f;

            if ((evnt.State & ModifierType.ShiftMask) > 0)
            {
                shift = 6f;
            }

            switch (evnt.Direction)
            {
            case ScrollDirection.Up:
            case ScrollDirection.Right:
                Position = animation.To - shift;
                return(true);

            case ScrollDirection.Down:
            case ScrollDirection.Left:
                Position = animation.To + shift;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 23
0
        public bool HandleScroll(EventScroll args)
        {
            if (editable)
            {
                switch (args.Direction)
                {
                case Gdk.ScrollDirection.Up:
                case Gdk.ScrollDirection.Right:
                    Value++;
                    return(true);

                case Gdk.ScrollDirection.Down:
                case Gdk.ScrollDirection.Left:
                    Value--;
                    return(true);
                }

                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Called when the mouse wheel is scrolled.
 /// </summary>
 /// <param name="e">An instance that contains the event data.</param>
 /// <returns><c>true</c> if the event was handled.</returns>
 protected override bool OnScrollEvent(EventScroll e)
 {
     return(this.ActualController.HandleMouseWheel(this, e.ToMouseWheelEventArgs()));
 }
Ejemplo n.º 25
0
 private PointerPointProperties BuildProperties(EventScroll scrollEvent)
 => new PointerPointProperties
 {
     MouseWheelDelta        = scrollEvent.DeltaX != 0 ? (int)scrollEvent.DeltaX : (int)scrollEvent.DeltaY,
     IsHorizontalMouseWheel = scrollEvent.DeltaX != 0,
 };
Ejemplo n.º 26
0
 protected override bool OnScrollEvent(EventScroll args)
 {
     return(HandleScroll(args));
 }