[gimp/gtk3-port: 65/233] modules: port to GtkWidget::draw()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 65/233] modules: port to GtkWidget::draw()
- Date: Thu, 22 Sep 2016 22:25:49 +0000 (UTC)
commit 24dae3168c3c8eaf3ae12f74ddc29b03c2f20326
Author: Michael Natterer <mitch gimp org>
Date: Thu Oct 21 12:49:13 2010 +0200
modules: port to GtkWidget::draw()
modules/color-selector-water.c | 49 +++++++++++++++++++--------------------
1 files changed, 24 insertions(+), 25 deletions(-)
---
diff --git a/modules/color-selector-water.c b/modules/color-selector-water.c
index 2c7efbe..ad39e8d 100644
--- a/modules/color-selector-water.c
+++ b/modules/color-selector-water.c
@@ -74,9 +74,8 @@ static void colorsel_water_set_config (GimpColorSelector *selector,
static void colorsel_water_create_transform (ColorselWater *water);
static void colorsel_water_destroy_transform (ColorselWater *water);
-static gboolean select_area_expose (GtkWidget *widget,
- GdkEventExpose *event,
- ColorselWater *water);
+static gboolean select_area_draw (GtkWidget *widget,
+ cairo_t *cr);
static gboolean button_press_event (GtkWidget *widget,
GdkEventButton *event,
ColorselWater *water);
@@ -159,8 +158,8 @@ colorsel_water_init (ColorselWater *water)
water->area = gtk_drawing_area_new ();
gtk_container_add (GTK_CONTAINER (frame), water->area);
- g_signal_connect (water->area, "expose-event",
- G_CALLBACK (select_area_expose),
+ g_signal_connect (water->area, "draw",
+ G_CALLBACK (select_area_draw),
water);
/* Event signals */
@@ -290,12 +289,13 @@ colorsel_water_destroy_transform (ColorselWater *water)
}
static gboolean
-select_area_expose (GtkWidget *widget,
- GdkEventExpose *event,
- ColorselWater *water)
+select_area_draw (GtkWidget *widget,
+ cairo_t *cr)
{
- cairo_t *cr;
+ ColorselWater *water = COLORSEL_WATER (widget);
+ GdkRectangle area;
GtkAllocation allocation;
+ gdouble x1, y1, x2, y2;
gdouble dx;
gdouble dy;
cairo_surface_t *surface;
@@ -303,10 +303,12 @@ select_area_expose (GtkWidget *widget,
gdouble y;
gint j;
- cr = gdk_cairo_create (event->window);
+ cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
+ area.x = floor (x1);
+ area.y = floor (y1);
+ area.width = ceil (x2) - area.x;
+ area.height = ceil (y2) - area.y;
gtk_widget_get_allocation (widget, &allocation);
@@ -314,16 +316,16 @@ select_area_expose (GtkWidget *widget,
dy = 1.0 / allocation.height;
surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
- event->area.width,
- event->area.height);
+ area.width,
+ area.height);
dest = cairo_image_surface_get_data (surface);
if (! water->transform)
colorsel_water_create_transform (water);
- for (j = 0, y = event->area.y / allocation.height;
- j < event->area.height;
+ for (j = 0, y = area.y / allocation.height;
+ j < area.height;
j++, y += dy)
{
guchar *d = dest;
@@ -338,11 +340,11 @@ select_area_expose (GtkWidget *widget,
gint i;
- r += event->area.x * dr;
- g += event->area.x * dg;
- b += event->area.x * db;
+ r += area.x * dr;
+ g += area.x * dg;
+ b += area.x * db;
- for (i = 0; i < event->area.width ; i++)
+ for (i = 0; i < area.width; i++)
{
GIMP_CAIRO_RGB24_SET_PIXEL (d,
CLAMP ((gint) r, 0, 255),
@@ -362,20 +364,17 @@ select_area_expose (GtkWidget *widget,
dest,
babl_format ("cairo-RGB24"),
dest,
- event->area.width);
+ area.width);
dest += cairo_image_surface_get_stride (surface);
}
cairo_surface_mark_dirty (surface);
- cairo_set_source_surface (cr, surface,
- event->area.x, event->area.y);
+ cairo_set_source_surface (cr, surface, area.x, area.y);
cairo_surface_destroy (surface);
cairo_paint (cr);
- cairo_destroy (cr);
-
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]