constrain popup size to GIMP_VIEWABLE_MAX_POPUP_SIZE but keep the aspect

2003-09-22  Sven Neumann  <sven@gimp.org>

	* app/core/gimpviewable.c (gimp_viewable_get_popup_size):
	constrain popup size to GIMP_VIEWABLE_MAX_POPUP_SIZE but keep the
	aspect ratio intact. Fixes bug #122923.

	* app/text/gimpfont.c: use a smaller font size for popups so we
	don't exceed the maximum size.
This commit is contained in:
Sven Neumann 2003-09-22 14:23:03 +00:00 committed by Sven Neumann
parent 7440dfd8fc
commit 8240ef1ccc
3 changed files with 33 additions and 7 deletions

View File

@ -1,3 +1,12 @@
2003-09-22 Sven Neumann <sven@gimp.org>
* app/core/gimpviewable.c (gimp_viewable_get_popup_size):
constrain popup size to GIMP_VIEWABLE_MAX_POPUP_SIZE but keep the
aspect ratio intact. Fixes bug #122923.
* app/text/gimpfont.c: use a smaller font size for popups so we
don't exceed the maximum size.
2003-09-22 Sven Neumann <sven@gimp.org>
* plug-ins/common/svg.c: added a hack to work around the

View File

@ -447,8 +447,25 @@ gimp_viewable_get_popup_size (GimpViewable *viewable,
width, height, dot_for_dot,
&w, &h))
{
w = MIN (w, GIMP_VIEWABLE_MAX_PREVIEW_SIZE);
h = MIN (h, GIMP_VIEWABLE_MAX_PREVIEW_SIZE);
if (w < 1) w = 1;
if (h < 1) h = 1;
if (w > GIMP_VIEWABLE_MAX_POPUP_SIZE ||
h > GIMP_VIEWABLE_MAX_POPUP_SIZE)
{
gdouble aspect = w / h;
if (w > h)
{
w = GIMP_VIEWABLE_MAX_POPUP_SIZE;
h = w / aspect;
}
else
{
h = GIMP_VIEWABLE_MAX_POPUP_SIZE;
w = h * aspect;
}
}
if (popup_width) *popup_width = w;
if (popup_height) *popup_height = h;

View File

@ -36,9 +36,9 @@
/* This is a so-called pangram; it's supposed to
contain all characters found in the alphabet. */
#define GIMP_TEXT_PANGRAM N_("Pack my box with\nfive dozen liquor jugs.")
#define GIMP_TEXT_PANGRAM N_("Pack my box with\nfive dozen liquor jugs.")
#define GIMP_FONT_POPUP_SIZE (PANGO_SCALE * 32)
#define GIMP_FONT_POPUP_SIZE (PANGO_SCALE * 20)
enum
@ -197,7 +197,7 @@ gimp_font_set_property (GObject *object,
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
}
static void
gimp_font_get_preview_size (GimpViewable *viewable,
@ -247,8 +247,8 @@ gimp_font_get_popup_size (GimpViewable *viewable,
pango_layout_set_text (font->popup_layout, gettext (GIMP_TEXT_PANGRAM), -1);
pango_layout_get_pixel_extents (font->popup_layout, NULL, &logical);
*popup_width = MIN (logical.width + 6, GIMP_VIEWABLE_MAX_PREVIEW_SIZE);
*popup_height = MIN (logical.height + 6, GIMP_VIEWABLE_MAX_PREVIEW_SIZE);
*popup_width = MIN (logical.width + 6, GIMP_VIEWABLE_MAX_POPUP_SIZE);
*popup_height = MIN (logical.height + 6, GIMP_VIEWABLE_MAX_POPUP_SIZE);
font->popup_width = *popup_width;
font->popup_height = *popup_height;