Commit d162376d authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

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.
parent 6033ef8f
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...
......
......@@ -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,8 +49,8 @@
void
view_zoomin_cmd_callback (GtkWidget *widget,
gpointer data)
view_zoom_in_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
......@@ -59,8 +59,8 @@ view_zoomin_cmd_callback (GtkWidget *widget,
}
void
view_zoomout_cmd_callback (GtkWidget *widget,
gpointer data)
view_zoom_out_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
......@@ -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,
......
......@@ -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,
......
......@@ -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);
......
......@@ -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);
......
......@@ -391,13 +391,11 @@ pop_stack (GimpImage *gimage,
GSList **unstack_ptr,
UndoState state)
{
Undo *object;
GSList *stack;
GSList *tmp;
gint status = 0;
gint in_group = 0;
gint x, y;
GimpDisplay *gdisp;
Undo *object;
GSList *stack;
GSList *tmp;
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;
if (status && ! in_group)
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)
......@@ -437,19 +440,26 @@ pop_stack (GimpImage *gimage,
}
}
if (!in_group)
if (! in_group)
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);
tmp->next = NULL;
g_slist_free (tmp);
if (status && !in_group)
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;
}
}
......
......@@ -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
......
......@@ -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? */
......
......@@ -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"
......
......@@ -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 \
......
This diff is collapsed.
/* 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__ */
......@@ -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)
{
......
......@@ -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);
......