Наследование: ObservableObject
Пример #1
0
		public void SetProperties (Layer layer)
		{
			layer.Name = Name;
			layer.Opacity = Opacity;
			layer.Hidden = Hidden;
			layer.BlendMode = BlendMode;
		}
Пример #2
0
}
Пример #3
0
        public override void Redo()
        {
            // Store the layer for "undo"
            layer = PintaCore.Layers[layer_index];

            PintaCore.Layers.DeleteLayer (layer_index, false);
        }
Пример #4
0
        protected override Rectangle DrawShape(Rectangle r, Layer l)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            doc.Selection.CreateEllipseSelection(l.Surface, r);

            return r;
        }
Пример #5
0
        protected override Rectangle DrawShape(Rectangle r, Layer l)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            doc.Selection.CreateRectangleSelection(l.Surface, r);

            // Add some padding for invalidation
            return new Rectangle (r.X, r.Y, r.Width + 2, r.Height + 2);
        }
Пример #6
0
        public override void Undo()
        {
            PintaCore.Layers.Insert (layer, layer_index);

            // Make new layer the current layer
            PintaCore.Layers.SetCurrentLayer (layer);

            layer = null;
        }
Пример #7
0
        protected override Rectangle DrawShape(Rectangle r, Layer l)
        {
            Path path = PintaCore.Layers.SelectionPath;

            using (Context g = new Context (l.Surface))
                PintaCore.Layers.SelectionPath = g.CreateEllipsePath (r);

            (path as IDisposable).Dispose ();

            return r;
        }
Пример #8
0
        protected override Rectangle DrawShape(Rectangle r, Layer l)
        {
            Path path = PintaCore.Layers.SelectionPath;

            using (Context g = new Context (l.Surface))
                PintaCore.Layers.SelectionPath = g.CreateRectanglePath (r);

            (path as IDisposable).Dispose ();

            // Add some padding for invalidation
            return new Rectangle (r.X, r.Y, r.Width + 2, r.Height + 2);
        }
Пример #9
0
        protected override Rectangle DrawShape(Rectangle r, Layer l)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            Path path = doc.SelectionPath;

            using (Context g = new Context (l.Surface))
                doc.SelectionPath = g.CreateEllipsePath (r);

            (path as IDisposable).Dispose ();

            return r;
        }
Пример #10
0
        protected override Rectangle DrawShape(Rectangle rect, Layer l)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            Rectangle dirty;

            using (Context g = new Context (l.Surface)) {
                g.AppendPath (doc.Selection.SelectionPath);
                g.FillRule = FillRule.EvenOdd;
                g.Clip ();

                g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;

                dirty = g.DrawLine (shape_origin, current_point , outline_color, BrushWidth);
            }

            return dirty;
        }
Пример #11
0
        public Document(Gdk.Size size)
        {
            Guid = Guid.NewGuid ();

            Workspace = new DocumentWorkspace (this);
            IsDirty = false;
            HasFile = false;
            ImageSize = size;

            Layers = new List<Layer> ();

            tool_layer = CreateLayer ("Tool Layer");
            tool_layer.Hidden = true;

            selection_layer = CreateLayer ("Selection Layer");
            selection_layer.Hidden = true;

            ResetSelectionPath ();
        }
Пример #12
0
        protected override Rectangle DrawShape(Rectangle rect, Layer l)
        {
            Rectangle dirty;

            using (Context g = new Context (l.Surface)) {
                g.AppendPath (PintaCore.Layers.SelectionPath);
                g.FillRule = FillRule.EvenOdd;
                g.Clip ();

                g.Antialias = Antialias.Subpixel;

                if (FillShape && StrokeShape)
                    dirty = g.FillStrokedRectangle (rect, fill_color, outline_color, BrushWidth);
                else if (FillShape)
                    dirty = g.FillRectangle (rect, outline_color);
                else
                    dirty = g.DrawRectangle (rect, outline_color, BrushWidth);
            }

            return dirty;
        }
Пример #13
0
 /// <summary>
 /// Override this to implement features on shift, like line snapping.
 /// </summary>
 protected virtual Rectangle DrawShape(Rectangle r, Layer l, bool shiftkey_pressed)
 {
     return DrawShape (r, l);
 }
Пример #14
0
        /// <summary>
        /// Forces the line to snap to angles.
        /// </summary>
        protected override Rectangle DrawShape(Rectangle r, Layer l, bool shiftkey_pressed)
        {
            if (shiftkey_pressed) {
                PointD dir = new PointD(current_point.X - shape_origin.X, current_point.Y - shape_origin.Y);
                double theta = Math.Atan2(dir.Y, dir.X);
                double len = Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y);

                theta = Math.Round(12 * theta / Math.PI) * Math.PI / 12;
                current_point = new PointD((shape_origin.X + len * Math.Cos(theta)), (shape_origin.Y + len * Math.Sin(theta)));
            }
            return DrawShape (r, l);
        }
