Commit 0614aa53 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added virtual function get_popup_size() which returns a boolean indicating

2003-02-27  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpviewable.[ch]: added virtual function
	get_popup_size() which returns a boolean indicating if a popup is
	needed and its size.

	* app/core/gimpbrush.c
	* app/core/gimpbrushpipe.c
	* app/core/gimpbuffer.c
	* app/core/gimpdrawable-preview.[ch]
	* app/core/gimpdrawable.c
	* app/core/gimpgradient.c
	* app/core/gimpimage.c
	* app/core/gimppalette.c
	* app/core/gimppattern.c
	* app/core/gimpundo.c: implement it.

	* app/widgets/gimppreview.[ch]: removed virtual functions
	needs_popup() and create_popup(). Removed the code which creates
	the popup and the popup members of the GimpPreview struct.

	* app/widgets/gimppreview-popup.[ch]: new files providing the
	utility function gimp_preview_popup_show() which can show popups
	from any widget, not just from a GimpPreview. Checks if a popup is
	needed using gimp_viewable_get_popup_size().

	* app/widgets/gimpcellrendererviewable.c: show popups here too.

	* app/widgets/gimpbrushpreview.c
	* app/widgets/gimpbufferpreview.c
	* app/widgets/gimpdrawablepreview.c
	* app/widgets/gimpimagepreview.c: removed needs_popup() and
	create_popup() implementations.

	* app/widgets/gimpnavigationpreview.c: removed empty render()
	implementation.

	* app/widgets/gimpundoeditor.c: use a tree instead of a list view.

	* app/widgets/gimpgradientpreview.[ch]
	* app/widgets/gimppalettepreview.[ch]
	* app/widgets/gimppatternpreview.[ch]: removed because they only
	implemented the removed popup functions.

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpmenuitem.c
	* app/widgets/gimppreview-utils.c: changed accordingly
