Beispiel #1
0
 protected override bool OnMotionNotifyEvent(EventMotion evnt)
 {
     SetHover(GetItemAt((int)evnt.X, (int)evnt.Y));
     return(true);
 }
Beispiel #2
0
        protected override bool OnMotionNotifyEvent(EventMotion evnt)
        {
            RemovePreviewPopupTimeout();

            if (button != 0)
            {
                MouseMove(evnt.Y);
            }

            int h = Allocation.Height - Allocation.Width - 3;

            if (TextEditor.HighlightSearchPattern)
            {
                if (evnt.Y > h)
                {
                    this.TooltipText = string.Format(GettextCatalog.GetPluralString("{0} match", "{0} matches", TextEditor.TextViewMargin.SearchResultMatchCount), TextEditor.TextViewMargin.SearchResultMatchCount);
                }
            }
            else
            {
                if (evnt.Y > h)
                {
                    int errors = 0, warnings = 0;
                    foreach (var task in AllTasks)
                    {
                        switch (task.Severity)
                        {
                        case Severity.Error:
                            errors++;
                            break;

                        case Severity.Warning:
                            warnings++;
                            break;
                        }
                    }
                    string text = null;
                    if (errors == 0 && warnings == 0)
                    {
                        text = GettextCatalog.GetString("No errors or warnings");
                    }
                    else if (errors == 0)
                    {
                        text = string.Format(GettextCatalog.GetPluralString("{0} warning", "{0} warnings", warnings), warnings);
                    }
                    else if (warnings == 0)
                    {
                        text = string.Format(GettextCatalog.GetPluralString("{0} error", "{0} errors", errors), errors);
                    }
                    else
                    {
                        text = string.Format(GettextCatalog.GetString("{0} errors and {1} warnings"), errors, warnings);
                    }
                    this.TooltipText = text;
                }
                else
                {
//					TextEditorData editorData = TextEditor.GetTextEditorData ();
                    foreach (var task in AllTasks)
                    {
                        double y = GetYPosition(task.Location.Line);
                        if (Math.Abs(y - evnt.Y) < 3)
                        {
                            hoverTask = task;
                        }
                    }
                    base.TooltipText = hoverTask != null ? hoverTask.Description : null;
                }
            }

            if (button == 0 && evnt.State.HasFlag(ModifierType.ShiftMask))
            {
                int line = YToLine(evnt.Y);

                line = Math.Max(1, line - 2);
                int lastLine = Math.Min(TextEditor.LineCount, line + 5);
                var start    = TextEditor.GetLine(line);
                var end      = TextEditor.GetLine(lastLine);
                if (start == null || end == null)
                {
                    return(base.OnMotionNotifyEvent(evnt));
                }
                var showSegment = new TextSegment(start.Offset, end.Offset + end.Length - start.Offset);

                if (previewWindow != null)
                {
                    previewWindow.SetSegment(showSegment, false);
                    PositionPreviewWindow((int)evnt.Y);
                }
                else
                {
                    var popup = new PreviewPopup(this, showSegment, TextEditor.Allocation.Width * 4 / 7, (int)evnt.Y);
                    previewPopupTimeout = GLib.Timeout.Add(450, new GLib.TimeoutHandler(popup.Run));
                }
            }
            else
            {
                RemovePreviewPopupTimeout();
                DestroyPreviewWindow();
            }
            return(base.OnMotionNotifyEvent(evnt));
        }
Beispiel #3
0
        protected override bool OnMotionNotifyEvent(EventMotion evnt)
        {
            int px = (int)evnt.X - x_offset;
            int py = (int)evnt.Y - y_offset;

            if (px < 0)
            {
                px = 0;
            }
            if (px > width - 1)
            {
                px = width - 1;
            }
            if (py < 0)
            {
                py = 0;
            }
            if (py > height - 1)
            {
                py = height - 1;
            }

            //find the closest point
            float closest_x = MinX - 1;
            var   distance  = Int32.MaxValue;

            foreach (var point in points)
            {
                int cx = Project(point.Key, MinX, MaxX, width);
                if (Math.Abs(px - cx) < distance)
                {
                    distance  = Math.Abs(px - cx);
                    closest_x = point.Key;
                }
            }

            switch (CurveType)
            {
            case CurveType.Spline:
            case CurveType.Linear:
                if (grab_point == null)                                 //No grabbed point
                {
                    if (distance <= min_distance)
                    {
                        CursorType = CursorType.Fleur;
                    }
                    else
                    {
                        CursorType = CursorType.Tcross;
                    }
                    return(true);
                }

                CursorType = CursorType.Tcross;
                points.Remove(grab_point.Value);
                AddPoint((closest_x = Unproject(px, MinX, MaxX, width)), MaxY - Unproject(py, MinY, MaxY, height));
                QueueDraw();
                grab_point = closest_x;

                break;

            case CurveType.Free:
                throw new NotImplementedException();
            }
            return(true);
        }
