[gimp] plug-ins: nova, draw cross and use mouse events properly when the preview allocation is larger than



commit 7552d1aa8b69474b161e59096d35e7a114fb1d94
Author: Mikael Magnusson <mikachu src gnome org>
Date:   Sun Apr 10 16:35:51 2011 +0200

    plug-ins: nova, draw cross and use mouse events properly when the preview allocation is larger than the area

 plug-ins/common/nova.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/plug-ins/common/nova.c b/plug-ins/common/nova.c
index 2472af0..e0b286d 100644
--- a/plug-ins/common/nova.c
+++ b/plug-ins/common/nova.c
@@ -536,22 +536,29 @@ nova_center_preview_expose (GtkWidget  *widget,
   if (show_cursor)
     {
       cairo_t *cr;
-      gint     x, y;
+      gint     x, y, offx, offy;
       gint     width, height;
 
+      GimpPreviewArea *area = GIMP_PREVIEW_AREA (center->preview->area);
+      GtkAllocation    allocation;
+
       cr = gdk_cairo_create (gtk_widget_get_window (center->preview->area));
 
       gimp_preview_transform (center->preview,
                               pvals.xcenter, pvals.ycenter,
                               &x, &y);
+      gtk_widget_get_allocation (GTK_WIDGET (area), &allocation);
+
+      offx = (allocation.width  - area->width)  / 2;
+      offy = (allocation.height - area->height) / 2;
 
       gimp_preview_get_size (center->preview, &width, &height);
 
-      cairo_move_to (cr, x + 0.5, 0);
-      cairo_line_to (cr, x + 0.5, height);
+      cairo_move_to (cr, offx + x + 0.5, 0);
+      cairo_line_to (cr, offx + x + 0.5, allocation.height);
 
-      cairo_move_to (cr, 0,     y + 0.5);
-      cairo_line_to (cr, width, y + 0.5);
+      cairo_move_to (cr, 0,    offy + y + 0.5);
+      cairo_line_to (cr, allocation.width, offy + y + 0.5);
 
       cairo_set_line_width (cr, 3.0);
       cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
@@ -579,6 +586,15 @@ nova_center_update (GtkWidget  *widget,
 {
   gint tx, ty;
 
+
+  GimpPreviewArea *area = GIMP_PREVIEW_AREA (center->preview->area);
+  GtkAllocation    allocation;
+
+  gtk_widget_get_allocation (GTK_WIDGET (area), &allocation);
+
+  x -= (allocation.width  - area->width)  / 2;
+  y -= (allocation.height - area->height) / 2;
+
   gimp_preview_untransform (center->preview, x, y, &tx, &ty);
 
   g_signal_handlers_block_by_func (center->coords,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]