Inheritance: CompoundHistoryItem
Exemplo n.º 1
0
        public void ResizeImage(int width, int height)
        {
            double scale;

            if (ImageSize.Width == width && ImageSize.Height == height)
            {
                return;
            }

            PintaCore.Tools.Commit();

            ResizeHistoryItem hist = new ResizeHistoryItem(ImageSize);

            hist.StartSnapshotOfImage();

            scale = Workspace.Scale;

            ImageSize = new Gdk.Size(width, height);

            foreach (var layer in UserLayers)
            {
                layer.Resize(width, height);
            }

            hist.FinishSnapshotOfImage();

            Workspace.History.PushNewItem(hist);

            ResetSelectionPath();

            Workspace.Scale = scale;
        }
Exemplo n.º 2
0
		static void CropImageToRectangle (Document doc, Gdk.Rectangle rect, Path selection)
		{
			if (rect.Width > 0 && rect.Height > 0)
			{
				ResizeHistoryItem hist = new ResizeHistoryItem(doc.ImageSize);

				hist.Icon = "Menu.Image.Crop.png";
				hist.Text = Catalog.GetString("Crop to Selection");
				hist.StartSnapshotOfImage();
				hist.RestoreSelection = doc.Selection.Clone();

				doc.Workspace.Canvas.GdkWindow.FreezeUpdates();

				double original_scale = doc.Workspace.Scale;
				doc.ImageSize = rect.Size;
				doc.Workspace.CanvasSize = rect.Size;
				doc.Workspace.Scale = original_scale;

				PintaCore.Actions.View.UpdateCanvasScale();

				doc.Workspace.Canvas.GdkWindow.ThawUpdates();

				foreach (var layer in doc.UserLayers)
                    layer.Crop (rect, selection);

				hist.FinishSnapshotOfImage();

				doc.History.PushNewItem(hist);
				doc.ResetSelectionPaths();

				doc.Workspace.Invalidate();
			}
		}
Exemplo n.º 3
0
        public void ResizeCanvas(int width, int height, Anchor anchor)
        {
            double scale;

            if (ImageSize.Width == width && ImageSize.Height == height)
            {
                return;
            }

            PintaCore.Tools.Commit();

            ResizeHistoryItem hist = new ResizeHistoryItem(ImageSize);

            hist.Icon = "Menu.Image.CanvasSize.png";
            hist.Text = Catalog.GetString("Resize Canvas");
            hist.TakeSnapshotOfImage();

            scale = Workspace.Scale;

            ImageSize = new Gdk.Size(width, height);

            foreach (var layer in Layers)
            {
                layer.ResizeCanvas(width, height, anchor);
            }

            Workspace.History.PushNewItem(hist);

            ResetSelectionPath();

            Workspace.Scale = scale;
        }
