added GIMP_VIEWABLE_MAX_BUTTON_SIZE GIMP_VIEWABLE_MAX_MENU_SIZE.

2003-10-09  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpviewable.h: added GIMP_VIEWABLE_MAX_BUTTON_SIZE
	GIMP_VIEWABLE_MAX_MENU_SIZE.

	* app/core/gimpviewable.c (gimp_viewable_get_popup_size): smarter
	popup size limitation: limit each axis to 2 * MAX_POPUP_SIZE
	and the area to MAX_POPUP_SIZE ^ 2.

	* app/core/gimpbuffer.c
	* app/core/gimpimage-preview.c
	* app/core/gimpitem-preview.c
	* app/text/gimpfont.c (GimpViewable::get_popup_size): removed
	all limitations.

	* app/widgets/gimpcontainermenu.c
	* app/widgets/gimpcontainermenuimpl.c
	* app/widgets/gimpmenuitem.c
	* app/widgets/gimpviewablebutton.c: use the new button and menu
	size defines.
This commit is contained in:
Michael Natterer 2003-10-09 12:26:46 +00:00 committed by Michael Natterer
parent da2bd8b91a
commit 482aa11bfb
11 changed files with 66 additions and 36 deletions

View File

@ -1,3 +1,24 @@
2003-10-09 Michael Natterer <mitch@gimp.org>
* app/core/gimpviewable.h: added GIMP_VIEWABLE_MAX_BUTTON_SIZE
GIMP_VIEWABLE_MAX_MENU_SIZE.
* app/core/gimpviewable.c (gimp_viewable_get_popup_size): smarter
popup size limitation: limit each axis to 2 * MAX_POPUP_SIZE
and the area to MAX_POPUP_SIZE ^ 2.
* app/core/gimpbuffer.c
* app/core/gimpimage-preview.c
* app/core/gimpitem-preview.c
* app/text/gimpfont.c (GimpViewable::get_popup_size): removed
all limitations.
* app/widgets/gimpcontainermenu.c
* app/widgets/gimpcontainermenuimpl.c
* app/widgets/gimpmenuitem.c
* app/widgets/gimpviewablebutton.c: use the new button and menu
size defines.
2003-10-09 Michael Natterer <mitch@gimp.org>
* app/core/core-types.h: added GimpScanConvert typedef.

View File