Пример #15
0
		public void CreateSelectionLayer ()
		{
			Layer old = selection_layer;

			selection_layer = CreateLayer ();

			if (old != null)
				(old.Surface as IDisposable).Dispose ();
		}
Пример #16
0
 protected virtual Rectangle DrawShape(Rectangle r, Layer l)
 {
     return r;
 }
Пример #17
0
 public void Render(Layer layer)
 {
     double scale_factor = (1.0 / PintaCore.Workspace.ActiveWorkspace.Scale);
     using (Context g = new Context (layer.Surface))
         g.FillStrokedRectangle (new Cairo.Rectangle (Position.X - scale_factor * 2, Position.Y - scale_factor * 2, scale_factor * 4, scale_factor * 4),
                                 new Cairo.Color (0, 0, 1, 0.5), new Cairo.Color (0, 0, 1, 0.7), 1);
 }
Пример #18
0
 public void CreateSelectionLayer()
 {
     selection_layer = CreateLayer ();
     selection_layer_index = current_layer + 1;
 }
Пример #19
0
        public Layer CreateLayer(string name, int width, int height)
        {
            Cairo.ImageSurface surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, width, height);
            Layer layer = new Layer (surface) { Name = name };

            return layer;
        }
Пример #20
0
        private Layer CreateLivePreviewLayer(Layer original)
        {
            var preview_layer = new Layer (PintaCore.LivePreview.LivePreviewSurface);

            preview_layer.BlendMode = original.BlendMode;
            preview_layer.Offset = original.Offset;
            preview_layer.Opacity = original.Opacity;
            preview_layer.Hidden = original.Hidden;

            return preview_layer;
        }
Пример #21
0
 /// <summary>
 /// Erase previously-drawn handles.
 /// </summary>
 private void ClearHandles(Layer layer)
 {
     using (var g = new Context (layer.Surface))
     {
         foreach (var tool_control in controls)
             tool_control.Clear (g);
     }
 }
Пример #22
0
 public void DrawHandler(Layer layer)
 {
     using (var g = new Context(layer.Surface))
     {
         foreach (var tool_control in controls)
             tool_control.Render (g);
     }
 }
Пример #23
0
		public Document (Gdk.Size size)
		{
		    Selection = new DocumentSelection ();

			Guid = Guid.NewGuid ();
			
			Workspace = new DocumentWorkspace (this);
			IsDirty = false;
			HasFile = false;
			HasBeenSavedInSession = false;
			ImageSize = size;

			UserLayers = new List<UserLayer>();

			tool_layer = CreateLayer ("Tool Layer");
			tool_layer.Hidden = true;

			selection_layer = CreateLayer ("Selection Layer");
			selection_layer.Hidden = true;

			ResetSelectionPaths ();
		}
Пример #24
0
		public void CreateSelectionLayer (int width, int height)
		{
			Layer old = selection_layer;

			selection_layer = CreateLayer (width, height);

			if (old != null)
				(old.Surface as IDisposable).Dispose ();
		}
Пример #25
0
        private Layer CreateOffsetLayer(Layer original)
        {
            var offset = OffsetLayer;
            offset.Surface.Clear ();

            using (var g = new Cairo.Context (offset.Surface)) {
                original.Draw(g, original.Surface, 1);
            }

            offset.BlendMode = original.BlendMode;
            offset.Transform.InitMatrix(original.Transform);
            offset.Opacity = original.Opacity;

            return offset;
        }
Пример #26
0
        private Layer CreateLivePreviewLayer(Layer original)
        {
            var preview_layer = new Layer (PintaCore.LivePreview.LivePreviewSurface);

            preview_layer.BlendMode = original.BlendMode;
            preview_layer.Transform.InitMatrix(original.Transform);
            preview_layer.Opacity = original.Opacity;
            preview_layer.Hidden = original.Hidden;

            return preview_layer;
        }
Пример #27
0
 public int IndexOf(Layer layer)
 {
     return Layers.IndexOf (layer);
 }
Пример #28
0
        // Adds a new layer above the current one
        public void Insert(Layer layer, int index)
        {
            Layers.Insert (index, layer);

            if (Layers.Count == 1)
                current_layer = 0;

            layer.PropertyChanged += RaiseLayerPropertyChangedEvent;

            PintaCore.Layers.OnLayerAdded ();
        }
Пример #29
0
        public void SetCurrentLayer(Layer layer)
        {
            current_layer = Layers.IndexOf (layer);

            PintaCore.Layers.OnSelectedLayerChanged ();
        }
Пример #30
0
		public void Start (BaseEffect effect)
		{			
			if (live_preview_enabled)
				throw new InvalidOperationException ("LivePreviewManager.Start() called while live preview is already enabled.");
			
			// Create live preview surface.
			// Start rendering.
			// Listen for changes to effectConfiguration object, and restart render if needed.

			live_preview_enabled = true;
			apply_live_preview_flag = false;
			cancel_live_preview_flag = false;
			
			layer = PintaCore.Layers.CurrentLayer;
			this.effect = effect;

			//TODO Use the current tool layer instead.
			live_preview_surface = new Cairo.ImageSurface (Cairo.Format.Argb32,
			                                  PintaCore.Workspace.ImageSize.Width,
			                                  PintaCore.Workspace.ImageSize.Height);

			// Handle selection path.
			PintaCore.Tools.Commit ();
			selection_path = (PintaCore.Layers.ShowSelection) ? PintaCore.Workspace.ActiveDocument.Selection.SelectionPath : null;
			render_bounds = (selection_path != null) ? selection_path.GetBounds () : live_preview_surface.GetBounds ();
			render_bounds = PintaCore.Workspace.ClampToImageSize (render_bounds);	

			history_item = new SimpleHistoryItem (effect.Icon, effect.Name);
			history_item.TakeSnapshotOfLayer (PintaCore.Layers.CurrentLayerIndex);	
			
			// Paint the pre-effect layer surface into into the working surface.
			using (var ctx = new Cairo.Context (live_preview_surface)) {
				layer.Draw(ctx, layer.Surface, 1);
			}
			
			if (effect.EffectData != null)
				effect.EffectData.PropertyChanged += EffectData_PropertyChanged;
			
			if (Started != null) {
				Started (this, new LivePreviewStartedEventArgs());
			}
			
			var settings = new AsyncEffectRenderer.Settings () {
				ThreadCount = PintaCore.System.RenderThreads,
				TileWidth = render_bounds.Width,
				TileHeight = 1,
				ThreadPriority = ThreadPriority.BelowNormal
			};
			
			Debug.WriteLine (DateTime.Now.ToString("HH:mm:ss:ffff") + "Start Live preview.");
			
			renderer = new Renderer (this, settings);
			renderer.Start (effect, layer.Surface, live_preview_surface, render_bounds);
			
			if (effect.IsConfigurable) {		
				if (!effect.LaunchConfiguration ()) {
					PintaCore.Chrome.MainWindowBusy = true;
					Cancel ();
				} else {
					PintaCore.Chrome.MainWindowBusy = true;
					Apply ();
				}
			} else {
				PintaCore.Chrome.MainWindowBusy = true;
				Apply ();
			}
		}
Пример #31
0
        public void Start(BaseEffect effect)
        {
            if (live_preview_enabled)
            {
                throw new InvalidOperationException("LivePreviewManager.Start() called while live preview is already enabled.");
            }

            // Create live preview surface.
            // Start rendering.
            // Listen for changes to effectConfiguration object, and restart render if needed.

            live_preview_enabled     = true;
            apply_live_preview_flag  = false;
            cancel_live_preview_flag = false;

            layer       = PintaCore.Layers.CurrentLayer;
            this.effect = effect;

            // Handle selection path.
            PintaCore.Tools.Commit();
            selection_path = (PintaCore.Layers.ShowSelection) ? PintaCore.Workspace.ActiveDocument.Selection.SelectionPath : null;
            render_bounds  = selection_path.GetBounds();
            render_bounds  = PintaCore.Workspace.ClampToImageSize(render_bounds);

            //TODO Use the current tool layer instead.
            live_preview_surface = new Cairo.ImageSurface(Cairo.Format.Argb32,
                                                          PintaCore.Workspace.ImageSize.Width,
                                                          PintaCore.Workspace.ImageSize.Height);

            // Paint the pre-effect layer surface into into the working surface.
            using (var ctx = new Cairo.Context(live_preview_surface)) {
                ctx.SetSourceSurface(layer.Surface, (int)layer.Offset.X, (int)layer.Offset.Y);
                ctx.Paint();
            }

            if (effect.EffectData != null)
            {
                effect.EffectData.PropertyChanged += EffectData_PropertyChanged;
            }

            if (Started != null)
            {
                Started(this, new LivePreviewStartedEventArgs());
            }

            var settings = new AsyncEffectRenderer.Settings()
            {
                ThreadCount    = PintaCore.System.RenderThreads,
                TileWidth      = render_bounds.Width,
                TileHeight     = 1,
                ThreadPriority = ThreadPriority.BelowNormal
            };

            Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss:ffff") + "Start Live preview.");

            renderer = new Renderer(this, settings);
            renderer.Start(effect, layer.Surface, live_preview_surface, render_bounds);

            if (effect.IsConfigurable)
            {
                if (!effect.LaunchConfiguration())
                {
                    PintaCore.Chrome.MainWindowBusy = true;
                    Cancel();
                }
                else
                {
                    PintaCore.Chrome.MainWindowBusy = true;
                    Apply();
                }
            }
            else
            {
                PintaCore.Chrome.MainWindowBusy = true;
                Apply();
            }
        }