[f-spot] move the CropHelpers to PhotoImageView
- From: Stephane Delcroix <sdelcroix src gnome org>
- To: svn-commits-list gnome org
- Subject: [f-spot] move the CropHelpers to PhotoImageView
- Date: Thu, 16 Jul 2009 08:25:18 +0000 (UTC)
commit 390ae42b27f3c7d43d5324ab02103a1d158cdc55
Author: Stephane Delcroix <stephane delcroix org>
Date: Thu Jul 16 10:25:10 2009 +0200
move the CropHelpers to PhotoImageView
src/PhotoImageView.cs | 43 +++++++++++++++++++++++++++++++++++++++-
src/Widgets/ImageView.cs | 49 ++++++++-------------------------------------
2 files changed, 51 insertions(+), 41 deletions(-)
---
diff --git a/src/PhotoImageView.cs b/src/PhotoImageView.cs
index da5fbd6..18d2971 100644
--- a/src/PhotoImageView.cs
+++ b/src/PhotoImageView.cs
@@ -407,6 +407,47 @@ namespace FSpot.Widgets {
{
FSpot.ColorManagement.ApplyScreenProfile (pixbuf);
}
-
+
+ bool crop_helpers = true;
+ public bool CropHelpers {
+ get { return crop_helpers; }
+ set {
+ if (crop_helpers == value)
+ return;
+ crop_helpers = value;
+ QueueDraw ();
+ }
+ }
+
+ protected override bool OnExposeEvent (EventExpose evnt)
+ {
+ if (!base.OnExposeEvent (evnt))
+ return false;
+
+ if (!CanSelect || !CropHelpers || Selection == Rectangle.Zero)
+ return true;
+
+ using (Cairo.Context ctx = CairoHelper.Create (GdkWindow)) {
+ ctx.SetSourceRGBA (.7, .7, .7, .8);
+ ctx.SetDash (new double [] {10, 15}, 0);
+ ctx.LineWidth = .8;
+ for (int i=1; i<3; i++) {
+ Point s = ImageCoordsToWindow (new Point (Selection.X + Selection.Width / 3 * i, Selection.Y));
+ Point e = ImageCoordsToWindow (new Point (Selection.X + Selection.Width / 3 * i, Selection.Y + Selection.Height));
+ ctx.MoveTo (s.X, s.Y);
+ ctx.LineTo (e.X, e.Y);
+ ctx.Stroke ();
+ }
+ for (int i=1; i<3; i++) {
+ Point s = ImageCoordsToWindow (new Point (Selection.X, Selection.Y + Selection.Height / 3 * i));
+ Point e = ImageCoordsToWindow (new Point (Selection.X + Selection.Width, Selection.Y + Selection.Height / 3 * i));
+ ctx.MoveTo (s.X, s.Y);
+ ctx.LineTo (e.X, e.Y);
+ ctx.Stroke ();
+ }
+ }
+ return true;
+ }
+
}
}
diff --git a/src/Widgets/ImageView.cs b/src/Widgets/ImageView.cs
index d561d84..463f509 100644
--- a/src/Widgets/ImageView.cs
+++ b/src/Widgets/ImageView.cs
@@ -112,17 +112,6 @@ namespace FSpot.Widgets
}
}
- bool crop_helpers = true;
- public bool CropHelpers {
- get { return crop_helpers; }
- set {
- if (crop_helpers == value)
- return;
- crop_helpers = value;
- QueueDraw ();
- }
- }
-
Gdk.Rectangle selection = Rectangle.Zero;
public Gdk.Rectangle Selection {
get {
@@ -890,38 +879,18 @@ namespace FSpot.Widgets
return false;
Rectangle win_selection = ImageCoordsToWindow (selection);
- using (Region r = new Region ()) {
- r.UnionWithRect (win_selection);
- evnt.Region.Subtract (r);
- }
-
- using (Cairo.Context ctx = CairoHelper.Create (GdkWindow)) {
- ctx.SetSourceRGBA (.5, .5, .5, .7);
- CairoHelper.Region (ctx, evnt.Region);
- ctx.Fill ();
-
- if (!crop_helpers)
- return true;
-
- ctx.SetSourceRGBA (.7, .7, .7, .8);
- ctx.SetDash (new double [] {10, 15}, 0);
- ctx.LineWidth = .8;
- for (int i=1; i<3; i++) {
- Point s = ImageCoordsToWindow (new Point (selection.X + selection.Width / 3 * i, selection.Y));
- Point e = ImageCoordsToWindow (new Point (selection.X + selection.Width / 3 * i, selection.Y + selection.Height));
- ctx.MoveTo (s.X, s.Y);
- ctx.LineTo (e.X, e.Y);
- ctx.Stroke ();
+ using (var evnt_region = evnt.Region.Copy ()) {
+ using (Region r = new Region ()) {
+ r.UnionWithRect (win_selection);
+ evnt_region.Subtract (r);
}
- for (int i=1; i<3; i++) {
- Point s = ImageCoordsToWindow (new Point (selection.X, selection.Y + selection.Height / 3 * i));
- Point e = ImageCoordsToWindow (new Point (selection.X + selection.Width, selection.Y + selection.Height / 3 * i));
- ctx.MoveTo (s.X, s.Y);
- ctx.LineTo (e.X, e.Y);
- ctx.Stroke ();
+
+ using (Cairo.Context ctx = CairoHelper.Create (GdkWindow)) {
+ ctx.SetSourceRGBA (.5, .5, .5, .7);
+ CairoHelper.Region (ctx, evnt_region);
+ ctx.Fill ();
}
}
-
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]