Exemplo n.º 4
0
        static void CropImageToRectangle(Document doc, Gdk.Rectangle rect)
        {
            ResizeHistoryItem hist = new ResizeHistoryItem(doc.ImageSize);

            hist.Icon = "Menu.Image.Crop.png";
            hist.Text = Catalog.GetString("Crop to Selection");
            hist.TakeSnapshotOfImage();
            hist.RestorePath = doc.SelectionPath.Clone();

            PintaCore.Chrome.Canvas.GdkWindow.FreezeUpdates();

            double original_scale = doc.Workspace.Scale;

            doc.ImageSize            = rect.Size;
            doc.Workspace.CanvasSize = rect.Size;
            doc.Workspace.Scale      = original_scale;

            PintaCore.Actions.View.UpdateCanvasScale();

            PintaCore.Chrome.Canvas.GdkWindow.ThawUpdates();

            foreach (var layer in doc.Layers)
            {
                layer.Crop(rect, doc.SelectionPath);
            }

            doc.History.PushNewItem(hist);
            doc.ResetSelectionPath();

            doc.Workspace.Invalidate();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Resizes the canvas.
        /// </summary>
        /// <param name="width">The new width of the canvas.</param>
        /// <param name="height">The new height of the canvas.</param>
        /// <param name="anchor">Direction in which to adjust the canvas</param>
        /// <param name='compoundAction'>
        /// Optionally, the history item for resizing the canvas can be added to
        /// a CompoundHistoryItem if it is part of a larger action (e.g. pasting an image).
        /// </param>
        public void ResizeCanvas(int width, int height, Anchor anchor, CompoundHistoryItem compoundAction)
        {
            double scale;

            if (ImageSize.Width == width && ImageSize.Height == height)
            {
                return;
            }

            PintaCore.Tools.Commit();

            ResizeHistoryItem hist = new ResizeHistoryItem(ImageSize);

            hist.Icon = "Menu.Image.CanvasSize.png";
            hist.Text = Catalog.GetString("Resize Canvas");
            hist.StartSnapshotOfImage();

            scale = Workspace.Scale;

            ImageSize = new Gdk.Size(width, height);

            foreach (var layer in UserLayers)
            {
                layer.ResizeCanvas(width, height, anchor);
            }

            hist.FinishSnapshotOfImage();

            if (compoundAction != null)
            {
                compoundAction.Push(hist);
            }
            else
            {
                Workspace.History.PushNewItem(hist);
            }

            ResetSelectionPaths();

            Workspace.Scale = scale;
        }
Exemplo n.º 6
0
        static void CropImageToRectangle(Document doc, Gdk.Rectangle rect)
        {
            ResizeHistoryItem hist = new ResizeHistoryItem (doc.ImageSize);

            hist.Icon = "Menu.Image.Crop.png";
            hist.Text = Catalog.GetString ("Crop to Selection");
            hist.StartSnapshotOfImage ();
            hist.RestoreSelection = doc.Selection.Clone();

            PintaCore.Chrome.Canvas.GdkWindow.FreezeUpdates ();

            double original_scale = doc.Workspace.Scale;
            doc.ImageSize = rect.Size;
            doc.Workspace.CanvasSize = rect.Size;
            doc.Workspace.Scale = original_scale;

            PintaCore.Actions.View.UpdateCanvasScale ();

            PintaCore.Chrome.Canvas.GdkWindow.ThawUpdates ();

            foreach (var layer in doc.UserLayers)
                layer.Crop (rect, doc.Selection.SelectionPath);

            hist.FinishSnapshotOfImage ();

            doc.History.PushNewItem (hist);
            doc.ResetSelectionPath ();

            doc.Workspace.Invalidate ();
        }
Exemplo n.º 7
0
        public void ResizeImage(int width, int height)
        {
            if (ImageSize.X == width && ImageSize.Y == height)
                return;

            PintaCore.Layers.FinishSelection ();

            ResizeHistoryItem hist = new ResizeHistoryItem (ImageSize.X, ImageSize.Y);
            hist.TakeSnapshotOfImage ();

            ImageSize = new Point (width, height);
            CanvasSize = new Point (width, height);

            foreach (var layer in PintaCore.Layers)
                layer.Resize (width, height);

            PintaCore.History.PushNewItem (hist);

            PintaCore.Layers.ResetSelectionPath ();
            PintaCore.Workspace.Invalidate ();
        }
Exemplo n.º 8
0
        private void HandlePintaCoreActionsImageCropToSelectionActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit ();

            Gdk.Rectangle rect = doc.GetSelectedBounds (true);

            ResizeHistoryItem hist = new ResizeHistoryItem (doc.ImageSize);

            hist.Icon = "Menu.Image.Crop.png";
            hist.Text = Catalog.GetString ("Crop to Selection");
            hist.TakeSnapshotOfImage ();
            hist.RestorePath = doc.SelectionPath.Clone ();

            PintaCore.Chrome.DrawingArea.GdkWindow.FreezeUpdates ();

            double original_scale = doc.Workspace.Scale;
            doc.ImageSize = rect.Size;
            doc.Workspace.CanvasSize = rect.Size;
            doc.Workspace.Scale = original_scale;

            PintaCore.Chrome.DrawingArea.GdkWindow.ThawUpdates ();

            foreach (var layer in doc.Layers)
                layer.Crop (rect, doc.SelectionPath);

            doc.History.PushNewItem (hist);
            doc.ResetSelectionPath ();

            doc.Workspace.Invalidate ();
        }
Exemplo n.º 9
0
        private void HandlePintaCoreActionsImageCropToSelectionActivated(object sender, EventArgs e)
        {
            PintaCore.Layers.FinishSelection ();

            Gdk.Rectangle rect = PintaCore.Layers.SelectionPath.GetBounds ();

            int width = rect.Width;
            int height = rect.Height;

            ResizeHistoryItem hist = new ResizeHistoryItem (PintaCore.Workspace.ImageSize.Width, PintaCore.Workspace.ImageSize.Height);
            hist.Icon = "Menu.Image.Crop.png";
            hist.Text = Catalog.GetString ("Crop to Selection");
            hist.TakeSnapshotOfImage ();
            hist.RestorePath = PintaCore.Layers.SelectionPath.Clone ();

            PintaCore.Workspace.ImageSize = new Gdk.Size (width, height);
            PintaCore.Workspace.CanvasSize = new Gdk.Size (width, height);

            foreach (var layer in PintaCore.Workspace.ActiveDocument.Layers)
                layer.Crop (rect);

            PintaCore.History.PushNewItem (hist);

            PintaCore.Layers.ResetSelectionPath ();
            PintaCore.Workspace.Invalidate ();
        }
Exemplo n.º 10
0
        public void ResizeCanvas(int width, int height, Anchor anchor)
        {
            if (ImageSize.X == width && ImageSize.Y == height)
                return;

            PintaCore.Layers.FinishSelection ();

            ResizeHistoryItem hist = new ResizeHistoryItem ((int)ImageSize.X, (int)ImageSize.Y);
            hist.Icon = "Menu.Image.CanvasSize.png";
            hist.Text = "Resize Canvas";
            hist.TakeSnapshotOfImage ();

            ImageSize = new PointD (width, height);
            CanvasSize = new PointD (width, height);

            foreach (var layer in PintaCore.Layers)
                layer.ResizeCanvas (width, height, anchor);

            PintaCore.History.PushNewItem (hist);

            PintaCore.Layers.ResetSelectionPath ();
            PintaCore.Workspace.Invalidate ();
        }