Beispiel #4
0
        bool OnSelectionMotionNotifyEvent(EventMotion evnt)
        {
            int          x, y;
            ModifierType mod;

            if (evnt.IsHint)
            {
                GdkWindow.GetPointer(out x, out y, out mod);
            }
            else
            {
                x = (int)evnt.X;
                y = (int)evnt.Y;
            }


            Point img = WindowCoordsToImage(new Point(x, y));

            if (is_dragging_selection)
            {
                Point win_anchor = ImageCoordsToWindow(selection_anchor);
                if (Selection == Rectangle.Zero &&
                    Math.Abs(evnt.X - win_anchor.X) < SELECTION_THRESHOLD &&
                    Math.Abs(evnt.Y - win_anchor.Y) < SELECTION_THRESHOLD)
                {
                    SelectionSetPointer(x, y);
                    return(true);
                }


                if (selection_xy_ratio == 0)
                {
                    Selection = new Rectangle(fixed_width ? Selection.X : Math.Min(selection_anchor.X, img.X),
                                              fixed_height ? Selection.Y : Math.Min(selection_anchor.Y, img.Y),
                                              fixed_width ? Selection.Width : Math.Abs(selection_anchor.X - img.X),
                                              fixed_height ? Selection.Height : Math.Abs(selection_anchor.Y - img.Y));
                }

                else
                {
                    Selection = ConstrainSelection(new Rectangle(Math.Min(selection_anchor.X, img.X),
                                                                 Math.Min(selection_anchor.Y, img.Y),
                                                                 Math.Abs(selection_anchor.X - img.X),
                                                                 Math.Abs(selection_anchor.Y - img.Y)),
                                                   fixed_width, fixed_height);
                }

                SelectionSetPointer(x, y);
                return(true);
            }

            if (is_moving_selection)
            {
                Selection = new Rectangle(Clamp(Selection.X + img.X - selection_anchor.X, 0, Pixbuf.Width - Selection.Width),
                                          Clamp(Selection.Y + img.Y - selection_anchor.Y, 0, Pixbuf.Height - Selection.Height),
                                          Selection.Width, Selection.Height);
                selection_anchor = img;
                SelectionSetPointer(x, y);
                return(true);
            }

            SelectionSetPointer(x, y);
            return(true);
        }
