1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
2000-01-14 20:41:00 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-03-02 03:32:41 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpdisplayconfig.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2001-12-29 01:36:58 +08:00
|
|
|
#include "core/gimpimage.h"
|
2001-11-20 21:53:21 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "display/gimpdisplayshell-scale.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
|
2002-03-19 06:26:41 +08:00
|
|
|
#include "widgets/gimpenummenu.h"
|
2002-12-20 00:33:29 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2002-03-19 06:26:41 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "gimpmagnifyoptions.h"
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "gimpmagnifytool.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-16 08:37:09 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
static void gimp_magnify_tool_class_init (GimpMagnifyToolClass *klass);
|
|
|
|
static void gimp_magnify_tool_init (GimpMagnifyTool *tool);
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
static void gimp_magnify_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_magnify_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_magnify_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_magnify_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_magnify_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
|
|
|
|
static void gimp_magnify_tool_draw (GimpDrawTool *draw_tool);
|
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
static void zoom_in (gint *src,
|
|
|
|
gint *dest,
|
|
|
|
gint scale);
|
|
|
|
static void zoom_out (gint *src,
|
|
|
|
gint *dest,
|
|
|
|
gint scale);
|
1999-06-22 06:12:07 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
static GimpDrawToolClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
/* public functions */
|
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_magnify_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
2001-03-04 00:22:18 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_MAGNIFY_TOOL,
|
2003-02-05 22:39:40 +08:00
|
|
|
GIMP_TYPE_MAGNIFY_OPTIONS,
|
|
|
|
gimp_magnify_options_gui,
|
2001-11-21 07:00:47 +08:00
|
|
|
FALSE,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-magnify-tool",
|
2001-11-21 07:00:47 +08:00
|
|
|
_("Magnify"),
|
|
|
|
_("Zoom in & out"),
|
|
|
|
N_("/Tools/Magnify"), NULL,
|
|
|
|
NULL, "tools/magnify.html",
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_ZOOM,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-03-04 00:22:18 +08:00
|
|
|
}
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2001-03-04 00:22:18 +08:00
|
|
|
gimp_magnify_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static GType tool_type = 0;
|
2001-03-04 00:22:18 +08:00
|
|
|
|
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static const GTypeInfo tool_info =
|
2001-03-04 00:22:18 +08:00
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
sizeof (GimpMagnifyToolClass),
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_magnify_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
2001-03-04 00:22:18 +08:00
|
|
|
sizeof (GimpMagnifyTool),
|
2001-08-14 22:53:55 +08:00
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_magnify_tool_init,
|
2001-03-04 00:22:18 +08:00
|
|
|
};
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_DRAW_TOOL,
|
|
|
|
"GimpMagnifyTool",
|
|
|
|
&tool_info, 0);
|
2001-03-04 00:22:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
|
|
|
}
|
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
static void
|
|
|
|
gimp_magnify_tool_class_init (GimpMagnifyToolClass *klass)
|
|
|
|
{
|
|
|
|
GimpToolClass *tool_class;
|
|
|
|
GimpDrawToolClass *draw_tool_class;
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
2001-03-04 00:22:18 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-03-04 00:22:18 +08:00
|
|
|
|
|
|
|
tool_class->button_press = gimp_magnify_tool_button_press;
|
|
|
|
tool_class->button_release = gimp_magnify_tool_button_release;
|
|
|
|
tool_class->motion = gimp_magnify_tool_motion;
|
|
|
|
tool_class->modifier_key = gimp_magnify_tool_modifier_key;
|
|
|
|
tool_class->cursor_update = gimp_magnify_tool_cursor_update;
|
|
|
|
|
|
|
|
draw_tool_class->draw = gimp_magnify_tool_draw;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_magnify_tool_init (GimpMagnifyTool *magnify_tool)
|
|
|
|
{
|
|
|
|
GimpTool *tool;
|
|
|
|
|
|
|
|
tool = GIMP_TOOL (magnify_tool);
|
|
|
|
|
|
|
|
magnify_tool->x = 0;
|
|
|
|
magnify_tool->y = 0;
|
|
|
|
magnify_tool->w = 0;
|
|
|
|
magnify_tool->h = 0;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2002-05-03 05:03:27 +08:00
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
|
|
|
gimp_tool_control_set_snap_to (tool->control, FALSE);
|
2002-09-27 23:51:57 +08:00
|
|
|
|
2002-06-17 01:13:39 +08:00
|
|
|
gimp_tool_control_set_cursor (tool->control,
|
|
|
|
GIMP_ZOOM_CURSOR);
|
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
|
|
|
GIMP_ZOOM_TOOL_CURSOR);
|
|
|
|
gimp_tool_control_set_cursor_modifier (tool->control,
|
|
|
|
GIMP_CURSOR_MODIFIER_PLUS);
|
2002-09-27 23:51:57 +08:00
|
|
|
|
|
|
|
gimp_tool_control_set_toggle_cursor (tool->control,
|
2002-06-17 01:13:39 +08:00
|
|
|
GIMP_ZOOM_CURSOR);
|
|
|
|
gimp_tool_control_set_toggle_tool_cursor (tool->control,
|
|
|
|
GIMP_ZOOM_TOOL_CURSOR);
|
|
|
|
gimp_tool_control_set_toggle_cursor_modifier (tool->control,
|
|
|
|
GIMP_CURSOR_MODIFIER_MINUS);
|
2001-03-04 00:22:18 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_magnify_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-05 19:35:03 +08:00
|
|
|
GimpMagnifyTool *magnify;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
magnify = GIMP_MAGNIFY_TOOL (tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
magnify->x = coords->x;
|
|
|
|
magnify->y = coords->y;
|
1997-11-25 06:05:25 +08:00
|
|
|
magnify->w = 0;
|
|
|
|
magnify->h = 0;
|
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_activate (tool->control);
|
2001-11-09 03:14:51 +08:00
|
|
|
tool->gdisp = gdisp;
|
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_magnify_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpMagnifyTool *magnify;
|
|
|
|
GimpMagnifyOptions *options;
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gint win_width, win_height;
|
|
|
|
gint width, height;
|
|
|
|
gint scalesrc, scaledest;
|
|
|
|
gint scale;
|
|
|
|
gint x1, y1, x2, y2, w, h;
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
magnify = GIMP_MAGNIFY_TOOL (tool);
|
2003-02-05 22:39:40 +08:00
|
|
|
options = GIMP_MAGNIFY_OPTIONS (tool->tool_info->tool_options);
|
2001-11-20 21:53:21 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell);
|
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
2003-01-03 21:59:23 +08:00
|
|
|
gimp_tool_control_halt (tool->control);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* First take care of the case where the user "cancels" the action */
|
2001-11-09 03:14:51 +08:00
|
|
|
if (! (state & GDK_BUTTON3_MASK))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
x1 = (magnify->w < 0) ? magnify->x + magnify->w : magnify->x;
|
|
|
|
y1 = (magnify->h < 0) ? magnify->y + magnify->h : magnify->y;
|
2001-11-02 18:55:10 +08:00
|
|
|
w = (magnify->w < 0) ? -magnify->w : magnify->w;
|
|
|
|
h = (magnify->h < 0) ? -magnify->h : magnify->h;
|
1997-11-25 06:05:25 +08:00
|
|
|
x2 = x1 + w;
|
|
|
|
y2 = y1 + h;
|
|
|
|
|
1998-12-06 05:48:37 +08:00
|
|
|
/* these change the user zoom level, so should not be changed to
|
2001-11-02 17:31:21 +08:00
|
|
|
* the resolution-aware scale macros -- austin
|
|
|
|
*/
|
2002-06-27 06:16:59 +08:00
|
|
|
scalesrc = SCALESRC (shell);
|
|
|
|
scaledest = SCALEDEST (shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
win_width = shell->disp_width;
|
|
|
|
win_height = shell->disp_height;
|
2001-03-04 00:22:18 +08:00
|
|
|
width = (win_width * scalesrc) / scaledest;
|
1997-11-25 06:05:25 +08:00
|
|
|
height = (win_height * scalesrc) / scaledest;
|
|
|
|
|
2001-12-29 01:36:58 +08:00
|
|
|
/* we need to compute the mouse movement in screen coordinates */
|
2002-06-27 06:16:59 +08:00
|
|
|
if ( (SCALEX (shell, w) < options->threshold) ||
|
|
|
|
(SCALEY (shell, h) < options->threshold) )
|
1997-11-25 06:05:25 +08:00
|
|
|
scale = 1;
|
|
|
|
else
|
2000-01-26 07:06:12 +08:00
|
|
|
scale = MIN ((width / w), (height / h));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
magnify->op = options->type;
|
2000-03-02 03:32:41 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (magnify->op)
|
|
|
|
{
|
2001-03-04 00:22:18 +08:00
|
|
|
case GIMP_ZOOM_IN:
|
1997-11-25 06:05:25 +08:00
|
|
|
zoom_in (&scalesrc, &scaledest, scale);
|
|
|
|
break;
|
2001-03-04 00:22:18 +08:00
|
|
|
case GIMP_ZOOM_OUT:
|
1997-11-25 06:05:25 +08:00
|
|
|
zoom_out (&scalesrc, &scaledest, scale);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-02-17 19:46:39 +08:00
|
|
|
gimp_display_shell_scale_by_values (shell,
|
|
|
|
(scaledest << 8) + scalesrc,
|
|
|
|
((scaledest * ((x1 + x2) / 2)) / scalesrc -
|
|
|
|
(win_width / 2)),
|
|
|
|
((scaledest * ((y1 + y2) / 2)) / scalesrc -
|
|
|
|
(win_height / 2)),
|
2002-04-28 22:35:01 +08:00
|
|
|
options->allow_resize);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_magnify_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-03-04 00:22:18 +08:00
|
|
|
GimpMagnifyTool *magnify;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
if (!gimp_tool_control_is_active (tool->control))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
magnify = GIMP_MAGNIFY_TOOL (tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-06 18:55:40 +08:00
|
|
|
magnify->w = (coords->x - magnify->x);
|
|
|
|
magnify->h = (coords->y - magnify->y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-03-02 03:32:41 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_magnify_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
2000-03-02 03:32:41 +08:00
|
|
|
{
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpMagnifyOptions *options;
|
2001-11-20 21:53:21 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
options = GIMP_MAGNIFY_OPTIONS (tool->tool_info->tool_options);
|
2001-11-20 21:53:21 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if (key == GDK_CONTROL_MASK)
|
2000-03-02 03:32:41 +08:00
|
|
|
{
|
2001-11-20 21:53:21 +08:00
|
|
|
switch (options->type)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
case GIMP_ZOOM_IN:
|
2002-03-19 06:26:41 +08:00
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w),
|
2001-11-23 01:11:52 +08:00
|
|
|
GINT_TO_POINTER (GIMP_ZOOM_OUT));
|
2001-11-09 03:14:51 +08:00
|
|
|
break;
|
|
|
|
case GIMP_ZOOM_OUT:
|
2002-03-19 06:26:41 +08:00
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w),
|
2001-11-23 01:11:52 +08:00
|
|
|
GINT_TO_POINTER (GIMP_ZOOM_IN));
|
2001-11-09 03:14:51 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2000-03-02 03:32:41 +08:00
|
|
|
}
|
|
|
|
}
|
2001-03-04 00:22:18 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_magnify_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpMagnifyOptions *options;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
options = GIMP_MAGNIFY_OPTIONS (tool->tool_info->tool_options);
|
2001-11-20 21:53:21 +08:00
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_set_toggle (tool->control, (options->type == GIMP_ZOOM_OUT));
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2002-02-05 01:43:01 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
static void
|
|
|
|
gimp_magnify_tool_draw (GimpDrawTool *draw_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpMagnifyTool *magnify;
|
|
|
|
GimpMagnifyOptions *options;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
magnify = GIMP_MAGNIFY_TOOL (draw_tool);
|
2003-02-05 22:39:40 +08:00
|
|
|
options = GIMP_MAGNIFY_OPTIONS (GIMP_TOOL (draw_tool)->tool_info->tool_options);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-12 22:45:58 +08:00
|
|
|
gimp_draw_tool_draw_rectangle (draw_tool,
|
|
|
|
FALSE,
|
|
|
|
magnify->x,
|
|
|
|
magnify->y,
|
|
|
|
magnify->w,
|
|
|
|
magnify->h,
|
|
|
|
FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-11-20 21:53:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* magnify utility functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
zoom_in (gint *src,
|
|
|
|
gint *dest,
|
|
|
|
gint scale)
|
|
|
|
{
|
|
|
|
while (scale--)
|
|
|
|
{
|
|
|
|
if (*src > 1)
|
|
|
|
(*src)--;
|
|
|
|
else
|
|
|
|
if (*dest < 0x10)
|
|
|
|
(*dest)++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
zoom_out (gint *src,
|
|
|
|
gint *dest,
|
|
|
|
gint scale)
|
|
|
|
{
|
|
|
|
while (scale--)
|
|
|
|
{
|
|
|
|
if (*dest > 1)
|
|
|
|
(*dest)--;
|
|
|
|
else
|
|
|
|
if (*src < 0x10)
|
|
|
|
(*src)++;
|
|
|
|
}
|
|
|
|
}
|