[gimp] libgimpwidgets: transform the cr to widget coords



commit 3584b662a613e15158ed10c8223c7e13763834eb
Author: Michael Natterer <mitch gimp org>
Date:   Fri Oct 15 10:40:37 2010 +0200

    libgimpwidgets: transform the cr to widget coords
    
    and get rid if all the allocation.x and .y

 libgimpwidgets/gimpchainbutton.c |   25 +++++++++----------------
 1 files changed, 9 insertions(+), 16 deletions(-)
---
diff --git a/libgimpwidgets/gimpchainbutton.c b/libgimpwidgets/gimpchainbutton.c
index 0fc2b31..4ab76f0 100644
--- a/libgimpwidgets/gimpchainbutton.c
+++ b/libgimpwidgets/gimpchainbutton.c
@@ -383,15 +383,16 @@ gimp_chain_line_expose_event (GtkWidget      *widget,
   GimpChainPosition  position;
   cairo_t           *cr;
 
+  gtk_widget_get_allocation (widget, &allocation);
+
   cr = gdk_cairo_create (gtk_widget_get_window (widget));
   gdk_cairo_region (cr, event->region);
+  cairo_translate (cr, allocation.x, allocation.y);
   cairo_clip (cr);
 
-  gtk_widget_get_allocation (widget, &allocation);
-
 #define SHORT_LINE 4
-  points[0].x = allocation.x + allocation.width  / 2;
-  points[0].y = allocation.y + allocation.height / 2;
+  points[0].x = allocation.width  / 2;
+  points[0].y = allocation.height / 2;
 
   position = line->position;
 
@@ -420,9 +421,7 @@ gimp_chain_line_expose_event (GtkWidget      *widget,
       points[1].x = points[0].x - SHORT_LINE;
       points[1].y = points[0].y;
       points[2].x = points[1].x;
-      points[2].y = (line->which == 1 ?
-                     allocation.y + allocation.height - 1 :
-                     allocation.y);
+      points[2].y = (line->which == 1 ? allocation.height - 1 : 0);
       break;
 
     case GIMP_CHAIN_RIGHT:
@@ -430,18 +429,14 @@ gimp_chain_line_expose_event (GtkWidget      *widget,
       points[1].x = points[0].x + SHORT_LINE;
       points[1].y = points[0].y;
       points[2].x = points[1].x;
-      points[2].y = (line->which == 1 ?
-                     allocation.y + allocation.height - 1 :
-                     allocation.y);
+      points[2].y = (line->which == 1 ? allocation.height - 1 : 0);
       break;
 
     case GIMP_CHAIN_TOP:
       points[0].y += SHORT_LINE;
       points[1].x = points[0].x;
       points[1].y = points[0].y - SHORT_LINE;
-      points[2].x = (line->which == 1 ?
-                     allocation.x + allocation.width - 1 :
-                     allocation.x);
+      points[2].x = (line->which == 1 ? allocation.width - 1 : 0);
       points[2].y = points[1].y;
       break;
 
@@ -449,9 +444,7 @@ gimp_chain_line_expose_event (GtkWidget      *widget,
       points[0].y -= SHORT_LINE;
       points[1].x = points[0].x;
       points[1].y = points[0].y + SHORT_LINE;
-      points[2].x = (line->which == 1 ?
-                     allocation.x + allocation.width - 1 :
-                     allocation.x);
+      points[2].x = (line->which == 1 ? allocation.width - 1 : 0);
       points[2].y = points[1].y;
       break;
 



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