Beispiel #5
0
        protected override bool OnMotionNotifyEvent(EventMotion evnt)
        {
            if (draggingTab && mouseHasLeft)
            {
                var sr = GetScreenRect();
                sr.Height = BarHeight;
                sr.Inflate(30, 30);

                int x, y;
                Gdk.Display.Default.GetPointer(out x, out y);

                if (x < sr.Left || x > sr.Right || y < sr.Top || y > sr.Bottom)
                {
                    draggingTab  = false;
                    mouseHasLeft = false;
                    CreatePlaceholderWindow();
                }
            }

            string newTooltip = null;

            if (placeholderWindow != null)
            {
                int x, y;
                Gdk.Display.Default.GetPointer(out x, out y);
                placeholderWindow.MovePosition(x, y);
                return(base.OnMotionNotifyEvent(evnt));
            }

            if (!draggingTab)
            {
                var t = FindTab((int)evnt.X, (int)evnt.Y);

                // If the user clicks and drags on the 'x' which closes the current
                // tab we can end up with a null tab here
                if (t == null)
                {
                    TooltipText = null;
                    return(base.OnMotionNotifyEvent(evnt));
                }
                SetHighlightedTab(t);

                var newOver = IsOverCloseButton(t, (int)evnt.X, (int)evnt.Y);
                if (newOver != overCloseButton)
                {
                    overCloseButton = newOver;
                    QueueDraw();
                }
                if (!overCloseButton && !draggingTab && buttonPressedOnTab)
                {
                    draggingTab   = true;
                    mouseHasLeft  = false;
                    dragXProgress = 1.0f;
                    int x = (int)evnt.X;
                    dragOffset = x - t.Allocation.X;
                    dragX      = x - dragOffset;
                    lastDragX  = (int)evnt.X;
                }
                else if (t != null)
                {
                    newTooltip = t.Tooltip;
                }
            }
            else if (evnt.State.HasFlag(ModifierType.Button1Mask))
            {
                dragX = (int)evnt.X - dragOffset;
                QueueDraw();

                var t = FindTab((int)evnt.X, (int)TabPadding.Top + 3);
                if (t == null)
                {
                    var last = (DockNotebookTab)notebook.Tabs.Last();
                    if (dragX > last.Allocation.Right)
                    {
                        t = last;
                    }
                    if (dragX < 0)
                    {
                        t = (DockNotebookTab)notebook.Tabs.First();
                    }
                }
                if (t != null && t != notebook.CurrentTab && (
                        ((int)evnt.X > lastDragX && t.Index > notebook.CurrentTab.Index) ||
                        ((int)evnt.X < lastDragX && t.Index < notebook.CurrentTab.Index)))
                {
                    t.SaveAllocation();
                    t.SaveStrength = 1;
                    notebook.ReorderTab((DockNotebookTab)notebook.CurrentTab, t);

                    t.Animate("TabMotion",
                              f => t.SaveStrength = f,
                              1.0f,
                              0.0f,
                              easing: Easing.CubicInOut);
                }
                lastDragX = (int)evnt.X;
            }

            if (newTooltip != null && TooltipText != null && TooltipText != newTooltip)
            {
                TooltipText = null;
            }
            else
            {
                TooltipText = newTooltip;
            }

            return(base.OnMotionNotifyEvent(evnt));
        }
Beispiel #6
0
        protected override bool OnMotionNotifyEvent(EventMotion evnt)
        {
            string newTooltip = null;

            if (!draggingTab)
            {
                var t = FindTab((int)evnt.X, (int)evnt.Y);

                // If the user clicks and drags on the 'x' which closes the current
                // tab we can end up with a null tab here
                if (t == null)
                {
                    return(base.OnMotionNotifyEvent(evnt));
                }
                SetHighlightedTab(t);

                var newOver = IsOverCloseButton(t, (int)evnt.X, (int)evnt.Y);
                if (newOver != overCloseButton)
                {
                    overCloseButton = newOver;
                    QueueDraw();
                }
                if (!overCloseButton && !draggingTab && buttonPressedOnTab)
                {
                    draggingTab   = true;
                    dragXProgress = 1.0f;
                    int x = (int)evnt.X;
                    dragOffset = x - t.Allocation.X;
                    dragX      = x - dragOffset;
                    lastDragX  = (int)evnt.X;
                }
                else if (t != null)
                {
                    newTooltip = t.Tooltip;
                }
            }
            else if (evnt.State.HasFlag(ModifierType.Button1Mask))
            {
                dragX = (int)evnt.X - dragOffset;
                QueueDraw();

                var t = FindTab((int)evnt.X, TopPadding + 3);
                if (t == null)
                {
                    var last = (DockNotebookTab)notebook.Tabs.Last();
                    if (dragX > last.Allocation.Right)
                    {
                        t = last;
                    }
                    if (dragX < 0)
                    {
                        t = (DockNotebookTab)notebook.Tabs.First();
                    }
                }
                if (t != null && t != notebook.CurrentTab && (
                        ((int)evnt.X > lastDragX && t.Index > notebook.CurrentTab.Index) ||
                        ((int)evnt.X < lastDragX && t.Index < notebook.CurrentTab.Index)))
                {
                    t.SaveAllocation();
                    t.SaveStrength = 1;
                    notebook.ReorderTab((DockNotebookTab)notebook.CurrentTab, t);

                    t.Animate("TabMotion",
                              f => t.SaveStrength = f,
                              1.0f,
                              0.0f,
                              easing: Easing.CubicInOut);
                }
                lastDragX = (int)evnt.X;
            }

            if (newTooltip != null && TooltipText != null && TooltipText != newTooltip)
            {
                TooltipText = null;
            }
            else
            {
                TooltipText = newTooltip;
            }

            return(base.OnMotionNotifyEvent(evnt));
        }
