plug-ins: separate preview computation from drawing in map-object
This commit is contained in:
@ -32,8 +32,14 @@ static BackBuffer backbuf = { 0, 0, 0, 0, NULL };
|
|||||||
/* Protos */
|
/* Protos */
|
||||||
/* ====== */
|
/* ====== */
|
||||||
|
|
||||||
static void draw_light_marker (gint xpos,
|
static void compute_preview (gint x,
|
||||||
gint ypos);
|
gint y,
|
||||||
|
gint w,
|
||||||
|
gint h,
|
||||||
|
gint pw,
|
||||||
|
gint ph);
|
||||||
|
static void draw_light_marker (gint xpos,
|
||||||
|
gint ypos);
|
||||||
static void clear_light_marker (void);
|
static void clear_light_marker (void);
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
@ -41,7 +47,7 @@ static void clear_light_marker (void);
|
|||||||
/* dimensions (w,h), placing the result in preview_RGB_data. */
|
/* dimensions (w,h), placing the result in preview_RGB_data. */
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
|
||||||
void
|
static void
|
||||||
compute_preview (gint x,
|
compute_preview (gint x,
|
||||||
gint y,
|
gint y,
|
||||||
gint w,
|
gint w,
|
||||||
@ -330,7 +336,32 @@ update_light (gint xpos,
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
void
|
void
|
||||||
draw_preview_image (gint docompute)
|
compute_preview_image (void)
|
||||||
|
{
|
||||||
|
GdkDisplay *display = gtk_widget_get_display (previewarea);
|
||||||
|
GdkCursor *cursor;
|
||||||
|
gint startx, starty, pw, ph;
|
||||||
|
|
||||||
|
pw = PREVIEW_WIDTH * mapvals.zoom;
|
||||||
|
ph = PREVIEW_HEIGHT * mapvals.zoom;
|
||||||
|
startx = (PREVIEW_WIDTH - pw) / 2;
|
||||||
|
starty = (PREVIEW_HEIGHT - ph) / 2;
|
||||||
|
|
||||||
|
cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
|
||||||
|
gdk_window_set_cursor (gtk_widget_get_window (previewarea), cursor);
|
||||||
|
gdk_cursor_unref (cursor);
|
||||||
|
|
||||||
|
compute_preview (0, 0, width - 1, height - 1, 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);
|
||||||
|
|
||||||
|
clear_light_marker ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
draw_preview_image (void)
|
||||||
{
|
{
|
||||||
gint startx, starty, pw, ph;
|
gint startx, starty, pw, ph;
|
||||||
GdkColor color;
|
GdkColor color;
|
||||||
@ -348,27 +379,6 @@ draw_preview_image (gint docompute)
|
|||||||
startx = (PREVIEW_WIDTH - pw) / 2;
|
startx = (PREVIEW_WIDTH - pw) / 2;
|
||||||
starty = (PREVIEW_HEIGHT - ph) / 2;
|
starty = (PREVIEW_HEIGHT - ph) / 2;
|
||||||
|
|
||||||
if (docompute == TRUE)
|
|
||||||
{
|
|
||||||
GdkDisplay *display = gtk_widget_get_display (previewarea);
|
|
||||||
GdkCursor *cursor;
|
|
||||||
|
|
||||||
cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
|
|
||||||
gdk_window_set_cursor (gtk_widget_get_window (previewarea), cursor);
|
|
||||||
gdk_cursor_unref (cursor);
|
|
||||||
|
|
||||||
compute_preview (0, 0, width - 1, height - 1, 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);
|
|
||||||
|
|
||||||
clear_light_marker ();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pw != PREVIEW_WIDTH || ph != PREVIEW_HEIGHT)
|
|
||||||
gdk_window_clear (gtk_widget_get_window (previewarea));
|
|
||||||
|
|
||||||
cairo_set_source_surface (cr, preview_surface, startx, starty);
|
cairo_set_source_surface (cr, preview_surface, startx, starty);
|
||||||
cairo_rectangle (cr, startx, starty, pw, ph);
|
cairo_rectangle (cr, startx, starty, pw, ph);
|
||||||
cairo_clip (cr);
|
cairo_clip (cr);
|
||||||
|
@ -13,13 +13,8 @@ extern gint lightx,lighty;
|
|||||||
/* Externally visible functions */
|
/* Externally visible functions */
|
||||||
/* ============================ */
|
/* ============================ */
|
||||||
|
|
||||||
void compute_preview (gint x,
|
void compute_preview_image (void);
|
||||||
gint y,
|
void draw_preview_image (void);
|
||||||
gint w,
|
|
||||||
gint h,
|
|
||||||
gint pw,
|
|
||||||
gint ph);
|
|
||||||
void draw_preview_image (gint docompute);
|
|
||||||
gint check_light_hit (gint xpos,
|
gint check_light_hit (gint xpos,
|
||||||
gint ypos);
|
gint ypos);
|
||||||
void update_light (gint xpos,
|
void update_light (gint xpos,
|
||||||
|
@ -80,7 +80,9 @@ double_adjustment_update (GtkAdjustment *adjustment,
|
|||||||
gimp_double_adjustment_update (adjustment, data);
|
gimp_double_adjustment_update (adjustment, data);
|
||||||
|
|
||||||
if (mapvals.livepreview)
|
if (mapvals.livepreview)
|
||||||
draw_preview_image (TRUE);
|
compute_preview_image ();
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (previewarea);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -124,7 +126,8 @@ toggle_update (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
gimp_toggle_button_update (widget, data);
|
gimp_toggle_button_update (widget, data);
|
||||||
|
|
||||||
draw_preview_image (TRUE);
|
compute_preview_image ();
|
||||||
|
gtk_widget_queue_draw (previewarea);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
@ -154,7 +157,9 @@ lightmenu_callback (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mapvals.livepreview)
|
if (mapvals.livepreview)
|
||||||
draw_preview_image (TRUE);
|
compute_preview_image ();
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (previewarea);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************/
|
/***************************************/
|
||||||
@ -170,7 +175,9 @@ mapmenu_callback (GtkWidget *widget,
|
|||||||
|
|
||||||
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), (gint *) data);
|
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), (gint *) data);
|
||||||
|
|
||||||
draw_preview_image (TRUE);
|
compute_preview_image ();
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (previewarea);
|
||||||
|
|
||||||
children = gtk_container_get_children (GTK_CONTAINER (options_note_book));
|
children = gtk_container_get_children (GTK_CONTAINER (options_note_book));
|
||||||
n_children = g_list_length (children);
|
n_children = g_list_length (children);
|
||||||
@ -234,7 +241,9 @@ static void
|
|||||||
preview_callback (GtkWidget *widget,
|
preview_callback (GtkWidget *widget,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
draw_preview_image (TRUE);
|
compute_preview_image ();
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (previewarea);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -242,7 +251,9 @@ zoomed_callback (GimpZoomModel *model)
|
|||||||
{
|
{
|
||||||
mapvals.zoom = gimp_zoom_model_get_factor (model);
|
mapvals.zoom = gimp_zoom_model_get_factor (model);
|
||||||
|
|
||||||
draw_preview_image (TRUE);
|
compute_preview_image ();
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (previewarea);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************/
|
/**********************************************/
|
||||||
@ -289,7 +300,7 @@ preview_events (GtkWidget *area,
|
|||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
case GDK_EXPOSE:
|
case GDK_EXPOSE:
|
||||||
draw_preview_image (FALSE);
|
draw_preview_image ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_ENTER_NOTIFY:
|
case GDK_ENTER_NOTIFY:
|
||||||
@ -315,7 +326,9 @@ preview_events (GtkWidget *area,
|
|||||||
case GDK_BUTTON_RELEASE:
|
case GDK_BUTTON_RELEASE:
|
||||||
if (light_hit == TRUE)
|
if (light_hit == TRUE)
|
||||||
{
|
{
|
||||||
draw_preview_image (TRUE);
|
compute_preview_image ();
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (previewarea);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1360,7 +1373,8 @@ main_dialog (GimpDrawable *drawable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
image_setup (drawable, TRUE);
|
image_setup (drawable, TRUE);
|
||||||
draw_preview_image (TRUE);
|
|
||||||
|
compute_preview_image ();
|
||||||
|
|
||||||
if (gimp_dialog_run (GIMP_DIALOG (appwin)) == GTK_RESPONSE_OK)
|
if (gimp_dialog_run (GIMP_DIALOG (appwin)) == GTK_RESPONSE_OK)
|
||||||
run = TRUE;
|
run = TRUE;
|
||||||
|
Reference in New Issue
Block a user