[gtk+/rendering-cleanup-next: 62/154] notebook: Draw tabs and arrows with Cairo



commit 6a4454194af51878ea8a13e13af5cb1e29bcaf3f
Author: Benjamin Otte <otte redhat com>
Date:   Tue Sep 7 01:33:25 2010 +0200

    notebook: Draw tabs and arrows with Cairo
    
    Includes a fix to only draw the current page once during a drag
    operation.

 gtk/gtknotebook.c |   56 +++++++++++++++++++++++++++-------------------------
 1 files changed, 29 insertions(+), 27 deletions(-)
---
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index ce74cad..d9dd9df 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -406,8 +406,9 @@ static void gtk_notebook_paint               (GtkWidget        *widget,
 					      GdkRectangle     *area);
 static void gtk_notebook_draw_tab            (GtkNotebook      *notebook,
 					      GtkNotebookPage  *page,
-					      GdkRectangle     *area);
+					      cairo_t          *cr);
 static void gtk_notebook_draw_arrow          (GtkNotebook      *notebook,
+                                              cairo_t          *cr,
 					      GtkNotebookArrow  arrow);
 
 /*** GtkNotebook Size Allocate Functions ***/
@@ -2294,7 +2295,6 @@ gtk_notebook_expose (GtkWidget      *widget,
 
   if (event->window == priv->drag_window)
     {
-      GdkRectangle area = { 0, };
       cairo_t *cr;
 
       /* FIXME: This is a workaround to make tabs reordering work better
@@ -2307,13 +2307,11 @@ gtk_notebook_expose (GtkWidget      *widget,
       cr = gdk_cairo_create (priv->drag_window);
       gdk_cairo_set_source_color (cr, &gtk_widget_get_style (widget)->bg [GTK_STATE_NORMAL]);
       cairo_paint (cr);
-      cairo_destroy (cr);
 
-      gdk_drawable_get_size (priv->drag_window,
-			     &area.width, &area.height);
       gtk_notebook_draw_tab (notebook,
 			     priv->cur_page,
-			     &area);
+			     cr);
+      cairo_destroy (cr);
       gtk_container_propagate_expose (GTK_CONTAINER (notebook),
 				      priv->cur_page->tab_label, event);
     }
@@ -4803,6 +4801,7 @@ gtk_notebook_paint (GtkWidget    *widget,
   gint gap_x = 0, gap_width = 0, step = STEP_PREV;
   gboolean is_rtl;
   gint tab_pos;
+  cairo_t *cr;
    
   notebook = GTK_NOTEBOOK (widget);
   priv = notebook->priv;
@@ -4893,6 +4892,10 @@ gtk_notebook_paint (GtkWidget    *widget,
 		     x, y, width, height,
 		     tab_pos, gap_x, gap_width);
 
+  cr = gdk_cairo_create (gtk_widget_get_window (widget));
+  gdk_cairo_rectangle (cr, area);
+  cairo_clip (cr);
+
   showarrow = FALSE;
   children = gtk_notebook_search_page (notebook, NULL, step, TRUE);
   while (children)
@@ -4905,31 +4908,34 @@ gtk_notebook_paint (GtkWidget    *widget,
       if (!gtk_widget_get_mapped (page->tab_label))
 	showarrow = TRUE;
       else if (page != priv->cur_page)
-	gtk_notebook_draw_tab (notebook, page, area);
+	gtk_notebook_draw_tab (notebook, page, cr);
     }
 
   if (showarrow && priv->scrollable)
     {
       if (priv->has_before_previous)
-	gtk_notebook_draw_arrow (notebook, ARROW_LEFT_BEFORE);
+	gtk_notebook_draw_arrow (notebook, cr, ARROW_LEFT_BEFORE);
       if (priv->has_before_next)
-	gtk_notebook_draw_arrow (notebook, ARROW_RIGHT_BEFORE);
+	gtk_notebook_draw_arrow (notebook, cr, ARROW_RIGHT_BEFORE);
       if (priv->has_after_previous)
-	gtk_notebook_draw_arrow (notebook, ARROW_LEFT_AFTER);
+	gtk_notebook_draw_arrow (notebook, cr, ARROW_LEFT_AFTER);
       if (priv->has_after_next)
-	gtk_notebook_draw_arrow (notebook, ARROW_RIGHT_AFTER);
+	gtk_notebook_draw_arrow (notebook, cr, ARROW_RIGHT_AFTER);
     }
-  gtk_notebook_draw_tab (notebook, priv->cur_page, area);
+
+  if (priv->operation != DRAG_OPERATION_REORDER)
+    gtk_notebook_draw_tab (notebook, priv->cur_page, cr);
+
+  cairo_destroy (cr);
 }
 
 static void
 gtk_notebook_draw_tab (GtkNotebook     *notebook,
 		       GtkNotebookPage *page,
-		       GdkRectangle    *area)
+		       cairo_t         *cr)
 {
   GtkNotebookPrivate *priv;
   GtkStateType state_type;
-  GdkWindow *window;
   GtkWidget *widget;
   
   if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) ||
@@ -4940,19 +4946,14 @@ gtk_notebook_draw_tab (GtkNotebook     *notebook,
   widget = GTK_WIDGET (notebook);
   priv = notebook->priv;
 
-  if (priv->operation == DRAG_OPERATION_REORDER && page == priv->cur_page)
-    window = priv->drag_window;
-  else
-    window = gtk_widget_get_window (widget);
-
   if (priv->cur_page == page)
     state_type = GTK_STATE_NORMAL;
   else 
     state_type = GTK_STATE_ACTIVE;
 
-  gtk_paint_extension (gtk_widget_get_style (widget), window,
+  gtk_cairo_paint_extension (gtk_widget_get_style (widget), cr,
                        state_type, GTK_SHADOW_OUT,
-                       area, widget, "tab",
+                       widget, "tab",
                        page->allocation.x,
                        page->allocation.y,
                        page->allocation.width,
@@ -4968,8 +4969,8 @@ gtk_notebook_draw_tab (GtkNotebook     *notebook,
       gtk_widget_get_allocation (page->tab_label, &allocation);
       gtk_widget_style_get (widget, "focus-line-width", &focus_width, NULL);
 
-      gtk_paint_focus (gtk_widget_get_style (widget), window, 
-                       gtk_widget_get_state (widget), area, widget, "tab",
+      gtk_cairo_paint_focus (gtk_widget_get_style (widget), cr,
+                       gtk_widget_get_state (widget), widget, "tab",
                        allocation.x - focus_width,
                        allocation.y - focus_width,
                        allocation.width + 2 * focus_width,
@@ -4979,6 +4980,7 @@ gtk_notebook_draw_tab (GtkNotebook     *notebook,
 
 static void
 gtk_notebook_draw_arrow (GtkNotebook      *notebook,
+                         cairo_t          *cr,
 			 GtkNotebookArrow  nbarrow)
 {
   GtkNotebookPrivate *priv = notebook->priv;
@@ -5042,10 +5044,10 @@ gtk_notebook_draw_arrow (GtkNotebook      *notebook,
           arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT);
           arrow_size = scroll_arrow_hlength;
         }
-
-      gtk_paint_arrow (gtk_widget_get_style (widget),
-                       gtk_widget_get_window (widget), state_type,
-		       shadow_type, NULL, widget, "notebook",
+     
+      gtk_cairo_paint_arrow (gtk_widget_get_style (widget),
+                       cr, state_type, 
+		       shadow_type, widget, "notebook",
 		       arrow, TRUE, arrow_rect.x, arrow_rect.y, 
 		       arrow_size, arrow_size);
     }



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