Inheritance: BaseHistoryItem
Exemplo n.º 1
0
		protected override void OnMouseDown (DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
		{
			// Ignore extra button clicks while drawing
			if (is_drawing)
				return;

			Document doc = PintaCore.Workspace.ActiveDocument;
			hist = new SelectionHistoryItem(Icon, Name);
			hist.TakeSnapshot();

			reset_origin = args.Event.GetPoint();

            active_control = HandleResize (point);
			if (!active_control.HasValue)
			{
				combine_mode = PintaCore.Workspace.SelectionHandler.DetermineCombineMode(args);

				double x = Utility.Clamp(point.X, 0, doc.ImageSize.Width - 1);
				double y = Utility.Clamp(point.Y, 0, doc.ImageSize.Height - 1);
				shape_origin = new PointD(x, y);

                doc.PreviousSelection.Dispose ();
				doc.PreviousSelection = doc.Selection.Clone();
				doc.Selection.SelectionPolygons.Clear();

                // The bottom right corner should be selected.
                active_control = 3;
			}

            is_drawing = true;
		}
Exemplo n.º 2
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            shape_origin = point;
            is_drawing = true;

            hist = new SelectionHistoryItem (Icon, Name);
            hist.TakeSnapshot ();
        }
Exemplo n.º 3
0
		protected override void OnStartTransform ()
		{
			base.OnStartTransform ();

			Document doc = PintaCore.Workspace.ActiveDocument;
			original_selection = new List<List<IntPoint>> (doc.Selection.SelectionPolygons);

			hist = new SelectionHistoryItem (Icon, Name);
			hist.TakeSnapshot ();
		}
Exemplo n.º 4
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            // Ignore extra button clicks while drawing
            if (is_drawing)
                return;

            shape_origin = point;
            is_drawing = true;

            hist = new SelectionHistoryItem (Icon, Name);
            hist.TakeSnapshot ();
        }
Exemplo n.º 5
0
        private void HandlePintaCoreActionsEditDeselectActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit();

            SelectionHistoryItem hist = new SelectionHistoryItem("Menu.Edit.Deselect.png", Catalog.GetString("Deselect"));

            hist.TakeSnapshot();

            doc.ResetSelectionPaths();

            doc.History.PushNewItem(hist);
            doc.Workspace.Invalidate();
        }
Exemplo n.º 6
0
        private void HandlePintaCoreActionsEditDeselectActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit();

            SelectionHistoryItem hist = new SelectionHistoryItem(Resources.Icons.EditSelectionNone, Translations.GetString("Deselect"));

            hist.TakeSnapshot();

            doc.ResetSelectionPaths();

            doc.History.PushNewItem(hist);
            doc.Workspace.Invalidate();
        }
Exemplo n.º 7
0
        private void HandlePintaCoreActionsEditSelectAllActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit();

            SelectionHistoryItem hist = new SelectionHistoryItem(Stock.SelectAll, Catalog.GetString("Select All"));

            hist.TakeSnapshot();

            doc.ResetSelectionPaths();
            doc.Selection.Visible = true;

            doc.History.PushNewItem(hist);
            doc.Workspace.Invalidate();
        }
Exemplo n.º 8
0
		protected override void OnMouseDown (Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
		{
			if (is_drawing)
				return;

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

			combine_mode = PintaCore.Workspace.SelectionHandler.DetermineCombineMode (args);			
			path = null;
			is_drawing = true;

			var doc = PintaCore.Workspace.ActiveDocument;
			doc.PreviousSelection.Dispose ();
			doc.PreviousSelection = doc.Selection.Clone();
		}
Exemplo n.º 9
0
        void HandleInvertSelectionActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            // Clear the selection resize handles if necessary.
            doc.ToolLayer.Clear();

            SelectionHistoryItem historyItem = new SelectionHistoryItem("Menu.Edit.InvertSelection.png",
                                                                        Catalog.GetString("Invert Selection"));

            historyItem.TakeSnapshot();

            doc.Selection.Invert(doc.SelectionLayer.Surface, doc.ImageSize);

            doc.History.PushNewItem(historyItem);
            doc.Workspace.Invalidate();
        }
