app/display/Makefile.am app/display/gimpdisplay-callbacks.[ch]

2001-11-01  Michael Natterer  <mitch@gimp.org>

	* app/display/Makefile.am
	* app/display/gimpdisplay-callbacks.[ch]
	* app/display/gimpdisplay-render.[ch]
	* app/display/gimpdisplay-scale.[ch]
	* app/display/gimpdisplay-scroll.[ch]: removed and added as
	gimpdisplayshell-foo.[ch] because they are all methods of the
	shell.

	* app/display/gimpdisplay.[ch]
	* app/display/gimpdisplayshell.[ch]: moved the "offset" and "size"
	variables from GimpDisplay to GimpDisplayShell. GimpDisplay
	should know nothing about screen coordinates.

	The gdisplay_[un]transform_foo() methods are still part of
	GimpDisplay but will be moved to GimpDisplayShell as soon as the
	tools' vitrual functions speak in image coordinates instead of
	GdkEvents.

	* app/display/gimpdisplayshell-callbacks.[ch]: prefixed all
	functions with gimp_display_shell_*. Moved some stuff to a
	"realize" callback File still has to be renamed.

	* app/display/gimpdisplay-foreach.[ch]: removed
	gdisplays_shrink_wrap().

	* app/gui/menus.c
	* app/gui/view-commands.[ch]
	* app/display/gimpdisplayshell-scale.[ch]: implemented "Zoom to
	Fit Window" function (#57670).

	* app/nav_window.c
	* app/display/gimpdisplay-handlers.c
	* app/display/gimpdisplayshell-render.[ch]
	* app/display/gimpdisplayshell-scale.[ch]
	* app/display/gimpdisplayshell-scroll.[ch]
	* app/gui/colormap-dialog.c
	* app/gui/gui.c
	* app/gui/preferences-dialog.c
	* app/tools/gimpmagnifytool.c
	* app/tools/gimpmovetool.c
	* app/widgets/gimppreview.c: changed according to variable
	and filename changes.

	* app/tools/tool_manager.c: tool_manager_select_tool(): send the
	active tool a "HALT" command before selecting the new one. Fixes
	stale tool dialogs which were there because some other hack was
	removed (This is IMHO the right place to shut down the active
	tool).

	* app/tools/gimpcroptool.c: don't shrink wrap after cropping but
	let gimprc.allow_resize_windows decide.

	* app/tools/gimpselectiontool.c: gimage_mask_value() takes image,
	not screen coordinates. A good example of how braindead it is to
	pass GdkEvents to tools :-) Fixes incorrect cursor and oper
	update of the selection tools.

	* app/tools/gimptransformtool.c
	* app/undo.c: removed (#if 0 for now) some strange code which did
	manual exposing of GimpDisplayShell areas. This was definitely a
	hack and should not be there given the image emits correct
	"update" signals.
This commit is contained in:
Michael Natterer
2001-11-02 09:31:21 +00:00
committed by Michael Natterer
parent 6033ef8fbb
commit d162376d47
58 changed files with 951 additions and 3371 deletions

View File

@ -1,3 +1,68 @@
2001-11-01 Michael Natterer <mitch@gimp.org>
* app/display/Makefile.am
* app/display/gimpdisplay-callbacks.[ch]
* app/display/gimpdisplay-render.[ch]
* app/display/gimpdisplay-scale.[ch]
* app/display/gimpdisplay-scroll.[ch]: removed and added as
gimpdisplayshell-foo.[ch] because they are all methods of the
shell.
* app/display/gimpdisplay.[ch]
* app/display/gimpdisplayshell.[ch]: moved the "offset" and "size"
variables from GimpDisplay to GimpDisplayShell. GimpDisplay
should know nothing about screen coordinates.
The gdisplay_[un]transform_foo() methods are still part of
GimpDisplay but will be moved to GimpDisplayShell as soon as the
tools' vitrual functions speak in image coordinates instead of
GdkEvents.
* app/display/gimpdisplayshell-callbacks.[ch]: prefixed all
functions with gimp_display_shell_*. Moved some stuff to a
"realize" callback File still has to be renamed.
* app/display/gimpdisplay-foreach.[ch]: removed
gdisplays_shrink_wrap().
* app/gui/menus.c
* app/gui/view-commands.[ch]
* app/display/gimpdisplayshell-scale.[ch]: implemented "Zoom to
Fit Window" function (#57670).
* app/nav_window.c
* app/display/gimpdisplay-handlers.c
* app/display/gimpdisplayshell-render.[ch]
* app/display/gimpdisplayshell-scale.[ch]
* app/display/gimpdisplayshell-scroll.[ch]
* app/gui/colormap-dialog.c
* app/gui/gui.c
* app/gui/preferences-dialog.c
* app/tools/gimpmagnifytool.c
* app/tools/gimpmovetool.c
* app/widgets/gimppreview.c: changed according to variable
and filename changes.
* app/tools/tool_manager.c: tool_manager_select_tool(): send the
active tool a "HALT" command before selecting the new one. Fixes
stale tool dialogs which were there because some other hack was
removed (This is IMHO the right place to shut down the active
tool).
* app/tools/gimpcroptool.c: don't shrink wrap after cropping but
let gimprc.allow_resize_windows decide.
* app/tools/gimpselectiontool.c: gimage_mask_value() takes image,
not screen coordinates. A good example of how braindead it is to
pass GdkEvents to tools :-) Fixes incorrect cursor and oper
update of the selection tools.
* app/tools/gimptransformtool.c
* app/undo.c: removed (#if 0 for now) some strange code which did
manual exposing of GimpDisplayShell areas. This was definitely a
hack and should not be there given the image emits correct
"update" signals.
2001-11-01 DindinX <odin@mandrakesoft.com>
* plug-ins/common/bz2.c: fix a little typo in a comment
@ -13,7 +78,7 @@
GimpDisplayShell has all the widgets and handles painting and
exposing of the result. Nobody should actually be required to
update ot look at it as it should be a view on the GimpDisplay
update or look at it as it should be a view on the GimpDisplay
object.
Much stuff is still in the wrong place and the functions don't
@ -27,7 +92,7 @@
functions.
* app/display/gimpdisplay-handlers.[ch]: new files: signal
handlers for GimpImage signals. Mostly from app/gui.c.
handlers for GimpImage signals. Mostly from gui/gui.c.
* app/display/gimpdisplay.[ch]: removed all widgets and other
GUI stuff. There is still much undecided here...

View File

@ -30,9 +30,9 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplay-scale.h"
#include "display/gimpdisplay-selection.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-scale.h"
#include "info-dialog.h"
#include "info-window.h"
@ -49,7 +49,7 @@
void
view_zoomin_cmd_callback (GtkWidget *widget,
view_zoom_in_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
@ -59,7 +59,7 @@ view_zoomin_cmd_callback (GtkWidget *widget,
}
void
view_zoomout_cmd_callback (GtkWidget *widget,
view_zoom_out_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
@ -68,6 +68,16 @@ view_zoomout_cmd_callback (GtkWidget *widget,
gimp_display_shell_scale (GIMP_DISPLAY_SHELL (gdisp->shell), GIMP_ZOOM_OUT);
}
void
view_zoom_fit_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
gimp_display_shell_scale_fit (GIMP_DISPLAY_SHELL (gdisp->shell));
}
void
view_zoom_cmd_callback (GtkWidget *widget,
gpointer data,

View File

@ -20,9 +20,11 @@
#define __VIEW_COMMANDS_H__
void view_zoomin_cmd_callback (GtkWidget *widget,
void view_zoom_in_cmd_callback (GtkWidget *widget,
gpointer data);
void view_zoomout_cmd_callback (GtkWidget *widget,
void view_zoom_out_cmd_callback (GtkWidget *widget,
gpointer data);
void view_zoom_fit_cmd_callback (GtkWidget *widget,
gpointer data);
void view_zoom_cmd_callback (GtkWidget *widget,
gpointer data,

View File

@ -602,7 +602,7 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
TransformUndo *tu;
PathUndo *pundo;
gboolean new_layer;
gint i, x, y;
gint i;
gimp_set_busy (gdisp->gimage->gimp);
@ -683,11 +683,17 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
*/
tool->preserve = FALSE;
#ifdef __GNUC__
#warning FIXME: investigate why display update was done here
#endif
#if 0
/* Flush the gdisplays */
if (gdisp->disp_xoffset || gdisp->disp_yoffset)
{
x = shell->canvas->allocation.width;
y = shell->canvas->allocation.height;
gint x, y;
x = shell->disp_width;
y = shell->disp_height;
if (gdisp->disp_yoffset)
{
@ -710,6 +716,7 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
gdisp->disp_width, gdisp->disp_height);
}
}
#endif
gimp_unset_busy (gdisp->gimage->gimp);

View File

@ -602,7 +602,7 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
TransformUndo *tu;
PathUndo *pundo;
gboolean new_layer;
gint i, x, y;
gint i;
gimp_set_busy (gdisp->gimage->gimp);
@ -683,11 +683,17 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
*/
tool->preserve = FALSE;
#ifdef __GNUC__
#warning FIXME: investigate why display update was done here
#endif
#if 0
/* Flush the gdisplays */
if (gdisp->disp_xoffset || gdisp->disp_yoffset)
{
x = shell->canvas->allocation.width;
y = shell->canvas->allocation.height;
gint x, y;
x = shell->disp_width;
y = shell->disp_height;
if (gdisp->disp_yoffset)
{
@ -710,6 +716,7 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
gdisp->disp_width, gdisp->disp_height);
}
}
#endif
gimp_unset_busy (gdisp->gimage->gimp);

View File

@ -394,10 +394,8 @@ pop_stack (GimpImage *gimage,
Undo *object;
GSList *stack;
GSList *tmp;
gint status = 0;
gint in_group = 0;
gint x, y;
GimpDisplay *gdisp;
gboolean status = FALSE;
gboolean in_group = FALSE;
/* Keep popping until we pop a valid object
* or get to the end of a group if we're in one
@ -407,21 +405,26 @@ pop_stack (GimpImage *gimage,
stack = *stack_ptr;
object = (Undo *) stack->data;
if (object->group_boundary)
{
in_group = (in_group) ? 0 : 1;
in_group = ! in_group;
if (in_group)
gimage->undo_levels += (state == UNDO) ? -1 : 1;
if (status && ! in_group)
status = 1;
status = TRUE;
else
status = 0;
status = FALSE;
}
else
{
TRC (("undo_pop: %s\n", undo_type_to_name (object->type)));
status = (* object->pop_func) (gimage, state, object->type,
status = (* object->pop_func) (gimage,
state,
object->type,
object->data);
if (object->dirties_image)
@ -441,7 +444,7 @@ pop_stack (GimpImage *gimage,
gimage->undo_levels += (state == UNDO) ? -1 : 1;
}
*unstack_ptr = g_slist_prepend (*unstack_ptr, (gpointer) object);
*unstack_ptr = g_slist_prepend (*unstack_ptr, object);
tmp = stack;
*stack_ptr = g_slist_next (*stack_ptr);
@ -450,6 +453,13 @@ pop_stack (GimpImage *gimage,
if (status && ! in_group)
{
#ifdef __GNUC__
#warning FIXME: investigate why display update was done here
#endif
#if 0
GimpDisplay *gdisp;
gint x, y;
/* Flush any image updates and displays */
gdisp = gimp_context_get_display (gimp_get_user_context (gimage->gimp));
@ -488,8 +498,7 @@ pop_stack (GimpImage *gimage,
}
}
}
gdisplays_flush ();
#endif
/* If the mode_changed flag was set */
if (mode_changed)
@ -527,6 +536,8 @@ pop_stack (GimpImage *gimage,
gimp_image_undo_event (gimage,
(state == UNDO)? UNDO_POPPED : UNDO_REDO);
gdisplays_flush ();
return TRUE;
}
}

View File

@ -122,15 +122,6 @@ gimp_display_init (GimpDisplay *gdisp)
gdisp->scale = 0;
gdisp->dot_for_dot = gimprc.default_dot_for_dot;
gdisp->offset_x = 0;
gdisp->offset_y = 0;
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;
@ -281,10 +272,8 @@ gdisplay_reconnect (GimpDisplay *gdisp,
gdisp->gimage->width,
gdisp->gimage->height);
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));
}
static gint
@ -584,7 +573,7 @@ gimp_display_paint_area (GimpDisplay *gdisp,
&x1, &y1,
FALSE, FALSE);
gdisplay_untransform_coords (gdisp,
gdisp->disp_width, gdisp->disp_height,
shell->disp_width, shell->disp_height,
&x2, &y2,
FALSE, FALSE);
@ -632,11 +621,11 @@ gdisplay_transform_coords (GimpDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = (gint) (scalex * (x + offset_x) - gdisp->offset_x);
*ny = (gint) (scaley * (y + offset_y) - gdisp->offset_y);
*nx = (gint) (scalex * (x + offset_x) - shell->offset_x);
*ny = (gint) (scaley * (y + offset_y) - shell->offset_y);
*nx += gdisp->disp_xoffset;
*ny += gdisp->disp_yoffset;
*nx += shell->disp_xoffset;
*ny += shell->disp_yoffset;
}
void
@ -660,8 +649,8 @@ gdisplay_untransform_coords (GimpDisplay *gdisp,
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
x -= gdisp->disp_xoffset;
y -= gdisp->disp_yoffset;
x -= shell->disp_xoffset;
y -= shell->disp_yoffset;
/* transform from screen coordinates to image coordinates */
scalex = SCALEFACTOR_X (gdisp);
@ -679,13 +668,13 @@ gdisplay_untransform_coords (GimpDisplay *gdisp,
if (round)
{
*nx = ROUND ((x + gdisp->offset_x) / scalex - offset_x);
*ny = ROUND ((y + gdisp->offset_y) / scaley - offset_y);
*nx = ROUND ((x + shell->offset_x) / scalex - offset_x);
*ny = ROUND ((y + shell->offset_y) / scaley - offset_y);
}
else
{
*nx = (int) ((x + gdisp->offset_x) / scalex - offset_x);
*ny = (int) ((y + gdisp->offset_y) / scaley - offset_y);
*nx = (int) ((x + shell->offset_x) / scalex - offset_x);
*ny = (int) ((y + shell->offset_y) / scaley - offset_y);
}
}
@ -723,11 +712,11 @@ gdisplay_transform_coords_f (GimpDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = scalex * (x + offset_x) - gdisp->offset_x;
*ny = scaley * (y + offset_y) - gdisp->offset_y;
*nx = scalex * (x + offset_x) - shell->offset_x;
*ny = scaley * (y + offset_y) - shell->offset_y;
*nx += gdisp->disp_xoffset;
*ny += gdisp->disp_yoffset;
*nx += shell->disp_xoffset;
*ny += shell->disp_yoffset;
}
void
@ -750,8 +739,8 @@ gdisplay_untransform_coords_f (GimpDisplay *gdisp,
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
x -= gdisp->disp_xoffset;
y -= gdisp->disp_yoffset;
x -= shell->disp_xoffset;
y -= shell->disp_yoffset;
/* transform from screen coordinates to gimp coordinates */
scalex = SCALEFACTOR_X (gdisp);
@ -767,8 +756,8 @@ gdisplay_untransform_coords_f (GimpDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = (x + gdisp->offset_x) / scalex - offset_x;
*ny = (y + gdisp->offset_y) / scaley - offset_y;
*nx = (x + shell->offset_x) / scalex - offset_x;
*ny = (y + shell->offset_y) / scaley - offset_y;
}
void

View File

@ -100,15 +100,6 @@ struct _GimpDisplay
gint scale; /* scale factor from original raw image */
gboolean dot_for_dot; /* is monitor resolution being ignored? */
gint offset_x;
gint offset_y;
gint disp_width; /* width of drawing area */
gint disp_height; /* height of drawing area */
gint disp_xoffset;
gint disp_yoffset;
gboolean draw_guides; /* should the guides be drawn? */
gboolean snap_to_guides; /* should the guides be snapped to? */

View File

@ -38,7 +38,7 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplay-render.h"
#include "display/gimpdisplayshell-render.h"
#include "tools/tool_manager.h"

View File

@ -8,23 +8,23 @@ libappdisplay_a_SOURCES = @STRIP_BEGIN@ \
gimpdisplay.h \
gimpdisplay-area.c \
gimpdisplay-area.h \
gimpdisplay-callbacks.c \
gimpdisplay-callbacks.h \
gimpdisplay-foreach.c \
gimpdisplay-foreach.h \
gimpdisplay-handlers.c \
gimpdisplay-handlers.h \
gimpdisplay-marching-ants.h \
gimpdisplay-render.c \
gimpdisplay-render.h \
gimpdisplay-scale.c \
gimpdisplay-scale.h \
gimpdisplay-scroll.c \
gimpdisplay-scroll.h \
gimpdisplay-selection.c \
gimpdisplay-selection.h \
gimpdisplayshell.c \
gimpdisplayshell.h \
gimpdisplayshell-callbacks.c \
gimpdisplayshell-callbacks.h \
gimpdisplayshell-render.c \
gimpdisplayshell-render.h \
gimpdisplayshell-scale.c \
gimpdisplayshell-scale.h \
gimpdisplayshell-scroll.c \
gimpdisplayshell-scroll.h \
\
gximage.c \
gximage.h \

File diff suppressed because it is too large Load Diff

View File

@ -1,67 +0,0 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DISPLAY_CALLBACKS_H__
#define __GIMP_DISPLAY_CALLBACKS_H__
#define CANVAS_EVENT_MASK (GDK_EXPOSURE_MASK | \
GDK_POINTER_MOTION_MASK | \
GDK_POINTER_MOTION_HINT_MASK | \
GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON_RELEASE_MASK | \
GDK_STRUCTURE_MASK | \
GDK_ENTER_NOTIFY_MASK | \
GDK_LEAVE_NOTIFY_MASK | \
GDK_KEY_PRESS_MASK | \
GDK_KEY_RELEASE_MASK | \
GDK_PROXIMITY_OUT_MASK)
gboolean gdisplay_shell_events (GtkWidget *widget,
GdkEvent *event,
GimpDisplayShell *shell);
gboolean gdisplay_canvas_events (GtkWidget *widget,
GdkEvent *event,
GimpDisplayShell *shell);
gboolean gdisplay_hruler_button_press (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell);
gboolean gdisplay_vruler_button_press (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell);
gboolean gdisplay_origin_button_press (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell);
void gdisplay_drop_drawable (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
void gdisplay_drop_pattern (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
void gdisplay_drop_color (GtkWidget *widget,
const GimpRGB *color,
gpointer data);
void gdisplay_drop_buffer (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
#endif /* __GIMP_DISPLAY_CALLBACKS_H__ */

View File

@ -26,7 +26,6 @@
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplay-scale.h"
#include "gimpdisplayshell.h"
#include "nav_window.h"
@ -59,23 +58,6 @@ gdisplays_expose_guide (GimpImage *gimage,
}
}
void
gdisplays_shrink_wrap (GimpImage *gimage)
{
GimpDisplay *gdisp;
GSList *list;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
for (list = display_list; list; list = g_slist_next (list))
{
gdisp = (GimpDisplay *) list->data;
if (gdisp->gimage == gimage)
gimp_display_shell_scale_shrink_wrap (GIMP_DISPLAY_SHELL (gdisp->shell));
}
}
void
gdisplays_expose_full (void)
{

View File

@ -28,7 +28,6 @@ void gdisplays_reconnect (GimpImage *old,
GimpImage *new);
void gdisplays_expose_guide (GimpImage *gimage,
GimpGuide *guide);
void gdisplays_shrink_wrap (GimpImage *gimage);
void gdisplays_expose_full (void);
gboolean gdisplays_dirty (void);
void gdisplays_delete (void);

View File

@ -26,8 +26,10 @@
#include "gimpdisplay.h"
#include "gimpdisplay-handlers.h"
#include "gimpdisplay-scale.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-scale.h"
#include "gimprc.h"
/* local function prototypes */
@ -230,7 +232,9 @@ gimp_display_size_changed_handler (GimpImage *gimage,
gdisp->gimage->height);
gimp_display_shell_resize_cursor_label (GIMP_DISPLAY_SHELL (gdisp->shell));
gimp_display_shell_shrink_wrap (GIMP_DISPLAY_SHELL (gdisp->shell));
gimp_display_shell_scale_resize (GIMP_DISPLAY_SHELL (gdisp->shell),
gimprc.allow_resize_windows, TRUE);
}
static void

View File

@ -1,891 +0,0 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "display-types.h"
#include "base/tile-manager.h"
#include "base/tile.h"
#include "core/gimpimage.h"
#include "gimpdisplay.h"
#include "gimpdisplay-render.h"
#include "gimpdisplayshell.h"
#include "gximage.h"
#include "gimprc.h"
#define MAX_PREVIEW_SIZE 256 /* EEK */
typedef struct _RenderInfo RenderInfo;
typedef void (* RenderFunc) (RenderInfo *info);
struct _RenderInfo
{
GimpDisplay *gdisp;
TileManager *src_tiles;
guint *alpha;
guchar *scale;
guchar *src;
guchar *dest;
gint x, y;
gint w, h;
gfloat scalex;
gfloat scaley;
gint src_x, src_y;
gint src_bpp;
gint dest_bpp;
gint dest_bpl;
gint dest_width;
gint byte_order;
};
/* accelerate transparency of image scaling */
guchar *render_check_buf = NULL;
guchar *render_empty_buf = NULL;
guchar *render_temp_buf = NULL;
guchar *render_blend_dark_check = NULL;
guchar *render_blend_light_check = NULL;
static guchar *tile_buf = NULL;
static guint check_mod = 0;
static guint check_shift = 0;
static guint tile_shift = 0;
static guchar check_combos[6][2] =
{
{ 204, 255 },
{ 102, 153 },
{ 0, 51 },
{ 255, 255 },
{ 127, 127 },
{ 0, 0 }
};
void
render_setup (GimpCheckType check_type,
GimpCheckSize check_size)
{
gint i, j;
if (check_type < LIGHT_CHECKS || check_type > BLACK_ONLY)
g_error ("invalid check_type argument to render_setup: %d", check_type);
if (check_size < SMALL_CHECKS || check_size > LARGE_CHECKS)
g_error ("invalid check_size argument to render_setup: %d", check_size);
/* based on the tile size, determine the tile shift amount
* (assume here that tile_height and tile_width are equal)
*/
tile_shift = 0;
while ((1 << tile_shift) < TILE_WIDTH)
tile_shift++;
/* allocate a buffer for arranging information from a row of tiles */
if (! tile_buf)
tile_buf = g_new (guchar, GXIMAGE_WIDTH * MAX_CHANNELS);
if (! render_blend_dark_check)
render_blend_dark_check = g_new (guchar, 65536);
if (! render_blend_light_check)
render_blend_light_check = g_new (guchar, 65536);
for (i = 0; i < 256; i++)
for (j = 0; j < 256; j++)
{
render_blend_dark_check [(i << 8) + j] = (guchar)
((j * i + check_combos[check_type][0] * (255 - i)) / 255);
render_blend_light_check [(i << 8) + j] = (guchar)
((j * i + check_combos[check_type][1] * (255 - i)) / 255);
}
switch (check_size)
{
case SMALL_CHECKS:
check_mod = 0x3;
check_shift = 2;
break;
case MEDIUM_CHECKS:
check_mod = 0x7;
check_shift = 3;
break;
case LARGE_CHECKS:
check_mod = 0xf;
check_shift = 4;
break;
}
g_free (render_check_buf);
g_free (render_empty_buf);
g_free (render_temp_buf);
/* calculate check buffer for previews */
if (TRUE /* preview_size */)
{
render_check_buf = g_new (guchar, (MAX_PREVIEW_SIZE + 4) * 3);
for (i = 0; i < (MAX_PREVIEW_SIZE + 4); i++)
{
if (i & 0x4)
{
render_check_buf[i * 3 + 0] = render_blend_dark_check[0];
render_check_buf[i * 3 + 1] = render_blend_dark_check[0];
render_check_buf[i * 3 + 2] = render_blend_dark_check[0];
}
else
{
render_check_buf[i * 3 + 0] = render_blend_light_check[0];
render_check_buf[i * 3 + 1] = render_blend_light_check[0];
render_check_buf[i * 3 + 2] = render_blend_light_check[0];
}
}
render_empty_buf = g_new0 (guchar, (MAX_PREVIEW_SIZE + 4) * 3);
render_temp_buf = g_new (guchar, (MAX_PREVIEW_SIZE + 4) * 3);
}
else
{
render_check_buf = NULL;
render_empty_buf = NULL;
render_temp_buf = NULL;
}
}
void
render_free (void)
{
g_free (tile_buf);
g_free (render_check_buf);
}
/* Render Image functions */
static void render_image_rgb (RenderInfo *info);
static void render_image_rgb_a (RenderInfo *info);
static void render_image_gray (RenderInfo *info);
static void render_image_gray_a (RenderInfo *info);
static void render_image_indexed (RenderInfo *info);
static void render_image_indexed_a (RenderInfo *info);
static void render_image_init_info (RenderInfo *info,
GimpDisplay *gdisp,
gint x,
gint y,
gint w,
gint h);
static guint * render_image_init_alpha (gint mult);
static guchar * render_image_accelerate_scaling (gint width,
gint start,
gfloat scalex);
static guchar * render_image_tile_fault (RenderInfo *info);
static RenderFunc render_funcs[6] =
{
render_image_rgb,
render_image_rgb_a,
render_image_gray,
render_image_gray_a,
render_image_indexed,
render_image_indexed_a,
};
/*****************************************************************/
/* This function is the core of the display--it offsets and */
/* scales the image according to the current parameters in the */
/* gdisp object. It handles color, grayscale, 8, 15, 16, 24, */
/* & 32 bit output depths. */
/*****************************************************************/
void
render_image (GimpDisplay *gdisp,
gint x,
gint y,
gint w,
gint h)
{
RenderInfo info;
gint image_type;
render_image_init_info (&info, gdisp, x, y, w, h);
image_type = gimp_image_projection_type (gdisp->gimage);
if ((image_type < 0) || (image_type > 5))
{
g_message ("unknown gimage projection type: %d",
gimp_image_projection_type (gdisp->gimage));
return;
}
if ((info.dest_bpp < 1) || (info.dest_bpp > 4))
{
g_message ("unsupported destination bytes per pixel: %d", info.dest_bpp);
return;
}
/* Currently, only RGBA and GRAYA projection types are used - the rest
* are in case of future need. -- austin, 28th Nov 1998.
*/
if (image_type != RGBA_GIMAGE && image_type != GRAYA_GIMAGE)
g_warning ("using untested projection type %d", image_type);
(* render_funcs[image_type]) (&info);
}
/*************************/
/* 8 Bit functions */
/*************************/
static void
render_image_indexed (RenderInfo *info)
{
guchar *src;
guchar *dest;
guchar *cmap;
gulong val;
gint byte_order;
gint y, ye;
gint x, xe;
gint initial;
gfloat error;
gfloat step;
cmap = gimp_image_cmap (info->gdisp->gimage);
y = info->y;
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((gint) error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (error < 1.0))
{
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else
{
src = info->src;
dest = info->dest;
g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++)
{
val = src[INDEXED_PIX] * 3;
src += 1;
dest[0] = cmap[val+0];
dest[1] = cmap[val+1];
dest[2] = cmap[val+2];
dest += 3;
}
}
info->dest += info->dest_bpl;
initial = FALSE;
if (error >= 1.0)
{
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
error += step;
}
}
static void
render_image_indexed_a (RenderInfo *info)
{
guchar *src;
guchar *dest;
guint *alpha;
guchar *cmap;
gulong r, g, b;
gulong val;
guint a;
gint dark_light;
gint byte_order;
gint y, ye;
gint x, xe;
gint initial;
gfloat error;
gfloat step;
cmap = gimp_image_cmap (info->gdisp->gimage);
alpha = info->alpha;
y = info->y;
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((gint) error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (error < 1.0) && (y & check_mod))
{
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else
{
src = info->src;
dest = info->dest;
dark_light = (y >> check_shift) + (info->x >> check_shift);
g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++)
{
a = alpha[src[ALPHA_I_PIX]];
val = src[INDEXED_PIX] * 3;
src += 2;
if (dark_light & 0x1)
{
r = render_blend_dark_check[(a | cmap[val + 0])];
g = render_blend_dark_check[(a | cmap[val + 1])];
b = render_blend_dark_check[(a | cmap[val + 2])];
}
else
{
r = render_blend_light_check[(a | cmap[val + 0])];
g = render_blend_light_check[(a | cmap[val + 1])];
b = render_blend_light_check[(a | cmap[val + 2])];
}
dest[0] = r;
dest[1] = g;
dest[2] = b;
dest += 3;
if (((x + 1) & check_mod) == 0)
dark_light += 1;
}
}
info->dest += info->dest_bpl;
initial = FALSE;
if (error >= 1.0)
{
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
error += step;
}
}
static void
render_image_gray (RenderInfo *info)
{
guchar *src;
guchar *dest;
gulong val;
gint byte_order;
gint y, ye;
gint x, xe;
gint initial;
gfloat error;
gfloat step;
y = info->y;
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((gint) error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (error < 1.0))
{
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else
{
src = info->src;
dest = info->dest;
g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++)
{
val = src[GRAY_PIX];
src += 1;
dest[0] = val;
dest[1] = val;
dest[2] = val;
dest += 3;
}
}
info->dest += info->dest_bpl;
initial = FALSE;
if (error >= 1.0)
{
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
error += step;
}
}
static void
render_image_gray_a (RenderInfo *info)
{
guchar *src;
guchar *dest;
guint *alpha;
gulong val;
guint a;
gint dark_light;
gint byte_order;
gint y, ye;
gint x, xe;
gint initial;
gfloat error;
gfloat step;
alpha = info->alpha;
y = info->y;
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((gint) error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (error < 1.0) && (y & check_mod))
{
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else
{
src = info->src;
dest = info->dest;
dark_light = (y >> check_shift) + (info->x >> check_shift);
g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++)
{
a = alpha[src[ALPHA_G_PIX]];
if (dark_light & 0x1)
val = render_blend_dark_check[(a | src[GRAY_PIX])];
else
val = render_blend_light_check[(a | src[GRAY_PIX])];
src += 2;
dest[0] = val;
dest[1] = val;
dest[2] = val;
dest += 3;
if (((x + 1) & check_mod) == 0)
dark_light += 1;
}
}
info->dest += info->dest_bpl;
initial = FALSE;
if (error >= 1.0)
{
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
error += step;
}
}
static void
render_image_rgb (RenderInfo *info)
{
guchar *src;
guchar *dest;
gint byte_order;
gint y, ye;
gint x, xe;
gint initial;
gfloat error;
gfloat step;
y = info->y;
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= (gint) error - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (error < 1.0))
{
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else
{
src = info->src;
dest = info->dest;
g_return_if_fail (src != NULL);
/* replace this with memcpy, or better yet, avoid it altogether? */
for (x = info->x; x < xe; x++)
{
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
src += 3;
dest += 3;
}
}
info->dest += info->dest_bpl;
initial = FALSE;
if (error >= 1.0)
{
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
error += step;
}
}
static void
render_image_rgb_a (RenderInfo *info)
{
guchar *src;
guchar *dest;
guint *alpha;
gulong r, g, b;
guint a;
gint dark_light;
gint byte_order;
gint y, ye;
gint x, xe;
gint initial;
gfloat error;
gfloat step;
alpha = info->alpha;
y = info->y;
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((gint) error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (error < 1.0) && (y & check_mod))
{
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
}
else
{
src = info->src;
dest = info->dest;
dark_light = (y >> check_shift) + (info->x >> check_shift);
g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++)
{
a = alpha[src[ALPHA_PIX]];
if (dark_light & 0x1)
{
r = render_blend_dark_check[(a | src[RED_PIX])];
g = render_blend_dark_check[(a | src[GREEN_PIX])];
b = render_blend_dark_check[(a | src[BLUE_PIX])];
}
else
{
r = render_blend_light_check[(a | src[RED_PIX])];
g = render_blend_light_check[(a | src[GREEN_PIX])];
b = render_blend_light_check[(a | src[BLUE_PIX])];
}
src += 4;
dest[0] = r;
dest[1] = g;
dest[2] = b;
dest += 3;
if (((x + 1) & check_mod) == 0)
dark_light += 1;
}
}
info->dest += info->dest_bpl;
initial = FALSE;
if (error >= 1.0)
{
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
error += step;
}
}
static void
render_image_init_info (RenderInfo *info,
GimpDisplay *gdisp,
gint x,
gint y,
gint w,
gint h)
{
info->gdisp = gdisp;
info->src_tiles = gimp_image_projection (gdisp->gimage);
info->x = x + gdisp->offset_x;
info->y = y + gdisp->offset_y;
info->w = w;
info->h = h;
info->scalex = SCALEFACTOR_X (gdisp);
info->scaley = SCALEFACTOR_Y (gdisp);
info->src_x = UNSCALEX (gdisp, info->x);
info->src_y = UNSCALEY (gdisp, info->y);
info->src_bpp = gimp_image_projection_bytes (gdisp->gimage);
info->dest = gximage_get_data ();
info->dest_bpp = gximage_get_bpp ();
info->dest_bpl = gximage_get_bpl ();
info->dest_width = info->w * info->dest_bpp;
info->byte_order = gximage_get_byte_order ();
info->scale = render_image_accelerate_scaling (w, info->x, info->scalex);
info->alpha = NULL;
switch (gimp_image_projection_type (gdisp->gimage))
{
case RGBA_GIMAGE:
case GRAYA_GIMAGE:
case INDEXEDA_GIMAGE:
info->alpha =
render_image_init_alpha (gimp_image_projection_opacity (gdisp->gimage));
break;
default:
/* nothing special needs doing */
break;
}
}
static guint*
render_image_init_alpha (gint mult)
{
static guint *alpha_mult = NULL;
static gint alpha_val = -1;
gint i;
if (alpha_val != mult)
{
if (!alpha_mult)
alpha_mult = g_new (guint, 256);
alpha_val = mult;
for (i = 0; i < 256; i++)
alpha_mult[i] = ((mult * i) / 255) << 8;
}
return alpha_mult;
}
static guchar*
render_image_accelerate_scaling (gint width,
gint start,
gfloat scalex)
{
static guchar *scale = NULL;
gfloat error;
gfloat step;
gint i;
if (!scale)
scale = g_new (guchar, GXIMAGE_WIDTH + 1);
step = 1.0 / scalex;
error = start * step;
error -= ((int)error) - step;
for (i = 0; i <= width; i++)
{
scale[i] = ((int)error);
error += step - (int)error;
}
return scale;
}
static guchar *
render_image_tile_fault (RenderInfo *info)
{
Tile *tile;
guchar *data;
guchar *dest;
guchar *scale;
gint width;
gint tilex;
gint tiley;
gint srctilex, srctiley;
gint step;
gint bpp = info->src_bpp;
gint x, b;
tilex = info->src_x / TILE_WIDTH;
tiley = info->src_y / TILE_HEIGHT;
tile = tile_manager_get_tile (info->src_tiles,
srctilex=info->src_x, srctiley=info->src_y,
TRUE, FALSE);
if (!tile)
return NULL;
data = tile_data_pointer (tile,
info->src_x % TILE_WIDTH,
info->src_y % TILE_HEIGHT);
scale = info->scale;
dest = tile_buf;
x = info->src_x;
width = info->w;
while (width--)
{
for (b = 0; b < bpp; b++)
*dest++ = data[b];
step = *scale++;
if (step != 0)
{
x += step;
data += step * bpp;
if ((x >> tile_shift) != tilex)
{
tile_release (tile, FALSE);
tilex += 1;
tile = tile_manager_get_tile (info->src_tiles, srctilex=x,
srctiley=info->src_y, TRUE, FALSE);
if (!tile)
return tile_buf;
data = tile_data_pointer (tile,
x % TILE_WIDTH,
info->src_y % TILE_HEIGHT);
}
}
}
tile_release (tile, FALSE);
return tile_buf;
}

View File

@ -1,43 +0,0 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DISPLAY_RENDER_H__
#define __GIMP_DISPLAY_RENDER_H__
/* Functions */
void render_setup (GimpCheckType check_type,
GimpCheckSize check_size);
void render_free (void);
void render_image (GimpDisplay *gdisp,
gint x,
gint y,
gint w,
gint h);
/*
* Extern variables
*/
extern guchar *render_check_buf;
extern guchar *render_empty_buf;
extern guchar *render_temp_buf;
extern guchar *render_blend_dark_check;
extern guchar *render_blend_light_check;
#endif /* __GIMP_DISPLAY_RENDER_H__ */

View File

@ -1,327 +0,0 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "display-types.h"
#include "core/gimpimage.h"
#include "tools/gimptool.h"
#include "tools/tool_manager.h"
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplay-scale.h"
#include "gimpdisplay-scroll.h"
#include "gimpdisplayshell.h"
#include "gimprc.h"
#include "nav_window.h"
/* local function prototypes */
static gdouble img2real (GimpDisplay *gdisp,
gboolean xdir,
gdouble a);
/* public functions */
void
gimp_display_shell_scale_setup (GimpDisplayShell *shell)
{
GtkRuler *hruler;
GtkRuler *vruler;
gfloat sx, sy;
gfloat stepx, stepy;
gint image_width, image_height;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
image_width = shell->gdisp->gimage->width;
image_height = shell->gdisp->gimage->height;
sx = SCALEX (shell->gdisp, image_width);
sy = SCALEY (shell->gdisp, image_height);
stepx = SCALEFACTOR_X (shell->gdisp);
stepy = SCALEFACTOR_Y (shell->gdisp);
shell->hsbdata->value = shell->gdisp->offset_x;
shell->hsbdata->upper = sx;
shell->hsbdata->page_size = MIN (sx, shell->gdisp->disp_width);
shell->hsbdata->page_increment = shell->gdisp->disp_width / 2;
shell->hsbdata->step_increment = stepx;
shell->vsbdata->value = shell->gdisp->offset_y;
shell->vsbdata->upper = sy;
shell->vsbdata->page_size = MIN (sy, shell->gdisp->disp_height);
shell->vsbdata->page_increment = shell->gdisp->disp_height / 2;
shell->vsbdata->step_increment = stepy;
gtk_adjustment_changed (shell->hsbdata);
gtk_adjustment_changed (shell->vsbdata);
hruler = GTK_RULER (shell->hrule);
vruler = GTK_RULER (shell->vrule);
hruler->lower = 0;
hruler->upper = img2real (shell->gdisp, TRUE,
FUNSCALEX (shell->gdisp, shell->gdisp->disp_width));
hruler->max_size = img2real (shell->gdisp, TRUE,
MAX (image_width, image_height));
vruler->lower = 0;
vruler->upper = img2real (shell->gdisp, FALSE,
FUNSCALEY (shell->gdisp, shell->gdisp->disp_height));
vruler->max_size = img2real (shell->gdisp, FALSE,
MAX (image_width, image_height));
if (sx < shell->gdisp->disp_width)
{
shell->gdisp->disp_xoffset = (shell->gdisp->disp_width - sx) / 2;
hruler->lower -= img2real (shell->gdisp, TRUE,
FUNSCALEX (shell->gdisp,
(gdouble) shell->gdisp->disp_xoffset));
hruler->upper -= img2real (shell->gdisp, TRUE,
FUNSCALEX (shell->gdisp,
(gdouble) shell->gdisp->disp_xoffset));
}
else
{
shell->gdisp->disp_xoffset = 0;
hruler->lower += img2real (shell->gdisp, TRUE,
FUNSCALEX (shell->gdisp,
(gdouble) shell->gdisp->offset_x));
hruler->upper += img2real (shell->gdisp, TRUE,
FUNSCALEX (shell->gdisp,
(gdouble) shell->gdisp->offset_x));
}
if (sy < shell->gdisp->disp_height)
{
shell->gdisp->disp_yoffset = (shell->gdisp->disp_height - sy) / 2;
vruler->lower -= img2real (shell->gdisp, FALSE,
FUNSCALEY (shell->gdisp,
(gdouble) shell->gdisp->disp_yoffset));
vruler->upper -= img2real (shell->gdisp, FALSE,
FUNSCALEY (shell->gdisp,
(gdouble) shell->gdisp->disp_yoffset));
}
else
{
shell->gdisp->disp_yoffset = 0;
vruler->lower += img2real (shell->gdisp, FALSE,
FUNSCALEY (shell->gdisp,
(gdouble) shell->gdisp->offset_y));
vruler->upper += img2real (shell->gdisp, FALSE,
FUNSCALEY (shell->gdisp,
(gdouble) shell->gdisp->offset_y));
}
gtk_widget_queue_draw (GTK_WIDGET (hruler));
gtk_widget_queue_draw (GTK_WIDGET (vruler));
nav_dialog_update_window_marker (shell->nav_dialog);
if (shell->nav_popup)
nav_dialog_update_window_marker (shell->nav_popup);
#if 0
g_print ("offset_x: %d\n"
"offset_y: %d\n"
"disp_width: %d\n"
"disp_height: %d\n"
"disp_xoffset: %d\n"
"disp_yoffset: %d\n\n",
shell->gdisp->offset_x, shell->gdisp->offset_y,
shell->gdisp->disp_width, shell->gdisp->disp_height,
shell->gdisp->disp_xoffset, shell->gdisp->disp_yoffset);
#endif
}
void
gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell,
gboolean dot_for_dot)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (dot_for_dot != shell->gdisp->dot_for_dot)
{
shell->gdisp->dot_for_dot = dot_for_dot;
gimp_display_shell_resize_cursor_label (shell);
gimp_display_shell_scale_resize (shell,
gimprc.allow_resize_windows, TRUE);
}
}
void
gimp_display_shell_scale (GimpDisplayShell *shell,
GimpZoomType zoom_type)
{
guchar scalesrc, scaledest;
gdouble offset_x, offset_y;
glong sx, sy;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
/* user zoom control, so resolution versions not needed -- austin */
scalesrc = SCALESRC (shell->gdisp);
scaledest = SCALEDEST (shell->gdisp);
offset_x = shell->gdisp->offset_x + (shell->gdisp->disp_width / 2.0);
offset_y = shell->gdisp->offset_y + (shell->gdisp->disp_height / 2.0);
offset_x *= ((double) scalesrc / (double) scaledest);
offset_y *= ((double) scalesrc / (double) scaledest);
switch (zoom_type)
{
case GIMP_ZOOM_IN:
if (scalesrc > 1)
scalesrc--;
else
if (scaledest < 0x10)
scaledest++;
else
return;
break;
case GIMP_ZOOM_OUT:
if (scaledest > 1)
scaledest--;
else
if (scalesrc < 0x10)
scalesrc++;
else
return;
break;
default:
scalesrc = zoom_type % 100;
if (scalesrc < 1)
scalesrc = 1;
else if (scalesrc > 0x10)
scalesrc = 0x10;
scaledest = zoom_type / 100;
if (scaledest < 1)
scaledest = 1;
else if (scaledest > 0x10)
scaledest = 0x10;
break;
}
sx = (shell->gdisp->gimage->width * scaledest) / scalesrc;
sy = (shell->gdisp->gimage->height * scaledest) / scalesrc;
/* The slider value is a short, so make sure we are within its
* range. If we are trying to scale past it, then stop the scale
*/
if (sx < 0xffff && sy < 0xffff)
{
shell->gdisp->scale = (scaledest << 8) + scalesrc;
/* set the offsets */
offset_x *= ((gdouble) scaledest / (gdouble) scalesrc);
offset_y *= ((gdouble) scaledest / (gdouble) scalesrc);
shell->gdisp->offset_x = (gint) (offset_x - (shell->gdisp->disp_width / 2));
shell->gdisp->offset_y = (gint) (offset_y - (shell->gdisp->disp_height / 2));
/* resize the display */
gimp_display_shell_scale_resize (shell, gimprc.allow_resize_windows, TRUE);
}
}
void
gimp_display_shell_scale_resize (GimpDisplayShell *shell,
gboolean resize_window,
gboolean redisplay)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
/* freeze the active tool */
tool_manager_control_active (shell->gdisp->gimage->gimp, PAUSE,
shell->gdisp);
if (resize_window)
gimp_display_shell_shrink_wrap (shell);
gimp_display_shell_scroll_clamp_offsets (shell);
gimp_display_shell_scale_setup (shell);
if (resize_window || redisplay)
{
gimp_display_shell_expose_full (shell);
gdisplays_flush ();
/* title may have changed if it includes the zoom ratio */
gimp_display_shell_update_title (shell);
}
/* re-enable the active tool */
tool_manager_control_active (shell->gdisp->gimage->gimp, RESUME,
shell->gdisp);
}
void
gimp_display_shell_scale_shrink_wrap (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
gimp_display_shell_scale_resize (shell, TRUE, TRUE);
}
/* private functions */
/* scale image coord to realworld units (cm, inches, pixels)
*
* 27/Feb/1999 I tried inlining this, but the result was slightly
* slower (poorer cache locality, probably) -- austin
*/
static gdouble
img2real (GimpDisplay *gdisp,
gboolean xdir,
gdouble a)
{
gdouble res;
if (gdisp->dot_for_dot)
return a;
if (xdir)
res = gdisp->gimage->xresolution;
else
res = gdisp->gimage->yresolution;
return a * gimp_unit_get_factor (gdisp->gimage->unit) / res;
}

