Exemplo n.º 1
0
        public Desk[,] GetDeskGridLayout()
        {
            Desk next, desk = GetUpperLeftDesk();

            Gdk.Point gridsize = GetDeskGridSize();
            Desk [,] grid = new Desk [gridsize.X, gridsize.Y];
            grid [0, 0]   = desk;
            int x = 0;

            for (int y = 0; y < gridsize.Y; y++)
            {
                x = 0;
                while ((next = desk.GetNeighbor(Wnck.MotionDirection.Right)) != null)
                {
                    desk = next;
                    x++;
                    if (gridsize.X - 1 < x)
                    {
                        break;
                    }
                    grid [x, y] = desk;
                }
                if (gridsize.Y - 1 > y)
                {
                    desk            = (grid [0, y] != null ? grid [0, y].GetNeighbor(Wnck.MotionDirection.Down) : null);
                    grid [0, y + 1] = desk;
                }
            }
            return(grid);
        }
Exemplo n.º 2
0
        private void RefreshFlyoutLayoutBehavior(FlyoutLayoutBehaviorType flyoutBehaviorType)
        {
            int detailWidthRequest = 0;

            Gdk.Point point = default(Gdk.Point);

            switch (_flyoutBehaviorType)
            {
            case FlyoutLayoutBehaviorType.Split:
                detailWidthRequest = _lastAllocation.Width - DefaultFlyoutWidth;
                point = new Gdk.Point(_flyout.WidthRequest, 0);
                break;

            case FlyoutLayoutBehaviorType.Default:
            case FlyoutLayoutBehaviorType.Popover:
                detailWidthRequest = _lastAllocation.Width;
                point = new Gdk.Point(0, 0);
                break;
            }

            if (detailWidthRequest >= 0)
            {
                _detail.WidthRequest = detailWidthRequest;
                _detail.MoveTo(point.X, point.Y);
            }
        }
Exemplo n.º 3
0
        void HandleButtonPressEvent(object sender, ButtonPressEventArgs args)
        {
            switch (args.Event.Type)
            {
            case EventType.ButtonPress:
                if (args.Event.Button == 1)
                {
                    start      = new Gdk.Point((int)args.Event.X, (int)args.Event.Y);
                    start_root = new Gdk.Point((int)args.Event.XRoot, (int)args.Event.YRoot);
                    start_hot  = hotspot;

                    Gdk.Point win;
                    GdkWindow.GetOrigin(out win.X, out win.Y);
                    start_hot.X += win.X;
                    start_hot.Y += win.Y;

                    dragging    = true;
                    rotate      = (args.Event.State & ModifierType.ShiftMask) > 0;
                    start_angle = Angle;
                }
                else
                {
                    Angle += Math.PI / 8;
                }
                break;

            case EventType.TwoButtonPress:
                dragging = false;
                App.Instance.Organizer.HideLoupe();
                break;
            }
        }
Exemplo n.º 4
0
        private void GdkDraw(EventExpose evnt, int height, int width)
        {
            Time time = new Time();

            width = Math.Min(width, this.Allocation.Width);
            layout.SetMarkup("0");
            this.GdkWindow.DrawLayout(this.Style.TextGC(StateType.Normal), 0, height - 23, layout);

            Gdk.Point topL   = new Gdk.Point((int)(CurrentFrame / pixelRatio - Scroll - 5), height - 15);
            Gdk.Point topR   = new Gdk.Point((int)(CurrentFrame / pixelRatio - Scroll + 5), height - 15);
            Gdk.Point bottom = new Gdk.Point((int)(CurrentFrame / pixelRatio - Scroll), height);
            this.GdkWindow.DrawPolygon(this.Style.TextGC(StateType.Normal), true, new Gdk.Point[] { topL, topR, bottom });

            for (int i = 10 * FrameRate; i <= frames / pixelRatio;)
            {
                // Drawing separator line
                evnt.Window.DrawLine(Style.DarkGC(StateType.Normal), i - (int)Scroll, height, i - (int)Scroll, height - 10);
                time.Seconds = (int)(i / FrameRate * pixelRatio);
                layout.SetMarkup(time.ToSecondsString());
                this.GdkWindow.DrawLayout(this.Style.TextGC(StateType.Normal), i - (int)Scroll - 13, height - 23, layout);
                //g.ShowText(time.ToSecondsString());
                i = i + 10 * FrameRate;
            }

            for (int i = 0; i <= frames / pixelRatio;)
            {
                evnt.Window.DrawLine(Style.DarkGC(StateType.Normal), i - (int)Scroll, height, i - (int)Scroll, height - 5);
                i = i + FrameRate;
            }
            // Drawing main line
            evnt.Window.DrawLine(Style.DarkGC(StateType.Normal), 0, height, width, height);
        }
Exemplo n.º 5
0
    //on inertial also uses to EncoderCapturePointsInertialDisc
    protected virtual void encoderCapturePointsAdaptativeDisplay()
    {
        //adaptative displayed height
        //if points go outside the graph, duplicate size of graph
        if (EncoderCapturePoints[i].Y > heightG || EncoderCapturePoints[i].Y < 0)
        {
            realHeightG *= 2;

            int xWidth = recordingTime;
            if (cont)
            {
                xWidth = recordedTimeCont;
            }

            double sum2 = 0;
            for (int j = 0; j <= i; j++)
            {
                sum2 += encoderReaded[j];
                EncoderCapturePoints[j] = new Gdk.Point(
                    Convert.ToInt32(widthG * j / xWidth),
                    Convert.ToInt32((heightG / 2) - (sum2 * heightG / realHeightG))
                    );
            }
            EncoderCapturePointsCaptured = i;
            EncoderCapturePointsPainted  = -1;            //mark meaning screen should be erased
        }
    }
Exemplo n.º 6
0
        protected override bool OnButtonPressEvent(EventButton evnt)
        {
            Gdk.Point global_point = new Gdk.Point((int)evnt.XRoot, (int)evnt.YRoot);
            Gdk.Point local_point  = new Gdk.Point((int)evnt.X, (int)evnt.Y);

            switch (bezel_drawing_area.GetPointLocation(local_point))
            {
            case PointLocation.Close:
            case PointLocation.Outside:
                controller.ButtonPressOffWindow();
                break;

            case PointLocation.Preferences:
                // We need to let the window manager handle the Do window before popping up the
                // preferences menu so that it can place the menu over the top.
                GdkWindow.OverrideRedirect = false;
                Services.Windowing.ShowMainMenu(global_point.X, global_point.Y);

                // Have to re-grab the pane from the menu.
                Interface.Windowing.PresentWindow(this);
                GdkWindow.OverrideRedirect = true;
                break;
            }

            return(base.OnButtonPressEvent(evnt));
        }
Exemplo n.º 7
0
        private bool DragUpdate()
        {
            if (!dragging)
            {
                return(false);
            }

            if (!rotate)
            {
                return(MoveWindow());
            }
            else
            {
                Gdk.Point initial = start_root;
                Gdk.Point hot     = start_hot;
                Gdk.Point win     = Gdk.Point.Zero;

                hot.X += win.X;
                hot.Y += win.Y;

                initial.X -= hot.X;
                initial.Y -= hot.Y;
                Gdk.Point now = root_pos;
                now.X -= hot.X;
                now.Y -= hot.Y;

                Vector v1 = new Vector(initial);
                Vector v2 = new Vector(now);

                double angle = Vector.AngleBetween(v1, v2);

                Angle = start_angle + angle;
                return(false);
            }
        }
Exemplo n.º 8
0
        void HandleImageViewMotion(object sender, MotionNotifyEventArgs args)
        {
            Gdk.Point coords;
            coords = new Gdk.Point((int)args.Event.X, (int)args.Event.Y);

            SetSamplePoint(view.WindowCoordsToImage(coords));
        }
        private void RefreshMasterBehavior(MasterBehaviorType masterBehaviorType)
        {
            int detailWidthRequest = 0;

            Gdk.Point point = default(Gdk.Point);

            switch (_masterBehaviorType)
            {
            case MasterBehaviorType.Split:
                detailWidthRequest = _lastAllocation.Width - DefaultMasterWidth;
                point = new Gdk.Point(_master.WidthRequest, 0);
                break;

            case MasterBehaviorType.Default:
            case MasterBehaviorType.Popover:
                detailWidthRequest = _lastAllocation.Width;
                point = new Gdk.Point(0, 0);
                break;
            }

            if (detailWidthRequest >= 0)
            {
                _detail.WidthRequest = detailWidthRequest;
                _detail.MoveTo(point.X, point.Y);
            }
        }