Beispiel #7
0
        protected override bool OnMotionNotifyEvent(EventMotion evnt)
        {
            if (button != 0)
            {
                MouseMove(evnt.Y);
            }

            int h = Allocation.Height - Allocation.Width - 3;

            if (TextEditor.HighlightSearchPattern)
            {
                if (evnt.Y > h)
                {
                    this.TooltipText = string.Format(GettextCatalog.GetPluralString("{0} match", "{0} matches", TextEditor.TextViewMargin.SearchResultMatchCount), TextEditor.TextViewMargin.SearchResultMatchCount);
                }
            }
            else
            {
                if (evnt.Y > h)
                {
                    int errors = 0, warnings = 0;
                    foreach (var task in AllTasks)
                    {
                        switch (task.Severity)
                        {
                        case QuickTaskSeverity.Error:
                            errors++;
                            break;

                        case QuickTaskSeverity.Warning:
                            warnings++;
                            break;
                        }
                    }
                    string text = null;
                    if (errors == 0 && warnings == 0)
                    {
                        text = GettextCatalog.GetString("No errors or warnings");
                    }
                    else if (errors == 0)
                    {
                        text = string.Format(GettextCatalog.GetPluralString("{0} warning", "{0} warnings", warnings), warnings);
                    }
                    else if (warnings == 0)
                    {
                        text = string.Format(GettextCatalog.GetPluralString("{0} error", "{0} errors", errors), errors);
                    }
                    else
                    {
                        text = string.Format(GettextCatalog.GetString("{0} errors and {1} warnings"), errors, warnings);
                    }
                    this.TooltipText = text;
                }
                else
                {
                    TextEditorData editorData = TextEditor.GetTextEditorData();
                    foreach (var tasks in providerTasks.Values)
                    {
                        foreach (var task in tasks)
                        {
                            double y = h * TextEditor.LineToY(task.Location.Line) / Math.Max(TextEditor.EditorLineThreshold * editorData.LineHeight + editorData.TotalHeight, TextEditor.Allocation.Height);
                            if (Math.Abs(y - evnt.Y) < 3)
                            {
                                hoverTask = task;
                            }
                        }
                    }
                    base.TooltipText = hoverTask != null ? hoverTask.Description : null;
                }
            }

            return(base.OnMotionNotifyEvent(evnt));
        }
Beispiel #8
0
 private PointerPointProperties BuildProperties(EventMotion eventMotion)
 => new Windows.UI.Input.PointerPointProperties()
 {
     IsLeftButtonPressed  = (eventMotion.State & Gdk.ModifierType.Button1Mask) != 0,
     IsRightButtonPressed = (eventMotion.State & Gdk.ModifierType.Button2Mask) != 0
 };
Beispiel #9
0
 protected override bool OnMotionNotifyEvent(EventMotion evnt)
 {
     State = IsInside(evnt.X, evnt.Y) ? hoverState : StateType.Normal;;
     return(base.OnMotionNotifyEvent(evnt));
 }
Beispiel #10
0
 protected override bool OnMotionNotifyEvent(EventMotion evnt)
 {
     in_thumbnail_region = evnt.X <= Allocation.Height;
     return(ShowHideCoverArt());
 }
Beispiel #11
0
        protected override bool OnMotionNotifyEvent(EventMotion evnt)
        {
            if ((evnt.State & (ModifierType.Button1Mask | ModifierType.Button3Mask)) == 0)
            {
                return(false);
            }

            if (!Gtk.Drag.CheckThreshold(this, selection_start.X, selection_start.Y,
                                         (int)evnt.X, (int)evnt.Y))
            {
                return(false);
            }

            if (isRectSelection)
            {
                // scroll if out of window
                double d_x, d_y;
                deltaVscroll = 30;

                if (EventHelper.GetCoords(evnt, out d_x, out d_y))
                {
                    int new_y = (int)d_y;
                    if ((new_y <= 0) || (new_y >= Allocation.Height))
                    {
                        if (scroll_timeout == 0)
                        {
                            scroll_timeout = GLib.Timeout.Add(100, new GLib.TimeoutHandler(HandleMotionTimeout));
                        }
                    }
                    else if (scroll_timeout != 0)
                    {
                        GLib.Source.Remove(scroll_timeout);
                        scroll_timeout = 0;
                    }
                }
                else if (scroll_timeout != 0)
                {
                    GLib.Source.Remove(scroll_timeout);
                    scroll_timeout = 0;
                }

                // handle selection
                UpdateRubberband();
                //SelectMotion (new Point ((int) args.Event.X, (int) args.Event.Y));
            }
            else
            {
                int cell_num = CellAtPosition(selection_start);

                if (Selection.Contains(cell_num))
                {
                    // on a selected cell : do drag&drop
                    isDragDrop = true;
                    if (StartDrag != null)
                    {
                        uint but = (evnt.State & ModifierType.Button1Mask) != 0 ? 1U : 3U;
                        StartDrag(this, new StartDragArgs(but, start_select_event));
                    }
                }
                else
                {
                    // not on a selected cell : do rectangular select
                    isRectSelection = true;

                    // ctrl : toggle selected, shift : keep selected
                    if ((evnt.State & (ModifierType.ShiftMask | ModifierType.ControlMask)) == 0)
                    {
                        Selection.Clear();
                    }

                    start_select_selection = Selection.Ids;                     // keep initial selection
                    // no rect draw at beginning
                    rect_select = Rectangle.Zero;

                    return(false);
                }
            }

            return(true);
        }
