Ejemplo n.º 1
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            origin_offset = point;
            is_dragging = true;

            hist = new MovePixelsHistoryItem (Icon, Name);
            hist.TakeSnapshot ();

            if (!PintaCore.Layers.ShowSelectionLayer) {
                // Copy the selection to the temp layer
                PintaCore.Layers.CreateSelectionLayer ();
                PintaCore.Layers.ShowSelectionLayer = true;

                using (Cairo.Context g = new Cairo.Context (PintaCore.Layers.SelectionLayer.Surface)) {
                    g.AppendPath (PintaCore.Layers.SelectionPath);
                    g.FillRule = FillRule.EvenOdd;
                    g.SetSource (PintaCore.Layers.CurrentLayer.Surface);
                    g.Clip ();
                    g.Paint ();
                }

                Cairo.ImageSurface surf = PintaCore.Layers.CurrentLayer.Surface;

                using (Cairo.Context g = new Cairo.Context (surf)) {
                    g.AppendPath (PintaCore.Layers.SelectionPath);
                    g.FillRule = FillRule.EvenOdd;
                    g.Operator = Cairo.Operator.Clear;
                    g.Fill ();
                }
            }

            canvas.GdkWindow.Invalidate ();
        }
Ejemplo n.º 2
0
		protected override void OnStartTransform ()
		{
			base.OnStartTransform ();

			Document doc = PintaCore.Workspace.ActiveDocument;

			// If there is no selection, select the whole image.
			if (doc.Selection.SelectionPolygons.Count == 0) {
                doc.Selection.CreateRectangleSelection (
                    new Cairo.Rectangle (0, 0, doc.ImageSize.Width, doc.ImageSize.Height));
			}

			original_selection = new List<List<IntPoint>> (doc.Selection.SelectionPolygons);
			original_transform.InitMatrix (doc.SelectionLayer.Transform);

			hist = new MovePixelsHistoryItem (Icon, Name, doc);
			hist.TakeSnapshot (!doc.ShowSelectionLayer);

			if (!doc.ShowSelectionLayer) {
				// Copy the selection to the temp layer
				doc.CreateSelectionLayer ();
				doc.ShowSelectionLayer = true;

				using (Cairo.Context g = new Cairo.Context (doc.SelectionLayer.Surface)) {
					g.AppendPath (doc.Selection.SelectionPath);
					g.FillRule = FillRule.EvenOdd;
					g.SetSource (doc.CurrentUserLayer.Surface);
					g.Clip ();
					g.Paint ();
				}

				Cairo.ImageSurface surf = doc.CurrentUserLayer.Surface;
				
				using (Cairo.Context g = new Cairo.Context (surf)) {
					g.AppendPath (doc.Selection.SelectionPath);
					g.FillRule = FillRule.EvenOdd;
					g.Operator = Cairo.Operator.Clear;
					g.Fill ();
				}
			}
			
			PintaCore.Workspace.Invalidate ();
		}
Ejemplo n.º 3
0
        protected override void OnFinishTransform()
        {
            base.OnFinishTransform ();

            if (hist != null)
                PintaCore.History.PushNewItem (hist);

            hist = null;
            original_selection = null;
            original_transform.InitIdentity ();
        }
Ejemplo n.º 4
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            is_dragging = false;

            if (hist != null)
                PintaCore.History.PushNewItem (hist);

            hist = null;
        }
Ejemplo n.º 5
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            // If we are already drawing, ignore any additional mouse down events
            if (is_dragging)
                return;

            Document doc = PintaCore.Workspace.ActiveDocument;

            origin_offset = point;
            is_dragging = true;

            hist = new MovePixelsHistoryItem (Icon, Name, doc);
            hist.TakeSnapshot (!doc.ShowSelectionLayer);

            if (!doc.ShowSelectionLayer) {
                // Copy the selection to the temp layer
                doc.CreateSelectionLayer ();
                doc.ShowSelectionLayer = true;

                using (Cairo.Context g = new Cairo.Context (doc.SelectionLayer.Surface)) {
                    g.AppendPath (doc.Selection.SelectionPath);
                    g.FillRule = FillRule.EvenOdd;
                    g.SetSource (doc.CurrentLayer.Surface);
                    g.Clip ();
                    g.Paint ();
                }

                Cairo.ImageSurface surf = doc.CurrentLayer.Surface;

                using (Cairo.Context g = new Cairo.Context (surf)) {
                    g.AppendPath (doc.Selection.SelectionPath);
                    g.FillRule = FillRule.EvenOdd;
                    g.Operator = Cairo.Operator.Clear;
                    g.Fill ();
                }
            }

            canvas.GdkWindow.Invalidate ();
        }