Exemplo n.º 10
0
        bool DragUpdate()
        {
            if (!dragging)
            {
                return(false);
            }

            if (!rotate)
            {
                return(MoveWindow());
            }

            var initial = start_root;
            var hot     = start_hot;

            Gdk.Point win = Gdk.Point.Zero;

            hot.X += win.X;
            hot.Y += win.Y;

            initial.X -= hot.X;
            initial.Y -= hot.Y;
            var now = root_pos;

            now.X -= hot.X;
            now.Y -= hot.Y;

            var v1 = new Vector(initial.X, initial.Y);
            var v2 = new Vector(now.X, now.Y);

            double angleBetween = Vector.AngleBetween(v1, v2);

            Angle = start_angle + angleBetween;
            return(false);
        }
Exemplo n.º 11
0
    protected override void encoderCapturePointsAdaptativeDisplay()
    {
        //adaptative displayed height
        //if points go outside the graph, duplicate size of graph
        if (
            EncoderCapturePoints[i].Y > heightG || EncoderCapturePoints[i].Y <0 ||
                                                                              EncoderCapturePointsInertialDisc[i].Y> heightG ||
            EncoderCapturePointsInertialDisc[i].Y < 0)
        {
            realHeightG *= 2;

            double sum2             = 0;
            double sum2InertialDisc = 0;
            for (int j = 0; j <= i; j++)
            {
                sum2                   += encoderReaded[j];
                sum2InertialDisc       += encoderReadedInertialDisc[j];
                EncoderCapturePoints[j] = new Gdk.Point(
                    Convert.ToInt32(widthG * j / recordingTime),
                    Convert.ToInt32((heightG / 2) - (sum2 * heightG / realHeightG))
                    );
                EncoderCapturePointsInertialDisc[j] = new Gdk.Point(
                    Convert.ToInt32(widthG * j / recordingTime),
                    Convert.ToInt32((heightG / 2) - (sum2InertialDisc * heightG / realHeightG))
                    );
            }
            EncoderCapturePointsCaptured = i;
            EncoderCapturePointsPainted  = -1;            //mark meaning screen should be erased and start painting from the beginning
        }
    }
Exemplo n.º 12
0
 //on inertial also assigns to EncoderCapturePointsInertialDisc
 protected virtual void assignEncoderCapturePoints()
 {
     EncoderCapturePoints[i] = new Gdk.Point(
         Convert.ToInt32(widthG * i / recordingTime),
         Convert.ToInt32((heightG / 2) - (sum * heightG / realHeightG))
         );
 }
Exemplo n.º 13
0
        public Gdk.Point WindowCoordsToImage(Gdk.Point win)
        {
            Gdk.Point img;

            f_image_view_window_coords_to_image(Handle, win.X, win.Y, out img.X, out img.Y);
            return(img);
        }
Exemplo n.º 14
0
 public void Redo()
 {
     for (int i = 0; i < NumCaptured; i++)
     {
         Points[i] = new Gdk.Point(GetTimeInPx(times[i]), GetForceInPx(forces[i]));
     }
 }
Exemplo n.º 15
0
 public PointLocation GetPointLocation(Gdk.Rectangle drawing_area, Gdk.Point point)
 {
     if (drawing_area.Contains(point))
     {
         return(PointLocation.Window);
     }
     return(PointLocation.Outside);
 }
Exemplo n.º 16
0
 public void ShowPopup(Xwt.Rectangle onScreenArea, PopupPosition position)
 {
     this.parent          = IdeApp.Workbench.RootWindow;
     this.currentCaret    = new Rectangle((int)onScreenArea.X, (int)onScreenArea.Y, (int)onScreenArea.Width, (int)onScreenArea.Height);
     Theme.TargetPosition = position;
     targetWindowOrigin   = new Point((int)onScreenArea.X, (int)onScreenArea.Y);
     RepositionWindow();
 }
Exemplo n.º 17
0
 public PointLocation GetPointLocation(Gdk.Point point)
 {
     if (BackgroundRenderer.GetPointLocation(drawing_area, point) == PointLocation.Outside)
     {
         return(PointLocation.Outside);
     }
     return(TitleBarRenderer.GetPointLocation(drawing_area, point));
 }
Exemplo n.º 18
0
		/// <summary>
		/// Enmarca una imagen.
		/// </summary>
		/// <param name="image">
		/// La imagen a enmarcar.
		/// </param>
		/// <param name="pos">
		/// La esquina de la zona a recortar.
		/// </param>
		/// <param name="size">
		/// El tamaño de la zona a recortar.
		/// </param>
		protected void GetEdges(FloatBitmap image, out Point pos, out Size size)
		{
			pos = new Point(0,0);
			size = new Size(image.Width, image.Height);
			
			bool found =false;
			
			for(int i = 0; i < image.Width && !found; i++)
			{
				for(int j = 0; j < image.Height && !found; j++)
				{
					if (image[i, j] != FloatBitmap.White)
					{
						pos.X = i-1;
						found = true;
					}
				}
			}
			
			found =false;
			for(int i = image.Width-1; i >=0 && !found; i--)
			{
				for(int j = 0; j < image.Height && !found; j++)
				{
					if (image[i, j] != FloatBitmap.White)
					{
						size.Width = i - pos.X +2 ;
						found = true;
					}
				}
			}
			
			found =false;
			for(int j = 0; j < image.Height && !found; j++)
			{
				for(int i = 0; i < image.Width&& !found; i++)
				{
					if (image[i, j] != FloatBitmap.White)
					{
						pos.Y = j-1;
						found = true;
					}
				}
			}
			
			found =false;
			for(int j = image.Height-1; j >=0 && !found; j--)
			{
				for(int i = 0; i < image.Width && !found; i++)
				{
					if (image[i, j] != FloatBitmap.White)
					{
						size.Height = j - pos.Y +2;
						found = true;
					}
				}
			}
		}
Exemplo n.º 19
0
        public void RenderItem(Context cr, Gdk.Point renderAnchor, int width, Do.Universe.Item item, bool drawArrow)
        {
            cr.Rectangle(renderAnchor.X, renderAnchor.Y, width, Height);
            cr.SetSourceRGBA(0, 0, 0, 0);
            cr.Operator = Operator.Source;
            cr.Fill();
            cr.Operator = Operator.Over;

            Gdk.Pixbuf pixbuf = IconProvider.PixbufFromIconName(item.Icon, IconSize);
            Gdk.CairoHelper.SetSourcePixbuf(cr, pixbuf, 2, 2);
            cr.Paint();

            pixbuf.Dispose();

            foreach (int i in parent.Secondary)
            {
                if (parent.Results[i] == item)
                {
                    pixbuf = IconProvider.PixbufFromIconName("gtk-add", IconSize);
                    Gdk.CairoHelper.SetSourcePixbuf(cr, pixbuf, 2, 2);
                    cr.PaintWithAlpha(.7);
                    pixbuf.Dispose();
                }
            }

            Pango.Layout layout = new Pango.Layout(parent.PangoContext);
            layout.Width     = Pango.Units.FromPixels(width - IconSize - 25);
            layout.Ellipsize = Pango.EllipsizeMode.End;
            layout.SetMarkup("<span foreground=\"#" + parent.ItemTextColor + "\">" + GLib.Markup.EscapeText(item.Name) + "</span>");
            layout.FontDescription = Pango.FontDescription.FromString("normal bold");
            layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels(10);

            cr.MoveTo(IconSize + 6, 4);
            Pango.CairoHelper.ShowLayout(cr, layout);

            layout.SetMarkup("<span foreground=\"#" + parent.ItemTextColor + "\">" + GLib.Markup.EscapeText(item.Description) + "</span>");
            layout.FontDescription.Dispose();
            layout.FontDescription = Pango.FontDescription.FromString("normal");
            layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels(10);
            cr.MoveTo(IconSize + 8, 19);
            Pango.CairoHelper.ShowLayout(cr, layout);

            if (drawArrow)
            {
                cr.MoveTo(width - 15, 13);
                cr.LineTo(width - 15 + 7, 17);
                cr.LineTo(width - 15, 21);
                Gdk.Color gc = new Gdk.Color();
                Gdk.Color.Parse("#" + parent.ItemTextColor, ref gc);
                cr.SetSourceRGB(gc);
                cr.Fill();
            }


            layout.FontDescription.Dispose();
            layout.Dispose();
            (cr as IDisposable).Dispose();
        }
