Implements Title bar codes for Layer dimensions

Implements codes %x, %y and %X, %Y to display
a layer's size in title and status bars
for image windows.
Addresses request at bug #728493
This commit is contained in:
João S. O. Bueno 2014-04-21 00:30:49 -03:00
parent 23d0eb16d1
commit bb172b52c8
2 changed files with 81 additions and 3 deletions

View File

@ -2008,7 +2008,8 @@ prefs_dialog_new (Gimp *gimp,
NULL,
"%f-%p.%i (%t) %z%%",
"%f-%p.%i (%t) %d:%s",
"%f-%p.%i (%t) %wx%h"
"%f-%p.%i (%t) %wx%h",
"%f-%p-%i (%t) %wx%h (%xx%y)"
};
const gchar *format_names[] =
@ -2017,7 +2018,8 @@ prefs_dialog_new (Gimp *gimp,
N_("Default format"),
N_("Show zoom percentage"),
N_("Show zoom ratio"),
N_("Show image size")
N_("Show image size"),
N_("Show drawable size")
};
struct

View File

@ -410,11 +410,87 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
gimp_unit_get_abbreviation (shell->unit));
break;
case 'X': /* drawable width in real world units */
if (shell->unit != GIMP_UNIT_PIXEL)
{
gdouble xres;
gdouble yres;
gchar unit_format[8];
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
gimp_image_get_resolution (image, &xres, &yres);
g_snprintf (unit_format, sizeof (unit_format), "%%.%df",
gimp_unit_get_digits (shell->unit) + 1);
i += print (title, title_len, i, unit_format,
gimp_pixels_to_units (gimp_item_get_width
(GIMP_ITEM (drawable)),
shell->unit, yres));
break;
}
/* else fallthru */
case 'x': /* drawable width in pixels */
{
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
i += print (title, title_len, i, "%d",
gimp_item_get_width (GIMP_ITEM (drawable)));
}
break;
case 'Y': /* drawable height in real world units */
if (shell->unit != GIMP_UNIT_PIXEL)
{
gdouble xres;
gdouble yres;
gchar unit_format[8];
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
gimp_image_get_resolution (image, &xres, &yres);
g_snprintf (unit_format, sizeof (unit_format), "%%.%df",
gimp_unit_get_digits (shell->unit) + 1);
i += print (title, title_len, i, unit_format,
gimp_pixels_to_units (gimp_item_get_height
(GIMP_ITEM (drawable)),
shell->unit, yres));
break;
}
/* else fallthru */
case 'y': /* drawable height in pixels */
{
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
i += print (title, title_len, i, "%d",
gimp_item_get_height (GIMP_ITEM (drawable)));
}
break;
case '\xc3': /* utf-8 extended char */
{
format ++;
switch (*format)
{
case '\xbe':
{
/* line actually written at 23:55 on an Easter Sunday */
i+= print(title, title_len, i, "42");
}
break;
default:
/* in the case of an unhandled utf-8 extended char format
* leave the format string parsing as it was
*/
format --;
break;
}
}
break;
/* Other cool things to be added:
* %r = xresolution
* %R = yresolution
* %ø = image's fractal dimension
* %þ = the answer to everything
* # %þ = the answer to everything - (implemented)
*/
default: