コード例 #1
0
        protected override Xwt.Point CalculateWindowLocation(Ide.Editor.TextEditor editor, TooltipItem item, Xwt.WindowFrame xwtWindow, int mouseX, int mouseY, Xwt.Point origin)
        {
            int    w;
            double xalign;

            GetRequiredPosition(editor, xwtWindow, out w, out xalign);
            w += 10;
            var allocation = GetAllocation(editor);

            var info = (TaggedTooltipInformation <CodeActions.CodeActionContainer>)item.Item;
            var loc  = editor.OffsetToLocation(info.Tag.Span.Start);
            var p    = editor.LocationToPoint(loc);
            var view = editor.GetContent <SourceEditorView> ();
            int x    = (int)(p.X + origin.X + allocation.X + xPadding);
            int y    = (int)(p.Y + view.TextEditor.GetLineHeight(loc.Line) + origin.Y + allocation.Y + yPadding);

            Gtk.Widget widget   = editor;
            var        geometry = widget.Screen.GetUsableMonitorGeometry(widget.Screen.GetMonitorAtPoint(x, y));

            if (x + w >= geometry.X + geometry.Width)
            {
                x = geometry.X + geometry.Width - w;
            }
            if (x < geometry.Left)
            {
                x = geometry.Left;
            }

            if (info.Tag?.FloatingWidgetShown == true)
            {
                x += windowSize;
            }

            int h = (int)xwtWindow.Size.Height;

            if (y + h >= geometry.Y + geometry.Height)
            {
                y = geometry.Y + geometry.Height - h;
            }
            if (y < geometry.Top)
            {
                y = geometry.Top;
            }

            return(new Xwt.Point(x, y));
        }