Exemplo n.º 20
0
        private unsafe void RenderPixelGrid(Cairo.ImageSurface dst, Gdk.Point offset)
        {
            EnsureLookupTablesCreated();

            // Draw horizontal lines
            var dst_ptr   = (ColorBgra *)dst.DataPtr;
            int dstHeight = dst.Height;
            int dstWidth  = dst.Width;
            int dstStride = dst.Stride;
            int sTop      = d2sLookupY[offset.Y];
            int sBottom   = d2sLookupY[offset.Y + dstHeight];

            for (int srcY = sTop; srcY <= sBottom; ++srcY)
            {
                int dstY   = s2dLookupY[srcY];
                int dstRow = dstY - offset.Y;

                if (dstRow >= 0 && dstRow < dstHeight)
                {
                    ColorBgra *dstRowPtr    = dst.GetRowAddressUnchecked(dst_ptr, dstWidth, dstRow);
                    ColorBgra *dstRowEndPtr = dstRowPtr + dstWidth;

                    dstRowPtr += offset.X & 1;

                    while (dstRowPtr < dstRowEndPtr)
                    {
                        *dstRowPtr = ColorBgra.Black;
                        dstRowPtr += 2;
                    }
                }
            }

            // Draw vertical lines
            int sLeft  = d2sLookupX[offset.X];
            int sRight = d2sLookupX[offset.X + dstWidth];

            for (int srcX = sLeft; srcX <= sRight; ++srcX)
            {
                int dstX   = s2dLookupX[srcX];
                int dstCol = dstX - offset.X;

                if (dstCol >= 0 && dstCol < dstWidth)
                {
                    byte *dstColPtr    = (byte *)dst.GetPointAddress(dstCol, 0);
                    byte *dstColEndPtr = dstColPtr + dstStride * dstHeight;

                    dstColPtr += (offset.Y & 1) * dstStride;

                    while (dstColPtr < dstColEndPtr)
                    {
                        *((ColorBgra *)dstColPtr) = ColorBgra.Black;
                        dstColPtr += 2 * dstStride;
                    }
                }
            }
        }
Exemplo n.º 21
0
    protected override void inertialCheckIfInverted()
    {
        /*
         * 1) on inertial, when we start we should go down (because exercise starts in full extension)
         * if at the beginning we detect movement as positive means that the encoder is connected backwards or
         * the disc is in a position that makes the start in that direction
         * we use the '20' to detect when 'some' movement has been done
         * Just -1 all the past and future values of this capture
         * (we use the 'sum > 0' to know that it's going upwards)
         *
         * 2) here sum == sumInertialDisc and encoderReaded == encoderReadedInertialDisc
         * because this variables change later (when sum < -25 )
         */
        if (Math.Abs(sum) > 20)
        {
            inertialShouldCheckStartDirection = false;

            if (sum > 0)
            {
                inertialCaptureDirectionInverted = true;
                byteReaded           *= -1;
                directionNow         *= -1;
                directionLastMSecond *= -1;
                sum             *= -1;
                sumInertialDisc *= -1;

                int xWidth = recordingTime;
                if (cont)
                {
                    xWidth = recordedTimeCont;
                }

                for (int j = 0; j <= i; j++)
                {
                    encoderReaded[j]             *= -1;
                    encoderReadedInertialDisc[j] *= -1;
                }
                double sum2 = 0;
                for (int j = 0; j <= i; j++)
                {
                    sum2 += encoderReaded[j];
                    EncoderCapturePoints[j] = new Gdk.Point(
                        Convert.ToInt32(widthG * j / xWidth),
                        Convert.ToInt32((heightG / 2) - (sum2 * heightG / realHeightG))
                        );
                    //same for InertialDisc. Read comment 2 on the top of this method
                    EncoderCapturePointsInertialDisc[j] = new Gdk.Point(
                        Convert.ToInt32(widthG * j / xWidth),
                        Convert.ToInt32((heightG / 2) - (sum2 * heightG / realHeightG))
                        );
                }
                EncoderCapturePointsCaptured = i;
                EncoderCapturePointsPainted  = -1;                //mark meaning screen should be erased
            }
        }
    }
Exemplo n.º 22
0
        void HandleCursorPositionChanged(object sender, CursorPostionChangedArgs e)
        {
            Gdk.Point cursor  = Owner.CursorTracker.Cursor;
            int       monitor = Owner.Screen.GetMonitorAtPoint(cursor.X, cursor.Y);

            Gdk.Rectangle geo = Owner.Screen.GetMonitorGeometry(monitor);

            int activeRegion = Math.Min(geo.Height / 3, geo.Width / 3);

            Gdk.Rectangle left   = new Gdk.Rectangle(geo.X, geo.Y + activeRegion, activeRegion, geo.Height - activeRegion * 2);
            Gdk.Rectangle top    = new Gdk.Rectangle(geo.X + activeRegion, geo.Y, geo.Width - activeRegion * 2, activeRegion);
            Gdk.Rectangle right  = new Gdk.Rectangle(geo.X + geo.Width - activeRegion, geo.Y + activeRegion, activeRegion, geo.Height - activeRegion * 2);
            Gdk.Rectangle bottom = new Gdk.Rectangle(geo.X + activeRegion, geo.Y + geo.Height - activeRegion, geo.Width - activeRegion * 2, activeRegion);

            DockPosition target;

            if (top.Contains(cursor))
            {
                target = DockPosition.Top;
            }
            else if (bottom.Contains(cursor))
            {
                target = DockPosition.Bottom;
            }
            else if (left.Contains(cursor))
            {
                target = DockPosition.Left;
            }
            else if (right.Contains(cursor))
            {
                target = DockPosition.Right;
            }
            else
            {
                return;
            }

            IDockPreferences prefs = Owner.Preferences;

            if (prefs.Position != target || prefs.MonitorNumber != monitor)
            {
                Dock d = Docky.Controller.DocksForMonitor(monitor).FirstOrDefault(dock => dock.Preferences.Position == target);
                if (d == null)
                {
                    prefs.MonitorNumber = monitor;
                    prefs.Position      = target;
                }
                else
                {
                    d.Preferences.MonitorNumber = prefs.MonitorNumber;
                    d.Preferences.Position      = prefs.Position;
                    prefs.MonitorNumber         = monitor;
                    prefs.Position = target;
                }
            }
        }
Exemplo n.º 23
0
        internal void ShowPopup(Xwt.Widget widget, Xwt.Rectangle caret, PopupPosition position)
        {
            xwtParent            = widget;
            this.currentCaret    = new Gdk.Rectangle((int)caret.X, (int)caret.Y, (int)caret.Width, (int)caret.Height);
            Theme.TargetPosition = position;
            var pos = GtkUtil.GetSceenBounds(widget);

            targetWindowOrigin = new Point((int)pos.X, (int)pos.Y);
            RepositionWindow();
        }
Exemplo n.º 24
0
 public PointLocation GetPointLocation(Gdk.Rectangle drawing_area, Gdk.Point point)
 {
     Gdk.Rectangle pref_circle = new Gdk.Rectangle(drawing_area.X + drawing_area.Width - 32,
                                                   drawing_area.Y + 5, 15, 15);
     if (pref_circle.Contains(point))
     {
         return(PointLocation.Preferences);
     }
     return(PointLocation.Window);
 }
