mirror of https://github.com/GNOME/gimp.git
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
This commit is contained in:
parent
b3e5867378
commit
0614aa5329
49
ChangeLog
49
ChangeLog
|
@ -1,3 +1,52 @@
|
|||
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;
|
||||
|
||||
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,
|
||||
|
|
|
@ -61,6 +61,12 @@ static void gimp_pattern_finalize (GObject *object);
|
|||
|
||||
static gsize gimp_pattern_get_memsize (GimpObject *object);
|
||||
|
||||
static gboolean gimp_pattern_get_popup_size (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean dot_for_dot,
|
||||
gint *popup_width,
|
||||
gint *popup_heigh);
|
||||
static TempBuf * gimp_pattern_get_new_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height);
|
||||
|
@ -119,6 +125,7 @@ gimp_pattern_class_init (GimpPatternClass *klass)
|
|||
|
||||
gimp_object_class->get_memsize = gimp_pattern_get_memsize;
|
||||
|
||||
viewable_class->get_popup_size = gimp_pattern_get_popup_size;
|
||||
viewable_class->get_new_preview = gimp_pattern_get_new_preview;
|
||||
|
||||
data_class->get_extension = gimp_pattern_get_extension;
|
||||
|
@ -161,6 +168,29 @@ gimp_pattern_get_memsize (GimpObject *object)
|
|||
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_pattern_get_popup_size (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean dot_for_dot,
|
||||
gint *popup_width,
|
||||
gint *popup_height)
|
||||
{
|
||||
GimpPattern *pattern;
|
||||
|
||||
pattern = GIMP_PATTERN (viewable);
|
||||
|
||||
if (pattern->mask->width > width || pattern->mask->height > height)
|
||||
{
|
||||
*popup_width = pattern->mask->width;
|
||||
*popup_height = pattern->mask->height;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static TempBuf *
|
||||
gimp_pattern_get_new_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
|
|
|
@ -61,6 +61,12 @@ static void gimp_pattern_finalize (GObject *object);
|
|||
|
||||
static gsize gimp_pattern_get_memsize (GimpObject *object);
|
||||
|
||||
static gboolean gimp_pattern_get_popup_size (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean dot_for_dot,
|
||||
gint *popup_width,
|
||||
gint *popup_heigh);
|
||||
static TempBuf * gimp_pattern_get_new_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height);
|
||||
|
@ -119,6 +125,7 @@ gimp_pattern_class_init (GimpPatternClass *klass)
|
|||
|
||||
gimp_object_class->get_memsize = gimp_pattern_get_memsize;
|
||||
|
||||
viewable_class->get_popup_size = gimp_pattern_get_popup_size;
|
||||
viewable_class->get_new_preview = gimp_pattern_get_new_preview;
|
||||
|
||||
data_class->get_extension = gimp_pattern_get_extension;
|
||||
|
@ -161,6 +168,29 @@ gimp_pattern_get_memsize (GimpObject *object)
|
|||
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_pattern_get_popup_size (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean dot_for_dot,
|
||||
gint *popup_width,
|
||||
gint *popup_height)
|
||||
{
|
||||
GimpPattern *pattern;
|
||||
|
||||
pattern = GIMP_PATTERN (viewable);
|
||||
|
||||
if (pattern->mask->width > width || pattern->mask->height > height)
|
||||
{
|
||||
*popup_width = pattern->mask->width;
|
||||
*popup_height = pattern->mask->height;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static TempBuf *
|
||||
gimp_pattern_get_new_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
|
|
|
@ -45,6 +45,12 @@ static void gimp_undo_finalize (GObject *object);
|
|||
|
||||
static gsize gimp_undo_get_memsize (GimpObject *object);
|
||||
|
||||
static gboolean gimp_undo_get_popup_size (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean dot_for_dot,
|
||||
gint *popup_width,
|
||||
gint *popup_height);
|
||||
static TempBuf * gimp_undo_get_new_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height);
|
||||
|
@ -130,6 +136,7 @@ gimp_undo_class_init (GimpUndoClass *klass)
|
|||
|
||||
gimp_object_class->get_memsize = gimp_undo_get_memsize;
|
||||
|
||||
viewable_class->get_popup_size = gimp_undo_get_popup_size;
|
||||
viewable_class->get_new_preview = gimp_undo_get_new_preview;
|
||||
|
||||
klass->pop = gimp_undo_real_pop;
|
||||
|
@ -186,6 +193,30 @@ gimp_undo_get_memsize (GimpObject *object)
|
|||
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_undo_get_popup_size (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean dot_for_dot,
|
||||
gint *popup_width,
|
||||
gint *popup_height)
|
||||
{
|
||||
GimpUndo *undo;
|
||||
|
||||
undo = GIMP_UNDO (viewable);
|
||||
|
||||
if (undo->preview &&
|
||||
(undo->preview->width > width || undo->preview->height > height))
|
||||
{
|
||||
*popup_width = undo->preview->width;
|
||||
*popup_height = undo->preview->height;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static TempBuf *
|
||||
gimp_undo_get_new_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
|
|
|
@ -135,6 +135,7 @@ gimp_viewable_class_init (GimpViewableClass *klass)
|
|||
klass->size_changed = NULL;
|
||||
|
||||
klass->get_preview_size = gimp_viewable_real_get_preview_size;
|
||||
klass->get_popup_size = NULL;
|
||||
klass->get_preview = NULL;
|
||||
klass->get_new_preview = NULL;
|
||||
}
|
||||
|
@ -295,6 +296,36 @@ gimp_viewable_get_preview_size (GimpViewable *viewable,
|
|||
width, height);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_viewable_get_popup_size (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean dot_for_dot,
|
||||
gint *popup_width,
|
||||
gint *popup_height)
|
||||
{
|
||||
GimpViewableClass *viewable_class;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), FALSE);
|
||||
|
||||
viewable_class = GIMP_VIEWABLE_GET_CLASS (viewable);
|
||||
|
||||
if (viewable_class->get_popup_size)
|
||||
{
|
||||
gint dummy_width;
|
||||
gint dummy_height;
|
||||
|
||||
if (! popup_width) popup_width = &dummy_width;
|
||||
if (! popup_height) popup_height = &dummy_height;
|
||||
|
||||
return viewable_class->get_popup_size (viewable,
|
||||
width, height, dot_for_dot,
|
||||
popup_width, popup_height);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
TempBuf *
|
||||
gimp_viewable_get_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
|
||||
#define GIMP_VIEWABLE_MAX_POPUP_SIZE 256
|
||||
|
||||
|
||||
#define GIMP_TYPE_VIEWABLE (gimp_viewable_get_type ())
|
||||
#define GIMP_VIEWABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_VIEWABLE, GimpViewable))
|
||||
#define GIMP_VIEWABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_VIEWABLE, GimpViewableClass))
|
||||
|
@ -64,6 +67,12 @@ struct _GimpViewableClass
|
|||
gboolean dot_for_dot,
|
||||
gint *width,
|
||||
gint *height);
|
||||
gboolean (* get_popup_size) (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean dot_for_dot,
|
||||
gint *popup_width,
|
||||
gint *popup_height);
|
||||
TempBuf * (* get_preview) (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height);
|
||||
|
@ -96,6 +105,13 @@ void gimp_viewable_get_preview_size (GimpViewable *viewable,
|
|||
gboolean dot_for_dot,
|
||||
gint *width,
|
||||
gint *height);
|
||||
gboolean gimp_viewable_get_popup_size (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean dot_for_dot,
|
||||
gint *popup_width,
|
||||
gint *popup_height);
|
||||
|
||||
TempBuf * gimp_viewable_get_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height);
|
||||
|
|
|
@ -97,8 +97,6 @@ libappwidgets_a_sources = \
|
|||
gimpfontselection-dialog.h \
|
||||
gimpgradienteditor.c \
|
||||
gimpgradienteditor.h \
|
||||
gimpgradientpreview.c \
|
||||
gimpgradientpreview.h \
|
||||
gimphelp.c \
|
||||
gimphelp.h \
|
||||
gimphistogrambox.c \
|
||||
|
@ -133,12 +131,10 @@ libappwidgets_a_sources = \
|
|||
gimpnavigationpreview.h \
|
||||
gimppaletteeditor.c \
|
||||
gimppaletteeditor.h \
|
||||
gimppalettepreview.c \
|
||||
gimppalettepreview.h \
|
||||
gimppatternpreview.c \
|
||||
gimppatternpreview.h \
|
||||
gimppreview.c \
|
||||
gimppreview.h \
|
||||
gimppreview-popup.c \
|
||||
gimppreview-popup.h \
|
||||
gimppreview-utils.c \
|
||||
gimppreview-utils.h \
|
||||
gimppropwidgets.c \
|
||||
|
|
|
@ -39,8 +39,6 @@ static void gimp_brush_preview_init (GimpBrushPreview *preview);
|
|||
|
||||
static void gimp_brush_preview_destroy (GtkObject *object);
|
||||
static void gimp_brush_preview_render (GimpPreview *preview);
|
||||
static GtkWidget * gimp_brush_preview_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview);
|
||||
|
||||
static gboolean gimp_brush_preview_render_timeout (gpointer data);
|
||||
|
||||
|
@ -87,11 +85,9 @@ gimp_brush_preview_class_init (GimpBrushPreviewClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->destroy = gimp_brush_preview_destroy;
|
||||
object_class->destroy = gimp_brush_preview_destroy;
|
||||
|
||||
preview_class->render = gimp_brush_preview_render;
|
||||
preview_class->create_popup = gimp_brush_preview_create_popup;
|
||||
preview_class->needs_popup = gimp_brush_preview_needs_popup;
|
||||
preview_class->render = gimp_brush_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -116,8 +112,7 @@ gimp_brush_preview_destroy (GtkObject *object)
|
|||
brush_preview->pipe_animation_index = 0;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -136,7 +131,6 @@ gimp_brush_preview_render (GimpPreview *preview)
|
|||
if (brush_preview->pipe_timeout_id)
|
||||
{
|
||||
g_source_remove (brush_preview->pipe_timeout_id);
|
||||
|
||||
brush_preview->pipe_timeout_id = 0;
|
||||
}
|
||||
|
||||
|
@ -295,41 +289,6 @@ gimp_brush_preview_render (GimpPreview *preview)
|
|||
temp_buf_free (temp_buf);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_brush_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
popup_width = GIMP_BRUSH (preview->viewable)->mask->width;
|
||||
popup_height = GIMP_BRUSH (preview->viewable)->mask->height;
|
||||
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_brush_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpBrush *brush;
|
||||
gint brush_width;
|
||||
gint brush_height;
|
||||
|
||||
brush = GIMP_BRUSH (preview->viewable);
|
||||
brush_width = brush->mask->width;
|
||||
brush_height = brush->mask->height;
|
||||
|
||||
if (GIMP_IS_BRUSH_PIPE (brush) ||
|
||||
brush_width > preview->width ||
|
||||
brush_height > preview->height)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_brush_preview_render_timeout (gpointer data)
|
||||
{
|
||||
|
|
|
@ -35,9 +35,7 @@
|
|||
static void gimp_buffer_preview_class_init (GimpBufferPreviewClass *klass);
|
||||
static void gimp_buffer_preview_init (GimpBufferPreview *preview);
|
||||
|
||||
static void gimp_buffer_preview_render (GimpPreview *preview);
|
||||
static GtkWidget * gimp_buffer_preview_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_buffer_preview_needs_popup (GimpPreview *preview);
|
||||
static void gimp_buffer_preview_render (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
@ -80,9 +78,7 @@ gimp_buffer_preview_class_init (GimpBufferPreviewClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
preview_class->render = gimp_buffer_preview_render;
|
||||
preview_class->create_popup = gimp_buffer_preview_create_popup;
|
||||
preview_class->needs_popup = gimp_buffer_preview_needs_popup;
|
||||
preview_class->render = gimp_buffer_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -155,68 +151,3 @@ gimp_buffer_preview_render (GimpPreview *preview)
|
|||
|
||||
temp_buf_free (render_buf);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_buffer_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpBuffer *buffer;
|
||||
gint buffer_width;
|
||||
gint buffer_height;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
gboolean scaling_up;
|
||||
|
||||
buffer = GIMP_BUFFER (preview->viewable);
|
||||
|
||||
buffer_width = gimp_buffer_get_width (buffer);
|
||||
buffer_height = gimp_buffer_get_height (buffer);
|
||||
|
||||
gimp_viewable_calc_preview_size (preview->viewable,
|
||||
buffer_width,
|
||||
buffer_height,
|
||||
MIN (preview->width * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
MIN (preview->height * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
preview->dot_for_dot,
|
||||
1.0,
|
||||
1.0,
|
||||
&popup_width,
|
||||
&popup_height,
|
||||
&scaling_up);
|
||||
|
||||
if (scaling_up)
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
buffer_width,
|
||||
buffer_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_buffer_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpBuffer *buffer;
|
||||
gint buffer_width;
|
||||
gint buffer_height;
|
||||
|
||||
buffer = GIMP_BUFFER (preview->viewable);
|
||||
|
||||
buffer_width = gimp_buffer_get_width (buffer);
|
||||
buffer_height = gimp_buffer_get_height (buffer);
|
||||
|
||||
if (buffer_width > preview->width || buffer_height > preview->height)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "core/gimpviewable.h"
|
||||
|
||||
#include "gimpcellrendererviewable.h"
|
||||
#include "gimppreview-popup.h"
|
||||
|
||||
|
||||
enum
|
||||
|
@ -62,7 +63,14 @@ static void gimp_cell_renderer_viewable_render (GtkCellRenderer *cell,
|
|||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags);
|
||||
GtkCellRendererState flags);
|
||||
static gboolean gimp_cell_renderer_viewable_activate (GtkCellRenderer *cell,
|
||||
GdkEvent *event,
|
||||
GtkWidget *widget,
|
||||
const gchar *path,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags);
|
||||
|
||||
|
||||
GtkCellRendererPixbufClass *parent_class = NULL;
|
||||
|
@ -112,6 +120,7 @@ gimp_cell_renderer_viewable_class_init (GimpCellRendererViewableClass *klass)
|
|||
|
||||
cell_class->get_size = gimp_cell_renderer_viewable_get_size;
|
||||
cell_class->render = gimp_cell_renderer_viewable_render;
|
||||
cell_class->activate = gimp_cell_renderer_viewable_activate;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_VIEWABLE,
|
||||
|
@ -131,6 +140,7 @@ gimp_cell_renderer_viewable_class_init (GimpCellRendererViewableClass *klass)
|
|||
static void
|
||||
gimp_cell_renderer_viewable_init (GimpCellRendererViewable *cellviewable)
|
||||
{
|
||||
GTK_CELL_RENDERER (cellviewable)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -358,6 +368,43 @@ gimp_cell_renderer_viewable_render (GtkCellRenderer *cell,
|
|||
flags);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_cell_renderer_viewable_activate (GtkCellRenderer *cell,
|
||||
GdkEvent *event,
|
||||
GtkWidget *widget,
|
||||
const gchar *path,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags)
|
||||
{
|
||||
GimpCellRendererViewable *cellviewable;
|
||||
|
||||
cellviewable = GIMP_CELL_RENDERER_VIEWABLE (cell);
|
||||
|
||||
if (cellviewable->viewable &&
|
||||
((GdkEventAny *) event)->type == GDK_BUTTON_PRESS &&
|
||||
((GdkEventButton *) event)->button == 1)
|
||||
{
|
||||
gint preview_width;
|
||||
gint preview_height;
|
||||
|
||||
gimp_viewable_get_preview_size (cellviewable->viewable,
|
||||
cellviewable->preview_size,
|
||||
FALSE, TRUE,
|
||||
&preview_width,
|
||||
&preview_height);
|
||||
|
||||
return gimp_preview_popup_show (widget,
|
||||
(GdkEventButton *) event,
|
||||
cellviewable->viewable,
|
||||
preview_width,
|
||||
preview_height,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GtkCellRenderer *
|
||||
gimp_cell_renderer_viewable_new (void)
|
||||
{
|
||||
|
|
|
@ -38,8 +38,7 @@
|
|||
static void gimp_drawable_preview_class_init (GimpDrawablePreviewClass *klass);
|
||||
static void gimp_drawable_preview_init (GimpDrawablePreview *preview);
|
||||
|
||||
static void gimp_drawable_preview_render (GimpPreview *preview);
|
||||
static GtkWidget * gimp_drawable_preview_create_popup (GimpPreview *preview);
|
||||
static void gimp_drawable_preview_render (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
@ -82,8 +81,7 @@ gimp_drawable_preview_class_init (GimpDrawablePreviewClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
preview_class->render = gimp_drawable_preview_render;
|
||||
preview_class->create_popup = gimp_drawable_preview_create_popup;
|
||||
preview_class->render = gimp_drawable_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -190,47 +188,3 @@ gimp_drawable_preview_render (GimpPreview *preview)
|
|||
|
||||
temp_buf_free (render_buf);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_drawable_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
GimpImage *gimage;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
gboolean scaling_up;
|
||||
|
||||
drawable = GIMP_DRAWABLE (preview->viewable);
|
||||
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||
|
||||
gimp_viewable_calc_preview_size (preview->viewable,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
MIN (preview->width * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
MIN (preview->height * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
preview->dot_for_dot,
|
||||
gimage ? gimage->xresolution : 1.0,
|
||||
gimage ? gimage->yresolution : 1.0,
|
||||
&popup_width,
|
||||
&popup_height,
|
||||
&scaling_up);
|
||||
|
||||
if (scaling_up)
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,154 +0,0 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* GimpGradientPreview Widget
|
||||
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "base/temp-buf.h"
|
||||
|
||||
#include "core/gimpgradient.h"
|
||||
|
||||
#include "gimpgradientpreview.h"
|
||||
|
||||
|
||||
static void gimp_gradient_preview_class_init (GimpGradientPreviewClass *klass);
|
||||
static void gimp_gradient_preview_init (GimpGradientPreview *preview);
|
||||
|
||||
static void gimp_gradient_preview_render (GimpPreview *preview);
|
||||
static gboolean gimp_gradient_preview_needs_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_gradient_preview_create_popup (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_gradient_preview_get_type (void)
|
||||
{
|
||||
static GType preview_type = 0;
|
||||
|
||||
if (! preview_type)
|
||||
{
|
||||
static const GTypeInfo preview_info =
|
||||
{
|
||||
sizeof (GimpGradientPreviewClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gimp_gradient_preview_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpGradientPreview),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_gradient_preview_init,
|
||||
};
|
||||
|
||||
preview_type = g_type_register_static (GIMP_TYPE_PREVIEW,
|
||||
"GimpGradientPreview",
|
||||
&preview_info, 0);
|
||||
}
|
||||
|
||||
return preview_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_gradient_preview_class_init (GimpGradientPreviewClass *klass)
|
||||
{
|
||||
GimpPreviewClass *preview_class;
|
||||
|
||||
preview_class = GIMP_PREVIEW_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
preview_class->render = gimp_gradient_preview_render;
|
||||
preview_class->needs_popup = gimp_gradient_preview_needs_popup;
|
||||
preview_class->create_popup = gimp_gradient_preview_create_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_gradient_preview_init (GimpGradientPreview *gradient_preview)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_gradient_preview_render (GimpPreview *preview)
|
||||
{
|
||||
GimpGradient *gradient;
|
||||
TempBuf *temp_buf;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
gradient = GIMP_GRADIENT (preview->viewable);
|
||||
|
||||
width = preview->width;
|
||||
height = preview->height;
|
||||
|
||||
temp_buf = gimp_viewable_get_new_preview (preview->viewable,
|
||||
width, height);
|
||||
|
||||
gimp_preview_render_preview (preview,
|
||||
temp_buf,
|
||||
-1,
|
||||
GIMP_PREVIEW_BG_CHECKS,
|
||||
GIMP_PREVIEW_BG_WHITE);
|
||||
|
||||
temp_buf_free (temp_buf);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_gradient_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpGradient *gradient;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
gradient = GIMP_GRADIENT (preview->viewable);
|
||||
|
||||
popup_width = 48;
|
||||
popup_height = 24;
|
||||
|
||||
if (popup_width > preview->width ||
|
||||
popup_height > preview->height)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_gradient_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpGradient *gradient;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
gradient = GIMP_GRADIENT (preview->viewable);
|
||||
|
||||
popup_width = 128;
|
||||
popup_height = 32;
|
||||
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* GimpGradientPreview Widget
|
||||
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_GRADIENT_PREVIEW_H__
|
||||
#define __GIMP_GRADIENT_PREVIEW_H__
|
||||
|
||||
#include "gimppreview.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_GRADIENT_PREVIEW (gimp_gradient_preview_get_type ())
|
||||
#define GIMP_GRADIENT_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_GRADIENT_PREVIEW, GimpGradientPreview))
|
||||
#define GIMP_GRADIENT_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_GRADIENT_PREVIEW, GimpGradientPreviewClass))
|
||||
#define GIMP_IS_GRADIENT_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GIMP_TYPE_GRADIENT_PREVIEW))
|
||||
#define GIMP_IS_GRADIENT_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_GRADIENT_PREVIEW))
|
||||
#define GIMP_GRADIENT_PREVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_GRADIENT_PREVIEW, GimpGradientPreviewClass))
|
||||
|
||||
|
||||
typedef struct _GimpGradientPreviewClass GimpGradientPreviewClass;
|
||||
|
||||
struct _GimpGradientPreview
|
||||
{
|
||||
GimpPreview parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpGradientPreviewClass
|
||||
{
|
||||
GimpPreviewClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_gradient_preview_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_GRADIENT_PREVIEW_H__ */
|
|
@ -35,8 +35,7 @@
|
|||
static void gimp_image_preview_class_init (GimpImagePreviewClass *klass);
|
||||
static void gimp_image_preview_init (GimpImagePreview *preview);
|
||||
|
||||
static void gimp_image_preview_render (GimpPreview *preview);
|
||||
static GtkWidget * gimp_image_preview_create_popup (GimpPreview *preview);
|
||||
static void gimp_image_preview_render (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
@ -79,8 +78,7 @@ gimp_image_preview_class_init (GimpImagePreviewClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
preview_class->render = gimp_image_preview_render;
|
||||
preview_class->create_popup = gimp_image_preview_create_popup;
|
||||
preview_class->render = gimp_image_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -156,45 +154,3 @@ gimp_image_preview_render (GimpPreview *preview)
|
|||
|
||||
temp_buf_free (render_buf);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_image_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
gboolean scaling_up;
|
||||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
gimp_viewable_calc_preview_size (preview->viewable,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
MIN (preview->width * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
MIN (preview->height * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
preview->dot_for_dot,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&popup_width,
|
||||
&popup_height,
|
||||
&scaling_up);
|
||||
|
||||
if (scaling_up)
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,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_PREVIEW_MAX_POPUP_SIZE, NULL);
|
||||
preview_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE, NULL);
|
||||
|
||||
menu_item = g_object_new (GIMP_TYPE_MENU_ITEM, NULL);
|
||||
|
||||
|
|
|
@ -68,7 +68,6 @@ static gboolean gimp_navigation_preview_motion_notify (GtkWidget *wi
|
|||
GdkEventMotion *mevent);
|
||||
static gboolean gimp_navigation_preview_key_press (GtkWidget *widget,
|
||||
GdkEventKey *kevent);
|
||||
static void gimp_navigation_preview_render (GimpPreview *preview);
|
||||
static void gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
||||
GdkRectangle *area);
|
||||
|
||||
|
@ -109,13 +108,11 @@ gimp_navigation_preview_get_type (void)
|
|||
static void
|
||||
gimp_navigation_preview_class_init (GimpNavigationPreviewClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GimpPreviewClass *preview_class;
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
widget_class = GTK_WIDGET_CLASS (klass);
|
||||
preview_class = GIMP_PREVIEW_CLASS (klass);
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
|
@ -159,8 +156,6 @@ gimp_navigation_preview_class_init (GimpNavigationPreviewClass *klass)
|
|||
widget_class->scroll_event = gimp_navigation_preview_scroll;
|
||||
widget_class->motion_notify_event = gimp_navigation_preview_motion_notify;
|
||||
widget_class->key_press_event = gimp_navigation_preview_key_press;
|
||||
|
||||
preview_class->render = gimp_navigation_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -201,8 +196,7 @@ gimp_navigation_preview_destroy (GtkObject *object)
|
|||
nav_preview->gc = NULL;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -514,17 +508,6 @@ gimp_navigation_preview_key_press (GtkWidget *widget,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_render (GimpPreview *preview)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (preview);
|
||||
|
||||
if (GIMP_PREVIEW_CLASS (parent_class)->render)
|
||||
GIMP_PREVIEW_CLASS (parent_class)->render (preview);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
||||
GdkRectangle *area)
|
||||
|
|
|
@ -68,7 +68,6 @@ static gboolean gimp_navigation_preview_motion_notify (GtkWidget *wi
|
|||
GdkEventMotion *mevent);
|
||||
static gboolean gimp_navigation_preview_key_press (GtkWidget *widget,
|
||||
GdkEventKey *kevent);
|
||||
static void gimp_navigation_preview_render (GimpPreview *preview);
|
||||
static void gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
||||
GdkRectangle *area);
|
||||
|
||||
|
@ -109,13 +108,11 @@ gimp_navigation_preview_get_type (void)
|
|||
static void
|
||||
gimp_navigation_preview_class_init (GimpNavigationPreviewClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GimpPreviewClass *preview_class;
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
widget_class = GTK_WIDGET_CLASS (klass);
|
||||
preview_class = GIMP_PREVIEW_CLASS (klass);
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
|
@ -159,8 +156,6 @@ gimp_navigation_preview_class_init (GimpNavigationPreviewClass *klass)
|
|||
widget_class->scroll_event = gimp_navigation_preview_scroll;
|
||||
widget_class->motion_notify_event = gimp_navigation_preview_motion_notify;
|
||||
widget_class->key_press_event = gimp_navigation_preview_key_press;
|
||||
|
||||
preview_class->render = gimp_navigation_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -201,8 +196,7 @@ gimp_navigation_preview_destroy (GtkObject *object)
|
|||
nav_preview->gc = NULL;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -514,17 +508,6 @@ gimp_navigation_preview_key_press (GtkWidget *widget,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_render (GimpPreview *preview)
|
||||
{
|
||||
GimpNavigationPreview *nav_preview;
|
||||
|
||||
nav_preview = GIMP_NAVIGATION_PREVIEW (preview);
|
||||
|
||||
if (GIMP_PREVIEW_CLASS (parent_class)->render)
|
||||
GIMP_PREVIEW_CLASS (parent_class)->render (preview);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_preview_draw_marker (GimpNavigationPreview *nav_preview,
|
||||
GdkRectangle *area)
|
||||
|
|
|
@ -1,162 +0,0 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimppalettepreview.c
|
||||
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "base/temp-buf.h"
|
||||
|
||||
#include "core/gimppalette.h"
|
||||
|
||||
#include "gimppalettepreview.h"
|
||||
|
||||
|
||||
static void gimp_palette_preview_class_init (GimpPalettePreviewClass *klass);
|
||||
static void gimp_palette_preview_init (GimpPalettePreview *preview);
|
||||
|
||||
static void gimp_palette_preview_render (GimpPreview *preview);
|
||||
static GtkWidget * gimp_palette_preview_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_palette_preview_needs_popup (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_palette_preview_get_type (void)
|
||||
{
|
||||
static GType preview_type = 0;
|
||||
|
||||
if (! preview_type)
|
||||
{
|
||||
static const GTypeInfo preview_info =
|
||||
{
|
||||
sizeof (GimpPalettePreviewClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gimp_palette_preview_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpPalettePreview),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_palette_preview_init,
|
||||
};
|
||||
|
||||
preview_type = g_type_register_static (GIMP_TYPE_PREVIEW,
|
||||
"GimpPalettePreview",
|
||||
&preview_info, 0);
|
||||
}
|
||||
|
||||
return preview_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_palette_preview_class_init (GimpPalettePreviewClass *klass)
|
||||
{
|
||||
GimpPreviewClass *preview_class;
|
||||
|
||||
preview_class = GIMP_PREVIEW_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
preview_class->render = gimp_palette_preview_render;
|
||||
preview_class->create_popup = gimp_palette_preview_create_popup;
|
||||
preview_class->needs_popup = gimp_palette_preview_needs_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_palette_preview_init (GimpPalettePreview *palette_preview)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_palette_preview_render (GimpPreview *preview)
|
||||
{
|
||||
GimpPalette *palette;
|
||||
TempBuf *temp_buf;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
palette = GIMP_PALETTE (preview->viewable);
|
||||
|
||||
width = preview->width;
|
||||
height = preview->height;
|
||||
|
||||
temp_buf = gimp_viewable_get_new_preview (preview->viewable,
|
||||
width, height);
|
||||
|
||||
gimp_preview_render_preview (preview, temp_buf, -1,
|
||||
GIMP_PREVIEW_BG_WHITE, GIMP_PREVIEW_BG_WHITE);
|
||||
|
||||
temp_buf_free (temp_buf);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_palette_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpPalette *palette;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
palette = GIMP_PALETTE (preview->viewable);
|
||||
|
||||
if (palette->n_columns)
|
||||
popup_width = palette->n_columns;
|
||||
else
|
||||
popup_width = MIN (palette->n_colors, 16);
|
||||
|
||||
popup_height = MAX (1, palette->n_colors / popup_width);
|
||||
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width * 4,
|
||||
popup_height * 4,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_palette_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpPalette *palette;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
palette = GIMP_PALETTE (preview->viewable);
|
||||
|
||||
if (! palette->n_colors)
|
||||
return FALSE;
|
||||
|
||||
if (palette->n_columns)
|
||||
popup_width = palette->n_columns;
|
||||
else
|
||||
popup_width = MIN (palette->n_colors, 16);
|
||||
|
||||
popup_height = MAX (1, palette->n_colors / popup_width);
|
||||
|
||||
if (popup_width * 4 > preview->width ||
|
||||
popup_height * 4 > preview->height)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimppalettepreview.h
|
||||
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_PALETTE_PREVIEW_H__
|
||||
#define __GIMP_PALETTE_PREVIEW_H__
|
||||
|
||||
#include "gimppreview.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_PALETTE_PREVIEW (gimp_palette_preview_get_type ())
|
||||
#define GIMP_PALETTE_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PALETTE_PREVIEW, GimpPalettePreview))
|
||||
#define GIMP_PALETTE_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PALETTE_PREVIEW, GimpPalettePreviewClass))
|
||||
#define GIMP_IS_PALETTE_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GIMP_TYPE_PALETTE_PREVIEW))
|
||||
#define GIMP_IS_PALETTE_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PALETTE_PREVIEW))
|
||||
#define GIMP_PALETTE_PREVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PALETTE_PREVIEW, GimpPalettePreviewClass))
|
||||
|
||||
|
||||
typedef struct _GimpPalettePreviewClass GimpPalettePreviewClass;
|
||||
|
||||
struct _GimpPalettePreview
|
||||
{
|
||||
GimpPreview parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpPalettePreviewClass
|
||||
{
|
||||
GimpPreviewClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_palette_preview_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_PALETTE_PREVIEW_H__ */
|
|
@ -1,170 +0,0 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimppatternpreview.c
|
||||
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "base/temp-buf.h"
|
||||
|
||||
#include "core/gimppattern.h"
|
||||
|
||||
#include "gimppatternpreview.h"
|
||||
|
||||
|
||||
static void gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass);
|
||||
static void gimp_pattern_preview_init (GimpPatternPreview *preview);
|
||||
|
||||
static void gimp_pattern_preview_render (GimpPreview *preview);
|
||||
static GtkWidget * gimp_pattern_preview_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_pattern_preview_needs_popup (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_pattern_preview_get_type (void)
|
||||
{
|
||||
static GType preview_type = 0;
|
||||
|
||||
if (! preview_type)
|
||||
{
|
||||
static const GTypeInfo preview_info =
|
||||
{
|
||||
sizeof (GimpPatternPreviewClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gimp_pattern_preview_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpPatternPreview),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_pattern_preview_init,
|
||||
};
|
||||
|
||||
preview_type = g_type_register_static (GIMP_TYPE_PREVIEW,
|
||||
"GimpPatternPreview",
|
||||
&preview_info, 0);
|
||||
}
|
||||
|
||||
return preview_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass)
|
||||
{
|
||||
GimpPreviewClass *preview_class;
|
||||
|
||||
preview_class = GIMP_PREVIEW_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
preview_class->render = gimp_pattern_preview_render;
|
||||
preview_class->create_popup = gimp_pattern_preview_create_popup;
|
||||
preview_class->needs_popup = gimp_pattern_preview_needs_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_pattern_preview_init (GimpPatternPreview *pattern_preview)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_pattern_preview_render (GimpPreview *preview)
|
||||
{
|
||||
GimpPattern *pattern;
|
||||
TempBuf *temp_buf;
|
||||
gint width;
|
||||
gint height;
|
||||
gint pattern_width;
|
||||
gint pattern_height;
|
||||
|
||||
pattern = GIMP_PATTERN (preview->viewable);
|
||||
pattern_width = pattern->mask->width;
|
||||
pattern_height = pattern->mask->height;
|
||||
|
||||
width = preview->width;
|
||||
height = preview->height;
|
||||
|
||||
if (width == pattern_width &&
|
||||
height == pattern_height)
|
||||
{
|
||||
gimp_preview_render_preview (preview, pattern->mask, -1,
|
||||
GIMP_PREVIEW_BG_WHITE,
|
||||
GIMP_PREVIEW_BG_WHITE);
|
||||
|
||||
return;
|
||||
}
|
||||
else if (width <= pattern_width &&
|
||||
height <= pattern_height)
|
||||
{
|
||||
gimp_preview_render_preview (preview, pattern->mask, -1,
|
||||
GIMP_PREVIEW_BG_WHITE,
|
||||
GIMP_PREVIEW_BG_WHITE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
temp_buf = gimp_viewable_get_new_preview (preview->viewable,
|
||||
width, height);
|
||||
|
||||
gimp_preview_render_preview (preview, temp_buf, -1,
|
||||
GIMP_PREVIEW_BG_WHITE,
|
||||
GIMP_PREVIEW_BG_WHITE);
|
||||
|
||||
temp_buf_free (temp_buf);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_pattern_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
popup_width = GIMP_PATTERN (preview->viewable)->mask->width;
|
||||
popup_height = GIMP_PATTERN (preview->viewable)->mask->height;
|
||||
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_pattern_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpPattern *pattern;
|
||||
gint pattern_width;
|
||||
gint pattern_height;
|
||||
|
||||
pattern = GIMP_PATTERN (preview->viewable);
|
||||
pattern_width = pattern->mask->width;
|
||||
pattern_height = pattern->mask->height;
|
||||
|
||||
if (pattern_width > preview->width || pattern_height > preview->height)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimppatternpreview.h
|
||||
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_PATTERN_PREVIEW_H__
|
||||
#define __GIMP_PATTERN_PREVIEW_H__
|
||||
|
||||
#include "gimppreview.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_PATTERN_PREVIEW (gimp_pattern_preview_get_type ())
|
||||
#define GIMP_PATTERN_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PATTERN_PREVIEW, GimpPatternPreview))
|
||||
#define GIMP_PATTERN_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PATTERN_PREVIEW, GimpPatternPreviewClass))
|
||||
#define GIMP_IS_PATTERN_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GIMP_TYPE_PATTERN_PREVIEW))
|
||||
#define GIMP_IS_PATTERN_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PATTERN_PREVIEW))
|
||||
#define GIMP_PATTERN_PREVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PATTERN_PREVIEW, GimpPatternPreviewClass))
|
||||
|
||||
|
||||
typedef struct _GimpPatternPreviewClass GimpPatternPreviewClass;
|
||||
|
||||
struct _GimpPatternPreview
|
||||
{
|
||||
GimpPreview parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpPatternPreviewClass
|
||||
{
|
||||
GimpPreviewClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_pattern_preview_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_PATTERN_PREVIEW_H__ */
|
|
@ -0,0 +1,199 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimppreview-popup.h
|
||||
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimpviewable.h"
|
||||
|
||||
#include "gimppreview.h"
|
||||
#include "gimppreview-popup.h"
|
||||
|
||||
|
||||
#define PREVIEW_POPUP_DELAY 150
|
||||
|
||||
|
||||
typedef struct _GimpPreviewPopup GimpPreviewPopup;
|
||||
|
||||
struct _GimpPreviewPopup
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GimpViewable *viewable;
|
||||
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
gboolean dot_for_dot;
|
||||
gint button;
|
||||
gint button_x;
|
||||
gint button_y;
|
||||
|
||||
guint timeout_id;
|
||||
GtkWidget *popup;
|
||||
};
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_preview_popup_hide (GimpPreviewPopup *popup);
|
||||
static gboolean gimp_preview_popup_button_release (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpPreviewPopup *popup);
|
||||
static gboolean gimp_preview_popup_timeout (GimpPreviewPopup *popup);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
gboolean
|
||||
gimp_preview_popup_show (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpViewable *viewable,
|
||||
gint preview_width,
|
||||
gint preview_height,
|
||||
gboolean dot_for_dot)
|
||||
{
|
||||
GimpPreviewPopup *popup;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
||||
g_return_val_if_fail (bevent != NULL, FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), FALSE);
|
||||
|
||||
if (! gimp_viewable_get_popup_size (viewable,
|
||||
preview_width,
|
||||
preview_height,
|
||||
dot_for_dot,
|
||||
&popup_width,
|
||||
&popup_height))
|
||||
return FALSE;
|
||||
|
||||
popup = g_new0 (GimpPreviewPopup, 1);
|
||||
|
||||
popup->widget = widget;
|
||||
popup->viewable = viewable;
|
||||
popup->popup_width = popup_width;
|
||||
popup->popup_height = popup_height;
|
||||
popup->dot_for_dot = dot_for_dot;
|
||||
popup->button = bevent->button;
|
||||
popup->button_x = bevent->x;
|
||||
popup->button_y = bevent->y;
|
||||
|
||||
g_signal_connect (widget, "button_release_event",
|
||||
G_CALLBACK (gimp_preview_popup_button_release),
|
||||
popup);
|
||||
|
||||
popup->timeout_id = g_timeout_add (PREVIEW_POPUP_DELAY,
|
||||
(GSourceFunc) gimp_preview_popup_timeout,
|
||||
popup);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (widget), "gimp-preview-popup", popup,
|
||||
(GDestroyNotify) gimp_preview_popup_hide);
|
||||
|
||||
gtk_grab_add (widget);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_preview_popup_hide (GimpPreviewPopup *popup)
|
||||
{
|
||||
if (popup->timeout_id)
|
||||
g_source_remove (popup->timeout_id);
|
||||
|
||||
if (popup->popup)
|
||||
gtk_widget_destroy (popup->popup);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (popup->widget,
|
||||
gimp_preview_popup_button_release,
|
||||
popup);
|
||||
|
||||
gtk_grab_remove (popup->widget);
|
||||
|
||||
g_free (popup);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_popup_button_release (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpPreviewPopup *popup)
|
||||
{
|
||||
if (bevent->button == popup->button)
|
||||
g_object_set_data (G_OBJECT (popup->widget), "gimp-preview-popup", NULL);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_popup_timeout (GimpPreviewPopup *popup)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *preview;
|
||||
gint orig_x;
|
||||
gint orig_y;
|
||||
gint scr_width;
|
||||
gint scr_height;
|
||||
gint x;
|
||||
gint y;
|
||||
|
||||
popup->timeout_id = 0;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (window), frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
preview = gimp_preview_new_full (popup->viewable,
|
||||
popup->popup_width,
|
||||
popup->popup_height,
|
||||
0, TRUE, FALSE, FALSE);
|
||||
gimp_preview_set_dot_for_dot (GIMP_PREVIEW (preview), popup->dot_for_dot);
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview);
|
||||
gtk_widget_show (preview);
|
||||
|
||||
gdk_window_get_origin (popup->widget->window, &orig_x, &orig_y);
|
||||
scr_width = gdk_screen_width ();
|
||||
scr_height = gdk_screen_height ();
|
||||
|
||||
x = orig_x + popup->button_x - (popup->popup_width >> 1);
|
||||
y = orig_y + popup->button_y - (popup->popup_height >> 1);
|
||||
|
||||
x = CLAMP (x, 0, scr_width - popup->popup_width);
|
||||
y = CLAMP (y, 0, scr_height - popup->popup_height);
|
||||
|
||||
gtk_window_move (GTK_WINDOW (window), x, y);
|
||||
gtk_widget_show (window);
|
||||
|
||||
popup->popup = window;
|
||||
|
||||
return FALSE;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimppreview-popup.h
|
||||
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_PREVIEW_POPUP_H__
|
||||
#define __GIMP_PREVIEW_POPUP_H__
|
||||
|
||||
|
||||
gboolean gimp_preview_popup_show (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpViewable *viewable,
|
||||
gint preview_width,
|
||||
gint preview_height,
|
||||
gboolean dot_for_dot);
|
||||
|
||||
|
||||
#endif /* __GIMP_PREVIEW_POPUP_H__ */
|
|
@ -28,18 +28,12 @@
|
|||
#include "core/gimpbrush.h"
|
||||
#include "core/gimpbuffer.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpgradient.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimppalette.h"
|
||||
#include "core/gimppattern.h"
|
||||
|
||||
#include "gimpbrushpreview.h"
|
||||
#include "gimpbufferpreview.h"
|
||||
#include "gimpdrawablepreview.h"
|
||||
#include "gimpgradientpreview.h"
|
||||
#include "gimpimagepreview.h"
|
||||
#include "gimppalettepreview.h"
|
||||
#include "gimppatternpreview.h"
|
||||
|
||||
|
||||
GType
|
||||
|
@ -62,18 +56,6 @@ gimp_preview_type_from_viewable_type (GType viewable_type)
|
|||
{
|
||||
type = GIMP_TYPE_IMAGE_PREVIEW;
|
||||
}
|
||||
else if (g_type_is_a (viewable_type, GIMP_TYPE_PATTERN))
|
||||
{
|
||||
type = GIMP_TYPE_PATTERN_PREVIEW;
|
||||
}
|
||||
else if (g_type_is_a (viewable_type, GIMP_TYPE_GRADIENT))
|
||||
{
|
||||
type = GIMP_TYPE_GRADIENT_PREVIEW;
|
||||
}
|
||||
else if (g_type_is_a (viewable_type, GIMP_TYPE_PALETTE))
|
||||
{
|
||||
type = GIMP_TYPE_PALETTE_PREVIEW;
|
||||
}
|
||||
else if (g_type_is_a (viewable_type, GIMP_TYPE_BUFFER))
|
||||
{
|
||||
type = GIMP_TYPE_BUFFER_PREVIEW;
|
||||
|
|
|
@ -46,17 +46,16 @@
|
|||
|
||||
#include "gimpdnd.h"
|
||||
#include "gimppreview.h"
|
||||
#include "gimppreview-popup.h"
|
||||
#include "gimppreview-utils.h"
|
||||
|
||||
|
||||
#define PREVIEW_BYTES 3
|
||||
#define PREVIEW_BYTES 3
|
||||
|
||||
#define PREVIEW_POPUP_DELAY 150
|
||||
|
||||
#define PREVIEW_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK)
|
||||
#define PREVIEW_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK)
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -88,16 +87,6 @@ static gboolean gimp_preview_leave_notify_event (GtkWidget *widget,
|
|||
static gboolean gimp_preview_idle_update (GimpPreview *preview);
|
||||
static void gimp_preview_render (GimpPreview *preview);
|
||||
static void gimp_preview_real_render (GimpPreview *preview);
|
||||
static gboolean gimp_preview_needs_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_real_needs_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_create_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_real_create_popup (GimpPreview *preview);
|
||||
|
||||
static void gimp_preview_popup_show (GimpPreview *preview,
|
||||
gint x,
|
||||
gint y);
|
||||
static void gimp_preview_popup_hide (GimpPreview *preview);
|
||||
static gboolean gimp_preview_popup_timeout (GimpPreview *preview);
|
||||
|
||||
static void gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable);
|
||||
|
@ -201,8 +190,6 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
klass->extended_clicked = NULL;
|
||||
klass->context = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -232,9 +219,6 @@ gimp_preview_init (GimpPreview *preview)
|
|||
preview->in_button = FALSE;
|
||||
preview->idle_id = 0;
|
||||
preview->needs_render = TRUE;
|
||||
preview->popup_id = 0;
|
||||
preview->popup_x = 0;
|
||||
preview->popup_y = 0;
|
||||
|
||||
gtk_widget_set_events (GTK_WIDGET (preview), PREVIEW_EVENT_MASK);
|
||||
}
|
||||
|
@ -252,8 +236,6 @@ gimp_preview_destroy (GtkObject *object)
|
|||
preview->idle_id = 0;
|
||||
}
|
||||
|
||||
gimp_preview_popup_hide (preview);
|
||||
|
||||
if (preview->viewable)
|
||||
gimp_preview_set_viewable (preview, NULL);
|
||||
|
||||
|
@ -324,6 +306,17 @@ gimp_preview_expose_event (GtkWidget *widget,
|
|||
if (! GTK_WIDGET_DRAWABLE (widget))
|
||||
return FALSE;
|
||||
|
||||
border_rect.x = 0;
|
||||
border_rect.y = 0;
|
||||
border_rect.width = preview->width + 2 * preview->border_width;
|
||||
border_rect.height = preview->height + 2 * preview->border_width;
|
||||
|
||||
if (widget->allocation.width > border_rect.width)
|
||||
border_rect.x = (widget->allocation.width - border_rect.width) / 2;
|
||||
|
||||
if (widget->allocation.height > border_rect.height)
|
||||
border_rect.y = (widget->allocation.height - border_rect.height) / 2;
|
||||
|
||||
if (preview->no_preview_pixbuf)
|
||||
{
|
||||
buf_rect.width = gdk_pixbuf_get_width (preview->no_preview_pixbuf);
|
||||
|
@ -362,53 +355,39 @@ gimp_preview_expose_event (GtkWidget *widget,
|
|||
event->area.y);
|
||||
#endif
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (! preview->buffer)
|
||||
return FALSE;
|
||||
|
||||
border_rect.x = 0;
|
||||
border_rect.y = 0;
|
||||
border_rect.width = preview->width + 2 * preview->border_width;
|
||||
border_rect.height = preview->height + 2 * preview->border_width;
|
||||
|
||||
if (widget->allocation.width > border_rect.width)
|
||||
border_rect.x = (widget->allocation.width - border_rect.width) / 2;
|
||||
|
||||
if (widget->allocation.height > border_rect.height)
|
||||
border_rect.y = (widget->allocation.height - border_rect.height) / 2;
|
||||
|
||||
if (preview->border_width > 0)
|
||||
else if (preview->buffer)
|
||||
{
|
||||
buf_rect.x = border_rect.x + preview->border_width;
|
||||
buf_rect.y = border_rect.y + preview->border_width;
|
||||
buf_rect.width = border_rect.width - 2 * preview->border_width;
|
||||
buf_rect.height = border_rect.height - 2 * preview->border_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf_rect = border_rect;
|
||||
}
|
||||
if (preview->border_width > 0)
|
||||
{
|
||||
buf_rect.x = border_rect.x + preview->border_width;
|
||||
buf_rect.y = border_rect.y + preview->border_width;
|
||||
buf_rect.width = border_rect.width - 2 * preview->border_width;
|
||||
buf_rect.height = border_rect.height - 2 * preview->border_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf_rect = border_rect;
|
||||
}
|
||||
|
||||
if (gdk_rectangle_intersect (&event->area, &buf_rect, &render_rect))
|
||||
{
|
||||
buf = (preview->buffer +
|
||||
(render_rect.y - buf_rect.y) * preview->rowstride +
|
||||
(render_rect.x - buf_rect.x) * PREVIEW_BYTES);
|
||||
if (gdk_rectangle_intersect (&buf_rect, &event->area, &render_rect))
|
||||
{
|
||||
buf = (preview->buffer +
|
||||
(render_rect.y - buf_rect.y) * preview->rowstride +
|
||||
(render_rect.x - buf_rect.x) * PREVIEW_BYTES);
|
||||
|
||||
gdk_draw_rgb_image_dithalign (widget->window,
|
||||
widget->style->black_gc,
|
||||
render_rect.x,
|
||||
render_rect.y,
|
||||
render_rect.width,
|
||||
render_rect.height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
buf,
|
||||
preview->rowstride,
|
||||
event->area.x,
|
||||
event->area.y);
|
||||
gdk_draw_rgb_image_dithalign (widget->window,
|
||||
widget->style->black_gc,
|
||||
render_rect.x,
|
||||
render_rect.y,
|
||||
render_rect.width,
|
||||
render_rect.height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
buf,
|
||||
preview->rowstride,
|
||||
event->area.x,
|
||||
event->area.y);
|
||||
}
|
||||
}
|
||||
|
||||
if (preview->border_width > 0)
|
||||
|
@ -482,18 +461,20 @@ gimp_preview_button_press_event (GtkWidget *widget,
|
|||
|
||||
preview->press_state = bevent->state;
|
||||
|
||||
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
||||
{
|
||||
gimp_preview_popup_show (preview,
|
||||
bevent->x,
|
||||
bevent->y);
|
||||
if (preview->show_popup)
|
||||
{
|
||||
gimp_preview_popup_show (widget, bevent,
|
||||
preview->viewable,
|
||||
preview->width,
|
||||
preview->height,
|
||||
preview->dot_for_dot);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
preview->press_state = 0;
|
||||
|
||||
if (bevent->button == 3)
|
||||
if (bevent->button == 3)
|
||||
{
|
||||
g_signal_emit (widget, preview_signals[CONTEXT], 0);
|
||||
}
|
||||
|
@ -519,7 +500,6 @@ gimp_preview_button_release_event (GtkWidget *widget,
|
|||
GdkEventButton *bevent)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
gboolean click = TRUE;
|
||||
|
||||
preview = GIMP_PREVIEW (widget);
|
||||
|
||||
|
@ -529,17 +509,9 @@ gimp_preview_button_release_event (GtkWidget *widget,
|
|||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
||||
{
|
||||
click = (preview->popup_id != 0);
|
||||
}
|
||||
|
||||
gimp_preview_popup_hide (preview);
|
||||
|
||||
/* remove the grab _after_ hiding the popup */
|
||||
gtk_grab_remove (widget);
|
||||
|
||||
if (preview->clickable && click && preview->in_button)
|
||||
if (preview->clickable && preview->in_button)
|
||||
{
|
||||
if (preview->press_state &
|
||||
(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK))
|
||||
|
@ -920,11 +892,11 @@ gimp_preview_idle_update (GimpPreview *preview)
|
|||
{
|
||||
preview->idle_id = 0;
|
||||
|
||||
if (! preview->viewable)
|
||||
return FALSE;
|
||||
|
||||
preview->needs_render = TRUE;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (preview));
|
||||
if (preview->viewable)
|
||||
{
|
||||
preview->needs_render = TRUE;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (preview));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1017,132 +989,6 @@ gimp_preview_real_render (GimpPreview *preview)
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_PREVIEW (preview), FALSE);
|
||||
|
||||
return GIMP_PREVIEW_GET_CLASS (preview)->needs_popup (preview);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_real_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_PREVIEW (preview), NULL);
|
||||
|
||||
return GIMP_PREVIEW_GET_CLASS (preview)->create_popup (preview);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_preview_real_create_popup (GimpPreview *preview)
|
||||
{
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
popup_width = MIN (preview->width * 2, GIMP_PREVIEW_MAX_POPUP_SIZE);
|
||||
popup_height = MIN (preview->height * 2, GIMP_PREVIEW_MAX_POPUP_SIZE);
|
||||
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_popup_show (GimpPreview *preview,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
preview->popup_x = x;
|
||||
preview->popup_y = y;
|
||||
|
||||
preview->popup_id = g_timeout_add (PREVIEW_POPUP_DELAY,
|
||||
(GSourceFunc) gimp_preview_popup_timeout,
|
||||
preview);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_popup_hide (GimpPreview *preview)
|
||||
{
|
||||
if (preview->popup_id)
|
||||
{
|
||||
g_source_remove (preview->popup_id);
|
||||
|
||||
preview->popup_id = 0;
|
||||
preview->popup_x = 0;
|
||||
preview->popup_y = 0;
|
||||
}
|
||||
|
||||
g_object_set_data (G_OBJECT (preview), "gimp-preview-popup", NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_popup_timeout (GimpPreview *preview)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidget *window;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *popup_preview;
|
||||
gint orig_x;
|
||||
gint orig_y;
|
||||
gint scr_width;
|
||||
gint scr_height;
|
||||
gint x;
|
||||
gint y;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
widget = GTK_WIDGET (preview);
|
||||
|
||||
x = preview->popup_x;
|
||||
y = preview->popup_y;
|
||||
|
||||
preview->popup_id = 0;
|
||||
preview->popup_x = 0;
|
||||
preview->popup_y = 0;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (window), frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
popup_preview = gimp_preview_create_popup (preview);
|
||||
|
||||
popup_width = popup_preview->requisition.width;
|
||||
popup_height = popup_preview->requisition.height;
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), popup_preview);
|
||||
gtk_widget_show (popup_preview);
|
||||
|
||||
gdk_window_get_origin (widget->window, &orig_x, &orig_y);
|
||||
scr_width = gdk_screen_width ();
|
||||
scr_height = gdk_screen_height ();
|
||||
x = orig_x + x - (popup_width >> 1);
|
||||
y = orig_y + y - (popup_height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + popup_width > scr_width) ? scr_width - popup_width : x;
|
||||
y = (y + popup_height > scr_height) ? scr_height - popup_height : y;
|
||||
|
||||
gtk_window_move (GTK_WINDOW (window), x, y);
|
||||
gtk_widget_show (window);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (preview), "gimp-preview-popup", window,
|
||||
(GDestroyNotify) gtk_widget_destroy);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable)
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
|
||||
#define GIMP_PREVIEW_MAX_SIZE 1024
|
||||
#define GIMP_PREVIEW_MAX_POPUP_SIZE 256
|
||||
#define GIMP_PREVIEW_MAX_BORDER_WIDTH 16
|
||||
|
||||
|
||||
|
@ -71,9 +70,6 @@ struct _GimpPreview
|
|||
guint press_state;
|
||||
guint idle_id;
|
||||
gboolean needs_render;
|
||||
guint popup_id;
|
||||
gint popup_x;
|
||||
gint popup_y;
|
||||
};
|
||||
|
||||
struct _GimpPreviewClass
|
||||
|
@ -89,8 +85,6 @@ struct _GimpPreviewClass
|
|||
|
||||
/* virtual functions */
|
||||
void (* render) (GimpPreview *preview);
|
||||
gboolean (* needs_popup) (GimpPreview *preview);
|
||||
GtkWidget * (* create_popup) (GimpPreview *preview);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -46,17 +46,16 @@
|
|||
|
||||
#include "gimpdnd.h"
|
||||
#include "gimppreview.h"
|
||||
#include "gimppreview-popup.h"
|
||||
#include "gimppreview-utils.h"
|
||||
|
||||
|
||||
#define PREVIEW_BYTES 3
|
||||
#define PREVIEW_BYTES 3
|
||||
|
||||
#define PREVIEW_POPUP_DELAY 150
|
||||
|
||||
#define PREVIEW_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK)
|
||||
#define PREVIEW_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK)
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -88,16 +87,6 @@ static gboolean gimp_preview_leave_notify_event (GtkWidget *widget,
|
|||
static gboolean gimp_preview_idle_update (GimpPreview *preview);
|
||||
static void gimp_preview_render (GimpPreview *preview);
|
||||
static void gimp_preview_real_render (GimpPreview *preview);
|
||||
static gboolean gimp_preview_needs_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_real_needs_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_create_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_real_create_popup (GimpPreview *preview);
|
||||
|
||||
static void gimp_preview_popup_show (GimpPreview *preview,
|
||||
gint x,
|
||||
gint y);
|
||||
static void gimp_preview_popup_hide (GimpPreview *preview);
|
||||
static gboolean gimp_preview_popup_timeout (GimpPreview *preview);
|
||||
|
||||
static void gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable);
|
||||
|
@ -201,8 +190,6 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
klass->extended_clicked = NULL;
|
||||
klass->context = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -232,9 +219,6 @@ gimp_preview_init (GimpPreview *preview)
|
|||
preview->in_button = FALSE;
|
||||
preview->idle_id = 0;
|
||||
preview->needs_render = TRUE;
|
||||
preview->popup_id = 0;
|
||||
preview->popup_x = 0;
|
||||
preview->popup_y = 0;
|
||||
|
||||
gtk_widget_set_events (GTK_WIDGET (preview), PREVIEW_EVENT_MASK);
|
||||
}
|
||||
|
@ -252,8 +236,6 @@ gimp_preview_destroy (GtkObject *object)
|
|||
preview->idle_id = 0;
|
||||
}
|
||||
|
||||
gimp_preview_popup_hide (preview);
|
||||
|
||||
if (preview->viewable)
|
||||
gimp_preview_set_viewable (preview, NULL);
|
||||
|
||||
|
@ -324,6 +306,17 @@ gimp_preview_expose_event (GtkWidget *widget,
|
|||
if (! GTK_WIDGET_DRAWABLE (widget))
|
||||
return FALSE;
|
||||
|
||||
border_rect.x = 0;
|
||||
border_rect.y = 0;
|
||||
border_rect.width = preview->width + 2 * preview->border_width;
|
||||
border_rect.height = preview->height + 2 * preview->border_width;
|
||||
|
||||
if (widget->allocation.width > border_rect.width)
|
||||
border_rect.x = (widget->allocation.width - border_rect.width) / 2;
|
||||
|
||||
if (widget->allocation.height > border_rect.height)
|
||||
border_rect.y = (widget->allocation.height - border_rect.height) / 2;
|
||||
|
||||
if (preview->no_preview_pixbuf)
|
||||
{
|
||||
buf_rect.width = gdk_pixbuf_get_width (preview->no_preview_pixbuf);
|
||||
|
@ -362,53 +355,39 @@ gimp_preview_expose_event (GtkWidget *widget,
|
|||
event->area.y);
|
||||
#endif
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (! preview->buffer)
|
||||
return FALSE;
|
||||
|
||||
border_rect.x = 0;
|
||||
border_rect.y = 0;
|
||||
border_rect.width = preview->width + 2 * preview->border_width;
|
||||
border_rect.height = preview->height + 2 * preview->border_width;
|
||||
|
||||
if (widget->allocation.width > border_rect.width)
|
||||
border_rect.x = (widget->allocation.width - border_rect.width) / 2;
|
||||
|
||||
if (widget->allocation.height > border_rect.height)
|
||||
border_rect.y = (widget->allocation.height - border_rect.height) / 2;
|
||||
|
||||
if (preview->border_width > 0)
|
||||
else if (preview->buffer)
|
||||
{
|
||||
buf_rect.x = border_rect.x + preview->border_width;
|
||||
buf_rect.y = border_rect.y + preview->border_width;
|
||||
buf_rect.width = border_rect.width - 2 * preview->border_width;
|
||||
buf_rect.height = border_rect.height - 2 * preview->border_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf_rect = border_rect;
|
||||
}
|
||||
if (preview->border_width > 0)
|
||||
{
|
||||
buf_rect.x = border_rect.x + preview->border_width;
|
||||
buf_rect.y = border_rect.y + preview->border_width;
|
||||
buf_rect.width = border_rect.width - 2 * preview->border_width;
|
||||
buf_rect.height = border_rect.height - 2 * preview->border_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf_rect = border_rect;
|
||||
}
|
||||
|
||||
if (gdk_rectangle_intersect (&event->area, &buf_rect, &render_rect))
|
||||
{
|
||||
buf = (preview->buffer +
|
||||
(render_rect.y - buf_rect.y) * preview->rowstride +
|
||||
(render_rect.x - buf_rect.x) * PREVIEW_BYTES);
|
||||
if (gdk_rectangle_intersect (&buf_rect, &event->area, &render_rect))
|
||||
{
|
||||
buf = (preview->buffer +
|
||||
(render_rect.y - buf_rect.y) * preview->rowstride +
|
||||
(render_rect.x - buf_rect.x) * PREVIEW_BYTES);
|
||||
|
||||
gdk_draw_rgb_image_dithalign (widget->window,
|
||||
widget->style->black_gc,
|
||||
render_rect.x,
|
||||
render_rect.y,
|
||||
render_rect.width,
|
||||
render_rect.height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
buf,
|
||||
preview->rowstride,
|
||||
event->area.x,
|
||||
event->area.y);
|
||||
gdk_draw_rgb_image_dithalign (widget->window,
|
||||
widget->style->black_gc,
|
||||
render_rect.x,
|
||||
render_rect.y,
|
||||
render_rect.width,
|
||||
render_rect.height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
buf,
|
||||
preview->rowstride,
|
||||
event->area.x,
|
||||
event->area.y);
|
||||
}
|
||||
}
|
||||
|
||||
if (preview->border_width > 0)
|
||||
|
@ -482,18 +461,20 @@ gimp_preview_button_press_event (GtkWidget *widget,
|
|||
|
||||
preview->press_state = bevent->state;
|
||||
|
||||
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
||||
{
|
||||
gimp_preview_popup_show (preview,
|
||||
bevent->x,
|
||||
bevent->y);
|
||||
if (preview->show_popup)
|
||||
{
|
||||
gimp_preview_popup_show (widget, bevent,
|
||||
preview->viewable,
|
||||
preview->width,
|
||||
preview->height,
|
||||
preview->dot_for_dot);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
preview->press_state = 0;
|
||||
|
||||
if (bevent->button == 3)
|
||||
if (bevent->button == 3)
|
||||
{
|
||||
g_signal_emit (widget, preview_signals[CONTEXT], 0);
|
||||
}
|
||||
|
@ -519,7 +500,6 @@ gimp_preview_button_release_event (GtkWidget *widget,
|
|||
GdkEventButton *bevent)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
gboolean click = TRUE;
|
||||
|
||||
preview = GIMP_PREVIEW (widget);
|
||||
|
||||
|
@ -529,17 +509,9 @@ gimp_preview_button_release_event (GtkWidget *widget,
|
|||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
||||
{
|
||||
click = (preview->popup_id != 0);
|
||||
}
|
||||
|
||||
gimp_preview_popup_hide (preview);
|
||||
|
||||
/* remove the grab _after_ hiding the popup */
|
||||
gtk_grab_remove (widget);
|
||||
|
||||
if (preview->clickable && click && preview->in_button)
|
||||
if (preview->clickable && preview->in_button)
|
||||
{
|
||||
if (preview->press_state &
|
||||
(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK))
|
||||
|
@ -920,11 +892,11 @@ gimp_preview_idle_update (GimpPreview *preview)
|
|||
{
|
||||
preview->idle_id = 0;
|
||||
|
||||
if (! preview->viewable)
|
||||
return FALSE;
|
||||
|
||||
preview->needs_render = TRUE;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (preview));
|
||||
if (preview->viewable)
|
||||
{
|
||||
preview->needs_render = TRUE;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (preview));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1017,132 +989,6 @@ gimp_preview_real_render (GimpPreview *preview)
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_PREVIEW (preview), FALSE);
|
||||
|
||||
return GIMP_PREVIEW_GET_CLASS (preview)->needs_popup (preview);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_real_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_PREVIEW (preview), NULL);
|
||||
|
||||
return GIMP_PREVIEW_GET_CLASS (preview)->create_popup (preview);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_preview_real_create_popup (GimpPreview *preview)
|
||||
{
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
popup_width = MIN (preview->width * 2, GIMP_PREVIEW_MAX_POPUP_SIZE);
|
||||
popup_height = MIN (preview->height * 2, GIMP_PREVIEW_MAX_POPUP_SIZE);
|
||||
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_popup_show (GimpPreview *preview,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
preview->popup_x = x;
|
||||
preview->popup_y = y;
|
||||
|
||||
preview->popup_id = g_timeout_add (PREVIEW_POPUP_DELAY,
|
||||
(GSourceFunc) gimp_preview_popup_timeout,
|
||||
preview);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_popup_hide (GimpPreview *preview)
|
||||
{
|
||||
if (preview->popup_id)
|
||||
{
|
||||
g_source_remove (preview->popup_id);
|
||||
|
||||
preview->popup_id = 0;
|
||||
preview->popup_x = 0;
|
||||
preview->popup_y = 0;
|
||||
}
|
||||
|
||||
g_object_set_data (G_OBJECT (preview), "gimp-preview-popup", NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_popup_timeout (GimpPreview *preview)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidget *window;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *popup_preview;
|
||||
gint orig_x;
|
||||
gint orig_y;
|
||||
gint scr_width;
|
||||
gint scr_height;
|
||||
gint x;
|
||||
gint y;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
widget = GTK_WIDGET (preview);
|
||||
|
||||
x = preview->popup_x;
|
||||
y = preview->popup_y;
|
||||
|
||||
preview->popup_id = 0;
|
||||
preview->popup_x = 0;
|
||||
preview->popup_y = 0;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (window), frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
popup_preview = gimp_preview_create_popup (preview);
|
||||
|
||||
popup_width = popup_preview->requisition.width;
|
||||
popup_height = popup_preview->requisition.height;
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), popup_preview);
|
||||
gtk_widget_show (popup_preview);
|
||||
|
||||
gdk_window_get_origin (widget->window, &orig_x, &orig_y);
|
||||
scr_width = gdk_screen_width ();
|
||||
scr_height = gdk_screen_height ();
|
||||
x = orig_x + x - (popup_width >> 1);
|
||||
y = orig_y + y - (popup_height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + popup_width > scr_width) ? scr_width - popup_width : x;
|
||||
y = (y + popup_height > scr_height) ? scr_height - popup_height : y;
|
||||
|
||||
gtk_window_move (GTK_WINDOW (window), x, y);
|
||||
gtk_widget_show (window);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (preview), "gimp-preview-popup", window,
|
||||
(GDestroyNotify) gtk_widget_destroy);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable)
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
|
||||
#define GIMP_PREVIEW_MAX_SIZE 1024
|
||||
#define GIMP_PREVIEW_MAX_POPUP_SIZE 256
|
||||
#define GIMP_PREVIEW_MAX_BORDER_WIDTH 16
|
||||
|
||||
|
||||
|
@ -71,9 +70,6 @@ struct _GimpPreview
|
|||
guint press_state;
|
||||
guint idle_id;
|
||||
gboolean needs_render;
|
||||
guint popup_id;
|
||||
gint popup_x;
|
||||
gint popup_y;
|
||||
};
|
||||
|
||||
struct _GimpPreviewClass
|
||||
|
@ -89,8 +85,6 @@ struct _GimpPreviewClass
|
|||
|
||||
/* virtual functions */
|
||||
void (* render) (GimpPreview *preview);
|
||||
gboolean (* needs_popup) (GimpPreview *preview);
|
||||
GtkWidget * (* create_popup) (GimpPreview *preview);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ static void gimp_brush_preview_init (GimpBrushPreview *preview);
|
|||
|
||||
static void gimp_brush_preview_destroy (GtkObject *object);
|
||||
static void gimp_brush_preview_render (GimpPreview *preview);
|
||||
static GtkWidget * gimp_brush_preview_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview);
|
||||
|
||||
static gboolean gimp_brush_preview_render_timeout (gpointer data);
|
||||
|
||||
|
@ -87,11 +85,9 @@ gimp_brush_preview_class_init (GimpBrushPreviewClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->destroy = gimp_brush_preview_destroy;
|
||||
object_class->destroy = gimp_brush_preview_destroy;
|
||||
|
||||
preview_class->render = gimp_brush_preview_render;
|
||||
preview_class->create_popup = gimp_brush_preview_create_popup;
|
||||
preview_class->needs_popup = gimp_brush_preview_needs_popup;
|
||||
preview_class->render = gimp_brush_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -116,8 +112,7 @@ gimp_brush_preview_destroy (GtkObject *object)
|
|||
brush_preview->pipe_animation_index = 0;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -136,7 +131,6 @@ gimp_brush_preview_render (GimpPreview *preview)
|
|||
if (brush_preview->pipe_timeout_id)
|
||||
{
|
||||
g_source_remove (brush_preview->pipe_timeout_id);
|
||||
|
||||
brush_preview->pipe_timeout_id = 0;
|
||||
}
|
||||
|
||||
|
@ -295,41 +289,6 @@ gimp_brush_preview_render (GimpPreview *preview)
|
|||
temp_buf_free (temp_buf);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_brush_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
popup_width = GIMP_BRUSH (preview->viewable)->mask->width;
|
||||
popup_height = GIMP_BRUSH (preview->viewable)->mask->height;
|
||||
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_brush_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpBrush *brush;
|
||||
gint brush_width;
|
||||
gint brush_height;
|
||||
|
||||
brush = GIMP_BRUSH (preview->viewable);
|
||||
brush_width = brush->mask->width;
|
||||
brush_height = brush->mask->height;
|
||||
|
||||
if (GIMP_IS_BRUSH_PIPE (brush) ||
|
||||
brush_width > preview->width ||
|
||||
brush_height > preview->height)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_brush_preview_render_timeout (gpointer data)
|
||||
{
|
||||
|
|
|
@ -38,8 +38,7 @@
|
|||
static void gimp_drawable_preview_class_init (GimpDrawablePreviewClass *klass);
|
||||
static void gimp_drawable_preview_init (GimpDrawablePreview *preview);
|
||||
|
||||
static void gimp_drawable_preview_render (GimpPreview *preview);
|
||||
static GtkWidget * gimp_drawable_preview_create_popup (GimpPreview *preview);
|
||||
static void gimp_drawable_preview_render (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
@ -82,8 +81,7 @@ gimp_drawable_preview_class_init (GimpDrawablePreviewClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
preview_class->render = gimp_drawable_preview_render;
|
||||
preview_class->create_popup = gimp_drawable_preview_create_popup;
|
||||
preview_class->render = gimp_drawable_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -190,47 +188,3 @@ gimp_drawable_preview_render (GimpPreview *preview)
|
|||
|
||||
temp_buf_free (render_buf);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_drawable_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
GimpImage *gimage;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
gboolean scaling_up;
|
||||
|
||||
drawable = GIMP_DRAWABLE (preview->viewable);
|
||||
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||
|
||||
gimp_viewable_calc_preview_size (preview->viewable,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
MIN (preview->width * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
MIN (preview->height * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
preview->dot_for_dot,
|
||||
gimage ? gimage->xresolution : 1.0,
|
||||
gimage ? gimage->yresolution : 1.0,
|
||||
&popup_width,
|
||||
&popup_height,
|
||||
&scaling_up);
|
||||
|
||||
if (scaling_up)
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
static void gimp_image_preview_class_init (GimpImagePreviewClass *klass);
|
||||
static void gimp_image_preview_init (GimpImagePreview *preview);
|
||||
|
||||
static void gimp_image_preview_render (GimpPreview *preview);
|
||||
static GtkWidget * gimp_image_preview_create_popup (GimpPreview *preview);
|
||||
static void gimp_image_preview_render (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
@ -79,8 +78,7 @@ gimp_image_preview_class_init (GimpImagePreviewClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
preview_class->render = gimp_image_preview_render;
|
||||
preview_class->create_popup = gimp_image_preview_create_popup;
|
||||
preview_class->render = gimp_image_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -156,45 +154,3 @@ gimp_image_preview_render (GimpPreview *preview)
|
|||
|
||||
temp_buf_free (render_buf);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_image_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
gboolean scaling_up;
|
||||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
gimp_viewable_calc_preview_size (preview->viewable,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
MIN (preview->width * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
MIN (preview->height * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
preview->dot_for_dot,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&popup_width,
|
||||
&popup_height,
|
||||
&scaling_up);
|
||||
|
||||
if (scaling_up)
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "core/gimpimage-undo.h"
|
||||
#include "core/gimpundostack.h"
|
||||
|
||||
#include "gimpcontainerlistview.h"
|
||||
#include "gimpcontainertreeview.h"
|
||||
#include "gimpundoeditor.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
@ -106,7 +106,7 @@ gimp_undo_editor_init (GimpUndoEditor *undo_editor)
|
|||
{
|
||||
undo_editor->container = NULL;
|
||||
|
||||
undo_editor->view = gimp_container_list_view_new (NULL,
|
||||
undo_editor->view = gimp_container_tree_view_new (NULL,
|
||||
NULL,
|
||||
GIMP_PREVIEW_SIZE_MEDIUM,
|
||||
FALSE, 3, 3);
|
||||
|
|
|
@ -0,0 +1,199 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimppreview-popup.h
|
||||
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimpviewable.h"
|
||||
|
||||
#include "gimppreview.h"
|
||||
#include "gimppreview-popup.h"
|
||||
|
||||
|
||||
#define PREVIEW_POPUP_DELAY 150
|
||||
|
||||
|
||||
typedef struct _GimpPreviewPopup GimpPreviewPopup;
|
||||
|
||||
struct _GimpPreviewPopup
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GimpViewable *viewable;
|
||||
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
gboolean dot_for_dot;
|
||||
gint button;
|
||||
gint button_x;
|
||||
gint button_y;
|
||||
|
||||
guint timeout_id;
|
||||
GtkWidget *popup;
|
||||
};
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_preview_popup_hide (GimpPreviewPopup *popup);
|
||||
static gboolean gimp_preview_popup_button_release (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpPreviewPopup *popup);
|
||||
static gboolean gimp_preview_popup_timeout (GimpPreviewPopup *popup);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
gboolean
|
||||
gimp_preview_popup_show (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpViewable *viewable,
|
||||
gint preview_width,
|
||||
gint preview_height,
|
||||
gboolean dot_for_dot)
|
||||
{
|
||||
GimpPreviewPopup *popup;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
||||
g_return_val_if_fail (bevent != NULL, FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), FALSE);
|
||||
|
||||
if (! gimp_viewable_get_popup_size (viewable,
|
||||
preview_width,
|
||||
preview_height,
|
||||
dot_for_dot,
|
||||
&popup_width,
|
||||
&popup_height))
|
||||
return FALSE;
|
||||
|
||||
popup = g_new0 (GimpPreviewPopup, 1);
|
||||
|
||||
popup->widget = widget;
|
||||
popup->viewable = viewable;
|
||||
popup->popup_width = popup_width;
|
||||
popup->popup_height = popup_height;
|
||||
popup->dot_for_dot = dot_for_dot;
|
||||
popup->button = bevent->button;
|
||||
popup->button_x = bevent->x;
|
||||
popup->button_y = bevent->y;
|
||||
|
||||
g_signal_connect (widget, "button_release_event",
|
||||
G_CALLBACK (gimp_preview_popup_button_release),
|
||||
popup);
|
||||
|
||||
popup->timeout_id = g_timeout_add (PREVIEW_POPUP_DELAY,
|
||||
(GSourceFunc) gimp_preview_popup_timeout,
|
||||
popup);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (widget), "gimp-preview-popup", popup,
|
||||
(GDestroyNotify) gimp_preview_popup_hide);
|
||||
|
||||
gtk_grab_add (widget);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_preview_popup_hide (GimpPreviewPopup *popup)
|
||||
{
|
||||
if (popup->timeout_id)
|
||||
g_source_remove (popup->timeout_id);
|
||||
|
||||
if (popup->popup)
|
||||
gtk_widget_destroy (popup->popup);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (popup->widget,
|
||||
gimp_preview_popup_button_release,
|
||||
popup);
|
||||
|
||||
gtk_grab_remove (popup->widget);
|
||||
|
||||
g_free (popup);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_popup_button_release (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpPreviewPopup *popup)
|
||||
{
|
||||
if (bevent->button == popup->button)
|
||||
g_object_set_data (G_OBJECT (popup->widget), "gimp-preview-popup", NULL);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_popup_timeout (GimpPreviewPopup *popup)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *preview;
|
||||
gint orig_x;
|
||||
gint orig_y;
|
||||
gint scr_width;
|
||||
gint scr_height;
|
||||
gint x;
|
||||
gint y;
|
||||
|
||||
popup->timeout_id = 0;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (window), frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
preview = gimp_preview_new_full (popup->viewable,
|
||||
popup->popup_width,
|
||||
popup->popup_height,
|
||||
0, TRUE, FALSE, FALSE);
|
||||
gimp_preview_set_dot_for_dot (GIMP_PREVIEW (preview), popup->dot_for_dot);
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview);
|
||||
gtk_widget_show (preview);
|
||||
|
||||
gdk_window_get_origin (popup->widget->window, &orig_x, &orig_y);
|
||||
scr_width = gdk_screen_width ();
|
||||
scr_height = gdk_screen_height ();
|
||||
|
||||
x = orig_x + popup->button_x - (popup->popup_width >> 1);
|
||||
y = orig_y + popup->button_y - (popup->popup_height >> 1);
|
||||
|
||||
x = CLAMP (x, 0, scr_width - popup->popup_width);
|
||||
y = CLAMP (y, 0, scr_height - popup->popup_height);
|
||||
|
||||
gtk_window_move (GTK_WINDOW (window), x, y);
|
||||
gtk_widget_show (window);
|
||||
|
||||
popup->popup = window;
|
||||
|
||||
return FALSE;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimppreview-popup.h
|
||||
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_PREVIEW_POPUP_H__
|
||||
#define __GIMP_PREVIEW_POPUP_H__
|
||||
|
||||
|
||||
gboolean gimp_preview_popup_show (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpViewable *viewable,
|
||||
gint preview_width,
|
||||
gint preview_height,
|
||||
gboolean dot_for_dot);
|
||||
|
||||
|
||||
#endif /* __GIMP_PREVIEW_POPUP_H__ */
|
|
@ -46,17 +46,16 @@
|
|||
|
||||
#include "gimpdnd.h"
|
||||
#include "gimppreview.h"
|
||||
#include "gimppreview-popup.h"
|
||||
#include "gimppreview-utils.h"
|
||||
|
||||
|
||||
#define PREVIEW_BYTES 3
|
||||
#define PREVIEW_BYTES 3
|
||||
|
||||
#define PREVIEW_POPUP_DELAY 150
|
||||
|
||||
#define PREVIEW_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK)
|
||||
#define PREVIEW_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK)
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -88,16 +87,6 @@ static gboolean gimp_preview_leave_notify_event (GtkWidget *widget,
|
|||
static gboolean gimp_preview_idle_update (GimpPreview *preview);
|
||||
static void gimp_preview_render (GimpPreview *preview);
|
||||
static void gimp_preview_real_render (GimpPreview *preview);
|
||||
static gboolean gimp_preview_needs_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_real_needs_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_create_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_real_create_popup (GimpPreview *preview);
|
||||
|
||||
static void gimp_preview_popup_show (GimpPreview *preview,
|
||||
gint x,
|
||||
gint y);
|
||||
static void gimp_preview_popup_hide (GimpPreview *preview);
|
||||
static gboolean gimp_preview_popup_timeout (GimpPreview *preview);
|
||||
|
||||
static void gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable);
|
||||
|
@ -201,8 +190,6 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
klass->extended_clicked = NULL;
|
||||
klass->context = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -232,9 +219,6 @@ gimp_preview_init (GimpPreview *preview)
|
|||
preview->in_button = FALSE;
|
||||
preview->idle_id = 0;
|
||||
preview->needs_render = TRUE;
|
||||
preview->popup_id = 0;
|
||||
preview->popup_x = 0;
|
||||
preview->popup_y = 0;
|
||||
|
||||
gtk_widget_set_events (GTK_WIDGET (preview), PREVIEW_EVENT_MASK);
|
||||
}
|
||||
|
@ -252,8 +236,6 @@ gimp_preview_destroy (GtkObject *object)
|
|||
preview->idle_id = 0;
|
||||
}
|
||||
|
||||
gimp_preview_popup_hide (preview);
|
||||
|
||||
if (preview->viewable)
|
||||
gimp_preview_set_viewable (preview, NULL);
|
||||
|
||||
|
@ -324,6 +306,17 @@ gimp_preview_expose_event (GtkWidget *widget,
|
|||
if (! GTK_WIDGET_DRAWABLE (widget))
|
||||
return FALSE;
|
||||
|
||||
border_rect.x = 0;
|
||||
border_rect.y = 0;
|
||||
border_rect.width = preview->width + 2 * preview->border_width;
|
||||
border_rect.height = preview->height + 2 * preview->border_width;
|
||||
|
||||
if (widget->allocation.width > border_rect.width)
|
||||
border_rect.x = (widget->allocation.width - border_rect.width) / 2;
|
||||
|
||||
if (widget->allocation.height > border_rect.height)
|
||||
border_rect.y = (widget->allocation.height - border_rect.height) / 2;
|
||||
|
||||
if (preview->no_preview_pixbuf)
|
||||
{
|
||||
buf_rect.width = gdk_pixbuf_get_width (preview->no_preview_pixbuf);
|
||||
|
@ -362,53 +355,39 @@ gimp_preview_expose_event (GtkWidget *widget,
|
|||
event->area.y);
|
||||
#endif
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (! preview->buffer)
|
||||
return FALSE;
|
||||
|
||||
border_rect.x = 0;
|
||||
border_rect.y = 0;
|
||||
border_rect.width = preview->width + 2 * preview->border_width;
|
||||
border_rect.height = preview->height + 2 * preview->border_width;
|
||||
|
||||
if (widget->allocation.width > border_rect.width)
|
||||
border_rect.x = (widget->allocation.width - border_rect.width) / 2;
|
||||
|
||||
if (widget->allocation.height > border_rect.height)
|
||||
border_rect.y = (widget->allocation.height - border_rect.height) / 2;
|
||||
|
||||
if (preview->border_width > 0)
|
||||
else if (preview->buffer)
|
||||
{
|
||||
buf_rect.x = border_rect.x + preview->border_width;
|
||||
buf_rect.y = border_rect.y + preview->border_width;
|
||||
buf_rect.width = border_rect.width - 2 * preview->border_width;
|
||||
buf_rect.height = border_rect.height - 2 * preview->border_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf_rect = border_rect;
|
||||
}
|
||||
if (preview->border_width > 0)
|
||||
{
|
||||
buf_rect.x = border_rect.x + preview->border_width;
|
||||
buf_rect.y = border_rect.y + preview->border_width;
|
||||
buf_rect.width = border_rect.width - 2 * preview->border_width;
|
||||
buf_rect.height = border_rect.height - 2 * preview->border_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf_rect = border_rect;
|
||||
}
|
||||
|
||||
if (gdk_rectangle_intersect (&event->area, &buf_rect, &render_rect))
|
||||
{
|
||||
buf = (preview->buffer +
|
||||
(render_rect.y - buf_rect.y) * preview->rowstride +
|
||||
(render_rect.x - buf_rect.x) * PREVIEW_BYTES);
|
||||
if (gdk_rectangle_intersect (&buf_rect, &event->area, &render_rect))
|
||||
{
|
||||
buf = (preview->buffer +
|
||||
(render_rect.y - buf_rect.y) * preview->rowstride +
|
||||
(render_rect.x - buf_rect.x) * PREVIEW_BYTES);
|
||||
|
||||
gdk_draw_rgb_image_dithalign (widget->window,
|
||||
widget->style->black_gc,
|
||||
render_rect.x,
|
||||
render_rect.y,
|
||||
render_rect.width,
|
||||
render_rect.height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
buf,
|
||||
preview->rowstride,
|
||||
event->area.x,
|
||||
event->area.y);
|
||||
gdk_draw_rgb_image_dithalign (widget->window,
|
||||
widget->style->black_gc,
|
||||
render_rect.x,
|
||||
render_rect.y,
|
||||
render_rect.width,
|
||||
render_rect.height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
buf,
|
||||
preview->rowstride,
|
||||
event->area.x,
|
||||
event->area.y);
|
||||
}
|
||||
}
|
||||
|
||||
if (preview->border_width > 0)
|
||||
|
@ -482,18 +461,20 @@ gimp_preview_button_press_event (GtkWidget *widget,
|
|||
|
||||
preview->press_state = bevent->state;
|
||||
|
||||
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
||||
{
|
||||
gimp_preview_popup_show (preview,
|
||||
bevent->x,
|
||||
bevent->y);
|
||||
if (preview->show_popup)
|
||||
{
|
||||
gimp_preview_popup_show (widget, bevent,
|
||||
preview->viewable,
|
||||
preview->width,
|
||||
preview->height,
|
||||
preview->dot_for_dot);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
preview->press_state = 0;
|
||||
|
||||
if (bevent->button == 3)
|
||||
if (bevent->button == 3)
|
||||
{
|
||||
g_signal_emit (widget, preview_signals[CONTEXT], 0);
|
||||
}
|
||||
|
@ -519,7 +500,6 @@ gimp_preview_button_release_event (GtkWidget *widget,
|
|||
GdkEventButton *bevent)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
gboolean click = TRUE;
|
||||
|
||||
preview = GIMP_PREVIEW (widget);
|
||||
|
||||
|
@ -529,17 +509,9 @@ gimp_preview_button_release_event (GtkWidget *widget,
|
|||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
||||
{
|
||||
click = (preview->popup_id != 0);
|
||||
}
|
||||
|
||||
gimp_preview_popup_hide (preview);
|
||||
|
||||
/* remove the grab _after_ hiding the popup */
|
||||
gtk_grab_remove (widget);
|
||||
|
||||
if (preview->clickable && click && preview->in_button)
|
||||
if (preview->clickable && preview->in_button)
|
||||
{
|
||||
if (preview->press_state &
|
||||
(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK))
|
||||
|
@ -920,11 +892,11 @@ gimp_preview_idle_update (GimpPreview *preview)
|
|||
{
|
||||
preview->idle_id = 0;
|
||||
|
||||
if (! preview->viewable)
|
||||
return FALSE;
|
||||
|
||||
preview->needs_render = TRUE;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (preview));
|
||||
if (preview->viewable)
|
||||
{
|
||||
preview->needs_render = TRUE;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (preview));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1017,132 +989,6 @@ gimp_preview_real_render (GimpPreview *preview)
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_PREVIEW (preview), FALSE);
|
||||
|
||||
return GIMP_PREVIEW_GET_CLASS (preview)->needs_popup (preview);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_real_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_PREVIEW (preview), NULL);
|
||||
|
||||
return GIMP_PREVIEW_GET_CLASS (preview)->create_popup (preview);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_preview_real_create_popup (GimpPreview *preview)
|
||||
{
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
popup_width = MIN (preview->width * 2, GIMP_PREVIEW_MAX_POPUP_SIZE);
|
||||
popup_height = MIN (preview->height * 2, GIMP_PREVIEW_MAX_POPUP_SIZE);
|
||||
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_popup_show (GimpPreview *preview,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
preview->popup_x = x;
|
||||
preview->popup_y = y;
|
||||
|
||||
preview->popup_id = g_timeout_add (PREVIEW_POPUP_DELAY,
|
||||
(GSourceFunc) gimp_preview_popup_timeout,
|
||||
preview);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_popup_hide (GimpPreview *preview)
|
||||
{
|
||||
if (preview->popup_id)
|
||||
{
|
||||
g_source_remove (preview->popup_id);
|
||||
|
||||
preview->popup_id = 0;
|
||||
preview->popup_x = 0;
|
||||
preview->popup_y = 0;
|
||||
}
|
||||
|
||||
g_object_set_data (G_OBJECT (preview), "gimp-preview-popup", NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_popup_timeout (GimpPreview *preview)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidget *window;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *popup_preview;
|
||||
gint orig_x;
|
||||
gint orig_y;
|
||||
gint scr_width;
|
||||
gint scr_height;
|
||||
gint x;
|
||||
gint y;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
widget = GTK_WIDGET (preview);
|
||||
|
||||
x = preview->popup_x;
|
||||
y = preview->popup_y;
|
||||
|
||||
preview->popup_id = 0;
|
||||
preview->popup_x = 0;
|
||||
preview->popup_y = 0;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (window), frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
popup_preview = gimp_preview_create_popup (preview);
|
||||
|
||||
popup_width = popup_preview->requisition.width;
|
||||
popup_height = popup_preview->requisition.height;
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), popup_preview);
|
||||
gtk_widget_show (popup_preview);
|
||||
|
||||
gdk_window_get_origin (widget->window, &orig_x, &orig_y);
|
||||
scr_width = gdk_screen_width ();
|
||||
scr_height = gdk_screen_height ();
|
||||
x = orig_x + x - (popup_width >> 1);
|
||||
y = orig_y + y - (popup_height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + popup_width > scr_width) ? scr_width - popup_width : x;
|
||||
y = (y + popup_height > scr_height) ? scr_height - popup_height : y;
|
||||
|
||||
gtk_window_move (GTK_WINDOW (window), x, y);
|
||||
gtk_widget_show (window);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (preview), "gimp-preview-popup", window,
|
||||
(GDestroyNotify) gtk_widget_destroy);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable)
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
|
||||
#define GIMP_PREVIEW_MAX_SIZE 1024
|
||||
#define GIMP_PREVIEW_MAX_POPUP_SIZE 256
|
||||
#define GIMP_PREVIEW_MAX_BORDER_WIDTH 16
|
||||
|
||||
|
||||
|
@ -71,9 +70,6 @@ struct _GimpPreview
|
|||
guint press_state;
|
||||
guint idle_id;
|
||||
gboolean needs_render;
|
||||
guint popup_id;
|
||||
gint popup_x;
|
||||
gint popup_y;
|
||||
};
|
||||
|
||||
struct _GimpPreviewClass
|
||||
|
@ -89,8 +85,6 @@ struct _GimpPreviewClass
|
|||
|
||||
/* virtual functions */
|
||||
void (* render) (GimpPreview *preview);
|
||||
gboolean (* needs_popup) (GimpPreview *preview);
|
||||
GtkWidget * (* create_popup) (GimpPreview *preview);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -46,17 +46,16 @@
|
|||
|
||||
#include "gimpdnd.h"
|
||||
#include "gimppreview.h"
|
||||
#include "gimppreview-popup.h"
|
||||
#include "gimppreview-utils.h"
|
||||
|
||||
|
||||
#define PREVIEW_BYTES 3
|
||||
#define PREVIEW_BYTES 3
|
||||
|
||||
#define PREVIEW_POPUP_DELAY 150
|
||||
|
||||
#define PREVIEW_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK)
|
||||
#define PREVIEW_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK)
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -88,16 +87,6 @@ static gboolean gimp_preview_leave_notify_event (GtkWidget *widget,
|
|||
static gboolean gimp_preview_idle_update (GimpPreview *preview);
|
||||
static void gimp_preview_render (GimpPreview *preview);
|
||||
static void gimp_preview_real_render (GimpPreview *preview);
|
||||
static gboolean gimp_preview_needs_popup (GimpPreview *preview);
|
||||
static gboolean gimp_preview_real_needs_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_create_popup (GimpPreview *preview);
|
||||
static GtkWidget * gimp_preview_real_create_popup (GimpPreview *preview);
|
||||
|
||||
static void gimp_preview_popup_show (GimpPreview *preview,
|
||||
gint x,
|
||||
gint y);
|
||||
static void gimp_preview_popup_hide (GimpPreview *preview);
|
||||
static gboolean gimp_preview_popup_timeout (GimpPreview *preview);
|
||||
|
||||
static void gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable);
|
||||
|
@ -201,8 +190,6 @@ gimp_preview_class_init (GimpPreviewClass *klass)
|
|||
klass->extended_clicked = NULL;
|
||||
klass->context = NULL;
|
||||
klass->render = gimp_preview_real_render;
|
||||
klass->needs_popup = gimp_preview_real_needs_popup;
|
||||
klass->create_popup = gimp_preview_real_create_popup;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -232,9 +219,6 @@ gimp_preview_init (GimpPreview *preview)
|
|||
preview->in_button = FALSE;
|
||||
preview->idle_id = 0;
|
||||
preview->needs_render = TRUE;
|
||||
preview->popup_id = 0;
|
||||
preview->popup_x = 0;
|
||||
preview->popup_y = 0;
|
||||
|
||||
gtk_widget_set_events (GTK_WIDGET (preview), PREVIEW_EVENT_MASK);
|
||||
}
|
||||
|
@ -252,8 +236,6 @@ gimp_preview_destroy (GtkObject *object)
|
|||
preview->idle_id = 0;
|
||||
}
|
||||
|
||||
gimp_preview_popup_hide (preview);
|
||||
|
||||
if (preview->viewable)
|
||||
gimp_preview_set_viewable (preview, NULL);
|
||||
|
||||
|
@ -324,6 +306,17 @@ gimp_preview_expose_event (GtkWidget *widget,
|
|||
if (! GTK_WIDGET_DRAWABLE (widget))
|
||||
return FALSE;
|
||||
|
||||
border_rect.x = 0;
|
||||
border_rect.y = 0;
|
||||
border_rect.width = preview->width + 2 * preview->border_width;
|
||||
border_rect.height = preview->height + 2 * preview->border_width;
|
||||
|
||||
if (widget->allocation.width > border_rect.width)
|
||||
border_rect.x = (widget->allocation.width - border_rect.width) / 2;
|
||||
|
||||
if (widget->allocation.height > border_rect.height)
|
||||
border_rect.y = (widget->allocation.height - border_rect.height) / 2;
|
||||
|
||||
if (preview->no_preview_pixbuf)
|
||||
{
|
||||
buf_rect.width = gdk_pixbuf_get_width (preview->no_preview_pixbuf);
|
||||
|
@ -362,53 +355,39 @@ gimp_preview_expose_event (GtkWidget *widget,
|
|||
event->area.y);
|
||||
#endif
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (! preview->buffer)
|
||||
return FALSE;
|
||||
|
||||
border_rect.x = 0;
|
||||
border_rect.y = 0;
|
||||
border_rect.width = preview->width + 2 * preview->border_width;
|
||||
border_rect.height = preview->height + 2 * preview->border_width;
|
||||
|
||||
if (widget->allocation.width > border_rect.width)
|
||||
border_rect.x = (widget->allocation.width - border_rect.width) / 2;
|
||||
|
||||
if (widget->allocation.height > border_rect.height)
|
||||
border_rect.y = (widget->allocation.height - border_rect.height) / 2;
|
||||
|
||||
if (preview->border_width > 0)
|
||||
else if (preview->buffer)
|
||||
{
|
||||
buf_rect.x = border_rect.x + preview->border_width;
|
||||
buf_rect.y = border_rect.y + preview->border_width;
|
||||
buf_rect.width = border_rect.width - 2 * preview->border_width;
|
||||
buf_rect.height = border_rect.height - 2 * preview->border_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf_rect = border_rect;
|
||||
}
|
||||
if (preview->border_width > 0)
|
||||
{
|
||||
buf_rect.x = border_rect.x + preview->border_width;
|
||||
buf_rect.y = border_rect.y + preview->border_width;
|
||||
buf_rect.width = border_rect.width - 2 * preview->border_width;
|
||||
buf_rect.height = border_rect.height - 2 * preview->border_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf_rect = border_rect;
|
||||
}
|
||||
|
||||
if (gdk_rectangle_intersect (&event->area, &buf_rect, &render_rect))
|
||||
{
|
||||
buf = (preview->buffer +
|
||||
(render_rect.y - buf_rect.y) * preview->rowstride +
|
||||
(render_rect.x - buf_rect.x) * PREVIEW_BYTES);
|
||||
if (gdk_rectangle_intersect (&buf_rect, &event->area, &render_rect))
|
||||
{
|
||||
buf = (preview->buffer +
|
||||
(render_rect.y - buf_rect.y) * preview->rowstride +
|
||||
(render_rect.x - buf_rect.x) * PREVIEW_BYTES);
|
||||
|
||||
gdk_draw_rgb_image_dithalign (widget->window,
|
||||
widget->style->black_gc,
|
||||
render_rect.x,
|
||||
render_rect.y,
|
||||
render_rect.width,
|
||||
render_rect.height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
buf,
|
||||
preview->rowstride,
|
||||
event->area.x,
|
||||
event->area.y);
|
||||
gdk_draw_rgb_image_dithalign (widget->window,
|
||||
widget->style->black_gc,
|
||||
render_rect.x,
|
||||
render_rect.y,
|
||||
render_rect.width,
|
||||
render_rect.height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
buf,
|
||||
preview->rowstride,
|
||||
event->area.x,
|
||||
event->area.y);
|
||||
}
|
||||
}
|
||||
|
||||
if (preview->border_width > 0)
|
||||
|
@ -482,18 +461,20 @@ gimp_preview_button_press_event (GtkWidget *widget,
|
|||
|
||||
preview->press_state = bevent->state;
|
||||
|
||||
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
||||
{
|
||||
gimp_preview_popup_show (preview,
|
||||
bevent->x,
|
||||
bevent->y);
|
||||
if (preview->show_popup)
|
||||
{
|
||||
gimp_preview_popup_show (widget, bevent,
|
||||
preview->viewable,
|
||||
preview->width,
|
||||
preview->height,
|
||||
preview->dot_for_dot);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
preview->press_state = 0;
|
||||
|
||||
if (bevent->button == 3)
|
||||
if (bevent->button == 3)
|
||||
{
|
||||
g_signal_emit (widget, preview_signals[CONTEXT], 0);
|
||||
}
|
||||
|
@ -519,7 +500,6 @@ gimp_preview_button_release_event (GtkWidget *widget,
|
|||
GdkEventButton *bevent)
|
||||
{
|
||||
GimpPreview *preview;
|
||||
gboolean click = TRUE;
|
||||
|
||||
preview = GIMP_PREVIEW (widget);
|
||||
|
||||
|
@ -529,17 +509,9 @@ gimp_preview_button_release_event (GtkWidget *widget,
|
|||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
if (preview->show_popup && gimp_preview_needs_popup (preview))
|
||||
{
|
||||
click = (preview->popup_id != 0);
|
||||
}
|
||||
|
||||
gimp_preview_popup_hide (preview);
|
||||
|
||||
/* remove the grab _after_ hiding the popup */
|
||||
gtk_grab_remove (widget);
|
||||
|
||||
if (preview->clickable && click && preview->in_button)
|
||||
if (preview->clickable && preview->in_button)
|
||||
{
|
||||
if (preview->press_state &
|
||||
(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK))
|
||||
|
@ -920,11 +892,11 @@ gimp_preview_idle_update (GimpPreview *preview)
|
|||
{
|
||||
preview->idle_id = 0;
|
||||
|
||||
if (! preview->viewable)
|
||||
return FALSE;
|
||||
|
||||
preview->needs_render = TRUE;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (preview));
|
||||
if (preview->viewable)
|
||||
{
|
||||
preview->needs_render = TRUE;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (preview));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1017,132 +989,6 @@ gimp_preview_real_render (GimpPreview *preview)
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_PREVIEW (preview), FALSE);
|
||||
|
||||
return GIMP_PREVIEW_GET_CLASS (preview)->needs_popup (preview);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_real_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_PREVIEW (preview), NULL);
|
||||
|
||||
return GIMP_PREVIEW_GET_CLASS (preview)->create_popup (preview);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_preview_real_create_popup (GimpPreview *preview)
|
||||
{
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
popup_width = MIN (preview->width * 2, GIMP_PREVIEW_MAX_POPUP_SIZE);
|
||||
popup_height = MIN (preview->height * 2, GIMP_PREVIEW_MAX_POPUP_SIZE);
|
||||
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_popup_show (GimpPreview *preview,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
preview->popup_x = x;
|
||||
preview->popup_y = y;
|
||||
|
||||
preview->popup_id = g_timeout_add (PREVIEW_POPUP_DELAY,
|
||||
(GSourceFunc) gimp_preview_popup_timeout,
|
||||
preview);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_popup_hide (GimpPreview *preview)
|
||||
{
|
||||
if (preview->popup_id)
|
||||
{
|
||||
g_source_remove (preview->popup_id);
|
||||
|
||||
preview->popup_id = 0;
|
||||
preview->popup_x = 0;
|
||||
preview->popup_y = 0;
|
||||
}
|
||||
|
||||
g_object_set_data (G_OBJECT (preview), "gimp-preview-popup", NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_preview_popup_timeout (GimpPreview *preview)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidget *window;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *popup_preview;
|
||||
gint orig_x;
|
||||
gint orig_y;
|
||||
gint scr_width;
|
||||
gint scr_height;
|
||||
gint x;
|
||||
gint y;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
widget = GTK_WIDGET (preview);
|
||||
|
||||
x = preview->popup_x;
|
||||
y = preview->popup_y;
|
||||
|
||||
preview->popup_id = 0;
|
||||
preview->popup_x = 0;
|
||||
preview->popup_y = 0;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_container_add (GTK_CONTAINER (window), frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
popup_preview = gimp_preview_create_popup (preview);
|
||||
|
||||
popup_width = popup_preview->requisition.width;
|
||||
popup_height = popup_preview->requisition.height;
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), popup_preview);
|
||||
gtk_widget_show (popup_preview);
|
||||
|
||||
gdk_window_get_origin (widget->window, &orig_x, &orig_y);
|
||||
scr_width = gdk_screen_width ();
|
||||
scr_height = gdk_screen_height ();
|
||||
x = orig_x + x - (popup_width >> 1);
|
||||
y = orig_y + y - (popup_height >> 1);
|
||||
x = (x < 0) ? 0 : x;
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + popup_width > scr_width) ? scr_width - popup_width : x;
|
||||
y = (y + popup_height > scr_height) ? scr_height - popup_height : y;
|
||||
|
||||
gtk_window_move (GTK_WINDOW (window), x, y);
|
||||
gtk_widget_show (window);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (preview), "gimp-preview-popup", window,
|
||||
(GDestroyNotify) gtk_widget_destroy);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_preview_size_changed (GimpPreview *preview,
|
||||
GimpViewable *viewable)
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
|
||||
#define GIMP_PREVIEW_MAX_SIZE 1024
|
||||
#define GIMP_PREVIEW_MAX_POPUP_SIZE 256
|
||||
#define GIMP_PREVIEW_MAX_BORDER_WIDTH 16
|
||||
|
||||
|
||||
|
@ -71,9 +70,6 @@ struct _GimpPreview
|
|||
guint press_state;
|
||||
guint idle_id;
|
||||
gboolean needs_render;
|
||||
guint popup_id;
|
||||
gint popup_x;
|
||||
gint popup_y;
|
||||
};
|
||||
|
||||
struct _GimpPreviewClass
|
||||
|
@ -89,8 +85,6 @@ struct _GimpPreviewClass
|
|||
|
||||
/* virtual functions */
|
||||
void (* render) (GimpPreview *preview);
|
||||
gboolean (* needs_popup) (GimpPreview *preview);
|
||||
GtkWidget * (* create_popup) (GimpPreview *preview);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ static void gimp_brush_preview_init (GimpBrushPreview *preview);
|
|||
|
||||
static void gimp_brush_preview_destroy (GtkObject *object);
|
||||
static void gimp_brush_preview_render (GimpPreview *preview);
|
||||
static GtkWidget * gimp_brush_preview_create_popup (GimpPreview *preview);
|
||||
static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview);
|
||||
|
||||
static gboolean gimp_brush_preview_render_timeout (gpointer data);
|
||||
|
||||
|
@ -87,11 +85,9 @@ gimp_brush_preview_class_init (GimpBrushPreviewClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->destroy = gimp_brush_preview_destroy;
|
||||
object_class->destroy = gimp_brush_preview_destroy;
|
||||
|
||||
preview_class->render = gimp_brush_preview_render;
|
||||
preview_class->create_popup = gimp_brush_preview_create_popup;
|
||||
preview_class->needs_popup = gimp_brush_preview_needs_popup;
|
||||
preview_class->render = gimp_brush_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -116,8 +112,7 @@ gimp_brush_preview_destroy (GtkObject *object)
|
|||
brush_preview->pipe_animation_index = 0;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -136,7 +131,6 @@ gimp_brush_preview_render (GimpPreview *preview)
|
|||
if (brush_preview->pipe_timeout_id)
|
||||
{
|
||||
g_source_remove (brush_preview->pipe_timeout_id);
|
||||
|
||||
brush_preview->pipe_timeout_id = 0;
|
||||
}
|
||||
|
||||
|
@ -295,41 +289,6 @@ gimp_brush_preview_render (GimpPreview *preview)
|
|||
temp_buf_free (temp_buf);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_brush_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
|
||||
popup_width = GIMP_BRUSH (preview->viewable)->mask->width;
|
||||
popup_height = GIMP_BRUSH (preview->viewable)->mask->height;
|
||||
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_brush_preview_needs_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpBrush *brush;
|
||||
gint brush_width;
|
||||
gint brush_height;
|
||||
|
||||
brush = GIMP_BRUSH (preview->viewable);
|
||||
brush_width = brush->mask->width;
|
||||
brush_height = brush->mask->height;
|
||||
|
||||
if (GIMP_IS_BRUSH_PIPE (brush) ||
|
||||
brush_width > preview->width ||
|
||||
brush_height > preview->height)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_brush_preview_render_timeout (gpointer data)
|
||||
{
|
||||
|
|
|
@ -38,8 +38,7 @@
|
|||
static void gimp_drawable_preview_class_init (GimpDrawablePreviewClass *klass);
|
||||
static void gimp_drawable_preview_init (GimpDrawablePreview *preview);
|
||||
|
||||
static void gimp_drawable_preview_render (GimpPreview *preview);
|
||||
static GtkWidget * gimp_drawable_preview_create_popup (GimpPreview *preview);
|
||||
static void gimp_drawable_preview_render (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
@ -82,8 +81,7 @@ gimp_drawable_preview_class_init (GimpDrawablePreviewClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
preview_class->render = gimp_drawable_preview_render;
|
||||
preview_class->create_popup = gimp_drawable_preview_create_popup;
|
||||
preview_class->render = gimp_drawable_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -190,47 +188,3 @@ gimp_drawable_preview_render (GimpPreview *preview)
|
|||
|
||||
temp_buf_free (render_buf);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_drawable_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
GimpImage *gimage;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
gboolean scaling_up;
|
||||
|
||||
drawable = GIMP_DRAWABLE (preview->viewable);
|
||||
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||
|
||||
gimp_viewable_calc_preview_size (preview->viewable,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
MIN (preview->width * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
MIN (preview->height * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
preview->dot_for_dot,
|
||||
gimage ? gimage->xresolution : 1.0,
|
||||
gimage ? gimage->yresolution : 1.0,
|
||||
&popup_width,
|
||||
&popup_height,
|
||||
&scaling_up);
|
||||
|
||||
if (scaling_up)
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
drawable->width,
|
||||
drawable->height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
static void gimp_image_preview_class_init (GimpImagePreviewClass *klass);
|
||||
static void gimp_image_preview_init (GimpImagePreview *preview);
|
||||
|
||||
static void gimp_image_preview_render (GimpPreview *preview);
|
||||
static GtkWidget * gimp_image_preview_create_popup (GimpPreview *preview);
|
||||
static void gimp_image_preview_render (GimpPreview *preview);
|
||||
|
||||
|
||||
static GimpPreviewClass *parent_class = NULL;
|
||||
|
@ -79,8 +78,7 @@ gimp_image_preview_class_init (GimpImagePreviewClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
preview_class->render = gimp_image_preview_render;
|
||||
preview_class->create_popup = gimp_image_preview_create_popup;
|
||||
preview_class->render = gimp_image_preview_render;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -156,45 +154,3 @@ gimp_image_preview_render (GimpPreview *preview)
|
|||
|
||||
temp_buf_free (render_buf);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_image_preview_create_popup (GimpPreview *preview)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
gint popup_width;
|
||||
gint popup_height;
|
||||
gboolean scaling_up;
|
||||
|
||||
gimage = GIMP_IMAGE (preview->viewable);
|
||||
|
||||
gimp_viewable_calc_preview_size (preview->viewable,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
MIN (preview->width * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
MIN (preview->height * 2,
|
||||
GIMP_PREVIEW_MAX_POPUP_SIZE),
|
||||
preview->dot_for_dot,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&popup_width,
|
||||
&popup_height,
|
||||
&scaling_up);
|
||||
|
||||
if (scaling_up)
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
gimage->width,
|
||||
gimage->height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
return gimp_preview_new_full (preview->viewable,
|
||||
popup_width,
|
||||
popup_height,
|
||||
0,
|
||||
TRUE, FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,11 +43,8 @@ typedef struct _GimpPreview GimpPreview;
|
|||
typedef struct _GimpBrushPreview GimpBrushPreview;
|
||||
typedef struct _GimpBufferPreview GimpBufferPreview;
|
||||
typedef struct _GimpDrawablePreview GimpDrawablePreview;
|
||||
typedef struct _GimpGradientPreview GimpGradientPreview;
|
||||
typedef struct _GimpImagePreview GimpImagePreview;
|
||||
typedef struct _GimpNavigationPreview GimpNavigationPreview;
|
||||
typedef struct _GimpPalettePreview GimpPalettePreview;
|
||||
typedef struct _GimpPatternPreview GimpPatternPreview;
|
||||
|
||||
typedef struct _GimpContainerMenu GimpContainerMenu;
|
||||
typedef struct _GimpContainerMenuImpl GimpContainerMenuImpl;
|
||||
|
|
Loading…
Reference in New Issue