Bug 763734 - better decimal places for physical units.

Compute the ideal decimal precision for cursor position and length
status so that you get the best precision on physical units depending
on the current resolution, yet avoiding over-precision (which can be
misleading). The unit's "digits" value is now used as a minimum
precision only.
This commit is contained in:
Jehan
2016-11-23 18:12:51 +01:00
parent 5da89f0daf
commit f836892314

View File

@ -1345,16 +1345,33 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
}
else /* show real world units */
{
gint w_digits = 0;
gint h_digits = 0;
gint length_digits;
if (image)
{
w_digits = ceil (log10 (image_width /
gimp_pixels_to_units (image_width,
shell->unit,
image_xres)));
h_digits = ceil (log10 (image_width /
gimp_pixels_to_units (image_height,
shell->unit,
image_yres)));
}
w_digits = MAX (w_digits, gimp_unit_get_digits (shell->unit));
h_digits = MAX (h_digits, gimp_unit_get_digits (shell->unit));
length_digits = MAX (w_digits, h_digits);
g_snprintf (statusbar->cursor_format_str,
sizeof (statusbar->cursor_format_str),
"%%s%%.%df%%s%%.%df%%s",
gimp_unit_get_digits (shell->unit),
gimp_unit_get_digits (shell->unit));
w_digits, h_digits);
strcpy (statusbar->cursor_format_str_f, statusbar->cursor_format_str);
g_snprintf (statusbar->length_format_str,
sizeof (statusbar->length_format_str),
"%%s%%.%df%%s",
gimp_unit_get_digits (shell->unit));
"%%s%%.%df%%s", length_digits);
}
gimp_statusbar_update_cursor (statusbar, GIMP_CURSOR_PRECISION_SUBPIXEL,