forked from AuroraMiddleware/gtk
GtkBubbleWindow: Use style border color to stroke the bubble shape
This improves themeability a bit, corners are still square though...
This commit is contained in:
parent
320613c439
commit
a960230a20
@ -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,
|
cairo_move_to (cr, CLAMP (x - priv->win_x - TAIL_GAP_WIDTH / 2,
|
||||||
0, allocation->width - TAIL_GAP_WIDTH), base);
|
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,
|
cairo_line_to (cr, CLAMP (x - priv->win_x + TAIL_GAP_WIDTH / 2,
|
||||||
TAIL_GAP_WIDTH, allocation->width), base);
|
TAIL_GAP_WIDTH, allocation->width), base);
|
||||||
cairo_line_to (cr, CLAMP (x - priv->win_x, 0, allocation->width), tip);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cairo_move_to (cr, base,
|
cairo_move_to (cr, base,
|
||||||
CLAMP (y - priv->win_y - TAIL_GAP_WIDTH / 2,
|
CLAMP (y - priv->win_y - TAIL_GAP_WIDTH / 2,
|
||||||
0, allocation->height - TAIL_GAP_WIDTH));
|
0, allocation->height - TAIL_GAP_WIDTH));
|
||||||
|
cairo_line_to (cr, tip, CLAMP (y - priv->win_y, 0, allocation->height));
|
||||||
cairo_line_to (cr, base,
|
cairo_line_to (cr, base,
|
||||||
CLAMP (y - priv->win_y + TAIL_GAP_WIDTH / 2,
|
CLAMP (y - priv->win_y + TAIL_GAP_WIDTH / 2,
|
||||||
TAIL_GAP_WIDTH, allocation->height));
|
TAIL_GAP_WIDTH, allocation->height));
|
||||||
cairo_line_to (cr, tip, CLAMP (y - priv->win_y, 0, allocation->height));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_close_path (cr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -276,18 +274,38 @@ _gtk_bubble_window_apply_border_path (GtkBubbleWindow *window,
|
|||||||
priv = window->_priv;
|
priv = window->_priv;
|
||||||
gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
|
gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
|
||||||
|
|
||||||
if (priv->final_position == GTK_POS_TOP)
|
|
||||||
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height - TAIL_HEIGHT);
|
|
||||||
else if (priv->final_position == GTK_POS_BOTTOM)
|
|
||||||
cairo_rectangle (cr, 0, TAIL_HEIGHT , allocation.width,
|
|
||||||
allocation.height - TAIL_HEIGHT);
|
|
||||||
else if (priv->final_position == GTK_POS_LEFT)
|
|
||||||
cairo_rectangle (cr, 0, 0, allocation.width - TAIL_HEIGHT, allocation.height);
|
|
||||||
else if (priv->final_position == GTK_POS_RIGHT)
|
|
||||||
cairo_rectangle (cr, TAIL_HEIGHT, 0,
|
|
||||||
allocation.width - TAIL_HEIGHT, allocation.height);
|
|
||||||
|
|
||||||
_gtk_bubble_window_apply_tail_path (window, cr, &allocation);
|
_gtk_bubble_window_apply_tail_path (window, cr, &allocation);
|
||||||
|
|
||||||
|
if (priv->final_position == GTK_POS_TOP)
|
||||||
|
{
|
||||||
|
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_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_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_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);
|
||||||
|
}
|
||||||
|
|
||||||
|
cairo_close_path (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -385,11 +403,15 @@ gtk_bubble_window_draw (GtkWidget *widget,
|
|||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
GtkWidget *child;
|
GtkWidget *child;
|
||||||
|
GdkRGBA *border;
|
||||||
|
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
context = gtk_widget_get_style_context (widget);
|
context = gtk_widget_get_style_context (widget);
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
|
||||||
|
gtk_render_background (context, cr, 0, 0,
|
||||||
|
allocation.width, allocation.height);
|
||||||
|
|
||||||
if (gtk_widget_is_composited (widget))
|
if (gtk_widget_is_composited (widget))
|
||||||
{
|
{
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
@ -404,6 +426,15 @@ gtk_bubble_window_draw (GtkWidget *widget,
|
|||||||
|
|
||||||
gtk_render_background (context, cr, 0, 0,
|
gtk_render_background (context, cr, 0, 0,
|
||||||
allocation.width, allocation.height);
|
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));
|
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||||
|
|
||||||
if (child)
|
if (child)
|
||||||
@ -411,6 +442,8 @@ gtk_bubble_window_draw (GtkWidget *widget,
|
|||||||
|
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
|
|
||||||
|
gdk_rgba_free (border);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user