1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
#include "config.h"
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display-types.h"
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools/tools-types.h"
|
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2002-05-09 01:48:24 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2001-11-28 11:08:03 +08:00
|
|
|
#include "core/gimpimage-projection.h"
|
2002-05-09 01:48:24 +08:00
|
|
|
#include "core/gimplist.h"
|
2001-05-14 05:51:20 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "widgets/gimpitemfactory.h"
|
|
|
|
|
2002-03-29 11:50:29 +08:00
|
|
|
#include "libgimptool/gimptool.h"
|
include the new "paint-funcs/paint-funcs-types.h".
2001-11-28 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: include the new
"paint-funcs/paint-funcs-types.h".
* app/paint-funcs/Makefile.am
* app/paint-funcs/paint-funcs-types.h: new file. Includes
"base/base-types.h".
* app/paint-funcs/paint-funcs.[ch]: removed the enums here,
include "paint-funcs-types.h".
* app/widgets/widgets-types.h: include "display/display-types.h"
* app/display/display-types.h: include "widgets/widgets-types.h".
* app/tools/tools-types.h: include "display/display-types.h"
* app/gui/gui-types.h: include "tools/tools-types.h".
The order of namespaces/dependencies should be (but is not):
(base, paint-funcs) -> (core, file, xcf, pdb) ->
(widgets, display) -> tools -> gui
* app/path.c: include "tools/tools-types.h".
* app/core/Makefile.am
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-merge.[ch]
* app/core/gimpimage-resize.[ch]
* app/core/gimpimage-scale.[ch]: new files.
* app/core/gimpimage.[ch]: removed the stuff which is in the new
files. Reordered all functions in both the .h and .c files,
commented the groups of functions.
* app/core/gimpcontainer.c: create the handler_id using a counter,
not the address of a pointer, because the address *may* be the
same twice, added debugging output.
* app/core/gimpviewable.[ch]: added primitive support for getting
a preview GdkPixbuf.
* app/nav_window.c
* app/undo.c
* app/undo_history.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.[ch]
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/layers-commands.c
* app/gui/palette-import-dialog.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/widgets/gimpcontainerview-utils.c
* app/xcf/xcf-load.c: changed accordingly, some cleanup.
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions.
* app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu
items to the name of the last plug-in (Fixes #50986).
* app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and
"Redo" to the resp. undo names. Much simplified the WM icon stuff
by removing most code and using gimp_viewable_get_new_preview_pixbuf().
* app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark
returned by gimp_container_add_handler().
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-29 01:51:06 +08:00
|
|
|
|
2001-02-28 10:53:27 +08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gimpdisplay.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "gimpdisplay-area.h"
|
|
|
|
#include "gimpdisplay-handlers.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gimpdisplayshell.h"
|
2001-11-11 07:03:22 +08:00
|
|
|
#include "gimpdisplayshell-handlers.h"
|
2003-01-04 02:01:30 +08:00
|
|
|
#include "gimpdisplayshell-transform.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
2001-07-31 19:33:13 +08:00
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_IMAGE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* local function prototypes */
|
2001-07-31 19:33:13 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
static void gimp_display_class_init (GimpDisplayClass *klass);
|
|
|
|
static void gimp_display_init (GimpDisplay *gdisp);
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
static void gimp_display_finalize (GObject *object);
|
2002-05-10 21:09:19 +08:00
|
|
|
static void gimp_display_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_display_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
static void gimp_display_flush_whenever (GimpDisplay *gdisp,
|
|
|
|
gboolean now);
|
|
|
|
static void gimp_display_idlerender_init (GimpDisplay *gdisp);
|
|
|
|
static gboolean gimp_display_idlerender_callback (gpointer data);
|
|
|
|
static gboolean gimp_display_idle_render_next_area (GimpDisplay *gdisp);
|
|
|
|
static void gimp_display_paint_area (GimpDisplay *gdisp,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
2001-09-26 01:44:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
static GimpObjectClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
GType
|
|
|
|
gimp_display_get_type (void)
|
|
|
|
{
|
|
|
|
static GType display_type = 0;
|
|
|
|
|
|
|
|
if (! display_type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo display_info =
|
|
|
|
{
|
|
|
|
sizeof (GimpDisplayClass),
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_display_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpDisplay),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_display_init,
|
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
display_type = g_type_register_static (GIMP_TYPE_OBJECT,
|
|
|
|
"GimpDisplay",
|
|
|
|
&display_info, 0);
|
|
|
|
}
|
2001-02-02 02:44:22 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
return display_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_class_init (GimpDisplayClass *klass)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
GObjectClass *object_class;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
object_class->finalize = gimp_display_finalize;
|
|
|
|
object_class->set_property = gimp_display_set_property;
|
|
|
|
object_class->get_property = gimp_display_get_property;
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_IMAGE,
|
|
|
|
g_param_spec_object ("image",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_IMAGE,
|
|
|
|
G_PARAM_READABLE));
|
2001-09-26 01:44:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_init (GimpDisplay *gdisp)
|
|
|
|
{
|
2002-05-09 01:48:24 +08:00
|
|
|
gdisp->ID = 0;
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisp->gimage = NULL;
|
|
|
|
gdisp->instance = 0;
|
2001-09-26 01:44:03 +08:00
|
|
|
|
|
|
|
gdisp->shell = NULL;
|
|
|
|
|
|
|
|
gdisp->update_areas = NULL;
|
1998-06-15 10:25:27 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
gdisp->idle_render.idle_id = 0;
|
1998-10-02 00:22:28 +08:00
|
|
|
gdisp->idle_render.update_areas = NULL;
|
2001-09-26 01:44:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
|
|
|
|
gdisp = GIMP_DISPLAY (object);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
static void
|
|
|
|
gimp_display_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
|
|
|
|
gdisp = GIMP_DISPLAY (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_IMAGE:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
|
|
|
|
gdisp = GIMP_DISPLAY (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_IMAGE:
|
|
|
|
g_value_set_object (value, gdisp->gimage);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
GimpDisplay *
|
2003-01-11 01:55:53 +08:00
|
|
|
gimp_display_new (GimpImage *gimage,
|
|
|
|
guint scale,
|
|
|
|
GimpMenuFactory *menu_factory,
|
|
|
|
GimpItemFactory *popup_factory)
|
2001-09-26 01:44:03 +08:00
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
/* If there isn't an interface, never create a gdisplay */
|
2001-10-29 19:47:11 +08:00
|
|
|
if (gimage->gimp->no_interface)
|
2001-09-26 01:44:03 +08:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
gdisp = g_object_new (GIMP_TYPE_DISPLAY, NULL);
|
|
|
|
|
2002-05-11 02:27:51 +08:00
|
|
|
gdisp->ID = gimage->gimp->next_display_ID++;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-08 20:39:01 +08:00
|
|
|
/* refs the image */
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_connect (gdisp, gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* create the shell for the image */
|
2003-01-11 01:55:53 +08:00
|
|
|
gdisp->shell = gimp_display_shell_new (gdisp, scale,
|
|
|
|
menu_factory, popup_factory);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-10 00:54:56 +08:00
|
|
|
gtk_widget_show (gdisp->shell);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return gdisp;
|
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
void
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_delete (GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-08 01:36:00 +08:00
|
|
|
GimpTool *active_tool;
|
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* remove the display from the list */
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_container_remove (gdisp->gimage->gimp->displays,
|
|
|
|
GIMP_OBJECT (gdisp));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* stop any active tool */
|
2001-07-08 01:36:00 +08:00
|
|
|
tool_manager_control_active (gdisp->gimage->gimp, HALT, gdisp);
|
|
|
|
|
|
|
|
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-06-22 06:12:07 +08:00
|
|
|
/* clear out the pointer to this gdisp from the active tool */
|
2001-07-08 01:36:00 +08:00
|
|
|
if (active_tool && active_tool->gdisp == gdisp)
|
1999-06-22 06:12:07 +08:00
|
|
|
{
|
1999-07-09 20:24:36 +08:00
|
|
|
active_tool->drawable = NULL;
|
2000-12-31 12:07:42 +08:00
|
|
|
active_tool->gdisp = NULL;
|
1998-04-15 06:05:08 +08:00
|
|
|
}
|
1998-04-13 12:32:39 +08:00
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
/* If this gdisplay was idlerendering at the time when it was deleted,
|
2001-11-11 07:03:22 +08:00
|
|
|
* deactivate the idlerendering thread before deletion!
|
|
|
|
*/
|
|
|
|
if (gdisp->idle_render.idle_id)
|
1998-10-02 00:22:28 +08:00
|
|
|
{
|
2001-11-11 07:03:22 +08:00
|
|
|
g_source_remove (gdisp->idle_render.idle_id);
|
|
|
|
gdisp->idle_render.idle_id = 0;
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
1999-08-23 22:34:58 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* free the update area lists */
|
|
|
|
gimp_display_area_list_free (gdisp->update_areas);
|
|
|
|
gimp_display_area_list_free (gdisp->idle_render.update_areas);
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
if (gdisp->shell)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (gdisp->shell);
|
|
|
|
gdisp->shell = NULL;
|
|
|
|
}
|
1998-02-14 23:30:31 +08:00
|
|
|
|
2002-05-08 20:39:01 +08:00
|
|
|
/* unrefs the gimage */
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_disconnect (gdisp);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
gint
|
|
|
|
gimp_display_get_ID (GimpDisplay *gdisp)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), -1);
|
|
|
|
|
|
|
|
return gdisp->ID;
|
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplay *
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_get_by_ID (Gimp *gimp,
|
|
|
|
gint ID)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplay *gdisp;
|
2002-05-09 01:48:24 +08:00
|
|
|
GList *list;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2002-05-08 20:39:01 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
for (list = GIMP_LIST (gimp->displays)->list;
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisp = (GimpDisplay *) list->data;
|
|
|
|
|
|
|
|
if (gdisp->ID == ID)
|
|
|
|
return gdisp;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
void
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_reconnect (GimpDisplay *gdisp,
|
|
|
|
GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
if (gdisp->idle_render.idle_id)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-11 07:03:22 +08:00
|
|
|
g_source_remove (gdisp->idle_render.idle_id);
|
|
|
|
gdisp->idle_render.idle_id = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_shell_disconnect (GIMP_DISPLAY_SHELL (gdisp->shell));
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_disconnect (gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_connect (gdisp, gimage);
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_add_update_area (gdisp,
|
|
|
|
0, 0,
|
|
|
|
gdisp->gimage->width,
|
|
|
|
gdisp->gimage->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_shell_reconnect (GIMP_DISPLAY_SHELL (gdisp->shell));
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
void
|
|
|
|
gimp_display_add_update_area (GimpDisplay *gdisp,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-16 23:08:59 +08:00
|
|
|
GimpArea *area;
|
1998-10-02 00:22:28 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
1998-10-02 00:22:28 +08:00
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
area = gimp_area_new (CLAMP (x, 0, gdisp->gimage->width),
|
|
|
|
CLAMP (y, 0, gdisp->gimage->height),
|
|
|
|
CLAMP (x + w, 0, gdisp->gimage->width),
|
|
|
|
CLAMP (y + h, 0, gdisp->gimage->height));
|
1997-11-27 03:30:17 +08:00
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
gdisp->update_areas = gimp_display_area_list_process (gdisp->update_areas,
|
|
|
|
area);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
void
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_flush (GimpDisplay *gdisp)
|
1998-10-02 00:22:28 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
/* Redraw on idle time */
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_flush_whenever (gdisp, FALSE);
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_flush_now (GimpDisplay *gdisp)
|
1998-10-02 00:22:28 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
/* Redraw NOW */
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_flush_whenever (gdisp, TRUE);
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
|
1999-01-18 06:50:14 +08:00
|
|
|
/* Force all gdisplays to finish their idlerender projection */
|
2001-02-20 23:15:30 +08:00
|
|
|
void
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_finish_draw (GimpDisplay *gdisp)
|
2001-02-20 23:15:30 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
if (gdisp->idle_render.idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (gdisp->idle_render.idle_id);
|
|
|
|
gdisp->idle_render.idle_id = 0;
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
while (gimp_display_idlerender_callback (gdisp));
|
|
|
|
}
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
/* utility function to check if the cursor is inside the active drawable */
|
|
|
|
gboolean
|
|
|
|
gimp_display_coords_in_active_drawable (GimpDisplay *gdisp,
|
|
|
|
const GimpCoords *coords)
|
|
|
|
{
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
gint x, y;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), FALSE);
|
|
|
|
|
|
|
|
if (!gdisp->gimage)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!(drawable = gimp_image_active_drawable (gdisp->gimage)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gimp_drawable_offsets (drawable, &x, &y);
|
|
|
|
|
|
|
|
x = ROUND (coords->x) - x;
|
|
|
|
if (x < 0 || x > gimp_drawable_width (drawable))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
y = ROUND (coords->y) - y;
|
|
|
|
if (y < 0 || y > gimp_drawable_height (drawable))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_flush_whenever (GimpDisplay *gdisp,
|
|
|
|
gboolean now)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2002-06-27 06:16:59 +08:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
/* Flush the items in the displays and updates lists -
|
|
|
|
* but only if gdisplay has been mapped and exposed
|
|
|
|
*/
|
2002-06-27 06:16:59 +08:00
|
|
|
if (! shell->select)
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
|
|
|
g_warning ("gimp_display_flush_whenever(): called unrealized");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First the updates... */
|
|
|
|
if (now)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2001-11-11 07:03:22 +08:00
|
|
|
/* Synchronous */
|
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
GSList *list;
|
|
|
|
GimpArea *area;
|
|
|
|
|
|
|
|
for (list = gdisp->update_areas; list; list = g_slist_next (list))
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2001-11-11 07:03:22 +08:00
|
|
|
/* Paint the area specified by the GimpArea */
|
2001-11-16 23:08:59 +08:00
|
|
|
area = (GimpArea *) list->data;
|
|
|
|
|
|
|
|
if ((area->x1 != area->x2) && (area->y1 != area->y2))
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
|
|
|
gimp_display_paint_area (gdisp,
|
2001-11-16 23:08:59 +08:00
|
|
|
area->x1,
|
|
|
|
area->y1,
|
|
|
|
(area->x2 - area->x1),
|
|
|
|
(area->y2 - area->y1));
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
|
|
|
}
|
2001-11-11 07:03:22 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Asynchronous */
|
|
|
|
|
|
|
|
if (gdisp->update_areas)
|
|
|
|
gimp_display_idlerender_init (gdisp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the update lists */
|
|
|
|
gdisp->update_areas = gimp_display_area_list_free (gdisp->update_areas);
|
|
|
|
|
|
|
|
/* Next the displays... */
|
2002-06-27 06:16:59 +08:00
|
|
|
gimp_display_shell_flush (shell);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2002-12-14 22:13:54 +08:00
|
|
|
/* ensure the consistency of the menus */
|
|
|
|
if (! now)
|
2003-01-11 01:55:53 +08:00
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
|
|
|
|
gimp_item_factory_update (shell->menubar_factory, shell);
|
|
|
|
|
|
|
|
context = gimp_get_current_context (gdisp->gimage->gimp);
|
|
|
|
|
|
|
|
if (gdisp == gimp_context_get_display (context))
|
|
|
|
gimp_item_factory_update (shell->popup_factory, shell);
|
|
|
|
}
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_idlerender_init (GimpDisplay *gdisp)
|
|
|
|
{
|
|
|
|
GSList *list;
|
2001-11-16 23:08:59 +08:00
|
|
|
GimpArea *area, *new_area;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
|
|
|
/* We need to merge the IdleRender's and the GimpDisplay's update_areas list
|
|
|
|
* to keep track of which of the updates have been flushed and hence need
|
|
|
|
* to be drawn.
|
|
|
|
*/
|
2001-11-16 23:08:59 +08:00
|
|
|
for (list = gdisp->update_areas; list; list = g_slist_next (list))
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
2001-11-16 23:08:59 +08:00
|
|
|
area = (GimpArea *) list->data;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2003-02-21 20:48:13 +08:00
|
|
|
new_area = g_memdup (area, sizeof (GimpArea));
|
2001-11-11 07:03:22 +08:00
|
|
|
|
|
|
|
gdisp->idle_render.update_areas =
|
2001-11-16 23:08:59 +08:00
|
|
|
gimp_display_area_list_process (gdisp->idle_render.update_areas,
|
|
|
|
new_area);
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If an idlerender was already running, merge the remainder of its
|
|
|
|
* unrendered area with the update_areas list, and make it start work
|
|
|
|
* on the next unrendered area in the list.
|
|
|
|
*/
|
|
|
|
if (gdisp->idle_render.idle_id)
|
|
|
|
{
|
2001-11-16 23:08:59 +08:00
|
|
|
new_area =
|
|
|
|
gimp_area_new (gdisp->idle_render.basex,
|
|
|
|
gdisp->idle_render.y,
|
|
|
|
gdisp->idle_render.basex + gdisp->idle_render.width,
|
|
|
|
gdisp->idle_render.y + (gdisp->idle_render.height -
|
|
|
|
(gdisp->idle_render.y -
|
|
|
|
gdisp->idle_render.basey)));
|
2001-11-11 07:03:22 +08:00
|
|
|
|
|
|
|
gdisp->idle_render.update_areas =
|
2001-11-16 23:08:59 +08:00
|
|
|
gimp_display_area_list_process (gdisp->idle_render.update_areas,
|
|
|
|
new_area);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
|
|
|
gimp_display_idle_render_next_area (gdisp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gdisp->idle_render.update_areas == NULL)
|
|
|
|
{
|
|
|
|
g_warning ("Wanted to start idlerender thread with no update_areas. (+memleak)");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_display_idle_render_next_area (gdisp);
|
|
|
|
|
|
|
|
gdisp->idle_render.idle_id = g_idle_add_full (G_PRIORITY_LOW,
|
|
|
|
gimp_display_idlerender_callback,
|
|
|
|
gdisp,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Caller frees gdisp->update_areas */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unless specified otherwise, display re-rendering is organised by
|
|
|
|
* IdleRender, which amalgamates areas to be re-rendered and breaks
|
|
|
|
* them into bite-sized chunks which are chewed on in a low- priority
|
|
|
|
* idle thread. This greatly improves responsiveness for many GIMP
|
|
|
|
* operations. -- Adam
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
gimp_display_idlerender_callback (gpointer data)
|
|
|
|
{
|
|
|
|
const gint CHUNK_WIDTH = 256;
|
|
|
|
const gint CHUNK_HEIGHT = 128;
|
|
|
|
gint workx, worky, workw, workh;
|
|
|
|
GimpDisplay *gdisp = data;
|
|
|
|
|
|
|
|
workw = CHUNK_WIDTH;
|
|
|
|
workh = CHUNK_HEIGHT;
|
|
|
|
workx = gdisp->idle_render.x;
|
|
|
|
worky = gdisp->idle_render.y;
|
|
|
|
|
|
|
|
if (workx + workw > gdisp->idle_render.basex + gdisp->idle_render.width)
|
|
|
|
{
|
|
|
|
workw = gdisp->idle_render.basex + gdisp->idle_render.width - workx;
|
|
|
|
}
|
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
if (worky + workh > gdisp->idle_render.basey + gdisp->idle_render.height)
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
|
|
|
workh = gdisp->idle_render.basey + gdisp->idle_render.height - worky;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_display_paint_area (gdisp, workx, worky, workw, workh);
|
|
|
|
|
|
|
|
gdisp->idle_render.x += CHUNK_WIDTH;
|
|
|
|
|
|
|
|
if (gdisp->idle_render.x >=
|
|
|
|
gdisp->idle_render.basex + gdisp->idle_render.width)
|
|
|
|
{
|
|
|
|
gdisp->idle_render.x = gdisp->idle_render.basex;
|
|
|
|
gdisp->idle_render.y += CHUNK_HEIGHT;
|
|
|
|
|
|
|
|
if (gdisp->idle_render.y >=
|
|
|
|
gdisp->idle_render.basey + gdisp->idle_render.height)
|
|
|
|
{
|
|
|
|
if (! gimp_display_idle_render_next_area (gdisp))
|
|
|
|
{
|
|
|
|
/* FINISHED */
|
|
|
|
gdisp->idle_render.idle_id = 0;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Still work to do. */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_display_idle_render_next_area (GimpDisplay *gdisp)
|
|
|
|
{
|
2001-11-16 23:08:59 +08:00
|
|
|
GimpArea *area;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
if (! gdisp->idle_render.update_areas)
|
|
|
|
return FALSE;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
area = (GimpArea *) gdisp->idle_render.update_areas->data;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
|
|
|
gdisp->idle_render.update_areas =
|
2001-11-16 23:08:59 +08:00
|
|
|
g_slist_remove (gdisp->idle_render.update_areas, area);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
gdisp->idle_render.x = gdisp->idle_render.basex = area->x1;
|
|
|
|
gdisp->idle_render.y = gdisp->idle_render.basey = area->y1;
|
|
|
|
gdisp->idle_render.width = area->x2 - area->x1;
|
|
|
|
gdisp->idle_render.height = area->y2 - area->y1;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
g_free (area);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_paint_area (GimpDisplay *gdisp,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
|
|
|
|
/* Bounds check */
|
|
|
|
x1 = CLAMP (x, 0, gdisp->gimage->width);
|
|
|
|
y1 = CLAMP (y, 0, gdisp->gimage->height);
|
|
|
|
x2 = CLAMP (x + w, 0, gdisp->gimage->width);
|
|
|
|
y2 = CLAMP (y + h, 0, gdisp->gimage->height);
|
|
|
|
x = x1;
|
|
|
|
y = y1;
|
|
|
|
w = (x2 - x1);
|
|
|
|
h = (y2 - y1);
|
|
|
|
|
|
|
|
/* calculate the extents of the update as limited by what's visible */
|
2002-06-27 06:16:59 +08:00
|
|
|
gimp_display_shell_untransform_xy (shell,
|
|
|
|
0, 0,
|
|
|
|
&x1, &y1,
|
|
|
|
FALSE, FALSE);
|
|
|
|
gimp_display_shell_untransform_xy (shell,
|
|
|
|
shell->disp_width, shell->disp_height,
|
|
|
|
&x2, &y2,
|
|
|
|
FALSE, FALSE);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
|
|
|
gimp_image_invalidate (gdisp->gimage, x, y, w, h, x1, y1, x2, y2);
|
|
|
|
|
|
|
|
/* display the area */
|
2002-06-27 06:16:59 +08:00
|
|
|
gimp_display_shell_transform_xy (shell, x, y, &x1, &y1, FALSE);
|
|
|
|
gimp_display_shell_transform_xy (shell, x + w, y + h, &x2, &y2, FALSE);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2003-02-21 20:16:43 +08:00
|
|
|
gimp_display_shell_expose_area (shell, x1, y1, (x2 - x1), (y2 - y1));
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|