Files
gimp/plug-ins/imagemap/imap_cmd_move.c
Michael Natterer 14d0a3ff07 app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c
2001-12-29  Michael Natterer  <mitch@gimp.org>

	* app/gimpprogress.c
	* app/nav_window.c
	* app/ops_buttons.c
	* app/undo_history.c
	* app/display/gimpdisplayshell.c
	* app/gui/about-dialog.c
	* app/gui/brush-editor.c
	* app/gui/channels-commands.c
	* app/gui/color-area.c
	* app/gui/color-notebook.c
	* app/gui/color-select.c
	* app/gui/colormap-dialog.c
	* app/gui/convert-dialog.c
	* app/gui/device-status-dialog.c
	* app/gui/file-new-dialog.c
	* app/gui/file-open-dialog.c
	* app/gui/file-save-dialog.c
	* app/gui/gradient-editor.c
	* app/gui/info-dialog.c
	* app/gui/layers-commands.c
	* app/gui/module-browser.c
	* app/gui/offset-dialog.c
	* app/gui/palette-editor.c
	* app/gui/palettes-commands.c
	* app/gui/paths-dialog.c
	* app/gui/qmask-commands.c
	* app/gui/resize-dialog.c
	* app/gui/resolution-calibrate-dialog.c
	* app/gui/splash.c
	* app/gui/tips-dialog.c
	* app/gui/toolbox.c
	* app/gui/user-install-dialog.c
	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpbycolorselecttool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimpcolorpickertool.c
	* app/tools/gimpcroptool.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimphuesaturationtool.c
	* app/tools/gimpinktool.c
	* app/tools/gimplevelstool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimprotatetool.c
	* app/tools/gimpthresholdtool.c
	* app/tools/paint_options.c
	* app/tools/selection_options.c
	* app/widgets/gimpchannellistview.c
	* app/widgets/gimpcolorpanel.c
	* app/widgets/gimpcomponentlistitem.c
	* app/widgets/gimpconstrainedhwrapbox.c
	* app/widgets/gimpcontainergridview.c
	* app/widgets/gimpcontainerlistview.c
	* app/widgets/gimpcontainermenuimpl.c
	* app/widgets/gimpdialogfactory.c
	* app/widgets/gimpdnd.c
	* app/widgets/gimpdock.c
	* app/widgets/gimpdockbook.c
	* app/widgets/gimpdrawablelistitem.c
	* app/widgets/gimpdrawablelistview.c
	* app/widgets/gimpfontselection-dialog.c
	* app/widgets/gimphistogramview.c
	* app/widgets/gimpitemfactory.c
	* app/widgets/gimplayerlistitem.c
	* app/widgets/gimplistitem.[ch]
	* app/widgets/gimpmenuitem.c
	* app/widgets/gimppreview.[ch]
	* app/widgets/gtkhwrapbox.c
	* app/widgets/gtkvwrapbox.c
	* app/widgets/gtkwrapbox.c
	* libgimp/gimpbrushmenu.c
	* libgimp/gimpexport.c
	* libgimp/gimpgradientmenu.c
	* libgimp/gimpmenu.c
	* libgimp/gimppatternmenu.c
	* libgimpwidgets/gimpbutton.c
	* libgimpwidgets/gimpchainbutton.[ch]
	* libgimpwidgets/gimpcolorarea.h
	* libgimpwidgets/gimpcolorbutton.c
	* libgimpwidgets/gimpfileselection.c
	* libgimpwidgets/gimphelpui.c
	* libgimpwidgets/gimpoffsetarea.c
	* libgimpwidgets/gimppatheditor.c
	* libgimpwidgets/gimppixmap.h
	* libgimpwidgets/gimpquerybox.c
	* libgimpwidgets/gimpstock.[ch]
	* libgimpwidgets/gimpwidgets.h
	* plug-ins/FractalExplorer/Dialogs.c
	* plug-ins/FractalExplorer/Events.c
	* plug-ins/FractalExplorer/FractalExplorer.c
	* plug-ins/Lighting/lighting_ui.c
	* plug-ins/MapObject/mapobject_ui.c
	* plug-ins/bmp/bmpwrite.c
	* plug-ins/dbbrowser/dbbrowser_utils.c
	* plug-ins/fits/fits.c
	* plug-ins/flame/flame.c
	* plug-ins/fp/fp_gtk.c
	* plug-ins/fp/fp_misc.c
	* plug-ins/gfig/gfig.c
	* plug-ins/gflare/gflare.c
	* plug-ins/gfli/gfli.c
	* plug-ins/gimpressionist/*.c
	* plug-ins/imagemap/*.[ch]
	* plug-ins/maze/maze_face.c
	* plug-ins/mosaic/mosaic.c
	* plug-ins/pagecurl/pagecurl.c
	* plug-ins/print/print_gimp.h
	* plug-ins/rcm/rcm_callback.c
	* plug-ins/rcm/rcm_dialog.c
	* plug-ins/rcm/rcm_misc.c
	* plug-ins/script-fu/script-fu-console.c
	* plug-ins/script-fu/script-fu-scripts.c
	* plug-ins/script-fu/script-fu-server.c
	* plug-ins/sel2path/sel2path.c
	* plug-ins/sel2path/sel2path_adv_dialog.c
	* plug-ins/sgi/sgi.c
	* plug-ins/webbrowser/webbrowser.c
	* plug-ins/xjt/xjt.c
	* plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED
	defined. Not everything is fully ported yet, had to #undef
	GTK_DISABLE_DEPRECATED in many places and added #warnings when
	doing so.

	* pixmaps/Makefile.am
	* pixmaps/chain.xpm: removed.

	* themes/Default/Makefile.am
	* themes/Default/images/Makefile.am
	* themes/Default/images/stock-button-hchain-broken.png
	* themes/Default/images/stock-button-hchain.png
	* themes/Default/images/stock-button-vchain-broken.png
	* themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 13:26:29 +00:00

172 lines
5.2 KiB
C

/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 <gtk/gtk.h>
#include "libgimp/gimp.h"
#include "imap_cmd_move.h"
#include "imap_cmd_object_move.h"
#include "imap_main.h"
#include "libgimp/stdplugins-intl.h"
static void move_command_destruct(Command_t *parent);
static CmdExecuteValue_t move_command_execute(Command_t *parent);
CommandClass_t move_command_class = {
move_command_destruct,
move_command_execute,
NULL, /* move_command_undo */
NULL /* move_command_redo */
};
typedef struct {
Command_t parent;
PreferencesData_t *preferences;
Preview_t *preview;
Object_t *obj;
gint start_x;
gint start_y;
gint obj_start_x;
gint obj_start_y;
gint obj_x;
gint obj_y;
gint obj_width;
gint obj_height;
gint image_width;
gint image_height;
GdkCursorType cursor; /* Remember previous cursor */
gboolean moved_first_time;
} MoveCommand_t;
Command_t*
move_command_new(Preview_t *preview, Object_t *obj, gint x, gint y)
{
MoveCommand_t *command = g_new(MoveCommand_t, 1);
command->preferences = get_preferences();
command->preview = preview;
command->obj = object_ref(obj);
command->start_x = x;
command->start_y = y;
object_get_dimensions(obj, &command->obj_x, &command->obj_y,
&command->obj_width, &command->obj_height);
command->obj_start_x = command->obj_x;
command->obj_start_y = command->obj_y;
command->image_width = get_image_width();
command->image_height = get_image_height();
command->moved_first_time = TRUE;
return command_init(&command->parent, _("Move"), &move_command_class);
}
static void
move_command_destruct(Command_t *parent)
{
MoveCommand_t *command = (MoveCommand_t*) parent;
object_unref(command->obj);
}
static void
button_motion(GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
MoveCommand_t *command = (MoveCommand_t*) data;
Object_t *obj = command->obj;
gint dx = get_real_coord((gint) event->x) - command->start_x;
gint dy = get_real_coord((gint) event->y) - command->start_y;
if (command->moved_first_time) {
command->moved_first_time = FALSE;
command->cursor = preview_set_cursor(command->preview, GDK_FLEUR);
gdk_gc_set_function(command->preferences->normal_gc, GDK_EQUIV);
gdk_gc_set_function(command->preferences->selected_gc, GDK_EQUIV);
hide_url();
}
if (command->obj_x + dx < 0)
dx = -command->obj_x;
if (command->obj_x + command->obj_width + dx > command->image_width)
dx = command->image_width - command->obj_width - command->obj_x;
if (command->obj_y + dy < 0)
dy = -command->obj_y;
if (command->obj_y + command->obj_height + dy > command->image_height)
dy = command->image_height - command->obj_height - command->obj_y;
if (dx || dy) {
command->start_x = get_real_coord((gint) event->x);
command->start_y = get_real_coord((gint) event->y);
command->obj_x += dx;
command->obj_y += dy;
object_draw(obj, widget->window);
object_move(obj, dx, dy);
object_draw(obj, widget->window);
}
}
static void
button_release(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
MoveCommand_t *command = (MoveCommand_t*) data;
g_signal_handlers_disconnect_by_func (G_OBJECT(widget),
button_motion, data);
g_signal_handlers_disconnect_by_func (G_OBJECT(widget),
button_release, data);
if (!command->moved_first_time) {
preview_set_cursor(command->preview, command->cursor);
gdk_gc_set_function(command->preferences->normal_gc, GDK_COPY);
gdk_gc_set_function(command->preferences->selected_gc, GDK_COPY);
show_url();
}
command->obj_x -= command->obj_start_x;
command->obj_y -= command->obj_start_y;
if (command->obj_x || command->obj_y)
command_list_add(object_move_command_new(command->obj, command->obj_x,
command->obj_y));
preview_thaw();
}
static CmdExecuteValue_t
move_command_execute(Command_t *parent)
{
MoveCommand_t *command = (MoveCommand_t*) parent;
GtkWidget *widget = command->preview->preview;
preview_freeze();
g_signal_connect(G_OBJECT(widget), "button_release_event",
G_CALLBACK (button_release), command);
g_signal_connect(G_OBJECT(widget), "motion_notify_event",
G_CALLBACK (button_motion), command);
return CMD_DESTRUCT;
}