Exemplo n.º 25
0
        public void Render(List <Layer> layers, Cairo.ImageSurface dst, Gdk.Point offset)
        {
            dst.Flush();

            // Our rectangle of interest
            var r = new Gdk.Rectangle(offset, dst.GetBounds().Size).ToCairoRectangle();

            using (var g = new Cairo.Context(dst)) {
                // Create the transparent checkerboard background
                g.Translate(-offset.X, -offset.Y);
                g.FillRectangle(r, tranparent_pattern, new Cairo.PointD(offset.X, offset.Y));

                for (var i = 0; i < layers.Count; i++)
                {
                    var layer = layers[i];

                    // If we're in LivePreview, substitute current layer with the preview layer
                    if (layer == PintaCore.Layers.CurrentLayer && PintaCore.LivePreview.IsEnabled)
                    {
                        layer = CreateLivePreviewLayer(layer);
                    }

                    // If the layer is offset, handle it here
                    if (!layer.Transform.IsIdentity())
                    {
                        layer = CreateOffsetLayer(layer);
                    }

                    // No need to resize the surface if we're at 100% zoom
                    if (scale_factor.Ratio == 1)
                    {
                        layer.Draw(g, layer.Surface, layer.Opacity, false);
                    }
                    else
                    {
                        using (var scaled = new Cairo.ImageSurface(Cairo.Format.Argb32, dst.Width, dst.Height)) {
                            g.Save();
                            // Have to undo the translate set above
                            g.Translate(offset.X, offset.Y);
                            CopyScaled(layer.Surface, scaled, r.ToGdkRectangle());
                            layer.Draw(g, scaled, layer.Opacity, false);
                            g.Restore();
                        }
                    }
                }
            }

            // If we are at least 200% and grid is requested, draw it
            if (enable_pixel_grid && PintaCore.Actions.View.PixelGrid.Active && scale_factor.Ratio <= 0.5d)
            {
                RenderPixelGrid(dst, offset);
            }

            dst.MarkDirty();
        }
Exemplo n.º 26
0
 protected override void assignEncoderCapturePoints()
 {
     EncoderCapturePoints[i] = new Gdk.Point(
         Convert.ToInt32(widthG * i / recordingTime),
         Convert.ToInt32((heightG / 2) - (sum * heightG / realHeightG))
         );
     EncoderCapturePointsInertialDisc[i] = new Gdk.Point(
         Convert.ToInt32(widthG * i / recordingTime),
         Convert.ToInt32((heightG / 2) - (sumInertialDisc * heightG / realHeightG))
         );
 }
Exemplo n.º 27
0
        void OnCursorPositionChanged(Gdk.Point oldPoint)
        {
            if (CursorPositionChanged != null)
            {
                CursorPostionChangedArgs args = new CursorPostionChangedArgs {
                    LastPosition = oldPoint,
                };

                CursorPositionChanged(this, args);
            }
        }
Exemplo n.º 28
0
 //when we click our mouse button
 void DragStart(object sender, Gtk.ButtonPressEventArgs args)
 {
     // single click
     if (args.Event.Type == EventType.ButtonPress)
     {
         mouseStart = new Gdk.Point((int)Math.Floor(args.Event.X), (int)Math.Floor(args.Event.Y));
         Console.WriteLine("-------------------------------------");
         Console.WriteLine("Mouse Clicked");
         Console.WriteLine("Mouse Start Point: ({0}, {1})", mouseStart.X, mouseStart.Y);
         Console.WriteLine("-------------------------------------");
     }
 }
Exemplo n.º 29
0
        Gdk.Point [] Interpolate(int width, int height)
        {
            var vector = GetVector(width);
            var retval = new Gdk.Point [width];

            for (int i = 0; i < width; i++)
            {
                retval[i].X = x_offset + i;
                retval[i].Y = y_offset + height - Project(vector[i], MinY, MaxY, height);
            }
            return(retval);
        }
Exemplo n.º 30
0
        public void SetSurfaceAtPoint(DockySurface surface, Gdk.Point point)
        {
            if (surface == currentSurface && point == currentPoint)
            {
                window.QueueDraw();
                return;
            }

            ResetBackgroundBuffer();
            currentSurface = surface;
            currentPoint   = point;

            if (surface == null)
            {
                Hide();
                return;
            }

            window.SetSizeRequest(surface.Width, surface.Height);

            Gdk.Point center  = Gdk.Point.Zero;
            int       padding = 5;

            switch (Gravity)
            {
            case DockPosition.Top:
                center = new Gdk.Point(point.X - surface.Width / 2, point.Y + padding);
                break;

            case DockPosition.Left:
                center = new Gdk.Point(point.X + padding, point.Y - surface.Height / 2);
                break;

            case DockPosition.Right:
                center = new Gdk.Point(point.X - surface.Width - padding, point.Y - surface.Height / 2);
                break;

            case DockPosition.Bottom:
                center = new Gdk.Point(point.X - surface.Width / 2, point.Y - surface.Height - padding);
                break;
            }

            Gdk.Rectangle monitor_geo = window.Screen.GetMonitorGeometry(Monitor);
            center.X = Math.Max(monitor_geo.X, Math.Min(center.X, monitor_geo.X + monitor_geo.Width - surface.Width));
            center.Y = Math.Max(monitor_geo.Y, Math.Min(center.Y, monitor_geo.Y + monitor_geo.Height - surface.Height));

            if (Visible)
            {
                window.QueueDraw();
            }
            window.Move(center.X, center.Y);
        }
Exemplo n.º 31
0
        public override void FillPolygon(Color c, List <Point> points)
        {
            Gdk.Point[] pointArray = new Gdk.Point[points.Count];
            for (int i = 0; i < points.Count; ++i)
            {
                pointArray[i].X = (int)points[i].X;
                pointArray[i].Y = (int)points[i].Y;
            }

            Gdk.GC g = new Gdk.GC(window);
            g.RgbFgColor = GdkColor(c);
            window.DrawPolygon(g, true, pointArray);
        }
Exemplo n.º 32
0
    public DragHandler(Gtk.Widget widget, Func<Gdk.Point[], IEnumerator> generator)
    {
        var p = new Gdk.Point[2];
        IEnumerator coroutine = null;

        widget.ButtonPressEvent += (o, args) => {
            p [0] = new Gdk.Point ((int)args.Event.X, (int)args.Event.Y);
            coroutine = generator(p);

            if(!coroutine.MoveNext()) coroutine = null;
        };

        widget.MotionNotifyEvent += (o, args) => {
            if(coroutine != null){
                p[1] = new Gdk.Point ((int)args.Event.X, (int)args.Event.Y);

                if(!coroutine.MoveNext()) coroutine = null;
            }
        };

        //escape from coroutine
        widget.ButtonReleaseEvent += (o, args) => coroutine = null;
    }
Exemplo n.º 33
0
        private void DrawSelectionRect (Gtk.Widget widget, Gdk.Window window) {
            Gdk.GC gc = (widget.Style.WhiteGC);
            gc.SetLineAttributes (1,LineStyle.OnOffDash, CapStyle.Butt, JoinStyle.Miter);
            gc.Function = Function.Xor;
            _selectionRect.Normalize ();
                      
            Gdk.Point[] points = new Gdk.Point[4];
            points [0] = new Gdk.Point((int)_selectionRect.X, (int)_selectionRect.Y);
            points [1] = new Gdk.Point((int)_selectionRect.X2, (int)_selectionRect.Y);
            points [2] = new Gdk.Point((int)_selectionRect.X2, (int)_selectionRect.Y2);
            points [3] = new Gdk.Point((int)_selectionRect.X, (int)_selectionRect.Y2);

            window.DrawPolygon(gc, false, points);
        }
Exemplo n.º 34
0
		public void SetSurfaceAtPoint (DockySurface surface, Gdk.Point point)
		{
			if (surface == currentSurface && point == currentPoint) {
				window.QueueDraw ();
				return;
			}
			
			ResetBackgroundBuffer ();
			currentSurface = surface;
			currentPoint = point;
			
			if (surface == null) {
				Hide ();
				return;
			}
			
			window.SetSizeRequest (surface.Width, surface.Height);
				
			Gdk.Point center = Gdk.Point.Zero;
			int padding = 5;
			switch (Gravity) {
			case DockPosition.Top:
				center = new Gdk.Point (point.X - surface.Width / 2, point.Y + padding);
				break;
			case DockPosition.Left:
				center = new Gdk.Point (point.X + padding, point.Y - surface.Height / 2);
				break;
			case DockPosition.Right:
				center = new Gdk.Point (point.X - surface.Width - padding, point.Y - surface.Height / 2);
				break;
			case DockPosition.Bottom:
				center = new Gdk.Point (point.X - surface.Width / 2, point.Y - surface.Height - padding);
				break;
			}
			
			Gdk.Rectangle monitor_geo = window.Screen.GetMonitorGeometry (Monitor);
			center.X = Math.Max (monitor_geo.X, Math.Min (center.X, monitor_geo.X + monitor_geo.Width - surface.Width));
			center.Y = Math.Max (monitor_geo.Y, Math.Min (center.Y, monitor_geo.Y + monitor_geo.Height - surface.Height));
			
			if (Visible)
				window.QueueDraw ();
			window.Move (center.X, center.Y);
		}