Exemplo n.º 10
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            // Ignore extra button clicks while drawing
            if (is_drawing)
                return;

            Document doc = PintaCore.Workspace.ActiveDocument;

            // Selection is around the pixel selection so add 1 pixel
            double x = Utility.Clamp (point.X, 0, doc.ImageSize.Width);
            double y = Utility.Clamp (point.Y, 0, doc.ImageSize.Height);
            shape_origin = new PointD (x, y);

            is_drawing = true;

            hist = new SelectionHistoryItem (Icon, Name);
            hist.TakeSnapshot ();
        }
Exemplo n.º 11
0
        void HandleInvertSelectionActivated(object sender, EventArgs e)
        {
            PintaCore.Tools.Commit();

            Document doc = PintaCore.Workspace.ActiveDocument;

            // Clear the selection resize handles if necessary.
            doc.Layers.ToolLayer.Clear();

            SelectionHistoryItem historyItem = new SelectionHistoryItem(Resources.Icons.EditSelectionInvert,
                                                                        Translations.GetString("Invert Selection"));

            historyItem.TakeSnapshot();

            doc.Selection.Invert(doc.Layers.SelectionLayer.Surface, doc.ImageSize);

            doc.History.PushNewItem(historyItem);
            doc.Workspace.Invalidate();
        }
Exemplo n.º 12
0
		protected override void OnFillRegionComputed(Point[][] polygonSet)
		{
			Document doc = PintaCore.Workspace.ActiveDocument;

			SelectionHistoryItem undoAction = new SelectionHistoryItem(this.Icon, this.Name);
			undoAction.TakeSnapshot();

            doc.PreviousSelection.Dispose ();
            doc.PreviousSelection = doc.Selection.Clone ();

            doc.Selection.SelectionPolygons.Clear ();
            SelectionModeHandler.PerformSelectionMode (combine_mode, DocumentSelection.ConvertToPolygons (polygonSet));

			doc.History.PushNewItem(undoAction);
			doc.Workspace.Invalidate();
		}
Exemplo n.º 13
0
		protected override void OnMouseUp (Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
		{
			Document doc = PintaCore.Workspace.ActiveDocument;

			ImageSurface surf = doc.SelectionLayer.Surface;

			using (Context g = new Context (surf)) {
				if (path != null) {
					g.AppendPath (path);
					(path as IDisposable).Dispose ();
					path = null;
				}

				g.FillRule = FillRule.EvenOdd;
				g.ClosePath ();
			}

			doc.Selection.SelectionPolygons.Clear ();
			doc.Selection.SelectionPolygons.Add(lasso_polygon.ToList());
		    SelectionModeHandler.PerformSelectionMode (combine_mode, doc.Selection.SelectionPolygons);
			doc.Workspace.Invalidate ();

			if (hist != null)
			{
				doc.History.PushNewItem (hist);
				hist = null;
			}

			lasso_polygon.Clear();
			is_drawing = false;
		}
Exemplo n.º 14
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            is_dragging = false;

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

            hist = null;
        }
Exemplo n.º 15
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;

            origin_offset = point;
            is_dragging = true;

            hist = new SelectionHistoryItem (Icon, Name);
            hist.TakeSnapshot ();
        }
Exemplo n.º 16
0
        protected override void OnMouseUp(DrawingArea canvas, ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            // If the user didn't move the mouse, they want to deselect
            int tolerance = 0;
            if (Math.Abs (reset_origin.X - args.Event.X) <= tolerance && Math.Abs (reset_origin.Y - args.Event.Y) <= tolerance) {
                PintaCore.Actions.Edit.Deselect.Activate ();
                hist.Dispose ();
                hist = null;
                handler_active = false;
                Document doc = PintaCore.Workspace.ActiveDocument;
                doc.ToolLayer.Clear ();
            } else {
                if (hist != null)
                    PintaCore.Workspace.ActiveDocument.History.PushNewItem (hist);

                handler_active = true;
                hist = null;
            }

            is_drawing = false;
        }
Exemplo n.º 17
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            // Ignore extra button clicks while drawing
            if (is_drawing)
                return;

            reset_origin = args.Event.GetPoint ();

            Document doc = PintaCore.Workspace.ActiveDocument;
            if (!handler_active || !HandleResize (point.X, point.Y)) {
                double x = Utility.Clamp (point.X, 0, doc.ImageSize.Width - 1);
                double y = Utility.Clamp (point.Y, 0, doc.ImageSize.Height - 1);

                shape_origin = new PointD (x, y);

                doc.Selection.SelectionPolygons.Clear ();
                is_drawing = true;
            }
            hist = new SelectionHistoryItem (Icon, Name);
            hist.TakeSnapshot ();
        }
