Gimp/app/tools/gimpscaletool.c

447 lines
14 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
1997-11-24 14:05:25 -08:00
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
1997-11-24 14:05:25 -08:00
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
1997-11-24 14:05:25 -08:00
* (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, see <https://www.gnu.org/licenses/>.
1997-11-24 14:05:25 -08:00
*/
#include "config.h"
#include <string.h>
#include <gegl.h>
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 07:22:01 -08:00
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
Makefile.am configure.in added the new library below. 2001-01-24 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added the new library below. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.[ch] * libgimpwidgets/gimpcolorbutton.[ch] * libgimpwidgets/gimpdialog.[ch] * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimphelpui.[ch] * libgimpwidgets/gimppatheditor.[ch] * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpquerybox.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch] * libgimpwidgets/gimpwidgets.[ch] * libgimpwidgets/gimpwidgets.def * libgimpwidgets/gimpwidgetstypes.h: new shared library. Currently there are some ugly dependencies into libgimp. These will be removed and go to a "libgimpglue" library which will be a library for functions which share a common interface between plug-ins and the app but have different implementations. Include "libgimp/gimpunit.h" from "libgimpwidgets/gimpwidgetstypes.h" to simulate this upcoming separation. * libgimp/Makefile.am * libgimp/gimpchainbutton.[ch] * libgimp/gimpcolorarea.[ch] * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimpfileselection.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimppixmap.[ch] * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: removed from here. * libgimp/gimpui.h * libgimp/gimpuitypes.h * libgimp/makefile.mingw.in * libgimp/makefile.msc: changed accordingly. * app/[all ui files] * app/pdb/palette_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: #include "libgimpwidgets/gimpwidgets.h" and removed useless includes. * app/apptypes.h: #include "libgimpwidgets/gimpwidgetstypes.h" * app/Makefile.am * plug-ins/[all makefiles which link against libgimpui]: link against libgimpwidgets.la * po-libgimp/POTFILES.in: changed file locations.
2001-01-24 14:36:18 -08:00
#include "libgimpwidgets/gimpwidgets.h"
devel-docs/Makefile.am new file documenting the core's include policy. 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.
2002-05-03 05:45:22 -07:00
#include "tools-types.h"
#include "core/gimp-transform-utils.h"
#include "core/gimpimage.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpsizebox.h"
#include "display/gimpdisplay.h"
removed gdisp->scale, gdisp->dot_for_dot, the scaling marcos and the 2002-06-27 Michael Natterer <mitch@gimp.org> * app/display/gimpdisplay.[ch]: removed gdisp->scale, gdisp->dot_for_dot, the scaling marcos and the gdisplay_[un]transform[_f]() functions. * app/display/gimpdisplayshell.[ch]: added them here. Named the transform functions gimp_display_shell_[un]transform_xy[_f](). Made the gimp_display_shell_[un]transform_coords() functions copy all values of the GimpCoords struct, not just x and y. * app/display/gimpstatusbar.[ch]: keep a pointer to GimpDisplayShell, not GimpDisplay. * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-render.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-selection.c * app/display/gimpnavigationview.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/select-commands.c * app/gui/view-commands.c * app/tools/gimpbezierselecttool.c * app/tools/gimpcroptool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpvectortool.c: changed accordingly. * app/gui/layers-commands.c: if(gimage->selection_mask) is always TRUE, use if(!gimp_image_mask_is_empty(gimage)) instead. * app/tools/gimpfuzzyselecttool.[ch]: moved global variables to the object struct.
2002-06-26 15:16:59 -07:00
#include "display/gimpdisplayshell.h"
#include "display/gimptoolgui.h"
#include "display/gimptooltransformgrid.h"
#include "gimpscaletool.h"
#include "gimptoolcontrol.h"
#include "gimptransformgridoptions.h"
#include "gimp-intl.h"
#define EPSILON 1e-6
/* index into trans_info array */
enum
{
X0,
Y0,
X1,
Y1
};
forgot to commit last time. 2001-11-19 Michael Natterer <mitch@gimp.org> * app/display/gimpdisplay-foreach.c: forgot to commit last time. Transform stuff cleanup: * app/core/Makefile.am * app/core/core-types.h * app/core/gimpdrawable-transform.[ch]: new files implementing the actual transform functions cut from tools/gimptransformtool.*. * app/core/gimpdrawable-transform-utils.[ch]: new files implementing transform matrix assembly utility functions. * app/tools/gimptransformtool.[ch]: removed the stuff here. cleanup. * app/tools/transform_options.[ch]: removed all stuff which does not belong here, e.g. the transform_tool_* functions and the global "transform_options" variable. Works like all other tool options now. * app/tools/gimpfliptool.[ch] * app/tools/gimpperspectivetool.[ch] * app/tools/gimprotatetool.[ch] * app/tools/gimpscaletool.[ch] * app/tools/gimpsheartool.[ch]: massive code removal because we can use core/gimpdrawable-fransform* functions now. cleanup. * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl: added new PDB group "transform_tools". * tools/pdbgen/pdb/tools.pdb: removed the transform stuff here... * tools/pdbgen/pdb/transform_tools.pdb: and added *much* simplified versions which use the new core/gimpdrawable-transform* utilities. * app/pdb/Makefile.am * app/pdb/transform_tools_cmds.c: new file. * app/pdb/internal_procs.c * app/pdb/tools_cmds.c: regenerated. * libgimp/Makefile.am * libgimp/gimp_pdb.h * libgimp/gimptransformtools_pdb.[ch]: new files. * libgimp/gimptools_pdb.[ch]: regenerated.
2001-11-19 10:23:43 -08:00
/* local function prototypes */
static gboolean gimp_scale_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
GimpMatrix3 *transform);
app: in GimpTransformGridTool, allow linking forward/backward transforms Add a GimpTransformGridTool::matrix_to_info() virtual function, which should extract the tool-specific transformation parameters given a transformation matrix, and the old parameter set (which is needed in some tools, to derive the parameters that aren't encoded in the matrix, such as the pivot point). The transformation matrix can be any combination of matrices calculated by the tool, and their inverses. Subclasses should only implement this function if every such matrix can be mapped back to transformation parameters. This is currently the case for all the transform-grid tools, except for the shear tool (since it only supports shearing along one of the horizontal or the vertical directions, however, the combined matrix may require shearing in both directions). When a transform-grid tool implements this function, show a chain- button between the two transform-direction radio-buttons in the tool options. When the chain-button is linked, whenever the transform corresponding to the active direction is modified, adjust the transform corresponding to the non-active direction such that the overall transform remains the same. One notable workflow that this enables is transforming a layer while adjusting a different area than its boundary, by first defining the area while the transform-directions are linked, and then transforming the area while the transform-directions are unlinked. (cherry picked from commit 39e23267f7ac76030f02e5f68bf7994a02bb81a1)
2019-02-04 12:33:44 -08:00
static void gimp_scale_tool_matrix_to_info (GimpTransformGridTool *tg_tool,
const GimpMatrix3 *transform);
static gchar * gimp_scale_tool_get_undo_desc (GimpTransformGridTool *tg_tool);
static void gimp_scale_tool_dialog (GimpTransformGridTool *tg_tool);
static void gimp_scale_tool_dialog_update (GimpTransformGridTool *tg_tool);
static void gimp_scale_tool_prepare (GimpTransformGridTool *tg_tool);
static GimpToolWidget * gimp_scale_tool_get_widget (GimpTransformGridTool *tg_tool);
static void gimp_scale_tool_update_widget (GimpTransformGridTool *tg_tool);
static void gimp_scale_tool_widget_changed (GimpTransformGridTool *tg_tool);
static void gimp_scale_tool_size_notify (GtkWidget *box,
GParamSpec *pspec,
GimpTransformGridTool *tg_tool);
G_DEFINE_TYPE (GimpScaleTool, gimp_scale_tool, GIMP_TYPE_TRANSFORM_GRID_TOOL)
2001-03-24 20:08:51 -08:00
#define parent_class gimp_scale_tool_parent_class
forgot to commit last time. 2001-11-19 Michael Natterer <mitch@gimp.org> * app/display/gimpdisplay-foreach.c: forgot to commit last time. Transform stuff cleanup: * app/core/Makefile.am * app/core/core-types.h * app/core/gimpdrawable-transform.[ch]: new files implementing the actual transform functions cut from tools/gimptransformtool.*. * app/core/gimpdrawable-transform-utils.[ch]: new files implementing transform matrix assembly utility functions. * app/tools/gimptransformtool.[ch]: removed the stuff here. cleanup. * app/tools/transform_options.[ch]: removed all stuff which does not belong here, e.g. the transform_tool_* functions and the global "transform_options" variable. Works like all other tool options now. * app/tools/gimpfliptool.[ch] * app/tools/gimpperspectivetool.[ch] * app/tools/gimprotatetool.[ch] * app/tools/gimpscaletool.[ch] * app/tools/gimpsheartool.[ch]: massive code removal because we can use core/gimpdrawable-fransform* functions now. cleanup. * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl: added new PDB group "transform_tools". * tools/pdbgen/pdb/tools.pdb: removed the transform stuff here... * tools/pdbgen/pdb/transform_tools.pdb: and added *much* simplified versions which use the new core/gimpdrawable-transform* utilities. * app/pdb/Makefile.am * app/pdb/transform_tools_cmds.c: new file. * app/pdb/internal_procs.c * app/pdb/tools_cmds.c: regenerated. * libgimp/Makefile.am * libgimp/gimp_pdb.h * libgimp/gimptransformtools_pdb.[ch]: new files. * libgimp/gimptools_pdb.[ch]: regenerated.
2001-11-19 10:23:43 -08:00
2001-03-24 20:08:51 -08:00
void
2002-03-28 19:50:29 -08:00
gimp_scale_tool_register (GimpToolRegisterCallback callback,
app/tools/gimpairbrushtool.[ch] app/tools/gimpbezierselecttool.[ch] 2002-05-03 Sven Neumann <sven@gimp.org> * app/tools/gimpairbrushtool.[ch] * app/tools/gimpbezierselecttool.[ch] * app/tools/gimpblendtool.[ch] * app/tools/gimpbrightnesscontrasttool.[ch] * app/tools/gimpbucketfilltool[.ch] * app/tools/gimpbycolorselecttool[.ch] * app/tools/gimpclonetool[.ch] * app/tools/gimpcolorbalancetool[.ch] * app/tools/gimpcolorpickertool[.ch] * app/tools/gimpconvolvetool[.ch] * app/tools/gimpcroptool[.ch] * app/tools/gimpcurvestool[.ch] * app/tools/gimpdodgeburntool[.ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool[.ch] * app/tools/gimperasertool[.ch] * app/tools/gimpfliptool[.ch] * app/tools/gimpfreeselecttool[.ch] * app/tools/gimpfuzzyselecttool[.ch] * app/tools/gimphistogramtool[.ch] * app/tools/gimphuesaturationtool[.ch] * app/tools/gimpinktool[.ch] * app/tools/gimpiscissorstool[.ch] * app/tools/gimplevelstool[.ch] * app/tools/gimpmagnifytool[.ch] * app/tools/gimpmeasuretool[.ch] * app/tools/gimpmovetool[.ch] * app/tools/gimppaintbrushtool[.ch] * app/tools/gimppainttool.c * app/tools/gimppathtool[.ch] * app/tools/gimppenciltool[.ch] * app/tools/gimpperspectivetool[.ch] * app/tools/gimpposterizetool[.ch] * app/tools/gimprectselecttool[.ch] * app/tools/gimprotatetool[.ch] * app/tools/gimpscaletool[.ch] * app/tools/gimpselectiontool.c * app/tools/gimpsheartool[.ch] * app/tools/gimpsmudgetool[.ch] * app/tools/gimptexttool[.ch] * app/tools/gimpthresholdtool[.ch] * app/tools/gimptool.c * app/tools/gimptoolcontrol.h * app/tools/gimptoolmodule[.ch] * app/tools/gimptransformtool.c * app/tools/gimpvectortool[.ch] * app/tools/path_tool.c * app/tools/tool_manager[.ch] * app/tools/tools.c * libgimptool/gimptool.c * libgimptool/gimptoolcontrol.h * libgimptool/gimptoolmodule.h: removed tons of warnings. Do we need to add -Werror to the CFLAGS to avoid such a mess in the future ?! Also had to enforce the GIMP coding style in lots of places :-( * libgimp/gimppixelrgn.c: got sick and tired of debugging plug-ins, so I've added checks for most parameters passed to the GimpPixelRgn functions. This will slow down plug-in execution a little bit but should help to find bugs early.
2002-05-03 04:31:08 -07:00
gpointer data)
2001-03-24 20:08:51 -08:00
{
2002-03-28 19:50:29 -08:00
(* callback) (GIMP_TYPE_SCALE_TOOL,
GIMP_TYPE_TRANSFORM_GRID_OPTIONS,
gimp_transform_grid_options_gui,
GIMP_CONTEXT_PROP_MASK_BACKGROUND,
./mitch --sanitize-identifier-namespace 2002-03-20 Michael Natterer <mitch@gimp.org> ./mitch --sanitize-identifier-namespace * app/core/gimpcontext.c * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-dnd.c * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/dialogs.c * app/gui/edit-commands.c * app/gui/gui.c * app/gui/menus.c * app/gui/vectors-commands.c * app/gui/view-commands.c * 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/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/gimpiscissorstool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppaintbrushtool.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/gimpsheartool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/gimpvectortool.c * app/widgets/gimpdnd.c * app/widgets/gimptoolbox-indicator-area.c * app/widgets/gimptoolbox.c: s/gimp:/gimp-/g and s/_/-/g for all identifier strings (e.g. gimp:eraser_tool -> gimp-eraser-tool, gimp:layer-list -> gimp-layer-list, ...) * plug-ins/tools/common/gimpbrushselecttool.c: s/gimp:brush_select_tool/gimp-brush-select-tool-module/ Don't quite remember why I introduced the "gimp:" prefix in the first place, but we can always add it back if we need it (for whatever reason) You may want to edit your ~/.gimp-1.3/sessionrc and devicerc or all session settings will be lost due to parse errors.
2002-03-21 04:17:17 -08:00
"gimp-scale-tool",
_("Scale"),
_("Scale Tool: Scale the layer, selection or path"),
N_("_Scale"), "<shift>S",
NULL, GIMP_HELP_TOOL_SCALE,
GIMP_ICON_TOOL_SCALE,
app/tools/gimpairbrushtool.[ch] app/tools/gimpbezierselecttool.[ch] 2002-05-03 Sven Neumann <sven@gimp.org> * app/tools/gimpairbrushtool.[ch] * app/tools/gimpbezierselecttool.[ch] * app/tools/gimpblendtool.[ch] * app/tools/gimpbrightnesscontrasttool.[ch] * app/tools/gimpbucketfilltool[.ch] * app/tools/gimpbycolorselecttool[.ch] * app/tools/gimpclonetool[.ch] * app/tools/gimpcolorbalancetool[.ch] * app/tools/gimpcolorpickertool[.ch] * app/tools/gimpconvolvetool[.ch] * app/tools/gimpcroptool[.ch] * app/tools/gimpcurvestool[.ch] * app/tools/gimpdodgeburntool[.ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool[.ch] * app/tools/gimperasertool[.ch] * app/tools/gimpfliptool[.ch] * app/tools/gimpfreeselecttool[.ch] * app/tools/gimpfuzzyselecttool[.ch] * app/tools/gimphistogramtool[.ch] * app/tools/gimphuesaturationtool[.ch] * app/tools/gimpinktool[.ch] * app/tools/gimpiscissorstool[.ch] * app/tools/gimplevelstool[.ch] * app/tools/gimpmagnifytool[.ch] * app/tools/gimpmeasuretool[.ch] * app/tools/gimpmovetool[.ch] * app/tools/gimppaintbrushtool[.ch] * app/tools/gimppainttool.c * app/tools/gimppathtool[.ch] * app/tools/gimppenciltool[.ch] * app/tools/gimpperspectivetool[.ch] * app/tools/gimpposterizetool[.ch] * app/tools/gimprectselecttool[.ch] * app/tools/gimprotatetool[.ch] * app/tools/gimpscaletool[.ch] * app/tools/gimpselectiontool.c * app/tools/gimpsheartool[.ch] * app/tools/gimpsmudgetool[.ch] * app/tools/gimptexttool[.ch] * app/tools/gimpthresholdtool[.ch] * app/tools/gimptool.c * app/tools/gimptoolcontrol.h * app/tools/gimptoolmodule[.ch] * app/tools/gimptransformtool.c * app/tools/gimpvectortool[.ch] * app/tools/path_tool.c * app/tools/tool_manager[.ch] * app/tools/tools.c * libgimptool/gimptool.c * libgimptool/gimptoolcontrol.h * libgimptool/gimptoolmodule.h: removed tons of warnings. Do we need to add -Werror to the CFLAGS to avoid such a mess in the future ?! Also had to enforce the GIMP coding style in lots of places :-( * libgimp/gimppixelrgn.c: got sick and tired of debugging plug-ins, so I've added checks for most parameters passed to the GimpPixelRgn functions. This will slow down plug-in execution a little bit but should help to find bugs early.
2002-05-03 04:31:08 -07:00
data);
}
2001-03-24 20:08:51 -08:00
static void
gimp_scale_tool_class_init (GimpScaleToolClass *klass)
{
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
tg_class->info_to_matrix = gimp_scale_tool_info_to_matrix;
app: in GimpTransformGridTool, allow linking forward/backward transforms Add a GimpTransformGridTool::matrix_to_info() virtual function, which should extract the tool-specific transformation parameters given a transformation matrix, and the old parameter set (which is needed in some tools, to derive the parameters that aren't encoded in the matrix, such as the pivot point). The transformation matrix can be any combination of matrices calculated by the tool, and their inverses. Subclasses should only implement this function if every such matrix can be mapped back to transformation parameters. This is currently the case for all the transform-grid tools, except for the shear tool (since it only supports shearing along one of the horizontal or the vertical directions, however, the combined matrix may require shearing in both directions). When a transform-grid tool implements this function, show a chain- button between the two transform-direction radio-buttons in the tool options. When the chain-button is linked, whenever the transform corresponding to the active direction is modified, adjust the transform corresponding to the non-active direction such that the overall transform remains the same. One notable workflow that this enables is transforming a layer while adjusting a different area than its boundary, by first defining the area while the transform-directions are linked, and then transforming the area while the transform-directions are unlinked. (cherry picked from commit 39e23267f7ac76030f02e5f68bf7994a02bb81a1)
2019-02-04 12:33:44 -08:00
tg_class->matrix_to_info = gimp_scale_tool_matrix_to_info;
tg_class->get_undo_desc = gimp_scale_tool_get_undo_desc;
tg_class->dialog = gimp_scale_tool_dialog;
tg_class->dialog_update = gimp_scale_tool_dialog_update;
tg_class->prepare = gimp_scale_tool_prepare;
tg_class->get_widget = gimp_scale_tool_get_widget;
tg_class->update_widget = gimp_scale_tool_update_widget;
tg_class->widget_changed = gimp_scale_tool_widget_changed;
tr_class->undo_desc = C_("undo-type", "Scale");
tr_class->progress_text = _("Scaling");
tg_class->ok_button_label = _("_Scale");
2001-03-24 20:08:51 -08:00
}
static void
forgot to commit last time. 2001-11-19 Michael Natterer <mitch@gimp.org> * app/display/gimpdisplay-foreach.c: forgot to commit last time. Transform stuff cleanup: * app/core/Makefile.am * app/core/core-types.h * app/core/gimpdrawable-transform.[ch]: new files implementing the actual transform functions cut from tools/gimptransformtool.*. * app/core/gimpdrawable-transform-utils.[ch]: new files implementing transform matrix assembly utility functions. * app/tools/gimptransformtool.[ch]: removed the stuff here. cleanup. * app/tools/transform_options.[ch]: removed all stuff which does not belong here, e.g. the transform_tool_* functions and the global "transform_options" variable. Works like all other tool options now. * app/tools/gimpfliptool.[ch] * app/tools/gimpperspectivetool.[ch] * app/tools/gimprotatetool.[ch] * app/tools/gimpscaletool.[ch] * app/tools/gimpsheartool.[ch]: massive code removal because we can use core/gimpdrawable-fransform* functions now. cleanup. * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl: added new PDB group "transform_tools". * tools/pdbgen/pdb/tools.pdb: removed the transform stuff here... * tools/pdbgen/pdb/transform_tools.pdb: and added *much* simplified versions which use the new core/gimpdrawable-transform* utilities. * app/pdb/Makefile.am * app/pdb/transform_tools_cmds.c: new file. * app/pdb/internal_procs.c * app/pdb/tools_cmds.c: regenerated. * libgimp/Makefile.am * libgimp/gimp_pdb.h * libgimp/gimptransformtools_pdb.[ch]: new files. * libgimp/gimptools_pdb.[ch]: regenerated.
2001-11-19 10:23:43 -08:00
gimp_scale_tool_init (GimpScaleTool *scale_tool)
1997-11-24 14:05:25 -08:00
{
GimpTool *tool = GIMP_TOOL (scale_tool);
1997-11-24 14:05:25 -08:00
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_RESIZE);
}
static gboolean
gimp_scale_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
GimpMatrix3 *transform)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
gimp_matrix3_identity (transform);
gimp_transform_matrix_scale (transform,
tr_tool->x1,
tr_tool->y1,
tr_tool->x2 - tr_tool->x1,
tr_tool->y2 - tr_tool->y1,
tg_tool->trans_info[X0],
tg_tool->trans_info[Y0],
tg_tool->trans_info[X1] - tg_tool->trans_info[X0],
tg_tool->trans_info[Y1] - tg_tool->trans_info[Y0]);
return TRUE;
}
app: in GimpTransformGridTool, allow linking forward/backward transforms Add a GimpTransformGridTool::matrix_to_info() virtual function, which should extract the tool-specific transformation parameters given a transformation matrix, and the old parameter set (which is needed in some tools, to derive the parameters that aren't encoded in the matrix, such as the pivot point). The transformation matrix can be any combination of matrices calculated by the tool, and their inverses. Subclasses should only implement this function if every such matrix can be mapped back to transformation parameters. This is currently the case for all the transform-grid tools, except for the shear tool (since it only supports shearing along one of the horizontal or the vertical directions, however, the combined matrix may require shearing in both directions). When a transform-grid tool implements this function, show a chain- button between the two transform-direction radio-buttons in the tool options. When the chain-button is linked, whenever the transform corresponding to the active direction is modified, adjust the transform corresponding to the non-active direction such that the overall transform remains the same. One notable workflow that this enables is transforming a layer while adjusting a different area than its boundary, by first defining the area while the transform-directions are linked, and then transforming the area while the transform-directions are unlinked. (cherry picked from commit 39e23267f7ac76030f02e5f68bf7994a02bb81a1)
2019-02-04 12:33:44 -08:00
static void
gimp_scale_tool_matrix_to_info (GimpTransformGridTool *tg_tool,
const GimpMatrix3 *transform)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
gdouble x;
gdouble y;
gdouble w;
gdouble h;
x = transform->coeff[0][2];
y = transform->coeff[1][2];
w = transform->coeff[0][0];
h = transform->coeff[1][1];
tg_tool->trans_info[X0] = x + w * tr_tool->x1;
tg_tool->trans_info[Y0] = y + h * tr_tool->y1;
tg_tool->trans_info[X1] = tg_tool->trans_info[X0] +
w * (tr_tool->x2 - tr_tool->x1);
tg_tool->trans_info[Y1] = tg_tool->trans_info[Y0] +
h * (tr_tool->y2 - tr_tool->y1);
}
static gchar *
gimp_scale_tool_get_undo_desc (GimpTransformGridTool *tg_tool)
{
gint width;
gint height;
width = ROUND (tg_tool->trans_info[X1] - tg_tool->trans_info[X0]);
height = ROUND (tg_tool->trans_info[Y1] - tg_tool->trans_info[Y0]);
1997-11-24 14:05:25 -08:00
return g_strdup_printf (C_("undo-type", "Scale to %d x %d"),
width, height);
1997-11-24 14:05:25 -08:00
}
static void
gimp_scale_tool_dialog (GimpTransformGridTool *tg_tool)
{
}
static void
gimp_scale_tool_dialog_update (GimpTransformGridTool *tg_tool)
{
GimpTransformGridOptions *options = GIMP_TRANSFORM_GRID_TOOL_GET_OPTIONS (tg_tool);
gint width;
gint height;
width = ROUND (tg_tool->trans_info[X1] - tg_tool->trans_info[X0]);
height = ROUND (tg_tool->trans_info[Y1] - tg_tool->trans_info[Y0]);
g_object_set (GIMP_SCALE_TOOL (tg_tool)->box,
"width", width,
"height", height,
"keep-aspect", options->constrain_scale,
NULL);
}
static void
gimp_scale_tool_prepare (GimpTransformGridTool *tg_tool)
{
GimpScaleTool *scale = GIMP_SCALE_TOOL (tg_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GimpTransformGridOptions *options = GIMP_TRANSFORM_GRID_TOOL_GET_OPTIONS (tg_tool);
GimpDisplay *display = GIMP_TOOL (tg_tool)->display;
gdouble xres;
gdouble yres;
tg_tool->trans_info[X0] = (gdouble) tr_tool->x1;
tg_tool->trans_info[Y0] = (gdouble) tr_tool->y1;
tg_tool->trans_info[X1] = (gdouble) tr_tool->x2;
tg_tool->trans_info[Y1] = (gdouble) tr_tool->y2;
gimp_image_get_resolution (gimp_display_get_image (display),
&xres, &yres);
if (scale->box)
{
g_signal_handlers_disconnect_by_func (scale->box,
gimp_scale_tool_size_notify,
tg_tool);
gtk_widget_destroy (scale->box);
}
/* Need to create a new GimpSizeBox widget because the initial
* width and height is what counts as 100%.
*/
scale->box =
g_object_new (GIMP_TYPE_SIZE_BOX,
"width", tr_tool->x2 - tr_tool->x1,
"height", tr_tool->y2 - tr_tool->y1,
"keep-aspect", options->constrain_scale,
"unit", gimp_display_get_shell (display)->unit,
"xresolution", xres,
"yresolution", yres,
NULL);
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tg_tool->gui)),
scale->box, FALSE, FALSE, 0);
gtk_widget_show (scale->box);
g_signal_connect (scale->box, "notify",
G_CALLBACK (gimp_scale_tool_size_notify),
tg_tool);
}
static GimpToolWidget *
gimp_scale_tool_get_widget (GimpTransformGridTool *tg_tool)
1997-11-24 14:05:25 -08:00
{
GimpTool *tool = GIMP_TOOL (tg_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
GimpToolWidget *widget;
widget = gimp_tool_transform_grid_new (shell,
&tr_tool->transform,
tr_tool->x1,
tr_tool->y1,
tr_tool->x2,
tr_tool->y2);
g_object_set (widget,
"inside-function", GIMP_TRANSFORM_FUNCTION_SCALE,
"outside-function", GIMP_TRANSFORM_FUNCTION_SCALE,
"use-corner-handles", TRUE,
"use-side-handles", TRUE,
"use-center-handle", TRUE,
NULL);
1997-11-24 14:05:25 -08:00
return widget;
1997-11-24 14:05:25 -08:00
}
static void
gimp_scale_tool_update_widget (GimpTransformGridTool *tg_tool)
1997-11-24 14:05:25 -08:00
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->update_widget (tg_tool);
g_object_set (
tg_tool->widget,
"x1", (gdouble) tr_tool->x1,
"y1", (gdouble) tr_tool->y1,
"x2", (gdouble) tr_tool->x2,
"y2", (gdouble) tr_tool->y2,
NULL);
}
static void
gimp_scale_tool_widget_changed (GimpTransformGridTool *tg_tool)
{
GimpTool *tool = GIMP_TOOL (tg_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GimpMatrix3 *transform;
gdouble x0, y0;
gdouble x1, y1;
gint width, height;
g_object_get (tg_tool->widget,
"transform", &transform,
NULL);
gimp_matrix3_transform_point (transform,
tr_tool->x1, tr_tool->y1,
&x0, &y0);
gimp_matrix3_transform_point (transform,
tr_tool->x2, tr_tool->y2,
&x1, &y1);
g_free (transform);
width = ROUND (x1 - x0);
height = ROUND (y1 - y0);
if (width > 0)
{
tg_tool->trans_info[X0] = x0;
tg_tool->trans_info[X1] = x1;
}
else if (fabs (x0 - tg_tool->trans_info[X0]) < EPSILON)
{
tg_tool->trans_info[X1] = tg_tool->trans_info[X0] + 1.0;
}
else if (fabs (x1 - tg_tool->trans_info[X1]) < EPSILON)
{
tg_tool->trans_info[X0] = tg_tool->trans_info[X1] - 1.0;
}
else
{
tg_tool->trans_info[X0] = (x0 + x1) / 2.0 - 0.5;
tg_tool->trans_info[X1] = (x0 + x1) / 2.0 + 0.5;
}
if (height > 0)
{
tg_tool->trans_info[Y0] = y0;
tg_tool->trans_info[Y1] = y1;
}
else if (fabs (y0 - tg_tool->trans_info[Y0]) < EPSILON)
{
tg_tool->trans_info[Y1] = tg_tool->trans_info[Y0] + 1.0;
}
else if (fabs (y1 - tg_tool->trans_info[Y1]) < EPSILON)
{
tg_tool->trans_info[Y0] = tg_tool->trans_info[Y1] - 1.0;
}
else
{
tg_tool->trans_info[Y0] = (y0 + y1) / 2.0 - 0.5;
tg_tool->trans_info[Y1] = (y0 + y1) / 2.0 + 0.5;
}
if (width <= 0 || height <= 0)
gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->widget_changed (tg_tool);
}
static void
gimp_scale_tool_size_notify (GtkWidget *box,
GParamSpec *pspec,
GimpTransformGridTool *tg_tool)
{
GimpTransformGridOptions *options = GIMP_TRANSFORM_GRID_TOOL_GET_OPTIONS (tg_tool);
if (! strcmp (pspec->name, "width") ||
! strcmp (pspec->name, "height"))
{
gint width;
gint height;
gint old_width;
gint old_height;
g_object_get (box,
"width", &width,
"height", &height,
NULL);
old_width = ROUND (tg_tool->trans_info[X1] - tg_tool->trans_info[X0]);
old_height = ROUND (tg_tool->trans_info[Y1] - tg_tool->trans_info[Y0]);
if ((width != old_width) || (height != old_height))
{
GimpTool *tool = GIMP_TOOL (tg_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
if (options->frompivot_scale)
{
gdouble center_x;
gdouble center_y;
center_x = (tg_tool->trans_info[X0] +
tg_tool->trans_info[X1]) / 2.0;
center_y = (tg_tool->trans_info[Y0] +
tg_tool->trans_info[Y1]) / 2.0;
tg_tool->trans_info[X0] = center_x - width / 2.0;
tg_tool->trans_info[Y0] = center_y - height / 2.0;
tg_tool->trans_info[X1] = center_x + width / 2.0;
tg_tool->trans_info[Y1] = center_y + height / 2.0;
}
else
{
tg_tool->trans_info[X1] = tg_tool->trans_info[X0] + width;
tg_tool->trans_info[Y1] = tg_tool->trans_info[Y0] + height;
}
gimp_transform_grid_tool_push_internal_undo (tg_tool);
gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
}
}
else if (! strcmp (pspec->name, "keep-aspect"))
{
gboolean constrain;
g_object_get (box,
"keep-aspect", &constrain,
NULL);
if (constrain != options->constrain_scale)
{
gint width;
gint height;
g_object_get (box,
"width", &width,
"height", &height,
NULL);
g_object_set (options,
"constrain-scale", constrain,
NULL);
}
}
}