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"
|
|
|
|
#include "gui/gui-types.h" /* FIXME */
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.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-05-14 05:51:20 +08:00
|
|
|
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "tools/gimptool.h"
|
2001-02-28 10:53:27 +08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "gui/info-window.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 "gimpdisplay-selection.h"
|
|
|
|
#include "gimpdisplayshell.h"
|
|
|
|
#include "gximage.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "gimprc.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "nav_window.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "plug_in.h"
|
1999-07-07 11:18:54 +08:00
|
|
|
#include "qmask.h"
|
2000-12-25 04:27:04 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
2001-07-31 19:33:13 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* local function prototypes */
|
2001-07-31 19:33:13 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
static void gimp_display_class_init (GimpDisplayClass *klass);
|
|
|
|
static void gimp_display_init (GimpDisplay *gdisp);
|
|
|
|
|
|
|
|
static void gimp_display_finalize (GObject *object);
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
static void gimp_display_flush_whenever (GimpDisplay *gdisp,
|
|
|
|
gboolean now);
|
|
|
|
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;
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
GSList *display_list = NULL;
|
|
|
|
static gint display_num = 1;
|
2001-09-26 01:44:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
object_class->finalize = gimp_display_finalize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_init (GimpDisplay *gdisp)
|
|
|
|
{
|
|
|
|
gdisp->ID = display_num++;
|
|
|
|
|
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;
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisp->scale = 0;
|
|
|
|
gdisp->dot_for_dot = gimprc.default_dot_for_dot;
|
|
|
|
|
|
|
|
gdisp->offset_x = 0;
|
|
|
|
gdisp->offset_y = 0;
|
2001-09-26 01:44:03 +08:00
|
|
|
|
|
|
|
gdisp->disp_width = 0;
|
|
|
|
gdisp->disp_height = 0;
|
|
|
|
gdisp->disp_xoffset = 0;
|
|
|
|
gdisp->disp_yoffset = 0;
|
|
|
|
|
|
|
|
gdisp->draw_guides = TRUE;
|
|
|
|
gdisp->snap_to_guides = TRUE;
|
|
|
|
|
|
|
|
gdisp->select = NULL;
|
|
|
|
|
|
|
|
gdisp->update_areas = NULL;
|
1998-06-15 10:25:27 +08:00
|
|
|
|
2000-06-09 20:31:19 +08:00
|
|
|
gdisp->idle_render.idleid = -1;
|
1998-10-02 00:22:28 +08:00
|
|
|
gdisp->idle_render.update_areas = NULL;
|
2000-06-09 20:31:19 +08:00
|
|
|
gdisp->idle_render.active = FALSE;
|
2001-09-26 01:44:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (object));
|
|
|
|
|
|
|
|
gdisp = GIMP_DISPLAY (object);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpDisplay *
|
|
|
|
gdisplay_new (GimpImage *gimage,
|
|
|
|
guint scale)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set all GimpDisplay parameters...
|
|
|
|
*/
|
|
|
|
gdisp = g_object_new (GIMP_TYPE_DISPLAY, NULL);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* add the new display to the list so that it isn't lost */
|
2001-06-18 21:10:03 +08:00
|
|
|
display_list = g_slist_append (display_list, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
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
|
|
|
gdisp->scale = scale;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* create the shell for the image */
|
|
|
|
gdisp->shell = gimp_display_shell_new (gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return gdisp;
|
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
void
|
2001-09-26 01:44:03 +08:00
|
|
|
gdisplay_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 */
|
|
|
|
display_list = g_slist_remove (display_list, 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
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
if (gdisp->select)
|
|
|
|
{
|
|
|
|
selection_free (gdisp->select);
|
|
|
|
gdisp->select = NULL;
|
|
|
|
}
|
1998-10-02 00:22:28 +08:00
|
|
|
|
|
|
|
/* If this gdisplay was idlerendering at the time when it was deleted,
|
|
|
|
deactivate the idlerendering thread before deletion! */
|
|
|
|
if (gdisp->idle_render.active)
|
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
g_source_remove (gdisp->idle_render.idleid);
|
1998-10-02 00:22:28 +08:00
|
|
|
gdisp->idle_render.active = FALSE;
|
|
|
|
}
|
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
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* free the gimage */
|
|
|
|
gimp_display_disconnect (gdisp);
|
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
g_object_unref (G_OBJECT (gdisp));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplay *
|
|
|
|
gdisplay_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;
|
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
/* Traverse the list of displays, returning the one that matches the ID
|
|
|
|
* If no display in the list is a match, return NULL.
|
|
|
|
*/
|
|
|
|
for (list = display_list; list; list = g_slist_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
|
|
|
|
gdisplay_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-01 05:20:09 +08:00
|
|
|
if (gdisp->idle_render.active)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
g_source_remove (gdisp->idle_render.idleid);
|
|
|
|
gdisp->idle_render.idleid = 0;
|
|
|
|
gdisp->idle_render.active = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
gdisplay_add_update_area (gdisp,
|
|
|
|
0, 0,
|
|
|
|
gdisp->gimage->width,
|
|
|
|
gdisp->gimage->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_update_title (GIMP_DISPLAY_SHELL (gdisp->shell));
|
|
|
|
gimp_display_shell_resize_cursor_label (GIMP_DISPLAY_SHELL (gdisp->shell));
|
|
|
|
gimp_display_shell_shrink_wrap (GIMP_DISPLAY_SHELL (gdisp->shell));
|
|
|
|
gimp_display_shell_expose_full (GIMP_DISPLAY_SHELL (gdisp->shell));
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
static gint
|
|
|
|
idle_render_next_area (GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
GimpArea *ga;
|
|
|
|
GSList *list;
|
1998-10-02 00:22:28 +08:00
|
|
|
|
|
|
|
list = gdisp->idle_render.update_areas;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
if (list == NULL)
|
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
return -1;
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
1998-10-01 19:53:20 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
ga = (GimpArea *) list->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
gdisp->idle_render.update_areas =
|
|
|
|
g_slist_remove (gdisp->idle_render.update_areas, ga);
|
|
|
|
|
|
|
|
gdisp->idle_render.x = gdisp->idle_render.basex = ga->x1;
|
|
|
|
gdisp->idle_render.y = gdisp->idle_render.basey = ga->y1;
|
|
|
|
gdisp->idle_render.width = ga->x2 - ga->x1;
|
|
|
|
gdisp->idle_render.height = ga->y2 - ga->y1;
|
|
|
|
|
|
|
|
g_free (ga);
|
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
return 0;
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
/* 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 gint
|
1998-10-02 00:22:28 +08:00
|
|
|
idlerender_callback (gpointer data)
|
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
const gint CHUNK_WIDTH = 256;
|
|
|
|
const gint CHUNK_HEIGHT = 128;
|
|
|
|
gint workx, worky, workw, workh;
|
|
|
|
GimpDisplay *gdisp = data;
|
1998-10-02 00:22:28 +08:00
|
|
|
|
|
|
|
workw = CHUNK_WIDTH;
|
|
|
|
workh = CHUNK_HEIGHT;
|
|
|
|
workx = gdisp->idle_render.x;
|
|
|
|
worky = gdisp->idle_render.y;
|
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
if (workx + workw > gdisp->idle_render.basex + gdisp->idle_render.width)
|
1998-10-02 00:22:28 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
workw = gdisp->idle_render.basex + gdisp->idle_render.width - workx;
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (worky+workh > gdisp->idle_render.basey+gdisp->idle_render.height)
|
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
workh = gdisp->idle_render.basey + gdisp->idle_render.height - worky;
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_paint_area (gdisp, workx, worky, workw, workh);
|
|
|
|
|
|
|
|
gimp_display_shell_flush (GIMP_DISPLAY_SHELL (gdisp->shell));
|
1998-10-02 00:22:28 +08:00
|
|
|
|
|
|
|
gdisp->idle_render.x += CHUNK_WIDTH;
|
2001-09-26 01:44:03 +08:00
|
|
|
if (gdisp->idle_render.x >=
|
|
|
|
gdisp->idle_render.basex + gdisp->idle_render.width)
|
1998-10-02 00:22:28 +08:00
|
|
|
{
|
|
|
|
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 (idle_render_next_area(gdisp) != 0)
|
|
|
|
{
|
|
|
|
/* FINISHED */
|
|
|
|
gdisp->idle_render.active = FALSE;
|
1999-01-11 07:36:29 +08:00
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Still work to do. */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_idlerender_init (GimpDisplay *gdisp)
|
1998-10-02 00:22:28 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
GSList *list;
|
2000-02-10 22:23:11 +08:00
|
|
|
GimpArea *ga, *new_ga;
|
1998-10-02 00:22:28 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
/* We need to merge the IdleRender's and the GimpDisplay's update_areas list
|
2001-11-01 05:20:09 +08:00
|
|
|
* to keep track of which of the updates have been flushed and hence need
|
|
|
|
* to be drawn.
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
list = gdisp->update_areas;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
while (list)
|
|
|
|
{
|
2000-02-10 22:23:11 +08:00
|
|
|
ga = (GimpArea *) list->data;
|
|
|
|
new_ga = g_malloc (sizeof(GimpArea));
|
|
|
|
memcpy (new_ga, ga, sizeof(GimpArea));
|
1998-10-01 19:53:20 +08:00
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
gdisp->idle_render.update_areas =
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_area_list_process (gdisp->idle_render.update_areas, new_ga);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-01-29 16:03:27 +08:00
|
|
|
list = g_slist_next (list);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-10-02 00:22:28 +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.active)
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
new_ga = g_malloc (sizeof (GimpArea));
|
1998-10-02 00:22:28 +08:00
|
|
|
new_ga->x1 = gdisp->idle_render.basex;
|
|
|
|
new_ga->y1 = gdisp->idle_render.y;
|
|
|
|
new_ga->x2 = gdisp->idle_render.basex + gdisp->idle_render.width;
|
|
|
|
new_ga->y2 = gdisp->idle_render.y +
|
|
|
|
(gdisp->idle_render.height -
|
|
|
|
(gdisp->idle_render.y - gdisp->idle_render.basey)
|
|
|
|
);
|
|
|
|
|
|
|
|
gdisp->idle_render.update_areas =
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_area_list_process (gdisp->idle_render.update_areas, new_ga);
|
1998-10-02 00:22:28 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
idle_render_next_area (gdisp);
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gdisp->idle_render.update_areas == NULL)
|
|
|
|
{
|
1999-05-30 00:35:47 +08:00
|
|
|
g_warning ("Wanted to start idlerender thread with no update_areas. (+memleak)");
|
1998-10-02 00:22:28 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
idle_render_next_area (gdisp);
|
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
gdisp->idle_render.active = TRUE;
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisp->idle_render.idleid = gtk_idle_add_priority (GTK_PRIORITY_LOW,
|
|
|
|
idlerender_callback,
|
|
|
|
gdisp);
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Caller frees gdisp->update_areas */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
static void
|
|
|
|
gimp_display_flush_whenever (GimpDisplay *gdisp,
|
|
|
|
gboolean now)
|
1998-10-02 00:22:28 +08:00
|
|
|
{
|
1999-07-07 21:32:58 +08:00
|
|
|
GSList *list;
|
2000-02-10 22:23:11 +08:00
|
|
|
GimpArea *ga;
|
1998-10-02 00:22:28 +08:00
|
|
|
|
|
|
|
/* Flush the items in the displays and updates lists -
|
|
|
|
* but only if gdisplay has been mapped and exposed
|
|
|
|
*/
|
|
|
|
if (!gdisp->select)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* First the updates... */
|
|
|
|
if (now)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
|
|
|
/* Synchronous */
|
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
list = gdisp->update_areas;
|
|
|
|
while (list)
|
|
|
|
{
|
2000-02-10 22:23:11 +08:00
|
|
|
/* Paint the area specified by the GimpArea */
|
|
|
|
ga = (GimpArea *) list->data;
|
1998-10-02 00:22:28 +08:00
|
|
|
|
|
|
|
if ((ga->x1 != ga->x2) && (ga->y1 != ga->y2))
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_paint_area (gdisp, ga->x1, ga->y1,
|
|
|
|
(ga->x2 - ga->x1), (ga->y2 - ga->y1));
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
list = g_slist_next (list);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-10-02 00:22:28 +08:00
|
|
|
else
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
|
|
|
/* Asynchronous */
|
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
if (gdisp->update_areas)
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_idlerender_init (gdisp);
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
/* Free the update lists */
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisp->update_areas = gimp_display_area_list_free (gdisp->update_areas);
|
1998-10-02 00:22:28 +08:00
|
|
|
|
|
|
|
/* Next the displays... */
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_flush (GIMP_DISPLAY_SHELL (gdisp->shell));
|
1997-11-27 03:30:17 +08:00
|
|
|
|
|
|
|
/* update the gdisplay's info dialog */
|
1999-11-30 08:11:08 +08:00
|
|
|
info_window_update (gdisp);
|
1999-07-07 11:18:54 +08:00
|
|
|
|
|
|
|
/* update the gdisplay's qmask buttons */
|
|
|
|
qmask_buttons_update (gdisp);
|
1999-07-07 21:32:58 +08:00
|
|
|
|
1999-06-21 07:29:34 +08:00
|
|
|
/* ensure the consistency of the tear-off menus */
|
2001-11-01 05:20:09 +08:00
|
|
|
if (! now && gimp_context_get_display (gimp_get_user_context
|
|
|
|
(gdisp->gimage->gimp)) == gdisp)
|
2001-07-07 20:17:23 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_set_menu_sensitivity (GIMP_DISPLAY_SHELL (gdisp->shell));
|
2001-07-07 20:17:23 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
void
|
2001-09-26 01:44:03 +08:00
|
|
|
gdisplay_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-09-26 01:44:03 +08:00
|
|
|
gdisplay_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 */
|
2000-01-02 02:33:40 +08:00
|
|
|
void
|
|
|
|
gdisplays_finish_draw (void)
|
1999-01-18 06:50:14 +08:00
|
|
|
{
|
2001-10-13 20:52:30 +08:00
|
|
|
GSList *list;
|
2001-09-26 01:44:03 +08:00
|
|
|
GimpDisplay *gdisp;
|
1999-01-18 06:50:14 +08:00
|
|
|
|
2001-10-13 20:52:30 +08:00
|
|
|
for (list = display_list; list; list = g_slist_next (list))
|
1999-01-18 06:50:14 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
gdisp = (GimpDisplay *) list->data;
|
1999-01-18 06:50:14 +08:00
|
|
|
|
|
|
|
if (gdisp->idle_render.active)
|
|
|
|
{
|
2001-10-13 20:52:30 +08:00
|
|
|
g_source_remove (gdisp->idle_render.idleid);
|
|
|
|
gdisp->idle_render.idleid = 0;
|
|
|
|
|
|
|
|
while (idlerender_callback (gdisp));
|
1999-01-18 06:50:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-20 23:15:30 +08:00
|
|
|
void
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisplay_add_update_area (GimpDisplay *gdisp,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
2001-02-20 23:15:30 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpArea *ga;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
|
|
|
|
|
|
|
ga = g_new (GimpArea, 1);
|
|
|
|
|
|
|
|
ga->x1 = CLAMP (x, 0, gdisp->gimage->width);
|
|
|
|
ga->y1 = CLAMP (y, 0, gdisp->gimage->height);
|
|
|
|
ga->x2 = CLAMP (x + w, 0, gdisp->gimage->width);
|
|
|
|
ga->y2 = CLAMP (y + h, 0, gdisp->gimage->height);
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisp->update_areas = gimp_display_area_list_process (gdisp->update_areas, ga);
|
|
|
|
}
|
2001-02-20 23:15:30 +08:00
|
|
|
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
static void
|
|
|
|
gimp_display_paint_area (GimpDisplay *gdisp,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gint x1, y1, x2, y2;
|
2001-02-23 04:23:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* 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);
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* calculate the extents of the update as limited by what's visible */
|
|
|
|
gdisplay_untransform_coords (gdisp,
|
|
|
|
0, 0,
|
|
|
|
&x1, &y1,
|
|
|
|
FALSE, FALSE);
|
|
|
|
gdisplay_untransform_coords (gdisp,
|
|
|
|
gdisp->disp_width, gdisp->disp_height,
|
|
|
|
&x2, &y2,
|
|
|
|
FALSE, FALSE);
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_image_invalidate (gdisp->gimage, x, y, w, h, x1, y1, x2, y2);
|
2001-09-03 21:03:34 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* display the area */
|
|
|
|
gdisplay_transform_coords (gdisp, x, y, &x1, &y1, FALSE);
|
|
|
|
gdisplay_transform_coords (gdisp, x + w, y + h, &x2, &y2, FALSE);
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_add_expose_area (shell,
|
|
|
|
x1, y1, (x2 - x1), (y2 - y1));
|
|
|
|
}
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
void
|
|
|
|
gdisplay_transform_coords (GimpDisplay *gdisp,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint *nx,
|
|
|
|
gint *ny,
|
|
|
|
gboolean use_offsets)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gdouble scalex;
|
|
|
|
gdouble scaley;
|
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
|
|
|
g_return_if_fail (nx != NULL);
|
|
|
|
g_return_if_fail (ny != NULL);
|
2001-02-23 04:23:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
2001-02-23 04:23:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* transform from image coordinates to screen coordinates */
|
|
|
|
scalex = SCALEFACTOR_X (gdisp);
|
|
|
|
scaley = SCALEFACTOR_Y (gdisp);
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
if (use_offsets)
|
2001-02-20 23:15:30 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
|
|
|
|
&offset_x, &offset_y);
|
2001-02-20 23:15:30 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
offset_x = offset_y = 0;
|
2001-02-20 23:15:30 +08:00
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
*nx = (gint) (scalex * (x + offset_x) - gdisp->offset_x);
|
|
|
|
*ny = (gint) (scaley * (y + offset_y) - gdisp->offset_y);
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
*nx += gdisp->disp_xoffset;
|
|
|
|
*ny += gdisp->disp_yoffset;
|
2001-02-20 23:15:30 +08:00
|
|
|
}
|
|
|
|
|
2001-02-23 04:23:30 +08:00
|
|
|
void
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisplay_untransform_coords (GimpDisplay *gdisp,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint *nx,
|
|
|
|
gint *ny,
|
|
|
|
gboolean round,
|
|
|
|
gboolean use_offsets)
|
2001-02-23 04:23:30 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gdouble scalex;
|
|
|
|
gdouble scaley;
|
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
2001-02-23 04:23:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
|
|
|
g_return_if_fail (nx != NULL);
|
|
|
|
g_return_if_fail (ny != NULL);
|
2001-02-23 04:23:30 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
2001-09-26 01:44:03 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
x -= gdisp->disp_xoffset;
|
|
|
|
y -= gdisp->disp_yoffset;
|
|
|
|
|
|
|
|
/* transform from screen coordinates to image coordinates */
|
1998-12-06 05:48:37 +08:00
|
|
|
scalex = SCALEFACTOR_X (gdisp);
|
|
|
|
scaley = SCALEFACTOR_Y (gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (use_offsets)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
|
|
|
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
|
|
|
|
&offset_x, &offset_y);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
offset_x = offset_y = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (round)
|
|
|
|
{
|
1998-12-06 05:48:37 +08:00
|
|
|
*nx = ROUND ((x + gdisp->offset_x) / scalex - offset_x);
|
|
|
|
*ny = ROUND ((y + gdisp->offset_y) / scaley - offset_y);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-12-06 05:48:37 +08:00
|
|
|
*nx = (int) ((x + gdisp->offset_x) / scalex - offset_x);
|
|
|
|
*ny = (int) ((y + gdisp->offset_y) / scaley - offset_y);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-26 01:44:03 +08:00
|
|
|
gdisplay_transform_coords_f (GimpDisplay *gdisp,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble *nx,
|
|
|
|
gdouble *ny,
|
|
|
|
gboolean use_offsets)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gdouble scalex;
|
|
|
|
gdouble scaley;
|
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
2001-11-01 05:20:09 +08:00
|
|
|
g_return_if_fail (nx != NULL);
|
|
|
|
g_return_if_fail (ny != NULL);
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
2001-09-26 01:44:03 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* transform from gimp coordinates to screen coordinates */
|
2000-02-10 22:23:11 +08:00
|
|
|
scalex = SCALEFACTOR_X (gdisp);
|
|
|
|
scaley = SCALEFACTOR_Y (gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (use_offsets)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
|
|
|
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
|
|
|
|
&offset_x, &offset_y);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
offset_x = offset_y = 0;
|
|
|
|
}
|
|
|
|
|
1998-12-06 05:48:37 +08:00
|
|
|
*nx = scalex * (x + offset_x) - gdisp->offset_x;
|
|
|
|
*ny = scaley * (y + offset_y) - gdisp->offset_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
*nx += gdisp->disp_xoffset;
|
|
|
|
*ny += gdisp->disp_yoffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-26 01:44:03 +08:00
|
|
|
gdisplay_untransform_coords_f (GimpDisplay *gdisp,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble *nx,
|
|
|
|
gdouble *ny,
|
|
|
|
gboolean use_offsets)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gdouble scalex;
|
|
|
|
gdouble scaley;
|
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
2001-11-01 05:20:09 +08:00
|
|
|
g_return_if_fail (nx != NULL);
|
|
|
|
g_return_if_fail (ny != NULL);
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
2001-09-26 01:44:03 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
x -= gdisp->disp_xoffset;
|
|
|
|
y -= gdisp->disp_yoffset;
|
|
|
|
|
|
|
|
/* transform from screen coordinates to gimp coordinates */
|
2000-02-10 22:23:11 +08:00
|
|
|
scalex = SCALEFACTOR_X (gdisp);
|
|
|
|
scaley = SCALEFACTOR_Y (gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (use_offsets)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
|
|
|
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
|
|
|
|
&offset_x, &offset_y);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
offset_x = offset_y = 0;
|
|
|
|
}
|
|
|
|
|
1998-12-06 05:48:37 +08:00
|
|
|
*nx = (x + gdisp->offset_x) / scalex - offset_x;
|
|
|
|
*ny = (y + gdisp->offset_y) / scaley - offset_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
void
|
2001-09-26 01:44:03 +08:00
|
|
|
gdisplay_selection_visibility (GimpDisplay *gdisp,
|
|
|
|
GimpSelectionControl control)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (gdisp->select)
|
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
switch (control)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2001-09-26 01:44:03 +08:00
|
|
|
case GIMP_SELECTION_OFF:
|
2001-06-18 21:10:03 +08:00
|
|
|
selection_invis (gdisp->select);
|
|
|
|
break;
|
2001-09-26 01:44:03 +08:00
|
|
|
case GIMP_SELECTION_LAYER_OFF:
|
2001-06-18 21:10:03 +08:00
|
|
|
selection_layer_invis (gdisp->select);
|
|
|
|
break;
|
2001-09-26 01:44:03 +08:00
|
|
|
case GIMP_SELECTION_ON:
|
2001-06-18 21:10:03 +08:00
|
|
|
selection_start (gdisp->select, TRUE);
|
|
|
|
break;
|
2001-09-26 01:44:03 +08:00
|
|
|
case GIMP_SELECTION_PAUSE:
|
2001-06-18 21:10:03 +08:00
|
|
|
selection_pause (gdisp->select);
|
|
|
|
break;
|
2001-09-26 01:44:03 +08:00
|
|
|
case GIMP_SELECTION_RESUME:
|
2001-06-18 21:10:03 +08:00
|
|
|
selection_resume (gdisp->select);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|