gimp/app/widgets/gimpviewrenderer.c

1166 lines
30 KiB
C
Raw Normal View History

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
cleanup. 2001-04-22 Michael Natterer <mitch@gimp.org> * app/Makefile.am: cleanup. * app/interface.c: #include "gimpui.h" * app/gui/dialogs-constructors.[ch] * app/gui/dialogs.c * app/gui/menus.c * app/gui/test-commands.[ch]: changes for the image menu below. * app/apptypes.h * app/widgets/Makefile.am * app/widgets/gimpcontainermenu.[ch] * app/widgets/gimpcontainermenuimpl.[ch]: new widgets. The actual implemtation lives in a separate file because gimpcontainermenu.c's code is identical to gimpcontainerview.c's except for the base class. This will become an interface with Gtk 2.0. * app/widgets/gimpimagedock.[ch]: a dock with an image menu. The pages still don't follow the context correctly. * app/widgets/gimpmenuitem.[ch]: a menu item with a preview. * app/widgets/gimpdialogfactory.[ch]: pass a dock constructor to the constructor and provide a method to create a new dock within this factory's context. * app/widgets/gimpdock.[ch]: removed the constructor because we create only image docks now. Put the vbox into a main_vbox (which also contains the image menu). * app/widgets/gimpdockbook.[ch]: create new docks with the dialog factory. * app/gimpcontainer.[ch] * app/gimpdata.[ch] * app/gimpdatafactory.[ch] * app/gimpdatalist.[ch] * app/gimplist.[ch] * app/gimpviewable.[ch] * app/widgets/gimpbrushpreview.[ch] * app/widgets/gimpcontainergridview.[ch] * app/widgets/gimpcontainerlistview.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdatafactoryview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistitem.[ch] * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimpdrawablepreview.[ch] * app/widgets/gimplayerlistitem.[ch] * app/widgets/gimplayerlistview.[ch] * app/widgets/gimplistitem.[ch] * app/widgets/gimppalettepreview.[ch] * app/widgets/gimppatternpreview.[ch] * app/widgets/gimppreview.[ch]: ass-sign some copyrights.
2001-04-22 08:38:56 +08:00
* gimppreview.c
* Copyright (C) 2001 Michael Natterer
*
* 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 <string.h>
#include <gtk/gtk.h>
app/Makefile.am app/apptypes.h new subclass of GimpDrawableListView (the 2001-03-11 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/apptypes.h * app/gimplayerlistview.[ch]: new subclass of GimpDrawableListView (the upcoming replacement of the layers dialog). Connects to the new GimpLayer signals using the layer container as signal proxy (see below). * app/gimpcontainerview.[ch]: made "set_container" a virtual function. This is needed by the GimpLayerListView to connect/disconnect signals. Subclasses implementing this method MUST obey the following order of instructions: 1. disconnect from signals related to GimpContainerView->container 2. chain up (!!!) 3. connect to signals related to GimpContainerView->container And yes, I will add DocBook files for all those new objects :) * app/gimppreview.[ch]: made "border_color" a GimpRGB instead of guchar[3]. Added gimp_preview_set_border_color(). * app/gimpcontainergridview.c * app/gimplayerlistitem.c: use gimp_preview_set_border_color(). * app/gimpcontainerlistview.c * app/gimpdrawablelistview.c: cleanup. * app/gimpdrawablelistitem.c: we can safely asume that our parent widget is a GimpDrawableListView and use it's "reorder_drawable" function pointer (after checking that it's there). * app/gimplistitem.c: connect the correct DND type when changing the container of a list item with "reorderable" enabled. * app/gimplayer.[ch]: added accessors and "*_changed" signals for layer->mode, layer->opacity and layer->preserve_trans. * app/disp_callbacks.c: fixed a FIXME: use the correct bucket fill tool context again. * app/tools/paint_options.[ch]: paint_mode_menu_new(): added a boolean which toggles the "Behind" item on/off to the same constructor can be used for all paint mode menus. * app/tools/gimptoolinfo.c: rect. select is the standard tool again. * app/brush_select.c * app/floating_sel.c * app/gimpimage.c * app/layers_dialog.c * app/pdb/layer_cmds.c * app/tools/gimpeditselectiontool.c * tools/pdbgen/pdb/layer.pdb: use the new layer accessors and the paint_mode_menu constructor. * app/commands.c * app/gdisplay.c * app/menus.c * app/undo.c * app/tools/gimppainttool.c * app/tools/gimptool.c * app/tools/paint_options.c * app/tools/tool_manager.c: put the #warning's back inside #ifdef __GNUC__
2001-03-12 01:24:47 +08:00
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimpbrush.h"
#include "core/gimpdrawable.h"
#include "core/gimpgradient.h"
#include "core/gimpimage.h"
#include "core/gimpmarshal.h"
#include "core/gimppalette.h"
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "gimpbrushpreview.h"
#include "gimpdnd.h"
#include "gimpdrawablepreview.h"
Made a GimpContainer out of the palette list: 2001-02-11 Michael Natterer <mitch@gimp.org> Made a GimpContainer out of the palette list: * app/Makefile.am * app/palettes.[ch]: new files for the global palette list. * app/gimpgradientpreview.[ch] * app/gimppalettepreview.[ch]: new widgets. * app/gimppalette.[ch]: derive it from GimpData to get all the preview etc. stuff. * app/datafiles.[ch]: new function datafiles_check_extension(), added a "loader_data" parameter to datafiles_read_directories() and pass it to the loader function. * app/gimpcontext.[ch]: added the palette (not really used yet except by the test dialogs). * app/gimpdatalist.[ch]: new function gimp_data_list_save_and_clear() which does everything needed for patterns_free(), brushes_free() ... * app/gimpdnd.c: added palette DND. * app/app_procs.c * app/brushes.c * app/color_notebook.h * app/commands.c * app/convert.c * app/gimpbrush.h * app/gimpbrushpipe.h * app/gimpgradient.c * app/gimppattern.h * app/gimppreview.c * app/gradients.c * app/module_db.c * app/palette.[ch] * app/paletteP.h * app/palette_import.c * app/palette_select.[ch] * app/patterns.c * app/plug_in.c * app/pdb/convert_cmds.c * app/pdb/palette_cmds.c * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/palette.pdb: lotsa stuff: changed due to the above API changes, #define the file extensions in the GimpData subclasses' header files instead of hardcoding them in several places, ... * data/palettes/*: The same file format change as for the gradient files: - Save the palette name in a parsable form (as part of the file format, not in a comment. - Removed unserscores from the palette names. - Added an extension (Gimp PaLettes are ".gpl" files now ;-)
2001-02-12 00:14:25 +08:00
#include "gimpgradientpreview.h"
#include "gimpimagepreview.h"
#include "gimppalettepreview.h"
#include "gimppatternpreview.h"
#include "gimppreview.h"
#include "gimptoolinfopreview.h"
#include "image_render.h"
#include "temp_buf.h"
#include "libgimp/gimplimits.h"
#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)
enum
{
CLICKED,
DOUBLE_CLICKED,
EXTENDED_CLICKED,
RENDER,
GET_SIZE,
NEEDS_POPUP,
CREATE_POPUP,
LAST_SIGNAL
};
static void gimp_preview_class_init (GimpPreviewClass *klass);
static void gimp_preview_init (GimpPreview *preview);
static void gimp_preview_destroy (GtkObject *object);
static void gimp_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gint gimp_preview_button_press_event (GtkWidget *widget,
GdkEventButton *bevent);
static gint gimp_preview_button_release_event (GtkWidget *widget,
GdkEventButton *bevent);
static gint gimp_preview_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event);
static gint gimp_preview_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event);
static void gimp_preview_real_render (GimpPreview *preview);
static void gimp_preview_get_size (GimpPreview *preview,
gint size,
gint *width,
gint *height);
static void gimp_preview_real_get_size (GimpPreview *preview,
gint size,
gint *width,
gint *height);
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 void gimp_preview_paint (GimpPreview *preview);
static gboolean gimp_preview_idle_paint (GimpPreview *preview);
static GimpViewable * gimp_preview_drag_viewable (GtkWidget *widget,
gpointer data);
static guint preview_signals[LAST_SIGNAL] = { 0 };
static GtkPreviewClass *parent_class = NULL;
GtkType
gimp_preview_get_type (void)
{
static GtkType preview_type = 0;
if (! preview_type)
{
GtkTypeInfo preview_info =
{
"GimpPreview",
sizeof (GimpPreview),
sizeof (GimpPreviewClass),
(GtkClassInitFunc) gimp_preview_class_init,
(GtkObjectInitFunc) gimp_preview_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
preview_type = gtk_type_unique (GTK_TYPE_PREVIEW, &preview_info);
}
return preview_type;
}
static void
gimp_preview_class_init (GimpPreviewClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
parent_class = gtk_type_class (GTK_TYPE_PREVIEW);
preview_signals[CLICKED] =
gtk_signal_new ("clicked",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpPreviewClass,
clicked),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
preview_signals[DOUBLE_CLICKED] =
gtk_signal_new ("double_clicked",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpPreviewClass,
double_clicked),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
preview_signals[EXTENDED_CLICKED] =
gtk_signal_new ("extended_clicked",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpPreviewClass,
extended_clicked),
gtk_marshal_NONE__UINT,
GTK_TYPE_NONE, 1,
GTK_TYPE_UINT);
preview_signals[RENDER] =
gtk_signal_new ("render",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpPreviewClass,
render),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
preview_signals[GET_SIZE] =
gtk_signal_new ("get_size",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpPreviewClass,
get_size),
gimp_marshal_NONE__INT_POINTER_POINTER,
GTK_TYPE_NONE, 3,
GTK_TYPE_INT,
GTK_TYPE_POINTER,
GTK_TYPE_POINTER);
preview_signals[NEEDS_POPUP] =
gtk_signal_new ("needs_popup",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpPreviewClass,
needs_popup),
gtk_marshal_BOOL__NONE,
GTK_TYPE_BOOL, 0);
preview_signals[CREATE_POPUP] =
gtk_signal_new ("create_popup",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpPreviewClass,
create_popup),
gimp_marshal_POINTER__NONE,
GTK_TYPE_POINTER, 0);
gtk_object_class_add_signals (object_class, preview_signals, LAST_SIGNAL);
object_class->destroy = gimp_preview_destroy;
widget_class->size_allocate = gimp_preview_size_allocate;
widget_class->button_press_event = gimp_preview_button_press_event;
widget_class->button_release_event = gimp_preview_button_release_event;
widget_class->enter_notify_event = gimp_preview_enter_notify_event;
widget_class->leave_notify_event = gimp_preview_leave_notify_event;
klass->clicked = NULL;
klass->double_clicked = NULL;
klass->extended_clicked = NULL;
klass->render = gimp_preview_real_render;
klass->get_size = gimp_preview_real_get_size;
klass->needs_popup = gimp_preview_real_needs_popup;
klass->create_popup = gimp_preview_real_create_popup;
}
static void
gimp_preview_init (GimpPreview *preview)
{
preview->viewable = NULL;
preview->width = 8;
preview->height = 8;
preview->border_width = 0;
app/Makefile.am app/apptypes.h new subclass of GimpDrawableListView (the 2001-03-11 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/apptypes.h * app/gimplayerlistview.[ch]: new subclass of GimpDrawableListView (the upcoming replacement of the layers dialog). Connects to the new GimpLayer signals using the layer container as signal proxy (see below). * app/gimpcontainerview.[ch]: made "set_container" a virtual function. This is needed by the GimpLayerListView to connect/disconnect signals. Subclasses implementing this method MUST obey the following order of instructions: 1. disconnect from signals related to GimpContainerView->container 2. chain up (!!!) 3. connect to signals related to GimpContainerView->container And yes, I will add DocBook files for all those new objects :) * app/gimppreview.[ch]: made "border_color" a GimpRGB instead of guchar[3]. Added gimp_preview_set_border_color(). * app/gimpcontainergridview.c * app/gimplayerlistitem.c: use gimp_preview_set_border_color(). * app/gimpcontainerlistview.c * app/gimpdrawablelistview.c: cleanup. * app/gimpdrawablelistitem.c: we can safely asume that our parent widget is a GimpDrawableListView and use it's "reorder_drawable" function pointer (after checking that it's there). * app/gimplistitem.c: connect the correct DND type when changing the container of a list item with "reorderable" enabled. * app/gimplayer.[ch]: added accessors and "*_changed" signals for layer->mode, layer->opacity and layer->preserve_trans. * app/disp_callbacks.c: fixed a FIXME: use the correct bucket fill tool context again. * app/tools/paint_options.[ch]: paint_mode_menu_new(): added a boolean which toggles the "Behind" item on/off to the same constructor can be used for all paint mode menus. * app/tools/gimptoolinfo.c: rect. select is the standard tool again. * app/brush_select.c * app/floating_sel.c * app/gimpimage.c * app/layers_dialog.c * app/pdb/layer_cmds.c * app/tools/gimpeditselectiontool.c * tools/pdbgen/pdb/layer.pdb: use the new layer accessors and the paint_mode_menu constructor. * app/commands.c * app/gdisplay.c * app/menus.c * app/undo.c * app/tools/gimppainttool.c * app/tools/gimptool.c * app/tools/paint_options.c * app/tools/tool_manager.c: put the #warning's back inside #ifdef __GNUC__
2001-03-12 01:24:47 +08:00
gimp_rgba_set (&preview->border_color, 0.0, 0.0, 0.0, 1.0);
preview->is_popup = FALSE;
preview->clickable = FALSE;
preview->show_popup = FALSE;
preview->in_button = FALSE;
preview->idle_id = 0;
preview->popup_id = 0;
preview->popup_x = 0;
preview->popup_y = 0;
GTK_PREVIEW (preview)->type = GTK_PREVIEW_COLOR;
GTK_PREVIEW (preview)->bpp = 3;
GTK_PREVIEW (preview)->dither = GDK_RGB_DITHER_NORMAL;
gtk_widget_set_events (GTK_WIDGET (preview), PREVIEW_EVENT_MASK);
}
static void
gimp_preview_destroy (GtkObject *object)
{
GimpPreview *preview;
preview = GIMP_PREVIEW (object);
if (preview->idle_id)
{
g_source_remove (preview->idle_id);
preview->idle_id = 0;
}
gimp_preview_popup_hide (preview);
gimp_preview_set_viewable (preview, NULL);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
GtkWidget *
gimp_preview_new (GimpViewable *viewable,
gint size,
gint border_width,
gboolean is_popup)
{
GimpPreview *preview;
gint width, height;
g_return_val_if_fail (viewable != NULL, NULL);
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (size > 0 && size <= 256, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
if (GIMP_IS_BRUSH (viewable))
{
preview = gtk_type_new (GIMP_TYPE_BRUSH_PREVIEW);
}
else if (GIMP_IS_DRAWABLE (viewable))
{
preview = gtk_type_new (GIMP_TYPE_DRAWABLE_PREVIEW);
}
else if (GIMP_IS_IMAGE (viewable))
{
preview = gtk_type_new (GIMP_TYPE_IMAGE_PREVIEW);
}
else if (GIMP_IS_PATTERN (viewable))
{
preview = gtk_type_new (GIMP_TYPE_PATTERN_PREVIEW);
}
else if (GIMP_IS_GRADIENT (viewable))
{
preview = gtk_type_new (GIMP_TYPE_GRADIENT_PREVIEW);
}
else if (GIMP_IS_PALETTE (viewable))
{
preview = gtk_type_new (GIMP_TYPE_PALETTE_PREVIEW);
}
else if (GIMP_IS_TOOL_INFO (viewable))
{
preview = gtk_type_new (GIMP_TYPE_TOOL_INFO_PREVIEW);
}
else
{
preview = gtk_type_new (GIMP_TYPE_PREVIEW);
}
preview->is_popup = is_popup;
preview->border_width = border_width;
gimp_preview_set_viewable (preview, viewable);
gimp_preview_get_size (preview, size, &width, &height);
preview->width = width;
preview->height = height;
gtk_preview_size (GTK_PREVIEW (preview),
width + 2 * border_width,
height + 2 * border_width);
return GTK_WIDGET (preview);
}
GtkWidget *
gimp_preview_new_full (GimpViewable *viewable,
gint width,
gint height,
gint border_width,
gboolean is_popup,
gboolean clickable,
gboolean show_popup)
{
GimpPreview *preview;
g_return_val_if_fail (viewable != NULL, NULL);
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (width > 0 && width <= 256, NULL);
g_return_val_if_fail (height > 0 && height <= 256, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
if (GIMP_IS_BRUSH (viewable))
{
preview = gtk_type_new (GIMP_TYPE_BRUSH_PREVIEW);
}
else if (GIMP_IS_DRAWABLE (viewable))
{
preview = gtk_type_new (GIMP_TYPE_DRAWABLE_PREVIEW);
}
else if (GIMP_IS_IMAGE (viewable))
{
preview = gtk_type_new (GIMP_TYPE_IMAGE_PREVIEW);
}
else if (GIMP_IS_PATTERN (viewable))
{
preview = gtk_type_new (GIMP_TYPE_PATTERN_PREVIEW);
}
Made a GimpContainer out of the palette list: 2001-02-11 Michael Natterer <mitch@gimp.org> Made a GimpContainer out of the palette list: * app/Makefile.am * app/palettes.[ch]: new files for the global palette list. * app/gimpgradientpreview.[ch] * app/gimppalettepreview.[ch]: new widgets. * app/gimppalette.[ch]: derive it from GimpData to get all the preview etc. stuff. * app/datafiles.[ch]: new function datafiles_check_extension(), added a "loader_data" parameter to datafiles_read_directories() and pass it to the loader function. * app/gimpcontext.[ch]: added the palette (not really used yet except by the test dialogs). * app/gimpdatalist.[ch]: new function gimp_data_list_save_and_clear() which does everything needed for patterns_free(), brushes_free() ... * app/gimpdnd.c: added palette DND. * app/app_procs.c * app/brushes.c * app/color_notebook.h * app/commands.c * app/convert.c * app/gimpbrush.h * app/gimpbrushpipe.h * app/gimpgradient.c * app/gimppattern.h * app/gimppreview.c * app/gradients.c * app/module_db.c * app/palette.[ch] * app/paletteP.h * app/palette_import.c * app/palette_select.[ch] * app/patterns.c * app/plug_in.c * app/pdb/convert_cmds.c * app/pdb/palette_cmds.c * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/palette.pdb: lotsa stuff: changed due to the above API changes, #define the file extensions in the GimpData subclasses' header files instead of hardcoding them in several places, ... * data/palettes/*: The same file format change as for the gradient files: - Save the palette name in a parsable form (as part of the file format, not in a comment. - Removed unserscores from the palette names. - Added an extension (Gimp PaLettes are ".gpl" files now ;-)
2001-02-12 00:14:25 +08:00
else if (GIMP_IS_GRADIENT (viewable))
{
preview = gtk_type_new (GIMP_TYPE_GRADIENT_PREVIEW);
}
else if (GIMP_IS_PALETTE (viewable))
{
preview = gtk_type_new (GIMP_TYPE_PALETTE_PREVIEW);
}
else if (GIMP_IS_TOOL_INFO (viewable))
{
preview = gtk_type_new (GIMP_TYPE_TOOL_INFO_PREVIEW);
}
else
{
preview = gtk_type_new (GIMP_TYPE_PREVIEW);
}
preview->is_popup = is_popup;
preview->width = width;
preview->height = height;
preview->border_width = border_width;
preview->clickable = clickable;
preview->show_popup = show_popup;
gimp_preview_set_viewable (preview, viewable);
gtk_preview_size (GTK_PREVIEW (preview),
width + 2 * border_width,
height + 2 * border_width);
return GTK_WIDGET (preview);
}
void
gimp_preview_set_viewable (GimpPreview *preview,
GimpViewable *viewable)
{
g_return_if_fail (preview != NULL);
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable));
if (preview->viewable)
{
if (! preview->is_popup)
{
GtkType type;
type = GTK_OBJECT (preview->viewable)->klass->type;
gtk_drag_source_unset (GTK_WIDGET (preview));
gimp_dnd_viewable_source_unset (GTK_WIDGET (preview), type);
}
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
gimp_preview_paint,
preview);
gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable),
gtk_widget_destroyed,
&preview->viewable);
}
preview->viewable = viewable;
if (preview->viewable)
{
if (! preview->is_popup)
{
GtkType type;
type = GTK_OBJECT (preview->viewable)->klass->type;
gimp_gtk_drag_source_set_by_type (GTK_WIDGET (preview),
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
type,
GDK_ACTION_COPY);
gimp_dnd_viewable_source_set (GTK_WIDGET (preview),
type,
gimp_preview_drag_viewable,
NULL);
}
gtk_signal_connect_object (GTK_OBJECT (preview->viewable),
"invalidate_preview",
GTK_SIGNAL_FUNC (gimp_preview_paint),
GTK_OBJECT (preview));
gtk_signal_connect (GTK_OBJECT (preview->viewable), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&preview->viewable);
gimp_preview_render (preview);
}
}
app/Makefile.am app/apptypes.h new subclass of GimpDrawableListView (the 2001-03-11 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/apptypes.h * app/gimplayerlistview.[ch]: new subclass of GimpDrawableListView (the upcoming replacement of the layers dialog). Connects to the new GimpLayer signals using the layer container as signal proxy (see below). * app/gimpcontainerview.[ch]: made "set_container" a virtual function. This is needed by the GimpLayerListView to connect/disconnect signals. Subclasses implementing this method MUST obey the following order of instructions: 1. disconnect from signals related to GimpContainerView->container 2. chain up (!!!) 3. connect to signals related to GimpContainerView->container And yes, I will add DocBook files for all those new objects :) * app/gimppreview.[ch]: made "border_color" a GimpRGB instead of guchar[3]. Added gimp_preview_set_border_color(). * app/gimpcontainergridview.c * app/gimplayerlistitem.c: use gimp_preview_set_border_color(). * app/gimpcontainerlistview.c * app/gimpdrawablelistview.c: cleanup. * app/gimpdrawablelistitem.c: we can safely asume that our parent widget is a GimpDrawableListView and use it's "reorder_drawable" function pointer (after checking that it's there). * app/gimplistitem.c: connect the correct DND type when changing the container of a list item with "reorderable" enabled. * app/gimplayer.[ch]: added accessors and "*_changed" signals for layer->mode, layer->opacity and layer->preserve_trans. * app/disp_callbacks.c: fixed a FIXME: use the correct bucket fill tool context again. * app/tools/paint_options.[ch]: paint_mode_menu_new(): added a boolean which toggles the "Behind" item on/off to the same constructor can be used for all paint mode menus. * app/tools/gimptoolinfo.c: rect. select is the standard tool again. * app/brush_select.c * app/floating_sel.c * app/gimpimage.c * app/layers_dialog.c * app/pdb/layer_cmds.c * app/tools/gimpeditselectiontool.c * tools/pdbgen/pdb/layer.pdb: use the new layer accessors and the paint_mode_menu constructor. * app/commands.c * app/gdisplay.c * app/menus.c * app/undo.c * app/tools/gimppainttool.c * app/tools/gimptool.c * app/tools/paint_options.c * app/tools/tool_manager.c: put the #warning's back inside #ifdef __GNUC__
2001-03-12 01:24:47 +08:00
void
gimp_preview_set_size (GimpPreview *preview,
gint preview_size,
gint border_width)
{
gint width, height;
g_return_if_fail (preview != NULL);
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_return_if_fail (preview_size > 0 && preview_size <= 256);
g_return_if_fail (border_width >= 0 && border_width <= 16);
gimp_preview_get_size (preview, preview_size, &width, &height);
gimp_preview_set_size_full (preview,
width,
height,
border_width);
}
void
gimp_preview_set_size_full (GimpPreview *preview,
gint width,
gint height,
gint border_width)
{
g_return_if_fail (preview != NULL);
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_return_if_fail (width > 0 && width <= 256);
g_return_if_fail (height > 0 && height <= 256);
g_return_if_fail (border_width >= 0 && border_width <= 16);
preview->width = width;
preview->height = height;
preview->border_width = border_width;
gtk_preview_size (GTK_PREVIEW (preview),
width + 2 * preview->border_width,
height + 2 * preview->border_width);
}
void
gimp_preview_set_border_color (GimpPreview *preview,
const GimpRGB *color)
{
g_return_if_fail (preview != NULL);
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_return_if_fail (color != NULL);
if (gimp_rgb_distance (&preview->border_color, color))
{
preview->border_color = *color;
gimp_preview_render (preview);
}
}
void
gimp_preview_render (GimpPreview *preview)
{
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[RENDER]);
}
static gint
gimp_preview_button_press_event (GtkWidget *widget,
GdkEventButton *bevent)
{
GimpPreview *preview;
preview = GIMP_PREVIEW (widget);
if (! preview->clickable &&
! preview->show_popup)
return FALSE;
if (bevent->type == GDK_BUTTON_PRESS)
{
if (bevent->button == 1)
{
gtk_grab_add (widget);
preview->press_state = bevent->state;
if (preview->show_popup && gimp_preview_needs_popup (preview))
{
gimp_preview_popup_show (preview,
bevent->x,
bevent->y);
}
}
else
{
return FALSE;
}
}
else if (bevent->type == GDK_2BUTTON_PRESS)
{
if (bevent->button == 1)
{
gtk_signal_emit (GTK_OBJECT (widget), preview_signals[DOUBLE_CLICKED]);
}
}
return TRUE;
}
static gint
gimp_preview_button_release_event (GtkWidget *widget,
GdkEventButton *bevent)
{
GimpPreview *preview;
gboolean click = TRUE;
preview = GIMP_PREVIEW (widget);
if (! preview->clickable &&
! preview->show_popup)
return FALSE;
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->press_state &
(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK))
{
gtk_signal_emit (GTK_OBJECT (widget),
preview_signals[EXTENDED_CLICKED],
preview->press_state);
}
else
{
gtk_signal_emit (GTK_OBJECT (widget), preview_signals[CLICKED]);
}
}
}
else
{
return FALSE;
}
return TRUE;
}
static gint
gimp_preview_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
GimpPreview *preview;
GtkWidget *event_widget;
preview = GIMP_PREVIEW (widget);
event_widget = gtk_get_event_widget ((GdkEvent *) event);
if ((event_widget == widget) &&
(event->detail != GDK_NOTIFY_INFERIOR))
{
preview->in_button = TRUE;
}
return FALSE;
}
static gint
gimp_preview_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
GimpPreview *preview;
GtkWidget *event_widget;
preview = GIMP_PREVIEW (widget);
event_widget = gtk_get_event_widget ((GdkEvent *) event);
if ((event_widget == widget) &&
(event->detail != GDK_NOTIFY_INFERIOR))
{
preview->in_button = FALSE;
}
return FALSE;
}
static void
gimp_preview_real_render (GimpPreview *preview)
{
TempBuf *temp_buf;
temp_buf = gimp_viewable_get_new_preview (preview->viewable,
preview->width,
preview->height);
Made the tool system work again and integrated it back with the 2001-02-21 Michael Natterer <mitch@gimp.org> Made the tool system work again and integrated it back with the GimpContext. It's a hack between old, new and freshly hacked stuff. There are still lots of warnings but at least we can switch tools again. * app/tools/Makefile.am * app/tools/gimptoolinfo.[ch]: resurrected as real object. The GimpToolInfo objects are derived from GimpData, which gives us the tool icon stuff for free. Also, we need a list of _objects_ which is allocated all the time. All tools are required to have a "register" function which registers themselves with the list of GimpToolInfo objects which is maintained by the tool manager. * app/tools/tool.[ch]: made a real GtkObject with properly named functions out of it. The former "active_tool_control" is of course not the default implementation of the tool's "control" method but a hack _around_ it, so it went to the tool manager. * app/tools/color_picker.[ch] * app/tools/measure.[ch]: ditto. Added "register" functions and "destroy" implementations so the tools go away after use. * app/tools/tool_manager.[ch]: badly hacked at the moment to keep both the list of class structures _and_ the tool info list. * app/tools/tools.c: call the tools' register functions. * app/gimpcontext.[ch]: store a pointer to a GimpToolInfo object as "active_tool" in the context, so we're independent of tools being allocated or not. It's treated just like a brush or pattern now. * app/gimpdnd.[ch]: made tool DND work like all other DND types. * app/devices.[ch]: also here: the tool is just a normal data object now, resulting in removal of lots of code. * app/commands.c * app/context_manager.c: updated the tool select and context stuff to work again. * app/toolbox.c: removed the old pixmap buttons and put GimpPreviews inside the tool buttons. Still needs an own preview type to look nice. * app/disp_callbacks.c * app/about_dialog.c * app/app_procs.c * app/appenums.h * app/apptypes.h * app/gimage.c * app/gimppalette.c * app/gimppreview.c * app/gimprc.c * app/info_window.c * app/menus.c * app/palette_select.h * app/scale.c * app/scroll.c: lots of changes to make it work again.
2001-02-21 20:18:09 +08:00
if (temp_buf)
gimp_preview_render_and_flush (preview,
temp_buf,
-1);
}
static void
gimp_preview_get_size (GimpPreview *preview,
gint size,
gint *width,
gint *height)
{
g_return_if_fail (preview != NULL);
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_return_if_fail (width != NULL);
g_return_if_fail (height != NULL);
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[GET_SIZE],
size, width, height);
}
static void
gimp_preview_real_get_size (GimpPreview *preview,
gint size,
gint *width,
gint *height)
{
*width = size;
*height = size;
}
static gboolean
gimp_preview_needs_popup (GimpPreview *preview)
{
gboolean needs_popup = FALSE;
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[NEEDS_POPUP],
&needs_popup);
return needs_popup;
}
static gboolean
gimp_preview_real_needs_popup (GimpPreview *preview)
{
return TRUE;
}
static GtkWidget *
gimp_preview_create_popup (GimpPreview *preview)
{
GtkWidget *popup_preview = NULL;
gtk_signal_emit (GTK_OBJECT (preview), preview_signals[CREATE_POPUP],
&popup_preview);
return popup_preview;
}
static GtkWidget *
gimp_preview_real_create_popup (GimpPreview *preview)
{
gint popup_width;
gint popup_height;
popup_width = MIN (preview->width * 2, 256);
popup_height = MIN (preview->height * 2, 256);
return gimp_preview_new_full (preview->viewable,
popup_width,
popup_height,
0,
TRUE, FALSE, FALSE);
}
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_policy (GTK_WINDOW (window), FALSE, FALSE, TRUE);
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_widget_popup (window, x, y);
gtk_object_set_data_full (GTK_OBJECT (preview), "preview_popup_window", window,
(GtkDestroyNotify) gtk_widget_destroy);
return 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;
}
gtk_object_set_data (GTK_OBJECT (preview), "preview_popup_window", NULL);
}
static void
gimp_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
gimp_preview_paint (GIMP_PREVIEW (widget));
}
static void
gimp_preview_paint (GimpPreview *preview)
{
if (preview->idle_id)
{
g_source_remove (preview->idle_id);
}
preview->idle_id =
g_idle_add_full (G_PRIORITY_LOW,
(GSourceFunc) gimp_preview_idle_paint, preview,
NULL);
}
static gboolean
gimp_preview_idle_paint (GimpPreview *preview)
{
preview->idle_id = 0;
if (! preview->viewable)
return FALSE;
gimp_preview_render (preview);
return FALSE;
}
void
gimp_preview_calc_size (gint aspect_width,
gint aspect_height,
gint width,
gint height,
gint *return_width,
gint *return_height,
gboolean *scaling_up)
{
gdouble ratio;
if (aspect_width > aspect_height)
{
ratio = (gdouble) width / (gdouble) aspect_width;
}
else
{
ratio = (gdouble) height / (gdouble) aspect_height;
}
width = RINT (ratio * (gdouble) aspect_width);
height = RINT (ratio * (gdouble) aspect_height);
if (width < 1) width = 1;
if (height < 1) height = 1;
*return_width = width;
*return_height = height;
*scaling_up = (ratio > 1.0);
}
void
gimp_preview_render_and_flush (GimpPreview *preview,
TempBuf *temp_buf,
gint channel)
{
gint width;
gint height;
guchar *src, *s;
guchar *cb;
guchar *buf;
gint a;
gint i, j, b;
gint x1, y1, x2, y2;
gint rowstride;
gboolean color_buf;
gboolean color;
gint alpha;
gboolean has_alpha;
gint image_bytes;
gint offset;
gint border;
app/Makefile.am app/apptypes.h new subclass of GimpDrawableListView (the 2001-03-11 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/apptypes.h * app/gimplayerlistview.[ch]: new subclass of GimpDrawableListView (the upcoming replacement of the layers dialog). Connects to the new GimpLayer signals using the layer container as signal proxy (see below). * app/gimpcontainerview.[ch]: made "set_container" a virtual function. This is needed by the GimpLayerListView to connect/disconnect signals. Subclasses implementing this method MUST obey the following order of instructions: 1. disconnect from signals related to GimpContainerView->container 2. chain up (!!!) 3. connect to signals related to GimpContainerView->container And yes, I will add DocBook files for all those new objects :) * app/gimppreview.[ch]: made "border_color" a GimpRGB instead of guchar[3]. Added gimp_preview_set_border_color(). * app/gimpcontainergridview.c * app/gimplayerlistitem.c: use gimp_preview_set_border_color(). * app/gimpcontainerlistview.c * app/gimpdrawablelistview.c: cleanup. * app/gimpdrawablelistitem.c: we can safely asume that our parent widget is a GimpDrawableListView and use it's "reorder_drawable" function pointer (after checking that it's there). * app/gimplistitem.c: connect the correct DND type when changing the container of a list item with "reorderable" enabled. * app/gimplayer.[ch]: added accessors and "*_changed" signals for layer->mode, layer->opacity and layer->preserve_trans. * app/disp_callbacks.c: fixed a FIXME: use the correct bucket fill tool context again. * app/tools/paint_options.[ch]: paint_mode_menu_new(): added a boolean which toggles the "Behind" item on/off to the same constructor can be used for all paint mode menus. * app/tools/gimptoolinfo.c: rect. select is the standard tool again. * app/brush_select.c * app/floating_sel.c * app/gimpimage.c * app/layers_dialog.c * app/pdb/layer_cmds.c * app/tools/gimpeditselectiontool.c * tools/pdbgen/pdb/layer.pdb: use the new layer accessors and the paint_mode_menu constructor. * app/commands.c * app/gdisplay.c * app/menus.c * app/undo.c * app/tools/gimppainttool.c * app/tools/gimptool.c * app/tools/paint_options.c * app/tools/tool_manager.c: put the #warning's back inside #ifdef __GNUC__
2001-03-12 01:24:47 +08:00
guchar border_color[3];
width = preview->width;
height = preview->height;
border = preview->border_width;
app/Makefile.am app/apptypes.h new subclass of GimpDrawableListView (the 2001-03-11 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/apptypes.h * app/gimplayerlistview.[ch]: new subclass of GimpDrawableListView (the upcoming replacement of the layers dialog). Connects to the new GimpLayer signals using the layer container as signal proxy (see below). * app/gimpcontainerview.[ch]: made "set_container" a virtual function. This is needed by the GimpLayerListView to connect/disconnect signals. Subclasses implementing this method MUST obey the following order of instructions: 1. disconnect from signals related to GimpContainerView->container 2. chain up (!!!) 3. connect to signals related to GimpContainerView->container And yes, I will add DocBook files for all those new objects :) * app/gimppreview.[ch]: made "border_color" a GimpRGB instead of guchar[3]. Added gimp_preview_set_border_color(). * app/gimpcontainergridview.c * app/gimplayerlistitem.c: use gimp_preview_set_border_color(). * app/gimpcontainerlistview.c * app/gimpdrawablelistview.c: cleanup. * app/gimpdrawablelistitem.c: we can safely asume that our parent widget is a GimpDrawableListView and use it's "reorder_drawable" function pointer (after checking that it's there). * app/gimplistitem.c: connect the correct DND type when changing the container of a list item with "reorderable" enabled. * app/gimplayer.[ch]: added accessors and "*_changed" signals for layer->mode, layer->opacity and layer->preserve_trans. * app/disp_callbacks.c: fixed a FIXME: use the correct bucket fill tool context again. * app/tools/paint_options.[ch]: paint_mode_menu_new(): added a boolean which toggles the "Behind" item on/off to the same constructor can be used for all paint mode menus. * app/tools/gimptoolinfo.c: rect. select is the standard tool again. * app/brush_select.c * app/floating_sel.c * app/gimpimage.c * app/layers_dialog.c * app/pdb/layer_cmds.c * app/tools/gimpeditselectiontool.c * tools/pdbgen/pdb/layer.pdb: use the new layer accessors and the paint_mode_menu constructor. * app/commands.c * app/gdisplay.c * app/menus.c * app/undo.c * app/tools/gimppainttool.c * app/tools/gimptool.c * app/tools/paint_options.c * app/tools/tool_manager.c: put the #warning's back inside #ifdef __GNUC__
2001-03-12 01:24:47 +08:00
gimp_rgb_get_uchar (&preview->border_color,
&border_color[0],
&border_color[1],
&border_color[2]);
alpha = ALPHA_PIX;
/* Here are the different cases this functions handles correctly:
* 1) Offset temp_buf which does not necessarily cover full image area
* 2) Color conversion of temp_buf if it is gray and image is color
* 3) Background check buffer for transparent temp_bufs
* 4) Using the optional "channel" argument, one channel can be extracted
* from a multi-channel temp_buf and composited as a grayscale
* Prereqs:
* 1) Grayscale temp_bufs have bytes == {1, 2}
* 2) Color temp_bufs have bytes == {3, 4}
* 3) If image is gray, then temp_buf should have bytes == {1, 2}
*/
color_buf = (GTK_PREVIEW (preview)->type == GTK_PREVIEW_COLOR);
image_bytes = (color_buf) ? 3 : 1;
has_alpha = (temp_buf->bytes == 2 || temp_buf->bytes == 4);
rowstride = temp_buf->width * temp_buf->bytes;
/* Determine if the preview buf supplied is color
* Generally, if the bytes == {3, 4}, this is true.
* However, if the channel argument supplied is not -1, then
* the preview buf is assumed to be gray despite the number of
* channels it contains
*/
color = ((channel == -1) &&
(temp_buf->bytes == 3 || temp_buf->bytes == 4));
if (has_alpha)
{
buf = render_check_buf;
alpha = ((color) ? ALPHA_PIX :
((channel != -1) ? (temp_buf->bytes - 1) :
ALPHA_G_PIX));
}
else
{
buf = render_empty_buf;
}
x1 = CLAMP (temp_buf->x, 0, width);
y1 = CLAMP (temp_buf->y, 0, height);
x2 = CLAMP (temp_buf->x + temp_buf->width, 0, width);
y2 = CLAMP (temp_buf->y + temp_buf->height, 0, height);
src = temp_buf_data (temp_buf) + ((y1 - temp_buf->y) * rowstride +
(x1 - temp_buf->x) * temp_buf->bytes);
/* One last thing for efficiency's sake: */
if (channel == -1)
channel = 0;
/* Set the border color once before rendering */
for (j = 0; j < width + border * 2; j++)
for (b = 0; b < image_bytes; b++)
render_temp_buf[j * image_bytes + b] = border_color[b];
for (i = 0; i < border; i++)
gtk_preview_draw_row (GTK_PREVIEW (preview),
render_temp_buf,
0, i,
width + 2 * border);
for (i = border + height; i < 2 * border + height; i++)
gtk_preview_draw_row (GTK_PREVIEW (preview),
render_temp_buf,
0, i,
width + 2 * border);
for (i = 0; i < height; i++)
{
if (i & 0x4)
{
offset = 4;
cb = buf + offset * 3;
}
else
{
offset = 0;
cb = buf;
}
/* The interesting stuff between leading & trailing
* vertical transparency
*/
if (i >= y1 && i < y2)
{
/* Handle the leading transparency */
for (j = 0; j < x1; j++)
for (b = 0; b < image_bytes; b++)
render_temp_buf[(border + j) * image_bytes + b] = cb[j * 3 + b];
/* The stuff in the middle */
s = src;
for (j = x1; j < x2; j++)
{
if (color)
{
if (has_alpha)
{
a = s[alpha] << 8;
if ((j + offset) & 0x4)
{
render_temp_buf[(border + j) * 3 + 0] =
render_blend_dark_check [(a | s[RED_PIX])];
render_temp_buf[(border + j) * 3 + 1] =
render_blend_dark_check [(a | s[GREEN_PIX])];
render_temp_buf[(border + j) * 3 + 2] =
render_blend_dark_check [(a | s[BLUE_PIX])];
}
else
{
render_temp_buf[(border + j) * 3 + 0] =
render_blend_light_check [(a | s[RED_PIX])];
render_temp_buf[(border + j) * 3 + 1] =
render_blend_light_check [(a | s[GREEN_PIX])];
render_temp_buf[(border + j) * 3 + 2] =
render_blend_light_check [(a | s[BLUE_PIX])];
}
}
else
{
render_temp_buf[(border + j) * 3 + 0] = s[RED_PIX];
render_temp_buf[(border + j) * 3 + 1] = s[GREEN_PIX];
render_temp_buf[(border + j) * 3 + 2] = s[BLUE_PIX];
}
}
else
{
if (has_alpha)
{
a = s[alpha] << 8;
if ((j + offset) & 0x4)
{
if (color_buf)
{
render_temp_buf[(border + j) * 3 + 0] =
render_blend_dark_check [(a | s[GRAY_PIX])];
render_temp_buf[(border + j) * 3 + 1] =
render_blend_dark_check [(a | s[GRAY_PIX])];
render_temp_buf[(border + j) * 3 + 2] =
render_blend_dark_check [(a | s[GRAY_PIX])];
}
else
{
render_temp_buf[(border + j)] =
render_blend_dark_check [(a | s[GRAY_PIX + channel])];
}
}
else
{
if (color_buf)
{
render_temp_buf[(border + j) * 3 + 0] =
render_blend_light_check [(a | s[GRAY_PIX])];
render_temp_buf[(border + j) * 3 + 1] =
render_blend_light_check [(a | s[GRAY_PIX])];
render_temp_buf[(border + j) * 3 + 2] =
render_blend_light_check [(a | s[GRAY_PIX])];
}
else
{
render_temp_buf[(border + j)] =
render_blend_light_check [(a | s[GRAY_PIX + channel])];
}
}
}
else
{
if (color_buf)
{
render_temp_buf[(border + j) * 3 + 0] = s[GRAY_PIX];
render_temp_buf[(border + j) * 3 + 1] = s[GRAY_PIX];
render_temp_buf[(border + j) * 3 + 2] = s[GRAY_PIX];
}
else
{
render_temp_buf[(border + j)] = s[GRAY_PIX + channel];
}
}
}
s += temp_buf->bytes;
}
/* Handle the trailing transparency */
for (j = x2; j < width; j++)
for (b = 0; b < image_bytes; b++)
render_temp_buf[(border + j) * image_bytes + b] = cb[j * 3 + b];
src += rowstride;
}
else
{
for (j = 0; j < width; j++)
for (b = 0; b < image_bytes; b++)
render_temp_buf[(border + j) * image_bytes + b] = cb[j * 3 + b];
}
gtk_preview_draw_row (GTK_PREVIEW (preview),
render_temp_buf,
0,
i + border,
width + 2 * border);
}
gtk_widget_queue_draw (GTK_WIDGET (preview));
}
static GimpViewable *
gimp_preview_drag_viewable (GtkWidget *widget,
gpointer data)
{
return GIMP_PREVIEW (widget)->viewable;
}