Exemplo n.º 35
0
        private void GdkDraw(EventExpose evnt,int height,int width)
        {
            Time time = new Time();
            layout.SetMarkup("0");
            this.GdkWindow.DrawLayout(this.Style.TextGC(StateType.Normal),0,height-23,layout);

            Gdk.Point topL= new Gdk.Point((int)(CurrentFrame/pixelRatio-Scroll-5),height-15);
            Gdk.Point topR= new Gdk.Point((int)(CurrentFrame/pixelRatio-Scroll+5),height-15);
            Gdk.Point bottom= new Gdk.Point((int)(CurrentFrame/pixelRatio-Scroll),height);
            this.GdkWindow.DrawPolygon(this.Style.TextGC(StateType.Normal),true,new Gdk.Point[] {topL,topR,bottom});

            for(int i=10*FrameRate; i<=frames/pixelRatio;) {
                // Drawing separator line
                evnt.Window.DrawLine(Style.DarkGC(StateType.Normal),i-(int)Scroll,height,i-(int)Scroll,height-10);
                time.Seconds = (int)(i/FrameRate*pixelRatio);
                layout.SetMarkup(time.ToSecondsString());
                this.GdkWindow.DrawLayout(this.Style.TextGC(StateType.Normal),i-(int)Scroll-13,height-23,layout);
                //g.ShowText(time.ToSecondsString());
                i=i+10*FrameRate;
            }

            for(int i=0; i<=frames/pixelRatio;) {
                evnt.Window.DrawLine(Style.DarkGC(StateType.Normal),i-(int)Scroll,height,i-(int)Scroll,height-5);
                i=i+FrameRate;
            }
            // Drawing main line
            evnt.Window.DrawLine(Style.DarkGC(StateType.Normal),0,height,width,height);
        }
Exemplo n.º 36
0
        public static Point TransformOrientation(int total_width, int total_height, Point args, ImageOrientation orientation)
        {
            Point p = args;

            switch (orientation) {
            default:
            case ImageOrientation.TopLeft:
                break;
            case ImageOrientation.TopRight:
                p.X = total_width - p.X;
                break;
            case ImageOrientation.BottomRight:
                p.X = total_width - p.X;
                p.Y = total_height - p.Y;
                break;
            case ImageOrientation.BottomLeft:
                p.Y = total_height - p.Y;
                break;
            case ImageOrientation.LeftTop:
                p.X = args.Y;
                p.Y = args.X;
                break;
            case ImageOrientation.RightTop:
                p.X = total_height - args.Y;
                p.Y = args.X;
                break;
            case ImageOrientation.RightBottom:
                p.X = total_height - args.Y;
                p.Y = total_width - args.X;
                break;
            case ImageOrientation.LeftBottom:
                p.X = args.Y;
                p.Y = total_width - args.X;
                break;
            }
            return p;
        }
Exemplo n.º 37
0
		/// <summary>
		/// Updates drawing regions for the supplied surface
		/// </summary>
		/// <param name="surface">
		/// The <see cref="DockySurface"/> surface off which the coordinates will be based
		/// </param>
		void UpdateDrawRegionsForSurface (DockySurface surface)
		{
			// first we do the math as if this is a top dock, to do this we need to set
			// up some "pretend" variables. we pretend we are a top dock because 0,0 is
			// at the top.
			int width = surface.Width;
			int height = surface.Height;
			double zoom;
			
			Gdk.Point cursor = LocalCursor;
			Gdk.Point localCursor = cursor;
			
			// "relocate" our cursor to be on the top
			switch (Position) {
			case DockPosition.Right:
				cursor.X = (Width - 1) - cursor.X;
				break;
			case DockPosition.Bottom:
				cursor.Y = (Height - 1) - cursor.Y;
				break;
			default:
				break;
			}
			
			if (Preferences.IsVertical) {
				int tmpY = cursor.Y;
				cursor.Y = cursor.X;
				cursor.X = tmpY;
				
				// our width and height switch around if we have a veritcal dock
				width = surface.Height;
				height = surface.Width;
			}
			
			// this offset is used to split the icons into left/right aligned for panel mode
			double panelanim = PanelModeToggleProgress;
			int panel_item_offset;
			
			if (Preferences.IsVertical)
				panel_item_offset = (monitor_geo.Height - DockWidth) / 2;
			else
				panel_item_offset = (monitor_geo.Width - DockWidth) / 2;
			
			if (panelanim >= 1) {
				if (!Preferences.PanelMode)
					panel_item_offset = 0;
			} else {
				if (Preferences.PanelMode)
					panel_item_offset = (int) (panel_item_offset * panelanim);
				else
					panel_item_offset -= (int) (panel_item_offset * panelanim);
			}
			
			// the line along the dock width about which the center of unzoomed icons sit
			int midline = DockHeight / 2;
			
			// the left most edge of the first dock item
			int startX = ((width - DockWidth) / 2) + DockWidthBuffer - panel_item_offset;
			
			Gdk.Point center = new Gdk.Point (startX, midline);
			
			// right align docklets
			bool rightAlign = (Items [0].Owner != Preferences.DefaultProvider && Items [0] != DockyItem);
			if (rightAlign)
				center.X += 2 * panel_item_offset;
			
			int index = 0;
			foreach (AbstractDockItem adi in Items) {
				// anything after the first separator is a docklet, and right aligned
				if (!rightAlign && adi is SeparatorItem) {
					rightAlign = true;
					center.X += 2 * panel_item_offset;
				}
				
				// used to handle remove animations
				if (remove_index != 0 && remove_index < index && remove_index > index - 1) {
					double removePercent = 1 - Math.Min (1, (DateTime.UtcNow - remove_time).TotalMilliseconds / BaseAnimationTime.TotalMilliseconds);
					if (removePercent == 0)
						remove_index = 0;
					else
						center.X += (int) ((remove_size + ItemWidthBuffer) * removePercent);
				}
				
				DrawValue val = new DrawValue ();
				int iconSize = IconSize;
				
				// div by 2 may result in rounding errors? Will this render OK? Shorts WidthBuffer by 1?
				double halfSize = iconSize / 2.0;
				
				if (!adi.Square) {
					DockySurface icon = adi.IconSurface (surface, iconSize, iconSize, VisibleDockHeight);
					halfSize = ((adi.RotateWithDock || !Preferences.IsVertical) ? icon.Width : icon.Height) / 2.0;
				}
				
				// animate adding new icon
				halfSize *= Math.Min (1, (DateTime.UtcNow - adi.AddTime).TotalMilliseconds / BaseAnimationTime.TotalMilliseconds);
				
				// center now represents our midpoint
				center.X += (int) Math.Floor (halfSize);
				val.StaticCenter = new PointD (center.X, center.Y);
				
				// get us some handy doubles with fancy names
				double cursorPosition = cursor.X;
				double centerPosition = center.X;
				
				// ZoomPercent is a number greater than 1.  It should never be less than one.
				
				// zoomInPercent is a range of 1 to ZoomPercent.
				// We need a number that is 1 when ZoomIn is 0, and ZoomPercent when ZoomIn is 1.
				// Then we treat this as if it were the ZoomPercent for the rest of the calculation.
				double zoomInPercent = 1 + (ZoomPercent - 1) * ZoomIn;
				
				double zoomSize = ZoomEnabled ? ZoomedIconSize : 2.0 * IconSize;
				
				// offset from the center of the true position, ranged between 0 and the zoom size
				double offset = Math.Min (Math.Abs (cursorPosition - centerPosition), zoomSize);
				
				double offsetPercent;
				if (ExternalDragActive && DragTracker.ProviderAcceptsDrop ()) {
					// Provide space for dropping between items
					offset += offset * zoomSize / IconSize;
					offsetPercent = Math.Min (1, offset / (zoomSize + ZoomedIconSize));
				} else {
					offsetPercent = offset / zoomSize;
				}
				
				if (offsetPercent > .99)
					offsetPercent = 1;
				
				// pull in our offset to make things less spaced out
				// explaination since this is a bit tricky...
				// we have three terms, basically offset = f(x) * h(x) * g(x)
				// f(x) == offset identity
				// h(x) == a number from 0 to DockPreference.ZoomPercent - 1.  This is used to get the smooth "zoom in" effect.
				//         additionally serves to "curve" the offset based on the max zoom
				// g(x) == a term used to move the ends of the zoom inward.  Precalculated that the edges should be 66% of the current
				//         value. The center is 100%. (1 - offsetPercent) == 0,1 distance from center
				// The .66 value comes from the area under the curve.  Dont ask me to explain it too much because it's too clever for me.
				
				// for external drags with no zoom, we pretend there is actually a zoom of 200%
				if (ExternalDragActive && ZoomPercent == 1 && DragTracker.ProviderAcceptsDrop ())
					offset *= ZoomIn / 2.0;
				else
					offset *= zoomInPercent - 1;
				offset *= 1 - offsetPercent / 3;
				
				if (cursorPosition > centerPosition)
					centerPosition -= offset;
				else
					centerPosition += offset;
				
				if (!adi.Zoom) {
					val.Zoom = 1;
					val.Center = new Cairo.PointD ((int) centerPosition, center.Y);
				} else {
					// zoom is calculated as 1 through target_zoom (default 2).  
					// The larger your offset, the smaller your zoom
					
					// First we get the point on our curve that defines our current zoom
					// offset is always going to fall on a point on the curve >= 0
					zoom = 1 - Math.Pow (offsetPercent, 2);
					
					// scale this to match our zoomInPercent
					zoom = 1 + zoom * (zoomInPercent - 1);
					
					double zoomedCenterHeight = DockHeightBuffer + (iconSize * zoom / 2.0);
					
					if (zoom == 1)
						centerPosition = Math.Round (centerPosition);
					
					val.Center = new Cairo.PointD (centerPosition, zoomedCenterHeight);
					val.Zoom = zoom;
				}
				
				// now we undo our transforms to the point
				if (Preferences.IsVertical) {
					double tmpY = val.Center.Y;
					val.Center.Y = val.Center.X;
					val.Center.X = tmpY;
					
					tmpY = val.StaticCenter.Y;
					val.StaticCenter.Y = val.StaticCenter.X;
					val.StaticCenter.X = tmpY;
				}
				
				switch (Position) {
				case DockPosition.Right:
					val.Center.X = (height - 1) - val.Center.X;
					val.StaticCenter.X = (height - 1) - val.StaticCenter.X;
					break;
				case DockPosition.Bottom:
					val.Center.Y = (height - 1) - val.Center.Y;
					val.StaticCenter.Y = (height - 1) - val.StaticCenter.Y;
					break;
				default:
					break;
				}
				
				Gdk.Rectangle hoverArea = DrawRegionForItemValue (adi, val, true);
				
				if (Preferences.IsVertical) {
					hoverArea.Inflate ((int) (ZoomedDockHeight * .3), ItemWidthBuffer / 2);
					hoverArea.Width += DockHeightBuffer;
				} else {
					hoverArea.Inflate (ItemWidthBuffer / 2, (int) (ZoomedDockHeight * .3));
					hoverArea.Height += DockHeightBuffer;
				}
				
				switch (Position) {
				case DockPosition.Right:
					hoverArea.X -= DockHeightBuffer;
					break;
				case DockPosition.Bottom:
					hoverArea.Y -= DockHeightBuffer;
					break;
				default:
					break;
				}
				
				val.HoverArea = hoverArea;
				DrawValues[adi] = val;

				// keep the hovereditem in mind, but don't change it while rendering
				if (hoverArea.Contains (localCursor) && !AutohideManager.Hidden && !(adi is SeparatorItem))
					next_hoveredItem = adi;
				
				if (update_screen_regions) {
					if (Menu.Visible || ConfigurationMode || Painter != null) {
						adi.SetScreenRegion (Screen, new Gdk.Rectangle (0, 0, 0, 0));
					} else {
						Gdk.Rectangle region = hoverArea;
						region.X += window_position.X;
						region.Y += window_position.Y;
						adi.SetScreenRegion (Screen, region);
					}
				}
				
				// move past midpoint to end of icon
				center.X += (int) Math.Ceiling (halfSize) + ItemWidthBuffer;
				
				index++;
			}
			
			update_screen_regions = false;
		}
Exemplo n.º 38
0
    protected override void inertialCheckIfInverted()
    {
        /*
         * 1) on inertial, when we start we should go down (because exercise starts in full extension)
         * if at the beginning we detect movement as positive means that the encoder is connected backwards or
         * the disc is in a position that makes the start in that direction
         * we use the '20' to detect when 'some' movement has been done
         * Just -1 all the past and future values of this capture
         * (we use the 'sum > 0' to know that it's going upwards)
         *
         * 2) here sum == sumInertialDisc and encoderReaded == encoderReadedInertialDisc
         * because this variables change later (when sum < -25 )
         */
        if(Math.Abs(sum) > 20)
        {
            inertialShouldCheckStartDirection = false;

            if(sum > 0) {
                inertialCaptureDirectionInverted = true;
                byteReaded *= -1;
                directionNow *= -1;
                directionLastMSecond *= -1;
                sum *= -1;
                sumInertialDisc *= -1;

                int xWidth = recordingTime;
                if(cont)
                    xWidth = recordedTimeCont;

                for(int j=0; j <= i; j ++) {
                    encoderReaded[j] *= -1;
                    encoderReadedInertialDisc[j] *= -1;
                }
                double sum2=0;
                for(int j=0; j <= i; j ++) {
                    sum2 += encoderReaded[j];
                    EncoderCapturePoints[j] = new Gdk.Point(
                            Convert.ToInt32(widthG * j / xWidth),
                            Convert.ToInt32( (heightG/2) - ( sum2 * heightG / realHeightG) )
                            );
                    //same for InertialDisc. Read comment 2 on the top of this method
                    EncoderCapturePointsInertialDisc[j] = new Gdk.Point(
                            Convert.ToInt32(widthG * j / xWidth),
                            Convert.ToInt32( (heightG/2) - ( sum2 * heightG / realHeightG) )
                            );
                }
                EncoderCapturePointsCaptured = i;
                EncoderCapturePointsPainted = -1; //mark meaning screen should be erased
            }
        }
    }
Exemplo n.º 39
0
        void HandleButtonPressEvent(object sender, ButtonPressEventArgs args)
        {
            switch (args.Event.Type) {
            case EventType.ButtonPress:
                if (args.Event.Button == 1) {
                    start = new Gdk.Point ((int)args.Event.X, (int)args.Event.Y);
                    start_root = new Gdk.Point ((int)args.Event.XRoot, (int)args.Event.YRoot);
                    start_hot = hotspot;

                    Gdk.Point win;
                    GdkWindow.GetOrigin (out win.X, out win.Y);
                    start_hot.X += win.X;
                    start_hot.Y += win.Y;

                    dragging = true;
                    rotate = (args.Event.State & ModifierType.ShiftMask) > 0;
                    start_angle = Angle;
                } else {
                    Angle += Math.PI /8;
                }
                break;
            case EventType.TwoButtonPress:
                dragging = false;
                App.Instance.Organizer.HideLoupe ();
                break;
            }
        }
Exemplo n.º 40
0
		private static void GetPerpendicularCoords (int x,
							    int y,
							    double
							    sin,
							    double
							    cos,
							    int width,
							    out Gdk.
							    Point p1,
							    out Gdk.Point p2)
		{
			int alpha = width / 2;
			p1 = new Gdk.Point ((int) Math.
					    Round (x + (alpha * sin)),
					    (int) Math.Round (y -
							      (alpha * cos)));
			p2 = new Gdk.Point ((int) Math.
					    Round (x - (alpha * sin)),
					    (int) Math.Round (y +
							      (alpha * cos)));
		}
