From 8240ef1ccc231e62689302a2cc05007acf11b10c Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Mon, 22 Sep 2003 14:23:03 +0000 Subject: [PATCH] constrain popup size to GIMP_VIEWABLE_MAX_POPUP_SIZE but keep the aspect 2003-09-22 Sven Neumann * 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. --- ChangeLog | 9 +++++++++ app/core/gimpviewable.c | 21 +++++++++++++++++++-- app/text/gimpfont.c | 10 +++++----- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 388f90ab20..0100755e35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2003-09-22 Sven Neumann + + * 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 * plug-ins/common/svg.c: added a hack to work around the diff --git a/app/core/gimpviewable.c b/app/core/gimpviewable.c index caad9a98f7..798bb2a206 100644 --- a/app/core/gimpviewable.c +++ b/app/core/gimpviewable.c @@ -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; diff --git a/app/text/gimpfont.c b/app/text/gimpfont.c index bf8b5e583e..51d1d808df 100644 --- a/app/text/gimpfont.c +++ b/app/text/gimpfont.c @@ -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;