Exemplo n.º 18
0
        private void HandlePintaCoreActionsEditDeselectActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit ();

            SelectionHistoryItem hist = new SelectionHistoryItem ("Menu.Edit.Deselect.png", Catalog.GetString ("Deselect"));
            hist.TakeSnapshot ();

            doc.ResetSelectionPath ();

            doc.History.PushNewItem (hist);
            doc.Workspace.Invalidate ();
        }
Exemplo n.º 19
0
        private void HandlePintaCoreActionsEditSelectAllActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit ();

            SelectionHistoryItem hist = new SelectionHistoryItem (Stock.SelectAll, Catalog.GetString ("Select All"));
            hist.TakeSnapshot ();

            doc.ResetSelectionPath ();
            doc.ShowSelection = true;

            doc.History.PushNewItem (hist);
            doc.Workspace.Invalidate ();
        }
Exemplo n.º 20
0
        protected override void OnMouseUp(DrawingArea canvas, ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            double x = point.X;
            double y = point.Y;

            // If the user didn't move the mouse, they want to deselect
            int tolerance = 2;

            if (Math.Abs (shape_origin.X - x) <= tolerance && Math.Abs (shape_origin.Y - y) <= tolerance) {
                PintaCore.Actions.Edit.Deselect.Activate ();
                hist.Dispose ();
                hist = null;
            } else {
                if (hist != null)
                    PintaCore.History.PushNewItem (hist);

                hist = null;
            }

            is_drawing = false;
        }
Exemplo n.º 21
0
        private void HandlePintaCoreActionsEditSelectAllActivated(object sender, EventArgs e)
        {
            PintaCore.Layers.FinishSelection ();

            SelectionHistoryItem hist = new SelectionHistoryItem ("Menu.Edit.SelectAll.png", Mono.Unix.Catalog.GetString ("Select All"));
            hist.TakeSnapshot ();

            PintaCore.Layers.ResetSelectionPath ();
            PintaCore.Layers.ShowSelection = true;

            PintaCore.History.PushNewItem (hist);
            PintaCore.Workspace.Invalidate ();
        }
Exemplo n.º 22
0
        protected override void OnFillRegionComputed(Point[][] polygonSet)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            SelectionHistoryItem undoAction = new SelectionHistoryItem(this.Icon, this.Name);
            undoAction.TakeSnapshot();

            //Convert Pinta's passed in Polygon Set to a Clipper Polygon collection.
            List<List<IntPoint>> newPolygons = DocumentSelection.ConvertToPolygons(polygonSet);

            using (Context g = new Context(PintaCore.Layers.CurrentLayer.Surface))
            {
                //Make sure time isn't wasted if the CombineMode is Replace - Replace is much simpler than the other 4 selection modes.
                if (combineMode == CombineMode.Replace)
                {
                    //Clear any previously stored Polygons.
                    doc.Selection.SelectionPolygons.Clear();

                    //Set the resulting selection path to the new selection path.
                    doc.Selection.SelectionPolygons = newPolygons;
                    doc.Selection.SelectionPath = g.CreatePolygonPath(polygonSet);
                }
                else
                {
                    List<List<IntPoint>> resultingPolygons = new List<List<IntPoint>>();

                    //Specify the Clipper Subject (the previous Polygons) and the Clipper Clip (the new Polygons).
                    //Note: for Union, ignore the Clipper Library instructions - the new polygon(s) should be Clips, not Subjects!
                    doc.Selection.SelectionClipper.AddPolygons(doc.Selection.SelectionPolygons, PolyType.ptSubject);
                    doc.Selection.SelectionClipper.AddPolygons(newPolygons, PolyType.ptClip);

                    switch (combineMode)
                    {
                        case CombineMode.Xor:
                            //Xor means "Combine both Polygon sets, but leave out any areas of intersection between the two."
                            doc.Selection.SelectionClipper.Execute(ClipType.ctXor, resultingPolygons);
                            break;
                        case CombineMode.Exclude:
                            //Exclude == Difference

                            //Exclude/Difference means "Subtract any overlapping areas of the new Polygon set from the old Polygon set."
                            doc.Selection.SelectionClipper.Execute(ClipType.ctDifference, resultingPolygons);
                            break;
                        case CombineMode.Intersect:
                            //Intersect means "Leave only the overlapping areas between the new and old Polygon sets."
                            doc.Selection.SelectionClipper.Execute(ClipType.ctIntersection, resultingPolygons);
                            break;
                        default:
                            //Default should only be *CombineMode.Union*, but just in case...

                            //Union means "Combine both Polygon sets, and keep any overlapping areas as well."
                            doc.Selection.SelectionClipper.Execute(ClipType.ctUnion, resultingPolygons);
                            break;
                    }

                    //After using Clipper, it has to be cleared so there are no conflicts with its next usage.
                    doc.Selection.SelectionClipper.Clear();

                    //Set the resulting selection path to the calculated ("clipped") selection path.
                    doc.Selection.SelectionPolygons = resultingPolygons;
                    doc.Selection.SelectionPath = g.CreatePolygonPath(DocumentSelection.ConvertToPolygonSet(resultingPolygons));
                }
            }

            doc.History.PushNewItem(undoAction);
            doc.Workspace.Invalidate();
        }