Exemplo n.º 41
0
		public static void DrawArrow (Cairo.Context cairo,
					      Cairo.Color color, int x1,
					      int y1, int x2, int y2,
					      int size, bool filled)
		{
			double len =
				Math.Sqrt ((y2 - y1) * (y2 - y1) +
					   (x2 - x1) * (x2 - x1));
			double sin = (y2 - y1) / len;
			double cos = (x2 - x1) / len;

			int alpha = size / 4;

			double line_portion = 0.75 * size / 2;
			// the tip now touches the end of the square.
			// computing it like this takes care of the direction
			// from which the arrow is coming!
			Gdk.Point tip = new Gdk.Point ((int) Math.
						       Round (x2 -
							      line_portion
							      * cos),
						       (int) Math.
						       Round (y2 -
							      line_portion
							      * sin));
			x2 = tip.X;
			y2 = tip.Y;

			Gdk.Point[]a = new Gdk.Point[2];
			GetPerpendicularCoords (x1, y1, sin, cos,
						alpha, out a[0], out a[1]);

			// This is the point where the arrow will start.
			// We need to draw a rectangle from the above point to this.
			// And the a triangle to the final dest.
			double factor = 1.5;
			Gdk.Point p =
				new Gdk.Point ((int) Math.
					       Round (x2 -
						      factor * alpha *
						      cos),
					       (int) Math.Round (y2 -
								 factor
								 *
								 alpha
								 * sin));


			Gdk.Point[]b = new Gdk.Point[2];
			GetPerpendicularCoords (p.X, p.Y, sin, cos,
						alpha, out b[0], out b[1]);
			Gdk.Point c, d;
			GetPerpendicularCoords (p.X, p.Y, sin, cos,
						3 * alpha, out c, out d);

			Gdk.Point[]points = new Gdk.Point[]
			{
			a[0], a[1], b[1], d, tip, c, b[0], a[0]};
			/*
			   Cairo.Color color =
			   new Cairo.Color (0.5, 0.5, 0.8, 0.5);
			 */
			cairo.Color = color;
			double orig = cairo.LineWidth;
			double fraction = 5;
			if (alpha > fraction)
				cairo.LineWidth = alpha / fraction;

			for (int i = 0; i < points.Length; i++)
			  {
				  if (i == 0)
					  cairo.MoveTo (points[i].X,
							points[i].Y);
				  if (i == points.Length - 1)
					  cairo.LineTo (points[0].X,
							points[0].Y);
				  else
					  cairo.LineTo (points[i + 1].
							X, points[i + 1].Y);
			  }
			cairo.FillPreserve ();
			color.A = 0.8;
			cairo.Color = color;
			cairo.Stroke ();
			cairo.LineWidth = orig;
		}
Exemplo n.º 42
0
		internal void ShowPopup (Xwt.Widget widget, Xwt.Rectangle caret, PopupPosition position)
		{
			xwtParent = widget;
			this.currentCaret = new Gdk.Rectangle ((int)caret.X, (int)caret.Y, (int)caret.Width, (int)caret.Height);
			Theme.TargetPosition = position;
			var pos = GtkUtil.GetSceenBounds (widget);
			targetWindowOrigin = new Point ((int)pos.X, (int)pos.Y);
			RepositionWindow ();
		}
Exemplo n.º 43
0
        private int[] CreateS2DLookupY(int srcHeight, int dstHeight, ScaleFactor scaleFactor)
        {
            var lookup = new int[srcHeight + 1];

            for (int y = 0; y < lookup.Length; ++y) {
                Gdk.Point pt = new Gdk.Point (0, y);
                Gdk.Point clientPt = scaleFactor.UnscalePoint (pt);

                // Sometimes the scale factor is slightly different on one axis than
                // on another, simply due to accuracy. So we have to clamp this value to
                // be within bounds.
                lookup[y] = Utility.Clamp (clientPt.Y, 0, dstHeight - 1);
            }

            return lookup;
        }
Exemplo n.º 44
0
        private int[] CreateS2DLookupX(int srcWidth, int dstWidth, ScaleFactor scaleFactor)
        {
            var lookup = new int[srcWidth + 1];

            for (int x = 0; x < lookup.Length; ++x) {
                Gdk.Point pt = new Gdk.Point (x, 0);
                Gdk.Point clientPt = scaleFactor.UnscalePoint (pt);

                // Sometimes the scale factor is slightly different on one axis than
                // on another, simply due to accuracy. So we have to clamp this value to
                // be within bounds.
                lookup[x] = Utility.Clamp (clientPt.X, 0, dstWidth - 1);
            }

            return lookup;
        }
Exemplo n.º 45
0
		void ShowPopup (Gtk.Widget parent, Gdk.EventButton evt, Gdk.Rectangle caret, PopupPosition position)
		{
			this.parent = parent;
			this.currentCaret = caret;
			Theme.TargetPosition = position;
			Gdk.Window targetWindow;
			if (evt != null) {
				eventProvided = true;
				targetWindow = evt.Window;
			} else
				targetWindow = parent.GdkWindow;
			
			if (targetWindow != null) {
				int x, y;
				targetWindow.GetOrigin (out x, out y);
				targetWindowOrigin = new Point (x, y);
			}
			RepositionWindow ();
		}
Exemplo n.º 46
0
        void HandleImageViewMotion(object sender, MotionNotifyEventArgs args)
        {
            Gdk.Point coords;
            coords = new Gdk.Point ((int) args.Event.X, (int) args.Event.Y);

            SetSamplePoint (view.WindowCoordsToImage (coords));
        }
Exemplo n.º 47
0
    protected override void encoderCapturePointsAdaptativeDisplay()
    {
        //adaptative displayed height
        //if points go outside the graph, duplicate size of graph
        if(
                EncoderCapturePoints[i].Y > heightG || EncoderCapturePoints[i].Y < 0 ||
                EncoderCapturePointsInertialDisc[i].Y > heightG ||
                EncoderCapturePointsInertialDisc[i].Y < 0 ) {
            realHeightG *= 2;

            int xWidth = recordingTime;
            if(cont)
                xWidth = recordedTimeCont;

            double sum2 = 0;
            double sum2InertialDisc = 0;
            for(int j=0; j <= i; j ++) {
                sum2 += encoderReaded[j];
                sum2InertialDisc += encoderReadedInertialDisc[j];
                EncoderCapturePoints[j] = new Gdk.Point(
                        Convert.ToInt32(widthG * j / xWidth),
                        Convert.ToInt32( (heightG/2) - ( sum2 * heightG / realHeightG) )
                        );
                EncoderCapturePointsInertialDisc[j] = new Gdk.Point(
                        Convert.ToInt32(widthG * j / xWidth),
                        Convert.ToInt32( (heightG/2) - ( sum2InertialDisc * heightG / realHeightG) )
                        );
            }
            EncoderCapturePointsCaptured = i;
            EncoderCapturePointsPainted = -1; //mark meaning screen should be erased and start painting from the beginning
        }
    }
Exemplo n.º 48
0
		public void ShowPopup (Xwt.Rectangle onScreenArea, PopupPosition position)
		{
			this.parent = IdeApp.Workbench.RootWindow;
			this.currentCaret = new Rectangle ((int)onScreenArea.X, (int)onScreenArea.Y, (int)onScreenArea.Width, (int)onScreenArea.Height);
			Theme.TargetPosition = position;
			targetWindowOrigin = new Point ((int)onScreenArea.X, (int)onScreenArea.Y);
			RepositionWindow ();
		}
