Commit 271fae5f authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added width and height to the info displayed in the statusbar and the info

2005-03-21  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimpmeasuretool.[ch]: added width and height to the
	info displayed in the statusbar and the info window.
	Fixes bug #165275.
parent 89a76c04
2005-03-21 Michael Natterer <mitch@gimp.org>
* app/tools/gimpmeasuretool.[ch]: added width and height to the
info displayed in the statusbar and the info window.
Fixes bug #165275.
2005-03-20 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* libgimpwidgets/gimpcolorscales.c (gimp_color_scales_update_scales):
......
......@@ -733,10 +733,14 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *mtool,
GimpImage *image = gdisp->gimage;
gint ax, ay;
gint bx, by;
gdouble theta1, theta2;
gint pixel_width;
gint pixel_height;
gdouble unit_width;
gdouble unit_height;
gdouble pixel_distance;
gdouble pixel_angle;
gdouble unit_distance;
gdouble theta1, theta2;
gdouble pixel_angle;
gdouble unit_angle;
gchar format[128];
gchar buf[128];
......@@ -756,6 +760,14 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *mtool,
by = 0;
}
pixel_width = ABS (ax - bx);
pixel_height = ABS (ay - by);
unit_width = (_gimp_unit_get_factor (image->gimp, shell->unit) *
pixel_width / image->xresolution);
unit_height = (_gimp_unit_get_factor (image->gimp, shell->unit) *
pixel_height / image->yresolution);
pixel_distance = sqrt (SQR (ax - bx) + SQR (ay - by));
unit_distance = (_gimp_unit_get_factor (image->gimp, shell->unit) *
sqrt (SQR ((gdouble)(ax - bx) / image->xresolution) +
......@@ -785,16 +797,21 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *mtool,
if (shell->unit == GIMP_UNIT_PIXEL)
{
g_snprintf (buf, sizeof (buf), "%.1f %s, %.2f \302\260",
pixel_distance, _("pixels"), pixel_angle);
g_snprintf (buf, sizeof (buf), "%.1f %s, %.2f \302\260 (%d x %d)",
pixel_distance, _("pixels"), pixel_angle,
pixel_width, pixel_height);
}
else
{
g_snprintf (format, sizeof (format), "%%.%df %s, %%.2f \302\260",
g_snprintf (format, sizeof (format),
"%%.%df %s, %%.2f \302\260 (%%.%df x %%.%df)",
_gimp_unit_get_digits (image->gimp, shell->unit),
_gimp_unit_get_plural (image->gimp, shell->unit),
_gimp_unit_get_digits (image->gimp, shell->unit),
_gimp_unit_get_plural (image->gimp, shell->unit));
_gimp_unit_get_digits (image->gimp, shell->unit));
g_snprintf (buf, sizeof (buf), format, unit_distance, unit_angle);
g_snprintf (buf, sizeof (buf), format, unit_distance, unit_angle,
unit_width, unit_height);
}
gimp_tool_pop_status (GIMP_TOOL (mtool));
......@@ -802,20 +819,23 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *mtool,
if (mtool->dialog)
{
g_snprintf (format, sizeof (format), "%%.%df",
_gimp_unit_get_digits (image->gimp, shell->unit));
/* Distance */
g_snprintf (buf, sizeof (buf), "%.1f", pixel_distance);
gtk_label_set_text (GTK_LABEL (mtool->distance_label[0]), buf);
g_snprintf (buf, sizeof (buf), "%.2f", pixel_angle);
gtk_label_set_text (GTK_LABEL (mtool->angle_label[0]), buf);
g_snprintf (format, sizeof (format),
"%%.%df", _gimp_unit_get_digits (image->gimp, shell->unit));
g_snprintf (buf, sizeof (buf), format, unit_distance);
gtk_label_set_text (GTK_LABEL (mtool->distance_label[1]), buf);
gtk_label_set_text (GTK_LABEL (mtool->unit_label[0]),
_gimp_unit_get_plural (image->gimp, shell->unit));
/* Angle */
g_snprintf (buf, sizeof (buf), "%.2f", pixel_angle);
gtk_label_set_text (GTK_LABEL (mtool->angle_label[0]), buf);
if (fabs (unit_angle - pixel_angle) > 0.01)
{
g_snprintf (buf, sizeof (buf), "%.2f", unit_angle);
......@@ -829,6 +849,26 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *mtool,
gtk_label_set_text (GTK_LABEL (mtool->unit_label[1]), " ");
}
/* Width */
g_snprintf (buf, sizeof (buf), "%d", pixel_width);
gtk_label_set_text (GTK_LABEL (mtool->width_label[0]), buf);
g_snprintf (buf, sizeof (buf), format, unit_width);
gtk_label_set_text (GTK_LABEL (mtool->width_label[1]), buf);
gtk_label_set_text (GTK_LABEL (mtool->unit_label[2]),
_gimp_unit_get_plural (image->gimp, shell->unit));
/* Height */
g_snprintf (buf, sizeof (buf), "%d", pixel_height);
gtk_label_set_text (GTK_LABEL (mtool->height_label[0]), buf);
g_snprintf (buf, sizeof (buf), format, unit_height);
gtk_label_set_text (GTK_LABEL (mtool->height_label[1]), buf);
gtk_label_set_text (GTK_LABEL (mtool->unit_label[3]),
_gimp_unit_get_plural (image->gimp, shell->unit));
if (GTK_WIDGET_VISIBLE (mtool->dialog))
gdk_window_show (mtool->dialog->window);
else
......@@ -856,7 +896,7 @@ gimp_measure_tool_dialog_new (GimpMeasureTool *mtool)
G_CALLBACK (gtk_widget_destroy),
NULL);
table = gtk_table_new (2, 5, TRUE);
table = gtk_table_new (4, 5, TRUE);
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_container_set_border_width (GTK_CONTAINER (table), 6);
......@@ -915,5 +955,57 @@ gimp_measure_tool_dialog_new (GimpMeasureTool *mtool)
gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 5, 1, 2);
gtk_widget_show (label);
label = gtk_label_new (_("Width:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3);
gtk_widget_show (label);
mtool->width_label[0] = label = gtk_label_new ("0.0");
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 2, 3);
gtk_widget_show (label);
label = gtk_label_new (_("pixels"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 2, 3);
gtk_widget_show (label);
mtool->width_label[1] = label = gtk_label_new ("0.0");
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 3, 4, 2, 3);
gtk_widget_show (label);
mtool->unit_label[2] = label = gtk_label_new (" ");
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 5, 2, 3);
gtk_widget_show (label);
label = gtk_label_new (_("Height:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4);
gtk_widget_show (label);
mtool->height_label[0] = label = gtk_label_new ("0.0");
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 3, 4);
gtk_widget_show (label);
label = gtk_label_new (_("pixels"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 3, 4);
gtk_widget_show (label);
mtool->height_label[1] = label = gtk_label_new ("0.0");
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 3, 4, 3, 4);
gtk_widget_show (label);
mtool->unit_label[3] = label = gtk_label_new (" ");
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 5, 3, 4);
gtk_widget_show (label);
return dialog;
}
......@@ -63,7 +63,9 @@ struct _GimpMeasureTool
GtkWidget *dialog;
GtkWidget *distance_label[2];
GtkWidget *angle_label[2];
GtkWidget *unit_label[2];
GtkWidget *width_label[2];
GtkWidget *height_label[2];
GtkWidget *unit_label[4];
};
struct _GimpMeasureToolClass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment