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"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
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"
|
|
|
|
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "gimpmagnifytool.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "tool_options.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "gimprc.h"
|
|
|
|
|
1998-12-16 08:37:09 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
typedef struct _MagnifyOptions MagnifyOptions;
|
2000-01-14 20:41:00 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
struct _MagnifyOptions
|
|
|
|
{
|
2001-07-18 04:50:01 +08:00
|
|
|
GimpToolOptions tool_options;
|
1999-04-13 01:55:06 +08:00
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
/* gint resize_windows_on_zoom; (from gimprc) */
|
2001-03-04 00:22:18 +08:00
|
|
|
gint allow_resize_d;
|
|
|
|
GtkWidget *allow_resize_w;
|
2000-03-02 03:32:41 +08:00
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
GimpZoomType type;
|
|
|
|
GimpZoomType type_d;
|
2002-03-19 06:26:41 +08:00
|
|
|
GtkWidget *type_w;
|
2001-12-29 01:36:58 +08:00
|
|
|
|
|
|
|
gdouble threshold;
|
2001-12-28 02:33:25 +08:00
|
|
|
gdouble threshold_d;
|
2001-12-29 01:36:58 +08:00
|
|
|
GtkObject *threshold_w;
|
1999-04-09 06:25:54 +08:00
|
|
|
};
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* magnify action functions */
|
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
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
static GimpToolOptions * magnify_options_new (GimpToolInfo *tool_info);
|
|
|
|
static void magnify_options_reset (GimpToolOptions *tool_options);
|
2001-03-04 00:22:18 +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
|
2001-11-21 07:00:47 +08:00
|
|
|
gimp_magnify_tool_register (Gimp *gimp,
|
|
|
|
GimpToolRegisterCallback callback)
|
2001-03-04 00:22:18 +08:00
|
|
|
{
|
2001-11-21 07:00:47 +08:00
|
|
|
(* callback) (gimp,
|
|
|
|
GIMP_TYPE_MAGNIFY_TOOL,
|
|
|
|
magnify_options_new,
|
|
|
|
FALSE,
|
|
|
|
"gimp:magnify_tool",
|
|
|
|
_("Magnify"),
|
|
|
|
_("Zoom in & out"),
|
|
|
|
N_("/Tools/Magnify"), NULL,
|
|
|
|
NULL, "tools/magnify.html",
|
|
|
|
GIMP_STOCK_TOOL_ZOOM);
|
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-02-05 01:43:01 +08:00
|
|
|
tool->cursor = GIMP_ZOOM_CURSOR;
|
|
|
|
tool->tool_cursor = GIMP_ZOOM_TOOL_CURSOR;
|
|
|
|
tool->cursor_modifier = GIMP_CURSOR_MODIFIER_PLUS;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2002-02-05 01:43:01 +08:00
|
|
|
tool->toggle_cursor = GIMP_ZOOM_CURSOR;
|
|
|
|
tool->toggle_tool_cursor = GIMP_ZOOM_TOOL_CURSOR;
|
|
|
|
tool->toggle_cursor_modifier = GIMP_CURSOR_MODIFIER_MINUS;
|
|
|
|
|
|
|
|
tool->scroll_lock = TRUE; /* Disallow scrolling */
|
|
|
|
tool->auto_snap_to = FALSE; /* Don't snap to guides */
|
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;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
tool->state = ACTIVE;
|
|
|
|
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
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpMagnifyTool *magnify;
|
2001-11-20 21:53:21 +08:00
|
|
|
MagnifyOptions *options;
|
2001-11-01 05:20:09 +08:00
|
|
|
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);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
options = (MagnifyOptions *) tool->tool_info->tool_options;
|
|
|
|
|
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));
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
tool->state = INACTIVE;
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
*/
|
2001-03-04 00:22:18 +08:00
|
|
|
scalesrc = SCALESRC (gdisp);
|
2000-01-26 07:06:12 +08:00
|
|
|
scaledest = SCALEDEST (gdisp);
|
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 */
|
|
|
|
if ( (SCALEX (gdisp, w) < options->threshold) ||
|
|
|
|
(SCALEY (gdisp, 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)),
|
|
|
|
gimprc.resize_windows_on_zoom);
|
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
|
|
|
|
|
|
|
if (tool->state != ACTIVE)
|
|
|
|
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
|
|
|
|
2001-11-09 03:14:51 +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
|
|
|
{
|
2001-11-20 21:53:21 +08:00
|
|
|
MagnifyOptions *options;
|
|
|
|
|
|
|
|
options = (MagnifyOptions *) tool->tool_info->tool_options;
|
|
|
|
|
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
|
|
|
{
|
2002-02-05 01:43:01 +08:00
|
|
|
MagnifyOptions *options;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
options = (MagnifyOptions *) tool->tool_info->tool_options;
|
|
|
|
|
2002-02-05 01:43:01 +08:00
|
|
|
tool->toggled = (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
|
|
|
{
|
2001-03-04 00:22:18 +08:00
|
|
|
GimpMagnifyTool *magnify;
|
2001-12-29 01:36:58 +08:00
|
|
|
MagnifyOptions *options;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-04 00:22:18 +08:00
|
|
|
magnify = GIMP_MAGNIFY_TOOL (draw_tool);
|
2001-12-29 01:36:58 +08:00
|
|
|
options = (MagnifyOptions *) 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)++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* magnify tool options functions */
|
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
static GimpToolOptions *
|
|
|
|
magnify_options_new (GimpToolInfo *tool_info)
|
2001-11-20 21:53:21 +08:00
|
|
|
{
|
|
|
|
MagnifyOptions *options;
|
2001-11-21 07:00:47 +08:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *frame;
|
2002-03-09 02:30:40 +08:00
|
|
|
GtkWidget *table;
|
2001-11-20 21:53:21 +08:00
|
|
|
|
|
|
|
options = g_new0 (MagnifyOptions, 1);
|
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
tool_options_init ((GimpToolOptions *) options, tool_info);
|
|
|
|
|
|
|
|
((GimpToolOptions *) options)->reset_func = magnify_options_reset;
|
2001-11-20 21:53:21 +08:00
|
|
|
|
|
|
|
options->allow_resize_d = gimprc.resize_windows_on_zoom;
|
2001-12-29 01:36:58 +08:00
|
|
|
options->type_d = options->type = GIMP_ZOOM_IN;
|
|
|
|
options->threshold_d = options->threshold = 5;
|
2001-11-20 21:53:21 +08:00
|
|
|
|
|
|
|
/* the main vbox */
|
|
|
|
vbox = options->tool_options.main_vbox;
|
|
|
|
|
|
|
|
/* the allow_resize toggle button */
|
|
|
|
options->allow_resize_w =
|
|
|
|
gtk_check_button_new_with_label (_("Allow Window Resizing"));
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_resize_w),
|
|
|
|
gimprc.resize_windows_on_zoom);
|
2001-11-23 01:11:52 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), options->allow_resize_w,
|
|
|
|
FALSE, FALSE, 0);
|
2001-11-20 21:53:21 +08:00
|
|
|
gtk_widget_show (options->allow_resize_w);
|
|
|
|
|
2001-11-23 01:11:52 +08:00
|
|
|
g_signal_connect (G_OBJECT (options->allow_resize_w), "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&(gimprc.resize_windows_on_zoom));
|
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
/* tool toggle */
|
2002-03-19 06:26:41 +08:00
|
|
|
frame = gimp_enum_radio_frame_new (GIMP_TYPE_ZOOM_TYPE,
|
|
|
|
gtk_label_new (_("Tool Toggle (<Ctrl>)")),
|
|
|
|
2,
|
|
|
|
G_CALLBACK (gimp_radio_button_update),
|
|
|
|
&options->type,
|
|
|
|
&options->type_w);
|
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w),
|
|
|
|
GINT_TO_POINTER (options->type));
|
2001-11-20 21:53:21 +08:00
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2001-12-28 02:33:25 +08:00
|
|
|
/* window threshold */
|
2002-03-09 02:30:40 +08:00
|
|
|
table = gtk_table_new (1, 3, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
options->threshold_w = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
|
|
|
|
_("Threshold:"), -1, 50,
|
|
|
|
options->threshold_d,
|
|
|
|
1.0, 15.0, 1.0, 3.0, 1,
|
|
|
|
TRUE, 0.0, 0.0,
|
|
|
|
NULL, NULL);
|
|
|
|
|
2001-12-28 02:33:25 +08:00
|
|
|
g_signal_connect (G_OBJECT (options->threshold_w), "value_changed",
|
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
2001-12-29 01:36:58 +08:00
|
|
|
&options->threshold);
|
2001-12-28 02:33:25 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
return (GimpToolOptions *) options;
|
2001-11-20 21:53:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
magnify_options_reset (GimpToolOptions *tool_options)
|
|
|
|
{
|
|
|
|
MagnifyOptions *options;
|
|
|
|
|
|
|
|
options = (MagnifyOptions *) tool_options;
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_resize_w),
|
|
|
|
options->allow_resize_d);
|
|
|
|
|
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 (options->type_d));
|
2001-12-29 01:36:58 +08:00
|
|
|
|
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->threshold_w),
|
|
|
|
options->threshold_d);
|
2001-11-20 21:53:21 +08:00
|
|
|
}
|