[gtk+/touch-selections: 8/8] GtkBubbleWindow: Use style border color to stroke the bubble shape



commit f7900097468fe5fb17df76977948d786ec6633a9
Author: Carlos Garnacho <carlos lanedo com>
Date:   Tue Jan 15 17:32:42 2013 +0100

    GtkBubbleWindow: Use style border color to stroke the bubble shape
    
    This improves themeability a bit, corners are still square though...

 gtk/gtkbubblewindow.c |   55 +++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 44 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkbubblewindow.c b/gtk/gtkbubblewindow.c
index 4198a95..08c735d 100644
--- a/gtk/gtkbubblewindow.c
+++ b/gtk/gtkbubblewindow.c
@@ -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;
 }
 



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