View File

@ -1,36 +0,0 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DISPLAY_SHELL_SCALE_H__
#define __GIMP_DISPLAY_SHELL_SCALE_H__
void gimp_display_shell_scale_setup (GimpDisplayShell *shell);
void gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *gdisp,
gboolean dot_for_dot);
void gimp_display_shell_scale (GimpDisplayShell *gdisp,
GimpZoomType zoom_type);
void gimp_display_shell_scale_resize (GimpDisplayShell *shell,
gboolean resize_window,
gboolean redisplay);
void gimp_display_shell_scale_shrink_wrap (GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_SCALE_H__ */

View File

@ -1,170 +0,0 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <gtk/gtk.h>
#include "display-types.h"
#include "core/gimpimage.h"
#include "tools/gimptool.h"
#include "tools/tool_manager.h"
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplay-scale.h"
#include "gimpdisplay-scroll.h"
#include "gimpdisplayshell.h"
#include "gimprc.h"
#include "nav_window.h"
gboolean
gimp_display_shell_scroll (GimpDisplayShell *shell,
gint x_offset,
gint y_offset)
{
gint old_x, old_y;
gint src_x, src_y;
gint dest_x, dest_y;
GdkEvent *event;
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
old_x = shell->gdisp->offset_x;
old_y = shell->gdisp->offset_y;
shell->gdisp->offset_x += x_offset;
shell->gdisp->offset_y += y_offset;
gimp_display_shell_scroll_clamp_offsets (shell);
/* the actual changes in offset */
x_offset = (shell->gdisp->offset_x - old_x);
y_offset = (shell->gdisp->offset_y - old_y);
if (x_offset || y_offset)
{
/* FIXME: I'm sure this is useless if all other places are correct --mitch
*/
gimp_display_shell_scale_setup (shell);
src_x = (x_offset < 0) ? 0 : x_offset;
src_y = (y_offset < 0) ? 0 : y_offset;
dest_x = (x_offset < 0) ? -x_offset : 0;
dest_y = (y_offset < 0) ? -y_offset : 0;
/* reset the old values so that the tool can accurately redraw */
shell->gdisp->offset_x = old_x;
shell->gdisp->offset_y = old_y;
/* freeze the active tool */
tool_manager_control_active (shell->gdisp->gimage->gimp, PAUSE,
shell->gdisp);
/* set the offsets back to the new values */
shell->gdisp->offset_x += x_offset;
shell->gdisp->offset_y += y_offset;
gdk_draw_drawable (shell->canvas->window,
shell->scroll_gc,
shell->canvas->window,
src_x, src_y,
dest_x, dest_y,
(shell->gdisp->disp_width - abs (x_offset)),
(shell->gdisp->disp_height - abs (y_offset)));
/* re-enable the active tool */
tool_manager_control_active (shell->gdisp->gimage->gimp, RESUME,
shell->gdisp);
/* scale the image into the exposed regions */
if (x_offset)
{
src_x = (x_offset < 0) ? 0 : shell->gdisp->disp_width - x_offset;
src_y = 0;
gimp_display_shell_add_expose_area (shell,
src_x, src_y,
abs (x_offset),
shell->gdisp->disp_height);
}
if (y_offset)
{
src_x = 0;
src_y = (y_offset < 0) ? 0 : shell->gdisp->disp_height - y_offset;
gimp_display_shell_add_expose_area (shell,
src_x, src_y,
shell->gdisp->disp_width,
abs (y_offset));
}
if (x_offset || y_offset)
gdisplay_flush (shell->gdisp);
nav_dialog_update_window_marker (shell->nav_dialog);
if (shell->nav_popup)
nav_dialog_update_window_marker (shell->nav_popup);
/* Make sure graphics expose events are processed before scrolling
* again
*/
while ((event = gdk_event_get_graphics_expose (shell->canvas->window)))
{
gtk_widget_event (shell->canvas, event);
if (event->expose.count == 0)
{
gdk_event_free (event);
break;
}
gdk_event_free (event);
}
return TRUE;
}
return FALSE;
}
void
gimp_display_shell_scroll_clamp_offsets (GimpDisplayShell *shell)
{
gint sx, sy;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
sx = SCALEX (shell->gdisp, shell->gdisp->gimage->width);
sy = SCALEY (shell->gdisp, shell->gdisp->gimage->height);
shell->gdisp->offset_x = CLAMP (shell->gdisp->offset_x, 0,
MAX (sx - shell->gdisp->disp_width, 0));
shell->gdisp->offset_y = CLAMP (shell->gdisp->offset_y, 0,
MAX (sy - shell->gdisp->disp_height, 0));
}

View File

@ -1,30 +0,0 @@
/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DISPLAY_SHELL_SCROLL_H__
#define __GIMP_DISPLAY_SHELL_SCROLL_H__
gboolean gimp_display_shell_scroll (GimpDisplayShell *shell,
gint x_offset,
gint y_offset);
void gimp_display_shell_scroll_clamp_offsets (GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_SCROLL_H__ */

View File

@ -122,15 +122,6 @@ gimp_display_init (GimpDisplay *gdisp)
gdisp->scale = 0;
gdisp->dot_for_dot = gimprc.default_dot_for_dot;
gdisp->offset_x = 0;
gdisp->offset_y = 0;
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;
@ -281,10 +272,8 @@ gdisplay_reconnect (GimpDisplay *gdisp,
gdisp->gimage->width,
gdisp->gimage->height);
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));
}
static gint
@ -584,7 +573,7 @@ gimp_display_paint_area (GimpDisplay *gdisp,
&x1, &y1,
FALSE, FALSE);
gdisplay_untransform_coords (gdisp,
gdisp->disp_width, gdisp->disp_height,
shell->disp_width, shell->disp_height,
&x2, &y2,
FALSE, FALSE);
@ -632,11 +621,11 @@ gdisplay_transform_coords (GimpDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = (gint) (scalex * (x + offset_x) - gdisp->offset_x);
*ny = (gint) (scaley * (y + offset_y) - gdisp->offset_y);
*nx = (gint) (scalex * (x + offset_x) - shell->offset_x);
*ny = (gint) (scaley * (y + offset_y) - shell->offset_y);
*nx += gdisp->disp_xoffset;
*ny += gdisp->disp_yoffset;
*nx += shell->disp_xoffset;
*ny += shell->disp_yoffset;
}
void
@ -660,8 +649,8 @@ gdisplay_untransform_coords (GimpDisplay *gdisp,
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
x -= gdisp->disp_xoffset;
y -= gdisp->disp_yoffset;
x -= shell->disp_xoffset;
y -= shell->disp_yoffset;
/* transform from screen coordinates to image coordinates */
scalex = SCALEFACTOR_X (gdisp);
@ -679,13 +668,13 @@ gdisplay_untransform_coords (GimpDisplay *gdisp,
if (round)
{
*nx = ROUND ((x + gdisp->offset_x) / scalex - offset_x);
*ny = ROUND ((y + gdisp->offset_y) / scaley - offset_y);
*nx = ROUND ((x + shell->offset_x) / scalex - offset_x);
*ny = ROUND ((y + shell->offset_y) / scaley - offset_y);
}
else
{
*nx = (int) ((x + gdisp->offset_x) / scalex - offset_x);
*ny = (int) ((y + gdisp->offset_y) / scaley - offset_y);
*nx = (int) ((x + shell->offset_x) / scalex - offset_x);
*ny = (int) ((y + shell->offset_y) / scaley - offset_y);
}
}
@ -723,11 +712,11 @@ gdisplay_transform_coords_f (GimpDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = scalex * (x + offset_x) - gdisp->offset_x;
*ny = scaley * (y + offset_y) - gdisp->offset_y;
*nx = scalex * (x + offset_x) - shell->offset_x;
*ny = scaley * (y + offset_y) - shell->offset_y;
*nx += gdisp->disp_xoffset;
*ny += gdisp->disp_yoffset;
*nx += shell->disp_xoffset;
*ny += shell->disp_yoffset;
}
void
@ -750,8 +739,8 @@ gdisplay_untransform_coords_f (GimpDisplay *gdisp,
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
x -= gdisp->disp_xoffset;
y -= gdisp->disp_yoffset;
x -= shell->disp_xoffset;
y -= shell->disp_yoffset;
/* transform from screen coordinates to gimp coordinates */
scalex = SCALEFACTOR_X (gdisp);
@ -767,8 +756,8 @@ gdisplay_untransform_coords_f (GimpDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = (x + gdisp->offset_x) / scalex - offset_x;
*ny = (y + gdisp->offset_y) / scaley - offset_y;
*nx = (x + shell->offset_x) / scalex - offset_x;
*ny = (y + shell->offset_y) / scaley - offset_y;
}
void

View File

@ -100,15 +100,6 @@ struct _GimpDisplay
gint scale; /* scale factor from original raw image */
gboolean dot_for_dot; /* is monitor resolution being ignored? */
gint offset_x;
gint offset_y;
gint disp_width; /* width of drawing area */
gint disp_height; /* height of drawing area */
gint disp_xoffset;
gint disp_yoffset;
gboolean draw_guides; /* should the guides be drawn? */
gboolean snap_to_guides; /* should the guides be snapped to? */

View File

@ -57,12 +57,12 @@
#include "gui/layer-select.h"
#include "gimpdisplay.h"
#include "gimpdisplay-callbacks.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplay-selection.h"
#include "gimpdisplay-scale.h"
#include "gimpdisplay-scroll.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
#include "devices.h"
#include "gimprc.h"
@ -72,7 +72,7 @@
static void
gdisplay_redraw (GimpDisplayShell *shell,
gimp_display_shell_redraw (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
@ -85,10 +85,10 @@ gdisplay_redraw (GimpDisplayShell *shell,
x2 = (x + w);
y2 = (y + h);
x1 = CLAMP (x1, 0, shell->gdisp->disp_width);
y1 = CLAMP (y1, 0, shell->gdisp->disp_height);
x2 = CLAMP (x2, 0, shell->gdisp->disp_width);
y2 = CLAMP (y2, 0, shell->gdisp->disp_height);
x1 = CLAMP (x1, 0, shell->disp_width);
y1 = CLAMP (y1, 0, shell->disp_height);
x2 = CLAMP (x2, 0, shell->disp_width);
y2 = CLAMP (y2, 0, shell->disp_height);
if ((x2 - x1) && (y2 - y1))
{
@ -100,7 +100,7 @@ gdisplay_redraw (GimpDisplayShell *shell,
}
static void
gdisplay_check_device_cursor (GimpDisplayShell *shell)
gimp_display_shell_check_device_cursor (GimpDisplayShell *shell)
{
GList *list;
@ -119,7 +119,7 @@ gdisplay_check_device_cursor (GimpDisplayShell *shell)
}
}
static int
static gint
key_to_state (gint key)
{
switch (key)
@ -139,21 +139,21 @@ key_to_state (gint key)
}
static void
gdisplay_vscrollbar_update (GtkAdjustment *adjustment,
gimp_display_shell_vscrollbar_update (GtkAdjustment *adjustment,
GimpDisplayShell *shell)
{
gimp_display_shell_scroll (shell, 0, (adjustment->value - shell->gdisp->offset_y));
gimp_display_shell_scroll (shell, 0, (adjustment->value - shell->offset_y));
}
static void
gdisplay_hscrollbar_update (GtkAdjustment *adjustment,
gimp_display_shell_hscrollbar_update (GtkAdjustment *adjustment,
GimpDisplayShell *shell)
{
gimp_display_shell_scroll (shell, (adjustment->value - shell->gdisp->offset_x), 0);
gimp_display_shell_scroll (shell, (adjustment->value - shell->offset_x), 0);
}
gboolean
gdisplay_shell_events (GtkWidget *widget,
gimp_display_shell_events (GtkWidget *widget,
GdkEvent *event,
GimpDisplayShell *shell)
{
@ -173,8 +173,42 @@ gdisplay_shell_events (GtkWidget *widget,
return FALSE;
}
void
gimp_display_shell_canvas_realize (GtkWidget *canvas,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
gdisp = shell->gdisp;
/* create the selection object */
gdisp->select = selection_create (canvas->window,
gdisp,
gdisp->gimage->height,
gdisp->gimage->width,
gimprc.marching_speed);
shell->disp_width = canvas->allocation.width;
shell->disp_height = canvas->allocation.height;
/* create GC for scrolling */
shell->scroll_gc = gdk_gc_new (shell->canvas->window);
gdk_gc_set_exposures (shell->scroll_gc, TRUE);
/* set up the scrollbar observers */
g_signal_connect (G_OBJECT (shell->hsbdata), "value_changed",
G_CALLBACK (gimp_display_shell_hscrollbar_update),
shell);
g_signal_connect (G_OBJECT (shell->vsbdata), "value_changed",
G_CALLBACK (gimp_display_shell_vscrollbar_update),
shell);
/* setup scale properly */
gimp_display_shell_scale_setup (shell);
}
gboolean
gdisplay_canvas_events (GtkWidget *canvas,
gimp_display_shell_canvas_events (GtkWidget *canvas,
GdkEvent *event,
GimpDisplayShell *shell)
{
@ -188,69 +222,50 @@ gdisplay_canvas_events (GtkWidget *canvas,
gdouble tx = 0;
gdouble ty = 0;
guint state = 0;
gint return_val = FALSE;
gboolean return_val = FALSE;
gboolean update_cursor = FALSE;
static gboolean scrolling = FALSE;
static gint scroll_start_x = 0;
static gint scroll_start_y = 0;
static guint key_signal_id = 0;
gboolean update_cursor = FALSE;
if (! canvas->window)
{
g_warning ("imp_display_shell_canvas_events(): called unrealized");
return FALSE;
}
gdisp = shell->gdisp;
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
/* If this is the first event... */
/* FIXME */
if (! gdisp->select)
{
/* create the selection object */
gdisp->select = selection_create (shell->canvas->window,
gdisp,
gdisp->gimage->height,
gdisp->gimage->width,
gimprc.marching_speed);
gdisp->disp_width = shell->canvas->allocation.width;
gdisp->disp_height = shell->canvas->allocation.height;
/* create GC for scrolling */
shell->scroll_gc = gdk_gc_new (shell->canvas->window);
gdk_gc_set_exposures (shell->scroll_gc, TRUE);
/* set up the scrollbar observers */
g_signal_connect (G_OBJECT (shell->hsbdata), "value_changed",
G_CALLBACK (gdisplay_hscrollbar_update),
shell);
g_signal_connect (G_OBJECT (shell->vsbdata), "value_changed",
G_CALLBACK (gdisplay_vscrollbar_update),
shell);
/* setup scale properly */
gimp_display_shell_scale_setup (shell);
gimp_display_shell_canvas_realize (shell->canvas, shell);
}
/* Find out what device the event occurred upon */
if (! gdisp->gimage->gimp->busy && devices_check_change (event))
gdisplay_check_device_cursor (shell);
gimp_display_shell_check_device_cursor (shell);
switch (event->type)
{
case GDK_EXPOSE:
eevent = (GdkEventExpose *) event;
gdisplay_redraw (shell,
gimp_display_shell_redraw (shell,
eevent->area.x, eevent->area.y,
eevent->area.width, eevent->area.height);
break;
case GDK_CONFIGURE:
if ((gdisp->disp_width != shell->canvas->allocation.width) ||
(gdisp->disp_height != shell->canvas->allocation.height))
if ((shell->disp_width != shell->canvas->allocation.width) ||
(shell->disp_height != shell->canvas->allocation.height))
{
gdisp->disp_width = shell->canvas->allocation.width;
gdisp->disp_height = shell->canvas->allocation.height;
shell->disp_width = shell->canvas->allocation.width;
shell->disp_height = shell->canvas->allocation.height;
gimp_display_shell_scale_resize (shell, FALSE, FALSE);
}
@ -285,6 +300,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
{
case 1:
state |= GDK_BUTTON1_MASK;
gtk_grab_add (canvas);
/* This is a hack to prevent other stuff being run in the middle of
@ -317,6 +333,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
}
/* reset the current tool if ... */
if ((/* it has no drawable */
! active_tool->drawable ||
@ -351,15 +368,15 @@ gdisplay_canvas_events (GtkWidget *canvas,
state |= GDK_BUTTON2_MASK;
scrolling = TRUE;
scroll_start_x = bevent->x + gdisp->offset_x;
scroll_start_y = bevent->y + gdisp->offset_y;
scroll_start_x = bevent->x + shell->offset_x;
scroll_start_y = bevent->y + shell->offset_y;
gtk_grab_add (canvas);
cursor = gimp_cursor_new (GDK_FLEUR,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
gdk_window_set_cursor (shell->canvas->window, cursor);
gdk_window_set_cursor (canvas->window, cursor);
gdk_cursor_unref (cursor);
}
break;
@ -494,47 +511,47 @@ gdisplay_canvas_events (GtkWidget *canvas,
/* Ask for the pointer position, but ignore it except for cursor
* handling, so motion events sync with the button press/release events
*/
if (mevent->is_hint)
{
#ifdef __GNUC__
#warning FIXME: replace gdk_input_window_get_pointer()
#endif
#if 0
if (mevent->is_hint)
{
gdk_input_window_get_pointer (canvas->window, current_device, &tx, &ty,
NULL, NULL, NULL, NULL);
#endif
}
else
{
#endif
tx = mevent->x;
ty = mevent->y;
#if 0
}
#endif
update_cursor = TRUE;
if (! shell->proximity)
{
shell->proximity = TRUE;
gdisplay_check_device_cursor (shell);
gimp_display_shell_check_device_cursor (shell);
}
if (active_tool && (GIMP_IS_MOVE_TOOL(active_tool) ||
! gimp_image_is_empty (gdisp->gimage)) &&
(mevent->state & GDK_BUTTON1_MASK))
if ((mevent->state & GDK_BUTTON1_MASK) &&
active_tool && (GIMP_IS_MOVE_TOOL (active_tool) ||
! gimp_image_is_empty (gdisp->gimage)))
{
if (active_tool->state == ACTIVE)
{
/* if the first mouse button is down, check for automatic
* scrolling...
*/
if ((mevent->state & GDK_BUTTON1_MASK) &&
if ((mevent->x < 0 ||
mevent->y < 0 ||
mevent->x > shell->disp_width ||
mevent->y > shell->disp_height) &&
! active_tool->scroll_lock)
{
if (mevent->x < 0 ||
mevent->y < 0 ||
mevent->x > gdisp->disp_width ||
mevent->y > gdisp->disp_height)
{
gdouble child_x, child_y;
gint off_x, off_y;
off_x = off_y = 0;
@ -542,13 +559,13 @@ gdisplay_canvas_events (GtkWidget *canvas,
/* The cases for scrolling */
if (mevent->x < 0)
off_x = mevent->x;
else if (mevent->x > gdisp->disp_width)
off_x = mevent->x - gdisp->disp_width;
else if (mevent->x > shell->disp_width)
off_x = mevent->x - shell->disp_width;
if (mevent->y < 0)
off_y = mevent->y;
else if (mevent->y > gdisp->disp_height)
off_y = mevent->y - gdisp->disp_height;
else if (mevent->y > shell->disp_height)
off_y = mevent->y - shell->disp_height;
if (gimp_display_shell_scroll (shell, off_x, off_y))
{
@ -556,6 +573,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
#warning FIXME: replace gdk_input_window_get_pointer()
#endif
#if 0
gdouble child_x, child_y;
gdk_input_window_get_pointer (shell->canvas->window, mevent->deviceid,
&child_x, &child_y,
NULL, NULL, NULL, NULL);
@ -566,7 +585,6 @@ gdisplay_canvas_events (GtkWidget *canvas,
#endif
}
}
}
if (active_tool->auto_snap_to)
{
@ -585,9 +603,9 @@ gdisplay_canvas_events (GtkWidget *canvas,
{
gimp_display_shell_scroll (shell,
(scroll_start_x - mevent->x -
gdisp->offset_x),
shell->offset_x),
(scroll_start_y - mevent->y -
gdisp->offset_y));
shell->offset_y));
}
if (/* Should we have a tool... */
@ -697,11 +715,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
if (gdisp->gimage->gimp->busy)
return TRUE;
/* Cursor update support
* no_cursor_updating is TRUE (=1) when
* <Toolbox>/File/Preferences.../Interface/...
* Image Windows/Disable Cursor Updating is TOGGLED ON
*/
/* cursor update support */
if (! gimprc.no_cursor_updating)
{
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
@ -710,8 +725,11 @@ gdisplay_canvas_events (GtkWidget *canvas,
! (state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)))
{
GdkEventMotion me;
me.x = tx; me.y = ty;
me.x = tx;
me.y = ty;
me.state = state;
gimp_tool_cursor_update (active_tool, &me, gdisp);
}
else if (gimp_image_is_empty (gdisp->gimage))
@ -730,7 +748,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
}
gboolean
gdisplay_hruler_button_press (GtkWidget *widget,
gimp_display_shell_hruler_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
{
@ -768,7 +786,7 @@ gdisplay_hruler_button_press (GtkWidget *widget,
}
gboolean
gdisplay_vruler_button_press (GtkWidget *widget,
gimp_display_shell_vruler_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
{
@ -806,7 +824,7 @@ gdisplay_vruler_button_press (GtkWidget *widget,
}
static void
gdisplay_origin_menu_position (GtkMenu *menu,
gimp_display_shell_origin_menu_position (GtkMenu *menu,
gint *x,
gint *y,
gpointer data)
@ -830,7 +848,7 @@ gdisplay_origin_menu_position (GtkMenu *menu,
}
gboolean
gdisplay_origin_button_press (GtkWidget *widget,
gimp_display_shell_origin_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
{
@ -842,7 +860,7 @@ gdisplay_origin_button_press (GtkWidget *widget,
{
gint x, y;
gdisplay_origin_menu_position (GTK_MENU (shell->ifactory->widget),
gimp_display_shell_origin_menu_position (GTK_MENU (shell->ifactory->widget),
&x, &y, widget);
gtk_item_factory_popup_with_data (shell->ifactory,
@ -858,7 +876,7 @@ gdisplay_origin_button_press (GtkWidget *widget,
}
void
gdisplay_drop_drawable (GtkWidget *widget,
gimp_display_shell_drop_drawable (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
@ -966,7 +984,7 @@ gdisplay_drop_drawable (GtkWidget *widget,
}
static void
gdisplay_bucket_fill (GimpDisplay *gdisp,
gimp_display_shell_bucket_fill (GimpDisplay *gdisp,
BucketFillMode fill_mode,
guchar orig_color[],
TempBuf *orig_pat_buf)
@ -1081,7 +1099,7 @@ gdisplay_bucket_fill (GimpDisplay *gdisp,
}
void
gdisplay_drop_pattern (GtkWidget *widget,
gimp_display_shell_drop_pattern (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
@ -1091,7 +1109,7 @@ gdisplay_drop_pattern (GtkWidget *widget,
if (GIMP_IS_PATTERN (viewable))
{
gdisplay_bucket_fill (gdisp,
gimp_display_shell_bucket_fill (gdisp,
PATTERN_BUCKET_FILL,
NULL,
GIMP_PATTERN (viewable)->mask);
@ -1099,7 +1117,7 @@ gdisplay_drop_pattern (GtkWidget *widget,
}
void
gdisplay_drop_color (GtkWidget *widget,
gimp_display_shell_drop_color (GtkWidget *widget,
const GimpRGB *drop_color,
gpointer data)
{
@ -1114,14 +1132,14 @@ gdisplay_drop_color (GtkWidget *widget,
&color[2],
&color[3]);
gdisplay_bucket_fill (gdisp,
gimp_display_shell_bucket_fill (gdisp,
FG_BUCKET_FILL,
color,
NULL);
}
void
gdisplay_drop_buffer (GtkWidget *widget,
gimp_display_shell_drop_buffer (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{

View File

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DISPLAY_CALLBACKS_H__
#define __GIMP_DISPLAY_CALLBACKS_H__
#ifndef __GIMP_DISPLAY_SHELL_CALLBACKS_H__
#define __GIMP_DISPLAY_SHELL_CALLBACKS_H__
#define CANVAS_EVENT_MASK (GDK_EXPOSURE_MASK | \
#define GIMP_DISPLAY_SHELL_CANVAS_EVENT_MASK (GDK_EXPOSURE_MASK | \
GDK_POINTER_MOTION_MASK | \
GDK_POINTER_MOTION_HINT_MASK | \
GDK_BUTTON_PRESS_MASK | \
@ -33,35 +33,38 @@
GDK_PROXIMITY_OUT_MASK)
gboolean gdisplay_shell_events (GtkWidget *widget,
GdkEvent *event,
GimpDisplayShell *shell);
gboolean gdisplay_canvas_events (GtkWidget *widget,
gboolean gimp_display_shell_events (GtkWidget *widget,
GdkEvent *event,
GimpDisplayShell *shell);
gboolean gdisplay_hruler_button_press (GtkWidget *widget,
void gimp_display_shell_canvas_realize (GtkWidget *widget,
GimpDisplayShell *shell);
gboolean gimp_display_shell_canvas_events (GtkWidget *widget,
GdkEvent *event,
GimpDisplayShell *shell);
gboolean gimp_display_shell_hruler_button_press (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell);
gboolean gdisplay_vruler_button_press (GtkWidget *widget,
gboolean gimp_display_shell_vruler_button_press (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell);
gboolean gdisplay_origin_button_press (GtkWidget *widget,
gboolean gimp_display_shell_origin_button_press (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell);
void gdisplay_drop_drawable (GtkWidget *widget,
void gimp_display_shell_drop_drawable (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
void gdisplay_drop_pattern (GtkWidget *widget,
void gimp_display_shell_drop_pattern (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
void gdisplay_drop_color (GtkWidget *widget,
void gimp_display_shell_drop_color (GtkWidget *widget,
const GimpRGB *color,
gpointer data);
void gdisplay_drop_buffer (GtkWidget *widget,
void gimp_display_shell_drop_buffer (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
#endif /* __GIMP_DISPLAY_CALLBACKS_H__ */
#endif /* __GIMP_DISPLAY_SHELL_CALLBACKS_H__ */

View File

@ -48,10 +48,10 @@
#include "gimpdisplay.h"
#include "gimpdisplay-area.h"
#include "gimpdisplay-callbacks.h"
#include "gimpdisplay-render.h"
#include "gimpdisplay-selection.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-render.h"
#include "gximage.h"
#include "colormaps.h"
@ -176,6 +176,14 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->gdisp = NULL;
shell->ifactory = NULL;
shell->offset_x = 0;
shell->offset_y = 0;
shell->disp_width = 0;
shell->disp_height = 0;
shell->disp_xoffset = 0;
shell->disp_yoffset = 0;
shell->proximity = FALSE;
shell->display_areas = NULL;
@ -406,10 +414,10 @@ gimp_display_shell_new (GimpDisplay *gdisp)
/* active display callback */
g_signal_connect (G_OBJECT (shell), "button_press_event",
G_CALLBACK (gdisplay_shell_events),
G_CALLBACK (gimp_display_shell_events),
shell);
g_signal_connect (G_OBJECT (shell), "key_press_event",
G_CALLBACK (gdisplay_shell_events),
G_CALLBACK (gimp_display_shell_events),
shell);
/* dnd stuff */
@ -420,22 +428,22 @@ gimp_display_shell_new (GimpDisplay *gdisp)
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (shell), GIMP_TYPE_LAYER,
gdisplay_drop_drawable,
gimp_display_shell_drop_drawable,
shell);
gimp_dnd_viewable_dest_set (GTK_WIDGET (shell), GIMP_TYPE_LAYER_MASK,
gdisplay_drop_drawable,
gimp_display_shell_drop_drawable,
shell);
gimp_dnd_viewable_dest_set (GTK_WIDGET (shell), GIMP_TYPE_CHANNEL,
gdisplay_drop_drawable,
gimp_display_shell_drop_drawable,
shell);
gimp_dnd_viewable_dest_set (GTK_WIDGET (shell), GIMP_TYPE_PATTERN,
gdisplay_drop_pattern,
gimp_display_shell_drop_pattern,
shell);
gimp_dnd_viewable_dest_set (GTK_WIDGET (shell), GIMP_TYPE_BUFFER,
gdisplay_drop_buffer,
gimp_display_shell_drop_buffer,
shell);
gimp_dnd_color_dest_set (GTK_WIDGET (shell),
gdisplay_drop_color,
gimp_display_shell_drop_color,
shell);
/* connect the "F1" help key */
@ -546,7 +554,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
g_signal_connect (G_OBJECT (shell->origin), "button_press_event",
G_CALLBACK (gdisplay_origin_button_press),
G_CALLBACK (gimp_display_shell_origin_button_press),
shell);
gimp_help_set_help_data (shell->origin, NULL, "#origin_button");
@ -565,7 +573,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
G_CALLBACK (GTK_WIDGET_GET_CLASS (shell->hrule)->motion_notify_event),
shell->hrule);
g_signal_connect (G_OBJECT (shell->hrule), "button_press_event",
G_CALLBACK (gdisplay_hruler_button_press),
G_CALLBACK (gimp_display_shell_hruler_button_press),
shell);
gimp_help_set_help_data (shell->hrule, NULL, "#ruler");
@ -579,7 +587,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
G_CALLBACK (GTK_WIDGET_GET_CLASS (shell->vrule)->motion_notify_event),
shell->vrule);
g_signal_connect (G_OBJECT (shell->vrule), "button_press_event",
G_CALLBACK (gdisplay_vruler_button_press),
G_CALLBACK (gimp_display_shell_vruler_button_press),
shell);
gimp_help_set_help_data (shell->vrule, NULL, "#ruler");
@ -588,16 +596,26 @@ gimp_display_shell_new (GimpDisplay *gdisp)
shell->canvas = gtk_drawing_area_new ();
gtk_widget_set_name (shell->canvas, "gimp-canvas");
gtk_drawing_area_size (GTK_DRAWING_AREA (shell->canvas), n_width, n_height);
gtk_widget_set_events (shell->canvas, CANVAS_EVENT_MASK);
gtk_widget_set_events (shell->canvas, GIMP_DISPLAY_SHELL_CANVAS_EVENT_MASK);
gtk_widget_set_extension_events (shell->canvas, GDK_EXTENSION_EVENTS_ALL);
GTK_WIDGET_SET_FLAGS (shell->canvas, GTK_CAN_FOCUS);
#if 0
FIXME
g_signal_connect (G_OBJECT (shell->canvas), "realize",
G_CALLBACK (gimp_display_shell_canvas_events),
shell);
#endif
/* set the active display before doing any other canvas event processing */
g_signal_connect (G_OBJECT (shell->canvas), "event",
G_CALLBACK (gdisplay_shell_events),
G_CALLBACK (gimp_display_shell_events),
shell);
g_signal_connect (G_OBJECT (shell->canvas), "event",
G_CALLBACK (gdisplay_canvas_events),
G_CALLBACK (gimp_display_shell_canvas_events),
shell);
/* create the contents of the lower_hbox *********************************/
@ -1194,10 +1212,10 @@ gimp_display_shell_mask_bounds (GimpDisplayShell *shell,
gdisplay_transform_coords (shell->gdisp, *x2, *y2, x2, y2, 0);
/* Make sure the extents are within bounds */
*x1 = CLAMP (*x1, 0, shell->gdisp->disp_width);
*y1 = CLAMP (*y1, 0, shell->gdisp->disp_height);
*x2 = CLAMP (*x2, 0, shell->gdisp->disp_width);
*y2 = CLAMP (*y2, 0, shell->gdisp->disp_height);
*x1 = CLAMP (*x1, 0, shell->disp_width);
*y1 = CLAMP (*y1, 0, shell->disp_height);
*x2 = CLAMP (*x2, 0, shell->disp_width);
*y2 = CLAMP (*y2, 0, shell->disp_height);
return TRUE;
}
@ -1215,10 +1233,10 @@ gimp_display_shell_add_expose_area (GimpDisplayShell *shell,
area = g_new (GimpArea, 1);
area->x1 = CLAMP (x, 0, shell->gdisp->disp_width);
area->y1 = CLAMP (y, 0, shell->gdisp->disp_height);
area->x2 = CLAMP (x + w, 0, shell->gdisp->disp_width);
area->y2 = CLAMP (y + h, 0, shell->gdisp->disp_height);
area->x1 = CLAMP (x, 0, shell->disp_width);
area->y1 = CLAMP (y, 0, shell->disp_height);
area->x2 = CLAMP (x + w, 0, shell->disp_width);
area->y2 = CLAMP (y + h, 0, shell->disp_height);
shell->display_areas = gimp_display_area_list_process (shell->display_areas,
area);
@ -1246,11 +1264,11 @@ gimp_display_shell_expose_guide (GimpDisplayShell *shell,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
gimp_display_shell_add_expose_area (shell, 0, y, shell->gdisp->disp_width, 1);
gimp_display_shell_add_expose_area (shell, 0, y, shell->disp_width, 1);
break;
case ORIENTATION_VERTICAL:
gimp_display_shell_add_expose_area (shell, x, 0, 1, shell->gdisp->disp_height);
gimp_display_shell_add_expose_area (shell, x, 0, 1, shell->disp_height);
break;
default:
@ -1265,8 +1283,8 @@ gimp_display_shell_expose_full (GimpDisplayShell *shell)
gimp_display_shell_add_expose_area (shell,
0, 0,
shell->gdisp->disp_width,
shell->gdisp->disp_height);
shell->disp_width,
shell->disp_height);
}
void
@ -1431,7 +1449,8 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gint y)
{
GimpImage *gimage;
gint new_cursor;
gboolean new_cursor;
gboolean flush = FALSE;
gchar buffer[CURSOR_STR_LENGTH];
gint t_x;
gint t_y;
@ -1455,10 +1474,19 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
if (! new_cursor)
{
shell->have_cursor = FALSE;
gdisplay_flush (shell->gdisp);
flush = TRUE;
}
}
shell->have_cursor = new_cursor;
shell->cursor_x = x;
shell->cursor_y = y;
if (new_cursor || flush)
{
gdisplay_flush (shell->gdisp);
}
gdisplay_untransform_coords (shell->gdisp, x, y, &t_x, &t_y, FALSE, FALSE);
if (t_x < 0 ||
@ -1473,29 +1501,23 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
{
if (shell->gdisp->dot_for_dot)
{
g_snprintf (buffer, CURSOR_STR_LENGTH,
shell->cursor_format_str, "", t_x, ", ", t_y);
g_snprintf (buffer, sizeof (buffer), shell->cursor_format_str,
"", t_x, ", ", t_y);
}
else /* show real world units */
{
gdouble unit_factor = gimp_unit_get_factor (gimage->unit);
g_snprintf (buffer, CURSOR_STR_LENGTH, shell->cursor_format_str,
g_snprintf (buffer, sizeof (buffer), shell->cursor_format_str,
"",
(gdouble) t_x * unit_factor / gimage->xresolution,
", ",
(gdouble) t_y * unit_factor / gimage->yresolution);
}
gtk_label_set_text (GTK_LABEL (shell->cursor_label), buffer);
info_window_update_extended (shell->gdisp, t_x, t_y);
}
shell->have_cursor = new_cursor;
shell->cursor_x = x;
shell->cursor_y = y;
if (new_cursor)
gdisplay_flush (shell->gdisp);
}
void
@ -1735,8 +1757,8 @@ gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
width = SCALEX (shell->gdisp, shell->gdisp->gimage->width);
height = SCALEY (shell->gdisp, shell->gdisp->gimage->height);
disp_width = shell->gdisp->disp_width;
disp_height = shell->gdisp->disp_height;
disp_width = shell->disp_width;
disp_height = shell->disp_height;
shell_width = GTK_WIDGET (shell)->allocation.width;
shell_height = GTK_WIDGET (shell)->allocation.height;
@ -1789,8 +1811,8 @@ gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
border_x, border_y);
#endif /* RESIZE_DEBUG */
shell->gdisp->disp_width = width;
shell->gdisp->disp_height = height;
shell->disp_width = width;
shell->disp_height = height;
allocation.width = width + border_x;
allocation.height = height + border_y;
@ -1799,10 +1821,10 @@ gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
* changes because our caller has to do a full display update anyway
*/
g_signal_handlers_block_by_func (G_OBJECT (shell->canvas),
gdisplay_shell_events,
gimp_display_shell_events,
shell);
g_signal_handlers_block_by_func (G_OBJECT (shell->canvas),
gdisplay_canvas_events,
gimp_display_shell_canvas_events,
shell);
gtk_widget_size_allocate (GTK_WIDGET (shell), &allocation);
@ -1828,21 +1850,21 @@ gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
}
g_signal_handlers_unblock_by_func (G_OBJECT (shell->canvas),
gdisplay_shell_events,
gimp_display_shell_events,
shell);
g_signal_handlers_unblock_by_func (G_OBJECT (shell->canvas),
gdisplay_canvas_events,
gimp_display_shell_canvas_events,
shell);
}
/* If the width or height of the display has changed, recalculate
* the display offsets...
*/
if (disp_width != shell->gdisp->disp_width ||
disp_height != shell->gdisp->disp_height)
if (disp_width != shell->disp_width ||
disp_height != shell->disp_height)
{
shell->gdisp->offset_x += (disp_width - shell->gdisp->disp_width) / 2;
shell->gdisp->offset_y += (disp_height - shell->gdisp->disp_height) / 2;
shell->offset_x += (disp_width - shell->disp_width) / 2;
shell->offset_y += (disp_height - shell->disp_height) / 2;
}
}
@ -1889,65 +1911,65 @@ gimp_display_shell_display_area (GimpDisplayShell *shell,
sy = SCALEY (shell->gdisp, shell->gdisp->gimage->height);
/* Bounds check */
x1 = CLAMP (x, 0, shell->gdisp->disp_width);
y1 = CLAMP (y, 0, shell->gdisp->disp_height);
x2 = CLAMP (x + w, 0, shell->gdisp->disp_width);
y2 = CLAMP (y + h, 0, shell->gdisp->disp_height);
x1 = CLAMP (x, 0, shell->disp_width);
y1 = CLAMP (y, 0, shell->disp_height);
x2 = CLAMP (x + w, 0, shell->disp_width);
y2 = CLAMP (y + h, 0, shell->disp_height);
if (y1 < shell->gdisp->disp_yoffset)
if (y1 < shell->disp_yoffset)
{
gdk_draw_rectangle (shell->canvas->window,
shell->canvas->style->bg_gc[GTK_STATE_NORMAL],
TRUE,
x, y,
w, shell->gdisp->disp_yoffset - y);
w, shell->disp_yoffset - y);
/* X X X
. # .
. . . */
y1 = shell->gdisp->disp_yoffset;
y1 = shell->disp_yoffset;
}
if (x1 < shell->gdisp->disp_xoffset)
if (x1 < shell->disp_xoffset)
{
gdk_draw_rectangle (shell->canvas->window,
shell->canvas->style->bg_gc[GTK_STATE_NORMAL],
TRUE,
x, y1,
shell->gdisp->disp_xoffset - x, h);
shell->disp_xoffset - x, h);
/* . . .
X # .
X . . */
x1 = shell->gdisp->disp_xoffset;
x1 = shell->disp_xoffset;
}
if (x2 > (shell->gdisp->disp_xoffset + sx))
if (x2 > (shell->disp_xoffset + sx))
{
gdk_draw_rectangle (shell->canvas->window,
shell->canvas->style->bg_gc[GTK_STATE_NORMAL],
TRUE,
shell->gdisp->disp_xoffset + sx, y1,
x2 - (shell->gdisp->disp_xoffset + sx), h - (y1 - y));
shell->disp_xoffset + sx, y1,
x2 - (shell->disp_xoffset + sx), h - (y1 - y));
/* . . .
. # X
. . X */
x2 = shell->gdisp->disp_xoffset + sx;
x2 = shell->disp_xoffset + sx;
}
if (y2 > (shell->gdisp->disp_yoffset + sy))
if (y2 > (shell->disp_yoffset + sy))
{
gdk_draw_rectangle (shell->canvas->window,
shell->canvas->style->bg_gc[GTK_STATE_NORMAL],
TRUE,
x1, shell->gdisp->disp_yoffset + sy,
x2 - x1, y2 - (shell->gdisp->disp_yoffset + sy));
x1, shell->disp_yoffset + sy,
x2 - x1, y2 - (shell->disp_yoffset + sy));
/* . . .
. # .
. X . */
y2 = shell->gdisp->disp_yoffset + sy;
y2 = shell->disp_yoffset + sy;
}
/* display the image in GXIMAGE_WIDTH x GXIMAGE_HEIGHT sized chunks */
@ -1959,14 +1981,14 @@ gimp_display_shell_display_area (GimpDisplayShell *shell,
dy = MIN (y2 - i, GXIMAGE_HEIGHT);
render_image (shell->gdisp,
j - shell->gdisp->disp_xoffset, i - shell->gdisp->disp_yoffset,
j - shell->disp_xoffset, i - shell->disp_yoffset,
dx, dy);
#if 0
/* Invalidate the projection just after we render it! */
gimp_image_invalidate_without_render (shell->gdisp->gimage,
j - shell->gdisp->disp_xoffset,
i - shell->gdisp->disp_yoffset,
j - shell->disp_xoffset,
i - shell->disp_yoffset,
dx, dy,
0, 0, 0, 0);
#endif
@ -1982,8 +2004,8 @@ gimp_display_shell_display_area (GimpDisplayShell *shell,
gximage_put (shell->canvas->window,
j, i, dx, dy,
shell->gdisp->offset_x,
shell->gdisp->offset_y);
shell->offset_x,
shell->offset_y);
}
}
}

View File

@ -50,6 +50,14 @@ struct _GimpDisplayShell
GtkItemFactory *ifactory;
gint offset_x; /* offset of display image into raw image */
gint offset_y;
gint disp_width; /* width of drawing area */
gint disp_height; /* height of drawing area */
gint disp_xoffset;
gint disp_yoffset;
gboolean proximity; /* is a device in proximity */
GSList *display_areas; /* display areas list */

View File

@ -31,8 +31,8 @@
#include "core/gimpimage.h"
#include "gimpdisplay.h"
#include "gimpdisplay-render.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-render.h"
#include "gximage.h"
#include "gimprc.h"
@ -744,8 +744,8 @@ render_image_init_info (RenderInfo *info,
{
info->gdisp = gdisp;
info->src_tiles = gimp_image_projection (gdisp->gimage);
info->x = x + gdisp->offset_x;
info->y = y + gdisp->offset_y;
info->x = x + GIMP_DISPLAY_SHELL (gdisp->shell)->offset_x;
info->y = y + GIMP_DISPLAY_SHELL (gdisp->shell)->offset_y;
info->w = w;
info->h = h;
info->scalex = SCALEFACTOR_X (gdisp);

View File

@ -33,9 +33,9 @@
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplay-scale.h"
#include "gimpdisplay-scroll.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
#include "gimprc.h"
#include "nav_window.h"
@ -69,16 +69,16 @@ gimp_display_shell_scale_setup (GimpDisplayShell *shell)
stepx = SCALEFACTOR_X (shell->gdisp);
stepy = SCALEFACTOR_Y (shell->gdisp);
shell->hsbdata->value = shell->gdisp->offset_x;
shell->hsbdata->value = shell->offset_x;
shell->hsbdata->upper = sx;
shell->hsbdata->page_size = MIN (sx, shell->gdisp->disp_width);
shell->hsbdata->page_increment = shell->gdisp->disp_width / 2;
shell->hsbdata->page_size = MIN (sx, shell->disp_width);
shell->hsbdata->page_increment = shell->disp_width / 2;
shell->hsbdata->step_increment = stepx;
shell->vsbdata->value = shell->gdisp->offset_y;
shell->vsbdata->value = shell->offset_y;
shell->vsbdata->upper = sy;
shell->vsbdata->page_size = MIN (sy, shell->gdisp->disp_height);
shell->vsbdata->page_increment = shell->gdisp->disp_height / 2;
shell->vsbdata->page_size = MIN (sy, shell->disp_height);
shell->vsbdata->page_increment = shell->disp_height / 2;
shell->vsbdata->step_increment = stepy;
gtk_adjustment_changed (shell->hsbdata);
@ -89,60 +89,60 @@ gimp_display_shell_scale_setup (GimpDisplayShell *shell)
hruler->lower = 0;
hruler->upper = img2real (shell->gdisp, TRUE,
FUNSCALEX (shell->gdisp, shell->gdisp->disp_width));
FUNSCALEX (shell->gdisp, shell->disp_width));
hruler->max_size = img2real (shell->gdisp, TRUE,
MAX (image_width, image_height));
vruler->lower = 0;
vruler->upper = img2real (shell->gdisp, FALSE,
FUNSCALEY (shell->gdisp, shell->gdisp->disp_height));
FUNSCALEY (shell->gdisp, shell->disp_height));
vruler->max_size = img2real (shell->gdisp, FALSE,
MAX (image_width, image_height));
if (sx < shell->gdisp->disp_width)
if (sx < shell->disp_width)
{
shell->gdisp->disp_xoffset = (shell->gdisp->disp_width - sx) / 2;
shell->disp_xoffset = (shell->disp_width - sx) / 2;
hruler->lower -= img2real (shell->gdisp, TRUE,
FUNSCALEX (shell->gdisp,
(gdouble) shell->gdisp->disp_xoffset));
(gdouble) shell->disp_xoffset));
hruler->upper -= img2real (shell->gdisp, TRUE,
FUNSCALEX (shell->gdisp,
(gdouble) shell->gdisp->disp_xoffset));
(gdouble) shell->disp_xoffset));
}
else
{
shell->gdisp->disp_xoffset = 0;
shell->disp_xoffset = 0;
hruler->lower += img2real (shell->gdisp, TRUE,
FUNSCALEX (shell->gdisp,
(gdouble) shell->gdisp->offset_x));
(gdouble) shell->offset_x));
hruler->upper += img2real (shell->gdisp, TRUE,
FUNSCALEX (shell->gdisp,
(gdouble) shell->gdisp->offset_x));
(gdouble) shell->offset_x));
}
if (sy < shell->gdisp->disp_height)
if (sy < shell->disp_height)
{
shell->gdisp->disp_yoffset = (shell->gdisp->disp_height - sy) / 2;
shell->disp_yoffset = (shell->disp_height - sy) / 2;
vruler->lower -= img2real (shell->gdisp, FALSE,
FUNSCALEY (shell->gdisp,
(gdouble) shell->gdisp->disp_yoffset));
(gdouble) shell->disp_yoffset));
vruler->upper -= img2real (shell->gdisp, FALSE,
FUNSCALEY (shell->gdisp,
(gdouble) shell->gdisp->disp_yoffset));
(gdouble) shell->disp_yoffset));
}
else
{
shell->gdisp->disp_yoffset = 0;
shell->disp_yoffset = 0;
vruler->lower += img2real (shell->gdisp, FALSE,
FUNSCALEY (shell->gdisp,
(gdouble) shell->gdisp->offset_y));
(gdouble) shell->offset_y));
vruler->upper += img2real (shell->gdisp, FALSE,
FUNSCALEY (shell->gdisp,
(gdouble) shell->gdisp->offset_y));
(gdouble) shell->offset_y));
}
gtk_widget_queue_draw (GTK_WIDGET (hruler));
@ -160,9 +160,9 @@ gimp_display_shell_scale_setup (GimpDisplayShell *shell)
"disp_height: %d\n"
"disp_xoffset: %d\n"
"disp_yoffset: %d\n\n",
shell->gdisp->offset_x, shell->gdisp->offset_y,
shell->gdisp->disp_width, shell->gdisp->disp_height,
shell->gdisp->disp_xoffset, shell->gdisp->disp_yoffset);
shell->offset_x, shell->offset_y,
shell->disp_width, shell->disp_height,
shell->disp_xoffset, shell->disp_yoffset);
#endif
}
@ -196,8 +196,8 @@ gimp_display_shell_scale (GimpDisplayShell *shell,
scalesrc = SCALESRC (shell->gdisp);
scaledest = SCALEDEST (shell->gdisp);
offset_x = shell->gdisp->offset_x + (shell->gdisp->disp_width / 2.0);
offset_y = shell->gdisp->offset_y + (shell->gdisp->disp_height / 2.0);
offset_x = shell->offset_x + (shell->disp_width / 2.0);
offset_y = shell->offset_y + (shell->disp_height / 2.0);
offset_x *= ((double) scalesrc / (double) scaledest);
offset_y *= ((double) scalesrc / (double) scaledest);
@ -252,14 +252,125 @@ gimp_display_shell_scale (GimpDisplayShell *shell,
offset_x *= ((gdouble) scaledest / (gdouble) scalesrc);
offset_y *= ((gdouble) scaledest / (gdouble) scalesrc);
shell->gdisp->offset_x = (gint) (offset_x - (shell->gdisp->disp_width / 2));
shell->gdisp->offset_y = (gint) (offset_y - (shell->gdisp->disp_height / 2));
shell->offset_x = (gint) (offset_x - (shell->disp_width / 2));
shell->offset_y = (gint) (offset_y - (shell->disp_height / 2));
/* resize the display */
gimp_display_shell_scale_resize (shell, gimprc.allow_resize_windows, TRUE);
}
}
void
gimp_display_shell_scale_fit (GimpDisplayShell *shell)
{
gint image_width;
gint image_height;
gdouble zoom_x;
gdouble zoom_y;
gdouble zoom_factor;
gdouble zoom_delta;
gdouble min_zoom_delta = G_MAXFLOAT;
gint scalesrc = 1;
gint scaledest = 1;
gint i;
gint best_i = 0x10;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
image_width = shell->gdisp->gimage->width;
image_height = shell->gdisp->gimage->height;
if (! shell->gdisp->dot_for_dot)
{
image_width = ROUND (image_width *
gimprc.monitor_xres /
shell->gdisp->gimage->xresolution);
image_height = ROUND (image_height *
gimprc.monitor_yres /
shell->gdisp->gimage->yresolution);
}
zoom_x = (gdouble) shell->disp_width / (gdouble) image_width;
zoom_y = (gdouble) shell->disp_height / (gdouble) image_height;
if ((gdouble) image_height * zoom_x <= (gdouble) shell->disp_height)
{
zoom_factor = zoom_x;
}
else
{
zoom_factor = zoom_y;
}
if (zoom_factor < 1.0)
{
for (i = 0x10; i > 0; i--)
{
scalesrc = i;
scaledest = floor ((gdouble) scalesrc * zoom_factor);
if (scaledest < 0x1)
{
scaledest = 0x1;
}
zoom_delta = ABS ((gdouble) scaledest / (gdouble) scalesrc -
zoom_factor);
if (zoom_delta <= min_zoom_delta)
{
min_zoom_delta = zoom_delta;
best_i = i;
}
}
scalesrc = best_i;
scaledest = floor ((gdouble) scalesrc * zoom_factor);
if (scaledest < 0x1)
{
scaledest = 0x1;
}
}
else
{
for (i = 0x10; i > 0; i--)
{
scaledest = i;
scalesrc = ceil ((gdouble) scaledest / zoom_factor);
if (scalesrc < 0x1)
{
scalesrc = 0x1;
}
zoom_delta = ABS ((gdouble) scaledest / (gdouble) scalesrc -
zoom_factor);
if (zoom_delta <= min_zoom_delta)
{
min_zoom_delta = zoom_delta;
best_i = i;
}
}
scaledest = best_i;
scalesrc = ceil ((gdouble) scaledest / zoom_factor);
if (scalesrc < 0x1)
{
scalesrc = 0x1;
}
}
shell->gdisp->scale = (scaledest << 8) + scalesrc;
shell->offset_x = 0;
shell->offset_y = 0;
gimp_display_shell_scale_resize (shell, FALSE, TRUE);
}
void
gimp_display_shell_scale_resize (GimpDisplayShell *shell,
gboolean resize_window,

View File

@ -27,6 +27,7 @@ void gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *gdisp,
void gimp_display_shell_scale (GimpDisplayShell *gdisp,
GimpZoomType zoom_type);
void gimp_display_shell_scale_fit (GimpDisplayShell *gdisp);
void gimp_display_shell_scale_resize (GimpDisplayShell *shell,
gboolean resize_window,
gboolean redisplay);

View File

@ -31,9 +31,9 @@
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplay-scale.h"
#include "gimpdisplay-scroll.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
#include "gimprc.h"
#include "nav_window.h"
@ -51,17 +51,17 @@ gimp_display_shell_scroll (GimpDisplayShell *shell,
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
old_x = shell->gdisp->offset_x;
old_y = shell->gdisp->offset_y;
old_x = shell->offset_x;
old_y = shell->offset_y;
shell->gdisp->offset_x += x_offset;
shell->gdisp->offset_y += y_offset;
shell->offset_x += x_offset;
shell->offset_y += y_offset;
gimp_display_shell_scroll_clamp_offsets (shell);
/* the actual changes in offset */
x_offset = (shell->gdisp->offset_x - old_x);
y_offset = (shell->gdisp->offset_y - old_y);
x_offset = (shell->offset_x - old_x);
y_offset = (shell->offset_y - old_y);
if (x_offset || y_offset)
{
@ -75,24 +75,24 @@ gimp_display_shell_scroll (GimpDisplayShell *shell,
dest_y = (y_offset < 0) ? -y_offset : 0;
/* reset the old values so that the tool can accurately redraw */
shell->gdisp->offset_x = old_x;
shell->gdisp->offset_y = old_y;
shell->offset_x = old_x;
shell->offset_y = old_y;
/* freeze the active tool */
tool_manager_control_active (shell->gdisp->gimage->gimp, PAUSE,
shell->gdisp);
/* set the offsets back to the new values */
shell->gdisp->offset_x += x_offset;
shell->gdisp->offset_y += y_offset;
shell->offset_x += x_offset;
shell->offset_y += y_offset;
gdk_draw_drawable (shell->canvas->window,
shell->scroll_gc,
shell->canvas->window,
src_x, src_y,
dest_x, dest_y,
(shell->gdisp->disp_width - abs (x_offset)),
(shell->gdisp->disp_height - abs (y_offset)));
(shell->disp_width - abs (x_offset)),
(shell->disp_height - abs (y_offset)));
/* re-enable the active tool */
tool_manager_control_active (shell->gdisp->gimage->gimp, RESUME,
@ -101,23 +101,23 @@ gimp_display_shell_scroll (GimpDisplayShell *shell,
/* scale the image into the exposed regions */
if (x_offset)
{
src_x = (x_offset < 0) ? 0 : shell->gdisp->disp_width - x_offset;
src_x = (x_offset < 0) ? 0 : shell->disp_width - x_offset;
src_y = 0;
gimp_display_shell_add_expose_area (shell,
src_x, src_y,
abs (x_offset),
shell->gdisp->disp_height);
shell->disp_height);
}
if (y_offset)
{
src_x = 0;
src_y = (y_offset < 0) ? 0 : shell->gdisp->disp_height - y_offset;
src_y = (y_offset < 0) ? 0 : shell->disp_height - y_offset;
gimp_display_shell_add_expose_area (shell,
src_x, src_y,
shell->gdisp->disp_width,
shell->disp_width,
abs (y_offset));
}
@ -161,10 +161,10 @@ gimp_display_shell_scroll_clamp_offsets (GimpDisplayShell *shell)
sx = SCALEX (shell->gdisp, shell->gdisp->gimage->width);
sy = SCALEY (shell->gdisp, shell->gdisp->gimage->height);
shell->gdisp->offset_x = CLAMP (shell->gdisp->offset_x, 0,
MAX (sx - shell->gdisp->disp_width, 0));
shell->offset_x = CLAMP (shell->offset_x, 0,
MAX (sx - shell->disp_width, 0));
shell->gdisp->offset_y = CLAMP (shell->gdisp->offset_y, 0,
MAX (sy - shell->gdisp->disp_height, 0));
shell->offset_y = CLAMP (shell->offset_y, 0,
MAX (sy - shell->disp_height, 0));
}

View File

@ -48,10 +48,10 @@
#include "gimpdisplay.h"
#include "gimpdisplay-area.h"
#include "gimpdisplay-callbacks.h"
#include "gimpdisplay-render.h"
#include "gimpdisplay-selection.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-render.h"
#include "gximage.h"
#include "colormaps.h"
@ -176,6 +176,14 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->gdisp = NULL;
shell->ifactory = NULL;
shell->offset_x = 0;
shell->offset_y = 0;
shell->disp_width = 0;
shell->disp_height = 0;
shell->disp_xoffset = 0;
shell->disp_yoffset = 0;
shell->proximity = FALSE;
shell->display_areas = NULL;
@ -406,10 +414,10 @@ gimp_display_shell_new (GimpDisplay *gdisp)
/* active display callback */
g_signal_connect (G_OBJECT (shell), "button_press_event",
G_CALLBACK (gdisplay_shell_events),
G_CALLBACK (gimp_display_shell_events),
shell);
g_signal_connect (G_OBJECT (shell), "key_press_event",
G_CALLBACK (gdisplay_shell_events),
G_CALLBACK (gimp_display_shell_events),
shell);
/* dnd stuff */
@ -420,22 +428,22 @@ gimp_display_shell_new (GimpDisplay *gdisp)
GDK_ACTION_COPY);
gimp_dnd_viewable_dest_set (GTK_WIDGET (shell), GIMP_TYPE_LAYER,
gdisplay_drop_drawable,
gimp_display_shell_drop_drawable,
shell);
gimp_dnd_viewable_dest_set (GTK_WIDGET (shell), GIMP_TYPE_LAYER_MASK,
gdisplay_drop_drawable,
gimp_display_shell_drop_drawable,
shell);
gimp_dnd_viewable_dest_set (GTK_WIDGET (shell), GIMP_TYPE_CHANNEL,
gdisplay_drop_drawable,
gimp_display_shell_drop_drawable,
shell);
gimp_dnd_viewable_dest_set (GTK_WIDGET (shell), GIMP_TYPE_PATTERN,
gdisplay_drop_pattern,
gimp_display_shell_drop_pattern,
shell);
gimp_dnd_viewable_dest_set (GTK_WIDGET (shell), GIMP_TYPE_BUFFER,
gdisplay_drop_buffer,
gimp_display_shell_drop_buffer,
shell);
gimp_dnd_color_dest_set (GTK_WIDGET (shell),
gdisplay_drop_color,
gimp_display_shell_drop_color,
shell);
/* connect the "F1" help key */
@ -546,7 +554,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
g_signal_connect (G_OBJECT (shell->origin), "button_press_event",
G_CALLBACK (gdisplay_origin_button_press),
G_CALLBACK (gimp_display_shell_origin_button_press),
shell);
gimp_help_set_help_data (shell->origin, NULL, "#origin_button");
@ -565,7 +573,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
G_CALLBACK (GTK_WIDGET_GET_CLASS (shell->hrule)->motion_notify_event),
shell->hrule);
g_signal_connect (G_OBJECT (shell->hrule), "button_press_event",
G_CALLBACK (gdisplay_hruler_button_press),
G_CALLBACK (gimp_display_shell_hruler_button_press),
shell);
gimp_help_set_help_data (shell->hrule, NULL, "#ruler");
@ -579,7 +587,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
G_CALLBACK (GTK_WIDGET_GET_CLASS (shell->vrule)->motion_notify_event),
shell->vrule);
g_signal_connect (G_OBJECT (shell->vrule), "button_press_event",
G_CALLBACK (gdisplay_vruler_button_press),
G_CALLBACK (gimp_display_shell_vruler_button_press),
shell);
gimp_help_set_help_data (shell->vrule, NULL, "#ruler");
@ -588,16 +596,26 @@ gimp_display_shell_new (GimpDisplay *gdisp)
shell->canvas = gtk_drawing_area_new ();
gtk_widget_set_name (shell->canvas, "gimp-canvas");
gtk_drawing_area_size (GTK_DRAWING_AREA (shell->canvas), n_width, n_height);
gtk_widget_set_events (shell->canvas, CANVAS_EVENT_MASK);
gtk_widget_set_events (shell->canvas, GIMP_DISPLAY_SHELL_CANVAS_EVENT_MASK);
gtk_widget_set_extension_events (shell->canvas, GDK_EXTENSION_EVENTS_ALL);
GTK_WIDGET_SET_FLAGS (shell->canvas, GTK_CAN_FOCUS);
#if 0
FIXME
g_signal_connect (G_OBJECT (shell->canvas), "realize",
G_CALLBACK (gimp_display_shell_canvas_events),
shell);
#endif
/* set the active display before doing any other canvas event processing */
g_signal_connect (G_OBJECT (shell->canvas), "event",
G_CALLBACK (gdisplay_shell_events),
G_CALLBACK (gimp_display_shell_events),
shell);
g_signal_connect (G_OBJECT (shell->canvas), "event",
G_CALLBACK (gdisplay_canvas_events),
G_CALLBACK (gimp_display_shell_canvas_events),
shell);
/* create the contents of the lower_hbox *********************************/
@ -1194,10 +1212,10 @@ gimp_display_shell_mask_bounds (GimpDisplayShell *shell,
gdisplay_transform_coords (shell->gdisp, *x2, *y2, x2, y2, 0);
/* Make sure the extents are within bounds */
*x1 = CLAMP (*x1, 0, shell->gdisp->disp_width);
*y1 = CLAMP (*y1, 0, shell->gdisp->disp_height);
*x2 = CLAMP (*x2, 0, shell->gdisp->disp_width);
*y2 = CLAMP (*y2, 0, shell->gdisp->disp_height);
*x1 = CLAMP (*x1, 0, shell->disp_width);
*y1 = CLAMP (*y1, 0, shell->disp_height);
*x2 = CLAMP (*x2, 0, shell->disp_width);
*y2 = CLAMP (*y2, 0, shell->disp_height);
return TRUE;
}
@ -1215,10 +1233,10 @@ gimp_display_shell_add_expose_area (GimpDisplayShell *shell,
area = g_new (GimpArea, 1);
area->x1 = CLAMP (x, 0, shell->gdisp->disp_width);
area->y1 = CLAMP (y, 0, shell->gdisp->disp_height);
area->x2 = CLAMP (x + w, 0, shell->gdisp->disp_width);
area->y2 = CLAMP (y + h, 0, shell->gdisp->disp_height);
area->x1 = CLAMP (x, 0, shell->disp_width);
area->y1 = CLAMP (y, 0, shell->disp_height);
area->x2 = CLAMP (x + w, 0, shell->disp_width);
area->y2 = CLAMP (y + h, 0, shell->disp_height);
shell->display_areas = gimp_display_area_list_process (shell->display_areas,
area);
@ -1246,11 +1264,11 @@ gimp_display_shell_expose_guide (GimpDisplayShell *shell,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
gimp_display_shell_add_expose_area (shell, 0, y, shell->gdisp->disp_width, 1);
gimp_display_shell_add_expose_area (shell, 0, y, shell->disp_width, 1);
break;
case ORIENTATION_VERTICAL:
gimp_display_shell_add_expose_area (shell, x, 0, 1, shell->gdisp->disp_height);
gimp_display_shell_add_expose_area (shell, x, 0, 1, shell->disp_height);
break;
default:
@ -1265,8 +1283,8 @@ gimp_display_shell_expose_full (GimpDisplayShell *shell)
gimp_display_shell_add_expose_area (shell,
0, 0,
shell->gdisp->disp_width,
shell->gdisp->disp_height);
shell->disp_width,
shell->disp_height);
}
void
@ -1431,7 +1449,8 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gint y)
{
GimpImage *gimage;
gint new_cursor;
gboolean new_cursor;
gboolean flush = FALSE;
gchar buffer[CURSOR_STR_LENGTH];
gint t_x;
gint t_y;
@ -1455,10 +1474,19 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
if (! new_cursor)
{
shell->have_cursor = FALSE;
gdisplay_flush (shell->gdisp);
flush = TRUE;
}
}
shell->have_cursor = new_cursor;
shell->cursor_x = x;
shell->cursor_y = y;
if (new_cursor || flush)
{
gdisplay_flush (shell->gdisp);
}
gdisplay_untransform_coords (shell->gdisp, x, y, &t_x, &t_y, FALSE, FALSE);
if (t_x < 0 ||
@ -1473,29 +1501,23 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
{
if (shell->gdisp->dot_for_dot)
{
g_snprintf (buffer, CURSOR_STR_LENGTH,
shell->cursor_format_str, "", t_x, ", ", t_y);
g_snprintf (buffer, sizeof (buffer), shell->cursor_format_str,
"", t_x, ", ", t_y);
}
else /* show real world units */
{
gdouble unit_factor = gimp_unit_get_factor (gimage->unit);
g_snprintf (buffer, CURSOR_STR_LENGTH, shell->cursor_format_str,
g_snprintf (buffer, sizeof (buffer), shell->cursor_format_str,
"",
(gdouble) t_x * unit_factor / gimage->xresolution,
", ",
(gdouble) t_y * unit_factor / gimage->yresolution);
}
gtk_label_set_text (GTK_LABEL (shell->cursor_label), buffer);
info_window_update_extended (shell->gdisp, t_x, t_y);
}
shell->have_cursor = new_cursor;
shell->cursor_x = x;
shell->cursor_y = y;
if (new_cursor)
gdisplay_flush (shell->gdisp);
}
void
@ -1735,8 +1757,8 @@ gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
width = SCALEX (shell->gdisp, shell->gdisp->gimage->width);
height = SCALEY (shell->gdisp, shell->gdisp->gimage->height);
disp_width = shell->gdisp->disp_width;
disp_height = shell->gdisp->disp_height;
disp_width = shell->disp_width;
disp_height = shell->disp_height;
shell_width = GTK_WIDGET (shell)->allocation.width;
shell_height = GTK_WIDGET (shell)->allocation.height;
@ -1789,8 +1811,8 @@ gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
border_x, border_y);
#endif /* RESIZE_DEBUG */
shell->gdisp->disp_width = width;
shell->gdisp->disp_height = height;
shell->disp_width = width;
shell->disp_height = height;
allocation.width = width + border_x;
allocation.height = height + border_y;
@ -1799,10 +1821,10 @@ gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
* changes because our caller has to do a full display update anyway
*/
g_signal_handlers_block_by_func (G_OBJECT (shell->canvas),
gdisplay_shell_events,
gimp_display_shell_events,
shell);
g_signal_handlers_block_by_func (G_OBJECT (shell->canvas),
gdisplay_canvas_events,
gimp_display_shell_canvas_events,
shell);
gtk_widget_size_allocate (GTK_WIDGET (shell), &allocation);
@ -1828,21 +1850,21 @@ gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
}
g_signal_handlers_unblock_by_func (G_OBJECT (shell->canvas),
gdisplay_shell_events,
gimp_display_shell_events,
shell);
g_signal_handlers_unblock_by_func (G_OBJECT (shell->canvas),
gdisplay_canvas_events,
gimp_display_shell_canvas_events,
shell);
}
/* If the width or height of the display has changed, recalculate
* the display offsets...
*/
if (disp_width != shell->gdisp->disp_width ||
disp_height != shell->gdisp->disp_height)
if (disp_width != shell->disp_width ||
disp_height != shell->disp_height)
{
shell->gdisp->offset_x += (disp_width - shell->gdisp->disp_width) / 2;
shell->gdisp->offset_y += (disp_height - shell->gdisp->disp_height) / 2;
shell->offset_x += (disp_width - shell->disp_width) / 2;
shell->offset_y += (disp_height - shell->disp_height) / 2;
}
}
@ -1889,65 +1911,65 @@ gimp_display_shell_display_area (GimpDisplayShell *shell,
sy = SCALEY (shell->gdisp, shell->gdisp->gimage->height);
/* Bounds check */
x1 = CLAMP (x, 0, shell->gdisp->disp_width);
y1 = CLAMP (y, 0, shell->gdisp->disp_height);
x2 = CLAMP (x + w, 0, shell->gdisp->disp_width);
y2 = CLAMP (y + h, 0, shell->gdisp->disp_height);
x1 = CLAMP (x, 0, shell->disp_width);
y1 = CLAMP (y, 0, shell->disp_height);
x2 = CLAMP (x + w, 0, shell->disp_width);
y2 = CLAMP (y + h, 0, shell->disp_height);
if (y1 < shell->gdisp->disp_yoffset)
if (y1 < shell->disp_yoffset)
{
gdk_draw_rectangle (shell->canvas->window,
shell->canvas->style->bg_gc[GTK_STATE_NORMAL],
TRUE,
x, y,
w, shell->gdisp->disp_yoffset - y);
w, shell->disp_yoffset - y);
/* X X X
. # .
. . . */
y1 = shell->gdisp->disp_yoffset;
y1 = shell->disp_yoffset;
}
if (x1 < shell->gdisp->disp_xoffset)
if (x1 < shell->disp_xoffset)
{
gdk_draw_rectangle (shell->canvas->window,
shell->canvas->style->bg_gc[GTK_STATE_NORMAL],
TRUE,
x, y1,
shell->gdisp->disp_xoffset - x, h);
shell->disp_xoffset - x, h);
/* . . .
X # .
X . . */
x1 = shell->gdisp->disp_xoffset;
x1 = shell->disp_xoffset;
}
if (x2 > (shell->gdisp->disp_xoffset + sx))
if (x2 > (shell->disp_xoffset + sx))
{
gdk_draw_rectangle (shell->canvas->window,
shell->canvas->style->bg_gc[GTK_STATE_NORMAL],
TRUE,
shell->gdisp->disp_xoffset + sx, y1,
x2 - (shell->gdisp->disp_xoffset + sx), h - (y1 - y));
shell->disp_xoffset + sx, y1,
x2 - (shell->disp_xoffset + sx), h - (y1 - y));
/* . . .
. # X
. . X */
x2 = shell->gdisp->disp_xoffset + sx;
x2 = shell->disp_xoffset + sx;
}
if (y2 > (shell->gdisp->disp_yoffset + sy))
if (y2 > (shell->disp_yoffset + sy))
{
gdk_draw_rectangle (shell->canvas->window,
shell->canvas->style->bg_gc[GTK_STATE_NORMAL],
TRUE,
x1, shell->gdisp->disp_yoffset + sy,
x2 - x1, y2 - (shell->gdisp->disp_yoffset + sy));
x1, shell->disp_yoffset + sy,
x2 - x1, y2 - (shell->disp_yoffset + sy));
/* . . .
. # .
. X . */
y2 = shell->gdisp->disp_yoffset + sy;
y2 = shell->disp_yoffset + sy;
}
/* display the image in GXIMAGE_WIDTH x GXIMAGE_HEIGHT sized chunks */
@ -1959,14 +1981,14 @@ gimp_display_shell_display_area (GimpDisplayShell *shell,
dy = MIN (y2 - i, GXIMAGE_HEIGHT);
render_image (shell->gdisp,
j - shell->gdisp->disp_xoffset, i - shell->gdisp->disp_yoffset,
j - shell->disp_xoffset, i - shell->disp_yoffset,
dx, dy);
#if 0
/* Invalidate the projection just after we render it! */
gimp_image_invalidate_without_render (shell->gdisp->gimage,
j - shell->gdisp->disp_xoffset,
i - shell->gdisp->disp_yoffset,
j - shell->disp_xoffset,
i - shell->disp_yoffset,
dx, dy,
0, 0, 0, 0);
#endif
@ -1982,8 +2004,8 @@ gimp_display_shell_display_area (GimpDisplayShell *shell,
gximage_put (shell->canvas->window,
j, i, dx, dy,
shell->gdisp->offset_x,
shell->gdisp->offset_y);
shell->offset_x,
shell->offset_y);
}
}
}

View File

@ -50,6 +50,14 @@ struct _GimpDisplayShell
GtkItemFactory *ifactory;
gint offset_x; /* offset of display image into raw image */
gint offset_y;
gint disp_width; /* width of drawing area */
gint disp_height; /* height of drawing area */
gint disp_xoffset;
gint disp_yoffset;
gboolean proximity; /* is a device in proximity */
GSList *display_areas; /* display areas list */

View File

@ -38,9 +38,9 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplay-scroll.h"
#include "display/gimpdisplay-scale.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-scroll.h"
#include "display/gimpdisplayshell-scale.h"
#include "widgets/gimpnavigationpreview.h"
@ -175,8 +175,8 @@ nav_dialog_marker_changed (GimpNavigationPreview *nav_preview,
xratio = SCALEFACTOR_X (nav_dialog->gdisp);
yratio = SCALEFACTOR_Y (nav_dialog->gdisp);
xoffset = x * xratio - shell->gdisp->offset_x;
yoffset = y * yratio - shell->gdisp->offset_y;
xoffset = x * xratio - shell->offset_x;
yoffset = y * yratio - shell->offset_y;
gimp_display_shell_scroll (shell, xoffset, yoffset);
}
@ -714,17 +714,17 @@ nav_dialog_disp_area (NavigationDialog *nav_dialog,
gimp_navigation_preview_set_marker
(GIMP_NAVIGATION_PREVIEW (nav_dialog->new_preview),
RINT (shell->gdisp->offset_x / xratio),
RINT (shell->gdisp->offset_y / yratio),
RINT (shell->gdisp->disp_width / xratio),
RINT (shell->gdisp->disp_height / yratio));
RINT (shell->offset_x / xratio),
RINT (shell->offset_y / yratio),
RINT (shell->disp_width / xratio),
RINT (shell->disp_height / yratio));
}
nav_dialog->dispx = shell->gdisp->offset_x * nav_dialog->ratio / xratio + 0.5;
nav_dialog->dispy = shell->gdisp->offset_y * nav_dialog->ratio/yratio + 0.5;
nav_dialog->dispx = shell->offset_x * nav_dialog->ratio / xratio + 0.5;
nav_dialog->dispy = shell->offset_y * nav_dialog->ratio/yratio + 0.5;
nav_dialog->dispwidth = (shell->gdisp->disp_width * nav_dialog->ratio) / xratio + 0.5;
nav_dialog->dispheight = (shell->gdisp->disp_height * nav_dialog->ratio) / yratio + 0.5;
nav_dialog->dispwidth = (shell->disp_width * nav_dialog->ratio) / xratio + 0.5;
nav_dialog->dispheight = (shell->disp_height * nav_dialog->ratio) / yratio + 0.5;
newwidth = gimage->width;
newheight = gimage->height;
@ -735,12 +735,12 @@ nav_dialog_disp_area (NavigationDialog *nav_dialog,
(newwidth * gdisp->gimage->yresolution) / gdisp->gimage->xresolution;
nav_dialog->dispx =
((shell->gdisp->offset_x *
((shell->offset_x *
gdisp->gimage->yresolution * nav_dialog->ratio) /
(gdisp->gimage->xresolution * xratio)) + 0.5; /*here*/
nav_dialog->dispwidth =
((shell->gdisp->disp_width *
((shell->disp_width *
gdisp->gimage->yresolution * nav_dialog->ratio) /
(gdisp->gimage->xresolution * xratio)) + 0.5; /*here*/
}
@ -1222,8 +1222,8 @@ nav_dialog_update_real_view (NavigationDialog *nav_dialog,
nav_dialog->gdisp->gimage->xresolution) /
nav_dialog->gdisp->gimage->yresolution) + 0.5;
xoffset = xpnt - shell->gdisp->offset_x;
yoffset = ypnt - shell->gdisp->offset_y;
xoffset = xpnt - shell->offset_x;
yoffset = ypnt - shell->offset_y;
gimp_display_shell_scroll (shell, xoffset, yoffset);
}

View File

@ -38,9 +38,9 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplay-scroll.h"
#include "display/gimpdisplay-scale.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-scroll.h"
#include "display/gimpdisplayshell-scale.h"
#include "widgets/gimpnavigationpreview.h"
@ -175,8 +175,8 @@ nav_dialog_marker_changed (GimpNavigationPreview *nav_preview,
xratio = SCALEFACTOR_X (nav_dialog->gdisp);
yratio = SCALEFACTOR_Y (nav_dialog->gdisp);
xoffset = x * xratio - shell->gdisp->offset_x;
yoffset = y * yratio - shell->gdisp->offset_y;
xoffset = x * xratio - shell->offset_x;
yoffset = y * yratio - shell->offset_y;
gimp_display_shell_scroll (shell, xoffset, yoffset);
}
@ -714,17 +714,17 @@ nav_dialog_disp_area (NavigationDialog *nav_dialog,
gimp_navigation_preview_set_marker
(GIMP_NAVIGATION_PREVIEW (nav_dialog->new_preview),
RINT (shell->gdisp->offset_x / xratio),
RINT (shell->gdisp->offset_y / yratio),
RINT (shell->gdisp->disp_width / xratio),
RINT (shell->gdisp->disp_height / yratio));
RINT (shell->offset_x / xratio),
RINT (shell->offset_y / yratio),
RINT (shell->disp_width / xratio),
RINT (shell->disp_height / yratio));
}
nav_dialog->dispx = shell->gdisp->offset_x * nav_dialog->ratio / xratio + 0.5;
nav_dialog->dispy = shell->gdisp->offset_y * nav_dialog->ratio/yratio + 0.5;
nav_dialog->dispx = shell->offset_x * nav_dialog->ratio / xratio + 0.5;
nav_dialog->dispy = shell->offset_y * nav_dialog->ratio/yratio + 0.5;
nav_dialog->dispwidth = (shell->gdisp->disp_width * nav_dialog->ratio) / xratio + 0.5;
nav_dialog->dispheight = (shell->gdisp->disp_height * nav_dialog->ratio) / yratio + 0.5;
nav_dialog->dispwidth = (shell->disp_width * nav_dialog->ratio) / xratio + 0.5;
nav_dialog->dispheight = (shell->disp_height * nav_dialog->ratio) / yratio + 0.5;
newwidth = gimage->width;
newheight = gimage->height;
@ -735,12 +735,12 @@ nav_dialog_disp_area (NavigationDialog *nav_dialog,
(newwidth * gdisp->gimage->yresolution) / gdisp->gimage->xresolution;
nav_dialog->dispx =
((shell->gdisp->offset_x *
((shell->offset_x *
gdisp->gimage->yresolution * nav_dialog->ratio) /
(gdisp->gimage->xresolution * xratio)) + 0.5; /*here*/
nav_dialog->dispwidth =
((shell->gdisp->disp_width *
((shell->disp_width *
gdisp->gimage->yresolution * nav_dialog->ratio) /
(gdisp->gimage->xresolution * xratio)) + 0.5; /*here*/
}
@ -1222,8 +1222,8 @@ nav_dialog_update_real_view (NavigationDialog *nav_dialog,
nav_dialog->gdisp->gimage->xresolution) /
nav_dialog->gdisp->gimage->yresolution) + 0.5;
xoffset = xpnt - shell->gdisp->offset_x;
yoffset = ypnt - shell->gdisp->offset_y;
xoffset = xpnt - shell->offset_x;
yoffset = ypnt - shell->offset_y;
gimp_display_shell_scroll (shell, xoffset, yoffset);
}

View File

@ -34,7 +34,7 @@
#include "core/gimpcontainer.h"
#include "core/gimpimage.h"
#include "display/gimpdisplay-render.h"
#include "display/gimpdisplayshell-render.h"
#include "widgets/gimpdnd.h"

View File

@ -35,8 +35,8 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplay-render.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-render.h"
#include "display/gximage.h"
#include "widgets/gimpdialogfactory.h"

View File

@ -512,15 +512,20 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/View */
{ { N_("/View/Zoom In"), "equal",
view_zoomin_cmd_callback, 0,
view_zoom_in_cmd_callback, 0,
"<StockItem>", GTK_STOCK_ZOOM_IN },
NULL,
"view/zoom.html", NULL },
{ { N_("/View/Zoom Out"), "minus",
view_zoomout_cmd_callback, 0,
view_zoom_out_cmd_callback, 0,
"<StockItem>", GTK_STOCK_ZOOM_OUT },
NULL,
"view/zoom.html", NULL },
{ { N_("/View/Zoom to Fit Window"), NULL,
view_zoom_fit_cmd_callback, 0,
"<StockItem>", GTK_STOCK_ZOOM_FIT },
NULL,
"view/zoom.html", NULL },
/* <Image>/View/Zoom */

View File

@ -38,7 +38,7 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplay-render.h"
#include "display/gimpdisplayshell-render.h"
#include "tools/tool_manager.h"

View File

@ -30,9 +30,9 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplay-scale.h"
#include "display/gimpdisplay-selection.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-scale.h"
#include "info-dialog.h"
#include "info-window.h"
@ -49,7 +49,7 @@
void
view_zoomin_cmd_callback (GtkWidget *widget,
view_zoom_in_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
@ -59,7 +59,7 @@ view_zoomin_cmd_callback (GtkWidget *widget,
}
void
view_zoomout_cmd_callback (GtkWidget *widget,
view_zoom_out_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
@ -68,6 +68,16 @@ view_zoomout_cmd_callback (GtkWidget *widget,
gimp_display_shell_scale (GIMP_DISPLAY_SHELL (gdisp->shell), GIMP_ZOOM_OUT);
}
void
view_zoom_fit_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
gimp_display_shell_scale_fit (GIMP_DISPLAY_SHELL (gdisp->shell));
}
void
view_zoom_cmd_callback (GtkWidget *widget,
gpointer data,

View File

@ -20,9 +20,11 @@
#define __VIEW_COMMANDS_H__
void view_zoomin_cmd_callback (GtkWidget *widget,
void view_zoom_in_cmd_callback (GtkWidget *widget,
gpointer data);
void view_zoomout_cmd_callback (GtkWidget *widget,
void view_zoom_out_cmd_callback (GtkWidget *widget,
gpointer data);
void view_zoom_fit_cmd_callback (GtkWidget *widget,
gpointer data);
void view_zoom_cmd_callback (GtkWidget *widget,
gpointer data,

View File

@ -512,15 +512,20 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/View */
{ { N_("/View/Zoom In"), "equal",
view_zoomin_cmd_callback, 0,
view_zoom_in_cmd_callback, 0,
"<StockItem>", GTK_STOCK_ZOOM_IN },
NULL,
"view/zoom.html", NULL },
{ { N_("/View/Zoom Out"), "minus",
view_zoomout_cmd_callback, 0,
view_zoom_out_cmd_callback, 0,
"<StockItem>", GTK_STOCK_ZOOM_OUT },
NULL,
"view/zoom.html", NULL },
{ { N_("/View/Zoom to Fit Window"), NULL,
view_zoom_fit_cmd_callback, 0,
"<StockItem>", GTK_STOCK_ZOOM_FIT },
NULL,
"view/zoom.html", NULL },
/* <Image>/View/Zoom */

View File

@ -38,9 +38,9 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplay-scroll.h"
#include "display/gimpdisplay-scale.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-scroll.h"
#include "display/gimpdisplayshell-scale.h"
#include "widgets/gimpnavigationpreview.h"
@ -175,8 +175,8 @@ nav_dialog_marker_changed (GimpNavigationPreview *nav_preview,
xratio = SCALEFACTOR_X (nav_dialog->gdisp);
yratio = SCALEFACTOR_Y (nav_dialog->gdisp);
xoffset = x * xratio - shell->gdisp->offset_x;
yoffset = y * yratio - shell->gdisp->offset_y;
xoffset = x * xratio - shell->offset_x;
yoffset = y * yratio - shell->offset_y;
gimp_display_shell_scroll (shell, xoffset, yoffset);
}
@ -714,17 +714,17 @@ nav_dialog_disp_area (NavigationDialog *nav_dialog,
gimp_navigation_preview_set_marker
(GIMP_NAVIGATION_PREVIEW (nav_dialog->new_preview),
RINT (shell->gdisp->offset_x / xratio),
RINT (shell->gdisp->offset_y / yratio),
RINT (shell->gdisp->disp_width / xratio),
RINT (shell->gdisp->disp_height / yratio));
RINT (shell->offset_x / xratio),
RINT (shell->offset_y / yratio),
RINT (shell->disp_width / xratio),
RINT (shell->disp_height / yratio));
}
nav_dialog->dispx = shell->gdisp->offset_x * nav_dialog->ratio / xratio + 0.5;
nav_dialog->dispy = shell->gdisp->offset_y * nav_dialog->ratio/yratio + 0.5;
nav_dialog->dispx = shell->offset_x * nav_dialog->ratio / xratio + 0.5;
nav_dialog->dispy = shell->offset_y * nav_dialog->ratio/yratio + 0.5;
nav_dialog->dispwidth = (shell->gdisp->disp_width * nav_dialog->ratio) / xratio + 0.5;
nav_dialog->dispheight = (shell->gdisp->disp_height * nav_dialog->ratio) / yratio + 0.5;
nav_dialog->dispwidth = (shell->disp_width * nav_dialog->ratio) / xratio + 0.5;
nav_dialog->dispheight = (shell->disp_height * nav_dialog->ratio) / yratio + 0.5;
newwidth = gimage->width;
newheight = gimage->height;
@ -735,12 +735,12 @@ nav_dialog_disp_area (NavigationDialog *nav_dialog,
(newwidth * gdisp->gimage->yresolution) / gdisp->gimage->xresolution;
nav_dialog->dispx =
((shell->gdisp->offset_x *
((shell->offset_x *
gdisp->gimage->yresolution * nav_dialog->ratio) /
(gdisp->gimage->xresolution * xratio)) + 0.5; /*here*/
nav_dialog->dispwidth =
((shell->gdisp->disp_width *
((shell->disp_width *
gdisp->gimage->yresolution * nav_dialog->ratio) /
(gdisp->gimage->xresolution * xratio)) + 0.5; /*here*/
}
@ -1222,8 +1222,8 @@ nav_dialog_update_real_view (NavigationDialog *nav_dialog,
nav_dialog->gdisp->gimage->xresolution) /
nav_dialog->gdisp->gimage->yresolution) + 0.5;
xoffset = xpnt - shell->gdisp->offset_x;
yoffset = ypnt - shell->gdisp->offset_y;
xoffset = xpnt - shell->offset_x;
yoffset = ypnt - shell->offset_y;
gimp_display_shell_scroll (shell, xoffset, yoffset);
}

View File

@ -744,10 +744,10 @@ gimp_crop_tool_draw (GimpDrawTool *draw)
gdk_draw_line (draw->win, draw->gc,
crop->x1, crop->y1,
tool->gdisp->disp_width, crop->y1);
shell->disp_width, crop->y1);
gdk_draw_line (draw->win, draw->gc,
crop->x1, crop->y1,
crop->x1, tool->gdisp->disp_height);
crop->x1, shell->disp_height);
gdk_draw_line (draw->win, draw->gc,
crop->x2, crop->y2,
0, crop->y2);
@ -793,10 +793,6 @@ crop_tool_crop_image (GimpImage *gimage,
x1, y1, x2, y2,
layer_only,
crop_layers);
gdisplays_shrink_wrap (gimage);
gdisplays_flush ();
}
static void

View File

@ -28,8 +28,8 @@
#include "tools-types.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-scale.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-scale.h"
#include "gimpmagnifytool.h"
#include "tool_options.h"
@ -353,12 +353,13 @@ gimp_magnify_tool_button_release (GimpTool *tool,
y2 = y1 + h;
/* these change the user zoom level, so should not be changed to
* the resolution-aware scale macros -- austin */
* the resolution-aware scale macros -- austin
*/
scalesrc = SCALESRC (gdisp);
scaledest = SCALEDEST (gdisp);
win_width = gdisp->disp_width;
win_height = gdisp->disp_height;
win_width = shell->disp_width;
win_height = shell->disp_height;
width = (win_width * scalesrc) / scaledest;
height = (win_height * scalesrc) / scaledest;
@ -381,10 +382,10 @@ gimp_magnify_tool_button_release (GimpTool *tool,
gdisp->scale = (scaledest << 8) + scalesrc;
gdisp->offset_x = (scaledest * ((x1 + x2) / 2)) / scalesrc -
(win_width / 2);
gdisp->offset_y = (scaledest * ((y1 + y2) / 2)) / scalesrc -
(win_height / 2);
shell->offset_x = ((scaledest * ((x1 + x2) / 2)) / scalesrc -
(win_width / 2));
shell->offset_y = ((scaledest * ((y1 + y2) / 2)) / scalesrc -
(win_height / 2));
/* resize the image */
gimp_display_shell_scale_resize (shell, gimprc.allow_resize_windows, TRUE);

View File

@ -357,7 +357,7 @@ move_tool_button_release (GimpTool *tool,
&x1, &y1,
FALSE, FALSE);
gdisplay_untransform_coords (gdisp,
gdisp->disp_width, gdisp->disp_height,
shell->disp_width, shell->disp_height,
&x2, &y2,
FALSE, FALSE);

View File

@ -251,15 +251,13 @@ gimp_selection_tool_update_op_state (GimpSelectionTool *selection_tool,
layer = gimp_image_pick_correlate_layer (gdisp->gimage, tx, ty);
floating_sel = gimp_image_floating_sel (gdisp->gimage);
if (state & GDK_MOD1_MASK &&
!gimage_mask_is_empty (gdisp->gimage))
if ((state & GDK_MOD1_MASK) && ! gimage_mask_is_empty (gdisp->gimage))
{
selection_tool->op = SELECTION_MOVE_MASK; /* move just the selection mask */
selection_tool->op = SELECTION_MOVE_MASK; /* move the selection mask */
}
else if (!(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
layer &&
else if (! (state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) && layer &&
(layer == floating_sel ||
(gimage_mask_value (gdisp->gimage, x, y) &&
(gimage_mask_value (gdisp->gimage, tx, ty) &&
floating_sel == NULL)))
{
selection_tool->op = SELECTION_MOVE; /* move the selection */

View File

@ -602,7 +602,7 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
TransformUndo *tu;
PathUndo *pundo;
gboolean new_layer;
gint i, x, y;
gint i;
gimp_set_busy (gdisp->gimage->gimp);
@ -683,11 +683,17 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
*/
tool->preserve = FALSE;
#ifdef __GNUC__
#warning FIXME: investigate why display update was done here
#endif
#if 0
/* Flush the gdisplays */
if (gdisp->disp_xoffset || gdisp->disp_yoffset)
{
x = shell->canvas->allocation.width;
y = shell->canvas->allocation.height;
gint x, y;
x = shell->disp_width;
y = shell->disp_height;
if (gdisp->disp_yoffset)
{
@ -710,6 +716,7 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
gdisp->disp_width, gdisp->disp_height);
}
}
#endif
gimp_unset_busy (gdisp->gimage->gimp);

View File

@ -234,7 +234,13 @@ tool_manager_select_tool (Gimp *gimp,
tool_manager = tool_manager_get (gimp);
if (tool_manager->active_tool)
{
tool_manager_control_active (gimp,
HALT,
tool_manager->active_tool->gdisp);
g_object_unref (G_OBJECT (tool_manager->active_tool));
}
tool_manager->active_tool = tool;
}

View File

@ -394,10 +394,8 @@ pop_stack (GimpImage *gimage,
Undo *object;
GSList *stack;
GSList *tmp;
gint status = 0;
gint in_group = 0;
gint x, y;
GimpDisplay *gdisp;
gboolean status = FALSE;
gboolean in_group = FALSE;
/* Keep popping until we pop a valid object
* or get to the end of a group if we're in one
@ -407,21 +405,26 @@ pop_stack (GimpImage *gimage,
stack = *stack_ptr;
object = (Undo *) stack->data;
if (object->group_boundary)
{
in_group = (in_group) ? 0 : 1;
in_group = ! in_group;
if (in_group)
gimage->undo_levels += (state == UNDO) ? -1 : 1;
if (status && ! in_group)
status = 1;
status = TRUE;
else
status = 0;
status = FALSE;
}
else
{
TRC (("undo_pop: %s\n", undo_type_to_name (object->type)));
status = (* object->pop_func) (gimage, state, object->type,
status = (* object->pop_func) (gimage,
state,
object->type,
object->data);
if (object->dirties_image)
@ -441,7 +444,7 @@ pop_stack (GimpImage *gimage,
gimage->undo_levels += (state == UNDO) ? -1 : 1;
}
*unstack_ptr = g_slist_prepend (*unstack_ptr, (gpointer) object);
*unstack_ptr = g_slist_prepend (*unstack_ptr, object);
tmp = stack;
*stack_ptr = g_slist_next (*stack_ptr);
@ -450,6 +453,13 @@ pop_stack (GimpImage *gimage,
if (status && ! in_group)
{
#ifdef __GNUC__
#warning FIXME: investigate why display update was done here
#endif
#if 0
GimpDisplay *gdisp;
gint x, y;
/* Flush any image updates and displays */
gdisp = gimp_context_get_display (gimp_get_user_context (gimage->gimp));
@ -488,8 +498,7 @@ pop_stack (GimpImage *gimage,
}
}
}
gdisplays_flush ();
#endif
/* If the mode_changed flag was set */
if (mode_changed)
@ -527,6 +536,8 @@ pop_stack (GimpImage *gimage,
gimp_image_undo_event (gimage,
(state == UNDO)? UNDO_POPPED : UNDO_REDO);
gdisplays_flush ();
return TRUE;
}
}

View File

@ -34,7 +34,7 @@
#include "core/gimpcontainer.h"
#include "core/gimpimage.h"
#include "display/gimpdisplay-render.h"
#include "display/gimpdisplayshell-render.h"
#include "widgets/gimpdnd.h"

View File

@ -512,15 +512,20 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/View */
{ { N_("/View/Zoom In"), "equal",
view_zoomin_cmd_callback, 0,
view_zoom_in_cmd_callback, 0,
"<StockItem>", GTK_STOCK_ZOOM_IN },
NULL,
"view/zoom.html", NULL },
{ { N_("/View/Zoom Out"), "minus",
view_zoomout_cmd_callback, 0,
view_zoom_out_cmd_callback, 0,
"<StockItem>", GTK_STOCK_ZOOM_OUT },
NULL,
"view/zoom.html", NULL },
{ { N_("/View/Zoom to Fit Window"), NULL,
view_zoom_fit_cmd_callback, 0,
"<StockItem>", GTK_STOCK_ZOOM_FIT },
NULL,
"view/zoom.html", NULL },
/* <Image>/View/Zoom */

View File

@ -44,7 +44,7 @@
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "display/gimpdisplay-render.h"
#include "display/gimpdisplayshell-render.h"
#include "gimpbrushpreview.h"
#include "gimpbufferpreview.h"

View File

@ -44,7 +44,7 @@
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "display/gimpdisplay-render.h"
#include "display/gimpdisplayshell-render.h"
#include "gimpbrushpreview.h"
#include "gimpbufferpreview.h"

View File

@ -44,7 +44,7 @@
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "display/gimpdisplay-render.h"
#include "display/gimpdisplayshell-render.h"
#include "gimpbrushpreview.h"
#include "gimpbufferpreview.h"

View File

@ -44,7 +44,7 @@
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "display/gimpdisplay-render.h"
#include "display/gimpdisplayshell-render.h"
#include "gimpbrushpreview.h"
#include "gimpbufferpreview.h"

View File

@ -1,3 +1,7 @@
2001-11-02 Michael Natterer <mitch@gimp.org>
* POTFILES.in: gimpdisplay-callbacks.c -> gimpdisplayshell-callbacks.
2001-10-31 Michael Natterer <mitch@gimp.org>
* POTFILES.in: updated.

View File

@ -34,9 +34,9 @@ app/core/gimppalette.c
app/core/gimppattern.c
app/core/gimpunit.c
app/display/gimpdisplay-callbacks.c
app/display/gimpdisplay.c
app/display/gimpdisplayshell.c
app/display/gimpdisplayshell-callbacks.c
app/file/file-open.c
app/file/file-save.c