2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-04-29 04:14:32 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-04-29 04:14:32 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-04-29 04:14:32 +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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2001-04-29 04:14:32 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-03-20 02:57:55 +08:00
|
|
|
#include <gegl.h>
|
2001-04-29 04:14:32 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2019-07-31 16:16:21 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-04-29 04:14:32 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "tools-types.h"
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpcoreconfig.h"
|
|
|
|
|
2002-02-12 10:31:45 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-04-29 04:14:32 +08:00
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
#include "widgets/gimppropwidgets.h"
|
2002-12-20 00:33:29 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2002-03-17 22:07:54 +08:00
|
|
|
|
2003-06-30 04:40:45 +08:00
|
|
|
#include "gimptooloptions-gui.h"
|
2003-02-09 05:12:03 +08:00
|
|
|
#include "gimptransformoptions.h"
|
2001-04-29 04:14:32 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-04-29 04:14:32 +08:00
|
|
|
|
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2003-05-31 07:52:24 +08:00
|
|
|
PROP_TYPE,
|
2003-02-08 01:12:21 +08:00
|
|
|
PROP_DIRECTION,
|
|
|
|
PROP_INTERPOLATION,
|
2018-06-10 04:25:03 +08:00
|
|
|
PROP_CLIP
|
2003-02-08 01:12:21 +08:00
|
|
|
};
|
|
|
|
|
2001-04-29 04:14:32 +08:00
|
|
|
|
2015-12-29 19:47:04 +08:00
|
|
|
static void gimp_transform_options_config_iface_init (GimpConfigInterface *config_iface);
|
|
|
|
|
2011-07-28 05:15:02 +08:00
|
|
|
static void gimp_transform_options_set_property (GObject *object,
|
2004-07-03 05:56:30 +08:00
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2011-07-28 05:15:02 +08:00
|
|
|
static void gimp_transform_options_get_property (GObject *object,
|
2004-07-03 05:56:30 +08:00
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2003-02-08 01:12:21 +08:00
|
|
|
|
2015-12-29 19:47:04 +08:00
|
|
|
static void gimp_transform_options_reset (GimpConfig *config);
|
2003-02-08 01:12:21 +08:00
|
|
|
|
2015-12-29 19:47:04 +08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpTransformOptions, gimp_transform_options,
|
|
|
|
GIMP_TYPE_TOOL_OPTIONS,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
|
|
|
|
gimp_transform_options_config_iface_init))
|
2001-04-29 04:14:32 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
#define parent_class gimp_transform_options_parent_class
|
2001-04-29 04:14:32 +08:00
|
|
|
|
2015-12-29 19:47:04 +08:00
|
|
|
static GimpConfigInterface *parent_config_iface = NULL;
|
|
|
|
|
2001-04-29 04:14:32 +08:00
|
|
|
|
2003-07-17 23:22:21 +08:00
|
|
|
static void
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_transform_options_class_init (GimpTransformOptionsClass *klass)
|
2001-04-29 04:14:32 +08:00
|
|
|
{
|
2015-12-29 19:47:04 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2003-02-08 01:12:21 +08:00
|
|
|
|
|
|
|
object_class->set_property = gimp_transform_options_set_property;
|
|
|
|
object_class->get_property = gimp_transform_options_get_property;
|
|
|
|
|
2016-02-12 06:44:07 +08:00
|
|
|
GIMP_CONFIG_PROP_ENUM (object_class, PROP_TYPE,
|
|
|
|
"type",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_TRANSFORM_TYPE,
|
|
|
|
GIMP_TRANSFORM_TYPE_LAYER,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
GIMP_CONFIG_PROP_ENUM (object_class, PROP_DIRECTION,
|
|
|
|
"direction",
|
|
|
|
_("Direction"),
|
|
|
|
_("Direction of transformation"),
|
|
|
|
GIMP_TYPE_TRANSFORM_DIRECTION,
|
|
|
|
GIMP_TRANSFORM_FORWARD,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
GIMP_CONFIG_PROP_ENUM (object_class, PROP_INTERPOLATION,
|
|
|
|
"interpolation",
|
|
|
|
_("Interpolation"),
|
|
|
|
_("Interpolation method"),
|
|
|
|
GIMP_TYPE_INTERPOLATION_TYPE,
|
|
|
|
GIMP_INTERPOLATION_LINEAR,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
GIMP_CONFIG_PROP_ENUM (object_class, PROP_CLIP,
|
|
|
|
"clip",
|
|
|
|
_("Clipping"),
|
|
|
|
_("How to clip"),
|
|
|
|
GIMP_TYPE_TRANSFORM_RESIZE,
|
|
|
|
GIMP_TRANSFORM_RESIZE_ADJUST,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-05 22:39:40 +08:00
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2015-12-29 19:47:04 +08:00
|
|
|
static void
|
|
|
|
gimp_transform_options_config_iface_init (GimpConfigInterface *config_iface)
|
|
|
|
{
|
|
|
|
parent_config_iface = g_type_interface_peek_parent (config_iface);
|
|
|
|
|
|
|
|
config_iface->reset = gimp_transform_options_reset;
|
|
|
|
}
|
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
static void
|
|
|
|
gimp_transform_options_init (GimpTransformOptions *options)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
static void
|
|
|
|
gimp_transform_options_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2004-09-24 20:01:35 +08:00
|
|
|
GimpTransformOptions *options = GIMP_TRANSFORM_OPTIONS (object);
|
2003-02-08 01:12:21 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2003-05-31 07:52:24 +08:00
|
|
|
case PROP_TYPE:
|
|
|
|
options->type = g_value_get_enum (value);
|
|
|
|
break;
|
2003-02-08 01:12:21 +08:00
|
|
|
case PROP_DIRECTION:
|
|
|
|
options->direction = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
case PROP_INTERPOLATION:
|
|
|
|
options->interpolation = g_value_get_enum (value);
|
|
|
|
break;
|
2005-05-07 17:38:29 +08:00
|
|
|
case PROP_CLIP:
|
2006-12-25 00:48:08 +08:00
|
|
|
options->clip = g_value_get_enum (value);
|
2003-02-08 01:12:21 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_transform_options_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2004-09-24 20:01:35 +08:00
|
|
|
GimpTransformOptions *options = GIMP_TRANSFORM_OPTIONS (object);
|
2003-02-08 01:12:21 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2003-05-31 07:52:24 +08:00
|
|
|
case PROP_TYPE:
|
|
|
|
g_value_set_enum (value, options->type);
|
|
|
|
break;
|
2003-02-08 01:12:21 +08:00
|
|
|
case PROP_DIRECTION:
|
|
|
|
g_value_set_enum (value, options->direction);
|
|
|
|
break;
|
|
|
|
case PROP_INTERPOLATION:
|
|
|
|
g_value_set_enum (value, options->interpolation);
|
|
|
|
break;
|
2005-05-07 17:38:29 +08:00
|
|
|
case PROP_CLIP:
|
2006-12-25 00:48:08 +08:00
|
|
|
g_value_set_enum (value, options->clip);
|
2003-02-08 01:12:21 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-12-29 19:47:04 +08:00
|
|
|
gimp_transform_options_reset (GimpConfig *config)
|
2003-07-17 23:22:21 +08:00
|
|
|
{
|
2015-12-29 19:47:04 +08:00
|
|
|
GimpToolOptions *tool_options = GIMP_TOOL_OPTIONS (config);
|
|
|
|
GParamSpec *pspec;
|
2003-02-08 01:12:21 +08:00
|
|
|
|
2015-12-29 19:47:04 +08:00
|
|
|
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (config),
|
2003-02-08 01:12:21 +08:00
|
|
|
"interpolation");
|
|
|
|
|
|
|
|
if (pspec)
|
2003-07-17 23:22:21 +08:00
|
|
|
G_PARAM_SPEC_ENUM (pspec)->default_value =
|
|
|
|
tool_options->tool_info->gimp->config->interpolation_type;
|
2004-10-07 01:21:22 +08:00
|
|
|
|
2015-12-29 19:47:04 +08:00
|
|
|
parent_config_iface->reset (config);
|
2003-02-05 22:39:40 +08:00
|
|
|
}
|
|
|
|
|
2008-03-06 19:54:44 +08:00
|
|
|
/**
|
|
|
|
* gimp_transform_options_gui:
|
2018-06-10 04:25:03 +08:00
|
|
|
* @tool_options: a #GimpToolOptions
|
|
|
|
* @direction: whether to show the direction frame
|
|
|
|
* @interpolation: whether to show the interpolation menu
|
|
|
|
* @clipping: whether to show the clipping menu
|
2008-03-06 19:54:44 +08:00
|
|
|
*
|
|
|
|
* Build the Transform Tool Options.
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: a container holding the transform tool options
|
2008-03-06 19:54:44 +08:00
|
|
|
**/
|
2003-02-10 01:32:52 +08:00
|
|
|
GtkWidget *
|
2018-06-10 04:25:03 +08:00
|
|
|
gimp_transform_options_gui (GimpToolOptions *tool_options,
|
|
|
|
gboolean direction,
|
|
|
|
gboolean interpolation,
|
|
|
|
gboolean clipping)
|
2003-02-05 22:39:40 +08:00
|
|
|
{
|
2018-12-10 20:39:32 +08:00
|
|
|
GObject *config = G_OBJECT (tool_options);
|
|
|
|
GimpTransformOptions *options = GIMP_TRANSFORM_OPTIONS (tool_options);
|
|
|
|
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *box;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *combo;
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2011-09-30 17:29:11 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
2003-05-31 07:52:24 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2018-12-10 20:39:32 +08:00
|
|
|
options->type_box = hbox;
|
|
|
|
|
2006-10-04 03:32:41 +08:00
|
|
|
label = gtk_label_new (_("Transform:"));
|
2003-05-31 07:52:24 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2014-05-08 03:30:06 +08:00
|
|
|
box = gimp_prop_enum_icon_box_new (config, "type", "gimp", 0, 0);
|
2008-03-08 22:07:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), box, FALSE, FALSE, 0);
|
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
if (direction)
|
|
|
|
{
|
|
|
|
frame = gimp_prop_enum_radio_frame_new (config, "direction", NULL,
|
|
|
|
0, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
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.
2019-02-05 04:33:44 +08:00
|
|
|
|
|
|
|
options->direction_frame = frame;
|
2018-06-10 04:25:03 +08:00
|
|
|
}
|
2001-04-29 04:14:32 +08:00
|
|
|
|
2005-05-07 17:38:29 +08:00
|
|
|
/* the interpolation menu */
|
2018-06-10 04:25:03 +08:00
|
|
|
if (interpolation)
|
2006-05-19 18:56:34 +08:00
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
combo = gimp_prop_enum_combo_box_new (config, "interpolation", 0, 0);
|
|
|
|
gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Interpolation"));
|
|
|
|
g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
|
2006-05-19 18:56:34 +08:00
|
|
|
}
|
2018-01-12 03:05:53 +08:00
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
/* the clipping menu */
|
|
|
|
if (clipping)
|
2011-08-06 06:00:35 +08:00
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
combo = gimp_prop_enum_combo_box_new (config, "clip", 0, 0);
|
|
|
|
gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Clipping"));
|
|
|
|
g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
|
2011-08-06 06:00:35 +08:00
|
|
|
}
|
2006-05-19 18:56:34 +08:00
|
|
|
|
2003-02-10 01:32:52 +08:00
|
|
|
return vbox;
|
2001-04-29 04:14:32 +08:00
|
|
|
}
|