app/core/gimpdrawable-preview.c return square dimensions in

2003-03-22  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpdrawable-preview.c
	* app/core/gimpimage.c (get_preview_size): return square
	dimensions in config->layer_previews is FALSE (except if the size
	is requested for a popup).
	(get_popup_size): don't crete popups if config->layer_previews
	is FALSE.

	* app/core/gimpimage.c: added utility function
	gimp_image_previews_resize() and call it on "notify::layer-previews".
	Calls gimp_viewable_size_changed() on all drawables of the image
	and on the image itself. Ensures that drawable/image previews
	toggle their size correctly when toggling layer_previews.

	* app/widgets/gimpselectioneditor.c: create the selection preview
	as a popup so it keeps the image's aspect ratio when
	layer_previews is FALSE.
This commit is contained in:
Michael Natterer 2003-03-22 22:53:29 +00:00 committed by Michael Natterer
parent a8ccd18b81
commit 06a2f8b110
4 changed files with 78 additions and 18 deletions

View File

@ -1,3 +1,22 @@
2003-03-22 Michael Natterer <mitch@gimp.org>
* app/core/gimpdrawable-preview.c
* app/core/gimpimage.c (get_preview_size): return square
dimensions in config->layer_previews is FALSE (except if the size
is requested for a popup).
(get_popup_size): don't crete popups if config->layer_previews
is FALSE.
* app/core/gimpimage.c: added utility function
gimp_image_previews_resize() and call it on "notify::layer-previews".
Calls gimp_viewable_size_changed() on all drawables of the image
and on the image itself. Ensures that drawable/image previews
toggle their size correctly when toggling layer_previews.
* app/widgets/gimpselectioneditor.c: create the selection preview
as a popup so it keeps the image's aspect ratio when
layer_previews is FALSE.
2003-03-22 Sven Neumann <sven@gimp.org>
* themes/Default/images/Makefile.am

View File

@ -71,6 +71,13 @@ gimp_drawable_get_preview_size (GimpViewable *viewable,
drawable = GIMP_DRAWABLE (viewable);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
if (gimage && ! gimage->gimp->config->layer_previews && ! is_popup)
{
*width = size;
*height = size;
return;
}
if (gimage && ! is_popup)
{
gimp_viewable_calc_preview_size (viewable,
@ -115,6 +122,9 @@ gimp_drawable_get_popup_size (GimpViewable *viewable,
drawable = GIMP_DRAWABLE (viewable);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
if (gimage && ! gimage->gimp->config->layer_previews)
return FALSE;
if (drawable->width > width || drawable->height > height)
{
gboolean scaling_up;
@ -154,8 +164,7 @@ gimp_drawable_get_preview (GimpViewable *viewable,
GimpImage *gimage;
drawable = GIMP_DRAWABLE (viewable);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
if (! gimage || ! gimage->gimp->config->layer_previews)
return NULL;

View File

@ -129,12 +129,13 @@ static TempBuf *gimp_image_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
static void gimp_image_real_colormap_changed (GimpImage *gimage,
gint ncol);
static void gimp_image_get_active_components (const GimpImage *gimage,
const GimpDrawable *drawable,
gboolean *active);
static void gimp_image_real_colormap_changed (GimpImage *gimage,
gint ncol);
static void gimp_image_previews_resize (GimpImage *gimage);
static gint valid_combinations[][MAX_CHANNELS + 1] =
@ -714,6 +715,13 @@ gimp_image_get_preview_size (GimpViewable *viewable,
gimage = GIMP_IMAGE (viewable);
if (! gimage->gimp->config->layer_previews && ! is_popup)
{
*width = size;
*height = size;
return;
}
gimp_viewable_calc_preview_size (viewable,
gimage->width,
gimage->height,
@ -739,6 +747,9 @@ gimp_image_get_popup_size (GimpViewable *viewable,
gimage = GIMP_IMAGE (viewable);
if (! gimage->gimp->config->layer_previews)
return FALSE;
if (gimage->width > width || gimage->height > height)
{
gboolean scaling_up;
@ -1000,6 +1011,19 @@ gimp_image_get_new_preview (GimpViewable *viewable,
return comp;
}
static void
gimp_image_real_colormap_changed (GimpImage *gimage,
gint ncol)
{
if (gimp_image_base_type (gimage) == GIMP_INDEXED)
{
/* A colormap alteration affects the whole image */
gimp_image_update (gimage, 0, 0, gimage->width, gimage->height);
gimp_image_color_hash_invalidate (gimage, ncol);
}
}
static void
gimp_image_get_active_components (const GimpImage *gimage,
const GimpDrawable *drawable,
@ -1030,17 +1054,28 @@ gimp_image_get_active_components (const GimpImage *gimage,
}
}
static void
gimp_image_real_colormap_changed (GimpImage *gimage,
gint ncol)
static void
gimp_image_previews_resize (GimpImage *gimage)
{
if (gimp_image_base_type (gimage) == GIMP_INDEXED)
{
/* A colormap alteration affects the whole image */
gimp_image_update (gimage, 0, 0, gimage->width, gimage->height);
GList *list;
gimp_image_color_hash_invalidate (gimage, ncol);
gimp_container_foreach (gimage->layers,
(GFunc) gimp_viewable_size_changed,
NULL);
gimp_container_foreach (gimage->channels,
(GFunc) gimp_viewable_size_changed,
NULL);
for (list = GIMP_LIST (gimage->layers)->list; list; list = g_list_next (list))
{
GimpLayerMask *mask = gimp_layer_get_mask (GIMP_LAYER (list->data));
if (mask)
gimp_viewable_size_changed (GIMP_VIEWABLE (mask));
}
gimp_viewable_size_changed (GIMP_VIEWABLE (gimp_image_get_mask (gimage)));
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
}
@ -1107,10 +1142,7 @@ gimp_image_new (Gimp *gimp,
G_CALLBACK (gimp_image_invalidate_layer_previews),
gimage, G_CONNECT_SWAPPED);
g_signal_connect_object (gimp->config, "notify::layer-previews",
G_CALLBACK (gimp_image_invalidate_layer_previews),
gimage, G_CONNECT_SWAPPED);
g_signal_connect_object (gimp->config, "notify::layer-previews",
G_CALLBACK (gimp_image_invalidate_channel_previews),
G_CALLBACK (gimp_image_previews_resize),
gimage, G_CONNECT_SWAPPED);
return gimage;

View File

@ -135,7 +135,7 @@ gimp_selection_editor_init (GimpSelectionEditor *selection_editor)
selection_editor->preview = gimp_preview_new_by_types (GIMP_TYPE_PREVIEW,
GIMP_TYPE_DRAWABLE,
GIMP_PREVIEW_SIZE_HUGE,
0, FALSE);
0, TRUE);
gtk_widget_set_size_request (selection_editor->preview,
GIMP_PREVIEW_SIZE_HUGE, GIMP_PREVIEW_SIZE_HUGE);
gimp_preview_set_expand (GIMP_PREVIEW (selection_editor->preview), TRUE);