[gimp/gtk3-port: 127/140] plug-ins: port lighting to GTK+ 3.0
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 127/140] plug-ins: port lighting to GTK+ 3.0
- Date: Thu, 25 Nov 2010 19:35:20 +0000 (UTC)
commit cf467e3e66ac7031ddd1b59aefbbc70f3d0f265b
Author: Michael Natterer <mitch gimp org>
Date: Tue Nov 2 21:49:54 2010 +0100
plug-ins: port lighting to GTK+ 3.0
plug-ins/lighting/lighting-preview.c | 81 ++++++++++++++++-----------------
plug-ins/lighting/lighting-preview.h | 4 +-
plug-ins/lighting/lighting-ui.c | 77 +++++++++++++++++---------------
3 files changed, 84 insertions(+), 78 deletions(-)
---
diff --git a/plug-ins/lighting/lighting-preview.c b/plug-ins/lighting/lighting-preview.c
index e647c92..8913fae 100644
--- a/plug-ins/lighting/lighting-preview.c
+++ b/plug-ins/lighting/lighting-preview.c
@@ -468,53 +468,35 @@ update_light (gint xpos, gint ypos)
/******************************************************************/
void
-draw_preview_image (gboolean recompute)
+preview_compute (void)
{
- gint startx, starty, pw, ph;
- cairo_t *cr;
+ GdkDisplay *display = gtk_widget_get_display (previewarea);
+ GdkCursor *cursor;
+ gint startx, starty, pw, ph;
compute_preview_rectangle (&startx, &starty, &pw, &ph);
- if (recompute)
- {
- GdkDisplay *display = gtk_widget_get_display (previewarea);
- GdkCursor *cursor;
-
- cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
+ cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
- gdk_window_set_cursor (gtk_widget_get_window (previewarea), cursor);
- gdk_cursor_unref (cursor);
+ gdk_window_set_cursor (gtk_widget_get_window (previewarea), cursor);
+ gdk_cursor_unref (cursor);
- compute_preview (startx, starty, pw, ph);
- cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
- gdk_window_set_cursor (gtk_widget_get_window (previewarea), cursor);
- gdk_cursor_unref (cursor);
- gdk_flush ();
-
- /* if we recompute, clear backbuf, so we don't
- * restore the wrong bitmap */
- if (backbuf.image != NULL)
- {
- cairo_surface_destroy (backbuf.image);
- backbuf.image = NULL;
- }
- }
+ compute_preview (startx, starty, pw, ph);
+ cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
+ gdk_window_set_cursor (gtk_widget_get_window (previewarea), cursor);
+ gdk_cursor_unref (cursor);
+ gdk_flush ();
- cr = gdk_cairo_create (gtk_widget_get_window (previewarea));
-
- cairo_set_source_surface (cr, preview_surface, 0.0, 0.0);
-
- cairo_paint (cr);
-
- cairo_destroy (cr);
-
- /* draw symbols if enabled in UI */
- if (mapvals.interactive_preview)
+ /* if we recompute, clear backbuf, so we don't
+ * restore the wrong bitmap */
+ if (backbuf.image != NULL)
{
- draw_handles ();
+ cairo_surface_destroy (backbuf.image);
+ backbuf.image = NULL;
}
}
+
/******************************/
/* Preview area event handler */
/******************************/
@@ -525,10 +507,6 @@ preview_events (GtkWidget *area,
{
switch (event->type)
{
- case GDK_EXPOSE:
-
- draw_preview_image (FALSE);
- break;
case GDK_ENTER_NOTIFY:
break;
case GDK_LEAVE_NOTIFY:
@@ -557,6 +535,23 @@ preview_events (GtkWidget *area,
return FALSE;
}
+gboolean
+preview_draw (GtkWidget *area,
+ cairo_t *cr)
+{
+ cairo_set_source_surface (cr, preview_surface, 0.0, 0.0);
+
+ cairo_paint (cr);
+
+ /* draw symbols if enabled in UI */
+ if (mapvals.interactive_preview)
+ {
+ draw_handles ();
+ }
+
+ return FALSE;
+}
+
void
interactive_preview_callback (GtkWidget *widget)
{
@@ -570,7 +565,7 @@ interactive_preview_callback (GtkWidget *widget)
}
static gboolean
-interactive_preview_timer_callback ( gpointer data )
+interactive_preview_timer_callback (gpointer data)
{
gint k = mapvals.light_selected;
@@ -591,7 +586,9 @@ interactive_preview_timer_callback ( gpointer data )
mapvals.update_enabled = TRUE;
- draw_preview_image (TRUE);
+ preview_compute ();
+
+ gtk_widget_queue_draw (previewarea);
preview_update_timer = 0;
diff --git a/plug-ins/lighting/lighting-preview.h b/plug-ins/lighting/lighting-preview.h
index d1698e6..2e15d2f 100644
--- a/plug-ins/lighting/lighting-preview.h
+++ b/plug-ins/lighting/lighting-preview.h
@@ -26,10 +26,12 @@ extern gdouble *xpostab, *ypostab;
/* Externally visible functions */
-void draw_preview_image (gboolean recompute);
+void preview_compute (void);
void interactive_preview_callback (GtkWidget *widget);
gboolean preview_events (GtkWidget *area,
GdkEvent *event);
+gboolean preview_draw (GtkWidget *area,
+ cairo_t *cr);
void update_light (gint xpos,
gint ypos);
diff --git a/plug-ins/lighting/lighting-ui.c b/plug-ins/lighting/lighting-ui.c
index 99fb348..db8d1ea 100644
--- a/plug-ins/lighting/lighting-ui.c
+++ b/plug-ins/lighting/lighting-ui.c
@@ -101,7 +101,8 @@ toggle_update (GtkWidget *widget,
{
gimp_toggle_button_update (widget, data);
- draw_preview_image (TRUE);
+ preview_compute ();
+ gtk_widget_queue_draw (previewarea);
}
@@ -111,7 +112,8 @@ distance_update (GtkAdjustment *adj,
{
mapvals.viewpoint.z = gtk_adjustment_get_value (adj);
- draw_preview_image (TRUE);
+ preview_compute ();
+ gtk_widget_queue_draw (previewarea);
}
@@ -197,7 +199,8 @@ mapmenu2_callback (GtkWidget *widget,
{
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), (gint *) data);
- draw_preview_image (TRUE);
+ preview_compute ();
+ gtk_widget_queue_draw (previewarea);
}
/******************************************/
@@ -207,7 +210,8 @@ mapmenu2_callback (GtkWidget *widget,
static void
preview_callback (GtkWidget *widget)
{
- draw_preview_image (TRUE);
+ preview_compute ();
+ gtk_widget_queue_draw (previewarea);
}
@@ -278,12 +282,12 @@ envmap_combo_callback (GtkWidget *widget,
static GtkWidget *
create_options_page (void)
{
- GtkWidget *page;
- GtkWidget *frame;
- GtkWidget *vbox;
- GtkWidget *toggle;
- GtkWidget *table;
- GtkObject *adj;
+ GtkWidget *page;
+ GtkWidget *frame;
+ GtkWidget *vbox;
+ GtkWidget *toggle;
+ GtkWidget *table;
+ GtkAdjustment *adj;
page = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (page), 12);
@@ -362,13 +366,13 @@ create_options_page (void)
static GtkWidget *
create_light_page (void)
{
- GtkWidget *page;
- GtkWidget *frame;
- GtkWidget *table;
- GtkWidget *button;
- GtkObject *adj;
- GtkWidget *label;
- gint k = mapvals.light_selected;
+ GtkWidget *page;
+ GtkWidget *frame;
+ GtkWidget *table;
+ GtkWidget *button;
+ GtkAdjustment *adj;
+ GtkWidget *label;
+ gint k = mapvals.light_selected;
page = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (page), 12);
@@ -602,16 +606,16 @@ create_light_page (void)
static GtkWidget *
create_material_page (void)
{
- GtkSizeGroup *group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- GtkWidget *page;
- GtkWidget *frame;
- GtkWidget *table;
- GtkWidget *label;
- GtkWidget *hbox;
- GtkWidget *spinbutton;
- GtkWidget *image;
- GtkWidget *button;
- GtkObject *adj;
+ GtkSizeGroup *group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ GtkWidget *page;
+ GtkWidget *frame;
+ GtkWidget *table;
+ GtkWidget *label;
+ GtkWidget *hbox;
+ GtkWidget *spinbutton;
+ GtkWidget *image;
+ GtkWidget *button;
+ GtkAdjustment *adj;
page = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (page), 12);
@@ -783,13 +787,13 @@ create_material_page (void)
static GtkWidget *
create_bump_page (void)
{
- GtkWidget *page;
- GtkWidget *toggle;
- GtkWidget *frame;
- GtkWidget *table;
- GtkWidget *combo;
- GtkWidget *spinbutton;
- GtkObject *adj;
+ GtkWidget *page;
+ GtkWidget *toggle;
+ GtkWidget *frame;
+ GtkWidget *table;
+ GtkWidget *combo;
+ GtkWidget *spinbutton;
+ GtkAdjustment *adj;
page = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (page), 12);
@@ -1062,6 +1066,9 @@ main_dialog (GimpDrawable *drawable)
g_signal_connect (previewarea, "event",
G_CALLBACK (preview_events),
previewarea);
+ g_signal_connect (previewarea, "draw",
+ G_CALLBACK (preview_draw),
+ previewarea);
gtk_container_add (GTK_CONTAINER (frame), previewarea);
gtk_widget_show (previewarea);
@@ -1111,7 +1118,7 @@ main_dialog (GimpDrawable *drawable)
image_setup (drawable, TRUE);
- draw_preview_image (TRUE);
+ preview_compute ();
if (gimp_dialog_run (GIMP_DIALOG (appwin)) == GTK_RESPONSE_OK)
run = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]