Exemplo n.º 23
0
        void HandleInvertSelectionActivated(object sender, EventArgs e)
        {
            PintaCore.Tools.Commit ();

            Document doc = PintaCore.Workspace.ActiveDocument;

            // Clear the selection resize handles if necessary.
            doc.ToolLayer.Clear ();

            SelectionHistoryItem historyItem = new SelectionHistoryItem ("Menu.Edit.InvertSelection.png",
                                                                         Catalog.GetString ("Invert Selection"));
            historyItem.TakeSnapshot ();

            doc.Selection.Invert (doc.SelectionLayer.Surface, doc.ImageSize);

            doc.History.PushNewItem (historyItem);
            doc.Workspace.Invalidate ();
        }
Exemplo n.º 24
0
        protected override void OnFillRegionComputed(Point[][] polygonSet)
        {
            SelectionHistoryItem undoAction = new SelectionHistoryItem (this.Icon, this.Name);
            undoAction.TakeSnapshot ();

            Path path = PintaCore.Layers.SelectionPath;

            using (Context g = new Context (PintaCore.Layers.CurrentLayer.Surface)) {
                PintaCore.Layers.SelectionPath = g.CreatePolygonPath (polygonSet);

                switch (combineMode) {
                    case CombineMode.Union:
                        g.AppendPath (path);
                        break;
                    case CombineMode.Xor:
                        //not supported
                        break;
                    case CombineMode.Exclude:
                        //not supported
                        break;
                    case CombineMode.Replace:
                        //do nothing
                        break;
                }

            }

            (path as IDisposable).Dispose ();

            //Selection.PerformChanging();
            //Selection.SetContinuation(polygonSet, this.combineMode);
            //Selection.CommitContinuation();
            //Selection.PerformChanged();

            PintaCore.History.PushNewItem (undoAction);
            PintaCore.Workspace.Invalidate ();
        }
Exemplo n.º 25
0
        protected override void OnFinishTransform()
        {
            base.OnFinishTransform ();

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

            hist = null;
            original_selection = null;
        }
Exemplo n.º 26
0
        protected override void OnMouseUp(DrawingArea canvas, ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            // If the user didn't move the mouse, they want to deselect
            int tolerance = 0;
            if (Math.Abs (reset_origin.X - args.Event.X) <= tolerance && Math.Abs (reset_origin.Y - args.Event.Y) <= tolerance) {
                PintaCore.Actions.Edit.Deselect.Activate ();
                if (hist != null)
                {
                    hist.Dispose();
                    hist = null;
                }
                doc.ToolLayer.Clear ();
            } else {
                ClearHandles (doc.ToolLayer);
                ReDraw(args.Event.State);
                if (doc.Selection != null)
                {
                    SelectionModeHandler.PerformSelectionMode (combine_mode, doc.Selection.SelectionPolygons);

                    doc.Selection.Origin = shape_origin;
                    doc.Selection.End = shape_end;
                    PintaCore.Workspace.Invalidate();
                }
                if (hist != null)
                {
                    doc.History.PushNewItem(hist);
                    hist = null;
                }
            }

            is_drawing = false;
            active_control = null;

            // Update the mouse cursor.
            UpdateCursor (point);
        }