]> Pileus Git - ~andy/gtk/commitdiff
GtkBubbleWindow: Use style border color to stroke the bubble shape
authorCarlos Garnacho <carlos@lanedo.com>
Tue, 15 Jan 2013 16:32:42 +0000 (17:32 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 5 Mar 2013 21:47:59 +0000 (16:47 -0500)
This improves themeability a bit, corners are still square though...

gtk/gtkbubblewindow.c

index 4198a95814b8012d90d5b009bae0c52c30350b1d..08c735d9e66a118c53e21d1c00688a35afbb8859 100644 (file)
@@ -248,22 +248,20 @@ _gtk_bubble_window_apply_tail_path (GtkBubbleWindow *window,
     {
       cairo_move_to (cr, CLAMP (x - priv->win_x - TAIL_GAP_WIDTH / 2,
                                 0, allocation->width - TAIL_GAP_WIDTH), base);
+      cairo_line_to (cr, CLAMP (x - priv->win_x, 0, allocation->width), tip);
       cairo_line_to (cr, CLAMP (x - priv->win_x + TAIL_GAP_WIDTH / 2,
                                 TAIL_GAP_WIDTH, allocation->width), base);
-      cairo_line_to (cr, CLAMP (x - priv->win_x, 0, allocation->width), tip);
     }
   else
     {
       cairo_move_to (cr, base,
                      CLAMP (y - priv->win_y - TAIL_GAP_WIDTH / 2,
                             0, allocation->height - TAIL_GAP_WIDTH));
+      cairo_line_to (cr, tip, CLAMP (y - priv->win_y, 0, allocation->height));
       cairo_line_to (cr, base,
                      CLAMP (y - priv->win_y + TAIL_GAP_WIDTH / 2,
                             TAIL_GAP_WIDTH, allocation->height));
-      cairo_line_to (cr, tip, CLAMP (y - priv->win_y, 0, allocation->height));
     }
-
-  cairo_close_path (cr);
 }
 
 static void
@@ -276,18 +274,38 @@ _gtk_bubble_window_apply_border_path (GtkBubbleWindow *window,
   priv = window->_priv;
   gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
 
+  _gtk_bubble_window_apply_tail_path (window, cr, &allocation);
+
   if (priv->final_position == GTK_POS_TOP)
-    cairo_rectangle (cr, 0, 0, allocation.width, allocation.height - TAIL_HEIGHT);
+    {
+      cairo_line_to (cr, allocation.width, allocation.height - TAIL_HEIGHT);
+      cairo_line_to (cr, allocation.width, 0);
+      cairo_line_to (cr, 0, 0);
+      cairo_line_to (cr, 0, allocation.height - TAIL_HEIGHT);
+    }
   else if (priv->final_position == GTK_POS_BOTTOM)
-    cairo_rectangle (cr, 0, TAIL_HEIGHT , allocation.width,
-                     allocation.height - TAIL_HEIGHT);
+    {
+      cairo_line_to (cr, allocation.width, TAIL_HEIGHT);
+      cairo_line_to (cr, allocation.width, allocation.height);
+      cairo_line_to (cr, 0, allocation.height);
+      cairo_line_to (cr, 0, TAIL_HEIGHT);
+    }
   else if (priv->final_position == GTK_POS_LEFT)
-    cairo_rectangle (cr, 0, 0, allocation.width - TAIL_HEIGHT, allocation.height);
+    {
+      cairo_line_to (cr, allocation.width - TAIL_HEIGHT, allocation.height);
+      cairo_line_to (cr, 0, allocation.height);
+      cairo_line_to (cr, 0, 0);
+      cairo_line_to (cr, allocation.width - TAIL_HEIGHT, 0);
+    }
   else if (priv->final_position == GTK_POS_RIGHT)
-    cairo_rectangle (cr, TAIL_HEIGHT, 0,
-                     allocation.width - TAIL_HEIGHT, allocation.height);
+    {
+      cairo_line_to (cr, TAIL_HEIGHT, 0);
+      cairo_line_to (cr, allocation.width, 0);
+      cairo_line_to (cr, allocation.width, allocation.height);
+      cairo_line_to (cr, TAIL_HEIGHT, allocation.height);
+    }
 
-  _gtk_bubble_window_apply_tail_path (window, cr, &allocation);
+  cairo_close_path (cr);
 }
 
 static void
@@ -385,11 +403,15 @@ gtk_bubble_window_draw (GtkWidget *widget,
   GtkStyleContext *context;
   GtkAllocation allocation;
   GtkWidget *child;
+  GdkRGBA *border;
 
   cairo_save (cr);
   context = gtk_widget_get_style_context (widget);
   gtk_widget_get_allocation (widget, &allocation);
 
+  gtk_render_background (context, cr, 0, 0,
+                         allocation.width, allocation.height);
+
   if (gtk_widget_is_composited (widget))
     {
       cairo_save (cr);
@@ -404,6 +426,15 @@ gtk_bubble_window_draw (GtkWidget *widget,
 
   gtk_render_background (context, cr, 0, 0,
                          allocation.width, allocation.height);
+
+  gtk_style_context_get (context, gtk_widget_get_state_flags (widget),
+                         GTK_STYLE_PROPERTY_BORDER_COLOR, &border,
+                         NULL);
+
+  _gtk_bubble_window_apply_border_path (GTK_BUBBLE_WINDOW (widget), cr);
+  gdk_cairo_set_source_rgba (cr, border);
+  cairo_stroke (cr);
+
   child = gtk_bin_get_child (GTK_BIN (widget));
 
   if (child)
@@ -411,6 +442,8 @@ gtk_bubble_window_draw (GtkWidget *widget,
 
   cairo_restore (cr);
 
+  gdk_rgba_free (border);
+
   return TRUE;
 }