diff --git a/ChangeLog b/ChangeLog index 3340010810..b384dd06af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +Sat Aug 15 15:27:39 MEST 1998 Sven Neumann + + * app/color_picker.c + * app/crop.c + * app/info_dialog.[ch] + * app/info_window.c + * app/rotate_tool.c + * app/scale_tool.c + * app/shear_tool.c: We have entries in the info dialog now that + allow to enter exact values for the transformations and crop. + + * app/transform_core.c + * app/transform_tool.c: Changed "Clip perspective" to "Clip result" + and made it available for all transformations. + + * app/rect_select.c + * app/ink.c: minor cosmetic changes + Fri Aug 14 19:58:13 EDT 1998 Adrian Likins * plugins/script-fu/scripts/select_to_brush.scm, diff --git a/app/color_picker.c b/app/color_picker.c index 5e16e29f21..fa4c2ff716 100644 --- a/app/color_picker.c +++ b/app/color_picker.c @@ -153,26 +153,26 @@ color_picker_button_press (Tool *tool, switch (drawable_type (active_drawable)) { case RGB_GIMAGE: case RGBA_GIMAGE: - info_dialog_add_field (color_picker_info, "Red", red_buf); - info_dialog_add_field (color_picker_info, "Green", green_buf); - info_dialog_add_field (color_picker_info, "Blue", blue_buf); - info_dialog_add_field (color_picker_info, "Alpha", alpha_buf); - info_dialog_add_field (color_picker_info, "Hex Triplet", hex_buf); + info_dialog_add_field (color_picker_info, "Red", red_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Green", green_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Blue", blue_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Alpha", alpha_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Hex Triplet", hex_buf, NULL, NULL); break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: - info_dialog_add_field (color_picker_info, "Index", index_buf); - info_dialog_add_field (color_picker_info, "Alpha", alpha_buf); - info_dialog_add_field (color_picker_info, "Red", red_buf); - info_dialog_add_field (color_picker_info, "Green", green_buf); - info_dialog_add_field (color_picker_info, "Blue", blue_buf); - info_dialog_add_field (color_picker_info, "Hex Triplet", hex_buf); + info_dialog_add_field (color_picker_info, "Index", index_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Alpha", alpha_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Red", red_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Green", green_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Blue", blue_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Hex Triplet", hex_buf, NULL, NULL); break; case GRAY_GIMAGE: case GRAYA_GIMAGE: - info_dialog_add_field (color_picker_info, "Intensity", gray_buf); - info_dialog_add_field (color_picker_info, "Alpha", alpha_buf); - info_dialog_add_field (color_picker_info, "Hex Triplet", hex_buf); + info_dialog_add_field (color_picker_info, "Intensity", gray_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Alpha", alpha_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Hex Triplet", hex_buf, NULL, NULL); break; default : diff --git a/app/crop.c b/app/crop.c index c2814fb066..25b2259729 100644 --- a/app/crop.c +++ b/app/crop.c @@ -97,6 +97,12 @@ static void crop_ok_callback (GtkWidget *, gpointer); static void crop_selection_callback (GtkWidget *, gpointer); static void crop_close_callback (GtkWidget *, gpointer); +/* Crop dialog callback funtions */ +static void crop_orig_x_changed (GtkWidget *, gpointer); +static void crop_orig_y_changed (GtkWidget *, gpointer); +static void crop_width_changed (GtkWidget *, gpointer); +static void crop_height_changed (GtkWidget *, gpointer); + static void *crop_options = NULL; static Argument *crop_invoker (Argument *); @@ -719,10 +725,10 @@ crop_info_create (Tool *tool) crop_info = info_dialog_new ("Crop Information"); /* add the information fields */ - info_dialog_add_field (crop_info, "X Origin: ", orig_x_buf); - info_dialog_add_field (crop_info, "Y Origin: ", orig_y_buf); - info_dialog_add_field (crop_info, "Width: ", width_buf); - info_dialog_add_field (crop_info, "Height: ", height_buf); + info_dialog_add_field (crop_info, "X Origin: ", orig_x_buf, crop_orig_x_changed, tool); + info_dialog_add_field (crop_info, "Y Origin: ", orig_y_buf, crop_orig_y_changed, tool); + info_dialog_add_field (crop_info, "Width: ", width_buf, crop_width_changed, tool); + info_dialog_add_field (crop_info, "Height: ", height_buf, crop_height_changed, tool); /* Create the action area */ build_action_area (GTK_DIALOG (crop_info->shell), action_items, 3, 0); @@ -800,6 +806,135 @@ crop_close_callback (GtkWidget *w, tool->state = INACTIVE; } +static void +crop_orig_x_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + Crop * crop; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + crop = (Crop *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != crop->tx1) + { + draw_core_pause (crop->core, tool); + crop->tx2 = crop->tx2 + (value - crop->tx1); + crop->tx1 = value; + crop_recalc (tool, crop); + draw_core_resume (crop->core, tool); + } + + g_free (str); + } +} + +static void +crop_orig_y_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + Crop * crop; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + crop = (Crop *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != crop->ty1) + { + draw_core_pause (crop->core, tool); + crop->ty2 = crop->ty2 + (value - crop->ty1); + crop->ty1 = value; + crop_recalc (tool, crop); + draw_core_resume (crop->core, tool); + } + + g_free (str); + } +} + +static void +crop_width_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + Crop * crop; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + crop = (Crop *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != (crop->tx2 - crop->tx1)); + { + draw_core_pause (crop->core, tool); + crop->tx2 = value + crop->tx1; + crop_recalc (tool, crop); + draw_core_resume (crop->core, tool); + } + + g_free (str); + } +} + +static void +crop_height_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + Crop * crop; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + crop = (Crop *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != (crop->ty2 - crop->ty1)); + { + draw_core_pause (crop->core, tool); + crop->ty2 = value + crop->ty1; + crop_recalc (tool, crop); + draw_core_resume (crop->core, tool); + } + + g_free (str); + } +} /* The procedure definition */ ProcArg crop_args[] = diff --git a/app/dialogs/info-dialog.c b/app/dialogs/info-dialog.c index 5513e56262..ac41b6facb 100644 --- a/app/dialogs/info-dialog.c +++ b/app/dialogs/info-dialog.c @@ -24,33 +24,55 @@ #include "session.h" /* static functions */ -static InfoField * info_field_new (InfoDialog *, char *, char *); +static InfoField * info_field_new (InfoDialog *, char *, char *, GtkSignalFunc, gpointer); static void update_field (InfoField *); static gint info_dialog_delete_callback (GtkWidget *, GdkEvent *, gpointer); static InfoField * -info_field_new (InfoDialog *idialog, - char *title, - char *text_ptr) +info_field_new (InfoDialog *idialog, + char *title, + char *text_ptr, + GtkSignalFunc callback, + gpointer client_data) { GtkWidget *label; InfoField *field; + int row; field = (InfoField *) g_malloc (sizeof (InfoField)); + row = idialog->nfields + 1; + gtk_table_resize (GTK_TABLE (idialog->info_table), 2, row); + label = gtk_label_new (title); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (idialog->labels), label, FALSE, FALSE, 0); + gtk_table_attach_defaults (GTK_TABLE (idialog->info_table), label, + 0, 1, row - 1, row); - field->w = gtk_label_new (text_ptr); - gtk_misc_set_alignment (GTK_MISC (field->w), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (idialog->values), field->w, FALSE, FALSE, 0); + if (callback == NULL) + { + field->w = gtk_label_new (text_ptr); + gtk_misc_set_alignment (GTK_MISC (field->w), 0.0, 0.5); + } + else + { + field->w = gtk_entry_new (); + gtk_widget_set_usize (field->w, 50, 0); + gtk_entry_set_text (GTK_ENTRY (field->w), text_ptr); + gtk_signal_connect (GTK_OBJECT (field->w), "changed", + GTK_SIGNAL_FUNC (callback), client_data); + } - field->text_ptr = text_ptr; + gtk_table_attach_defaults (GTK_TABLE (idialog->info_table), field->w, + 1, 2, row - 1, row); gtk_widget_show (field->w); gtk_widget_show (label); + field->text_ptr = text_ptr; + field->callback = callback; + field->client_data = client_data; + return field; } @@ -60,12 +82,18 @@ update_field (InfoField *field) gchar *old_text; /* only update the field if its new value differs from the old */ - gtk_label_get (GTK_LABEL (field->w), &old_text); + if (field->callback == NULL) + gtk_label_get (GTK_LABEL (field->w), &old_text); + else + old_text = gtk_entry_get_text (GTK_ENTRY (field->w)); if (strcmp (old_text, field->text_ptr)) { /* set the new value and update somehow */ - gtk_label_set (GTK_LABEL (field->w), field->text_ptr); + if (field->callback == NULL) + gtk_label_set (GTK_LABEL (field->w), field->text_ptr); + else + gtk_entry_set_text (GTK_ENTRY (field->w), field->text_ptr); } } @@ -77,11 +105,11 @@ info_dialog_new (char *title) InfoDialog * idialog; GtkWidget *shell; GtkWidget *vbox; - GtkWidget *labels, *values; - GtkWidget *info_area; + GtkWidget *info_table; idialog = (InfoDialog *) g_malloc (sizeof (InfoDialog)); idialog->field_list = NULL; + idialog->nfields = 0; shell = gtk_dialog_new (); gtk_window_set_wmclass (GTK_WINDOW (shell), "info_dialog", "Gimp"); @@ -96,25 +124,15 @@ info_dialog_new (char *title) gtk_container_border_width (GTK_CONTAINER (vbox), 1); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (shell)->vbox), vbox, TRUE, TRUE, 0); - info_area = gtk_hbox_new (FALSE, 1); - gtk_container_border_width (GTK_CONTAINER (info_area), 5); - gtk_box_pack_start (GTK_BOX (vbox), info_area, TRUE, TRUE, 0); - - labels = gtk_vbox_new (FALSE, 1); - gtk_box_pack_start (GTK_BOX (info_area), labels, TRUE, TRUE, 0); - - values = gtk_vbox_new (FALSE, 1); - gtk_box_pack_start (GTK_BOX (info_area), values, TRUE, TRUE, 0); + info_table = gtk_table_new (0, 0, FALSE); + gtk_container_border_width (GTK_CONTAINER (info_table), 5); + gtk_box_pack_start (GTK_BOX (vbox), info_table, TRUE, TRUE, 0); idialog->shell = shell; idialog->vbox = vbox; - idialog->info_area = info_area; - idialog->labels = labels; - idialog->values = values; + idialog->info_table = info_table; - gtk_widget_show (idialog->labels); - gtk_widget_show (idialog->values); - gtk_widget_show (idialog->info_area); + gtk_widget_show (idialog->info_table); gtk_widget_show (idialog->vbox); return idialog; @@ -150,17 +168,20 @@ info_dialog_free (InfoDialog *idialog) } void -info_dialog_add_field (InfoDialog *idialog, - char *title, - char *text_ptr) +info_dialog_add_field (InfoDialog *idialog, + char *title, + char *text_ptr, + GtkSignalFunc callback, + gpointer data) { InfoField * new_field; if (!idialog) return; - new_field = info_field_new (idialog, title, text_ptr); + new_field = info_field_new (idialog, title, text_ptr, callback, data); idialog->field_list = g_slist_prepend (idialog->field_list, (void *) new_field); + idialog->nfields++; } void diff --git a/app/dialogs/info-dialog.h b/app/dialogs/info-dialog.h index e9b2d6f70d..1cf877a7a7 100644 --- a/app/dialogs/info-dialog.h +++ b/app/dialogs/info-dialog.h @@ -24,8 +24,10 @@ typedef struct _info_field InfoField; struct _info_field { - GtkWidget *w; - char * text_ptr; + GtkWidget *w; + char *text_ptr; + GtkSignalFunc callback; + gpointer client_data; }; @@ -35,11 +37,10 @@ struct _info_dialog { GtkWidget *shell; GtkWidget *vbox; - GtkWidget *info_area; - GtkWidget *labels; - GtkWidget *values; + GtkWidget *info_table; GSList *field_list; + int nfields; void *user_data; }; @@ -49,7 +50,11 @@ struct _info_dialog InfoDialog * info_dialog_new (char *); void info_dialog_free (InfoDialog *); -void info_dialog_add_field (InfoDialog *, char *, char *); +void info_dialog_add_field (InfoDialog *, + char *, + char *, + GtkSignalFunc, + gpointer); void info_dialog_popup (InfoDialog *); void info_dialog_popdown (InfoDialog *); void info_dialog_update (InfoDialog *); diff --git a/app/dialogs/info-window.c b/app/dialogs/info-window.c index b347cda08b..ad024e1cf1 100644 --- a/app/dialogs/info-window.c +++ b/app/dialogs/info-window.c @@ -148,17 +148,17 @@ info_window_create (void *gdisp_ptr) iwd->shades_str[0] = '\0'; /* add the information fields */ - info_dialog_add_field (info_win, "Dimensions (w x h): ", iwd->dimensions_str); - info_dialog_add_field (info_win, "Scale Ratio: ", iwd->scale_str); - info_dialog_add_field (info_win, "Display Type: ", iwd->color_type_str); - info_dialog_add_field (info_win, "Visual Class: ", iwd->visual_class_str); - info_dialog_add_field (info_win, "Visual Depth: ", iwd->visual_depth_str); + info_dialog_add_field (info_win, "Dimensions (w x h): ", iwd->dimensions_str, NULL, NULL); + info_dialog_add_field (info_win, "Scale Ratio: ", iwd->scale_str, NULL, NULL); + info_dialog_add_field (info_win, "Display Type: ", iwd->color_type_str, NULL, NULL); + info_dialog_add_field (info_win, "Visual Class: ", iwd->visual_class_str, NULL, NULL); + info_dialog_add_field (info_win, "Visual Depth: ", iwd->visual_depth_str, NULL, NULL); if (type == RGB) - info_dialog_add_field (info_win, "Shades of Color: ", iwd->shades_str); + info_dialog_add_field (info_win, "Shades of Color: ", iwd->shades_str, NULL, NULL); else if (type == INDEXED) - info_dialog_add_field (info_win, "Shades: ", iwd->shades_str); + info_dialog_add_field (info_win, "Shades: ", iwd->shades_str, NULL, NULL); else if (type == GRAY) - info_dialog_add_field (info_win, "Shades of Gray: ", iwd->shades_str); + info_dialog_add_field (info_win, "Shades of Gray: ", iwd->shades_str, NULL, NULL); /* update the fields */ info_window_update (info_win, gdisp_ptr); diff --git a/app/gui/info-dialog.c b/app/gui/info-dialog.c index 5513e56262..ac41b6facb 100644 --- a/app/gui/info-dialog.c +++ b/app/gui/info-dialog.c @@ -24,33 +24,55 @@ #include "session.h" /* static functions */ -static InfoField * info_field_new (InfoDialog *, char *, char *); +static InfoField * info_field_new (InfoDialog *, char *, char *, GtkSignalFunc, gpointer); static void update_field (InfoField *); static gint info_dialog_delete_callback (GtkWidget *, GdkEvent *, gpointer); static InfoField * -info_field_new (InfoDialog *idialog, - char *title, - char *text_ptr) +info_field_new (InfoDialog *idialog, + char *title, + char *text_ptr, + GtkSignalFunc callback, + gpointer client_data) { GtkWidget *label; InfoField *field; + int row; field = (InfoField *) g_malloc (sizeof (InfoField)); + row = idialog->nfields + 1; + gtk_table_resize (GTK_TABLE (idialog->info_table), 2, row); + label = gtk_label_new (title); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (idialog->labels), label, FALSE, FALSE, 0); + gtk_table_attach_defaults (GTK_TABLE (idialog->info_table), label, + 0, 1, row - 1, row); - field->w = gtk_label_new (text_ptr); - gtk_misc_set_alignment (GTK_MISC (field->w), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (idialog->values), field->w, FALSE, FALSE, 0); + if (callback == NULL) + { + field->w = gtk_label_new (text_ptr); + gtk_misc_set_alignment (GTK_MISC (field->w), 0.0, 0.5); + } + else + { + field->w = gtk_entry_new (); + gtk_widget_set_usize (field->w, 50, 0); + gtk_entry_set_text (GTK_ENTRY (field->w), text_ptr); + gtk_signal_connect (GTK_OBJECT (field->w), "changed", + GTK_SIGNAL_FUNC (callback), client_data); + } - field->text_ptr = text_ptr; + gtk_table_attach_defaults (GTK_TABLE (idialog->info_table), field->w, + 1, 2, row - 1, row); gtk_widget_show (field->w); gtk_widget_show (label); + field->text_ptr = text_ptr; + field->callback = callback; + field->client_data = client_data; + return field; } @@ -60,12 +82,18 @@ update_field (InfoField *field) gchar *old_text; /* only update the field if its new value differs from the old */ - gtk_label_get (GTK_LABEL (field->w), &old_text); + if (field->callback == NULL) + gtk_label_get (GTK_LABEL (field->w), &old_text); + else + old_text = gtk_entry_get_text (GTK_ENTRY (field->w)); if (strcmp (old_text, field->text_ptr)) { /* set the new value and update somehow */ - gtk_label_set (GTK_LABEL (field->w), field->text_ptr); + if (field->callback == NULL) + gtk_label_set (GTK_LABEL (field->w), field->text_ptr); + else + gtk_entry_set_text (GTK_ENTRY (field->w), field->text_ptr); } } @@ -77,11 +105,11 @@ info_dialog_new (char *title) InfoDialog * idialog; GtkWidget *shell; GtkWidget *vbox; - GtkWidget *labels, *values; - GtkWidget *info_area; + GtkWidget *info_table; idialog = (InfoDialog *) g_malloc (sizeof (InfoDialog)); idialog->field_list = NULL; + idialog->nfields = 0; shell = gtk_dialog_new (); gtk_window_set_wmclass (GTK_WINDOW (shell), "info_dialog", "Gimp"); @@ -96,25 +124,15 @@ info_dialog_new (char *title) gtk_container_border_width (GTK_CONTAINER (vbox), 1); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (shell)->vbox), vbox, TRUE, TRUE, 0); - info_area = gtk_hbox_new (FALSE, 1); - gtk_container_border_width (GTK_CONTAINER (info_area), 5); - gtk_box_pack_start (GTK_BOX (vbox), info_area, TRUE, TRUE, 0); - - labels = gtk_vbox_new (FALSE, 1); - gtk_box_pack_start (GTK_BOX (info_area), labels, TRUE, TRUE, 0); - - values = gtk_vbox_new (FALSE, 1); - gtk_box_pack_start (GTK_BOX (info_area), values, TRUE, TRUE, 0); + info_table = gtk_table_new (0, 0, FALSE); + gtk_container_border_width (GTK_CONTAINER (info_table), 5); + gtk_box_pack_start (GTK_BOX (vbox), info_table, TRUE, TRUE, 0); idialog->shell = shell; idialog->vbox = vbox; - idialog->info_area = info_area; - idialog->labels = labels; - idialog->values = values; + idialog->info_table = info_table; - gtk_widget_show (idialog->labels); - gtk_widget_show (idialog->values); - gtk_widget_show (idialog->info_area); + gtk_widget_show (idialog->info_table); gtk_widget_show (idialog->vbox); return idialog; @@ -150,17 +168,20 @@ info_dialog_free (InfoDialog *idialog) } void -info_dialog_add_field (InfoDialog *idialog, - char *title, - char *text_ptr) +info_dialog_add_field (InfoDialog *idialog, + char *title, + char *text_ptr, + GtkSignalFunc callback, + gpointer data) { InfoField * new_field; if (!idialog) return; - new_field = info_field_new (idialog, title, text_ptr); + new_field = info_field_new (idialog, title, text_ptr, callback, data); idialog->field_list = g_slist_prepend (idialog->field_list, (void *) new_field); + idialog->nfields++; } void diff --git a/app/gui/info-dialog.h b/app/gui/info-dialog.h index e9b2d6f70d..1cf877a7a7 100644 --- a/app/gui/info-dialog.h +++ b/app/gui/info-dialog.h @@ -24,8 +24,10 @@ typedef struct _info_field InfoField; struct _info_field { - GtkWidget *w; - char * text_ptr; + GtkWidget *w; + char *text_ptr; + GtkSignalFunc callback; + gpointer client_data; }; @@ -35,11 +37,10 @@ struct _info_dialog { GtkWidget *shell; GtkWidget *vbox; - GtkWidget *info_area; - GtkWidget *labels; - GtkWidget *values; + GtkWidget *info_table; GSList *field_list; + int nfields; void *user_data; }; @@ -49,7 +50,11 @@ struct _info_dialog InfoDialog * info_dialog_new (char *); void info_dialog_free (InfoDialog *); -void info_dialog_add_field (InfoDialog *, char *, char *); +void info_dialog_add_field (InfoDialog *, + char *, + char *, + GtkSignalFunc, + gpointer); void info_dialog_popup (InfoDialog *); void info_dialog_popdown (InfoDialog *); void info_dialog_update (InfoDialog *); diff --git a/app/gui/info-window.c b/app/gui/info-window.c index b347cda08b..ad024e1cf1 100644 --- a/app/gui/info-window.c +++ b/app/gui/info-window.c @@ -148,17 +148,17 @@ info_window_create (void *gdisp_ptr) iwd->shades_str[0] = '\0'; /* add the information fields */ - info_dialog_add_field (info_win, "Dimensions (w x h): ", iwd->dimensions_str); - info_dialog_add_field (info_win, "Scale Ratio: ", iwd->scale_str); - info_dialog_add_field (info_win, "Display Type: ", iwd->color_type_str); - info_dialog_add_field (info_win, "Visual Class: ", iwd->visual_class_str); - info_dialog_add_field (info_win, "Visual Depth: ", iwd->visual_depth_str); + info_dialog_add_field (info_win, "Dimensions (w x h): ", iwd->dimensions_str, NULL, NULL); + info_dialog_add_field (info_win, "Scale Ratio: ", iwd->scale_str, NULL, NULL); + info_dialog_add_field (info_win, "Display Type: ", iwd->color_type_str, NULL, NULL); + info_dialog_add_field (info_win, "Visual Class: ", iwd->visual_class_str, NULL, NULL); + info_dialog_add_field (info_win, "Visual Depth: ", iwd->visual_depth_str, NULL, NULL); if (type == RGB) - info_dialog_add_field (info_win, "Shades of Color: ", iwd->shades_str); + info_dialog_add_field (info_win, "Shades of Color: ", iwd->shades_str, NULL, NULL); else if (type == INDEXED) - info_dialog_add_field (info_win, "Shades: ", iwd->shades_str); + info_dialog_add_field (info_win, "Shades: ", iwd->shades_str, NULL, NULL); else if (type == GRAY) - info_dialog_add_field (info_win, "Shades of Gray: ", iwd->shades_str); + info_dialog_add_field (info_win, "Shades of Gray: ", iwd->shades_str, NULL, NULL); /* update the fields */ info_window_update (info_win, gdisp_ptr); diff --git a/app/info_dialog.c b/app/info_dialog.c index 5513e56262..ac41b6facb 100644 --- a/app/info_dialog.c +++ b/app/info_dialog.c @@ -24,33 +24,55 @@ #include "session.h" /* static functions */ -static InfoField * info_field_new (InfoDialog *, char *, char *); +static InfoField * info_field_new (InfoDialog *, char *, char *, GtkSignalFunc, gpointer); static void update_field (InfoField *); static gint info_dialog_delete_callback (GtkWidget *, GdkEvent *, gpointer); static InfoField * -info_field_new (InfoDialog *idialog, - char *title, - char *text_ptr) +info_field_new (InfoDialog *idialog, + char *title, + char *text_ptr, + GtkSignalFunc callback, + gpointer client_data) { GtkWidget *label; InfoField *field; + int row; field = (InfoField *) g_malloc (sizeof (InfoField)); + row = idialog->nfields + 1; + gtk_table_resize (GTK_TABLE (idialog->info_table), 2, row); + label = gtk_label_new (title); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (idialog->labels), label, FALSE, FALSE, 0); + gtk_table_attach_defaults (GTK_TABLE (idialog->info_table), label, + 0, 1, row - 1, row); - field->w = gtk_label_new (text_ptr); - gtk_misc_set_alignment (GTK_MISC (field->w), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (idialog->values), field->w, FALSE, FALSE, 0); + if (callback == NULL) + { + field->w = gtk_label_new (text_ptr); + gtk_misc_set_alignment (GTK_MISC (field->w), 0.0, 0.5); + } + else + { + field->w = gtk_entry_new (); + gtk_widget_set_usize (field->w, 50, 0); + gtk_entry_set_text (GTK_ENTRY (field->w), text_ptr); + gtk_signal_connect (GTK_OBJECT (field->w), "changed", + GTK_SIGNAL_FUNC (callback), client_data); + } - field->text_ptr = text_ptr; + gtk_table_attach_defaults (GTK_TABLE (idialog->info_table), field->w, + 1, 2, row - 1, row); gtk_widget_show (field->w); gtk_widget_show (label); + field->text_ptr = text_ptr; + field->callback = callback; + field->client_data = client_data; + return field; } @@ -60,12 +82,18 @@ update_field (InfoField *field) gchar *old_text; /* only update the field if its new value differs from the old */ - gtk_label_get (GTK_LABEL (field->w), &old_text); + if (field->callback == NULL) + gtk_label_get (GTK_LABEL (field->w), &old_text); + else + old_text = gtk_entry_get_text (GTK_ENTRY (field->w)); if (strcmp (old_text, field->text_ptr)) { /* set the new value and update somehow */ - gtk_label_set (GTK_LABEL (field->w), field->text_ptr); + if (field->callback == NULL) + gtk_label_set (GTK_LABEL (field->w), field->text_ptr); + else + gtk_entry_set_text (GTK_ENTRY (field->w), field->text_ptr); } } @@ -77,11 +105,11 @@ info_dialog_new (char *title) InfoDialog * idialog; GtkWidget *shell; GtkWidget *vbox; - GtkWidget *labels, *values; - GtkWidget *info_area; + GtkWidget *info_table; idialog = (InfoDialog *) g_malloc (sizeof (InfoDialog)); idialog->field_list = NULL; + idialog->nfields = 0; shell = gtk_dialog_new (); gtk_window_set_wmclass (GTK_WINDOW (shell), "info_dialog", "Gimp"); @@ -96,25 +124,15 @@ info_dialog_new (char *title) gtk_container_border_width (GTK_CONTAINER (vbox), 1); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (shell)->vbox), vbox, TRUE, TRUE, 0); - info_area = gtk_hbox_new (FALSE, 1); - gtk_container_border_width (GTK_CONTAINER (info_area), 5); - gtk_box_pack_start (GTK_BOX (vbox), info_area, TRUE, TRUE, 0); - - labels = gtk_vbox_new (FALSE, 1); - gtk_box_pack_start (GTK_BOX (info_area), labels, TRUE, TRUE, 0); - - values = gtk_vbox_new (FALSE, 1); - gtk_box_pack_start (GTK_BOX (info_area), values, TRUE, TRUE, 0); + info_table = gtk_table_new (0, 0, FALSE); + gtk_container_border_width (GTK_CONTAINER (info_table), 5); + gtk_box_pack_start (GTK_BOX (vbox), info_table, TRUE, TRUE, 0); idialog->shell = shell; idialog->vbox = vbox; - idialog->info_area = info_area; - idialog->labels = labels; - idialog->values = values; + idialog->info_table = info_table; - gtk_widget_show (idialog->labels); - gtk_widget_show (idialog->values); - gtk_widget_show (idialog->info_area); + gtk_widget_show (idialog->info_table); gtk_widget_show (idialog->vbox); return idialog; @@ -150,17 +168,20 @@ info_dialog_free (InfoDialog *idialog) } void -info_dialog_add_field (InfoDialog *idialog, - char *title, - char *text_ptr) +info_dialog_add_field (InfoDialog *idialog, + char *title, + char *text_ptr, + GtkSignalFunc callback, + gpointer data) { InfoField * new_field; if (!idialog) return; - new_field = info_field_new (idialog, title, text_ptr); + new_field = info_field_new (idialog, title, text_ptr, callback, data); idialog->field_list = g_slist_prepend (idialog->field_list, (void *) new_field); + idialog->nfields++; } void diff --git a/app/info_dialog.h b/app/info_dialog.h index e9b2d6f70d..1cf877a7a7 100644 --- a/app/info_dialog.h +++ b/app/info_dialog.h @@ -24,8 +24,10 @@ typedef struct _info_field InfoField; struct _info_field { - GtkWidget *w; - char * text_ptr; + GtkWidget *w; + char *text_ptr; + GtkSignalFunc callback; + gpointer client_data; }; @@ -35,11 +37,10 @@ struct _info_dialog { GtkWidget *shell; GtkWidget *vbox; - GtkWidget *info_area; - GtkWidget *labels; - GtkWidget *values; + GtkWidget *info_table; GSList *field_list; + int nfields; void *user_data; }; @@ -49,7 +50,11 @@ struct _info_dialog InfoDialog * info_dialog_new (char *); void info_dialog_free (InfoDialog *); -void info_dialog_add_field (InfoDialog *, char *, char *); +void info_dialog_add_field (InfoDialog *, + char *, + char *, + GtkSignalFunc, + gpointer); void info_dialog_popup (InfoDialog *); void info_dialog_popdown (InfoDialog *); void info_dialog_update (InfoDialog *); diff --git a/app/info_window.c b/app/info_window.c index b347cda08b..ad024e1cf1 100644 --- a/app/info_window.c +++ b/app/info_window.c @@ -148,17 +148,17 @@ info_window_create (void *gdisp_ptr) iwd->shades_str[0] = '\0'; /* add the information fields */ - info_dialog_add_field (info_win, "Dimensions (w x h): ", iwd->dimensions_str); - info_dialog_add_field (info_win, "Scale Ratio: ", iwd->scale_str); - info_dialog_add_field (info_win, "Display Type: ", iwd->color_type_str); - info_dialog_add_field (info_win, "Visual Class: ", iwd->visual_class_str); - info_dialog_add_field (info_win, "Visual Depth: ", iwd->visual_depth_str); + info_dialog_add_field (info_win, "Dimensions (w x h): ", iwd->dimensions_str, NULL, NULL); + info_dialog_add_field (info_win, "Scale Ratio: ", iwd->scale_str, NULL, NULL); + info_dialog_add_field (info_win, "Display Type: ", iwd->color_type_str, NULL, NULL); + info_dialog_add_field (info_win, "Visual Class: ", iwd->visual_class_str, NULL, NULL); + info_dialog_add_field (info_win, "Visual Depth: ", iwd->visual_depth_str, NULL, NULL); if (type == RGB) - info_dialog_add_field (info_win, "Shades of Color: ", iwd->shades_str); + info_dialog_add_field (info_win, "Shades of Color: ", iwd->shades_str, NULL, NULL); else if (type == INDEXED) - info_dialog_add_field (info_win, "Shades: ", iwd->shades_str); + info_dialog_add_field (info_win, "Shades: ", iwd->shades_str, NULL, NULL); else if (type == GRAY) - info_dialog_add_field (info_win, "Shades of Gray: ", iwd->shades_str); + info_dialog_add_field (info_win, "Shades of Gray: ", iwd->shades_str, NULL, NULL); /* update the fields */ info_window_update (info_win, gdisp_ptr); diff --git a/app/ink.c b/app/ink.c index cbcab3ade2..26a323ca94 100644 --- a/app/ink.c +++ b/app/ink.c @@ -160,6 +160,11 @@ create_ink_options () /* the main vbox */ vbox = gtk_vbox_new (FALSE, 1); + /* the main label */ + label = gtk_label_new ("Ink Options"); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + /* size slider */ hbox = gtk_hbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0); diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c index cbcab3ade2..26a323ca94 100644 --- a/app/paint/gimpink.c +++ b/app/paint/gimpink.c @@ -160,6 +160,11 @@ create_ink_options () /* the main vbox */ vbox = gtk_vbox_new (FALSE, 1); + /* the main label */ + label = gtk_label_new ("Ink Options"); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + /* size slider */ hbox = gtk_hbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0); diff --git a/app/perspective_tool.c b/app/perspective_tool.c index 9df1fa6971..4c6b482f77 100644 --- a/app/perspective_tool.c +++ b/app/perspective_tool.c @@ -70,11 +70,11 @@ perspective_tool_transform (tool, gdisp_ptr, state) { transform_info = info_dialog_new ("Perspective Transform Information"); info_dialog_add_field (transform_info, "Matrix: ", - matrix_row_buf[0]); + matrix_row_buf[0], NULL, NULL); info_dialog_add_field (transform_info, " ", - matrix_row_buf[1]); + matrix_row_buf[1], NULL, NULL); info_dialog_add_field (transform_info, " ", - matrix_row_buf[2]); + matrix_row_buf[2], NULL, NULL); } transform_core->trans_info [X0] = (double) transform_core->x1; @@ -212,7 +212,6 @@ perspective_tool_motion (tool, gdisp_ptr) } } - static void * perspective_tool_recalc (tool, gdisp_ptr) Tool * tool; diff --git a/app/rect_select.c b/app/rect_select.c index 0668fddc61..3fe8721a15 100644 --- a/app/rect_select.c +++ b/app/rect_select.c @@ -185,7 +185,7 @@ create_selection_options (ToolType tool_type) /* Widgets for fixed size select */ if (tool_type == RECT_SELECT || tool_type == ELLIPSE_SELECT) { - fixed_size_toggle = gtk_check_button_new_with_label ("Fixed size"); + fixed_size_toggle = gtk_check_button_new_with_label ("Fixed size / aspect ratio"); gtk_box_pack_start (GTK_BOX(vbox), fixed_size_toggle, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT(fixed_size_toggle), "toggled", (GtkSignalFunc)selection_toggle_update, diff --git a/app/rotate_tool.c b/app/rotate_tool.c index d7c1d58703..13d9d5398f 100644 --- a/app/rotate_tool.c +++ b/app/rotate_tool.c @@ -58,6 +58,12 @@ static void rotate_tool_motion (Tool *, void *); static void rotate_info_update (Tool *); static Argument * rotate_invoker (Argument *); +/* callback functions for the info dialog entries */ +static void rotate_angle_changed (GtkWidget *entry, gpointer data); +static void rotate_center_x_changed (GtkWidget *entry, gpointer data); +static void rotate_center_y_changed (GtkWidget *entry, gpointer data); + + void * rotate_tool_transform (tool, gdisp_ptr, state) Tool * tool; @@ -76,9 +82,9 @@ rotate_tool_transform (tool, gdisp_ptr, state) if (!transform_info) { transform_info = info_dialog_new ("Rotation Information"); - info_dialog_add_field (transform_info, "Angle: ", angle_buf); - info_dialog_add_field (transform_info, "Center X: ", center_x_buf); - info_dialog_add_field (transform_info, "Center Y: ", center_y_buf); + info_dialog_add_field (transform_info, "Angle: ", angle_buf, (GtkSignalFunc) rotate_angle_changed, tool); + info_dialog_add_field (transform_info, "Center X: ", center_x_buf, (GtkSignalFunc) rotate_center_x_changed, tool); + info_dialog_add_field (transform_info, "Center Y: ", center_y_buf, (GtkSignalFunc) rotate_center_y_changed, tool); } transform_core->trans_info[ANGLE] = 0.0; @@ -145,12 +151,10 @@ static void rotate_info_update (tool) Tool * tool; { - GDisplay * gdisp; TransformCore * transform_core; double angle; int cx, cy; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; angle = (transform_core->trans_info[ANGLE] * 180.0) / M_PI; @@ -165,6 +169,102 @@ rotate_info_update (tool) info_dialog_popup (transform_info); } +static void +rotate_angle_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + GDisplay * gdisp; + TransformCore * transform_core; + gchar *str; + double value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (atof(str) * M_PI) / 180.0; + + if (value != transform_core->trans_info[ANGLE]) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[ANGLE] = value; + rotate_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + +static void +rotate_center_x_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + GDisplay * gdisp; + TransformCore * transform_core; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != transform_core->cx) + { + draw_core_pause (transform_core->core, tool); + transform_core->cx = value; + rotate_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + +static void +rotate_center_y_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + GDisplay * gdisp; + TransformCore * transform_core; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != transform_core->cy) + { + draw_core_pause (transform_core->core, tool); + transform_core->cy = value; + rotate_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + static void rotate_tool_motion (tool, gdisp_ptr) Tool * tool; diff --git a/app/scale_tool.c b/app/scale_tool.c index 4f2e780a16..2c595ea639 100644 --- a/app/scale_tool.c +++ b/app/scale_tool.c @@ -51,6 +51,10 @@ static void scale_tool_motion (Tool *, void *); static void scale_info_update (Tool *); static Argument * scale_invoker (Argument *); +/* callback functions for the info dialog entries */ +static void scale_width_changed (GtkWidget *entry, gpointer data); +static void scale_height_changed (GtkWidget *entry, gpointer data); + void * scale_tool_transform (tool, gdisp_ptr, state) Tool * tool; @@ -69,12 +73,12 @@ scale_tool_transform (tool, gdisp_ptr, state) if (!transform_info) { transform_info = info_dialog_new ("Scaling Information"); - info_dialog_add_field (transform_info, "Original Width: ", orig_width_buf); - info_dialog_add_field (transform_info, "Original Height: ", orig_height_buf); - info_dialog_add_field (transform_info, "Current Width: ", width_buf); - info_dialog_add_field (transform_info, "Current Height: ", height_buf); - info_dialog_add_field (transform_info, "X Scale Ratio: ", x_ratio_buf); - info_dialog_add_field (transform_info, "Y Scale Ratio: ", y_ratio_buf); + info_dialog_add_field (transform_info, "Original Width: ", orig_width_buf, NULL, NULL); + info_dialog_add_field (transform_info, "Original Height: ", orig_height_buf, NULL, NULL); + info_dialog_add_field (transform_info, "Current Width: ", width_buf, scale_width_changed, tool); + info_dialog_add_field (transform_info, "Current Height: ", height_buf, scale_height_changed, tool); + info_dialog_add_field (transform_info, "X Scale Ratio: ", x_ratio_buf, NULL, NULL); + info_dialog_add_field (transform_info, "Y Scale Ratio: ", y_ratio_buf, NULL, NULL); } transform_core->trans_info [X1] = (double) transform_core->x1; @@ -181,6 +185,70 @@ scale_info_update (tool) info_dialog_popup (transform_info); } +static void +scale_width_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + TransformCore * transform_core; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != (transform_core->trans_info[X2] - transform_core->trans_info[X1])) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[X2] = transform_core->trans_info[X1] + value; + scale_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + +static void +scale_height_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + TransformCore * transform_core; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != (transform_core->trans_info[Y2] - transform_core->trans_info[Y1])) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[Y2] = transform_core->trans_info[Y1] + value; + scale_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + static void scale_tool_motion (tool, gdisp_ptr) Tool * tool; diff --git a/app/shear_tool.c b/app/shear_tool.c index 6f016afd7c..7a75524988 100644 --- a/app/shear_tool.c +++ b/app/shear_tool.c @@ -57,6 +57,10 @@ static void shear_tool_motion (Tool *, void *); static void shear_info_update (Tool *); static Argument * shear_invoker (Argument *); +/* Info dialog callback funtions */ +static void shear_x_mag_changed (GtkWidget *, gpointer); +static void shear_y_mag_changed (GtkWidget *, gpointer); + void * shear_tool_transform (tool, gdisp_ptr, state) Tool * tool; @@ -75,8 +79,8 @@ shear_tool_transform (tool, gdisp_ptr, state) if (!transform_info) { transform_info = info_dialog_new ("Shear Information"); - info_dialog_add_field (transform_info, "X Shear Magnitude: ", xshear_buf); - info_dialog_add_field (transform_info, "Y Shear Magnitude: ", yshear_buf); + info_dialog_add_field (transform_info, "X Shear Magnitude: ", xshear_buf, shear_x_mag_changed, tool); + info_dialog_add_field (transform_info, "Y Shear Magnitude: ", yshear_buf, shear_y_mag_changed, tool); } direction_unknown = 1; transform_core->trans_info[HORZ_OR_VERT] = HORZ; @@ -150,6 +154,69 @@ shear_info_update (tool) info_dialog_popup (transform_info); } +static void +shear_x_mag_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + TransformCore * transform_core; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != transform_core->trans_info[XSHEAR]) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[XSHEAR] = value; + shear_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + +static void +shear_y_mag_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + TransformCore * transform_core; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != transform_core->trans_info[YSHEAR]) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[YSHEAR] = value; + shear_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} static void shear_tool_motion (tool, gdisp_ptr) diff --git a/app/tools/color_picker.c b/app/tools/color_picker.c index 5e16e29f21..fa4c2ff716 100644 --- a/app/tools/color_picker.c +++ b/app/tools/color_picker.c @@ -153,26 +153,26 @@ color_picker_button_press (Tool *tool, switch (drawable_type (active_drawable)) { case RGB_GIMAGE: case RGBA_GIMAGE: - info_dialog_add_field (color_picker_info, "Red", red_buf); - info_dialog_add_field (color_picker_info, "Green", green_buf); - info_dialog_add_field (color_picker_info, "Blue", blue_buf); - info_dialog_add_field (color_picker_info, "Alpha", alpha_buf); - info_dialog_add_field (color_picker_info, "Hex Triplet", hex_buf); + info_dialog_add_field (color_picker_info, "Red", red_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Green", green_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Blue", blue_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Alpha", alpha_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Hex Triplet", hex_buf, NULL, NULL); break; case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: - info_dialog_add_field (color_picker_info, "Index", index_buf); - info_dialog_add_field (color_picker_info, "Alpha", alpha_buf); - info_dialog_add_field (color_picker_info, "Red", red_buf); - info_dialog_add_field (color_picker_info, "Green", green_buf); - info_dialog_add_field (color_picker_info, "Blue", blue_buf); - info_dialog_add_field (color_picker_info, "Hex Triplet", hex_buf); + info_dialog_add_field (color_picker_info, "Index", index_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Alpha", alpha_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Red", red_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Green", green_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Blue", blue_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Hex Triplet", hex_buf, NULL, NULL); break; case GRAY_GIMAGE: case GRAYA_GIMAGE: - info_dialog_add_field (color_picker_info, "Intensity", gray_buf); - info_dialog_add_field (color_picker_info, "Alpha", alpha_buf); - info_dialog_add_field (color_picker_info, "Hex Triplet", hex_buf); + info_dialog_add_field (color_picker_info, "Intensity", gray_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Alpha", alpha_buf, NULL, NULL); + info_dialog_add_field (color_picker_info, "Hex Triplet", hex_buf, NULL, NULL); break; default : diff --git a/app/tools/crop.c b/app/tools/crop.c index c2814fb066..25b2259729 100644 --- a/app/tools/crop.c +++ b/app/tools/crop.c @@ -97,6 +97,12 @@ static void crop_ok_callback (GtkWidget *, gpointer); static void crop_selection_callback (GtkWidget *, gpointer); static void crop_close_callback (GtkWidget *, gpointer); +/* Crop dialog callback funtions */ +static void crop_orig_x_changed (GtkWidget *, gpointer); +static void crop_orig_y_changed (GtkWidget *, gpointer); +static void crop_width_changed (GtkWidget *, gpointer); +static void crop_height_changed (GtkWidget *, gpointer); + static void *crop_options = NULL; static Argument *crop_invoker (Argument *); @@ -719,10 +725,10 @@ crop_info_create (Tool *tool) crop_info = info_dialog_new ("Crop Information"); /* add the information fields */ - info_dialog_add_field (crop_info, "X Origin: ", orig_x_buf); - info_dialog_add_field (crop_info, "Y Origin: ", orig_y_buf); - info_dialog_add_field (crop_info, "Width: ", width_buf); - info_dialog_add_field (crop_info, "Height: ", height_buf); + info_dialog_add_field (crop_info, "X Origin: ", orig_x_buf, crop_orig_x_changed, tool); + info_dialog_add_field (crop_info, "Y Origin: ", orig_y_buf, crop_orig_y_changed, tool); + info_dialog_add_field (crop_info, "Width: ", width_buf, crop_width_changed, tool); + info_dialog_add_field (crop_info, "Height: ", height_buf, crop_height_changed, tool); /* Create the action area */ build_action_area (GTK_DIALOG (crop_info->shell), action_items, 3, 0); @@ -800,6 +806,135 @@ crop_close_callback (GtkWidget *w, tool->state = INACTIVE; } +static void +crop_orig_x_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + Crop * crop; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + crop = (Crop *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != crop->tx1) + { + draw_core_pause (crop->core, tool); + crop->tx2 = crop->tx2 + (value - crop->tx1); + crop->tx1 = value; + crop_recalc (tool, crop); + draw_core_resume (crop->core, tool); + } + + g_free (str); + } +} + +static void +crop_orig_y_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + Crop * crop; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + crop = (Crop *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != crop->ty1) + { + draw_core_pause (crop->core, tool); + crop->ty2 = crop->ty2 + (value - crop->ty1); + crop->ty1 = value; + crop_recalc (tool, crop); + draw_core_resume (crop->core, tool); + } + + g_free (str); + } +} + +static void +crop_width_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + Crop * crop; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + crop = (Crop *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != (crop->tx2 - crop->tx1)); + { + draw_core_pause (crop->core, tool); + crop->tx2 = value + crop->tx1; + crop_recalc (tool, crop); + draw_core_resume (crop->core, tool); + } + + g_free (str); + } +} + +static void +crop_height_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + Crop * crop; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + crop = (Crop *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != (crop->ty2 - crop->ty1)); + { + draw_core_pause (crop->core, tool); + crop->ty2 = value + crop->ty1; + crop_recalc (tool, crop); + draw_core_resume (crop->core, tool); + } + + g_free (str); + } +} /* The procedure definition */ ProcArg crop_args[] = diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c index c2814fb066..25b2259729 100644 --- a/app/tools/gimpcroptool.c +++ b/app/tools/gimpcroptool.c @@ -97,6 +97,12 @@ static void crop_ok_callback (GtkWidget *, gpointer); static void crop_selection_callback (GtkWidget *, gpointer); static void crop_close_callback (GtkWidget *, gpointer); +/* Crop dialog callback funtions */ +static void crop_orig_x_changed (GtkWidget *, gpointer); +static void crop_orig_y_changed (GtkWidget *, gpointer); +static void crop_width_changed (GtkWidget *, gpointer); +static void crop_height_changed (GtkWidget *, gpointer); + static void *crop_options = NULL; static Argument *crop_invoker (Argument *); @@ -719,10 +725,10 @@ crop_info_create (Tool *tool) crop_info = info_dialog_new ("Crop Information"); /* add the information fields */ - info_dialog_add_field (crop_info, "X Origin: ", orig_x_buf); - info_dialog_add_field (crop_info, "Y Origin: ", orig_y_buf); - info_dialog_add_field (crop_info, "Width: ", width_buf); - info_dialog_add_field (crop_info, "Height: ", height_buf); + info_dialog_add_field (crop_info, "X Origin: ", orig_x_buf, crop_orig_x_changed, tool); + info_dialog_add_field (crop_info, "Y Origin: ", orig_y_buf, crop_orig_y_changed, tool); + info_dialog_add_field (crop_info, "Width: ", width_buf, crop_width_changed, tool); + info_dialog_add_field (crop_info, "Height: ", height_buf, crop_height_changed, tool); /* Create the action area */ build_action_area (GTK_DIALOG (crop_info->shell), action_items, 3, 0); @@ -800,6 +806,135 @@ crop_close_callback (GtkWidget *w, tool->state = INACTIVE; } +static void +crop_orig_x_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + Crop * crop; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + crop = (Crop *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != crop->tx1) + { + draw_core_pause (crop->core, tool); + crop->tx2 = crop->tx2 + (value - crop->tx1); + crop->tx1 = value; + crop_recalc (tool, crop); + draw_core_resume (crop->core, tool); + } + + g_free (str); + } +} + +static void +crop_orig_y_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + Crop * crop; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + crop = (Crop *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != crop->ty1) + { + draw_core_pause (crop->core, tool); + crop->ty2 = crop->ty2 + (value - crop->ty1); + crop->ty1 = value; + crop_recalc (tool, crop); + draw_core_resume (crop->core, tool); + } + + g_free (str); + } +} + +static void +crop_width_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + Crop * crop; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + crop = (Crop *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != (crop->tx2 - crop->tx1)); + { + draw_core_pause (crop->core, tool); + crop->tx2 = value + crop->tx1; + crop_recalc (tool, crop); + draw_core_resume (crop->core, tool); + } + + g_free (str); + } +} + +static void +crop_height_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + Crop * crop; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + crop = (Crop *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != (crop->ty2 - crop->ty1)); + { + draw_core_pause (crop->core, tool); + crop->ty2 = value + crop->ty1; + crop_recalc (tool, crop); + draw_core_resume (crop->core, tool); + } + + g_free (str); + } +} /* The procedure definition */ ProcArg crop_args[] = diff --git a/app/tools/gimpinktool.c b/app/tools/gimpinktool.c index cbcab3ade2..26a323ca94 100644 --- a/app/tools/gimpinktool.c +++ b/app/tools/gimpinktool.c @@ -160,6 +160,11 @@ create_ink_options () /* the main vbox */ vbox = gtk_vbox_new (FALSE, 1); + /* the main label */ + label = gtk_label_new ("Ink Options"); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + /* size slider */ hbox = gtk_hbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0); diff --git a/app/tools/gimpperspectivetool.c b/app/tools/gimpperspectivetool.c index 9df1fa6971..4c6b482f77 100644 --- a/app/tools/gimpperspectivetool.c +++ b/app/tools/gimpperspectivetool.c @@ -70,11 +70,11 @@ perspective_tool_transform (tool, gdisp_ptr, state) { transform_info = info_dialog_new ("Perspective Transform Information"); info_dialog_add_field (transform_info, "Matrix: ", - matrix_row_buf[0]); + matrix_row_buf[0], NULL, NULL); info_dialog_add_field (transform_info, " ", - matrix_row_buf[1]); + matrix_row_buf[1], NULL, NULL); info_dialog_add_field (transform_info, " ", - matrix_row_buf[2]); + matrix_row_buf[2], NULL, NULL); } transform_core->trans_info [X0] = (double) transform_core->x1; @@ -212,7 +212,6 @@ perspective_tool_motion (tool, gdisp_ptr) } } - static void * perspective_tool_recalc (tool, gdisp_ptr) Tool * tool; diff --git a/app/tools/gimprectselecttool.c b/app/tools/gimprectselecttool.c index 0668fddc61..3fe8721a15 100644 --- a/app/tools/gimprectselecttool.c +++ b/app/tools/gimprectselecttool.c @@ -185,7 +185,7 @@ create_selection_options (ToolType tool_type) /* Widgets for fixed size select */ if (tool_type == RECT_SELECT || tool_type == ELLIPSE_SELECT) { - fixed_size_toggle = gtk_check_button_new_with_label ("Fixed size"); + fixed_size_toggle = gtk_check_button_new_with_label ("Fixed size / aspect ratio"); gtk_box_pack_start (GTK_BOX(vbox), fixed_size_toggle, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT(fixed_size_toggle), "toggled", (GtkSignalFunc)selection_toggle_update, diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c index d7c1d58703..13d9d5398f 100644 --- a/app/tools/gimprotatetool.c +++ b/app/tools/gimprotatetool.c @@ -58,6 +58,12 @@ static void rotate_tool_motion (Tool *, void *); static void rotate_info_update (Tool *); static Argument * rotate_invoker (Argument *); +/* callback functions for the info dialog entries */ +static void rotate_angle_changed (GtkWidget *entry, gpointer data); +static void rotate_center_x_changed (GtkWidget *entry, gpointer data); +static void rotate_center_y_changed (GtkWidget *entry, gpointer data); + + void * rotate_tool_transform (tool, gdisp_ptr, state) Tool * tool; @@ -76,9 +82,9 @@ rotate_tool_transform (tool, gdisp_ptr, state) if (!transform_info) { transform_info = info_dialog_new ("Rotation Information"); - info_dialog_add_field (transform_info, "Angle: ", angle_buf); - info_dialog_add_field (transform_info, "Center X: ", center_x_buf); - info_dialog_add_field (transform_info, "Center Y: ", center_y_buf); + info_dialog_add_field (transform_info, "Angle: ", angle_buf, (GtkSignalFunc) rotate_angle_changed, tool); + info_dialog_add_field (transform_info, "Center X: ", center_x_buf, (GtkSignalFunc) rotate_center_x_changed, tool); + info_dialog_add_field (transform_info, "Center Y: ", center_y_buf, (GtkSignalFunc) rotate_center_y_changed, tool); } transform_core->trans_info[ANGLE] = 0.0; @@ -145,12 +151,10 @@ static void rotate_info_update (tool) Tool * tool; { - GDisplay * gdisp; TransformCore * transform_core; double angle; int cx, cy; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; angle = (transform_core->trans_info[ANGLE] * 180.0) / M_PI; @@ -165,6 +169,102 @@ rotate_info_update (tool) info_dialog_popup (transform_info); } +static void +rotate_angle_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + GDisplay * gdisp; + TransformCore * transform_core; + gchar *str; + double value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (atof(str) * M_PI) / 180.0; + + if (value != transform_core->trans_info[ANGLE]) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[ANGLE] = value; + rotate_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + +static void +rotate_center_x_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + GDisplay * gdisp; + TransformCore * transform_core; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != transform_core->cx) + { + draw_core_pause (transform_core->core, tool); + transform_core->cx = value; + rotate_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + +static void +rotate_center_y_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + GDisplay * gdisp; + TransformCore * transform_core; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != transform_core->cy) + { + draw_core_pause (transform_core->core, tool); + transform_core->cy = value; + rotate_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + static void rotate_tool_motion (tool, gdisp_ptr) Tool * tool; diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c index 4f2e780a16..2c595ea639 100644 --- a/app/tools/gimpscaletool.c +++ b/app/tools/gimpscaletool.c @@ -51,6 +51,10 @@ static void scale_tool_motion (Tool *, void *); static void scale_info_update (Tool *); static Argument * scale_invoker (Argument *); +/* callback functions for the info dialog entries */ +static void scale_width_changed (GtkWidget *entry, gpointer data); +static void scale_height_changed (GtkWidget *entry, gpointer data); + void * scale_tool_transform (tool, gdisp_ptr, state) Tool * tool; @@ -69,12 +73,12 @@ scale_tool_transform (tool, gdisp_ptr, state) if (!transform_info) { transform_info = info_dialog_new ("Scaling Information"); - info_dialog_add_field (transform_info, "Original Width: ", orig_width_buf); - info_dialog_add_field (transform_info, "Original Height: ", orig_height_buf); - info_dialog_add_field (transform_info, "Current Width: ", width_buf); - info_dialog_add_field (transform_info, "Current Height: ", height_buf); - info_dialog_add_field (transform_info, "X Scale Ratio: ", x_ratio_buf); - info_dialog_add_field (transform_info, "Y Scale Ratio: ", y_ratio_buf); + info_dialog_add_field (transform_info, "Original Width: ", orig_width_buf, NULL, NULL); + info_dialog_add_field (transform_info, "Original Height: ", orig_height_buf, NULL, NULL); + info_dialog_add_field (transform_info, "Current Width: ", width_buf, scale_width_changed, tool); + info_dialog_add_field (transform_info, "Current Height: ", height_buf, scale_height_changed, tool); + info_dialog_add_field (transform_info, "X Scale Ratio: ", x_ratio_buf, NULL, NULL); + info_dialog_add_field (transform_info, "Y Scale Ratio: ", y_ratio_buf, NULL, NULL); } transform_core->trans_info [X1] = (double) transform_core->x1; @@ -181,6 +185,70 @@ scale_info_update (tool) info_dialog_popup (transform_info); } +static void +scale_width_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + TransformCore * transform_core; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != (transform_core->trans_info[X2] - transform_core->trans_info[X1])) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[X2] = transform_core->trans_info[X1] + value; + scale_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + +static void +scale_height_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + TransformCore * transform_core; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != (transform_core->trans_info[Y2] - transform_core->trans_info[Y1])) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[Y2] = transform_core->trans_info[Y1] + value; + scale_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + static void scale_tool_motion (tool, gdisp_ptr) Tool * tool; diff --git a/app/tools/gimpsheartool.c b/app/tools/gimpsheartool.c index 6f016afd7c..7a75524988 100644 --- a/app/tools/gimpsheartool.c +++ b/app/tools/gimpsheartool.c @@ -57,6 +57,10 @@ static void shear_tool_motion (Tool *, void *); static void shear_info_update (Tool *); static Argument * shear_invoker (Argument *); +/* Info dialog callback funtions */ +static void shear_x_mag_changed (GtkWidget *, gpointer); +static void shear_y_mag_changed (GtkWidget *, gpointer); + void * shear_tool_transform (tool, gdisp_ptr, state) Tool * tool; @@ -75,8 +79,8 @@ shear_tool_transform (tool, gdisp_ptr, state) if (!transform_info) { transform_info = info_dialog_new ("Shear Information"); - info_dialog_add_field (transform_info, "X Shear Magnitude: ", xshear_buf); - info_dialog_add_field (transform_info, "Y Shear Magnitude: ", yshear_buf); + info_dialog_add_field (transform_info, "X Shear Magnitude: ", xshear_buf, shear_x_mag_changed, tool); + info_dialog_add_field (transform_info, "Y Shear Magnitude: ", yshear_buf, shear_y_mag_changed, tool); } direction_unknown = 1; transform_core->trans_info[HORZ_OR_VERT] = HORZ; @@ -150,6 +154,69 @@ shear_info_update (tool) info_dialog_popup (transform_info); } +static void +shear_x_mag_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + TransformCore * transform_core; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != transform_core->trans_info[XSHEAR]) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[XSHEAR] = value; + shear_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + +static void +shear_y_mag_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + TransformCore * transform_core; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != transform_core->trans_info[YSHEAR]) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[YSHEAR] = value; + shear_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} static void shear_tool_motion (tool, gdisp_ptr) diff --git a/app/tools/ink.c b/app/tools/ink.c index cbcab3ade2..26a323ca94 100644 --- a/app/tools/ink.c +++ b/app/tools/ink.c @@ -160,6 +160,11 @@ create_ink_options () /* the main vbox */ vbox = gtk_vbox_new (FALSE, 1); + /* the main label */ + label = gtk_label_new ("Ink Options"); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + /* size slider */ hbox = gtk_hbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0); diff --git a/app/tools/perspective_tool.c b/app/tools/perspective_tool.c index 9df1fa6971..4c6b482f77 100644 --- a/app/tools/perspective_tool.c +++ b/app/tools/perspective_tool.c @@ -70,11 +70,11 @@ perspective_tool_transform (tool, gdisp_ptr, state) { transform_info = info_dialog_new ("Perspective Transform Information"); info_dialog_add_field (transform_info, "Matrix: ", - matrix_row_buf[0]); + matrix_row_buf[0], NULL, NULL); info_dialog_add_field (transform_info, " ", - matrix_row_buf[1]); + matrix_row_buf[1], NULL, NULL); info_dialog_add_field (transform_info, " ", - matrix_row_buf[2]); + matrix_row_buf[2], NULL, NULL); } transform_core->trans_info [X0] = (double) transform_core->x1; @@ -212,7 +212,6 @@ perspective_tool_motion (tool, gdisp_ptr) } } - static void * perspective_tool_recalc (tool, gdisp_ptr) Tool * tool; diff --git a/app/tools/rect_select.c b/app/tools/rect_select.c index 0668fddc61..3fe8721a15 100644 --- a/app/tools/rect_select.c +++ b/app/tools/rect_select.c @@ -185,7 +185,7 @@ create_selection_options (ToolType tool_type) /* Widgets for fixed size select */ if (tool_type == RECT_SELECT || tool_type == ELLIPSE_SELECT) { - fixed_size_toggle = gtk_check_button_new_with_label ("Fixed size"); + fixed_size_toggle = gtk_check_button_new_with_label ("Fixed size / aspect ratio"); gtk_box_pack_start (GTK_BOX(vbox), fixed_size_toggle, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT(fixed_size_toggle), "toggled", (GtkSignalFunc)selection_toggle_update, diff --git a/app/tools/rotate_tool.c b/app/tools/rotate_tool.c index d7c1d58703..13d9d5398f 100644 --- a/app/tools/rotate_tool.c +++ b/app/tools/rotate_tool.c @@ -58,6 +58,12 @@ static void rotate_tool_motion (Tool *, void *); static void rotate_info_update (Tool *); static Argument * rotate_invoker (Argument *); +/* callback functions for the info dialog entries */ +static void rotate_angle_changed (GtkWidget *entry, gpointer data); +static void rotate_center_x_changed (GtkWidget *entry, gpointer data); +static void rotate_center_y_changed (GtkWidget *entry, gpointer data); + + void * rotate_tool_transform (tool, gdisp_ptr, state) Tool * tool; @@ -76,9 +82,9 @@ rotate_tool_transform (tool, gdisp_ptr, state) if (!transform_info) { transform_info = info_dialog_new ("Rotation Information"); - info_dialog_add_field (transform_info, "Angle: ", angle_buf); - info_dialog_add_field (transform_info, "Center X: ", center_x_buf); - info_dialog_add_field (transform_info, "Center Y: ", center_y_buf); + info_dialog_add_field (transform_info, "Angle: ", angle_buf, (GtkSignalFunc) rotate_angle_changed, tool); + info_dialog_add_field (transform_info, "Center X: ", center_x_buf, (GtkSignalFunc) rotate_center_x_changed, tool); + info_dialog_add_field (transform_info, "Center Y: ", center_y_buf, (GtkSignalFunc) rotate_center_y_changed, tool); } transform_core->trans_info[ANGLE] = 0.0; @@ -145,12 +151,10 @@ static void rotate_info_update (tool) Tool * tool; { - GDisplay * gdisp; TransformCore * transform_core; double angle; int cx, cy; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; angle = (transform_core->trans_info[ANGLE] * 180.0) / M_PI; @@ -165,6 +169,102 @@ rotate_info_update (tool) info_dialog_popup (transform_info); } +static void +rotate_angle_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + GDisplay * gdisp; + TransformCore * transform_core; + gchar *str; + double value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (atof(str) * M_PI) / 180.0; + + if (value != transform_core->trans_info[ANGLE]) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[ANGLE] = value; + rotate_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + +static void +rotate_center_x_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + GDisplay * gdisp; + TransformCore * transform_core; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != transform_core->cx) + { + draw_core_pause (transform_core->core, tool); + transform_core->cx = value; + rotate_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + +static void +rotate_center_y_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + GDisplay * gdisp; + TransformCore * transform_core; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != transform_core->cy) + { + draw_core_pause (transform_core->core, tool); + transform_core->cy = value; + rotate_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + static void rotate_tool_motion (tool, gdisp_ptr) Tool * tool; diff --git a/app/tools/scale_tool.c b/app/tools/scale_tool.c index 4f2e780a16..2c595ea639 100644 --- a/app/tools/scale_tool.c +++ b/app/tools/scale_tool.c @@ -51,6 +51,10 @@ static void scale_tool_motion (Tool *, void *); static void scale_info_update (Tool *); static Argument * scale_invoker (Argument *); +/* callback functions for the info dialog entries */ +static void scale_width_changed (GtkWidget *entry, gpointer data); +static void scale_height_changed (GtkWidget *entry, gpointer data); + void * scale_tool_transform (tool, gdisp_ptr, state) Tool * tool; @@ -69,12 +73,12 @@ scale_tool_transform (tool, gdisp_ptr, state) if (!transform_info) { transform_info = info_dialog_new ("Scaling Information"); - info_dialog_add_field (transform_info, "Original Width: ", orig_width_buf); - info_dialog_add_field (transform_info, "Original Height: ", orig_height_buf); - info_dialog_add_field (transform_info, "Current Width: ", width_buf); - info_dialog_add_field (transform_info, "Current Height: ", height_buf); - info_dialog_add_field (transform_info, "X Scale Ratio: ", x_ratio_buf); - info_dialog_add_field (transform_info, "Y Scale Ratio: ", y_ratio_buf); + info_dialog_add_field (transform_info, "Original Width: ", orig_width_buf, NULL, NULL); + info_dialog_add_field (transform_info, "Original Height: ", orig_height_buf, NULL, NULL); + info_dialog_add_field (transform_info, "Current Width: ", width_buf, scale_width_changed, tool); + info_dialog_add_field (transform_info, "Current Height: ", height_buf, scale_height_changed, tool); + info_dialog_add_field (transform_info, "X Scale Ratio: ", x_ratio_buf, NULL, NULL); + info_dialog_add_field (transform_info, "Y Scale Ratio: ", y_ratio_buf, NULL, NULL); } transform_core->trans_info [X1] = (double) transform_core->x1; @@ -181,6 +185,70 @@ scale_info_update (tool) info_dialog_popup (transform_info); } +static void +scale_width_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + TransformCore * transform_core; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != (transform_core->trans_info[X2] - transform_core->trans_info[X1])) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[X2] = transform_core->trans_info[X1] + value; + scale_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + +static void +scale_height_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + TransformCore * transform_core; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != (transform_core->trans_info[Y2] - transform_core->trans_info[Y1])) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[Y2] = transform_core->trans_info[Y1] + value; + scale_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + static void scale_tool_motion (tool, gdisp_ptr) Tool * tool; diff --git a/app/tools/shear_tool.c b/app/tools/shear_tool.c index 6f016afd7c..7a75524988 100644 --- a/app/tools/shear_tool.c +++ b/app/tools/shear_tool.c @@ -57,6 +57,10 @@ static void shear_tool_motion (Tool *, void *); static void shear_info_update (Tool *); static Argument * shear_invoker (Argument *); +/* Info dialog callback funtions */ +static void shear_x_mag_changed (GtkWidget *, gpointer); +static void shear_y_mag_changed (GtkWidget *, gpointer); + void * shear_tool_transform (tool, gdisp_ptr, state) Tool * tool; @@ -75,8 +79,8 @@ shear_tool_transform (tool, gdisp_ptr, state) if (!transform_info) { transform_info = info_dialog_new ("Shear Information"); - info_dialog_add_field (transform_info, "X Shear Magnitude: ", xshear_buf); - info_dialog_add_field (transform_info, "Y Shear Magnitude: ", yshear_buf); + info_dialog_add_field (transform_info, "X Shear Magnitude: ", xshear_buf, shear_x_mag_changed, tool); + info_dialog_add_field (transform_info, "Y Shear Magnitude: ", yshear_buf, shear_y_mag_changed, tool); } direction_unknown = 1; transform_core->trans_info[HORZ_OR_VERT] = HORZ; @@ -150,6 +154,69 @@ shear_info_update (tool) info_dialog_popup (transform_info); } +static void +shear_x_mag_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + TransformCore * transform_core; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != transform_core->trans_info[XSHEAR]) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[XSHEAR] = value; + shear_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} + +static void +shear_y_mag_changed (GtkWidget *w, + gpointer data) +{ + Tool * tool; + TransformCore * transform_core; + GDisplay * gdisp; + gchar *str; + int value; + + tool = (Tool *)data; + + if (tool) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + transform_core = (TransformCore *) tool->private; + + str = g_strdup (gtk_entry_get_text (GTK_ENTRY (w))); + value = (int) atof(str); + + if (value != transform_core->trans_info[YSHEAR]) + { + draw_core_pause (transform_core->core, tool); + transform_core->trans_info[YSHEAR] = value; + shear_tool_recalc (tool, gdisp); + draw_core_resume (transform_core->core, tool); + } + + g_free (str); + } +} static void shear_tool_motion (tool, gdisp_ptr) diff --git a/app/tools/transform_core.c b/app/tools/transform_core.c index ea8924dfe3..6594b6c87b 100644 --- a/app/tools/transform_core.c +++ b/app/tools/transform_core.c @@ -79,8 +79,8 @@ transform_ok_callback (GtkWidget *w, } static void -transform_cancel_callback (GtkWidget *w, - gpointer client_data) +transform_reset_callback (GtkWidget *w, + gpointer client_data) { Tool *tool; TransformCore *transform_core; @@ -106,7 +106,7 @@ transform_cancel_callback (GtkWidget *w, static ActionAreaItem action_items[2] = { { NULL, transform_ok_callback, NULL, NULL }, - { "Cancel", transform_cancel_callback, NULL, NULL }, + { "Reset", transform_reset_callback, NULL, NULL }, }; static char *action_labels[4] = @@ -607,8 +607,8 @@ transform_core_draw (tool) if ((transform_core->grid_coords != NULL) && (transform_core->tgrid_coords != NULL) && ((tool->type != PERSPECTIVE) || - (transform_core->transform[0][0] >=0.0) && - (transform_core->transform[1][1] >=0.0))) + ((transform_core->transform[0][0] >=0.0) && + (transform_core->transform[1][1] >=0.0)))) { gci = 0; @@ -1196,7 +1196,7 @@ transform_core_do (gimage, drawable, float_tiles, interpolation, matrix) y2 = y1 + float_tiles->levels[0].height; /* Find the bounding coordinates */ - if (active_tool && active_tool->type == PERSPECTIVE && transform_tool_clip ()) + if (active_tool && transform_tool_clip ()) { tx1 = x1; ty1 = y1; diff --git a/app/tools/transform_tool.c b/app/tools/transform_tool.c index aad4084744..5bb3d3def0 100644 --- a/app/tools/transform_tool.c +++ b/app/tools/transform_tool.c @@ -125,8 +125,8 @@ create_transform_options (void) /* the new options structure */ options = (TransformOptions *) g_malloc (sizeof (TransformOptions)); options->type = ROTATE; - options->smoothing = 1; - options->clip = 1; + options->smoothing = TRUE; + options->clip = FALSE; options->direction = TRANSFORM_TRADITIONAL; options->grid_size = 32; options->show_grid = TRUE; @@ -238,7 +238,7 @@ create_transform_options (void) gtk_widget_show (grid_density); /* the clip resulting image toggle button */ - toggle = gtk_check_button_new_with_label ("Clip perspective"); + toggle = gtk_check_button_new_with_label ("Clip result"); gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (toggle), "toggled", (GtkSignalFunc) transform_toggle_update, @@ -324,7 +324,7 @@ int transform_tool_smoothing () { if (!transform_options) - return 1; + return TRUE; else return transform_options->smoothing; } @@ -333,7 +333,7 @@ int transform_tool_clip () { if (!transform_options) - return 1; + return FALSE; else return transform_options->clip; } diff --git a/app/transform_core.c b/app/transform_core.c index ea8924dfe3..6594b6c87b 100644 --- a/app/transform_core.c +++ b/app/transform_core.c @@ -79,8 +79,8 @@ transform_ok_callback (GtkWidget *w, } static void -transform_cancel_callback (GtkWidget *w, - gpointer client_data) +transform_reset_callback (GtkWidget *w, + gpointer client_data) { Tool *tool; TransformCore *transform_core; @@ -106,7 +106,7 @@ transform_cancel_callback (GtkWidget *w, static ActionAreaItem action_items[2] = { { NULL, transform_ok_callback, NULL, NULL }, - { "Cancel", transform_cancel_callback, NULL, NULL }, + { "Reset", transform_reset_callback, NULL, NULL }, }; static char *action_labels[4] = @@ -607,8 +607,8 @@ transform_core_draw (tool) if ((transform_core->grid_coords != NULL) && (transform_core->tgrid_coords != NULL) && ((tool->type != PERSPECTIVE) || - (transform_core->transform[0][0] >=0.0) && - (transform_core->transform[1][1] >=0.0))) + ((transform_core->transform[0][0] >=0.0) && + (transform_core->transform[1][1] >=0.0)))) { gci = 0; @@ -1196,7 +1196,7 @@ transform_core_do (gimage, drawable, float_tiles, interpolation, matrix) y2 = y1 + float_tiles->levels[0].height; /* Find the bounding coordinates */ - if (active_tool && active_tool->type == PERSPECTIVE && transform_tool_clip ()) + if (active_tool && transform_tool_clip ()) { tx1 = x1; ty1 = y1; diff --git a/app/transform_tool.c b/app/transform_tool.c index aad4084744..5bb3d3def0 100644 --- a/app/transform_tool.c +++ b/app/transform_tool.c @@ -125,8 +125,8 @@ create_transform_options (void) /* the new options structure */ options = (TransformOptions *) g_malloc (sizeof (TransformOptions)); options->type = ROTATE; - options->smoothing = 1; - options->clip = 1; + options->smoothing = TRUE; + options->clip = FALSE; options->direction = TRANSFORM_TRADITIONAL; options->grid_size = 32; options->show_grid = TRUE; @@ -238,7 +238,7 @@ create_transform_options (void) gtk_widget_show (grid_density); /* the clip resulting image toggle button */ - toggle = gtk_check_button_new_with_label ("Clip perspective"); + toggle = gtk_check_button_new_with_label ("Clip result"); gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (toggle), "toggled", (GtkSignalFunc) transform_toggle_update, @@ -324,7 +324,7 @@ int transform_tool_smoothing () { if (!transform_options) - return 1; + return TRUE; else return transform_options->smoothing; } @@ -333,7 +333,7 @@ int transform_tool_clip () { if (!transform_options) - return 1; + return FALSE; else return transform_options->clip; }