Commit 47f84a8b authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

plug-ins/rcm/rcm_callback.c plug-ins/rcm/rcm_dialog.c redraw the previews

2005-08-15  Sven Neumann  <sven@gimp.org>

	* plug-ins/rcm/rcm_callback.c
	* plug-ins/rcm/rcm_dialog.c
	* plug-ins/rcm/rcm_misc.[ch]: redraw the previews if their size
	changes. Fixes bug #172284.
parent d0a5930f
2005-08-15 Sven Neumann <sven@gimp.org>
* plug-ins/rcm/rcm_callback.c
* plug-ins/rcm/rcm_dialog.c
* plug-ins/rcm/rcm_misc.[ch]: redraw the previews if their size
changes. Fixes bug #172284.
2005-08-15 Michael Natterer <mitch@gimp.org>
* plug-ins/common/CML_explorer.c
......
......@@ -90,7 +90,7 @@ rcm_360_degrees (GtkWidget *button,
rcm_draw_arrows (circle->preview->window, circle->preview->style->black_gc,
circle->angle);
circle->action_flag = VIRGIN;
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
}
void
......@@ -123,7 +123,7 @@ rcm_a_to_b (GtkWidget *button,
circle->angle);
circle->action_flag = VIRGIN;
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
}
......@@ -293,7 +293,7 @@ rcm_switch_to_gray_to (GtkWidget *button,
return;
Current.Gray_to_from = GRAY_TO;
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
}
void
......@@ -304,7 +304,7 @@ rcm_switch_to_gray_from (GtkWidget *button,
return;
Current.Gray_to_from = GRAY_FROM;
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
}
......@@ -317,32 +317,6 @@ rcm_preview_as_you_drag (GtkWidget *button,
Current.RealTime = GTK_TOGGLE_BUTTON (button)->active;
}
static void
rcm_change_preview (void)
{
/* must hide and show or resize would not work ... */
gtk_widget_hide (Current.Bna->before);
gtk_widget_hide (Current.Bna->after);
gtk_widget_set_size_request (Current.Bna->before,
Current.reduced->width,
Current.reduced->height);
gtk_widget_set_size_request (Current.Bna->after,
Current.reduced->width,
Current.reduced->height);
rcm_render_preview (Current.Bna->before, ORIGINAL);
rcm_render_preview (Current.Bna->after, CURRENT);
gtk_widget_queue_draw (Current.Bna->before);
gtk_widget_queue_draw (Current.Bna->after);
gtk_widget_show (Current.Bna->before);
gtk_widget_show (Current.Bna->after);
}
void
rcm_combo_callback (GtkWidget *widget,
gpointer data)
......@@ -353,7 +327,13 @@ rcm_combo_callback (GtkWidget *widget,
Current.reduced = rcm_reduce_image (Current.drawable, Current.mask,
MAX_PREVIEW_SIZE, value);
rcm_change_preview ();
gtk_widget_set_size_request (Current.Bna->before,
Current.reduced->width,
Current.reduced->height);
gtk_widget_set_size_request (Current.Bna->after,
Current.reduced->width,
Current.reduced->height);
}
......@@ -364,18 +344,11 @@ rcm_expose_event (GtkWidget *widget,
GdkEvent *event,
RcmCircle *circle)
{
switch (circle->action_flag)
if (circle->action_flag == VIRGIN)
{
case DO_NOTHING: return FALSE; break;
case VIRGIN: rcm_draw_arrows(widget->window, widget->style->black_gc,
circle->angle);
break;
rcm_draw_arrows (widget->window, widget->style->black_gc, circle->angle);
}
default: if (Current.RealTime)
rcm_render_preview(Current.Bna->after,CURRENT);
break;
}
return TRUE;
}
......@@ -420,7 +393,7 @@ rcm_button_press_event (GtkWidget *widget,
rcm_units_factor(Current.Units));
if (Current.RealTime)
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
}
}
else
......@@ -442,8 +415,7 @@ rcm_release_event (GtkWidget *widget,
circle->action_flag = VIRGIN;
if (! Current.RealTime)
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
return TRUE;
}
......@@ -511,7 +483,7 @@ rcm_motion_notify_event (GtkWidget *widget,
rcm_units_factor(Current.Units));
if (Current.RealTime)
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
}
return TRUE;
......@@ -533,8 +505,6 @@ rcm_gray_expose_event (GtkWidget *widget,
rcm_draw_large_circle (widget->window,
widget->style->black_gc, circle->gray_sat);
}
else if (Current.RealTime)
rcm_render_preview (Current.Bna->after, CURRENT);
return TRUE;
}
......@@ -573,7 +543,7 @@ rcm_gray_button_press_event (GtkWidget *widget,
circle->satur);
if (Current.RealTime)
rcm_render_preview (Current.Bna->after,CURRENT);
rcm_render_preview (Current.Bna->after);
return TRUE;
}
......@@ -591,8 +561,7 @@ rcm_gray_release_event (GtkWidget *widget,
circle->action_flag = VIRGIN;
if (!Current.RealTime)
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
return TRUE;
}
......@@ -646,7 +615,7 @@ rcm_gray_motion_notify_event (GtkWidget *widget,
circle->satur);
if (Current.RealTime)
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
return TRUE;
}
......@@ -671,7 +640,7 @@ rcm_set_alpha (GtkWidget *entry,
rcm_draw_arrows (circle->preview->window, circle->preview->style->black_gc,
circle->angle);
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
}
void
......@@ -691,7 +660,7 @@ rcm_set_beta (GtkWidget *entry,
rcm_draw_arrows (circle->preview->window, circle->preview->style->black_gc,
circle->angle);
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
}
void
......@@ -716,7 +685,7 @@ rcm_set_hue (GtkWidget *entry,
circle->preview->style->black_gc,
circle->gray_sat);
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
}
void
......@@ -740,7 +709,7 @@ rcm_set_satur (GtkWidget *entry,
circle->preview->style->black_gc,
circle->gray_sat);
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
}
void
......@@ -757,5 +726,5 @@ rcm_set_gray_sat (GtkWidget *entry,
circle->preview->style->black_gc,
circle->gray_sat);
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_preview (Current.Bna->after);
}
......@@ -73,6 +73,7 @@
static GtkWidget *
rcm_create_one_preview (GtkWidget **preview,
gint mode,
gint width,
gint height)
{
......@@ -90,6 +91,8 @@ rcm_create_one_preview (GtkWidget **preview,
gtk_container_add (GTK_CONTAINER (frame), *preview);
gtk_widget_show (*preview);
g_object_set_data (G_OBJECT (*preview), "mode", GINT_TO_POINTER (mode));
return align;
}
......@@ -117,12 +120,16 @@ rcm_create_previews (void)
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
frame = rcm_create_one_preview (&Current.Bna->before,
frame = rcm_create_one_preview (&Current.Bna->before, ORIGINAL,
Current.reduced->width,
Current.reduced->height);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
g_signal_connect_after (Current.Bna->before, "size-allocate",
G_CALLBACK (rcm_render_preview),
NULL);
vbox = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (top_vbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
......@@ -131,12 +138,16 @@ rcm_create_previews (void)
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
frame = rcm_create_one_preview (&Current.Bna->after,
frame = rcm_create_one_preview (&Current.Bna->after, CURRENT,
Current.reduced->width,
Current.reduced->height);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
g_signal_connect_after (Current.Bna->after, "size-allocate",
G_CALLBACK (rcm_render_preview),
NULL);
vbox = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (top_vbox), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
......@@ -687,8 +698,6 @@ rcm_dialog (void)
gtk_widget_show (dlg);
rcm_render_preview (Current.Bna->before, ORIGINAL);
rcm_render_preview (Current.Bna->after, CURRENT);
rcm_render_circle (Current.From->preview, SUM, MARGIN);
rcm_render_circle (Current.To->preview, SUM, MARGIN);
rcm_render_circle (Current.Gray->preview, GRAY_SUM, GRAY_MARGIN);
......
......@@ -312,21 +312,22 @@ rcm_reduce_image (GimpDrawable *drawable,
/* render before/after preview */
void
rcm_render_preview (GtkWidget *preview,
gint version)
rcm_render_preview (GtkWidget *preview)
{
ReducedImage *reduced;
gint RW, RH, bytes, i, j, unchanged, skip;
gint version;
gint RW, RH, bytes, i, j;
gboolean unchanged, skip;
guchar *rgb_array, *a;
gdouble H, S, V;
gdouble *hsv_array;
guchar rgb[3];
gfloat degree;
/* init some variables */
g_return_if_fail (preview != NULL);
version = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (preview), "mode"));
reduced = Current.reduced;
RW = reduced->width;
RH = reduced->height;
......@@ -342,8 +343,8 @@ rcm_render_preview (GtkWidget *preview,
{
for (j = 0; j < RW; j++)
{
unchanged = 1; /* TRUE */
skip = 0; /* FALSE */
unchanged = TRUE;
skip = FALSE;
H = hsv_array[i*RW*bytes + j*bytes + 0];
S = hsv_array[i*RW*bytes + j*bytes + 1];
......@@ -361,13 +362,16 @@ rcm_render_preview (GtkWidget *preview,
S = Current.Gray->satur;
}
else
skip = 1;
skip = TRUE;
break;
case GRAY_TO:
unchanged = 0;
skip = 1;
gimp_hsv_to_rgb4 (rgb, Current.Gray->hue/TP, Current.Gray->satur, V);
unchanged = FALSE;
skip = TRUE;
gimp_hsv_to_rgb4 (rgb,
Current.Gray->hue/TP,
Current.Gray->satur,
V);
break;
default:
......@@ -377,7 +381,7 @@ rcm_render_preview (GtkWidget *preview,
if (!skip)
{
unchanged = 0;
unchanged = FALSE;
H = rcm_linear (rcm_left_end (Current.From->angle),
rcm_right_end (Current.From->angle),
rcm_left_end (Current.To->angle),
......@@ -422,11 +426,12 @@ rcm_render_preview (GtkWidget *preview,
}
}
}
gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview),
0, 0, RW, RH,
GIMP_RGBA_IMAGE,
a,
RW * 4);
gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview),
0, 0, RW, RH,
GIMP_RGBA_IMAGE,
a,
RW * 4);
g_free (a);
}
......
......@@ -53,12 +53,11 @@ float *closest (gfloat *alpha,
gfloat *beta,
gfloat angle);
float angle_mod_2PI (gfloat angle);
ReducedImage *rcm_reduce_image (GimpDrawable *,
GimpDrawable *,
gint ,
gint );
void rcm_render_preview (GtkWidget *,
gint);
ReducedImage *rcm_reduce_image (GimpDrawable *drawable,
GimpDrawable *mask,
gint longer_size,
gint selection);
void rcm_render_preview (GtkWidget *preview);
void rcm_render_circle (GtkWidget *preview,
gint sum,
gint margin);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment