Commit 14394b2e authored by Sven Neumann's avatar Sven Neumann

We have entries in the info dialog now that allow to enter exact values

for the transformations and crop.

Changed "Clip perspective" to "Clip result" in the ransform tool options
and made it available for all transformations.

Minor cosmetic changes to rect_select and ink option dialogs.


--Sven
parent e6568759
Sat Aug 15 15:27:39 MEST 1998 Sven Neumann <sven@gimp.org>
* 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 <adrian@gimp.org>
* plugins/script-fu/scripts/select_to_brush.scm,
......
......@@ -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 :
......
......@@ -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[] =
......
......@@ -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
......
......@@ -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 *);
......
......@@ -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);
......
......@@ -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
......
......@@ -24,8 +24,10 @@ typedef struct _info_field InfoField;