Esempio n. 1
0
		/// <summary>
		/// Draws the hover point, if any.
		/// </summary>
		/// <param name="g"></param>
		protected void DrawHoverPoint(Context g)
		{
			ShapeEngine activeEngine = ActiveShapeEngine;

			if (activeEngine != null)
			{
				last_control_pt_size = Math.Min(activeEngine.BrushWidth + 1, 5);
			}
			else
			{
				last_control_pt_size = Math.Min(BrushWidth + 1, 5);
			}

			double controlPointOffset = (double)last_control_pt_size / 2d;

			//Verify that the user isn't changing the tension of a control point and that there is a hover point to draw.
			if (!changing_tension && hover_point.X > -1d)
			{
				Rectangle hoverOuterEllipseRect = new Rectangle(
					hover_point.X - controlPointOffset * 3d, hover_point.Y - controlPointOffset * 3d,
					controlPointOffset * 6d, controlPointOffset * 6d);

				g.FillStrokedEllipse(hoverOuterEllipseRect, hover_color, hover_color, 1);

				g.FillStrokedEllipse(new Rectangle(
					hover_point.X - controlPointOffset, hover_point.Y - controlPointOffset,
					last_control_pt_size, last_control_pt_size), hover_color, hover_color, (int)last_control_pt_size);


				hoverOuterEllipseRect = hoverOuterEllipseRect.Inflate(1, 1);

				//Since the hover point can be outside of the active shape's bounds (hovering over a different shape), a special
				//invalidation call needs to be made for the hover point in order to ensure its visibility at all times.
				PintaCore.Workspace.Invalidate(hoverOuterEllipseRect.ToGdkRectangle());

				last_hover = hoverOuterEllipseRect;
				last_hover = last_hover.Value.Clamp();
			}
		}
Esempio n. 2
0
		private void InvalidateAfterDraw(Rectangle dirty)
		{
			Document doc = PintaCore.Workspace.ActiveDocument;

			//Inflate to accomodate for previously drawn control points, if any.
			int inflate = (int)(last_control_pt_size * 8d);
			dirty = dirty.Inflate(inflate, inflate);

			// Increase the size of the dirty rect to account for antialiasing.
			if (owner.UseAntialiasing)
			{
				dirty = dirty.Inflate(1, 1);
			}

			//Combine, clamp, and invalidate the dirty Rectangle.
			dirty = ((Rectangle?)dirty).UnionRectangles(last_dirty).Value;
			dirty = dirty.Clamp();
			doc.Workspace.Invalidate(dirty.ToGdkRectangle());

			last_dirty = dirty;
		}