2002-05-03 Michael Natterer <mitch@gimp.org> * devel-docs/Makefile.am * devel-docs/includes.txt: new file documenting the core's include policy. * HACKING: mention it here. * libgimptool/gimptooltypes.h: removed GimpToolOptions here. * app/core/core-types.h: and added it here. This is a temp hack needed because GimpToolInfo needs to know the GimpToolOptions type. * libgimpproxy/gimpproxytypes.h: regenerated. * libgimptool/gimptoolmodule.h: don't include gimptooltypes.h here... * libgimptool/gimptoolmodule.c: ...but here. * app/config/gimpconfig-params.c: include "libgimpbase/gimpbase.h" entirely, not single files from it. * app/core/gimp.c * app/core/gimpcontext.c * app/core/gimpcoreconfig.c * app/core/gimpdatafactory.c * app/core/gimpdocuments.c * app/core/gimpdrawable-blend.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpdrawable-offset.c * app/core/gimpdrawable-transform.c * app/core/gimpdrawable.c * app/core/gimpedit.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-guides.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-new.c * app/core/gimpimage-projection.c * app/core/gimpimage-qmask.c * app/core/gimpimage-resize.c * app/core/gimpimage-scale.c * app/core/gimpimage.c * app/core/gimpitem.c * app/core/gimpmodules.c * app/core/gimppaintinfo.c * app/core/gimpparasite.c * app/core/gimppreviewcache.c * app/core/gimptoolinfo.c * app/core/gimpunit.c: include "core-types.h" and no other types file. * app/display/gimpdisplay.c * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell.c: include "tools/tools-types.h" instead of "libgimptool/gimptooltypes.h", warn about inclusion on "gui/gui-types.h" * app/file/file-open.c * app/file/file-save.c: don't include "libgimptool/gimptooltypes.h". * app/gui/about-dialog.c * app/gui/brush-select.c * app/gui/brushes-commands.c * app/gui/color-select.c * app/gui/data-commands.c * app/gui/device-status-dialog.c * app/gui/dialogs.c * app/gui/gradients-commands.c * app/gui/help-commands.c * app/gui/info-window.c * app/gui/palettes-commands.c * app/gui/patterns-commands.c * app/gui/resize-dialog.c * app/gui/tips-dialog.c * app/gui/tool-options-dialog.c: include "gui-types.h" and no other types file. * app/paint/gimpairbrush.c * app/paint/gimpclone.c * app/paint/gimpconvolve.c * app/paint/gimpdodgeburn.c * app/paint/gimperaser.c * app/paint/gimppaintbrush.c * app/paint/gimppaintcore-stroke.c * app/paint/gimppaintcore.c * app/paint/gimppaintoptions.c * app/paint/gimppencil.c * app/paint/gimpsmudge.c * app/paint/paint.c: include "paint-types.h" and no other types file. * app/pdb/pdb-types.h: don't include "libgimptool/gimptooltypes.h". * app/plug-in/plug-in-progress.c: warn about inclusion of "display/display-types.h" * app/tools/tools-types.h: include "libgimptool/gimptooltypes.h". * app/tools/gimpairbrushtool.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool.c * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppaintbrushtool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimppenciltool.c * app/tools/gimpperspectivetool.c * app/tools/gimpposterizetool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpselectiontool.c * app/tools/gimpsheartool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/gimptoolcontrol.c * app/tools/gimptoolcontrol.h * app/tools/gimptransformtool.c * app/tools/gimpvectortool.c * app/tools/tools.c: include "tools-types.h" and no other types file, warn about inclusion of "gui/gui-types.h". * app/widgets/gimpcolorpanel.c * app/widgets/gimptoolbox-color-area.c: warn about inclusion of "gui/gui-types.h". * app/xcf/xcf-load.c * app/xcf/xcf.c: don't include "libgimptool/gimptooltypes.h". Split tool-safe-mode up in two files, one including libgimpproxy, one libgimp. * plug-ins/tools/Makefile.am * plug-ins/tools/tool-safe-mode-plug-in.[ch]: new files including libgimp/ stuff only. * plug-ins/tools/tool-safe-mode.[ch]: include libgimpproxy/ and libgimptool/ but don't include libgimp/ because of conflicting declarations. Unrelated: * app/tools/gimpclonetool.c: create the clone core so we don't crash. * app/gui/file-open-dialog.c: changed the way we create previews so that only out-of-date previews are created on a click in the preview area. Unconditional creation can still be forced by <Ctrl>+click. Changed the tooltip to document this.
329 lines
9.4 KiB
C
329 lines
9.4 KiB
C
/* 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.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
#include "tools-types.h"
|
|
|
|
#include "core/gimpdrawable.h"
|
|
#include "core/gimpdrawable-transform.h"
|
|
#include "core/gimpimage.h"
|
|
#include "core/gimpimage-mask.h"
|
|
#include "core/gimptoolinfo.h"
|
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
#include "gimpfliptool.h"
|
|
#include "tool_options.h"
|
|
|
|
#include "path_transform.h"
|
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
typedef struct _FlipOptions FlipOptions;
|
|
|
|
struct _FlipOptions
|
|
{
|
|
GimpToolOptions tool_options;
|
|
|
|
InternalOrientationType type;
|
|
InternalOrientationType type_d;
|
|
GtkWidget *type_w[2];
|
|
};
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
static void gimp_flip_tool_class_init (GimpFlipToolClass *klass);
|
|
static void gimp_flip_tool_init (GimpFlipTool *flip_tool);
|
|
|
|
static void gimp_flip_tool_modifier_key (GimpTool *tool,
|
|
GdkModifierType key,
|
|
gboolean press,
|
|
GdkModifierType state,
|
|
GimpDisplay *gdisp);
|
|
static void gimp_flip_tool_cursor_update (GimpTool *tool,
|
|
GimpCoords *coords,
|
|
GdkModifierType state,
|
|
GimpDisplay *gdisp);
|
|
|
|
static TileManager * gimp_flip_tool_transform (GimpTransformTool *tool,
|
|
GimpDisplay *gdisp,
|
|
TransformState state);
|
|
|
|
static GimpToolOptions * flip_options_new (GimpToolInfo *tool_info);
|
|
static void flip_options_reset (GimpToolOptions *tool_options);
|
|
|
|
|
|
static GimpTransformToolClass *parent_class = NULL;
|
|
|
|
|
|
/* public functions */
|
|
|
|
void
|
|
gimp_flip_tool_register (GimpToolRegisterCallback callback,
|
|
gpointer data)
|
|
{
|
|
(* callback) (GIMP_TYPE_FLIP_TOOL,
|
|
flip_options_new,
|
|
FALSE,
|
|
"gimp-flip-tool",
|
|
_("Flip Tool"),
|
|
_("Flip the layer or selection"),
|
|
N_("/Tools/Transform Tools/Flip"), "<shift>F",
|
|
NULL, "tools/flip.html",
|
|
GIMP_STOCK_TOOL_FLIP,
|
|
data);
|
|
}
|
|
|
|
GType
|
|
gimp_flip_tool_get_type (void)
|
|
{
|
|
static GType tool_type = 0;
|
|
|
|
if (! tool_type)
|
|
{
|
|
static const GTypeInfo tool_info =
|
|
{
|
|
sizeof (GimpFlipToolClass),
|
|
(GBaseInitFunc) NULL,
|
|
(GBaseFinalizeFunc) NULL,
|
|
(GClassInitFunc) gimp_flip_tool_class_init,
|
|
NULL, /* class_finalize */
|
|
NULL, /* class_data */
|
|
sizeof (GimpFlipTool),
|
|
0, /* n_preallocs */
|
|
(GInstanceInitFunc) gimp_flip_tool_init,
|
|
};
|
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_TRANSFORM_TOOL,
|
|
"GimpFlipTool",
|
|
&tool_info, 0);
|
|
}
|
|
|
|
return tool_type;
|
|
}
|
|
|
|
|
|
/* private functions */
|
|
|
|
static void
|
|
gimp_flip_tool_class_init (GimpFlipToolClass *klass)
|
|
{
|
|
GimpToolClass *tool_class;
|
|
GimpTransformToolClass *trans_class;
|
|
|
|
tool_class = GIMP_TOOL_CLASS (klass);
|
|
trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
tool_class->modifier_key = gimp_flip_tool_modifier_key;
|
|
tool_class->cursor_update = gimp_flip_tool_cursor_update;
|
|
|
|
trans_class->transform = gimp_flip_tool_transform;
|
|
}
|
|
|
|
static void
|
|
gimp_flip_tool_init (GimpFlipTool *flip_tool)
|
|
{
|
|
GimpTool *tool;
|
|
GimpTransformTool *transform_tool;
|
|
|
|
tool = GIMP_TOOL (flip_tool);
|
|
transform_tool = GIMP_TRANSFORM_TOOL (flip_tool);
|
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
|
gimp_tool_control_set_snap_to (tool->control, FALSE);
|
|
gimp_tool_control_set_preserve (tool->control, FALSE);
|
|
gimp_tool_control_set_cursor (tool->control, GDK_SB_H_DOUBLE_ARROW);
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_FLIP_HORIZONTAL_TOOL_CURSOR);
|
|
gimp_tool_control_set_tool_cursor (tool->control, GDK_SB_V_DOUBLE_ARROW);
|
|
gimp_tool_control_set_toggle_tool_cursor (tool->control, GIMP_FLIP_VERTICAL_TOOL_CURSOR);
|
|
|
|
transform_tool->use_grid = FALSE;
|
|
}
|
|
|
|
static void
|
|
gimp_flip_tool_modifier_key (GimpTool *tool,
|
|
GdkModifierType key,
|
|
gboolean press,
|
|
GdkModifierType state,
|
|
GimpDisplay *gdisp)
|
|
{
|
|
FlipOptions *options;
|
|
|
|
options = (FlipOptions *) tool->tool_info->tool_options;
|
|
|
|
if (key == GDK_CONTROL_MASK)
|
|
{
|
|
switch (options->type)
|
|
{
|
|
case ORIENTATION_HORIZONTAL:
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w[0]),
|
|
GINT_TO_POINTER (ORIENTATION_VERTICAL));
|
|
break;
|
|
case ORIENTATION_VERTICAL:
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w[0]),
|
|
GINT_TO_POINTER (ORIENTATION_HORIZONTAL));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
static void
|
|
gimp_flip_tool_cursor_update (GimpTool *tool,
|
|
GimpCoords *coords,
|
|
GdkModifierType state,
|
|
GimpDisplay *gdisp)
|
|
{
|
|
GimpDrawable *drawable;
|
|
FlipOptions *options;
|
|
gboolean bad_cursor = TRUE;
|
|
|
|
options = (FlipOptions *) tool->tool_info->tool_options;
|
|
|
|
if ((drawable = gimp_image_active_drawable (gdisp->gimage)))
|
|
{
|
|
gint off_x, off_y;
|
|
|
|
gimp_drawable_offsets (drawable, &off_x, &off_y);
|
|
|
|
if (coords->x >= off_x &&
|
|
coords->y >= off_y &&
|
|
coords->x < (off_x + gimp_drawable_width (drawable)) &&
|
|
coords->y < (off_y + gimp_drawable_height (drawable)))
|
|
{
|
|
/* Is there a selected region? If so, is cursor inside? */
|
|
if (gimp_image_mask_is_empty (gdisp->gimage) ||
|
|
gimp_image_mask_value (gdisp->gimage, coords->x, coords->y))
|
|
{
|
|
bad_cursor = FALSE;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (bad_cursor)
|
|
{
|
|
gimp_tool_control_set_cursor (tool->control, GIMP_BAD_CURSOR);
|
|
gimp_tool_control_set_toggle_cursor (tool->control, GIMP_BAD_CURSOR);
|
|
}
|
|
else
|
|
{
|
|
gimp_tool_control_set_cursor (tool->control, GDK_SB_H_DOUBLE_ARROW);
|
|
gimp_tool_control_set_toggle_cursor (tool->control, GDK_SB_V_DOUBLE_ARROW);
|
|
}
|
|
|
|
gimp_tool_control_set_toggle (tool->control, (options->type == ORIENTATION_VERTICAL));
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
|
}
|
|
|
|
static TileManager *
|
|
gimp_flip_tool_transform (GimpTransformTool *trans_tool,
|
|
GimpDisplay *gdisp,
|
|
TransformState state)
|
|
{
|
|
FlipOptions *options;
|
|
|
|
options = (FlipOptions *) GIMP_TOOL (trans_tool)->tool_info->tool_options;
|
|
|
|
switch (state)
|
|
{
|
|
case TRANSFORM_INIT:
|
|
break;
|
|
|
|
case TRANSFORM_MOTION:
|
|
break;
|
|
|
|
case TRANSFORM_RECALC:
|
|
break;
|
|
|
|
case TRANSFORM_FINISH:
|
|
return gimp_drawable_transform_tiles_flip (gimp_image_active_drawable (gdisp->gimage),
|
|
trans_tool->original,
|
|
options->type);
|
|
break;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
|
|
/* tool options stuff */
|
|
|
|
static GimpToolOptions *
|
|
flip_options_new (GimpToolInfo *tool_info)
|
|
{
|
|
FlipOptions *options;
|
|
GtkWidget *vbox;
|
|
GtkWidget *frame;
|
|
|
|
options = g_new0 (FlipOptions, 1);
|
|
|
|
tool_options_init ((GimpToolOptions *) options, tool_info);
|
|
|
|
((GimpToolOptions *) options)->reset_func = flip_options_reset;
|
|
|
|
options->type = options->type_d = ORIENTATION_HORIZONTAL;
|
|
|
|
/* the main vbox */
|
|
vbox = options->tool_options.main_vbox;
|
|
|
|
/* tool toggle */
|
|
frame = gimp_radio_group_new2 (TRUE, _("Tool Toggle (<Ctrl>)"),
|
|
G_CALLBACK (gimp_radio_button_update),
|
|
&options->type,
|
|
GINT_TO_POINTER (options->type),
|
|
|
|
_("Horizontal"),
|
|
GINT_TO_POINTER (ORIENTATION_HORIZONTAL),
|
|
&options->type_w[0],
|
|
|
|
_("Vertical"),
|
|
GINT_TO_POINTER (ORIENTATION_VERTICAL),
|
|
&options->type_w[1],
|
|
|
|
NULL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
gtk_widget_show (frame);
|
|
|
|
return (GimpToolOptions *) options;
|
|
}
|
|
|
|
static void
|
|
flip_options_reset (GimpToolOptions *tool_options)
|
|
{
|
|
FlipOptions *options;
|
|
|
|
options = (FlipOptions *) tool_options;
|
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w[0]),
|
|
GINT_TO_POINTER (options->type_d));
|
|
}
|