@ -198,10 +198,8 @@ gimp_buffer_get_popup_size (GimpViewable *viewable,
gimp_viewable_calc_preview_size (viewable,
buffer_width,
buffer_height,
MIN (width * 2,
GIMP_VIEWABLE_MAX_POPUP_SIZE),
MIN (height * 2,
GIMP_VIEWABLE_MAX_POPUP_SIZE),
width * 2,
height * 2,
dot_for_dot, 1.0, 1.0,
popup_width,
popup_height,

View File

@ -91,10 +91,8 @@ gimp_image_get_popup_size (GimpViewable *viewable,
gimp_viewable_calc_preview_size (viewable,
gimage->width,
gimage->height,
MIN (width * 2,
GIMP_VIEWABLE_MAX_POPUP_SIZE),
MIN (height * 2,
GIMP_VIEWABLE_MAX_POPUP_SIZE),
width * 2,
height * 2,
dot_for_dot, 1.0, 1.0,
popup_width,
popup_height,

View File

@ -111,10 +111,8 @@ gimp_item_get_popup_size (GimpViewable *viewable,
gimp_viewable_calc_preview_size (viewable,
item->width,
item->height,
MIN (width * 2,
GIMP_VIEWABLE_MAX_POPUP_SIZE),
MIN (height * 2,
GIMP_VIEWABLE_MAX_POPUP_SIZE),
width * 2,
height * 2,
dot_for_dot,
gimage ? gimage->xresolution : 1.0,
gimage ? gimage->yresolution : 1.0,

View File

@ -447,26 +447,39 @@ gimp_viewable_get_popup_size (GimpViewable *viewable,
width, height, dot_for_dot,
&w, &h))
{
if (w < 1) w = 1;
if (h < 1) h = 1;
if (w < 1) w = 1;
if (h < 1) h = 1;
if (w > GIMP_VIEWABLE_MAX_POPUP_SIZE ||
h > GIMP_VIEWABLE_MAX_POPUP_SIZE)
/* limit the popup to 2 * GIMP_VIEWABLE_MAX_POPUP_SIZE
* on each axis.
*/
if ((w > (2 * GIMP_VIEWABLE_MAX_POPUP_SIZE)) ||
(h > (2 * 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;
}
gimp_viewable_calc_preview_size (viewable, w, h,
2 * GIMP_VIEWABLE_MAX_POPUP_SIZE,
2 * GIMP_VIEWABLE_MAX_POPUP_SIZE,
dot_for_dot, 1.0, 1.0,
&w, &h, NULL);
}
/* limit the number of pixels to
* GIMP_VIEWABLE_MAX_POPUP_SIZE ^ 2
*/
if ((w * h) > SQR (GIMP_VIEWABLE_MAX_POPUP_SIZE))
{
gdouble factor;
factor = sqrt (((gdouble) (w * h) /
(gdouble) SQR (GIMP_VIEWABLE_MAX_POPUP_SIZE)));
w = RINT ((gdouble) w / factor);
h = RINT ((gdouble) h / factor);
}
if (w < 1) w = 1;
if (h < 1) h = 1;
if (popup_width) *popup_width = w;
if (popup_height) *popup_height = h;

View File

@ -29,7 +29,9 @@
#define GIMP_VIEWABLE_MAX_PREVIEW_SIZE 1024
#define GIMP_VIEWABLE_MAX_POPUP_SIZE 256
#define GIMP_VIEWABLE_MAX_POPUP_SIZE 256
#define GIMP_VIEWABLE_MAX_BUTTON_SIZE 64
#define GIMP_VIEWABLE_MAX_MENU_SIZE 48
#define GIMP_TYPE_VIEWABLE (gimp_viewable_get_type ())

View File

@ -38,7 +38,7 @@
contain all characters found in the alphabet. */
#define GIMP_TEXT_PANGRAM N_("Pack my box with\nfive dozen liquor jugs.")
#define GIMP_FONT_POPUP_SIZE (PANGO_SCALE * 20)
#define GIMP_FONT_POPUP_SIZE (PANGO_SCALE * 30)
enum
@ -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_POPUP_SIZE);
*popup_height = MIN (logical.height + 6, GIMP_VIEWABLE_MAX_POPUP_SIZE);
*popup_width = logical.width + 6;
*popup_height = logical.height + 6;
font->popup_width = *popup_width;
font->popup_height = *popup_height;

View File

@ -334,7 +334,7 @@ gimp_container_menu_set_preview_size (GimpContainerMenu *menu,
{
g_return_if_fail (GIMP_IS_CONTAINER_MENU (menu));
g_return_if_fail (preview_size > 0 &&
preview_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE);
preview_size <= GIMP_VIEWABLE_MAX_MENU_SIZE);
g_return_if_fail (preview_border_width >= 0 &&
preview_border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH);

View File

@ -130,7 +130,7 @@ gimp_container_menu_new (GimpContainer *container,
NULL);
g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (preview_size > 0 &&
preview_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE, NULL);
preview_size <= GIMP_VIEWABLE_MAX_MENU_SIZE, NULL);
g_return_val_if_fail (preview_border_width >= 0 &&
preview_border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH,
NULL);

View File

@ -113,7 +113,7 @@ gimp_menu_item_new (GimpViewable *viewable,
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (preview_size > 0 &&
preview_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE, NULL);
preview_size <= GIMP_VIEWABLE_MAX_MENU_SIZE, NULL);
g_return_val_if_fail (preview_border_width >= 0 &&
preview_border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH,
NULL);

View File

@ -221,7 +221,7 @@ gimp_viewable_button_new (GimpContainer *container,
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (preview_size > 0 &&
preview_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE, NULL);
preview_size <= GIMP_VIEWABLE_MAX_BUTTON_SIZE, NULL);
g_return_val_if_fail (preview_border_width >= 0 &&
preview_border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH,
NULL);