parent b3e58673
2003-02-27 Michael Natterer <mitch@gimp.org>
* app/core/gimpviewable.[ch]: added virtual function
get_popup_size() which returns a boolean indicating if a popup is
needed and its size.
* app/core/gimpbrush.c
* app/core/gimpbrushpipe.c
* app/core/gimpbuffer.c
* app/core/gimpdrawable-preview.[ch]
* app/core/gimpdrawable.c
* app/core/gimpgradient.c
* app/core/gimpimage.c
* app/core/gimppalette.c
* app/core/gimppattern.c
* app/core/gimpundo.c: implement it.
* app/widgets/gimppreview.[ch]: removed virtual functions
needs_popup() and create_popup(). Removed the code which creates
the popup and the popup members of the GimpPreview struct.
* app/widgets/gimppreview-popup.[ch]: new files providing the
utility function gimp_preview_popup_show() which can show popups
from any widget, not just from a GimpPreview. Checks if a popup is
needed using gimp_viewable_get_popup_size().
* app/widgets/gimpcellrendererviewable.c: show popups here too.
* app/widgets/gimpbrushpreview.c
* app/widgets/gimpbufferpreview.c
* app/widgets/gimpdrawablepreview.c
* app/widgets/gimpimagepreview.c: removed needs_popup() and
create_popup() implementations.
* app/widgets/gimpnavigationpreview.c: removed empty render()
implementation.
* app/widgets/gimpundoeditor.c: use a tree instead of a list view.
* app/widgets/gimpgradientpreview.[ch]
* app/widgets/gimppalettepreview.[ch]
* app/widgets/gimppatternpreview.[ch]: removed because they only
implemented the removed popup functions.
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpmenuitem.c
* app/widgets/gimppreview-utils.c: changed accordingly
2003-02-26 Sven Neumann <sven@gimp.org>
* app/config/gimpconfig-serialize.c (gimp_config_serialize_properties):
......@@ -71,6 +71,12 @@ static void gimp_brush_finalize (GObject *object);
static gsize gimp_brush_get_memsize (GimpObject *object);
static gboolean gimp_brush_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height);
static TempBuf * gimp_brush_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
......@@ -145,6 +151,7 @@ gimp_brush_class_init (GimpBrushClass *klass)
gimp_object_class->get_memsize = gimp_brush_get_memsize;
viewable_class->get_popup_size = gimp_brush_get_popup_size;
viewable_class->get_new_preview = gimp_brush_get_new_preview;
data_class->get_extension = gimp_brush_get_extension;
......@@ -206,6 +213,29 @@ gimp_brush_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static gboolean
gimp_brush_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height)
{
GimpBrush *brush;
brush = GIMP_BRUSH (viewable);
if (brush->mask->width > width || brush->mask->height > height)
{
*popup_width = brush->mask->width;
*popup_height = brush->mask->height;
return TRUE;
}
return FALSE;
}
static TempBuf *
gimp_brush_get_new_preview (GimpViewable *viewable,
gint width,
......
......@@ -71,6 +71,12 @@ static void gimp_brush_finalize (GObject *object);
static gsize gimp_brush_get_memsize (GimpObject *object);
static gboolean gimp_brush_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height);
static TempBuf * gimp_brush_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
......@@ -145,6 +151,7 @@ gimp_brush_class_init (GimpBrushClass *klass)
gimp_object_class->get_memsize = gimp_brush_get_memsize;
viewable_class->get_popup_size = gimp_brush_get_popup_size;
viewable_class->get_new_preview = gimp_brush_get_new_preview;
data_class->get_extension = gimp_brush_get_extension;
......@@ -206,6 +213,29 @@ gimp_brush_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static gboolean
gimp_brush_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height)
{
GimpBrush *brush;
brush = GIMP_BRUSH (viewable);
if (brush->mask->width > width || brush->mask->height > height)
{
*popup_width = brush->mask->width;
*popup_height = brush->mask->height;
return TRUE;
}
return FALSE;
}
static TempBuf *
gimp_brush_get_new_preview (GimpViewable *viewable,
gint width,
......
......@@ -45,6 +45,8 @@
#include "core-types.h"
#include "base/temp-buf.h"
#include "gimpbrush.h"
#include "gimpbrush-header.h"
#include "gimpbrushpipe.h"
......@@ -60,6 +62,13 @@ static void gimp_brush_pipe_finalize (GObject *object);
static gsize gimp_brush_pipe_get_memsize (GimpObject *object);
static gboolean gimp_brush_pipe_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height);
static GimpBrush * gimp_brush_pipe_select_brush (GimpBrush *brush,
GimpCoords *last_coords,
GimpCoords *cur_coords);
......@@ -102,12 +111,14 @@ gimp_brush_pipe_get_type (void)
static void
gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
{
GObjectClass *object_class;
GimpObjectClass *gimp_object_class;
GimpBrushClass *brush_class;
GObjectClass *object_class;
GimpObjectClass *gimp_object_class;
GimpViewableClass *viewable_class;
GimpBrushClass *brush_class;
object_class = G_OBJECT_CLASS (klass);
gimp_object_class = GIMP_OBJECT_CLASS (klass);
viewable_class = GIMP_VIEWABLE_CLASS (klass);
brush_class = GIMP_BRUSH_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -116,6 +127,8 @@ gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
gimp_object_class->get_memsize = gimp_brush_pipe_get_memsize;
viewable_class->get_popup_size = gimp_brush_pipe_get_popup_size;
brush_class->select_brush = gimp_brush_pipe_select_brush;
brush_class->want_null_motion = gimp_brush_pipe_want_null_motion;
}
......@@ -203,6 +216,24 @@ gimp_brush_pipe_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static gboolean
gimp_brush_pipe_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height)
{
GimpBrush *brush;
brush = GIMP_BRUSH (viewable);
*popup_width = brush->mask->width;
*popup_height = brush->mask->height;
return TRUE;
}
static GimpBrush *
gimp_brush_pipe_select_brush (GimpBrush *brush,
GimpCoords *last_coords,
......
......@@ -45,6 +45,8 @@
#include "core-types.h"
#include "base/temp-buf.h"
#include "gimpbrush.h"
#include "gimpbrush-header.h"
#include "gimpbrushpipe.h"
......@@ -60,6 +62,13 @@ static void gimp_brush_pipe_finalize (GObject *object);
static gsize gimp_brush_pipe_get_memsize (GimpObject *object);
static gboolean gimp_brush_pipe_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height);
static GimpBrush * gimp_brush_pipe_select_brush (GimpBrush *brush,
GimpCoords *last_coords,
GimpCoords *cur_coords);
......@@ -102,12 +111,14 @@ gimp_brush_pipe_get_type (void)
static void
gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
{
GObjectClass *object_class;
GimpObjectClass *gimp_object_class;
GimpBrushClass *brush_class;
GObjectClass *object_class;
GimpObjectClass *gimp_object_class;
GimpViewableClass *viewable_class;
GimpBrushClass *brush_class;
object_class = G_OBJECT_CLASS (klass);
gimp_object_class = GIMP_OBJECT_CLASS (klass);
viewable_class = GIMP_VIEWABLE_CLASS (klass);
brush_class = GIMP_BRUSH_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -116,6 +127,8 @@ gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
gimp_object_class->get_memsize = gimp_brush_pipe_get_memsize;
viewable_class->get_popup_size = gimp_brush_pipe_get_popup_size;
brush_class->select_brush = gimp_brush_pipe_select_brush;
brush_class->want_null_motion = gimp_brush_pipe_want_null_motion;
}
......@@ -203,6 +216,24 @@ gimp_brush_pipe_get_memsize (GimpObject *object)
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
}
static gboolean
gimp_brush_pipe_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height)
{
GimpBrush *brush;
brush = GIMP_BRUSH (viewable);
*popup_width = brush->mask->width;
*popup_height = brush->mask->height;
return TRUE;
}
static GimpBrush *
gimp_brush_pipe_select_brush (GimpBrush *brush,
GimpCoords *last_coords,
......
......@@ -44,8 +44,14 @@ static void gimp_buffer_get_preview_size (GimpViewable *viewable,
gint size,
gboolean is_popup,
gboolean dot_for_dot,
gint *width,
gint *height);
gint *popup_width,
gint *popup_height);
static gboolean gimp_buffer_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height);
static TempBuf * gimp_buffer_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
......@@ -100,6 +106,7 @@ gimp_buffer_class_init (GimpBufferClass *klass)
gimp_object_class->get_memsize = gimp_buffer_get_memsize;
viewable_class->get_preview_size = gimp_buffer_get_preview_size;
viewable_class->get_popup_size = gimp_buffer_get_popup_size;
viewable_class->get_new_preview = gimp_buffer_get_new_preview;
}
......@@ -162,6 +169,50 @@ gimp_buffer_get_preview_size (GimpViewable *viewable,
NULL);
}
static gboolean
gimp_buffer_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height)
{
GimpBuffer *buffer;
gint buffer_width;
gint buffer_height;
buffer = GIMP_BUFFER (viewable);
buffer_width = gimp_buffer_get_width (buffer);
buffer_height = gimp_buffer_get_height (buffer);
if (buffer_width > width || buffer_height > height)
{
gboolean scaling_up;
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),
dot_for_dot, 1.0, 1.0,
popup_width,
popup_height,
&scaling_up);
if (scaling_up)
{
*popup_width = buffer_width;
*popup_height = buffer_height;
}
return TRUE;
}
return FALSE;
}
static TempBuf *
gimp_buffer_get_new_preview (GimpViewable *viewable,
gint width,
......
......@@ -98,6 +98,50 @@ gimp_drawable_get_preview_size (GimpViewable *viewable,
}
}
gboolean
gimp_drawable_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height)
{
GimpDrawable *drawable;
GimpImage *gimage;
drawable = GIMP_DRAWABLE (viewable);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
if (drawable->width > width || drawable->height > height)
{
gboolean scaling_up;
gimp_viewable_calc_preview_size (viewable,
drawable->width,
drawable->height,
MIN (width * 2,
GIMP_VIEWABLE_MAX_POPUP_SIZE),
MIN (height * 2,
GIMP_VIEWABLE_MAX_POPUP_SIZE),
dot_for_dot,
gimage ? gimage->xresolution : 1.0,
gimage ? gimage->yresolution : 1.0,
popup_width,
popup_height,
&scaling_up);
if (scaling_up)
{
*popup_width = drawable->width;
*popup_width = drawable->height;
}
return TRUE;
}
return FALSE;
}
TempBuf *
gimp_drawable_get_preview (GimpViewable *viewable,
gint width,
......
......@@ -30,6 +30,12 @@ void gimp_drawable_get_preview_size (GimpViewable *viewable,
gboolean dot_for_dot,
gint *width,
gint *height);
gboolean gimp_drawable_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height);
TempBuf * gimp_drawable_get_preview (GimpViewable *viewable,
gint width,
gint height);
......
......@@ -141,6 +141,7 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
viewable_class->invalidate_preview = gimp_drawable_invalidate_preview;
viewable_class->get_preview_size = gimp_drawable_get_preview_size;
viewable_class->get_popup_size = gimp_drawable_get_popup_size;
viewable_class->get_preview = gimp_drawable_get_preview;
item_class->duplicate = gimp_drawable_duplicate;
......
......@@ -55,6 +55,12 @@ static void gimp_gradient_get_preview_size (GimpViewable *viewable,
gboolean dot_for_dot,
gint *width,
gint *height);
static gboolean gimp_gradient_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height);
static TempBuf * gimp_gradient_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
......@@ -128,6 +134,7 @@ gimp_gradient_class_init (GimpGradientClass *klass)
gimp_object_class->get_memsize = gimp_gradient_get_memsize;
viewable_class->get_preview_size = gimp_gradient_get_preview_size;
viewable_class->get_popup_size = gimp_gradient_get_popup_size;
viewable_class->get_new_preview = gimp_gradient_get_new_preview;
data_class->dirty = gimp_gradient_dirty;
......@@ -188,6 +195,25 @@ gimp_gradient_get_preview_size (GimpViewable *viewable,
*height = size / 2;
}
static gboolean
gimp_gradient_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height)
{
if (width < 128 || height < 32)
{
*popup_width = 128;
*popup_height = 32;
return TRUE;
}
return FALSE;
}
static TempBuf *
gimp_gradient_get_new_preview (GimpViewable *viewable,
gint width,
......
......@@ -115,6 +115,12 @@ static void gimp_image_get_preview_size (GimpViewable *viewable,
gboolean dot_for_dot,
gint *width,
gint *height);
static gboolean gimp_image_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height);
static TempBuf *gimp_image_get_preview (GimpViewable *gimage,
gint width,
gint height);
......@@ -400,6 +406,7 @@ gimp_image_class_init (GimpImageClass *klass)
viewable_class->invalidate_preview = gimp_image_invalidate_preview;
viewable_class->size_changed = gimp_image_size_changed;
viewable_class->get_preview_size = gimp_image_get_preview_size;
viewable_class->get_popup_size = gimp_image_get_popup_size;
viewable_class->get_preview = gimp_image_get_preview;
viewable_class->get_new_preview = gimp_image_get_new_preview;
......@@ -709,6 +716,46 @@ gimp_image_get_preview_size (GimpViewable *viewable,
NULL);
}
static gboolean
gimp_image_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height)
{
GimpImage *gimage;
gimage = GIMP_IMAGE (viewable);
if (gimage->width > width || gimage->height > height)
{
gboolean scaling_up;
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),
dot_for_dot, 1.0, 1.0,
popup_width,
popup_height,
&scaling_up);
if (scaling_up)
{
*popup_width = gimage->width;
*popup_height = gimage->height;
}
return TRUE;
}
return FALSE;
}
static TempBuf *
gimp_image_get_preview (GimpViewable *viewable,
gint width,
......
......@@ -54,6 +54,12 @@ static void gimp_palette_get_preview_size (GimpViewable *viewable,
gboolean dot_for_dot,
gint *width,
gint *height);
static gboolean gimp_palette_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height);
static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
......@@ -118,6 +124,7 @@ gimp_palette_class_init (GimpPaletteClass *klass)
gimp_object_class->get_memsize = gimp_palette_get_memsize;
viewable_class->get_preview_size = gimp_palette_get_preview_size;
viewable_class->get_popup_size = gimp_palette_get_popup_size;
viewable_class->get_new_preview = gimp_palette_get_new_preview;
data_class->dirty = gimp_palette_dirty;
......@@ -188,6 +195,41 @@ gimp_palette_get_preview_size (GimpViewable *viewable,
*height = size / 2;
}
static gboolean
gimp_palette_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height)
{
GimpPalette *palette;
gint p_width;
gint p_height;
palette = GIMP_PALETTE (viewable);
if (! palette->n_colors)
return FALSE;
if (palette->n_columns)
p_width = palette->n_columns;
else
p_width = MIN (palette->n_colors, 16);
p_height = MAX (1, palette->n_colors / p_width);
if (p_width * 4 > width || p_height * 4 > height)
{
*popup_width = p_width * 4;
*popup_height = p_height * 4;
return TRUE;
}
return FALSE;
}
static TempBuf *
gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
......
......@@ -54,6 +54,12 @@ static void gimp_palette_get_preview_size (GimpViewable *viewable,
gboolean dot_for_dot,
gint *width,
gint *height);
static gboolean gimp_palette_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height);
static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
......@@ -118,6 +124,7 @@ gimp_palette_class_init (GimpPaletteClass *klass)
gimp_object_class->get_memsize = gimp_palette_get_memsize;
viewable_class->get_preview_size = gimp_palette_get_preview_size;
viewable_class->get_popup_size = gimp_palette_get_popup_size;
viewable_class->get_new_preview = gimp_palette_get_new_preview;
data_class->dirty = gimp_palette_dirty;
......@@ -188,6 +195,41 @@ gimp_palette_get_preview_size (GimpViewable *viewable,
*height = size / 2;
}
static gboolean
gimp_palette_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height)
{
GimpPalette *palette;
gint p_width;
gint p_height;
palette = GIMP_PALETTE (viewable);
if (! palette->n_colors)
return FALSE;
if (palette->n_columns)
p_width = palette->n_columns;
else
p_width = MIN (palette->n_colors, 16);
p_height = MAX (1, palette->n_colors / p_width);
if (p_width * 4 > width || p_height * 4 > height)
{
*popup_width = p_width * 4;
*popup_height = p_height * 4;
return TRUE;
}
return FALSE;
}
static TempBuf *
gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
......
......@@ -54,6 +54,12 @@ static void gimp_palette_get_preview_size (GimpViewable *viewable,
gboolean dot_for_dot,
gint *width,
gint *height);
static gboolean gimp_palette_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height);
static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
gint height);
......@@ -118,6 +124,7 @@ gimp_palette_class_init (GimpPaletteClass *klass)
gimp_object_class->get_memsize = gimp_palette_get_memsize;
viewable_class->get_preview_size = gimp_palette_get_preview_size;
viewable_class->get_popup_size = gimp_palette_get_popup_size;
viewable_class->get_new_preview = gimp_palette_get_new_preview;
data_class->dirty = gimp_palette_dirty;
......@@ -188,6 +195,41 @@ gimp_palette_get_preview_size (GimpViewable *viewable,
*height = size / 2;
}
static gboolean
gimp_palette_get_popup_size (GimpViewable *viewable,
gint width,
gint height,
gboolean dot_for_dot,
gint *popup_width,
gint *popup_height)
{
GimpPalette *palette;
gint p_width;
gint p_height;