Exemple #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;
        }
Exemple #2
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();
        }
        protected override void OnStartTransform()
        {
            base.OnStartTransform();

            Document doc = PintaCore.Workspace.ActiveDocument;

            original_selection = doc.Selection.Clone();

            hist = new SelectionHistoryItem(Icon, Name);
            hist.TakeSnapshot();
        }
Exemple #4
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();
        }
Exemple #5
0
        protected override void OnFillRegionComputed(Document document, Point[][] polygonSet)
        {
            var undoAction = new SelectionHistoryItem(Icon, Name);

            undoAction.TakeSnapshot();

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

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

            document.History.PushNewItem(undoAction);
            document.Workspace.Invalidate();
        }
Exemple #6
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, polygonSet);

            doc.History.PushNewItem(undoAction);
            doc.Workspace.Invalidate();
        }
        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();
        }
Exemple #8
0
        protected override void OnFillRegionComputed(Point[][] polygonSet)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

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

            undoAction.TakeSnapshot();

            Path path = doc.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();

            doc.History.PushNewItem(undoAction);
            doc.Workspace.Invalidate();
        }
Exemple #9
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();
        }