Beispiel #12
0
        protected override bool OnMotionNotifyEvent(EventMotion evnt)
        {
            RootMousePos = new POINT((int)evnt.XRoot, (int)evnt.YRoot);
            MousePos     = new POINT((int)evnt.X, (int)evnt.Y);

            MouseImagePos = AbsPosToUnrotatedPos(MousePos);

            if (Debug)
            {
                DebugText  = PartBottom.Rect.Contains(MouseImagePos).ToString();
                DebugPoint = MouseImagePos;
                InvalidateImage();
            }

            var relMousePos = new POINT(RootMousePos.X - StartRootMousePos.X, RootMousePos.Y - StartRootMousePos.Y);

            if (Resizing)
            {
                if (Math.Abs(relMousePos.X) > 10 || Math.Abs(relMousePos.Y) > 10)
                {
                    PartBottom.Rect.X  = GetDistanceToRotationCenter(RootMousePos);
                    PartBottom.Rect.X -= MoveMouseXOffset;
                    PartBottom.Rect.X  = Math.Max(PartBottom.Rect.X, ZeroDistanceOffset);
                    UpdatePartScale();

                    if (Distance > MinDistanceForRotation)
                    {
                        TmpAngle  = Helper.GetAngleOfLineBetweenTwoPoints(RotationCenterRoot, RootMousePos);
                        TmpAngle -= MoveMouseAngleOffset;
                        TmpAngle  = NormalizeAngle(TmpAngle);

                        if ((evnt.State & ModifierType.ControlMask) == ModifierType.ControlMask && (evnt.State & ModifierType.ShiftMask) != ModifierType.ShiftMask)
                        {
                            Angle = TmpAngle;
                        }
                        else
                        {
                            var      snapAngle = SnapAngle;
                            double[] angleMarkers;
                            if ((evnt.State & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                            {
                                angleMarkers = new double[] {
                                    0,
                                    Math.PI / 4,
                                    Math.PI / 2,
                                    Math.PI,
                                    Math.PI - Math.PI / 4,
                                    -(Math.PI - Math.PI / 4),
                                    -(Math.PI / 2),
                                    -(Math.PI / 4)
                                };
                                snapAngle = snapAngle / 2;
                            }
                            else
                            {
                                angleMarkers = new double[] { 0, Math.PI / 2, Math.PI, -Math.PI, -(Math.PI / 2) }
                            };

                            for (var i = 0; i < angleMarkers.Length; i++)
                            {
                                var a = angleMarkers[i];
                                if (TmpAngle <= a + snapAngle && TmpAngle >= a - snapAngle)
                                {
                                    SetAngle(a);
                                    break;
                                }
                            }
                        }
                    }

                    InvalidateImage();
                }
            }

            if (Moving)
            {
                var x = (StartWinPos.X + (RootMousePos.X - StartRootMousePos.X));
                var y = (StartWinPos.Y + (RootMousePos.Y - StartRootMousePos.Y));
                Move(x, y);
                UpdateRotationCenter();
            }

            return(base.OnMotionNotifyEvent(evnt));
        }
Beispiel #13
0
 /// <summary>
 /// Called on mouse move events.
 /// </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 OnMotionNotifyEvent(EventMotion e)
 {
     return(this.ActualController.HandleMouseMove(this, e.ToMouseEventArgs()));
 }