2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* 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
|
|
|
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2003-08-08 15:57:33 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpimage.h"
|
2003-08-31 00:41:35 +08:00
|
|
|
#include "core/gimppaintinfo.h"
|
2004-07-14 00:36:29 +08:00
|
|
|
#include "core/gimpprojection.h"
|
2001-12-02 05:02:34 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2004-06-02 06:04:20 +08:00
|
|
|
#include "core/gimpunit.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "paint/gimppaintcore.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "paint/gimppaintoptions.h"
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
#include "widgets/gimpdevices.h"
|
2006-08-02 07:42:12 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2001-12-08 01:39:51 +08:00
|
|
|
|
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-09-26 07:23:09 +08:00
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
#include "gimpcoloroptions.h"
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "gimppainttool.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
2004-08-23 05:48:50 +08:00
|
|
|
#include "tools-utils.h"
|
2001-03-08 09:07:03 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2000-03-05 08:06:11 +08:00
|
|
|
|
1999-09-02 02:46:25 +08:00
|
|
|
|
2006-08-16 05:46:22 +08:00
|
|
|
#define HANDLE_SIZE 15
|
2006-07-31 04:15:07 +08:00
|
|
|
#define STATUSBAR_SIZE 200
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
|
2003-08-31 00:41:35 +08:00
|
|
|
static GObject * gimp_paint_tool_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
2002-02-15 03:31:16 +08:00
|
|
|
static void gimp_paint_tool_finalize (GObject *object);
|
|
|
|
|
2006-08-16 05:46:22 +08:00
|
|
|
static void gimp_paint_tool_control (GimpTool *tool,
|
2004-06-05 07:08:29 +08:00
|
|
|
GimpToolAction action,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display);
|
2002-02-15 03:31:16 +08:00
|
|
|
static void gimp_paint_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
2004-06-05 07:08:29 +08:00
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display);
|
2002-02-15 03:31:16 +08:00
|
|
|
static void gimp_paint_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
2004-06-05 07:08:29 +08:00
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display);
|
2002-02-15 03:31:16 +08:00
|
|
|
static void gimp_paint_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
2004-06-05 07:08:29 +08:00
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display);
|
2003-06-05 23:43:49 +08:00
|
|
|
static void gimp_paint_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display);
|
2003-06-05 23:43:49 +08:00
|
|
|
static void gimp_paint_tool_oper_update (GimpTool *tool,
|
2002-02-15 03:31:16 +08:00
|
|
|
GimpCoords *coords,
|
2004-06-05 07:08:29 +08:00
|
|
|
GdkModifierType state,
|
2006-03-25 22:23:09 +08:00
|
|
|
gboolean proximity,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display);
|
2002-02-15 03:31:16 +08:00
|
|
|
|
|
|
|
static void gimp_paint_tool_draw (GimpDrawTool *draw_tool);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpPaintTool, gimp_paint_tool, GIMP_TYPE_COLOR_TOOL)
|
2001-02-28 03:18:01 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
#define parent_class gimp_paint_tool_parent_class
|
2001-02-27 13:21:12 +08:00
|
|
|
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
|
|
|
gimp_paint_tool_class_init (GimpPaintToolClass *klass)
|
2001-02-27 13:21:12 +08:00
|
|
|
{
|
2006-05-28 22:13:44 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
2001-02-28 03:18:01 +08:00
|
|
|
|
2003-08-31 00:41:35 +08:00
|
|
|
object_class->constructor = gimp_paint_tool_constructor;
|
2002-02-13 22:50:37 +08:00
|
|
|
object_class->finalize = gimp_paint_tool_finalize;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
tool_class->control = gimp_paint_tool_control;
|
2001-02-28 03:18:01 +08:00
|
|
|
tool_class->button_press = gimp_paint_tool_button_press;
|
|
|
|
tool_class->button_release = gimp_paint_tool_button_release;
|
|
|
|
tool_class->motion = gimp_paint_tool_motion;
|
2003-06-05 23:43:49 +08:00
|
|
|
tool_class->modifier_key = gimp_paint_tool_modifier_key;
|
|
|
|
tool_class->oper_update = gimp_paint_tool_oper_update;
|
2001-02-28 03:18:01 +08:00
|
|
|
|
|
|
|
draw_tool_class->draw = gimp_paint_tool_draw;
|
2001-02-27 13:21:12 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2002-02-05 19:35:03 +08:00
|
|
|
gimp_paint_tool_init (GimpPaintTool *paint_tool)
|
2001-02-28 03:18:01 +08:00
|
|
|
{
|
2003-06-05 23:43:49 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (paint_tool);
|
2002-02-05 19:35:03 +08:00
|
|
|
|
2006-12-04 03:23:50 +08:00
|
|
|
gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_EXACT);
|
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
|
|
|
gimp_tool_control_set_action_value_1 (tool->control,
|
|
|
|
"context/context-opacity-set");
|
2002-06-17 01:13:39 +08:00
|
|
|
|
2003-08-31 00:41:35 +08:00
|
|
|
paint_tool->pick_colors = FALSE;
|
|
|
|
paint_tool->draw_line = FALSE;
|
2003-07-11 00:01:45 +08:00
|
|
|
|
2006-09-12 14:37:54 +08:00
|
|
|
paint_tool->status = _("Click to paint");
|
|
|
|
paint_tool->status_line = _("Click to draw the line");
|
2006-08-02 07:42:12 +08:00
|
|
|
paint_tool->status_ctrl = _("%s to pick a color");
|
|
|
|
|
2003-08-31 00:41:35 +08:00
|
|
|
paint_tool->core = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
gimp_paint_tool_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
|
|
|
GObject *object;
|
|
|
|
GimpTool *tool;
|
2006-09-03 21:16:58 +08:00
|
|
|
GimpPaintInfo *paint_info;
|
2003-08-31 00:41:35 +08:00
|
|
|
GimpPaintTool *paint_tool;
|
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
|
|
|
|
tool = GIMP_TOOL (object);
|
|
|
|
paint_tool = GIMP_PAINT_TOOL (object);
|
|
|
|
|
|
|
|
g_assert (GIMP_IS_TOOL_INFO (tool->tool_info));
|
2006-08-16 05:46:22 +08:00
|
|
|
g_assert (GIMP_IS_PAINT_INFO (tool->tool_info->paint_info));
|
2003-08-31 00:41:35 +08:00
|
|
|
|
2006-09-03 21:16:58 +08:00
|
|
|
paint_info = tool->tool_info->paint_info;
|
|
|
|
|
|
|
|
g_assert (g_type_is_a (paint_info->paint_type, GIMP_TYPE_PAINT_CORE));
|
|
|
|
|
|
|
|
paint_tool->core = g_object_new (paint_info->paint_type,
|
|
|
|
"undo-desc", paint_info->blurb,
|
2003-08-31 00:41:35 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
return object;
|
2002-02-13 22:50:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_paint_tool_finalize (GObject *object)
|
|
|
|
{
|
2003-06-05 23:43:49 +08:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (object);
|
2002-02-13 22:50:37 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
if (paint_tool->core)
|
2002-02-13 22:50:37 +08:00
|
|
|
{
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (paint_tool->core);
|
2002-02-15 03:31:16 +08:00
|
|
|
paint_tool->core = NULL;
|
2002-02-13 22:50:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-02-28 03:18:01 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-10-26 03:00:49 +08:00
|
|
|
/**
|
|
|
|
* gimp_paint_tool_enable_color_picker:
|
|
|
|
* @tool: a #GimpPaintTool
|
|
|
|
* @mode: the #GimpColorPickMode to set
|
|
|
|
*
|
|
|
|
* This is a convenience function used from the init method of paint
|
|
|
|
* tools that want the color picking functionality. The @mode that is
|
|
|
|
* set here is used to decide what cursor modifier to draw and if the
|
|
|
|
* picked color goes to the foreground or background color.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_paint_tool_enable_color_picker (GimpPaintTool *tool,
|
|
|
|
GimpColorPickMode mode)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PAINT_TOOL (tool));
|
|
|
|
|
|
|
|
tool->pick_colors = TRUE;
|
|
|
|
|
|
|
|
GIMP_COLOR_TOOL (tool)->pick_mode = mode;
|
|
|
|
}
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2002-02-19 01:00:09 +08:00
|
|
|
gimp_paint_tool_control (GimpTool *tool,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *display)
|
2001-02-28 03:18:01 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
2001-02-28 03:18:01 +08:00
|
|
|
GimpDrawable *drawable;
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
drawable = gimp_image_active_drawable (display->image);
|
2001-02-28 03:18:01 +08:00
|
|
|
|
|
|
|
switch (action)
|
1999-05-13 19:12:32 +08:00
|
|
|
{
|
2006-05-22 05:12:01 +08:00
|
|
|
case GIMP_TOOL_ACTION_PAUSE:
|
|
|
|
case GIMP_TOOL_ACTION_RESUME:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_HALT:
|
2002-02-16 01:44:05 +08:00
|
|
|
gimp_paint_core_paint (paint_tool->core,
|
|
|
|
drawable,
|
2006-09-06 02:25:31 +08:00
|
|
|
GIMP_PAINT_TOOL_GET_OPTIONS (tool),
|
2004-07-19 22:37:40 +08:00
|
|
|
GIMP_PAINT_STATE_FINISH, 0);
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_paint_core_cleanup (paint_tool->core);
|
2001-02-28 03:18:01 +08:00
|
|
|
break;
|
1999-05-13 19:12:32 +08:00
|
|
|
}
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
|
2001-02-28 03:18:01 +08:00
|
|
|
}
|
1999-05-13 19:12:32 +08:00
|
|
|
|
2003-05-23 21:22:38 +08:00
|
|
|
/**
|
|
|
|
* gimp_paint_tool_round_line:
|
2004-02-19 02:37:49 +08:00
|
|
|
* @core: the #GimpPaintCore
|
|
|
|
* @center_pixels: push coordinates to pixel centers?
|
|
|
|
* @state: the modifier state
|
2003-05-23 21:22:38 +08:00
|
|
|
*
|
|
|
|
* Adjusts core->last_coords and core_cur_coords in preparation to
|
2004-02-19 02:37:49 +08:00
|
|
|
* drawing a straight line. If @center_pixels is TRUE the endpoints
|
|
|
|
* get pushed to the center of the pixels. This avoids artefacts
|
|
|
|
* for e.g. the hard mode. The rounding of the slope to 15 degree
|
2003-05-23 21:22:38 +08:00
|
|
|
* steps if ctrl is pressed happens, as does rounding the start and
|
|
|
|
* end coordinates (which may be fractional in high zoom modes) to
|
|
|
|
* the center of pixels.
|
|
|
|
**/
|
|
|
|
static void
|
|
|
|
gimp_paint_tool_round_line (GimpPaintCore *core,
|
2004-02-19 02:37:49 +08:00
|
|
|
gboolean center_pixels,
|
2003-05-23 21:22:38 +08:00
|
|
|
GdkModifierType state)
|
|
|
|
{
|
2004-02-19 02:37:49 +08:00
|
|
|
if (center_pixels)
|
|
|
|
{
|
|
|
|
core->last_coords.x = floor (core->last_coords.x) + 0.5;
|
|
|
|
core->last_coords.y = floor (core->last_coords.y) + 0.5;
|
|
|
|
core->cur_coords.x = floor (core->cur_coords.x ) + 0.5;
|
|
|
|
core->cur_coords.y = floor (core->cur_coords.y ) + 0.5;
|
|
|
|
}
|
2003-07-11 00:01:45 +08:00
|
|
|
|
2003-05-23 21:22:38 +08:00
|
|
|
/* Restrict to multiples of 15 degrees if ctrl is pressed */
|
|
|
|
if (state & GDK_CONTROL_MASK)
|
2004-08-23 05:48:50 +08:00
|
|
|
gimp_tool_motion_constrain (core->last_coords.x, core->last_coords.y,
|
|
|
|
&core->cur_coords.x, &core->cur_coords.y);
|
2003-05-23 21:22:38 +08:00
|
|
|
}
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_paint_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
2006-04-12 20:49:29 +08:00
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
|
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
|
2006-09-12 17:05:41 +08:00
|
|
|
GimpPaintCore *core = paint_tool->core;
|
2002-02-22 00:02:30 +08:00
|
|
|
GimpDrawable *drawable;
|
2003-10-30 04:57:21 +08:00
|
|
|
GdkDisplay *gdk_display;
|
2002-02-22 00:02:30 +08:00
|
|
|
GimpCoords curr_coords;
|
2003-05-08 22:06:03 +08:00
|
|
|
gint off_x, off_y;
|
2006-09-27 04:55:40 +08:00
|
|
|
GError *error = NULL;
|
2001-02-27 13:21:12 +08:00
|
|
|
|
2006-09-12 17:05:41 +08:00
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
|
|
|
{
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->button_press (tool, coords, time, state,
|
|
|
|
display);
|
|
|
|
return;
|
|
|
|
}
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
drawable = gimp_image_active_drawable (display->image);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
curr_coords = *coords;
|
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
curr_coords.x -= off_x;
|
|
|
|
curr_coords.y -= off_y;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2004-06-23 20:19:28 +08:00
|
|
|
if (gimp_draw_tool_is_active (draw_tool))
|
|
|
|
gimp_draw_tool_stop (draw_tool);
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
if (tool->display &&
|
|
|
|
tool->display != display &&
|
|
|
|
tool->display->image == display->image)
|
2002-02-19 01:00:09 +08:00
|
|
|
{
|
|
|
|
/* if this is a different display, but the same image, HACK around
|
|
|
|
* in tool internals AFTER stopping the current draw_tool, so
|
|
|
|
* straight line drawing works across different views of the
|
|
|
|
* same image.
|
|
|
|
*/
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
tool->display = display;
|
2002-02-19 01:00:09 +08:00
|
|
|
}
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gdk_display = gtk_widget_get_display (display->shell);
|
2004-05-26 04:41:09 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
core->use_pressure = (gimp_devices_get_current (display->image->gimp) !=
|
2003-10-30 04:57:21 +08:00
|
|
|
gdk_display_get_core_pointer (gdk_display));
|
2002-02-21 19:01:12 +08:00
|
|
|
|
2006-09-27 04:55:40 +08:00
|
|
|
if (! gimp_paint_core_start (core, drawable, paint_options, &curr_coords,
|
|
|
|
&error))
|
|
|
|
{
|
2006-09-28 16:32:09 +08:00
|
|
|
gimp_tool_message (tool, display, error->message);
|
2006-09-27 04:55:40 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
if ((display != tool->display) || ! paint_tool->draw_line)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-16 01:44:05 +08:00
|
|
|
/* if this is a new image, reinit the core vals */
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
core->start_coords = core->cur_coords;
|
|
|
|
core->last_coords = core->cur_coords;
|
2003-08-21 18:44:11 +08:00
|
|
|
|
|
|
|
core->distance = 0.0;
|
|
|
|
core->pixel_dist = 0.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2003-07-11 00:01:45 +08:00
|
|
|
else if (paint_tool->draw_line)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-16 01:44:05 +08:00
|
|
|
/* If shift is down and this is not the first paint
|
|
|
|
* stroke, then draw a line from the last coords to the pointer
|
|
|
|
*/
|
2004-02-19 02:37:49 +08:00
|
|
|
gboolean hard;
|
2004-05-26 20:55:10 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
core->start_coords = core->last_coords;
|
1999-06-18 04:34:50 +08:00
|
|
|
|
2004-05-26 20:55:10 +08:00
|
|
|
hard = (gimp_paint_options_get_brush_mode (paint_options) ==
|
|
|
|
GIMP_BRUSH_HARD);
|
2004-02-19 02:37:49 +08:00
|
|
|
gimp_paint_tool_round_line (core, hard, state);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-09-12 17:05:41 +08:00
|
|
|
/* chain up to activate the tool */
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->button_press (tool, coords, time, state,
|
|
|
|
display);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-05 19:35:03 +08:00
|
|
|
/* pause the current selection */
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_selection_control (display->image, GIMP_SELECTION_PAUSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Let the specific painting function initialize itself */
|
2004-07-19 22:37:40 +08:00
|
|
|
gimp_paint_core_paint (core, drawable, paint_options,
|
|
|
|
GIMP_PAINT_STATE_INIT, time);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Paint to the image */
|
2003-07-11 00:01:45 +08:00
|
|
|
if (paint_tool->draw_line)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-05-27 00:13:53 +08:00
|
|
|
gimp_paint_core_interpolate (core, drawable, paint_options, time);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
{
|
2004-07-19 22:37:40 +08:00
|
|
|
gimp_paint_core_paint (core, drawable, paint_options,
|
|
|
|
GIMP_PAINT_STATE_MOTION, time);
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
}
|
2000-06-06 06:08:45 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_projection_flush_now (display->image->projection);
|
|
|
|
gimp_display_flush_now (display);
|
2000-06-06 06:08:45 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_draw_tool_start (draw_tool, display);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_paint_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
2006-04-12 20:49:29 +08:00
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
|
2006-09-12 17:05:41 +08:00
|
|
|
GimpPaintCore *core = paint_tool->core;
|
2002-02-22 00:02:30 +08:00
|
|
|
GimpDrawable *drawable;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-09-12 17:05:41 +08:00
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
|
|
|
{
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->button_release (tool, coords, time,
|
|
|
|
state, display);
|
|
|
|
return;
|
|
|
|
}
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
drawable = gimp_image_active_drawable (display->image);
|
2001-12-02 06:59:48 +08:00
|
|
|
|
2004-06-28 19:36:00 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Let the specific painting function finish up */
|
2004-07-19 22:37:40 +08:00
|
|
|
gimp_paint_core_paint (core, drawable, paint_options,
|
|
|
|
GIMP_PAINT_STATE_FINISH, time);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-16 01:44:05 +08:00
|
|
|
/* resume the current selection */
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_selection_control (display->image, GIMP_SELECTION_RESUME);
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
/* chain up to halt the tool */
|
2006-09-12 17:05:41 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->button_release (tool, coords, time, state,
|
|
|
|
display);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-09-17 20:05:11 +08:00
|
|
|
if (state & GDK_BUTTON3_MASK)
|
|
|
|
gimp_paint_core_cancel (core, drawable);
|
|
|
|
else
|
|
|
|
gimp_paint_core_finish (core, drawable);
|
2001-02-28 03:18:01 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_flush (display->image);
|
2004-06-28 19:36:00 +08:00
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_paint_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
2006-04-12 20:49:29 +08:00
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
|
2006-09-12 17:05:41 +08:00
|
|
|
GimpPaintCore *core = paint_tool->core;
|
2002-02-22 00:02:30 +08:00
|
|
|
GimpDrawable *drawable;
|
2003-05-08 22:06:03 +08:00
|
|
|
gint off_x, off_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-09-12 17:05:41 +08:00
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
|
|
|
{
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state,
|
|
|
|
display);
|
|
|
|
return;
|
|
|
|
}
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
drawable = gimp_image_active_drawable (display->image);
|
2001-12-02 06:59:48 +08:00
|
|
|
|
2002-02-16 01:44:05 +08:00
|
|
|
core->cur_coords = *coords;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
core->cur_coords.x -= off_x;
|
|
|
|
core->cur_coords.y -= off_y;
|
1999-05-13 19:12:32 +08:00
|
|
|
|
2006-09-12 17:05:41 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state,
|
|
|
|
display);
|
1999-05-13 19:12:32 +08:00
|
|
|
|
2004-06-14 23:26:29 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
2000-06-06 06:08:45 +08:00
|
|
|
|
2004-05-27 00:13:53 +08:00
|
|
|
gimp_paint_core_interpolate (core, drawable, paint_options, time);
|
2002-02-07 19:33:01 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_projection_flush_now (display->image->projection);
|
|
|
|
gimp_display_flush_now (display);
|
2000-06-06 06:08:45 +08:00
|
|
|
|
2004-06-14 23:26:29 +08:00
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2003-06-05 23:43:49 +08:00
|
|
|
gimp_paint_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2003-06-05 23:43:49 +08:00
|
|
|
{
|
2004-06-14 23:26:29 +08:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
|
2003-07-11 00:01:45 +08:00
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
if (key != GDK_CONTROL_MASK)
|
|
|
|
return;
|
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
if (paint_tool->pick_colors && ! paint_tool->draw_line)
|
2003-06-05 23:43:49 +08:00
|
|
|
{
|
|
|
|
if (press)
|
|
|
|
{
|
2006-09-08 21:42:00 +08:00
|
|
|
GimpToolInfo *info = gimp_get_tool_info (display->image->gimp,
|
|
|
|
"gimp-color-picker-tool");
|
2003-07-11 00:01:45 +08:00
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
if (GIMP_IS_TOOL_INFO (info))
|
|
|
|
{
|
|
|
|
if (gimp_draw_tool_is_active (draw_tool))
|
|
|
|
gimp_draw_tool_stop (draw_tool);
|
|
|
|
|
|
|
|
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
|
|
|
|
GIMP_COLOR_OPTIONS (info->tool_options));
|
2006-09-06 02:25:31 +08:00
|
|
|
|
2006-08-02 07:42:12 +08:00
|
|
|
switch (GIMP_COLOR_TOOL (tool)->pick_mode)
|
|
|
|
{
|
|
|
|
case GIMP_COLOR_PICK_MODE_FOREGROUND:
|
|
|
|
gimp_tool_push_status (tool, display,
|
|
|
|
_("Click in any image to pick the "
|
2006-09-12 14:37:54 +08:00
|
|
|
"foreground color"));
|
2006-08-02 07:42:12 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_PICK_MODE_BACKGROUND:
|
|
|
|
gimp_tool_push_status (tool, display,
|
|
|
|
_("Click in any image to pick the "
|
2006-09-12 14:37:54 +08:00
|
|
|
"background color"));
|
2006-08-02 07:42:12 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
2003-06-05 23:43:49 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-09-18 21:51:10 +08:00
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
2006-07-31 04:15:07 +08:00
|
|
|
{
|
|
|
|
gimp_tool_pop_status (tool, display);
|
|
|
|
gimp_color_tool_disable (GIMP_COLOR_TOOL (tool));
|
|
|
|
}
|
2003-06-05 23:43:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_paint_tool_oper_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
2006-03-25 22:23:09 +08:00
|
|
|
gboolean proximity,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
|
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
|
2006-09-12 17:05:41 +08:00
|
|
|
GimpPaintCore *core = paint_tool->core;
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
|
2003-08-20 02:04:40 +08:00
|
|
|
GimpDrawable *drawable;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-09-12 17:05:41 +08:00
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
2003-07-11 00:01:45 +08:00
|
|
|
{
|
2006-03-25 22:23:09 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state,
|
2006-03-29 01:55:52 +08:00
|
|
|
proximity, display);
|
2003-07-11 00:01:45 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gimp_draw_tool_is_active (draw_tool))
|
2002-02-07 19:33:01 +08:00
|
|
|
gimp_draw_tool_stop (draw_tool);
|
2000-03-05 08:06:11 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_pop_status (tool, display);
|
1999-05-15 08:02:47 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
if (tool->display &&
|
|
|
|
tool->display != display &&
|
|
|
|
tool->display->image == display->image)
|
2002-02-19 01:00:09 +08:00
|
|
|
{
|
|
|
|
/* if this is a different display, but the same image, HACK around
|
|
|
|
* in tool internals AFTER stopping the current draw_tool, so
|
|
|
|
* straight line drawing works across different views of the
|
|
|
|
* same image.
|
|
|
|
*/
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
tool->display = display;
|
2002-02-19 01:00:09 +08:00
|
|
|
}
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
drawable = gimp_image_active_drawable (display->image);
|
2004-01-03 01:36:45 +08:00
|
|
|
|
2006-03-25 22:23:09 +08:00
|
|
|
if (drawable && proximity)
|
1998-01-22 15:02:57 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
if (display == tool->display && (state & GDK_SHIFT_MASK))
|
2003-07-11 00:01:45 +08:00
|
|
|
{
|
2002-02-16 01:44:05 +08:00
|
|
|
/* If shift is down and this is not the first paint stroke,
|
2005-04-05 05:03:21 +08:00
|
|
|
* draw a line.
|
2002-02-16 01:44:05 +08:00
|
|
|
*/
|
|
|
|
|
2006-09-12 14:37:54 +08:00
|
|
|
gchar *status_help;
|
|
|
|
gdouble dx, dy, dist;
|
|
|
|
gint off_x, off_y;
|
|
|
|
gboolean hard;
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2002-02-17 19:46:39 +08:00
|
|
|
core->cur_coords = *coords;
|
1999-08-21 21:16:20 +08:00
|
|
|
|
2003-08-20 02:04:40 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
|
2002-02-17 19:46:39 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
core->cur_coords.x -= off_x;
|
|
|
|
core->cur_coords.y -= off_y;
|
1999-05-15 08:36:42 +08:00
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
hard = (gimp_paint_options_get_brush_mode (paint_options) ==
|
|
|
|
GIMP_BRUSH_HARD);
|
2004-02-19 02:37:49 +08:00
|
|
|
gimp_paint_tool_round_line (core, hard, state);
|
1999-06-18 04:34:50 +08:00
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
dx = core->cur_coords.x - core->last_coords.x;
|
|
|
|
dy = core->cur_coords.y - core->last_coords.y;
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2006-08-02 07:42:12 +08:00
|
|
|
status_help = gimp_suggest_modifiers (paint_tool->status_line,
|
|
|
|
GDK_CONTROL_MASK & ~state,
|
|
|
|
NULL,
|
|
|
|
_("%s for constrained angles"),
|
|
|
|
NULL);
|
2006-07-31 04:15:07 +08:00
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
/* show distance in statusbar */
|
2004-06-02 06:04:20 +08:00
|
|
|
if (shell->unit == GIMP_UNIT_PIXEL)
|
2003-07-11 00:01:45 +08:00
|
|
|
{
|
|
|
|
dist = sqrt (SQR (dx) + SQR (dy));
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2006-09-28 19:07:55 +08:00
|
|
|
gimp_tool_push_status (tool, display, "%.1f %s. %s",
|
|
|
|
dist, _("pixels"), status_help);
|
2003-07-11 00:01:45 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpImage *image = display->image;
|
2004-06-02 06:04:20 +08:00
|
|
|
gchar format_str[64];
|
2002-02-05 01:43:01 +08:00
|
|
|
|
2006-07-31 04:15:07 +08:00
|
|
|
g_snprintf (format_str, sizeof (format_str), "%%.%df %s. %%s",
|
2004-06-02 06:04:20 +08:00
|
|
|
_gimp_unit_get_digits (image->gimp, shell->unit),
|
|
|
|
_gimp_unit_get_symbol (image->gimp, shell->unit));
|
2002-02-05 01:43:01 +08:00
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
dist = (_gimp_unit_get_factor (image->gimp, shell->unit) *
|
|
|
|
sqrt (SQR (dx / image->xresolution) +
|
|
|
|
SQR (dy / image->yresolution)));
|
2000-03-05 08:06:11 +08:00
|
|
|
|
2006-09-28 19:07:55 +08:00
|
|
|
gimp_tool_push_status (tool, display, format_str,
|
|
|
|
dist, status_help);
|
2003-07-11 00:01:45 +08:00
|
|
|
}
|
2006-09-28 19:07:55 +08:00
|
|
|
|
2006-08-02 07:42:12 +08:00
|
|
|
g_free (status_help);
|
1999-09-02 02:46:25 +08:00
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
paint_tool->draw_line = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-08-02 22:41:24 +08:00
|
|
|
gchar *status;
|
|
|
|
GdkModifierType modifiers = 0;
|
|
|
|
|
|
|
|
/* HACK: A paint tool may set status_ctrl to NULL to indicate that
|
|
|
|
* it ignores the Ctrl modifier (temporarily or permanently), so
|
|
|
|
* it should not be suggested. This is different from how
|
2006-09-28 19:07:55 +08:00
|
|
|
* gimp_suggest_modifiers() would interpret this parameter.
|
|
|
|
*/
|
2006-08-02 22:41:24 +08:00
|
|
|
if (paint_tool->status_ctrl != NULL)
|
|
|
|
modifiers |= GDK_CONTROL_MASK;
|
2006-09-28 19:07:55 +08:00
|
|
|
|
|
|
|
/* suggest drawing lines only after the first point is set
|
|
|
|
*/
|
2006-03-29 01:55:52 +08:00
|
|
|
if (display == tool->display)
|
2006-08-02 22:41:24 +08:00
|
|
|
modifiers |= GDK_SHIFT_MASK;
|
|
|
|
|
|
|
|
status = gimp_suggest_modifiers (paint_tool->status,
|
|
|
|
modifiers & ~state,
|
|
|
|
_("%s for a straight line"),
|
|
|
|
paint_tool->status_ctrl,
|
|
|
|
NULL);
|
2006-08-02 07:42:12 +08:00
|
|
|
gimp_tool_push_status (tool, display, status);
|
|
|
|
g_free (status);
|
2005-04-01 19:54:08 +08:00
|
|
|
|
2003-07-11 00:01:45 +08:00
|
|
|
paint_tool->draw_line = FALSE;
|
|
|
|
}
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_draw_tool_start (draw_tool, display);
|
2002-02-05 01:43:01 +08:00
|
|
|
}
|
2001-02-25 03:29:47 +08:00
|
|
|
|
2006-03-25 22:23:09 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity,
|
2006-03-29 01:55:52 +08:00
|
|
|
display);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
|
|
|
gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-06-05 23:43:49 +08:00
|
|
|
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (draw_tool)))
|
2002-02-07 19:33:01 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (draw_tool);
|
|
|
|
GimpPaintCore *core = paint_tool->core;
|
2003-07-11 00:01:45 +08:00
|
|
|
|
2004-06-14 23:26:29 +08:00
|
|
|
if (paint_tool->draw_line &&
|
|
|
|
! gimp_tool_control_is_active (GIMP_TOOL (draw_tool)->control))
|
2003-07-11 00:01:45 +08:00
|
|
|
{
|
|
|
|
/* Draw start target */
|
|
|
|
gimp_draw_tool_draw_handle (draw_tool,
|
|
|
|
GIMP_HANDLE_CROSS,
|
|
|
|
core->last_coords.x,
|
|
|
|
core->last_coords.y,
|
2006-08-16 05:46:22 +08:00
|
|
|
HANDLE_SIZE,
|
|
|
|
HANDLE_SIZE,
|
2003-07-11 00:01:45 +08:00
|
|
|
GTK_ANCHOR_CENTER,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
/* Draw end target */
|
|
|
|
gimp_draw_tool_draw_handle (draw_tool,
|
|
|
|
GIMP_HANDLE_CROSS,
|
|
|
|
core->cur_coords.x,
|
|
|
|
core->cur_coords.y,
|
2006-08-16 05:46:22 +08:00
|
|
|
HANDLE_SIZE,
|
|
|
|
HANDLE_SIZE,
|
2003-07-11 00:01:45 +08:00
|
|
|
GTK_ANCHOR_CENTER,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
/* Draw the line between the start and end coords */
|
|
|
|
gimp_draw_tool_draw_line (draw_tool,
|
|
|
|
core->last_coords.x,
|
|
|
|
core->last_coords.y,
|
|
|
|
core->cur_coords.x,
|
|
|
|
core->cur_coords.y,
|
|
|
|
TRUE);
|
|
|
|
}
|
2002-02-07 19:33:01 +08:00
|
|
|
}
|
2003-06-05 23:43:49 +08:00
|
|
|
|
|
|
|
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|