Exemplo n.º 49
0
		internal void UpdateHoverText ()
		{
			int top = (int) (IconSize * (ZoomPercent + .2));
			Gdk.Point point = new Gdk.Point (-1, -1);
			DockySurface hover = null;
			
			if (ActiveGlow) {
				if (config_hover_buffer == null)
					config_hover_buffer = DrawHoverText (config_hover_buffer, Catalog.GetString ("Drag to reposition"));
				hover = config_hover_buffer;
				top = IconSize + 2 * DockHeightBuffer;
			} else if (hoveredItem != null && background_buffer != null) {
				if (ExternalDragActive) {
					if (DragTracker.ItemAcceptsDrop ()) {
						if (launch_hover_buffer != null)
							launch_hover_buffer.Dispose ();
						launch_hover_buffer = DrawHoverText (launch_hover_buffer, hoveredItem.DropText);
						hover = launch_hover_buffer;
					} else if (DragTracker.ProviderAcceptsDrop ()) {
						if (drop_hover_buffer == null)
							drop_hover_buffer = DrawHoverText (drop_hover_buffer, Catalog.GetString ("Drop to add to dock"));
						hover = drop_hover_buffer;
					}
				} else {
					hover = hoveredItem.HoverTextSurface (background_buffer, Style, HoverTextManager.IsLight);
					
					DrawValue loc = DrawValues[hoveredItem].MoveIn (Position, IconSize * (ZoomPercent + .1) - IconSize / 2);
					
					point = new Gdk.Point ((int) loc.StaticCenter.X, (int) loc.StaticCenter.Y);
					point.X += window_position.X;
					point.Y += window_position.Y;
				}
			} else if (hoveredItem == null && ExternalDragActive && DragTracker.ProviderAcceptsDrop ()) {
				if (drop_hover_buffer == null)
					drop_hover_buffer = DrawHoverText (drop_hover_buffer, Catalog.GetString ("Drop to add to dock"));
				hover = drop_hover_buffer;
			} else {
				return;
			}
			
			// default centers it on the dock
			if (point.X == -1 && point.Y == -1) {
				int offset = 8;
				switch (Position) {
				default:
				case DockPosition.Top:
					point = new Gdk.Point (window_position.X + Allocation.Width / 2, offset + window_position.Y + top);
					break;
				case DockPosition.Bottom:
					point = new Gdk.Point (window_position.X + Allocation.Width / 2, window_position.Y + Allocation.Height - top - offset);
					break;
				case DockPosition.Left:
					point = new Gdk.Point (offset + window_position.X + top, window_position.Y + Allocation.Height / 2);
					break;
				case DockPosition.Right:
					point = new Gdk.Point (window_position.X + Allocation.Width - top - offset, window_position.Y + Allocation.Height / 2);
					break;
				}
			}
			
			TextManager.Gravity = Position; // FIXME
			TextManager.Monitor = Monitor;
			TextManager.SetSurfaceAtPoint (hover, point);
		}
Exemplo n.º 50
0
		void Update (Gdk.Screen screen, int x, int y, Gdk.ModifierType mod)
		{
			last_update = DateTime.UtcNow;
				
			if (!Enabled)
				return;
			
			Gdk.Point lastPostion = Cursor;
			
			Cursor = new Gdk.Point (x, y);
			Modifier = mod;
			Screen = screen;
			
			if (lastPostion != Cursor)
				OnCursorPositionChanged (lastPostion);
		}
Exemplo n.º 51
0
    private void updateEncoderCaptureGraphPaint(UpdateEncoderPaintModes mode)
    {
        if(eCapture.EncoderCapturePoints == null)
            return;

        //this happens when EncoderCaptureShowOnlyBars=TRUE
        if(encoder_capture_signal_drawingarea == null || encoder_capture_signal_pixmap == null)
            return;

        bool refreshAreaOnly = false;

        //mark meaning screen should be erased
        if(eCapture.EncoderCapturePointsPainted == -1) {
            UtilGtk.ErasePaint(encoder_capture_signal_drawingarea, encoder_capture_signal_pixmap);
            eCapture.EncoderCapturePointsPainted = 0;
        }

        //also can be optimized to do not erase window every time and only add points since last time
        int last = eCapture.EncoderCapturePointsCaptured;
        int toDraw = eCapture.EncoderCapturePointsCaptured - eCapture.EncoderCapturePointsPainted;

        //LogB.Information("last - toDraw:" + last + " - " + toDraw);

        //fixes crash at the end
        if(toDraw == 0)
            return;

        int maxY=-1;
        int minY=10000;

        Gdk.Point [] paintPoints = new Gdk.Point[toDraw];
        Gdk.Point [] paintPointsInertial = new Gdk.Point[toDraw];

        //currently disabled points painting on continuous mode
        if(radio_encoder_capture_cont.Active) {
            int graphWidth = encoder_capture_signal_drawingarea.Allocation.Width;
            int graphHeight = encoder_capture_signal_drawingarea.Allocation.Height;

            layout_encoder_capture_signal.SetMarkup("Graph currently disabled\non continuous mode");
            int textWidth = 1;
            int textHeight = 1;
            layout_encoder_capture_signal.GetPixelSize(out textWidth, out textHeight);

            encoder_capture_signal_pixmap.DrawLayout(pen_blue_encoder_capture,
                    graphWidth/2 - textWidth/2, graphHeight/2 - textHeight/2, layout_encoder_capture_signal);
        }
        else {
            for(int j=0, i = eCapture.EncoderCapturePointsPainted +1 ; i <= last ; i ++, j++)
            {
                paintPoints[j] = eCapture.EncoderCapturePoints[i];

                if(refreshAreaOnly) {
                    if(eCapture.EncoderCapturePoints[i].Y > maxY)
                        maxY = eCapture.EncoderCapturePoints[i].Y;
                    if(eCapture.EncoderCapturePoints[i].Y < minY)
                        minY = eCapture.EncoderCapturePoints[i].Y;
                }

            }

            if(mode == UpdateEncoderPaintModes.INERTIAL) {
                for(int j=0, i = eCapture.EncoderCapturePointsPainted +1 ; i <= last ; i ++, j ++)
                {
                    //only assign the points if they are different than paintPoints
                    if(eCapture.EncoderCapturePointsInertialDisc[i] != eCapture.EncoderCapturePoints[i] &&
                            (i % 800) <= 520 //dashed accepting 520 points and discarding 280
                      ) {
                        paintPointsInertial[j] = eCapture.EncoderCapturePointsInertialDisc[i];

                        if(refreshAreaOnly) {
                            if(eCapture.EncoderCapturePointsInertialDisc[i].Y > maxY)
                                maxY = eCapture.EncoderCapturePointsInertialDisc[i].Y;
                            if(eCapture.EncoderCapturePointsInertialDisc[i].Y < minY)
                                minY = eCapture.EncoderCapturePointsInertialDisc[i].Y;
                        }
                    }
                }
                encoder_capture_signal_pixmap.DrawPoints(pen_gray, paintPointsInertial);
            }
            //paint this after the inertial because this should mask the other
            encoder_capture_signal_pixmap.DrawPoints(pen_black_encoder_capture, paintPoints);
        }

        //write title
        string title = "";
        if(mode == UpdateEncoderPaintModes.CALCULE_IM)
            title = Catalog.GetString("Inertia M.");
        else {
            title = currentPerson.Name + " (";
            if(encoderConfigurationCurrent.has_inertia)
                title += encoderConfigurationCurrent.inertiaTotal.ToString() + " " + Catalog.GetString("Inertia M.") + ")";
            else
                title += findMass(Constants.MassType.EXTRA).ToString() + "Kg)";
        }
        layout_encoder_capture_signal.SetMarkup(title);

        encoder_capture_signal_pixmap.DrawLayout(pen_blue_encoder_capture, 5, 5, layout_encoder_capture_signal);

        if(refreshAreaOnly) {
            /*
                        LogB.Information("pp X-TD-W: " +
                        paintPoints[0].X.ToString() + " - " +
                        paintPoints[toDraw-1].X.ToString() + " - " +
                        (paintPoints[toDraw-1].X-paintPoints[0].X).ToString());
                        */

            int startX = paintPoints[0].X;
            /*
             * this helps to ensure that no white points are drawed
             * caused by this int when eCapture.EncoderCapturePoints are assigned:
             * Convert.ToInt32(width*i/recordingTime)
             */
            int exposeMargin = 4;
            if(startX -exposeMargin > 0)
                startX -= exposeMargin;

            encoder_capture_signal_drawingarea.QueueDrawArea( 			// -- refresh
                    startX,
                    minY,
                    (paintPoints[toDraw-1].X-paintPoints[0].X ) + exposeMargin,
                    maxY-minY
                    );
            //if refreshAreaOnly is true, then repeat above instruction for paintPointsInertial

            LogB.Information("minY - maxY " + minY + " - " + maxY);
        } else
            encoder_capture_signal_drawingarea.QueueDraw(); 			// -- refresh

        eCapture.EncoderCapturePointsPainted = eCapture.EncoderCapturePointsCaptured;
    }
Exemplo n.º 52
0
 Gdk.Point[] Interpolate(int width, int height)
 {
     var vector = GetVector (width);
     var retval = new Gdk.Point [width];
     for (int i = 0; i < width; i++) {
         retval[i].X = x_offset + i;
         retval[i].Y = y_offset + height - Project (vector[i], MinY, MaxY, height);
     }
     return retval;
 }