Exemplo n.º 11
0
        public void ResizeImage(int width, int height)
        {
            double scale;

            if (ImageSize.Width == width && ImageSize.Height == height)
                return;

            FinishSelection ();

            ResizeHistoryItem hist = new ResizeHistoryItem (ImageSize.Width, ImageSize.Height);
            hist.TakeSnapshotOfImage ();

            scale = Workspace.Scale;

            ImageSize = new Gdk.Size (width, height);

            foreach (var layer in Layers)
                layer.Resize (width, height);

            Workspace.History.PushNewItem (hist);

            ResetSelectionPath ();

            Workspace.Scale = scale;
        }
Exemplo n.º 12
0
        public void ResizeCanvas(int width, int height, Anchor anchor)
        {
            double scale;

            if (ImageSize.Width == width && ImageSize.Height == height)
                return;

            FinishSelection ();

            ResizeHistoryItem hist = new ResizeHistoryItem (ImageSize.Width, ImageSize.Height);
            hist.Icon = "Menu.Image.CanvasSize.png";
            hist.Text = Catalog.GetString ("Resize Canvas");
            hist.TakeSnapshotOfImage ();

            ImageSize = new Gdk.Size (width, height);

            scale = Workspace.Scale;

            foreach (var layer in Layers)
                layer.ResizeCanvas (width, height, anchor);

            Workspace.History.PushNewItem (hist);

            ResetSelectionPath ();

            Workspace.Scale = scale;
        }
Exemplo n.º 13
0
		public void ResizeImage (int width, int height)
		{
			double scale;

			if (ImageSize.Width == width && ImageSize.Height == height)
				return;

			PintaCore.Tools.Commit ();

			ResizeHistoryItem hist = new ResizeHistoryItem (ImageSize);
			hist.StartSnapshotOfImage ();

			scale = Workspace.Scale;

			ImageSize = new Gdk.Size (width, height);

			foreach (var layer in UserLayers)
				layer.Resize (width, height);

			hist.FinishSnapshotOfImage ();

			Workspace.History.PushNewItem (hist);

			ResetSelectionPaths ();

			Workspace.Scale = scale;
		}
Exemplo n.º 14
0
		/// <summary>
		/// Resizes the canvas.
		/// </summary>
		/// <param name="width">The new width of the canvas.</param>
		/// <param name="height">The new height of the canvas.</param>
		/// <param name="anchor">Direction in which to adjust the canvas</param>
		/// <param name='compoundAction'>
		/// Optionally, the history item for resizing the canvas can be added to
		/// a CompoundHistoryItem if it is part of a larger action (e.g. pasting an image).
		/// </param>
		public void ResizeCanvas (int width, int height, Anchor anchor, CompoundHistoryItem compoundAction)
		{
			double scale;

			if (ImageSize.Width == width && ImageSize.Height == height)
				return;

			PintaCore.Tools.Commit ();

			ResizeHistoryItem hist = new ResizeHistoryItem (ImageSize);
			hist.Icon = "Menu.Image.CanvasSize.png";
			hist.Text = Catalog.GetString ("Resize Canvas");
			hist.StartSnapshotOfImage ();

			scale = Workspace.Scale;

			ImageSize = new Gdk.Size (width, height);

			foreach (var layer in UserLayers)
				layer.ResizeCanvas (width, height, anchor);

			hist.FinishSnapshotOfImage ();

			if (compoundAction != null) {
				compoundAction.Push (hist);
			} else {
				Workspace.History.PushNewItem (hist);
			}

			ResetSelectionPaths ();

			Workspace.Scale = scale;
		}
Exemplo n.º 15
0
        private void HandlePintaCoreActionsImageCropToSelectionActivated(object sender, EventArgs e)
        {
            PintaCore.Layers.FinishSelection ();

            Cairo.Rectangle rect = PintaCore.Layers.SelectionPath.GetBounds ();

            int width = (int)rect.Width;
            int height = (int)rect.Height;

            ResizeHistoryItem hist = new ResizeHistoryItem ((int)PintaCore.Workspace.ImageSize.X, (int)PintaCore.Workspace.ImageSize.Y);
            hist.Icon = "Menu.Image.Crop.png";
            hist.Text = "Crop to Selection";
            hist.TakeSnapshotOfImage ();
            hist.RestorePath = PintaCore.Layers.SelectionPath.Clone ();

            PintaCore.Workspace.ImageSize = new Cairo.PointD (width, height);
            PintaCore.Workspace.CanvasSize = new Cairo.PointD (width, height);

            foreach (var layer in PintaCore.Layers)
                layer.Crop (rect);

            PintaCore.History.PushNewItem (hist);

            PintaCore.Layers.ResetSelectionPath ();
            PintaCore.Workspace.Invalidate ();
        }