[gimp] libgimpwidgets: port the GimpChainButton lines to cairo
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpwidgets: port the GimpChainButton lines to cairo
- Date: Fri, 15 Oct 2010 08:36:11 +0000 (UTC)
commit 1de338ea9d14e0c264b64248c31d9cea430083a5
Author: Michael Natterer <mitch gimp org>
Date: Fri Oct 15 10:35:28 2010 +0200
libgimpwidgets: port the GimpChainButton lines to cairo
A proper two-pixel line in FG color looks a lot less shabby...
libgimpwidgets/gimpchainbutton.c | 43 ++++++++++++++++---------------------
1 files changed, 19 insertions(+), 24 deletions(-)
---
diff --git a/libgimpwidgets/gimpchainbutton.c b/libgimpwidgets/gimpchainbutton.c
index 54bccc4..0fc2b31 100644
--- a/libgimpwidgets/gimpchainbutton.c
+++ b/libgimpwidgets/gimpchainbutton.c
@@ -373,15 +373,19 @@ gimp_chain_line_new (GimpChainPosition position,
}
static gboolean
-gimp_chain_line_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
+gimp_chain_line_expose_event (GtkWidget *widget,
+ GdkEventExpose *event)
{
- GimpChainLine *line = ((GimpChainLine *) widget);
+ GtkStyle *style = gtk_widget_get_style (widget);
+ GimpChainLine *line = ((GimpChainLine *) widget);
GtkAllocation allocation;
GdkPoint points[3];
- GdkPoint buf;
- GtkShadowType shadow;
GimpChainPosition position;
+ cairo_t *cr;
+
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
+ gdk_cairo_region (cr, event->region);
+ cairo_clip (cr);
gtk_widget_get_allocation (widget, &allocation);
@@ -419,7 +423,6 @@ gimp_chain_line_expose_event (GtkWidget *widget,
points[2].y = (line->which == 1 ?
allocation.y + allocation.height - 1 :
allocation.y);
- shadow = GTK_SHADOW_ETCHED_IN;
break;
case GIMP_CHAIN_RIGHT:
@@ -430,7 +433,6 @@ gimp_chain_line_expose_event (GtkWidget *widget,
points[2].y = (line->which == 1 ?
allocation.y + allocation.height - 1 :
allocation.y);
- shadow = GTK_SHADOW_ETCHED_OUT;
break;
case GIMP_CHAIN_TOP:
@@ -441,7 +443,6 @@ gimp_chain_line_expose_event (GtkWidget *widget,
allocation.x + allocation.width - 1 :
allocation.x);
points[2].y = points[1].y;
- shadow = GTK_SHADOW_ETCHED_OUT;
break;
case GIMP_CHAIN_BOTTOM:
@@ -452,29 +453,23 @@ gimp_chain_line_expose_event (GtkWidget *widget,
allocation.x + allocation.width - 1 :
allocation.x);
points[2].y = points[1].y;
- shadow = GTK_SHADOW_ETCHED_IN;
break;
default:
return FALSE;
}
- if ( ((shadow == GTK_SHADOW_ETCHED_OUT) && (line->which == -1)) ||
- ((shadow == GTK_SHADOW_ETCHED_IN) && (line->which == 1)) )
- {
- buf = points[0];
- points[0] = points[2];
- points[2] = buf;
- }
+ cairo_move_to (cr, points[0].x, points[0].y);
+ cairo_line_to (cr, points[1].x, points[1].y);
+ cairo_line_to (cr, points[2].x, points[2].y);
+
+ cairo_set_line_width (cr, 2.0);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
+ gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+
+ cairo_stroke (cr);
- gtk_paint_polygon (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget), GTK_STATE_NORMAL,
- shadow,
- &event->area,
- widget,
- "chainbutton",
- points, 3,
- FALSE);
+ cairo_destroy (cr);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]