mirror of https://github.com/GNOME/gimp.git
app: add GimpTransformGridTool; derive most transform tools from it
While most of our transform tools use an interactive transform grid, and have similar behavior, the flip tool is an odd one out. The new "auto straighten" function of the measure tool introduces another tool that performs transformations, while not behaving like the rest of the transform tools. Factor out the parts of GimpTransformTool that handle user interaction into GimpTransformGridTool (with corresponding GimpTransformGridOptions, and GimpTransformGridToolUndo), and only leave the basic transform functionality and options in GimpTransformTool (and GimpTransformOptions). Derive all the transform tools (and transform-tool base classes) that previously derived from GimpTransformTool, from GimpTransformGridTool. The one exception is GimpFlipTool, which still derives from GimpTransformTool directly. The next commit will derive GimpMeasureTool from GimpTransformTool as well.
This commit is contained in:
parent
8d6f023b41
commit
1dbe765905
|
@ -848,7 +848,7 @@ gimp_undo_type_get_type (void)
|
|||
{ GIMP_UNDO_VECTORS_REMOVE, "GIMP_UNDO_VECTORS_REMOVE", "vectors-remove" },
|
||||
{ GIMP_UNDO_VECTORS_MOD, "GIMP_UNDO_VECTORS_MOD", "vectors-mod" },
|
||||
{ GIMP_UNDO_FS_TO_LAYER, "GIMP_UNDO_FS_TO_LAYER", "fs-to-layer" },
|
||||
{ GIMP_UNDO_TRANSFORM, "GIMP_UNDO_TRANSFORM", "transform" },
|
||||
{ GIMP_UNDO_TRANSFORM_GRID, "GIMP_UNDO_TRANSFORM_GRID", "transform-grid" },
|
||||
{ GIMP_UNDO_PAINT, "GIMP_UNDO_PAINT", "paint" },
|
||||
{ GIMP_UNDO_INK, "GIMP_UNDO_INK", "ink" },
|
||||
{ GIMP_UNDO_FOREGROUND_SELECT, "GIMP_UNDO_FOREGROUND_SELECT", "foreground-select" },
|
||||
|
@ -946,7 +946,7 @@ gimp_undo_type_get_type (void)
|
|||
{ GIMP_UNDO_VECTORS_REMOVE, NC_("undo-type", "Delete path"), NULL },
|
||||
{ GIMP_UNDO_VECTORS_MOD, NC_("undo-type", "Path modification"), NULL },
|
||||
{ GIMP_UNDO_FS_TO_LAYER, NC_("undo-type", "Floating selection to layer"), NULL },
|
||||
{ GIMP_UNDO_TRANSFORM, NC_("undo-type", "Transform"), NULL },
|
||||
{ GIMP_UNDO_TRANSFORM_GRID, NC_("undo-type", "Transform grid"), NULL },
|
||||
{ GIMP_UNDO_PAINT, NC_("undo-type", "Paint"), NULL },
|
||||
{ GIMP_UNDO_INK, NC_("undo-type", "Ink"), NULL },
|
||||
{ GIMP_UNDO_FOREGROUND_SELECT, NC_("undo-type", "Select foreground"), NULL },
|
||||
|
|
|
@ -444,7 +444,7 @@ typedef enum /*< pdb-skip >*/
|
|||
GIMP_UNDO_VECTORS_REMOVE, /*< desc="Delete path" >*/
|
||||
GIMP_UNDO_VECTORS_MOD, /*< desc="Path modification" >*/
|
||||
GIMP_UNDO_FS_TO_LAYER, /*< desc="Floating selection to layer" >*/
|
||||
GIMP_UNDO_TRANSFORM, /*< desc="Transform" >*/
|
||||
GIMP_UNDO_TRANSFORM_GRID, /*< desc="Transform grid" >*/
|
||||
GIMP_UNDO_PAINT, /*< desc="Paint" >*/
|
||||
GIMP_UNDO_INK, /*< desc="Ink" >*/
|
||||
GIMP_UNDO_FOREGROUND_SELECT, /*< desc="Select foreground" >*/
|
||||
|
|
|
@ -206,12 +206,16 @@ libapptools_a_sources = \
|
|||
gimptoolcontrol.h \
|
||||
gimptooloptions-gui.c \
|
||||
gimptooloptions-gui.h \
|
||||
gimptransformgridoptions.c \
|
||||
gimptransformgridoptions.h \
|
||||
gimptransformgridtool.c \
|
||||
gimptransformgridtool.h \
|
||||
gimptransformgridtoolundo.c \
|
||||
gimptransformgridtoolundo.h \
|
||||
gimptransformoptions.c \
|
||||
gimptransformoptions.h \
|
||||
gimptransformtool.c \
|
||||
gimptransformtool.h \
|
||||
gimptransformtoolundo.c \
|
||||
gimptransformtoolundo.h \
|
||||
gimpunifiedtransformtool.c \
|
||||
gimpunifiedtransformtool.h \
|
||||
gimpvectoroptions.c \
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "gimpflipoptions.h"
|
||||
#include "gimptooloptions-gui.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
@ -120,30 +119,17 @@ gimp_flip_options_gui (GimpToolOptions *tool_options)
|
|||
GObject *config = G_OBJECT (tool_options);
|
||||
GimpFlipOptions *options = GIMP_FLIP_OPTIONS (tool_options);
|
||||
GimpTransformOptions *tr_options = GIMP_TRANSFORM_OPTIONS (tool_options);
|
||||
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *box;
|
||||
GtkWidget *label;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *combo;
|
||||
gchar *str;
|
||||
GtkListStore *clip_model;
|
||||
GdkModifierType toggle_mask;
|
||||
|
||||
vbox = gimp_transform_options_gui (tool_options, FALSE, FALSE, FALSE);
|
||||
|
||||
toggle_mask = gimp_get_toggle_behavior_mask ();
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
label = gtk_label_new (_("Transform:"));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
box = gimp_prop_enum_icon_box_new (config, "type", "gimp", 0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), box, FALSE, FALSE, 0);
|
||||
gtk_widget_show (box);
|
||||
|
||||
/* tool toggle */
|
||||
str = g_strdup_printf (_("Direction (%s)"),
|
||||
gimp_get_mod_string (toggle_mask));
|
||||
|
|
|
@ -54,37 +54,38 @@
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static GimpDisplay * gimp_flip_tool_has_image (GimpTool *tool,
|
||||
GimpImage *image);
|
||||
static gboolean gimp_flip_tool_initialize (GimpTool *tool,
|
||||
GimpDisplay *display,
|
||||
GError **error);
|
||||
static void gimp_flip_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_flip_tool_oper_update (GimpTool *tool,
|
||||
const GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
gboolean proximity,
|
||||
GimpDisplay *display);
|
||||
static void gimp_flip_tool_cursor_update (GimpTool *tool,
|
||||
const GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_flip_tool_button_press (GimpTool *tool,
|
||||
const GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpButtonPressType press_type,
|
||||
GimpDisplay *display);
|
||||
static void gimp_flip_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_flip_tool_oper_update (GimpTool *tool,
|
||||
const GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
gboolean proximity,
|
||||
GimpDisplay *display);
|
||||
static void gimp_flip_tool_cursor_update (GimpTool *tool,
|
||||
const GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
|
||||
static void gimp_flip_tool_draw (GimpDrawTool *draw_tool);
|
||||
static void gimp_flip_tool_draw (GimpDrawTool *draw_tool);
|
||||
|
||||
static gchar * gimp_flip_tool_get_undo_desc (GimpTransformTool *tool);
|
||||
static GeglBuffer * gimp_flip_tool_transform (GimpTransformTool *tool,
|
||||
GimpItem *item,
|
||||
GeglBuffer *orig_buffer,
|
||||
gint orig_offset_x,
|
||||
gint orig_offset_y,
|
||||
GimpColorProfile **buffer_profile,
|
||||
gint *new_offset_x,
|
||||
gint *new_offset_y);
|
||||
static gchar * gimp_flip_tool_get_undo_desc (GimpTransformTool *tr_tool);
|
||||
static GeglBuffer * gimp_flip_tool_transform (GimpTransformTool *tr_tool,
|
||||
GimpItem *item,
|
||||
GeglBuffer *orig_buffer,
|
||||
gint orig_offset_x,
|
||||
gint orig_offset_y,
|
||||
GimpColorProfile **buffer_profile,
|
||||
gint *new_offset_x,
|
||||
gint *new_offset_y);
|
||||
|
||||
static GimpOrientationType gimp_flip_tool_get_flip_type (GimpFlipTool *flip);
|
||||
|
||||
|
@ -117,20 +118,19 @@ gimp_flip_tool_class_init (GimpFlipToolClass *klass)
|
|||
{
|
||||
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
||||
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
||||
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
|
||||
tool_class->has_image = gimp_flip_tool_has_image;
|
||||
tool_class->initialize = gimp_flip_tool_initialize;
|
||||
tool_class->modifier_key = gimp_flip_tool_modifier_key;
|
||||
tool_class->oper_update = gimp_flip_tool_oper_update;
|
||||
tool_class->cursor_update = gimp_flip_tool_cursor_update;
|
||||
tool_class->button_press = gimp_flip_tool_button_press;
|
||||
tool_class->modifier_key = gimp_flip_tool_modifier_key;
|
||||
tool_class->oper_update = gimp_flip_tool_oper_update;
|
||||
tool_class->cursor_update = gimp_flip_tool_cursor_update;
|
||||
|
||||
draw_tool_class->draw = gimp_flip_tool_draw;
|
||||
draw_tool_class->draw = gimp_flip_tool_draw;
|
||||
|
||||
trans_class->get_undo_desc = gimp_flip_tool_get_undo_desc;
|
||||
trans_class->transform = gimp_flip_tool_transform;
|
||||
tr_class->get_undo_desc = gimp_flip_tool_get_undo_desc;
|
||||
tr_class->transform = gimp_flip_tool_transform;
|
||||
|
||||
trans_class->ok_button_label = _("_Flip");
|
||||
tr_class->progress_text = _("Flipping");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -151,26 +151,17 @@ gimp_flip_tool_init (GimpFlipTool *flip_tool)
|
|||
flip_tool->guide = NULL;
|
||||
}
|
||||
|
||||
static GimpDisplay *
|
||||
gimp_flip_tool_has_image (GimpTool *tool,
|
||||
GimpImage *image)
|
||||
static void
|
||||
gimp_flip_tool_button_press (GimpTool *tool,
|
||||
const GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpButtonPressType press_type,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
/* avoid committing, and hence flipping, when changing tools */
|
||||
return NULL;
|
||||
}
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
static gboolean
|
||||
gimp_flip_tool_initialize (GimpTool *tool,
|
||||
GimpDisplay *display,
|
||||
GError **error)
|
||||
{
|
||||
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
|
||||
|
||||
/* let GimpTransformTool take control over the draw tool while it's active */
|
||||
if (gimp_draw_tool_is_active (draw_tool))
|
||||
gimp_draw_tool_stop (draw_tool);
|
||||
|
||||
return GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
|
||||
gimp_transform_tool_transform (tr_tool, display);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -258,7 +249,17 @@ gimp_flip_tool_cursor_update (GimpTool *tool,
|
|||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpFlipTool *flip = GIMP_FLIP_TOOL (tool);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
GimpFlipTool *flip = GIMP_FLIP_TOOL (tool);
|
||||
|
||||
if (! gimp_transform_tool_get_active_item (tr_tool, display, TRUE, NULL))
|
||||
{
|
||||
gimp_tool_set_cursor (tool, display,
|
||||
gimp_tool_control_get_cursor (tool->control),
|
||||
gimp_tool_control_get_tool_cursor (tool->control),
|
||||
GIMP_CURSOR_MODIFIER_BAD);
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_tool_control_set_toggled (tool->control,
|
||||
gimp_flip_tool_get_flip_type (flip) ==
|
||||
|
@ -309,7 +310,7 @@ gimp_flip_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
|||
}
|
||||
|
||||
static GeglBuffer *
|
||||
gimp_flip_tool_transform (GimpTransformTool *trans_tool,
|
||||
gimp_flip_tool_transform (GimpTransformTool *tr_tool,
|
||||
GimpItem *active_item,
|
||||
GeglBuffer *orig_buffer,
|
||||
gint orig_offset_x,
|
||||
|
@ -318,9 +319,9 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
|
|||
gint *new_offset_x,
|
||||
gint *new_offset_y)
|
||||
{
|
||||
GimpFlipTool *flip = GIMP_FLIP_TOOL (trans_tool);
|
||||
GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (trans_tool);
|
||||
GimpTransformOptions *tr_options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (trans_tool);
|
||||
GimpFlipTool *flip = GIMP_FLIP_TOOL (tr_tool);
|
||||
GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (tr_tool);
|
||||
GimpTransformOptions *tr_options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
|
||||
GimpContext *context = GIMP_CONTEXT (options);
|
||||
GimpOrientationType flip_type = GIMP_ORIENTATION_UNKNOWN;
|
||||
gdouble axis = 0.0;
|
||||
|
@ -338,13 +339,13 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
|
|||
switch (flip_type)
|
||||
{
|
||||
case GIMP_ORIENTATION_HORIZONTAL:
|
||||
axis = ((gdouble) trans_tool->x1 +
|
||||
(gdouble) (trans_tool->x2 - trans_tool->x1) / 2.0);
|
||||
axis = ((gdouble) tr_tool->x1 +
|
||||
(gdouble) (tr_tool->x2 - tr_tool->x1) / 2.0);
|
||||
break;
|
||||
|
||||
case GIMP_ORIENTATION_VERTICAL:
|
||||
axis = ((gdouble) trans_tool->y1 +
|
||||
(gdouble) (trans_tool->y2 - trans_tool->y1) / 2.0);
|
||||
axis = ((gdouble) tr_tool->y1 +
|
||||
(gdouble) (tr_tool->y2 - tr_tool->y1) / 2.0);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -35,33 +35,33 @@
|
|||
|
||||
#include "gimpgenerictransformtool.h"
|
||||
#include "gimptoolcontrol.h"
|
||||
#include "gimptransformoptions.h"
|
||||
#include "gimptransformgridoptions.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_generic_transform_tool_dialog (GimpTransformTool *tr_tool);
|
||||
static void gimp_generic_transform_tool_dialog_update (GimpTransformTool *tr_tool);
|
||||
static void gimp_generic_transform_tool_prepare (GimpTransformTool *tr_tool);
|
||||
static void gimp_generic_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget);
|
||||
static void gimp_generic_transform_tool_dialog (GimpTransformGridTool *tg_tool);
|
||||
static void gimp_generic_transform_tool_dialog_update (GimpTransformGridTool *tg_tool);
|
||||
static void gimp_generic_transform_tool_prepare (GimpTransformGridTool *tg_tool);
|
||||
static void gimp_generic_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpGenericTransformTool, gimp_generic_transform_tool,
|
||||
GIMP_TYPE_TRANSFORM_TOOL)
|
||||
GIMP_TYPE_TRANSFORM_GRID_TOOL)
|
||||
|
||||
|
||||
static void
|
||||
gimp_generic_transform_tool_class_init (GimpGenericTransformToolClass *klass)
|
||||
{
|
||||
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
|
||||
|
||||
trans_class->dialog = gimp_generic_transform_tool_dialog;
|
||||
trans_class->dialog_update = gimp_generic_transform_tool_dialog_update;
|
||||
trans_class->prepare = gimp_generic_transform_tool_prepare;
|
||||
trans_class->recalc_matrix = gimp_generic_transform_tool_recalc_matrix;
|
||||
tg_class->dialog = gimp_generic_transform_tool_dialog;
|
||||
tg_class->dialog_update = gimp_generic_transform_tool_dialog_update;
|
||||
tg_class->prepare = gimp_generic_transform_tool_prepare;
|
||||
tg_class->recalc_matrix = gimp_generic_transform_tool_recalc_matrix;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -70,9 +70,9 @@ gimp_generic_transform_tool_init (GimpGenericTransformTool *unified_tool)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_generic_transform_tool_dialog (GimpTransformTool *tr_tool)
|
||||
gimp_generic_transform_tool_dialog (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tr_tool);
|
||||
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tg_tool);
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *grid;
|
||||
|
@ -81,7 +81,7 @@ gimp_generic_transform_tool_dialog (GimpTransformTool *tr_tool)
|
|||
gint x, y;
|
||||
|
||||
frame = gimp_frame_new (_("Transform Matrix"));
|
||||
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tr_tool->gui)), frame,
|
||||
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tg_tool->gui)), frame,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
|
@ -121,9 +121,10 @@ gimp_generic_transform_tool_dialog (GimpTransformTool *tr_tool)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_generic_transform_tool_dialog_update (GimpTransformTool *tr_tool)
|
||||
gimp_generic_transform_tool_dialog_update (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tr_tool);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tg_tool);
|
||||
|
||||
if (tr_tool->transform_valid)
|
||||
{
|
||||
|
@ -153,9 +154,10 @@ gimp_generic_transform_tool_dialog_update (GimpTransformTool *tr_tool)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_generic_transform_tool_prepare (GimpTransformTool *tr_tool)
|
||||
gimp_generic_transform_tool_prepare (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tr_tool);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tg_tool);
|
||||
|
||||
generic->input_points[0] = (GimpVector2) {tr_tool->x1, tr_tool->y1};
|
||||
generic->input_points[1] = (GimpVector2) {tr_tool->x2, tr_tool->y1};
|
||||
|
@ -167,10 +169,11 @@ gimp_generic_transform_tool_prepare (GimpTransformTool *tr_tool)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_generic_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget)
|
||||
gimp_generic_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget)
|
||||
{
|
||||
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tr_tool);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tg_tool);
|
||||
|
||||
if (GIMP_GENERIC_TRANSFORM_TOOL_GET_CLASS (generic)->recalc_points)
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#define __GIMP_GENERIC_TRANSFORM_TOOL_H__
|
||||
|
||||
|
||||
#include "gimptransformtool.h"
|
||||
#include "gimptransformgridtool.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_GENERIC_TRANSFORM_TOOL (gimp_generic_transform_tool_get_type ())
|
||||
|
@ -34,19 +34,19 @@ typedef struct _GimpGenericTransformToolClass GimpGenericTransformToolClass;
|
|||
|
||||
struct _GimpGenericTransformTool
|
||||
{
|
||||
GimpTransformTool parent_instance;
|
||||
GimpTransformGridTool parent_instance;
|
||||
|
||||
GimpVector2 input_points[4];
|
||||
GimpVector2 output_points[4];
|
||||
GimpVector2 input_points[4];
|
||||
GimpVector2 output_points[4];
|
||||
|
||||
GtkWidget *matrix_grid;
|
||||
GtkWidget *matrix_labels[3][3];
|
||||
GtkWidget *invalid_label;
|
||||
GtkWidget *matrix_grid;
|
||||
GtkWidget *matrix_labels[3][3];
|
||||
GtkWidget *invalid_label;
|
||||
};
|
||||
|
||||
struct _GimpGenericTransformToolClass
|
||||
{
|
||||
GimpTransformToolClass parent_class;
|
||||
GimpTransformGridToolClass parent_class;
|
||||
|
||||
/* virtual functions */
|
||||
void (* recalc_points) (GimpGenericTransformTool *generic,
|
||||
|
|
|
@ -55,7 +55,7 @@ static void gimp_handle_transform_options_get_property (GObject *objec
|
|||
|
||||
|
||||
G_DEFINE_TYPE (GimpHandleTransformOptions, gimp_handle_transform_options,
|
||||
GIMP_TYPE_TRANSFORM_OPTIONS)
|
||||
GIMP_TYPE_TRANSFORM_GRID_OPTIONS)
|
||||
|
||||
#define parent_class gimp_handle_transform_options_parent_class
|
||||
|
||||
|
@ -134,7 +134,7 @@ GtkWidget *
|
|||
gimp_handle_transform_options_gui (GimpToolOptions *tool_options)
|
||||
{
|
||||
GObject *config = G_OBJECT (tool_options);
|
||||
GtkWidget *vbox = gimp_transform_options_gui (tool_options);
|
||||
GtkWidget *vbox = gimp_transform_grid_options_gui (tool_options);
|
||||
GtkWidget *frame;
|
||||
GtkWidget *button;
|
||||
gint i;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#define __GIMP_HANDLE_TRANSFORM_OPTIONS_H__
|
||||
|
||||
|
||||
#include "gimptransformoptions.h"
|
||||
#include "gimptransformgridoptions.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_HANDLE_TRANSFORM_OPTIONS (gimp_handle_transform_options_get_type ())
|
||||
|
@ -35,14 +35,14 @@ typedef struct _GimpHandleTransformOptionsClass GimpHandleTransformOptionsClass;
|
|||
|
||||
struct _GimpHandleTransformOptions
|
||||
{
|
||||
GimpTransformOptions parent_instance;
|
||||
GimpTransformGridOptions parent_instance;
|
||||
|
||||
GimpTransformHandleMode handle_mode;
|
||||
};
|
||||
|
||||
struct _GimpHandleTransformOptionsClass
|
||||
{
|
||||
GimpTransformOptionsClass parent_class;
|
||||
GimpTransformGridOptionsClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -83,18 +83,19 @@ static void gimp_handle_transform_tool_modifier_key (GimpTool
|
|||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
|
||||
static void gimp_handle_transform_tool_prepare (GimpTransformTool *tr_tool);
|
||||
static GimpToolWidget *
|
||||
gimp_handle_transform_tool_get_widget (GimpTransformTool *tr_tool);
|
||||
static void gimp_handle_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget);
|
||||
static gchar *gimp_handle_transform_tool_get_undo_desc (GimpTransformTool *tr_tool);
|
||||
|
||||
static void gimp_handle_transform_tool_prepare (GimpTransformGridTool *tg_tool);
|
||||
static GimpToolWidget *
|
||||
gimp_handle_transform_tool_get_widget (GimpTransformGridTool *tg_tool);
|
||||
static void gimp_handle_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget);
|
||||
|
||||
static void gimp_handle_transform_tool_recalc_points (GimpGenericTransformTool *generic,
|
||||
GimpToolWidget *widget);
|
||||
|
||||
static void gimp_handle_transform_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformTool *tr_tool);
|
||||
GimpTransformGridTool *tg_tool);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpHandleTransformTool, gimp_handle_transform_tool,
|
||||
|
@ -125,26 +126,26 @@ static void
|
|||
gimp_handle_transform_tool_class_init (GimpHandleTransformToolClass *klass)
|
||||
{
|
||||
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
||||
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
|
||||
GimpGenericTransformToolClass *generic_class = GIMP_GENERIC_TRANSFORM_TOOL_CLASS (klass);
|
||||
|
||||
tool_class->modifier_key = gimp_handle_transform_tool_modifier_key;
|
||||
|
||||
trans_class->prepare = gimp_handle_transform_tool_prepare;
|
||||
trans_class->get_widget = gimp_handle_transform_tool_get_widget;
|
||||
trans_class->recalc_matrix = gimp_handle_transform_tool_recalc_matrix;
|
||||
trans_class->get_undo_desc = gimp_handle_transform_tool_get_undo_desc;
|
||||
tr_class->get_undo_desc = gimp_handle_transform_tool_get_undo_desc;
|
||||
|
||||
tg_class->prepare = gimp_handle_transform_tool_prepare;
|
||||
tg_class->get_widget = gimp_handle_transform_tool_get_widget;
|
||||
tg_class->recalc_matrix = gimp_handle_transform_tool_recalc_matrix;
|
||||
|
||||
generic_class->recalc_points = gimp_handle_transform_tool_recalc_points;
|
||||
|
||||
tr_class->progress_text = _("Handle transformation");
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_handle_transform_tool_init (GimpHandleTransformTool *ht_tool)
|
||||
{
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (ht_tool);
|
||||
|
||||
tr_tool->progress_text = _("Handle transformation");
|
||||
|
||||
ht_tool->saved_handle_mode = GIMP_HANDLE_MODE_ADD_TRANSFORM;
|
||||
}
|
||||
|
||||
|
@ -202,39 +203,48 @@ gimp_handle_transform_tool_modifier_key (GimpTool *tool,
|
|||
state, display);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_handle_transform_tool_prepare (GimpTransformTool *tr_tool)
|
||||
static gchar *
|
||||
gimp_handle_transform_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
||||
{
|
||||
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->prepare (tr_tool);
|
||||
return g_strdup (C_("undo-type", "Handle transform"));
|
||||
}
|
||||
|
||||
tr_tool->trans_info[X0] = (gdouble) tr_tool->x1;
|
||||
tr_tool->trans_info[Y0] = (gdouble) tr_tool->y1;
|
||||
tr_tool->trans_info[X1] = (gdouble) tr_tool->x2;
|
||||
tr_tool->trans_info[Y1] = (gdouble) tr_tool->y1;
|
||||
tr_tool->trans_info[X2] = (gdouble) tr_tool->x1;
|
||||
tr_tool->trans_info[Y2] = (gdouble) tr_tool->y2;
|
||||
tr_tool->trans_info[X3] = (gdouble) tr_tool->x2;
|
||||
tr_tool->trans_info[Y3] = (gdouble) tr_tool->y2;
|
||||
tr_tool->trans_info[OX0] = (gdouble) tr_tool->x1;
|
||||
tr_tool->trans_info[OY0] = (gdouble) tr_tool->y1;
|
||||
tr_tool->trans_info[OX1] = (gdouble) tr_tool->x2;
|
||||
tr_tool->trans_info[OY1] = (gdouble) tr_tool->y1;
|
||||
tr_tool->trans_info[OX2] = (gdouble) tr_tool->x1;
|
||||
tr_tool->trans_info[OY2] = (gdouble) tr_tool->y2;
|
||||
tr_tool->trans_info[OX3] = (gdouble) tr_tool->x2;
|
||||
tr_tool->trans_info[OY3] = (gdouble) tr_tool->y2;
|
||||
tr_tool->trans_info[N_HANDLES] = 0;
|
||||
static void
|
||||
gimp_handle_transform_tool_prepare (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
|
||||
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->prepare (tg_tool);
|
||||
|
||||
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->y1;
|
||||
tg_tool->trans_info[X2] = (gdouble) tr_tool->x1;
|
||||
tg_tool->trans_info[Y2] = (gdouble) tr_tool->y2;
|
||||
tg_tool->trans_info[X3] = (gdouble) tr_tool->x2;
|
||||
tg_tool->trans_info[Y3] = (gdouble) tr_tool->y2;
|
||||
tg_tool->trans_info[OX0] = (gdouble) tr_tool->x1;
|
||||
tg_tool->trans_info[OY0] = (gdouble) tr_tool->y1;
|
||||
tg_tool->trans_info[OX1] = (gdouble) tr_tool->x2;
|
||||
tg_tool->trans_info[OY1] = (gdouble) tr_tool->y1;
|
||||
tg_tool->trans_info[OX2] = (gdouble) tr_tool->x1;
|
||||
tg_tool->trans_info[OY2] = (gdouble) tr_tool->y2;
|
||||
tg_tool->trans_info[OX3] = (gdouble) tr_tool->x2;
|
||||
tg_tool->trans_info[OY3] = (gdouble) tr_tool->y2;
|
||||
tg_tool->trans_info[N_HANDLES] = 0;
|
||||
}
|
||||
|
||||
static GimpToolWidget *
|
||||
gimp_handle_transform_tool_get_widget (GimpTransformTool *tr_tool)
|
||||
gimp_handle_transform_tool_get_widget (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (tr_tool);
|
||||
GimpTool *tool = GIMP_TOOL (tg_tool);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
GimpHandleTransformOptions *options;
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
||||
GimpToolWidget *widget;
|
||||
|
||||
options = GIMP_HANDLE_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
|
||||
options = GIMP_HANDLE_TRANSFORM_TOOL_GET_OPTIONS (tg_tool);
|
||||
|
||||
widget = gimp_tool_handle_grid_new (shell,
|
||||
tr_tool->x1,
|
||||
|
@ -243,23 +253,23 @@ gimp_handle_transform_tool_get_widget (GimpTransformTool *tr_tool)
|
|||
tr_tool->y2);
|
||||
|
||||
g_object_set (widget,
|
||||
"n-handles", (gint) tr_tool->trans_info[N_HANDLES],
|
||||
"orig-x1", tr_tool->trans_info[OX0],
|
||||
"orig-y1", tr_tool->trans_info[OY0],
|
||||
"orig-x2", tr_tool->trans_info[OX1],
|
||||
"orig-y2", tr_tool->trans_info[OY1],
|
||||
"orig-x3", tr_tool->trans_info[OX2],
|
||||
"orig-y3", tr_tool->trans_info[OY2],
|
||||
"orig-x4", tr_tool->trans_info[OX3],
|
||||
"orig-y4", tr_tool->trans_info[OY3],
|
||||
"trans-x1", tr_tool->trans_info[X0],
|
||||
"trans-y1", tr_tool->trans_info[Y0],
|
||||
"trans-x2", tr_tool->trans_info[X1],
|
||||
"trans-y2", tr_tool->trans_info[Y1],
|
||||
"trans-x3", tr_tool->trans_info[X2],
|
||||
"trans-y3", tr_tool->trans_info[Y2],
|
||||
"trans-x4", tr_tool->trans_info[X3],
|
||||
"trans-y4", tr_tool->trans_info[Y3],
|
||||
"n-handles", (gint) tg_tool->trans_info[N_HANDLES],
|
||||
"orig-x1", tg_tool->trans_info[OX0],
|
||||
"orig-y1", tg_tool->trans_info[OY0],
|
||||
"orig-x2", tg_tool->trans_info[OX1],
|
||||
"orig-y2", tg_tool->trans_info[OY1],
|
||||
"orig-x3", tg_tool->trans_info[OX2],
|
||||
"orig-y3", tg_tool->trans_info[OY2],
|
||||
"orig-x4", tg_tool->trans_info[OX3],
|
||||
"orig-y4", tg_tool->trans_info[OY3],
|
||||
"trans-x1", tg_tool->trans_info[X0],
|
||||
"trans-y1", tg_tool->trans_info[Y0],
|
||||
"trans-x2", tg_tool->trans_info[X1],
|
||||
"trans-y2", tg_tool->trans_info[Y1],
|
||||
"trans-x3", tg_tool->trans_info[X2],
|
||||
"trans-y3", tg_tool->trans_info[Y2],
|
||||
"trans-x4", tg_tool->trans_info[X3],
|
||||
"trans-y4", tg_tool->trans_info[Y3],
|
||||
NULL);
|
||||
|
||||
g_object_bind_property (G_OBJECT (options), "handle-mode",
|
||||
|
@ -269,99 +279,95 @@ gimp_handle_transform_tool_get_widget (GimpTransformTool *tr_tool)
|
|||
|
||||
g_signal_connect (widget, "changed",
|
||||
G_CALLBACK (gimp_handle_transform_tool_widget_changed),
|
||||
tr_tool);
|
||||
tg_tool);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_handle_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget)
|
||||
gimp_handle_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget)
|
||||
{
|
||||
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool, widget);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
|
||||
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->recalc_matrix (tg_tool, widget);
|
||||
|
||||
if (widget)
|
||||
g_object_set (widget,
|
||||
"transform", &tr_tool->transform,
|
||||
"show-guides", tr_tool->transform_valid,
|
||||
"n-handles", (gint) tr_tool->trans_info[N_HANDLES],
|
||||
"orig-x1", tr_tool->trans_info[OX0],
|
||||
"orig-y1", tr_tool->trans_info[OY0],
|
||||
"orig-x2", tr_tool->trans_info[OX1],
|
||||
"orig-y2", tr_tool->trans_info[OY1],
|
||||
"orig-x3", tr_tool->trans_info[OX2],
|
||||
"orig-y3", tr_tool->trans_info[OY2],
|
||||
"orig-x4", tr_tool->trans_info[OX3],
|
||||
"orig-y4", tr_tool->trans_info[OY3],
|
||||
"trans-x1", tr_tool->trans_info[X0],
|
||||
"trans-y1", tr_tool->trans_info[Y0],
|
||||
"trans-x2", tr_tool->trans_info[X1],
|
||||
"trans-y2", tr_tool->trans_info[Y1],
|
||||
"trans-x3", tr_tool->trans_info[X2],
|
||||
"trans-y3", tr_tool->trans_info[Y2],
|
||||
"trans-x4", tr_tool->trans_info[X3],
|
||||
"trans-y4", tr_tool->trans_info[Y3],
|
||||
"n-handles", (gint) tg_tool->trans_info[N_HANDLES],
|
||||
"orig-x1", tg_tool->trans_info[OX0],
|
||||
"orig-y1", tg_tool->trans_info[OY0],
|
||||
"orig-x2", tg_tool->trans_info[OX1],
|
||||
"orig-y2", tg_tool->trans_info[OY1],
|
||||
"orig-x3", tg_tool->trans_info[OX2],
|
||||
"orig-y3", tg_tool->trans_info[OY2],
|
||||
"orig-x4", tg_tool->trans_info[OX3],
|
||||
"orig-y4", tg_tool->trans_info[OY3],
|
||||
"trans-x1", tg_tool->trans_info[X0],
|
||||
"trans-y1", tg_tool->trans_info[Y0],
|
||||
"trans-x2", tg_tool->trans_info[X1],
|
||||
"trans-y2", tg_tool->trans_info[Y1],
|
||||
"trans-x3", tg_tool->trans_info[X2],
|
||||
"trans-y3", tg_tool->trans_info[Y2],
|
||||
"trans-x4", tg_tool->trans_info[X3],
|
||||
"trans-y4", tg_tool->trans_info[Y3],
|
||||
NULL);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gimp_handle_transform_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
||||
{
|
||||
return g_strdup (C_("undo-type", "Handle transform"));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_handle_transform_tool_recalc_points (GimpGenericTransformTool *generic,
|
||||
GimpToolWidget *widget)
|
||||
{
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (generic);
|
||||
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (generic);
|
||||
|
||||
generic->input_points[0] = (GimpVector2) {tr_tool->trans_info[OX0],
|
||||
tr_tool->trans_info[OY0]};
|
||||
generic->input_points[1] = (GimpVector2) {tr_tool->trans_info[OX1],
|
||||
tr_tool->trans_info[OY1]};
|
||||
generic->input_points[2] = (GimpVector2) {tr_tool->trans_info[OX2],
|
||||
tr_tool->trans_info[OY2]};
|
||||
generic->input_points[3] = (GimpVector2) {tr_tool->trans_info[OX3],
|
||||
tr_tool->trans_info[OY3]};
|
||||
generic->input_points[0] = (GimpVector2) {tg_tool->trans_info[OX0],
|
||||
tg_tool->trans_info[OY0]};
|
||||
generic->input_points[1] = (GimpVector2) {tg_tool->trans_info[OX1],
|
||||
tg_tool->trans_info[OY1]};
|
||||
generic->input_points[2] = (GimpVector2) {tg_tool->trans_info[OX2],
|
||||
tg_tool->trans_info[OY2]};
|
||||
generic->input_points[3] = (GimpVector2) {tg_tool->trans_info[OX3],
|
||||
tg_tool->trans_info[OY3]};
|
||||
|
||||
generic->output_points[0] = (GimpVector2) {tr_tool->trans_info[X0],
|
||||
tr_tool->trans_info[Y0]};
|
||||
generic->output_points[1] = (GimpVector2) {tr_tool->trans_info[X1],
|
||||
tr_tool->trans_info[Y1]};
|
||||
generic->output_points[2] = (GimpVector2) {tr_tool->trans_info[X2],
|
||||
tr_tool->trans_info[Y2]};
|
||||
generic->output_points[3] = (GimpVector2) {tr_tool->trans_info[X3],
|
||||
tr_tool->trans_info[Y3]};
|
||||
generic->output_points[0] = (GimpVector2) {tg_tool->trans_info[X0],
|
||||
tg_tool->trans_info[Y0]};
|
||||
generic->output_points[1] = (GimpVector2) {tg_tool->trans_info[X1],
|
||||
tg_tool->trans_info[Y1]};
|
||||
generic->output_points[2] = (GimpVector2) {tg_tool->trans_info[X2],
|
||||
tg_tool->trans_info[Y2]};
|
||||
generic->output_points[3] = (GimpVector2) {tg_tool->trans_info[X3],
|
||||
tg_tool->trans_info[Y3]};
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_handle_transform_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformTool *tr_tool)
|
||||
gimp_handle_transform_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
gint n_handles;
|
||||
|
||||
g_object_get (widget,
|
||||
"n-handles", &n_handles,
|
||||
"orig-x1", &tr_tool->trans_info[OX0],
|
||||
"orig-y1", &tr_tool->trans_info[OY0],
|
||||
"orig-x2", &tr_tool->trans_info[OX1],
|
||||
"orig-y2", &tr_tool->trans_info[OY1],
|
||||
"orig-x3", &tr_tool->trans_info[OX2],
|
||||
"orig-y3", &tr_tool->trans_info[OY2],
|
||||
"orig-x4", &tr_tool->trans_info[OX3],
|
||||
"orig-y4", &tr_tool->trans_info[OY3],
|
||||
"trans-x1", &tr_tool->trans_info[X0],
|
||||
"trans-y1", &tr_tool->trans_info[Y0],
|
||||
"trans-x2", &tr_tool->trans_info[X1],
|
||||
"trans-y2", &tr_tool->trans_info[Y1],
|
||||
"trans-x3", &tr_tool->trans_info[X2],
|
||||
"trans-y3", &tr_tool->trans_info[Y2],
|
||||
"trans-x4", &tr_tool->trans_info[X3],
|
||||
"trans-y4", &tr_tool->trans_info[Y3],
|
||||
"orig-x1", &tg_tool->trans_info[OX0],
|
||||
"orig-y1", &tg_tool->trans_info[OY0],
|
||||
"orig-x2", &tg_tool->trans_info[OX1],
|
||||
"orig-y2", &tg_tool->trans_info[OY1],
|
||||
"orig-x3", &tg_tool->trans_info[OX2],
|
||||
"orig-y3", &tg_tool->trans_info[OY2],
|
||||
"orig-x4", &tg_tool->trans_info[OX3],
|
||||
"orig-y4", &tg_tool->trans_info[OY3],
|
||||
"trans-x1", &tg_tool->trans_info[X0],
|
||||
"trans-y1", &tg_tool->trans_info[Y0],
|
||||
"trans-x2", &tg_tool->trans_info[X1],
|
||||
"trans-y2", &tg_tool->trans_info[Y1],
|
||||
"trans-x3", &tg_tool->trans_info[X2],
|
||||
"trans-y3", &tg_tool->trans_info[Y2],
|
||||
"trans-x4", &tg_tool->trans_info[X3],
|
||||
"trans-y4", &tg_tool->trans_info[Y3],
|
||||
NULL);
|
||||
|
||||
tr_tool->trans_info[N_HANDLES] = n_handles;
|
||||
tg_tool->trans_info[N_HANDLES] = n_handles;
|
||||
|
||||
gimp_transform_tool_recalc_matrix (tr_tool, NULL);
|
||||
gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include "gimpperspectivetool.h"
|
||||
#include "gimptoolcontrol.h"
|
||||
#include "gimptransformoptions.h"
|
||||
#include "gimptransformgridoptions.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
@ -54,17 +54,18 @@ enum
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_perspective_tool_prepare (GimpTransformTool *tr_tool);
|
||||
static GimpToolWidget * gimp_perspective_tool_get_widget (GimpTransformTool *tr_tool);
|
||||
static void gimp_perspective_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget);
|
||||
static gchar * gimp_perspective_tool_get_undo_desc (GimpTransformTool *tr_tool);
|
||||
|
||||
static void gimp_perspective_tool_prepare (GimpTransformGridTool *tg_tool);
|
||||
static GimpToolWidget * gimp_perspective_tool_get_widget (GimpTransformGridTool *tg_tool);
|
||||
static void gimp_perspective_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget);
|
||||
|
||||
static void gimp_perspective_tool_recalc_points (GimpGenericTransformTool *generic,
|
||||
GimpToolWidget *widget);
|
||||
|
||||
static void gimp_perspective_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformTool *tr_tool);
|
||||
GimpTransformGridTool *tg_tool);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpPerspectiveTool, gimp_perspective_tool,
|
||||
|
@ -78,8 +79,8 @@ gimp_perspective_tool_register (GimpToolRegisterCallback callback,
|
|||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_PERSPECTIVE_TOOL,
|
||||
GIMP_TYPE_TRANSFORM_OPTIONS,
|
||||
gimp_transform_options_gui,
|
||||
GIMP_TYPE_TRANSFORM_GRID_OPTIONS,
|
||||
gimp_transform_grid_options_gui,
|
||||
GIMP_CONTEXT_PROP_MASK_BACKGROUND,
|
||||
"gimp-perspective-tool",
|
||||
_("Perspective"),
|
||||
|
@ -94,50 +95,60 @@ gimp_perspective_tool_register (GimpToolRegisterCallback callback,
|
|||
static void
|
||||
gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass)
|
||||
{
|
||||
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
|
||||
GimpGenericTransformToolClass *generic_class = GIMP_GENERIC_TRANSFORM_TOOL_CLASS (klass);
|
||||
|
||||
trans_class->prepare = gimp_perspective_tool_prepare;
|
||||
trans_class->get_widget = gimp_perspective_tool_get_widget;
|
||||
trans_class->recalc_matrix = gimp_perspective_tool_recalc_matrix;
|
||||
trans_class->get_undo_desc = gimp_perspective_tool_get_undo_desc;
|
||||
tr_class->get_undo_desc = gimp_perspective_tool_get_undo_desc;
|
||||
|
||||
tg_class->prepare = gimp_perspective_tool_prepare;
|
||||
tg_class->get_widget = gimp_perspective_tool_get_widget;
|
||||
tg_class->recalc_matrix = gimp_perspective_tool_recalc_matrix;
|
||||
|
||||
generic_class->recalc_points = gimp_perspective_tool_recalc_points;
|
||||
|
||||
tr_class->progress_text = _("Perspective transformation");
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (perspective_tool);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (perspective_tool);
|
||||
GimpTool *tool = GIMP_TOOL (perspective_tool);
|
||||
|
||||
gimp_tool_control_set_tool_cursor (tool->control,
|
||||
GIMP_TOOL_CURSOR_PERSPECTIVE);
|
||||
}
|
||||
|
||||
tr_tool->progress_text = _("Perspective transformation");
|
||||
static gchar *
|
||||
gimp_perspective_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
||||
{
|
||||
return g_strdup (C_("undo-type", "Perspective"));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_perspective_tool_prepare (GimpTransformTool *tr_tool)
|
||||
gimp_perspective_tool_prepare (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->prepare (tr_tool);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
|
||||
tr_tool->trans_info[X0] = (gdouble) tr_tool->x1;
|
||||
tr_tool->trans_info[Y0] = (gdouble) tr_tool->y1;
|
||||
tr_tool->trans_info[X1] = (gdouble) tr_tool->x2;
|
||||
tr_tool->trans_info[Y1] = (gdouble) tr_tool->y1;
|
||||
tr_tool->trans_info[X2] = (gdouble) tr_tool->x1;
|
||||
tr_tool->trans_info[Y2] = (gdouble) tr_tool->y2;
|
||||
tr_tool->trans_info[X3] = (gdouble) tr_tool->x2;
|
||||
tr_tool->trans_info[Y3] = (gdouble) tr_tool->y2;
|
||||
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->prepare (tg_tool);
|
||||
|
||||
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->y1;
|
||||
tg_tool->trans_info[X2] = (gdouble) tr_tool->x1;
|
||||
tg_tool->trans_info[Y2] = (gdouble) tr_tool->y2;
|
||||
tg_tool->trans_info[X3] = (gdouble) tr_tool->x2;
|
||||
tg_tool->trans_info[Y3] = (gdouble) tr_tool->y2;
|
||||
}
|
||||
|
||||
static GimpToolWidget *
|
||||
gimp_perspective_tool_get_widget (GimpTransformTool *tr_tool)
|
||||
gimp_perspective_tool_get_widget (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (tr_tool);
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
||||
GimpToolWidget *widget;
|
||||
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,
|
||||
|
@ -155,16 +166,18 @@ gimp_perspective_tool_get_widget (GimpTransformTool *tr_tool)
|
|||
|
||||
g_signal_connect (widget, "changed",
|
||||
G_CALLBACK (gimp_perspective_tool_widget_changed),
|
||||
tr_tool);
|
||||
tg_tool);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_perspective_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget)
|
||||
gimp_perspective_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget)
|
||||
{
|
||||
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool, widget);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
|
||||
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->recalc_matrix (tg_tool, widget);
|
||||
|
||||
if (widget)
|
||||
g_object_set (widget,
|
||||
|
@ -176,38 +189,34 @@ gimp_perspective_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
|||
NULL);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gimp_perspective_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
||||
{
|
||||
return g_strdup (C_("undo-type", "Perspective"));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_perspective_tool_recalc_points (GimpGenericTransformTool *generic,
|
||||
GimpToolWidget *widget)
|
||||
{
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (generic);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (generic);
|
||||
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (generic);
|
||||
|
||||
generic->input_points[0] = (GimpVector2) {tr_tool->x1, tr_tool->y1};
|
||||
generic->input_points[1] = (GimpVector2) {tr_tool->x2, tr_tool->y1};
|
||||
generic->input_points[2] = (GimpVector2) {tr_tool->x1, tr_tool->y2};
|
||||
generic->input_points[3] = (GimpVector2) {tr_tool->x2, tr_tool->y2};
|
||||
|
||||
generic->output_points[0] = (GimpVector2) {tr_tool->trans_info[X0],
|
||||
tr_tool->trans_info[Y0]};
|
||||
generic->output_points[1] = (GimpVector2) {tr_tool->trans_info[X1],
|
||||
tr_tool->trans_info[Y1]};
|
||||
generic->output_points[2] = (GimpVector2) {tr_tool->trans_info[X2],
|
||||
tr_tool->trans_info[Y2]};
|
||||
generic->output_points[3] = (GimpVector2) {tr_tool->trans_info[X3],
|
||||
tr_tool->trans_info[Y3]};
|
||||
generic->output_points[0] = (GimpVector2) {tg_tool->trans_info[X0],
|
||||
tg_tool->trans_info[Y0]};
|
||||
generic->output_points[1] = (GimpVector2) {tg_tool->trans_info[X1],
|
||||
tg_tool->trans_info[Y1]};
|
||||
generic->output_points[2] = (GimpVector2) {tg_tool->trans_info[X2],
|
||||
tg_tool->trans_info[Y2]};
|
||||
generic->output_points[3] = (GimpVector2) {tg_tool->trans_info[X3],
|
||||
tg_tool->trans_info[Y3]};
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_perspective_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformTool *tr_tool)
|
||||
gimp_perspective_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpMatrix3 *transform;
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
GimpMatrix3 *transform;
|
||||
|
||||
g_object_get (widget,
|
||||
"transform", &transform,
|
||||
|
@ -215,22 +224,22 @@ gimp_perspective_tool_widget_changed (GimpToolWidget *widget,
|
|||
|
||||
gimp_matrix3_transform_point (transform,
|
||||
tr_tool->x1, tr_tool->y1,
|
||||
&tr_tool->trans_info[X0],
|
||||
&tr_tool->trans_info[Y0]);
|
||||
&tg_tool->trans_info[X0],
|
||||
&tg_tool->trans_info[Y0]);
|
||||
gimp_matrix3_transform_point (transform,
|
||||
tr_tool->x2, tr_tool->y1,
|
||||
&tr_tool->trans_info[X1],
|
||||
&tr_tool->trans_info[Y1]);
|
||||
&tg_tool->trans_info[X1],
|
||||
&tg_tool->trans_info[Y1]);
|
||||
gimp_matrix3_transform_point (transform,
|
||||
tr_tool->x1, tr_tool->y2,
|
||||
&tr_tool->trans_info[X2],
|
||||
&tr_tool->trans_info[Y2]);
|
||||
&tg_tool->trans_info[X2],
|
||||
&tg_tool->trans_info[Y2]);
|
||||
gimp_matrix3_transform_point (transform,
|
||||
tr_tool->x2, tr_tool->y2,
|
||||
&tr_tool->trans_info[X3],
|
||||
&tr_tool->trans_info[Y3]);
|
||||
&tg_tool->trans_info[X3],
|
||||
&tg_tool->trans_info[Y3]);
|
||||
|
||||
g_free (transform);
|
||||
|
||||
gimp_transform_tool_recalc_matrix (tr_tool, NULL);
|
||||
gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include "gimprotatetool.h"
|
||||
#include "gimptoolcontrol.h"
|
||||
#include "gimptransformoptions.h"
|
||||
#include "gimptransformgridoptions.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
@ -57,28 +57,29 @@ enum
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static gboolean gimp_rotate_tool_key_press (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpDisplay *display);
|
||||
static gboolean gimp_rotate_tool_key_press (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpDisplay *display);
|
||||
|
||||
static void gimp_rotate_tool_dialog (GimpTransformTool *tr_tool);
|
||||
static void gimp_rotate_tool_dialog_update (GimpTransformTool *tr_tool);
|
||||
static void gimp_rotate_tool_prepare (GimpTransformTool *tr_tool);
|
||||
static GimpToolWidget * gimp_rotate_tool_get_widget (GimpTransformTool *tr_tool);
|
||||
static void gimp_rotate_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget);
|
||||
static gchar * gimp_rotate_tool_get_undo_desc (GimpTransformTool *tr_tool);
|
||||
static gchar * gimp_rotate_tool_get_undo_desc (GimpTransformTool *tr_tool);
|
||||
|
||||
static void gimp_rotate_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformTool *tr_tool);
|
||||
static void gimp_rotate_tool_dialog (GimpTransformGridTool *tg_tool);
|
||||
static void gimp_rotate_tool_dialog_update (GimpTransformGridTool *tg_tool);
|
||||
static void gimp_rotate_tool_prepare (GimpTransformGridTool *tg_tool);
|
||||
static GimpToolWidget * gimp_rotate_tool_get_widget (GimpTransformGridTool *tg_tool);
|
||||
static void gimp_rotate_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget);
|
||||
|
||||
static void rotate_angle_changed (GtkAdjustment *adj,
|
||||
GimpTransformTool *tr_tool);
|
||||
static void rotate_center_changed (GtkWidget *entry,
|
||||
GimpTransformTool *tr_tool);
|
||||
static void gimp_rotate_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformGridTool *tg_tool);
|
||||
|
||||
static void rotate_angle_changed (GtkAdjustment *adj,
|
||||
GimpTransformGridTool *tg_tool);
|
||||
static void rotate_center_changed (GtkWidget *entry,
|
||||
GimpTransformGridTool *tg_tool);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpRotateTool, gimp_rotate_tool, GIMP_TYPE_TRANSFORM_TOOL)
|
||||
G_DEFINE_TYPE (GimpRotateTool, gimp_rotate_tool, GIMP_TYPE_TRANSFORM_GRID_TOOL)
|
||||
|
||||
#define parent_class gimp_rotate_tool_parent_class
|
||||
|
||||
|
@ -88,8 +89,8 @@ gimp_rotate_tool_register (GimpToolRegisterCallback callback,
|
|||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_ROTATE_TOOL,
|
||||
GIMP_TYPE_TRANSFORM_OPTIONS,
|
||||
gimp_transform_options_gui,
|
||||
GIMP_TYPE_TRANSFORM_GRID_OPTIONS,
|
||||
gimp_transform_grid_options_gui,
|
||||
GIMP_CONTEXT_PROP_MASK_BACKGROUND,
|
||||
"gimp-rotate-tool",
|
||||
_("Rotate"),
|
||||
|
@ -103,30 +104,30 @@ gimp_rotate_tool_register (GimpToolRegisterCallback callback,
|
|||
static void
|
||||
gimp_rotate_tool_class_init (GimpRotateToolClass *klass)
|
||||
{
|
||||
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
||||
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
||||
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
|
||||
|
||||
tool_class->key_press = gimp_rotate_tool_key_press;
|
||||
tool_class->key_press = gimp_rotate_tool_key_press;
|
||||
|
||||
trans_class->dialog = gimp_rotate_tool_dialog;
|
||||
trans_class->dialog_update = gimp_rotate_tool_dialog_update;
|
||||
trans_class->prepare = gimp_rotate_tool_prepare;
|
||||
trans_class->get_widget = gimp_rotate_tool_get_widget;
|
||||
trans_class->recalc_matrix = gimp_rotate_tool_recalc_matrix;
|
||||
trans_class->get_undo_desc = gimp_rotate_tool_get_undo_desc;
|
||||
tr_class->get_undo_desc = gimp_rotate_tool_get_undo_desc;
|
||||
|
||||
trans_class->ok_button_label = _("R_otate");
|
||||
tg_class->dialog = gimp_rotate_tool_dialog;
|
||||
tg_class->dialog_update = gimp_rotate_tool_dialog_update;
|
||||
tg_class->prepare = gimp_rotate_tool_prepare;
|
||||
tg_class->get_widget = gimp_rotate_tool_get_widget;
|
||||
tg_class->recalc_matrix = gimp_rotate_tool_recalc_matrix;
|
||||
|
||||
tr_class->progress_text = _("Rotating");
|
||||
tg_class->ok_button_label = _("R_otate");
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rotate_tool_init (GimpRotateTool *rotate_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rotate_tool);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (rotate_tool);
|
||||
GimpTool *tool = GIMP_TOOL (rotate_tool);
|
||||
|
||||
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_ROTATE);
|
||||
|
||||
tr_tool->progress_text = _("Rotating");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -167,10 +168,22 @@ gimp_rotate_tool_key_press (GimpTool *tool,
|
|||
return GIMP_TOOL_CLASS (parent_class)->key_press (tool, kevent, display);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rotate_tool_dialog (GimpTransformTool *tr_tool)
|
||||
static gchar *
|
||||
gimp_rotate_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
||||
{
|
||||
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tr_tool);
|
||||
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tr_tool);
|
||||
|
||||
return g_strdup_printf (C_("undo-type",
|
||||
"Rotate by %-3.3g° around (%g, %g)"),
|
||||
gimp_rad_to_deg (tg_tool->trans_info[ANGLE]),
|
||||
tg_tool->trans_info[PIVOT_X],
|
||||
tg_tool->trans_info[PIVOT_Y]);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rotate_tool_dialog (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tg_tool);
|
||||
GtkWidget *grid;
|
||||
GtkWidget *button;
|
||||
GtkWidget *scale;
|
||||
|
@ -179,7 +192,7 @@ gimp_rotate_tool_dialog (GimpTransformTool *tr_tool)
|
|||
grid = gtk_grid_new ();
|
||||
gtk_grid_set_row_spacing (GTK_GRID (grid), 2);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
|
||||
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tr_tool->gui)), grid,
|
||||
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tg_tool->gui)), grid,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (grid);
|
||||
|
||||
|
@ -195,7 +208,7 @@ gimp_rotate_tool_dialog (GimpTransformTool *tr_tool)
|
|||
|
||||
g_signal_connect (rotate->angle_adj, "value-changed",
|
||||
G_CALLBACK (rotate_angle_changed),
|
||||
tr_tool);
|
||||
tg_tool);
|
||||
|
||||
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, rotate->angle_adj);
|
||||
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
|
||||
|
@ -223,49 +236,50 @@ gimp_rotate_tool_dialog (GimpTransformTool *tr_tool)
|
|||
|
||||
g_signal_connect (rotate->sizeentry, "value-changed",
|
||||
G_CALLBACK (rotate_center_changed),
|
||||
tr_tool);
|
||||
tg_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rotate_tool_dialog_update (GimpTransformTool *tr_tool)
|
||||
gimp_rotate_tool_dialog_update (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tr_tool);
|
||||
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tg_tool);
|
||||
|
||||
gtk_adjustment_set_value (rotate->angle_adj,
|
||||
gimp_rad_to_deg (tr_tool->trans_info[ANGLE]));
|
||||
gimp_rad_to_deg (tg_tool->trans_info[ANGLE]));
|
||||
|
||||
g_signal_handlers_block_by_func (rotate->sizeentry,
|
||||
rotate_center_changed,
|
||||
tr_tool);
|
||||
tg_tool);
|
||||
|
||||
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (rotate->sizeentry), 0,
|
||||
tr_tool->trans_info[PIVOT_X]);
|
||||
tg_tool->trans_info[PIVOT_X]);
|
||||
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (rotate->sizeentry), 1,
|
||||
tr_tool->trans_info[PIVOT_Y]);
|
||||
tg_tool->trans_info[PIVOT_Y]);
|
||||
|
||||
g_signal_handlers_unblock_by_func (rotate->sizeentry,
|
||||
rotate_center_changed,
|
||||
tr_tool);
|
||||
tg_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rotate_tool_prepare (GimpTransformTool *tr_tool)
|
||||
gimp_rotate_tool_prepare (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tr_tool);
|
||||
GimpDisplay *display = GIMP_TOOL (tr_tool)->display;
|
||||
GimpImage *image = gimp_display_get_image (display);
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tg_tool);
|
||||
GimpDisplay *display = GIMP_TOOL (tg_tool)->display;
|
||||
GimpImage *image = gimp_display_get_image (display);
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
||||
tr_tool->trans_info[ANGLE] = 0.0;
|
||||
tr_tool->trans_info[PIVOT_X] = (gdouble) (tr_tool->x1 + tr_tool->x2) / 2.0;
|
||||
tr_tool->trans_info[PIVOT_Y] = (gdouble) (tr_tool->y1 + tr_tool->y2) / 2.0;
|
||||
tg_tool->trans_info[ANGLE] = 0.0;
|
||||
tg_tool->trans_info[PIVOT_X] = (gdouble) (tr_tool->x1 + tr_tool->x2) / 2.0;
|
||||
tg_tool->trans_info[PIVOT_Y] = (gdouble) (tr_tool->y1 + tr_tool->y2) / 2.0;
|
||||
|
||||
gimp_image_get_resolution (image, &xres, &yres);
|
||||
|
||||
g_signal_handlers_block_by_func (rotate->sizeentry,
|
||||
rotate_center_changed,
|
||||
tr_tool);
|
||||
tg_tool);
|
||||
|
||||
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (rotate->sizeentry),
|
||||
gimp_display_get_shell (display)->unit);
|
||||
|
@ -291,24 +305,25 @@ gimp_rotate_tool_prepare (GimpTransformTool *tr_tool)
|
|||
|
||||
g_signal_handlers_unblock_by_func (rotate->sizeentry,
|
||||
rotate_center_changed,
|
||||
tr_tool);
|
||||
tg_tool);
|
||||
}
|
||||
|
||||
static GimpToolWidget *
|
||||
gimp_rotate_tool_get_widget (GimpTransformTool *tr_tool)
|
||||
gimp_rotate_tool_get_widget (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (tr_tool);
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
||||
GimpToolWidget *widget;
|
||||
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_rotate_grid_new (shell,
|
||||
tr_tool->x1,
|
||||
tr_tool->y1,
|
||||
tr_tool->x2,
|
||||
tr_tool->y2,
|
||||
tr_tool->trans_info[PIVOT_X],
|
||||
tr_tool->trans_info[PIVOT_Y],
|
||||
tr_tool->trans_info[ANGLE]);
|
||||
tg_tool->trans_info[PIVOT_X],
|
||||
tg_tool->trans_info[PIVOT_Y],
|
||||
tg_tool->trans_info[ANGLE]);
|
||||
|
||||
g_object_set (widget,
|
||||
"inside-function", GIMP_TRANSFORM_FUNCTION_ROTATE,
|
||||
|
@ -318,88 +333,80 @@ gimp_rotate_tool_get_widget (GimpTransformTool *tr_tool)
|
|||
|
||||
g_signal_connect (widget, "changed",
|
||||
G_CALLBACK (gimp_rotate_tool_widget_changed),
|
||||
tr_tool);
|
||||
tg_tool);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rotate_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget)
|
||||
gimp_rotate_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget)
|
||||
{
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
|
||||
gimp_matrix3_identity (&tr_tool->transform);
|
||||
gimp_transform_matrix_rotate_center (&tr_tool->transform,
|
||||
tr_tool->trans_info[PIVOT_X],
|
||||
tr_tool->trans_info[PIVOT_Y],
|
||||
tr_tool->trans_info[ANGLE]);
|
||||
tg_tool->trans_info[PIVOT_X],
|
||||
tg_tool->trans_info[PIVOT_Y],
|
||||
tg_tool->trans_info[ANGLE]);
|
||||
|
||||
if (widget)
|
||||
g_object_set (widget,
|
||||
"transform", &tr_tool->transform,
|
||||
"angle", tr_tool->trans_info[ANGLE],
|
||||
"pivot-x", tr_tool->trans_info[PIVOT_X],
|
||||
"pivot-y", tr_tool->trans_info[PIVOT_Y],
|
||||
"angle", tg_tool->trans_info[ANGLE],
|
||||
"pivot-x", tg_tool->trans_info[PIVOT_X],
|
||||
"pivot-y", tg_tool->trans_info[PIVOT_Y],
|
||||
NULL);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gimp_rotate_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
||||
{
|
||||
return g_strdup_printf (C_("undo-type",
|
||||
"Rotate by %-3.3g° around (%g, %g)"),
|
||||
gimp_rad_to_deg (tr_tool->trans_info[ANGLE]),
|
||||
tr_tool->trans_info[PIVOT_X],
|
||||
tr_tool->trans_info[PIVOT_Y]);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rotate_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformTool *tr_tool)
|
||||
gimp_rotate_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
g_object_get (widget,
|
||||
"angle", &tr_tool->trans_info[ANGLE],
|
||||
"pivot-x", &tr_tool->trans_info[PIVOT_X],
|
||||
"pivot-y", &tr_tool->trans_info[PIVOT_Y],
|
||||
"angle", &tg_tool->trans_info[ANGLE],
|
||||
"pivot-x", &tg_tool->trans_info[PIVOT_X],
|
||||
"pivot-y", &tg_tool->trans_info[PIVOT_Y],
|
||||
NULL);
|
||||
|
||||
gimp_transform_tool_recalc_matrix (tr_tool, NULL);
|
||||
gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
rotate_angle_changed (GtkAdjustment *adj,
|
||||
GimpTransformTool *tr_tool)
|
||||
rotate_angle_changed (GtkAdjustment *adj,
|
||||
GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
gdouble value = gimp_deg_to_rad (gtk_adjustment_get_value (adj));
|
||||
|
||||
#define ANGLE_EPSILON 0.0001
|
||||
|
||||
if (ABS (value - tr_tool->trans_info[ANGLE]) > ANGLE_EPSILON)
|
||||
if (ABS (value - tg_tool->trans_info[ANGLE]) > ANGLE_EPSILON)
|
||||
{
|
||||
tr_tool->trans_info[ANGLE] = value;
|
||||
tg_tool->trans_info[ANGLE] = value;
|
||||
|
||||
gimp_transform_tool_push_internal_undo (tr_tool);
|
||||
gimp_transform_grid_tool_push_internal_undo (tg_tool);
|
||||
|
||||
gimp_transform_tool_recalc_matrix (tr_tool, tr_tool->widget);
|
||||
gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
|
||||
}
|
||||
|
||||
#undef ANGLE_EPSILON
|
||||
}
|
||||
|
||||
static void
|
||||
rotate_center_changed (GtkWidget *widget,
|
||||
GimpTransformTool *tr_tool)
|
||||
rotate_center_changed (GtkWidget *widget,
|
||||
GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
gdouble px = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
|
||||
gdouble py = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
|
||||
|
||||
if ((px != tr_tool->trans_info[PIVOT_X]) ||
|
||||
(py != tr_tool->trans_info[PIVOT_Y]))
|
||||
if ((px != tg_tool->trans_info[PIVOT_X]) ||
|
||||
(py != tg_tool->trans_info[PIVOT_Y]))
|
||||
{
|
||||
tr_tool->trans_info[PIVOT_X] = px;
|
||||
tr_tool->trans_info[PIVOT_Y] = py;
|
||||
tg_tool->trans_info[PIVOT_X] = px;
|
||||
tg_tool->trans_info[PIVOT_Y] = py;
|
||||
|
||||
gimp_transform_tool_push_internal_undo (tr_tool);
|
||||
gimp_transform_grid_tool_push_internal_undo (tg_tool);
|
||||
|
||||
gimp_transform_tool_recalc_matrix (tr_tool, tr_tool->widget);
|
||||
gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#define __GIMP_ROTATE_TOOL_H__
|
||||
|
||||
|
||||
#include "gimptransformtool.h"
|
||||
#include "gimptransformgridtool.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_ROTATE_TOOL (gimp_rotate_tool_get_type ())
|
||||
|
@ -35,16 +35,16 @@ typedef struct _GimpRotateToolClass GimpRotateToolClass;
|
|||
|
||||
struct _GimpRotateTool
|
||||
{
|
||||
GimpTransformTool parent_instance;
|
||||
GimpTransformGridTool parent_instance;
|
||||
|
||||
GtkAdjustment *angle_adj;
|
||||
GtkWidget *angle_spin_button;
|
||||
GtkWidget *sizeentry;
|
||||
GtkAdjustment *angle_adj;
|
||||
GtkWidget *angle_spin_button;
|
||||
GtkWidget *sizeentry;
|
||||
};
|
||||
|
||||
struct _GimpRotateToolClass
|
||||
{
|
||||
GimpTransformToolClass parent_class;
|
||||
GimpTransformGridToolClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include "gimpscaletool.h"
|
||||
#include "gimptoolcontrol.h"
|
||||
#include "gimptransformoptions.h"
|
||||
#include "gimptransformgridoptions.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
@ -57,23 +57,24 @@ enum
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_scale_tool_dialog (GimpTransformTool *tr_tool);
|
||||
static void gimp_scale_tool_dialog_update (GimpTransformTool *tr_tool);
|
||||
static void gimp_scale_tool_prepare (GimpTransformTool *tr_tool);
|
||||
static GimpToolWidget * gimp_scale_tool_get_widget (GimpTransformTool *tr_tool);
|
||||
static void gimp_scale_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget);
|
||||
static gchar * gimp_scale_tool_get_undo_desc (GimpTransformTool *tr_tool);
|
||||
static gchar * gimp_scale_tool_get_undo_desc (GimpTransformTool *tr_tool);
|
||||
|
||||
static void gimp_scale_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformTool *tr_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_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget);
|
||||
|
||||
static void gimp_scale_tool_size_notify (GtkWidget *box,
|
||||
GParamSpec *pspec,
|
||||
GimpTransformTool *tr_tool);
|
||||
static void gimp_scale_tool_widget_changed (GimpToolWidget *widget,
|
||||
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_TOOL)
|
||||
G_DEFINE_TYPE (GimpScaleTool, gimp_scale_tool, GIMP_TYPE_TRANSFORM_GRID_TOOL)
|
||||
|
||||
#define parent_class gimp_scale_tool_parent_class
|
||||
|
||||
|
@ -83,8 +84,8 @@ gimp_scale_tool_register (GimpToolRegisterCallback callback,
|
|||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_SCALE_TOOL,
|
||||
GIMP_TYPE_TRANSFORM_OPTIONS,
|
||||
gimp_transform_options_gui,
|
||||
GIMP_TYPE_TRANSFORM_GRID_OPTIONS,
|
||||
gimp_transform_grid_options_gui,
|
||||
GIMP_CONTEXT_PROP_MASK_BACKGROUND,
|
||||
"gimp-scale-tool",
|
||||
_("Scale"),
|
||||
|
@ -98,45 +99,59 @@ gimp_scale_tool_register (GimpToolRegisterCallback callback,
|
|||
static void
|
||||
gimp_scale_tool_class_init (GimpScaleToolClass *klass)
|
||||
{
|
||||
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
|
||||
|
||||
trans_class->dialog = gimp_scale_tool_dialog;
|
||||
trans_class->dialog_update = gimp_scale_tool_dialog_update;
|
||||
trans_class->prepare = gimp_scale_tool_prepare;
|
||||
trans_class->get_widget = gimp_scale_tool_get_widget;
|
||||
trans_class->recalc_matrix = gimp_scale_tool_recalc_matrix;
|
||||
trans_class->get_undo_desc = gimp_scale_tool_get_undo_desc;
|
||||
tr_class->get_undo_desc = gimp_scale_tool_get_undo_desc;
|
||||
|
||||
trans_class->ok_button_label = _("_Scale");
|
||||
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->recalc_matrix = gimp_scale_tool_recalc_matrix;
|
||||
|
||||
tr_class->progress_text = _("Scaling");
|
||||
tg_class->ok_button_label = _("_Scale");
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_scale_tool_init (GimpScaleTool *scale_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (scale_tool);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (scale_tool);
|
||||
GimpTool *tool = GIMP_TOOL (scale_tool);
|
||||
|
||||
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_RESIZE);
|
||||
}
|
||||
|
||||
tr_tool->progress_text = _("Scaling");
|
||||
static gchar *
|
||||
gimp_scale_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
||||
{
|
||||
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tr_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]);
|
||||
|
||||
return g_strdup_printf (C_("undo-type", "Scale to %d x %d"),
|
||||
width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_scale_tool_dialog (GimpTransformTool *tr_tool)
|
||||
gimp_scale_tool_dialog (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_scale_tool_dialog_update (GimpTransformTool *tr_tool)
|
||||
gimp_scale_tool_dialog_update (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
|
||||
gint width;
|
||||
gint height;
|
||||
GimpTransformGridOptions *options = GIMP_TRANSFORM_GRID_TOOL_GET_OPTIONS (tg_tool);
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
width = ROUND (tr_tool->trans_info[X1] - tr_tool->trans_info[X0]);
|
||||
height = ROUND (tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0]);
|
||||
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 (tr_tool)->box,
|
||||
g_object_set (GIMP_SCALE_TOOL (tg_tool)->box,
|
||||
"width", width,
|
||||
"height", height,
|
||||
"keep-aspect", options->constrain_scale,
|
||||
|
@ -144,18 +159,19 @@ gimp_scale_tool_dialog_update (GimpTransformTool *tr_tool)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_scale_tool_prepare (GimpTransformTool *tr_tool)
|
||||
gimp_scale_tool_prepare (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpScaleTool *scale = GIMP_SCALE_TOOL (tr_tool);
|
||||
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
|
||||
GimpDisplay *display = GIMP_TOOL (tr_tool)->display;
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
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;
|
||||
|
||||
tr_tool->trans_info[X0] = (gdouble) tr_tool->x1;
|
||||
tr_tool->trans_info[Y0] = (gdouble) tr_tool->y1;
|
||||
tr_tool->trans_info[X1] = (gdouble) tr_tool->x2;
|
||||
tr_tool->trans_info[Y1] = (gdouble) tr_tool->y2;
|
||||
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);
|
||||
|
@ -164,7 +180,7 @@ gimp_scale_tool_prepare (GimpTransformTool *tr_tool)
|
|||
{
|
||||
g_signal_handlers_disconnect_by_func (scale->box,
|
||||
gimp_scale_tool_size_notify,
|
||||
tr_tool);
|
||||
tg_tool);
|
||||
gtk_widget_destroy (scale->box);
|
||||
}
|
||||
|
||||
|
@ -181,21 +197,22 @@ gimp_scale_tool_prepare (GimpTransformTool *tr_tool)
|
|||
"yresolution", yres,
|
||||
NULL);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tr_tool->gui)),
|
||||
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),
|
||||
tr_tool);
|
||||
tg_tool);
|
||||
}
|
||||
|
||||
static GimpToolWidget *
|
||||
gimp_scale_tool_get_widget (GimpTransformTool *tr_tool)
|
||||
gimp_scale_tool_get_widget (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (tr_tool);
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
||||
GimpToolWidget *widget;
|
||||
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,
|
||||
|
@ -216,25 +233,27 @@ gimp_scale_tool_get_widget (GimpTransformTool *tr_tool)
|
|||
|
||||
g_signal_connect (widget, "changed",
|
||||
G_CALLBACK (gimp_scale_tool_widget_changed),
|
||||
tr_tool);
|
||||
tg_tool);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_scale_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget)
|
||||
gimp_scale_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget)
|
||||
{
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
|
||||
gimp_matrix3_identity (&tr_tool->transform);
|
||||
gimp_transform_matrix_scale (&tr_tool->transform,
|
||||
tr_tool->x1,
|
||||
tr_tool->y1,
|
||||
tr_tool->x2 - tr_tool->x1,
|
||||
tr_tool->y2 - tr_tool->y1,
|
||||
tr_tool->trans_info[X0],
|
||||
tr_tool->trans_info[Y0],
|
||||
tr_tool->trans_info[X1] - tr_tool->trans_info[X0],
|
||||
tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0]);
|
||||
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]);
|
||||
|
||||
if (widget)
|
||||
g_object_set (widget,
|
||||
|
@ -248,21 +267,12 @@ gimp_scale_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
|||
NULL);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gimp_scale_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
||||
{
|
||||
gint width = ROUND (tr_tool->trans_info[X1] - tr_tool->trans_info[X0]);
|
||||
gint height = ROUND (tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0]);
|
||||
|
||||
return g_strdup_printf (C_("undo-type", "Scale to %d x %d"),
|
||||
width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_scale_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformTool *tr_tool)
|
||||
gimp_scale_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpMatrix3 *transform;
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
GimpMatrix3 *transform;
|
||||
|
||||
g_object_get (widget,
|
||||
"transform", &transform,
|
||||
|
@ -270,24 +280,24 @@ gimp_scale_tool_widget_changed (GimpToolWidget *widget,
|
|||
|
||||
gimp_matrix3_transform_point (transform,
|
||||
tr_tool->x1, tr_tool->y1,
|
||||
&tr_tool->trans_info[X0],
|
||||
&tr_tool->trans_info[Y0]);
|
||||
&tg_tool->trans_info[X0],
|
||||
&tg_tool->trans_info[Y0]);
|
||||
gimp_matrix3_transform_point (transform,
|
||||
tr_tool->x2, tr_tool->y2,
|
||||
&tr_tool->trans_info[X1],
|
||||
&tr_tool->trans_info[Y1]);
|
||||
&tg_tool->trans_info[X1],
|
||||
&tg_tool->trans_info[Y1]);
|
||||
|
||||
g_free (transform);
|
||||
|
||||
gimp_transform_tool_recalc_matrix (tr_tool, NULL);
|
||||
gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_scale_tool_size_notify (GtkWidget *box,
|
||||
GParamSpec *pspec,
|
||||
GimpTransformTool *tr_tool)
|
||||
gimp_scale_tool_size_notify (GtkWidget *box,
|
||||
GParamSpec *pspec,
|
||||
GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
|
||||
GimpTransformGridOptions *options = GIMP_TRANSFORM_GRID_TOOL_GET_OPTIONS (tg_tool);
|
||||
|
||||
if (! strcmp (pspec->name, "width") ||
|
||||
! strcmp (pspec->name, "height"))
|
||||
|
@ -302,17 +312,17 @@ gimp_scale_tool_size_notify (GtkWidget *box,
|
|||
"height", &height,
|
||||
NULL);
|
||||
|
||||
old_width = ROUND (tr_tool->trans_info[X1] - tr_tool->trans_info[X0]);
|
||||
old_height = ROUND (tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0]);
|
||||
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))
|
||||
{
|
||||
tr_tool->trans_info[X1] = tr_tool->trans_info[X0] + width;
|
||||
tr_tool->trans_info[Y1] = tr_tool->trans_info[Y0] + height;
|
||||
tg_tool->trans_info[X1] = tg_tool->trans_info[X0] + width;
|
||||
tg_tool->trans_info[Y1] = tg_tool->trans_info[Y0] + height;
|
||||
|
||||
gimp_transform_tool_push_internal_undo (tr_tool);
|
||||
gimp_transform_grid_tool_push_internal_undo (tg_tool);
|
||||
|
||||
gimp_transform_tool_recalc_matrix (tr_tool, tr_tool->widget);
|
||||
gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
|
||||
}
|
||||
}
|
||||
else if (! strcmp (pspec->name, "keep-aspect"))
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#define __GIMP_SCALE_TOOL_H__
|
||||
|
||||
|
||||
#include "gimptransformtool.h"
|
||||
#include "gimptransformgridtool.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_SCALE_TOOL (gimp_scale_tool_get_type ())
|
||||
|
@ -34,14 +34,14 @@ typedef struct _GimpScaleToolClass GimpScaleToolClass;
|
|||
|
||||
struct _GimpScaleTool
|
||||
{
|
||||
GimpTransformTool parent_instance;
|
||||
GimpTransformGridTool parent_instance;
|
||||
|
||||
GtkWidget *box;
|
||||
GtkWidget *box;
|
||||
};
|
||||
|
||||
struct _GimpScaleToolClass
|
||||
{
|
||||
GimpTransformToolClass parent_class;
|
||||
GimpTransformGridToolClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include "gimpsheartool.h"
|
||||
#include "gimptoolcontrol.h"
|
||||
#include "gimptransformoptions.h"
|
||||
#include "gimptransformgridoptions.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
@ -55,25 +55,25 @@ enum
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_shear_tool_dialog (GimpTransformTool *tr_tool);
|
||||
static void gimp_shear_tool_dialog_update (GimpTransformTool *tr_tool);
|
||||
static gchar * gimp_shear_tool_get_undo_desc (GimpTransformTool *tr_tool);
|
||||
|
||||
static void gimp_shear_tool_prepare (GimpTransformTool *tr_tool);
|
||||
static GimpToolWidget * gimp_shear_tool_get_widget (GimpTransformTool *tr_tool);
|
||||
static void gimp_shear_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget);
|
||||
static gchar * gimp_shear_tool_get_undo_desc (GimpTransformTool *tr_tool);
|
||||
static void gimp_shear_tool_dialog (GimpTransformGridTool *tg_tool);
|
||||
static void gimp_shear_tool_dialog_update (GimpTransformGridTool *tg_tool);
|
||||
static void gimp_shear_tool_prepare (GimpTransformGridTool *tg_tool);
|
||||
static GimpToolWidget * gimp_shear_tool_get_widget (GimpTransformGridTool *tg_tool);
|
||||
static void gimp_shear_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget);
|
||||
|
||||
static void gimp_shear_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformTool *tr_tool);
|
||||
static void gimp_shear_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformGridTool *tg_tool);
|
||||
|
||||
static void shear_x_mag_changed (GtkAdjustment *adj,
|
||||
GimpTransformTool *tr_tool);
|
||||
static void shear_y_mag_changed (GtkAdjustment *adj,
|
||||
GimpTransformTool *tr_tool);
|
||||
static void shear_x_mag_changed (GtkAdjustment *adj,
|
||||
GimpTransformGridTool *tg_tool);
|
||||
static void shear_y_mag_changed (GtkAdjustment *adj,
|
||||
GimpTransformGridTool *tg_tool);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpShearTool, gimp_shear_tool, GIMP_TYPE_TRANSFORM_TOOL)
|
||||
G_DEFINE_TYPE (GimpShearTool, gimp_shear_tool, GIMP_TYPE_TRANSFORM_GRID_TOOL)
|
||||
|
||||
|
||||
void
|
||||
|
@ -81,8 +81,8 @@ gimp_shear_tool_register (GimpToolRegisterCallback callback,
|
|||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_SHEAR_TOOL,
|
||||
GIMP_TYPE_TRANSFORM_OPTIONS,
|
||||
gimp_transform_options_gui,
|
||||
GIMP_TYPE_TRANSFORM_GRID_OPTIONS,
|
||||
gimp_transform_grid_options_gui,
|
||||
0,
|
||||
"gimp-shear-tool",
|
||||
_("Shear"),
|
||||
|
@ -96,154 +96,37 @@ gimp_shear_tool_register (GimpToolRegisterCallback callback,
|
|||
static void
|
||||
gimp_shear_tool_class_init (GimpShearToolClass *klass)
|
||||
{
|
||||
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
|
||||
|
||||
trans_class->dialog = gimp_shear_tool_dialog;
|
||||
trans_class->dialog_update = gimp_shear_tool_dialog_update;
|
||||
trans_class->prepare = gimp_shear_tool_prepare;
|
||||
trans_class->get_widget = gimp_shear_tool_get_widget;
|
||||
trans_class->recalc_matrix = gimp_shear_tool_recalc_matrix;
|
||||
trans_class->get_undo_desc = gimp_shear_tool_get_undo_desc;
|
||||
tr_class->get_undo_desc = gimp_shear_tool_get_undo_desc;
|
||||
|
||||
trans_class->ok_button_label = _("_Shear");
|
||||
tg_class->dialog = gimp_shear_tool_dialog;
|
||||
tg_class->dialog_update = gimp_shear_tool_dialog_update;
|
||||
tg_class->prepare = gimp_shear_tool_prepare;
|
||||
tg_class->get_widget = gimp_shear_tool_get_widget;
|
||||
tg_class->recalc_matrix = gimp_shear_tool_recalc_matrix;
|
||||
|
||||
tr_class->progress_text = _("Shearing");
|
||||
tg_class->ok_button_label = _("_Shear");
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_shear_tool_init (GimpShearTool *shear_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (shear_tool);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (shear_tool);
|
||||
GimpTool *tool = GIMP_TOOL (shear_tool);
|
||||
|
||||
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_SHEAR);
|
||||
|
||||
tr_tool->progress_text = _("Shearing");
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_shear_tool_dialog (GimpTransformTool *tr_tool)
|
||||
{
|
||||
GimpShearTool *shear = GIMP_SHEAR_TOOL (tr_tool);
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *scale;
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
||||
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tr_tool->gui)), vbox,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
shear->x_adj = gtk_adjustment_new (0, -65536, 65536, 1, 10, 0);
|
||||
scale = gimp_spin_scale_new (shear->x_adj, _("Shear magnitude _X"), 0);
|
||||
gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), -1000, 1000);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
g_signal_connect (shear->x_adj, "value-changed",
|
||||
G_CALLBACK (shear_x_mag_changed),
|
||||
tr_tool);
|
||||
|
||||
shear->y_adj = gtk_adjustment_new (0, -65536, 65536, 1, 10, 0);
|
||||
scale = gimp_spin_scale_new (shear->y_adj, _("Shear magnitude _Y"), 0);
|
||||
gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), -1000, 1000);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
g_signal_connect (shear->y_adj, "value-changed",
|
||||
G_CALLBACK (shear_y_mag_changed),
|
||||
tr_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_shear_tool_dialog_update (GimpTransformTool *tr_tool)
|
||||
{
|
||||
GimpShearTool *shear = GIMP_SHEAR_TOOL (tr_tool);
|
||||
|
||||
gtk_adjustment_set_value (shear->x_adj, tr_tool->trans_info[SHEAR_X]);
|
||||
gtk_adjustment_set_value (shear->y_adj, tr_tool->trans_info[SHEAR_Y]);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_shear_tool_prepare (GimpTransformTool *tr_tool)
|
||||
{
|
||||
tr_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_UNKNOWN;
|
||||
tr_tool->trans_info[SHEAR_X] = 0.0;
|
||||
tr_tool->trans_info[SHEAR_Y] = 0.0;
|
||||
}
|
||||
|
||||
static GimpToolWidget *
|
||||
gimp_shear_tool_get_widget (GimpTransformTool *tr_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (tr_tool);
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
||||
GimpToolWidget *widget;
|
||||
|
||||
widget = gimp_tool_shear_grid_new (shell,
|
||||
tr_tool->x1,
|
||||
tr_tool->y1,
|
||||
tr_tool->x2,
|
||||
tr_tool->y2,
|
||||
tr_tool->trans_info[ORIENTATION],
|
||||
tr_tool->trans_info[SHEAR_X],
|
||||
tr_tool->trans_info[SHEAR_Y]);
|
||||
|
||||
g_object_set (widget,
|
||||
"inside-function", GIMP_TRANSFORM_FUNCTION_SHEAR,
|
||||
"outside-function", GIMP_TRANSFORM_FUNCTION_SHEAR,
|
||||
"frompivot-shear", TRUE,
|
||||
NULL);
|
||||
|
||||
g_signal_connect (widget, "changed",
|
||||
G_CALLBACK (gimp_shear_tool_widget_changed),
|
||||
tr_tool);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_shear_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget)
|
||||
{
|
||||
gdouble amount;
|
||||
|
||||
if (tr_tool->trans_info[SHEAR_X] == 0.0 &&
|
||||
tr_tool->trans_info[SHEAR_Y] == 0.0)
|
||||
{
|
||||
tr_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_UNKNOWN;
|
||||
}
|
||||
|
||||
if (tr_tool->trans_info[ORIENTATION] == GIMP_ORIENTATION_HORIZONTAL)
|
||||
amount = tr_tool->trans_info[SHEAR_X];
|
||||
else
|
||||
amount = tr_tool->trans_info[SHEAR_Y];
|
||||
|
||||
gimp_matrix3_identity (&tr_tool->transform);
|
||||
gimp_transform_matrix_shear (&tr_tool->transform,
|
||||
tr_tool->x1,
|
||||
tr_tool->y1,
|
||||
tr_tool->x2 - tr_tool->x1,
|
||||
tr_tool->y2 - tr_tool->y1,
|
||||
tr_tool->trans_info[ORIENTATION],
|
||||
amount);
|
||||
|
||||
if (widget)
|
||||
g_object_set (widget,
|
||||
"transform", &tr_tool->transform,
|
||||
"x1", (gdouble) tr_tool->x1,
|
||||
"y1", (gdouble) tr_tool->y1,
|
||||
"x2", (gdouble) tr_tool->x2,
|
||||
"y2", (gdouble) tr_tool->y2,
|
||||
"orientation", (gint) tr_tool->trans_info[ORIENTATION],
|
||||
"shear-x", tr_tool->trans_info[SHEAR_X],
|
||||
"shear-y", tr_tool->trans_info[SHEAR_Y],
|
||||
NULL);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gimp_shear_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
||||
{
|
||||
gdouble x = tr_tool->trans_info[SHEAR_X];
|
||||
gdouble y = tr_tool->trans_info[SHEAR_Y];
|
||||
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tr_tool);
|
||||
gdouble x = tg_tool->trans_info[SHEAR_X];
|
||||
gdouble y = tg_tool->trans_info[SHEAR_Y];
|
||||
|
||||
switch ((gint) tr_tool->trans_info[ORIENTATION])
|
||||
switch ((gint) tg_tool->trans_info[ORIENTATION])
|
||||
{
|
||||
case GIMP_ORIENTATION_HORIZONTAL:
|
||||
return g_strdup_printf (C_("undo-type", "Shear horizontally by %-3.3g"),
|
||||
|
@ -261,56 +144,176 @@ gimp_shear_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_shear_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformTool *tr_tool)
|
||||
gimp_shear_tool_dialog (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpShearTool *shear = GIMP_SHEAR_TOOL (tg_tool);
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *scale;
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
||||
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tg_tool->gui)), vbox,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
shear->x_adj = gtk_adjustment_new (0, -65536, 65536, 1, 10, 0);
|
||||
scale = gimp_spin_scale_new (shear->x_adj, _("Shear magnitude _X"), 0);
|
||||
gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), -1000, 1000);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
g_signal_connect (shear->x_adj, "value-changed",
|
||||
G_CALLBACK (shear_x_mag_changed),
|
||||
tg_tool);
|
||||
|
||||
shear->y_adj = gtk_adjustment_new (0, -65536, 65536, 1, 10, 0);
|
||||
scale = gimp_spin_scale_new (shear->y_adj, _("Shear magnitude _Y"), 0);
|
||||
gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), -1000, 1000);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
g_signal_connect (shear->y_adj, "value-changed",
|
||||
G_CALLBACK (shear_y_mag_changed),
|
||||
tg_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_shear_tool_dialog_update (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpShearTool *shear = GIMP_SHEAR_TOOL (tg_tool);
|
||||
|
||||
gtk_adjustment_set_value (shear->x_adj, tg_tool->trans_info[SHEAR_X]);
|
||||
gtk_adjustment_set_value (shear->y_adj, tg_tool->trans_info[SHEAR_Y]);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_shear_tool_prepare (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
tg_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_UNKNOWN;
|
||||
tg_tool->trans_info[SHEAR_X] = 0.0;
|
||||
tg_tool->trans_info[SHEAR_Y] = 0.0;
|
||||
}
|
||||
|
||||
static GimpToolWidget *
|
||||
gimp_shear_tool_get_widget (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
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_shear_grid_new (shell,
|
||||
tr_tool->x1,
|
||||
tr_tool->y1,
|
||||
tr_tool->x2,
|
||||
tr_tool->y2,
|
||||
tg_tool->trans_info[ORIENTATION],
|
||||
tg_tool->trans_info[SHEAR_X],
|
||||
tg_tool->trans_info[SHEAR_Y]);
|
||||
|
||||
g_object_set (widget,
|
||||
"inside-function", GIMP_TRANSFORM_FUNCTION_SHEAR,
|
||||
"outside-function", GIMP_TRANSFORM_FUNCTION_SHEAR,
|
||||
"frompivot-shear", TRUE,
|
||||
NULL);
|
||||
|
||||
g_signal_connect (widget, "changed",
|
||||
G_CALLBACK (gimp_shear_tool_widget_changed),
|
||||
tg_tool);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_shear_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget)
|
||||
{
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
gdouble amount;
|
||||
|
||||
if (tg_tool->trans_info[SHEAR_X] == 0.0 &&
|
||||
tg_tool->trans_info[SHEAR_Y] == 0.0)
|
||||
{
|
||||
tg_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_UNKNOWN;
|
||||
}
|
||||
|
||||
if (tg_tool->trans_info[ORIENTATION] == GIMP_ORIENTATION_HORIZONTAL)
|
||||
amount = tg_tool->trans_info[SHEAR_X];
|
||||
else
|
||||
amount = tg_tool->trans_info[SHEAR_Y];
|
||||
|
||||
gimp_matrix3_identity (&tr_tool->transform);
|
||||
gimp_transform_matrix_shear (&tr_tool->transform,
|
||||
tr_tool->x1,
|
||||
tr_tool->y1,
|
||||
tr_tool->x2 - tr_tool->x1,
|
||||
tr_tool->y2 - tr_tool->y1,
|
||||
tg_tool->trans_info[ORIENTATION],
|
||||
amount);
|
||||
|
||||
if (widget)
|
||||
g_object_set (widget,
|
||||
"transform", &tr_tool->transform,
|
||||
"x1", (gdouble) tr_tool->x1,
|
||||
"y1", (gdouble) tr_tool->y1,
|
||||
"x2", (gdouble) tr_tool->x2,
|
||||
"y2", (gdouble) tr_tool->y2,
|
||||
"orientation", (gint) tg_tool->trans_info[ORIENTATION],
|
||||
"shear-x", tg_tool->trans_info[SHEAR_X],
|
||||
"shear-y", tg_tool->trans_info[SHEAR_Y],
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_shear_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpOrientationType orientation;
|
||||
|
||||
g_object_get (widget,
|
||||
"orientation", &orientation,
|
||||
"shear-x", &tr_tool->trans_info[SHEAR_X],
|
||||
"shear-y", &tr_tool->trans_info[SHEAR_Y],
|
||||
"shear-x", &tg_tool->trans_info[SHEAR_X],
|
||||
"shear-y", &tg_tool->trans_info[SHEAR_Y],
|
||||
NULL);
|
||||
|
||||
tr_tool->trans_info[ORIENTATION] = orientation;
|
||||
tg_tool->trans_info[ORIENTATION] = orientation;
|
||||
|
||||
gimp_transform_tool_recalc_matrix (tr_tool, NULL);
|
||||
gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
shear_x_mag_changed (GtkAdjustment *adj,
|
||||
GimpTransformTool *tr_tool)
|
||||
shear_x_mag_changed (GtkAdjustment *adj,
|
||||
GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
gdouble value = gtk_adjustment_get_value (adj);
|
||||
|
||||
if (value != tr_tool->trans_info[SHEAR_X])
|
||||
if (value != tg_tool->trans_info[SHEAR_X])
|
||||
{
|
||||
tr_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_HORIZONTAL;
|
||||
tg_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_HORIZONTAL;
|
||||
|
||||
tr_tool->trans_info[SHEAR_X] = value;
|
||||
tr_tool->trans_info[SHEAR_Y] = 0.0; /* can only shear in one axis */
|
||||
tg_tool->trans_info[SHEAR_X] = value;
|
||||
tg_tool->trans_info[SHEAR_Y] = 0.0; /* can only shear in one axis */
|
||||
|
||||
gimp_transform_tool_push_internal_undo (tr_tool);
|
||||
gimp_transform_grid_tool_push_internal_undo (tg_tool);
|
||||
|
||||
gimp_transform_tool_recalc_matrix (tr_tool, tr_tool->widget);
|
||||
gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
shear_y_mag_changed (GtkAdjustment *adj,
|
||||
GimpTransformTool *tr_tool)
|
||||
shear_y_mag_changed (GtkAdjustment *adj,
|
||||
GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
gdouble value = gtk_adjustment_get_value (adj);
|
||||
|
||||
if (value != tr_tool->trans_info[SHEAR_Y])
|
||||
if (value != tg_tool->trans_info[SHEAR_Y])
|
||||
{
|
||||
tr_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_VERTICAL;
|
||||
tg_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_VERTICAL;
|
||||
|
||||
tr_tool->trans_info[SHEAR_Y] = value;
|
||||
tr_tool->trans_info[SHEAR_X] = 0.0; /* can only shear in one axis */
|
||||
tg_tool->trans_info[SHEAR_Y] = value;
|
||||
tg_tool->trans_info[SHEAR_X] = 0.0; /* can only shear in one axis */
|
||||
|
||||
gimp_transform_tool_push_internal_undo (tr_tool);
|
||||
gimp_transform_grid_tool_push_internal_undo (tg_tool);
|
||||
|
||||
gimp_transform_tool_recalc_matrix (tr_tool, tr_tool->widget);
|
||||
gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#define __GIMP_SHEAR_TOOL_H__
|
||||
|
||||
|
||||
#include "gimptransformtool.h"
|
||||
#include "gimptransformgridtool.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_SHEAR_TOOL (gimp_shear_tool_get_type ())
|
||||
|
@ -35,15 +35,15 @@ typedef struct _GimpShearToolClass GimpShearToolClass;
|
|||
|
||||
struct _GimpShearTool
|
||||
{
|
||||
GimpTransformTool parent_instance;
|
||||
GimpTransformGridTool parent_instance;
|
||||
|
||||
GtkAdjustment *x_adj;
|
||||
GtkAdjustment *y_adj;
|
||||
GtkAdjustment *x_adj;
|
||||
GtkAdjustment *y_adj;
|
||||
};
|
||||
|
||||
struct _GimpShearToolClass
|
||||
{
|
||||
GimpTransformToolClass parent_class;
|
||||
GimpTransformGridToolClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,548 @@
|
|||
/* GIMP - The GNU 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "widgets/gimppropwidgets.h"
|
||||
#include "widgets/gimpspinscale.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "gimprotatetool.h"
|
||||
#include "gimpscaletool.h"
|
||||
#include "gimpunifiedtransformtool.h"
|
||||
#include "gimptooloptions-gui.h"
|
||||
#include "gimptransformgridoptions.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_DIRECTION,
|
||||
PROP_SHOW_PREVIEW,
|
||||
PROP_PREVIEW_OPACITY,
|
||||
PROP_GRID_TYPE,
|
||||
PROP_GRID_SIZE,
|
||||
PROP_CONSTRAIN_MOVE,
|
||||
PROP_CONSTRAIN_SCALE,
|
||||
PROP_CONSTRAIN_ROTATE,
|
||||
PROP_CONSTRAIN_SHEAR,
|
||||
PROP_CONSTRAIN_PERSPECTIVE,
|
||||
PROP_FROMPIVOT_SCALE,
|
||||
PROP_FROMPIVOT_SHEAR,
|
||||
PROP_FROMPIVOT_PERSPECTIVE,
|
||||
PROP_CORNERSNAP,
|
||||
PROP_FIXEDPIVOT,
|
||||
};
|
||||
|
||||
|
||||
static void gimp_transform_grid_options_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_transform_grid_options_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static gboolean gimp_transform_grid_options_sync_grid (GBinding *binding,
|
||||
const GValue *source_value,
|
||||
GValue *target_value,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpTransformGridOptions, gimp_transform_grid_options,
|
||||
GIMP_TYPE_TRANSFORM_OPTIONS)
|
||||
|
||||
#define parent_class gimp_transform_grid_options_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_transform_grid_options_class_init (GimpTransformGridOptionsClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = gimp_transform_grid_options_set_property;
|
||||
object_class->get_property = gimp_transform_grid_options_get_property;
|
||||
|
||||
g_object_class_override_property (object_class, PROP_DIRECTION,
|
||||
"direction");
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_PREVIEW,
|
||||
"show-preview",
|
||||
_("Show image preview"),
|
||||
_("Show a preview of the transform_grided image"),
|
||||
TRUE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_PREVIEW_OPACITY,
|
||||
"preview-opacity",
|
||||
_("Image opacity"),
|
||||
_("Opacity of the preview image"),
|
||||
0.0, 1.0, 1.0,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_ENUM (object_class, PROP_GRID_TYPE,
|
||||
"grid-type",
|
||||
_("Guides"),
|
||||
_("Composition guides such as rule of thirds"),
|
||||
GIMP_TYPE_GUIDES_TYPE,
|
||||
GIMP_GUIDES_NONE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_INT (object_class, PROP_GRID_SIZE,
|
||||
"grid-size",
|
||||
NULL,
|
||||
_("Size of a grid cell for variable number "
|
||||
"of composition guides"),
|
||||
1, 128, 15,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_MOVE,
|
||||
"constrain-move",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_SCALE,
|
||||
"constrain-scale",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_ROTATE,
|
||||
"constrain-rotate",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_SHEAR,
|
||||
"constrain-shear",
|
||||
NULL, NULL,
|
||||
TRUE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_PERSPECTIVE,
|
||||
"constrain-perspective",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_FROMPIVOT_SCALE,
|
||||
"frompivot-scale",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_FROMPIVOT_SHEAR,
|
||||
"frompivot-shear",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_FROMPIVOT_PERSPECTIVE,
|
||||
"frompivot-perspective",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CORNERSNAP,
|
||||
"cornersnap",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_FIXEDPIVOT,
|
||||
"fixedpivot",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_grid_options_init (GimpTransformGridOptions *options)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_grid_options_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpTransformGridOptions *options = GIMP_TRANSFORM_GRID_OPTIONS (object);
|
||||
GimpTransformOptions *transform_options = GIMP_TRANSFORM_OPTIONS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_DIRECTION:
|
||||
transform_options->direction = g_value_get_enum (value);
|
||||
|
||||
/* Expected default for corrective transform_grid is to see the
|
||||
* original image only.
|
||||
*/
|
||||
g_object_set (options,
|
||||
"show-preview",
|
||||
transform_options->direction != GIMP_TRANSFORM_BACKWARD,
|
||||
NULL);
|
||||
break;
|
||||
case PROP_SHOW_PREVIEW:
|
||||
options->show_preview = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_PREVIEW_OPACITY:
|
||||
options->preview_opacity = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_GRID_TYPE:
|
||||
options->grid_type = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_GRID_SIZE:
|
||||
options->grid_size = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_CONSTRAIN_MOVE:
|
||||
options->constrain_move = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_CONSTRAIN_SCALE:
|
||||
options->constrain_scale = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_CONSTRAIN_ROTATE:
|
||||
options->constrain_rotate = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_CONSTRAIN_SHEAR:
|
||||
options->constrain_shear = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_CONSTRAIN_PERSPECTIVE:
|
||||
options->constrain_perspective = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_FROMPIVOT_SCALE:
|
||||
options->frompivot_scale = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_FROMPIVOT_SHEAR:
|
||||
options->frompivot_shear = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_FROMPIVOT_PERSPECTIVE:
|
||||
options->frompivot_perspective = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_CORNERSNAP:
|
||||
options->cornersnap = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_FIXEDPIVOT:
|
||||
options->fixedpivot = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_grid_options_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpTransformGridOptions *options = GIMP_TRANSFORM_GRID_OPTIONS (object);
|
||||
GimpTransformOptions *transform_options = GIMP_TRANSFORM_OPTIONS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_DIRECTION:
|
||||
g_value_set_enum (value, transform_options->direction);
|
||||
break;
|
||||
case PROP_SHOW_PREVIEW:
|
||||
g_value_set_boolean (value, options->show_preview);
|
||||
break;
|
||||
case PROP_PREVIEW_OPACITY:
|
||||
g_value_set_double (value, options->preview_opacity);
|
||||
break;
|
||||
case PROP_GRID_TYPE:
|
||||
g_value_set_enum (value, options->grid_type);
|
||||
break;
|
||||
case PROP_GRID_SIZE:
|
||||
g_value_set_int (value, options->grid_size);
|
||||
break;
|
||||
case PROP_CONSTRAIN_MOVE:
|
||||
g_value_set_boolean (value, options->constrain_move);
|
||||
break;
|
||||
case PROP_CONSTRAIN_SCALE:
|
||||
g_value_set_boolean (value, options->constrain_scale);
|
||||
break;
|
||||
case PROP_CONSTRAIN_ROTATE:
|
||||
g_value_set_boolean (value, options->constrain_rotate);
|
||||
break;
|
||||
case PROP_CONSTRAIN_SHEAR:
|
||||
g_value_set_boolean (value, options->constrain_shear);
|
||||
break;
|
||||
case PROP_CONSTRAIN_PERSPECTIVE:
|
||||
g_value_set_boolean (value, options->constrain_perspective);
|
||||
break;
|
||||
case PROP_FROMPIVOT_SCALE:
|
||||
g_value_set_boolean (value, options->frompivot_scale);
|
||||
break;
|
||||
case PROP_FROMPIVOT_SHEAR:
|
||||
g_value_set_boolean (value, options->frompivot_shear);
|
||||
break;
|
||||
case PROP_FROMPIVOT_PERSPECTIVE:
|
||||
g_value_set_boolean (value, options->frompivot_perspective);
|
||||
break;
|
||||
case PROP_CORNERSNAP:
|
||||
g_value_set_boolean (value, options->cornersnap);
|
||||
break;
|
||||
case PROP_FIXEDPIVOT:
|
||||
g_value_set_boolean (value, options->fixedpivot);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_transform_grid_options_gui:
|
||||
* @tool_options: a #GimpToolOptions
|
||||
*
|
||||
* Build the TransformGrid Tool Options.
|
||||
*
|
||||
* Return value: a container holding the transform_grid tool options
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_transform_grid_options_gui (GimpToolOptions *tool_options)
|
||||
{
|
||||
GObject *config = G_OBJECT (tool_options);
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *combo;
|
||||
GtkWidget *scale;
|
||||
GtkWidget *grid_box;
|
||||
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
|
||||
GdkModifierType constrain_mask = gimp_get_constrain_behavior_mask ();
|
||||
|
||||
vbox = gimp_transform_options_gui (tool_options, TRUE, TRUE, TRUE);
|
||||
|
||||
/* the preview frame */
|
||||
scale = gimp_prop_spin_scale_new (config, "preview-opacity", NULL,
|
||||
0.01, 0.1, 0);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
|
||||
frame = gimp_prop_expanding_frame_new (config, "show-preview", NULL,
|
||||
scale, NULL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* the guides frame */
|
||||
frame = gimp_frame_new (NULL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* the guides type menu */
|
||||
combo = gimp_prop_enum_combo_box_new (config, "grid-type", 0, 0);
|
||||
gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Guides"));
|
||||
g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
||||
gtk_frame_set_label_widget (GTK_FRAME (frame), combo);
|
||||
gtk_widget_show (combo);
|
||||
|
||||
/* the grid density scale */
|
||||
scale = gimp_prop_spin_scale_new (config, "grid-size", NULL,
|
||||
1.8, 8.0, 0);
|
||||
gimp_spin_scale_set_label (GIMP_SPIN_SCALE (scale), NULL);
|
||||
gtk_container_add (GTK_CONTAINER (frame), scale);
|
||||
|
||||
g_object_bind_property_full (config, "grid-type",
|
||||
scale, "visible",
|
||||
G_BINDING_SYNC_CREATE,
|
||||
gimp_transform_grid_options_sync_grid,
|
||||
NULL,
|
||||
NULL, NULL);
|
||||
|
||||
if (tool_options->tool_info->tool_type == GIMP_TYPE_ROTATE_TOOL)
|
||||
{
|
||||
GtkWidget *button;
|
||||
gchar *label;
|
||||
|
||||
label = g_strdup_printf (_("15 degrees (%s)"),
|
||||
gimp_get_mod_string (extend_mask));
|
||||
|
||||
button = gimp_prop_check_button_new (config, "constrain-rotate", label);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gimp_help_set_help_data (button, _("Limit rotation steps to 15 degrees"),
|
||||
NULL);
|
||||
|
||||
g_free (label);
|
||||
}
|
||||
else if (tool_options->tool_info->tool_type == GIMP_TYPE_SCALE_TOOL)
|
||||
{
|
||||
GtkWidget *button;
|
||||
gchar *label;
|
||||
|
||||
label = g_strdup_printf (_("Keep aspect (%s)"),
|
||||
gimp_get_mod_string (extend_mask));
|
||||
|
||||
button = gimp_prop_check_button_new (config, "constrain-scale", label);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gimp_help_set_help_data (button, _("Keep the original aspect ratio"),
|
||||
NULL);
|
||||
|
||||
g_free (label);
|
||||
|
||||
label = g_strdup_printf (_("Around center (%s)"),
|
||||
gimp_get_mod_string (constrain_mask));
|
||||
|
||||
button = gimp_prop_check_button_new (config, "frompivot-scale", label);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gimp_help_set_help_data (button, _("Scale around the center point"),
|
||||
NULL);
|
||||
|
||||
g_free (label);
|
||||
}
|
||||
else if (tool_options->tool_info->tool_type == GIMP_TYPE_UNIFIED_TRANSFORM_TOOL)
|
||||
{
|
||||
struct
|
||||
{
|
||||
GdkModifierType mod;
|
||||
gchar *name;
|
||||
gchar *desc;
|
||||
gchar *tip;
|
||||
}
|
||||
opt_list[] =
|
||||
{
|
||||
{ extend_mask, NULL, N_("Constrain (%s)") },
|
||||
{ extend_mask, "constrain-move", N_("Move"),
|
||||
N_("Constrain movement to 45 degree angles from center (%s)") },
|
||||
{ extend_mask, "constrain-scale", N_("Scale"),
|
||||
N_("Maintain aspect ratio when scaling (%s)") },
|
||||
{ extend_mask, "constrain-rotate", N_("Rotate"),
|
||||
N_("Constrain rotation to 15 degree increments (%s)") },
|
||||
{ extend_mask, "constrain-shear", N_("Shear"),
|
||||
N_("Shear along edge direction only (%s)") },
|
||||
{ extend_mask, "constrain-perspective", N_("Perspective"),
|
||||
N_("Constrain perspective handles to move along edges and diagonal (%s)") },
|
||||
|
||||
{ constrain_mask, NULL,
|
||||
N_("From pivot (%s)") },
|
||||
{ constrain_mask, "frompivot-scale", N_("Scale"),
|
||||
N_("Scale from pivot point (%s)") },
|
||||
{ constrain_mask, "frompivot-shear", N_("Shear"),
|
||||
N_("Shear opposite edge by same amount (%s)") },
|
||||
{ constrain_mask, "frompivot-perspective", N_("Perspective"),
|
||||
N_("Maintain position of pivot while changing perspective (%s)") },
|
||||
|
||||
{ 0, NULL,
|
||||
N_("Pivot") },
|
||||
{ extend_mask, "cornersnap", N_("Snap (%s)"),
|
||||
N_("Snap pivot to corners and center (%s)") },
|
||||
{ 0, "fixedpivot", N_("Lock"),
|
||||
N_("Lock pivot position to canvas") },
|
||||
};
|
||||
|
||||
GtkWidget *button;
|
||||
gchar *label;
|
||||
gint i;
|
||||
|
||||
frame = NULL;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (opt_list); i++)
|
||||
{
|
||||
if (! opt_list[i].name && ! opt_list[i].desc)
|
||||
{
|
||||
frame = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
label = g_strdup_printf (gettext (opt_list[i].desc),
|
||||
gimp_get_mod_string (opt_list[i].mod));
|
||||
|
||||
if (opt_list[i].name)
|
||||
{
|
||||
button = gimp_prop_check_button_new (config, opt_list[i].name,
|
||||
label);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (frame ? grid_box : vbox),
|
||||
button, FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_free (label);
|
||||
label = g_strdup_printf (gettext (opt_list[i].tip),
|
||||
gimp_get_mod_string (opt_list[i].mod));
|
||||
|
||||
gimp_help_set_help_data (button, label, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = gimp_frame_new (label);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
grid_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
||||
gtk_container_add (GTK_CONTAINER (frame), grid_box);
|
||||
gtk_widget_show (grid_box);
|
||||
}
|
||||
|
||||
g_free (label);
|
||||
}
|
||||
}
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_transform_grid_options_show_preview (GimpTransformGridOptions *options)
|
||||
{
|
||||
GimpTransformOptions *transform_options;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_TRANSFORM_GRID_OPTIONS (options), FALSE);
|
||||
|
||||
transform_options = GIMP_TRANSFORM_OPTIONS (options);
|
||||
|
||||
return (options->show_preview &&
|
||||
transform_options->type == GIMP_TRANSFORM_TYPE_LAYER);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static gboolean
|
||||
gimp_transform_grid_options_sync_grid (GBinding *binding,
|
||||
const GValue *source_value,
|
||||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
GimpGuidesType type = g_value_get_enum (source_value);
|
||||
|
||||
g_value_set_boolean (target_value,
|
||||
type == GIMP_GUIDES_N_LINES ||
|
||||
type == GIMP_GUIDES_SPACING);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/* GIMP - The GNU 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_TRANSFORM_GRID_OPTIONS_H__
|
||||
#define __GIMP_TRANSFORM_GRID_OPTIONS_H__
|
||||
|
||||
|
||||
#include "gimptransformoptions.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_TRANSFORM_GRID_OPTIONS (gimp_transform_grid_options_get_type ())
|
||||
#define GIMP_TRANSFORM_GRID_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TRANSFORM_GRID_OPTIONS, GimpTransformGridOptions))
|
||||
#define GIMP_TRANSFORM_GRID_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TRANSFORM_GRID_OPTIONS, GimpTransformGridOptionsClass))
|
||||
#define GIMP_IS_TRANSFORM_GRID_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TRANSFORM_GRID_OPTIONS))
|
||||
#define GIMP_IS_TRANSFORM_GRID_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TRANSFORM_GRID_OPTIONS))
|
||||
#define GIMP_TRANSFORM_GRID_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TRANSFORM_GRID_OPTIONS, GimpTransformGridOptionsClass))
|
||||
|
||||
|
||||
typedef struct _GimpTransformGridOptions GimpTransformGridOptions;
|
||||
typedef struct _GimpTransformGridOptionsClass GimpTransformGridOptionsClass;
|
||||
|
||||
struct _GimpTransformGridOptions
|
||||
{
|
||||
GimpTransformOptions parent_instance;
|
||||
|
||||
gboolean show_preview;
|
||||
gdouble preview_opacity;
|
||||
GimpGuidesType grid_type;
|
||||
gint grid_size;
|
||||
gboolean constrain_move;
|
||||
gboolean constrain_scale;
|
||||
gboolean constrain_rotate;
|
||||
gboolean constrain_shear;
|
||||
gboolean constrain_perspective;
|
||||
gboolean frompivot_scale;
|
||||
gboolean frompivot_shear;
|
||||
gboolean frompivot_perspective;
|
||||
gboolean cornersnap;
|
||||
gboolean fixedpivot;
|
||||
};
|
||||
|
||||
struct _GimpTransformGridOptionsClass
|
||||
{
|
||||
GimpTransformOptionsClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_transform_grid_options_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_transform_grid_options_gui (GimpToolOptions *tool_options);
|
||||
|
||||
gboolean gimp_transform_grid_options_show_preview (GimpTransformGridOptions *options);
|
||||
|
||||
|
||||
#endif /* __GIMP_TRANSFORM_GRID_OPTIONS_H__ */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,103 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_TRANSFORM_GRID_TOOL_H__
|
||||
#define __GIMP_TRANSFORM_GRID_TOOL_H__
|
||||
|
||||
|
||||
#include "gimptransformtool.h"
|
||||
|
||||
|
||||
/* This is not the number of items in the enum above, but the max size
|
||||
* of the enums at the top of each transformation tool, stored in
|
||||
* trans_info and related
|
||||
*/
|
||||
#define TRANS_INFO_SIZE 17
|
||||
|
||||
typedef gdouble TransInfo[TRANS_INFO_SIZE];
|
||||
|
||||
|
||||
#define GIMP_TYPE_TRANSFORM_GRID_TOOL (gimp_transform_grid_tool_get_type ())
|
||||
#define GIMP_TRANSFORM_GRID_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TRANSFORM_GRID_TOOL, GimpTransformGridTool))
|
||||
#define GIMP_TRANSFORM_GRID_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TRANSFORM_GRID_TOOL, GimpTransformGridToolClass))
|
||||
#define GIMP_IS_TRANSFORM_GRID_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TRANSFORM_GRID_TOOL))
|
||||
#define GIMP_IS_TRANSFORM_GRID_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TRANSFORM_GRID_TOOL))
|
||||
#define GIMP_TRANSFORM_GRID_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TRANSFORM_GRID_TOOL, GimpTransformGridToolClass))
|
||||
|
||||
#define GIMP_TRANSFORM_GRID_TOOL_GET_OPTIONS(t) (GIMP_TRANSFORM_GRID_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))
|
||||
|
||||
|
||||
typedef struct _GimpTransformGridToolClass GimpTransformGridToolClass;
|
||||
|
||||
struct _GimpTransformGridTool
|
||||
{
|
||||
GimpTransformTool parent_instance;
|
||||
|
||||
TransInfo trans_info; /* transformation info */
|
||||
TransInfo *old_trans_info; /* for resetting everything */
|
||||
TransInfo *prev_trans_info; /* the current finished state */
|
||||
GList *undo_list; /* list of all states,
|
||||
head is current == prev_trans_info,
|
||||
tail is original == old_trans_info */
|
||||
GList *redo_list; /* list of all undone states,
|
||||
NULL when nothing undone */
|
||||
|
||||
GimpItem *hidden_item; /* the item that was hidden during
|
||||
the transform */
|
||||
|
||||
GimpToolWidget *widget;
|
||||
GimpToolWidget *grab_widget;
|
||||
GimpCanvasItem *preview;
|
||||
GimpCanvasItem *boundary_in;
|
||||
GimpCanvasItem *boundary_out;
|
||||
GPtrArray *strokes;
|
||||
|
||||
GimpToolGui *gui;
|
||||
};
|
||||
|
||||
struct _GimpTransformGridToolClass
|
||||
{
|
||||
GimpTransformToolClass parent_class;
|
||||
|
||||
/* virtual functions */
|
||||
void (* dialog) (GimpTransformGridTool *tg_tool);
|
||||
void (* dialog_update) (GimpTransformGridTool *tg_tool);
|
||||
void (* prepare) (GimpTransformGridTool *tg_tool);
|
||||
GimpToolWidget * (* get_widget) (GimpTransformGridTool *tg_tool);
|
||||
void (* recalc_matrix) (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget);
|
||||
GeglBuffer * (* transform) (GimpTransformGridTool *tg_tool,
|
||||
GimpItem *item,
|
||||
GeglBuffer *orig_buffer,
|
||||
gint orig_offset_x,
|
||||
gint orig_offset_y,
|
||||
GimpColorProfile **buffer_profile,
|
||||
gint *new_offset_x,
|
||||
gint *new_offset_y);
|
||||
|
||||
const gchar *ok_button_label;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_transform_grid_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void gimp_transform_grid_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget);
|
||||
void gimp_transform_grid_tool_push_internal_undo (GimpTransformGridTool *tg_tool);
|
||||
|
||||
|
||||
#endif /* __GIMP_TRANSFORM_GRID_TOOL_H__ */
|
|
@ -0,0 +1,220 @@
|
|||
/* GIMP - The GNU 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "gimptoolcontrol.h"
|
||||
#include "gimptransformgridtool.h"
|
||||
#include "gimptransformgridtoolundo.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_TRANSFORM_TOOL
|
||||
};
|
||||
|
||||
|
||||
static void gimp_transform_grid_tool_undo_constructed (GObject *object);
|
||||
static void gimp_transform_grid_tool_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_transform_grid_tool_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_transform_grid_tool_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void gimp_transform_grid_tool_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpTransformGridToolUndo, gimp_transform_grid_tool_undo, GIMP_TYPE_UNDO)
|
||||
|
||||
#define parent_class gimp_transform_grid_tool_undo_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_transform_grid_tool_undo_class_init (GimpTransformGridToolUndoClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
|
||||
|
||||
object_class->constructed = gimp_transform_grid_tool_undo_constructed;
|
||||
object_class->set_property = gimp_transform_grid_tool_undo_set_property;
|
||||
object_class->get_property = gimp_transform_grid_tool_undo_get_property;
|
||||
|
||||
undo_class->pop = gimp_transform_grid_tool_undo_pop;
|
||||
undo_class->free = gimp_transform_grid_tool_undo_free;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_TRANSFORM_TOOL,
|
||||
g_param_spec_object ("transform-tool",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_TRANSFORM_GRID_TOOL,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_grid_tool_undo_init (GimpTransformGridToolUndo *undo)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_grid_tool_undo_constructed (GObject *object)
|
||||
{
|
||||
GimpTransformGridToolUndo *tg_tool_undo = GIMP_TRANSFORM_GRID_TOOL_UNDO (object);
|
||||
GimpTransformGridTool *tg_tool;
|
||||
gint i;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->constructed (object);
|
||||
|
||||
gimp_assert (GIMP_IS_TRANSFORM_GRID_TOOL (tg_tool_undo->tg_tool));
|
||||
|
||||
tg_tool = tg_tool_undo->tg_tool;
|
||||
|
||||
for (i = 0; i < TRANS_INFO_SIZE; i++)
|
||||
tg_tool_undo->trans_info[i] = (*tg_tool->old_trans_info)[i];
|
||||
|
||||
#if 0
|
||||
if (tg_tool->original)
|
||||
tg_tool_undo->original = tile_manager_ref (tg_tool->original);
|
||||
#endif
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (tg_tool_undo->tg_tool),
|
||||
(gpointer) &tg_tool_undo->tg_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_grid_tool_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpTransformGridToolUndo *tg_tool_undo = GIMP_TRANSFORM_GRID_TOOL_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_TRANSFORM_TOOL:
|
||||
tg_tool_undo->tg_tool = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_grid_tool_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpTransformGridToolUndo *tg_tool_undo = GIMP_TRANSFORM_GRID_TOOL_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_TRANSFORM_TOOL:
|
||||
g_value_set_object (value, tg_tool_undo->tg_tool);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_grid_tool_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
GimpTransformGridToolUndo *tg_tool_undo = GIMP_TRANSFORM_GRID_TOOL_UNDO (undo);
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
|
||||
|
||||
if (tg_tool_undo->tg_tool)
|
||||
{
|
||||
GimpTransformGridTool *tg_tool;
|
||||
#if 0
|
||||
TileManager *temp;
|
||||
#endif
|
||||
gdouble d;
|
||||
gint i;
|
||||
|
||||
tg_tool = tg_tool_undo->tg_tool;
|
||||
|
||||
/* swap the transformation information arrays */
|
||||
for (i = 0; i < TRANS_INFO_SIZE; i++)
|
||||
{
|
||||
d = tg_tool_undo->trans_info[i];
|
||||
tg_tool_undo->trans_info[i] = tg_tool->trans_info[i];
|
||||
tg_tool->trans_info[i] = d;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* swap the original buffer--the source buffer for repeated transform_grids
|
||||
*/
|
||||
temp = tg_tool_undo->original;
|
||||
tg_tool_undo->original = tg_tool->original;
|
||||
tg_tool->original = temp;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* If we're re-implementing the first transform_grid, reactivate tool */
|
||||
if (undo_mode == GIMP_UNDO_MODE_REDO && tg_tool->original)
|
||||
{
|
||||
gimp_tool_control_activate (GIMP_TOOL (tg_tool)->control);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tg_tool));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_grid_tool_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
GimpTransformGridToolUndo *tg_tool_undo = GIMP_TRANSFORM_GRID_TOOL_UNDO (undo);
|
||||
|
||||
if (tg_tool_undo->tg_tool)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (tg_tool_undo->tg_tool),
|
||||
(gpointer) &tg_tool_undo->tg_tool);
|
||||
tg_tool_undo->tg_tool = NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (tg_tool_undo->original)
|
||||
{
|
||||
tile_manager_unref (tg_tool_undo->original);
|
||||
tg_tool_undo->original = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/* GIMP - The GNU 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_TRANSFORM_GRID_TOOL_UNDO_H__
|
||||
#define __GIMP_TRANSFORM_GRID_TOOL_UNDO_H__
|
||||
|
||||
|
||||
#include "core/gimpundo.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_TRANSFORM_GRID_TOOL_UNDO (gimp_transform_grid_tool_undo_get_type ())
|
||||
#define GIMP_TRANSFORM_GRID_TOOL_UNDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TRANSFORM_GRID_TOOL_UNDO, GimpTransformGridToolUndo))
|
||||
#define GIMP_TRANSFORM_GRID_TOOL_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TRANSFORM_GRID_TOOL_UNDO, GimpTransformGridToolUndoClass))
|
||||
#define GIMP_IS_TRANSFORM_GRID_TOOL_UNDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TRANSFORM_GRID_TOOL_UNDO))
|
||||
#define GIMP_IS_TRANSFORM_GRID_TOOL_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TRANSFORM_GRID_TOOL_UNDO))
|
||||
#define GIMP_TRANSFORM_GRID_TOOL_UNDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TRANSFORM_GRID_TOOL_UNDO, GimpTransformGridToolUndoClass))
|
||||
|
||||
|
||||
typedef struct _GimpTransformGridToolUndo GimpTransformGridToolUndo;
|
||||
typedef struct _GimpTransformGridToolUndoClass GimpTransformGridToolUndoClass;
|
||||
|
||||
struct _GimpTransformGridToolUndo
|
||||
{
|
||||
GimpUndo parent_instance;
|
||||
|
||||
GimpTransformGridTool *tg_tool;
|
||||
TransInfo trans_info;
|
||||
#if 0
|
||||
TileManager *original;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct _GimpTransformGridToolUndoClass
|
||||
{
|
||||
GimpUndoClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_transform_grid_tool_undo_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_TRANSFORM_GRID_TOOL_UNDO_H__ */
|
|
@ -31,12 +31,8 @@
|
|||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "widgets/gimppropwidgets.h"
|
||||
#include "widgets/gimpspinscale.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "gimprotatetool.h"
|
||||
#include "gimpscaletool.h"
|
||||
#include "gimpunifiedtransformtool.h"
|
||||
#include "gimptooloptions-gui.h"
|
||||
#include "gimptransformoptions.h"
|
||||
|
||||
|
@ -49,21 +45,7 @@ enum
|
|||
PROP_TYPE,
|
||||
PROP_DIRECTION,
|
||||
PROP_INTERPOLATION,
|
||||
PROP_CLIP,
|
||||
PROP_SHOW_PREVIEW,
|
||||
PROP_PREVIEW_OPACITY,
|
||||
PROP_GRID_TYPE,
|
||||
PROP_GRID_SIZE,
|
||||
PROP_CONSTRAIN_MOVE,
|
||||
PROP_CONSTRAIN_SCALE,
|
||||
PROP_CONSTRAIN_ROTATE,
|
||||
PROP_CONSTRAIN_SHEAR,
|
||||
PROP_CONSTRAIN_PERSPECTIVE,
|
||||
PROP_FROMPIVOT_SCALE,
|
||||
PROP_FROMPIVOT_SHEAR,
|
||||
PROP_FROMPIVOT_PERSPECTIVE,
|
||||
PROP_CORNERSNAP,
|
||||
PROP_FIXEDPIVOT,
|
||||
PROP_CLIP
|
||||
};
|
||||
|
||||
|
||||
|
@ -80,12 +62,6 @@ static void gimp_transform_options_get_property (GObject *object,
|
|||
|
||||
static void gimp_transform_options_reset (GimpConfig *config);
|
||||
|
||||
static gboolean gimp_transform_options_sync_grid (GBinding *binding,
|
||||
const GValue *source_value,
|
||||
GValue *target_value,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpTransformOptions, gimp_transform_options,
|
||||
GIMP_TYPE_TOOL_OPTIONS,
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
|
||||
|
@ -134,96 +110,6 @@ gimp_transform_options_class_init (GimpTransformOptionsClass *klass)
|
|||
GIMP_TYPE_TRANSFORM_RESIZE,
|
||||
GIMP_TRANSFORM_RESIZE_ADJUST,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_PREVIEW,
|
||||
"show-preview",
|
||||
_("Show image preview"),
|
||||
_("Show a preview of the transformed image"),
|
||||
TRUE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_PREVIEW_OPACITY,
|
||||
"preview-opacity",
|
||||
_("Image opacity"),
|
||||
_("Opacity of the preview image"),
|
||||
0.0, 1.0, 1.0,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_ENUM (object_class, PROP_GRID_TYPE,
|
||||
"grid-type",
|
||||
_("Guides"),
|
||||
_("Composition guides such as rule of thirds"),
|
||||
GIMP_TYPE_GUIDES_TYPE,
|
||||
GIMP_GUIDES_NONE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_INT (object_class, PROP_GRID_SIZE,
|
||||
"grid-size",
|
||||
NULL,
|
||||
_("Size of a grid cell for variable number "
|
||||
"of composition guides"),
|
||||
1, 128, 15,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_MOVE,
|
||||
"constrain-move",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_SCALE,
|
||||
"constrain-scale",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_ROTATE,
|
||||
"constrain-rotate",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_SHEAR,
|
||||
"constrain-shear",
|
||||
NULL, NULL,
|
||||
TRUE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_PERSPECTIVE,
|
||||
"constrain-perspective",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_FROMPIVOT_SCALE,
|
||||
"frompivot-scale",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_FROMPIVOT_SHEAR,
|
||||
"frompivot-shear",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_FROMPIVOT_PERSPECTIVE,
|
||||
"frompivot-perspective",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CORNERSNAP,
|
||||
"cornersnap",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_FIXEDPIVOT,
|
||||
"fixedpivot",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -254,14 +140,6 @@ gimp_transform_options_set_property (GObject *object,
|
|||
break;
|
||||
case PROP_DIRECTION:
|
||||
options->direction = g_value_get_enum (value);
|
||||
|
||||
/* Expected default for corrective transform is to see the
|
||||
* original image only.
|
||||
*/
|
||||
g_object_set (options,
|
||||
"show-preview",
|
||||
options->direction != GIMP_TRANSFORM_BACKWARD,
|
||||
NULL);
|
||||
break;
|
||||
case PROP_INTERPOLATION:
|
||||
options->interpolation = g_value_get_enum (value);
|
||||
|
@ -269,48 +147,6 @@ gimp_transform_options_set_property (GObject *object,
|
|||
case PROP_CLIP:
|
||||
options->clip = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_SHOW_PREVIEW:
|
||||
options->show_preview = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_PREVIEW_OPACITY:
|
||||
options->preview_opacity = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_GRID_TYPE:
|
||||
options->grid_type = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_GRID_SIZE:
|
||||
options->grid_size = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_CONSTRAIN_MOVE:
|
||||
options->constrain_move = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_CONSTRAIN_SCALE:
|
||||
options->constrain_scale = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_CONSTRAIN_ROTATE:
|
||||
options->constrain_rotate = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_CONSTRAIN_SHEAR:
|
||||
options->constrain_shear = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_CONSTRAIN_PERSPECTIVE:
|
||||
options->constrain_perspective = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_FROMPIVOT_SCALE:
|
||||
options->frompivot_scale = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_FROMPIVOT_SHEAR:
|
||||
options->frompivot_shear = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_FROMPIVOT_PERSPECTIVE:
|
||||
options->frompivot_perspective = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_CORNERSNAP:
|
||||
options->cornersnap = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_FIXEDPIVOT:
|
||||
options->fixedpivot = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -339,48 +175,6 @@ gimp_transform_options_get_property (GObject *object,
|
|||
case PROP_CLIP:
|
||||
g_value_set_enum (value, options->clip);
|
||||
break;
|
||||
case PROP_SHOW_PREVIEW:
|
||||
g_value_set_boolean (value, options->show_preview);
|
||||
break;
|
||||
case PROP_PREVIEW_OPACITY:
|
||||
g_value_set_double (value, options->preview_opacity);
|
||||
break;
|
||||
case PROP_GRID_TYPE:
|
||||
g_value_set_enum (value, options->grid_type);
|
||||
break;
|
||||
case PROP_GRID_SIZE:
|
||||
g_value_set_int (value, options->grid_size);
|
||||
break;
|
||||
case PROP_CONSTRAIN_MOVE:
|
||||
g_value_set_boolean (value, options->constrain_move);
|
||||
break;
|
||||
case PROP_CONSTRAIN_SCALE:
|
||||
g_value_set_boolean (value, options->constrain_scale);
|
||||
break;
|
||||
case PROP_CONSTRAIN_ROTATE:
|
||||
g_value_set_boolean (value, options->constrain_rotate);
|
||||
break;
|
||||
case PROP_CONSTRAIN_SHEAR:
|
||||
g_value_set_boolean (value, options->constrain_shear);
|
||||
break;
|
||||
case PROP_CONSTRAIN_PERSPECTIVE:
|
||||
g_value_set_boolean (value, options->constrain_perspective);
|
||||
break;
|
||||
case PROP_FROMPIVOT_SCALE:
|
||||
g_value_set_boolean (value, options->frompivot_scale);
|
||||
break;
|
||||
case PROP_FROMPIVOT_SHEAR:
|
||||
g_value_set_boolean (value, options->frompivot_shear);
|
||||
break;
|
||||
case PROP_FROMPIVOT_PERSPECTIVE:
|
||||
g_value_set_boolean (value, options->frompivot_perspective);
|
||||
break;
|
||||
case PROP_CORNERSNAP:
|
||||
g_value_set_boolean (value, options->cornersnap);
|
||||
break;
|
||||
case PROP_FIXEDPIVOT:
|
||||
g_value_set_boolean (value, options->fixedpivot);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -405,14 +199,20 @@ gimp_transform_options_reset (GimpConfig *config)
|
|||
|
||||
/**
|
||||
* gimp_transform_options_gui:
|
||||
* @tool_options: a #GimpToolOptions
|
||||
* @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
|
||||
*
|
||||
* Build the Transform Tool Options.
|
||||
*
|
||||
* Return value: a container holding the transform tool options
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_transform_options_gui (GimpToolOptions *tool_options)
|
||||
gimp_transform_options_gui (GimpToolOptions *tool_options,
|
||||
gboolean direction,
|
||||
gboolean interpolation,
|
||||
gboolean clipping)
|
||||
{
|
||||
GObject *config = G_OBJECT (tool_options);
|
||||
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
|
||||
|
@ -421,10 +221,6 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
|
|||
GtkWidget *label;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *combo;
|
||||
GtkWidget *scale;
|
||||
GtkWidget *grid_box;
|
||||
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
|
||||
GdkModifierType constrain_mask = gimp_get_constrain_behavior_mask ();
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
|
@ -438,219 +234,33 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
|
|||
gtk_box_pack_start (GTK_BOX (hbox), box, FALSE, FALSE, 0);
|
||||
gtk_widget_show (box);
|
||||
|
||||
frame = gimp_prop_enum_radio_frame_new (config, "direction", NULL,
|
||||
0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
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);
|
||||
gtk_widget_show (frame);
|
||||
}
|
||||
|
||||
/* the interpolation menu */
|
||||
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);
|
||||
gtk_widget_show (combo);
|
||||
if (interpolation)
|
||||
{
|
||||
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);
|
||||
gtk_widget_show (combo);
|
||||
}
|
||||
|
||||
/* the clipping menu */
|
||||
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);
|
||||
gtk_widget_show (combo);
|
||||
|
||||
/* the preview frame */
|
||||
scale = gimp_prop_spin_scale_new (config, "preview-opacity", NULL,
|
||||
0.01, 0.1, 0);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
|
||||
frame = gimp_prop_expanding_frame_new (config, "show-preview", NULL,
|
||||
scale, NULL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* the guides frame */
|
||||
frame = gimp_frame_new (NULL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* the guides type menu */
|
||||
combo = gimp_prop_enum_combo_box_new (config, "grid-type", 0, 0);
|
||||
gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Guides"));
|
||||
g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
||||
gtk_frame_set_label_widget (GTK_FRAME (frame), combo);
|
||||
gtk_widget_show (combo);
|
||||
|
||||
/* the grid density scale */
|
||||
scale = gimp_prop_spin_scale_new (config, "grid-size", NULL,
|
||||
1.8, 8.0, 0);
|
||||
gimp_spin_scale_set_label (GIMP_SPIN_SCALE (scale), NULL);
|
||||
gtk_container_add (GTK_CONTAINER (frame), scale);
|
||||
|
||||
g_object_bind_property_full (config, "grid-type",
|
||||
scale, "visible",
|
||||
G_BINDING_SYNC_CREATE,
|
||||
gimp_transform_options_sync_grid,
|
||||
NULL,
|
||||
NULL, NULL);
|
||||
|
||||
if (tool_options->tool_info->tool_type == GIMP_TYPE_ROTATE_TOOL)
|
||||
if (clipping)
|
||||
{
|
||||
GtkWidget *button;
|
||||
gchar *label;
|
||||
|
||||
label = g_strdup_printf (_("15 degrees (%s)"),
|
||||
gimp_get_mod_string (extend_mask));
|
||||
|
||||
button = gimp_prop_check_button_new (config, "constrain-rotate", label);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gimp_help_set_help_data (button, _("Limit rotation steps to 15 degrees"),
|
||||
NULL);
|
||||
|
||||
g_free (label);
|
||||
}
|
||||
else if (tool_options->tool_info->tool_type == GIMP_TYPE_SCALE_TOOL)
|
||||
{
|
||||
GtkWidget *button;
|
||||
gchar *label;
|
||||
|
||||
label = g_strdup_printf (_("Keep aspect (%s)"),
|
||||
gimp_get_mod_string (extend_mask));
|
||||
|
||||
button = gimp_prop_check_button_new (config, "constrain-scale", label);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gimp_help_set_help_data (button, _("Keep the original aspect ratio"),
|
||||
NULL);
|
||||
|
||||
g_free (label);
|
||||
|
||||
label = g_strdup_printf (_("Around center (%s)"),
|
||||
gimp_get_mod_string (constrain_mask));
|
||||
|
||||
button = gimp_prop_check_button_new (config, "frompivot-scale", label);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gimp_help_set_help_data (button, _("Scale around the center point"),
|
||||
NULL);
|
||||
|
||||
g_free (label);
|
||||
}
|
||||
else if (tool_options->tool_info->tool_type == GIMP_TYPE_UNIFIED_TRANSFORM_TOOL)
|
||||
{
|
||||
struct
|
||||
{
|
||||
GdkModifierType mod;
|
||||
gchar *name;
|
||||
gchar *desc;
|
||||
gchar *tip;
|
||||
}
|
||||
opt_list[] =
|
||||
{
|
||||
{ extend_mask, NULL, N_("Constrain (%s)") },
|
||||
{ extend_mask, "constrain-move", N_("Move"),
|
||||
N_("Constrain movement to 45 degree angles from center (%s)") },
|
||||
{ extend_mask, "constrain-scale", N_("Scale"),
|
||||
N_("Maintain aspect ratio when scaling (%s)") },
|
||||
{ extend_mask, "constrain-rotate", N_("Rotate"),
|
||||
N_("Constrain rotation to 15 degree increments (%s)") },
|
||||
{ extend_mask, "constrain-shear", N_("Shear"),
|
||||
N_("Shear along edge direction only (%s)") },
|
||||
{ extend_mask, "constrain-perspective", N_("Perspective"),
|
||||
N_("Constrain perspective handles to move along edges and diagonal (%s)") },
|
||||
|
||||
{ constrain_mask, NULL,
|
||||
N_("From pivot (%s)") },
|
||||
{ constrain_mask, "frompivot-scale", N_("Scale"),
|
||||
N_("Scale from pivot point (%s)") },
|
||||
{ constrain_mask, "frompivot-shear", N_("Shear"),
|
||||
N_("Shear opposite edge by same amount (%s)") },
|
||||
{ constrain_mask, "frompivot-perspective", N_("Perspective"),
|
||||
N_("Maintain position of pivot while changing perspective (%s)") },
|
||||
|
||||
{ 0, NULL,
|
||||
N_("Pivot") },
|
||||
{ extend_mask, "cornersnap", N_("Snap (%s)"),
|
||||
N_("Snap pivot to corners and center (%s)") },
|
||||
{ 0, "fixedpivot", N_("Lock"),
|
||||
N_("Lock pivot position to canvas") },
|
||||
};
|
||||
|
||||
GtkWidget *button;
|
||||
gchar *label;
|
||||
gint i;
|
||||
|
||||
frame = NULL;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (opt_list); i++)
|
||||
{
|
||||
if (! opt_list[i].name && ! opt_list[i].desc)
|
||||
{
|
||||
frame = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
label = g_strdup_printf (gettext (opt_list[i].desc),
|
||||
gimp_get_mod_string (opt_list[i].mod));
|
||||
|
||||
if (opt_list[i].name)
|
||||
{
|
||||
button = gimp_prop_check_button_new (config, opt_list[i].name,
|
||||
label);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (frame ? grid_box : vbox),
|
||||
button, FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_free (label);
|
||||
label = g_strdup_printf (gettext (opt_list[i].tip),
|
||||
gimp_get_mod_string (opt_list[i].mod));
|
||||
|
||||
gimp_help_set_help_data (button, label, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = gimp_frame_new (label);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
grid_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
||||
gtk_container_add (GTK_CONTAINER (frame), grid_box);
|
||||
gtk_widget_show (grid_box);
|
||||
}
|
||||
|
||||
g_free (label);
|
||||
}
|
||||
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);
|
||||
gtk_widget_show (combo);
|
||||
}
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_transform_options_show_preview (GimpTransformOptions *options)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_TRANSFORM_OPTIONS (options), FALSE);
|
||||
|
||||
return (options->show_preview &&
|
||||
options->type == GIMP_TRANSFORM_TYPE_LAYER);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static gboolean
|
||||
gimp_transform_options_sync_grid (GBinding *binding,
|
||||
const GValue *source_value,
|
||||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
GimpGuidesType type = g_value_get_enum (source_value);
|
||||
|
||||
g_value_set_boolean (target_value,
|
||||
type == GIMP_GUIDES_N_LINES ||
|
||||
type == GIMP_GUIDES_SPACING);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -35,26 +35,12 @@ typedef struct _GimpTransformOptionsClass GimpTransformOptionsClass;
|
|||
|
||||
struct _GimpTransformOptions
|
||||
{
|
||||
GimpToolOptions parent_instance;
|
||||
GimpToolOptions parent_instance;
|
||||
|
||||
GimpTransformType type;
|
||||
GimpTransformDirection direction;
|
||||
GimpInterpolationType interpolation;
|
||||
GimpTransformResize clip;
|
||||
gboolean show_preview;
|
||||
gdouble preview_opacity;
|
||||
GimpGuidesType grid_type;
|
||||
gint grid_size;
|
||||
gboolean constrain_move;
|
||||
gboolean constrain_scale;
|
||||
gboolean constrain_rotate;
|
||||
gboolean constrain_shear;
|
||||
gboolean constrain_perspective;
|
||||
gboolean frompivot_scale;
|
||||
gboolean frompivot_shear;
|
||||
gboolean frompivot_perspective;
|
||||
gboolean cornersnap;
|
||||
gboolean fixedpivot;
|
||||
GimpTransformType type;
|
||||
GimpTransformDirection direction;
|
||||
GimpInterpolationType interpolation;
|
||||
GimpTransformResize clip;
|
||||
};
|
||||
|
||||
struct _GimpTransformOptionsClass
|
||||
|
@ -63,11 +49,12 @@ struct _GimpTransformOptionsClass
|
|||
};
|
||||
|
||||
|
||||
GType gimp_transform_options_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_transform_options_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_transform_options_gui (GimpToolOptions *tool_options);
|
||||
|
||||
gboolean gimp_transform_options_show_preview (GimpTransformOptions *options);
|
||||
GtkWidget * gimp_transform_options_gui (GimpToolOptions *tool_options,
|
||||
gboolean direction,
|
||||
gboolean interpolation,
|
||||
gboolean clipping);
|
||||
|
||||
|
||||
#endif /* __GIMP_TRANSFORM_OPTIONS_H__ */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -45,35 +45,13 @@ typedef struct _GimpTransformToolClass GimpTransformToolClass;
|
|||
|
||||
struct _GimpTransformTool
|
||||
{
|
||||
GimpDrawTool parent_instance;
|
||||
GimpDrawTool parent_instance;
|
||||
|
||||
gint x1, y1; /* upper left hand coordinate */
|
||||
gint x2, y2; /* lower right hand coords */
|
||||
gint x1, y1; /* upper left hand coordinate */
|
||||
gint x2, y2; /* lower right hand coords */
|
||||
|
||||
GimpMatrix3 transform; /* transformation matrix */
|
||||
gboolean transform_valid; /* whether the matrix is valid */
|
||||
TransInfo trans_info; /* transformation info */
|
||||
TransInfo *old_trans_info; /* for resetting everything */
|
||||
TransInfo *prev_trans_info; /* the current finished state */
|
||||
GList *undo_list; /* list of all states,
|
||||
head is current == prev_trans_info,
|
||||
tail is original == old_trans_info */
|
||||
GList *redo_list; /* list of all undone states,
|
||||
NULL when nothing undone */
|
||||
|
||||
GimpItem *hidden_item; /* the item that was hidden during
|
||||
the transform */
|
||||
|
||||
GimpToolWidget *widget;
|
||||
GimpToolWidget *grab_widget;
|
||||
GimpCanvasItem *preview;
|
||||
GimpCanvasItem *boundary_in;
|
||||
GimpCanvasItem *boundary_out;
|
||||
GPtrArray *strokes;
|
||||
|
||||
const gchar *progress_text;
|
||||
|
||||
GimpToolGui *gui;
|
||||
GimpMatrix3 transform; /* transformation matrix */
|
||||
gboolean transform_valid; /* whether the matrix is valid */
|
||||
};
|
||||
|
||||
struct _GimpTransformToolClass
|
||||
|
@ -81,31 +59,35 @@ struct _GimpTransformToolClass
|
|||
GimpDrawToolClass parent_class;
|
||||
|
||||
/* virtual functions */
|
||||
void (* dialog) (GimpTransformTool *tool);
|
||||
void (* dialog_update) (GimpTransformTool *tool);
|
||||
void (* prepare) (GimpTransformTool *tool);
|
||||
GimpToolWidget * (* get_widget) (GimpTransformTool *tool);
|
||||
void (* recalc_matrix) (GimpTransformTool *tool,
|
||||
GimpToolWidget *widget);
|
||||
gchar * (* get_undo_desc) (GimpTransformTool *tool);
|
||||
GeglBuffer * (* transform) (GimpTransformTool *tool,
|
||||
GimpItem *item,
|
||||
GeglBuffer *orig_buffer,
|
||||
gint orig_offset_x,
|
||||
gint orig_offset_y,
|
||||
GimpColorProfile **buffer_profile,
|
||||
gint *new_offset_x,
|
||||
gint *new_offset_y);
|
||||
void (* recalc_matrix) (GimpTransformTool *tr_tool);
|
||||
gchar * (* get_undo_desc) (GimpTransformTool *tr_tool);
|
||||
GeglBuffer * (* transform) (GimpTransformTool *tr_tool,
|
||||
GimpItem *item,
|
||||
GeglBuffer *orig_buffer,
|
||||
gint orig_offset_x,
|
||||
gint orig_offset_y,
|
||||
GimpColorProfile **buffer_profile,
|
||||
gint *new_offset_x,
|
||||
gint *new_offset_y);
|
||||
|
||||
const gchar *ok_button_label;
|
||||
const gchar *progress_text;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_transform_tool_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_transform_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void gimp_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget);
|
||||
void gimp_transform_tool_push_internal_undo (GimpTransformTool *tr_tool);
|
||||
GimpItem * gimp_transform_tool_get_active_item (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *display,
|
||||
gboolean invisible_layer_ok,
|
||||
GError **error);
|
||||
|
||||
gboolean gimp_transform_tool_bounds (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *display);
|
||||
void gimp_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *display);
|
||||
|
||||
gboolean gimp_transform_tool_transform (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *display);
|
||||
|
||||
|
||||
#endif /* __GIMP_TRANSFORM_TOOL_H__ */
|
||||
|
|
|
@ -1,220 +0,0 @@
|
|||
/* GIMP - The GNU 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "gimptoolcontrol.h"
|
||||
#include "gimptransformtool.h"
|
||||
#include "gimptransformtoolundo.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_TRANSFORM_TOOL
|
||||
};
|
||||
|
||||
|
||||
static void gimp_transform_tool_undo_constructed (GObject *object);
|
||||
static void gimp_transform_tool_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_transform_tool_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_transform_tool_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void gimp_transform_tool_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpTransformToolUndo, gimp_transform_tool_undo, GIMP_TYPE_UNDO)
|
||||
|
||||
#define parent_class gimp_transform_tool_undo_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_transform_tool_undo_class_init (GimpTransformToolUndoClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
|
||||
|
||||
object_class->constructed = gimp_transform_tool_undo_constructed;
|
||||
object_class->set_property = gimp_transform_tool_undo_set_property;
|
||||
object_class->get_property = gimp_transform_tool_undo_get_property;
|
||||
|
||||
undo_class->pop = gimp_transform_tool_undo_pop;
|
||||
undo_class->free = gimp_transform_tool_undo_free;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_TRANSFORM_TOOL,
|
||||
g_param_spec_object ("transform-tool",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_TRANSFORM_TOOL,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_undo_init (GimpTransformToolUndo *undo)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_undo_constructed (GObject *object)
|
||||
{
|
||||
GimpTransformToolUndo *transform_tool_undo = GIMP_TRANSFORM_TOOL_UNDO (object);
|
||||
GimpTransformTool *transform_tool;
|
||||
gint i;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->constructed (object);
|
||||
|
||||
gimp_assert (GIMP_IS_TRANSFORM_TOOL (transform_tool_undo->transform_tool));
|
||||
|
||||
transform_tool = transform_tool_undo->transform_tool;
|
||||
|
||||
for (i = 0; i < TRANS_INFO_SIZE; i++)
|
||||
transform_tool_undo->trans_info[i] = (*transform_tool->old_trans_info)[i];
|
||||
|
||||
#if 0
|
||||
if (transform_tool->original)
|
||||
transform_tool_undo->original = tile_manager_ref (transform_tool->original);
|
||||
#endif
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (transform_tool_undo->transform_tool),
|
||||
(gpointer) &transform_tool_undo->transform_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpTransformToolUndo *transform_tool_undo = GIMP_TRANSFORM_TOOL_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_TRANSFORM_TOOL:
|
||||
transform_tool_undo->transform_tool = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpTransformToolUndo *transform_tool_undo = GIMP_TRANSFORM_TOOL_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_TRANSFORM_TOOL:
|
||||
g_value_set_object (value, transform_tool_undo->transform_tool);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
GimpTransformToolUndo *transform_tool_undo = GIMP_TRANSFORM_TOOL_UNDO (undo);
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
|
||||
|
||||
if (transform_tool_undo->transform_tool)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
#if 0
|
||||
TileManager *temp;
|
||||
#endif
|
||||
gdouble d;
|
||||
gint i;
|
||||
|
||||
transform_tool = transform_tool_undo->transform_tool;
|
||||
|
||||
/* swap the transformation information arrays */
|
||||
for (i = 0; i < TRANS_INFO_SIZE; i++)
|
||||
{
|
||||
d = transform_tool_undo->trans_info[i];
|
||||
transform_tool_undo->trans_info[i] = transform_tool->trans_info[i];
|
||||
transform_tool->trans_info[i] = d;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* swap the original buffer--the source buffer for repeated transforms
|
||||
*/
|
||||
temp = transform_tool_undo->original;
|
||||
transform_tool_undo->original = transform_tool->original;
|
||||
transform_tool->original = temp;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* If we're re-implementing the first transform, reactivate tool */
|
||||
if (undo_mode == GIMP_UNDO_MODE_REDO && transform_tool->original)
|
||||
{
|
||||
gimp_tool_control_activate (GIMP_TOOL (transform_tool)->control);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (transform_tool));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
GimpTransformToolUndo *transform_tool_undo = GIMP_TRANSFORM_TOOL_UNDO (undo);
|
||||
|
||||
if (transform_tool_undo->transform_tool)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (transform_tool_undo->transform_tool),
|
||||
(gpointer) &transform_tool_undo->transform_tool);
|
||||
transform_tool_undo->transform_tool = NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (transform_tool_undo->original)
|
||||
{
|
||||
tile_manager_unref (transform_tool_undo->original);
|
||||
transform_tool_undo->original = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/* GIMP - The GNU 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_TRANSFORM_TOOL_UNDO_H__
|
||||
#define __GIMP_TRANSFORM_TOOL_UNDO_H__
|
||||
|
||||
|
||||
#include "core/gimpundo.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_TRANSFORM_TOOL_UNDO (gimp_transform_tool_undo_get_type ())
|
||||
#define GIMP_TRANSFORM_TOOL_UNDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TRANSFORM_TOOL_UNDO, GimpTransformToolUndo))
|
||||
#define GIMP_TRANSFORM_TOOL_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TRANSFORM_TOOL_UNDO, GimpTransformToolUndoClass))
|
||||
#define GIMP_IS_TRANSFORM_TOOL_UNDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TRANSFORM_TOOL_UNDO))
|
||||
#define GIMP_IS_TRANSFORM_TOOL_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TRANSFORM_TOOL_UNDO))
|
||||
#define GIMP_TRANSFORM_TOOL_UNDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TRANSFORM_TOOL_UNDO, GimpTransformToolUndoClass))
|
||||
|
||||
|
||||
typedef struct _GimpTransformToolUndo GimpTransformToolUndo;
|
||||
typedef struct _GimpTransformToolUndoClass GimpTransformToolUndoClass;
|
||||
|
||||
struct _GimpTransformToolUndo
|
||||
{
|
||||
GimpUndo parent_instance;
|
||||
|
||||
GimpTransformTool *transform_tool;
|
||||
TransInfo trans_info;
|
||||
#if 0
|
||||
TileManager *original;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct _GimpTransformToolUndoClass
|
||||
{
|
||||
GimpUndoClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_transform_tool_undo_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_TRANSFORM_TOOL_UNDO_H__ */
|
|
@ -32,7 +32,7 @@
|
|||
#include "display/gimptooltransformgrid.h"
|
||||
|
||||
#include "gimptoolcontrol.h"
|
||||
#include "gimptransformoptions.h"
|
||||
#include "gimptransformgridoptions.h"
|
||||
#include "gimpunifiedtransformtool.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
@ -56,17 +56,18 @@ enum
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_unified_transform_tool_prepare (GimpTransformTool *tr_tool);
|
||||
static GimpToolWidget * gimp_unified_transform_tool_get_widget (GimpTransformTool *tr_tool);
|
||||
static void gimp_unified_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget);
|
||||
static gchar * gimp_unified_transform_tool_get_undo_desc (GimpTransformTool *tr_tool);
|
||||
|
||||
static void gimp_unified_transform_tool_prepare (GimpTransformGridTool *tg_tool);
|
||||
static GimpToolWidget * gimp_unified_transform_tool_get_widget (GimpTransformGridTool *tg_tool);
|
||||
static void gimp_unified_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget);
|
||||
|
||||
static void gimp_unified_transform_tool_recalc_points (GimpGenericTransformTool *generic,
|
||||
GimpToolWidget *widget);
|
||||
|
||||
static void gimp_unified_transform_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformTool *tr_tool);
|
||||
GimpTransformGridTool *tg_tool);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpUnifiedTransformTool, gimp_unified_transform_tool,
|
||||
|
@ -80,8 +81,8 @@ gimp_unified_transform_tool_register (GimpToolRegisterCallback callback,
|
|||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_UNIFIED_TRANSFORM_TOOL,
|
||||
GIMP_TYPE_TRANSFORM_OPTIONS,
|
||||
gimp_transform_options_gui,
|
||||
GIMP_TYPE_TRANSFORM_GRID_OPTIONS,
|
||||
gimp_transform_grid_options_gui,
|
||||
GIMP_CONTEXT_PROP_MASK_BACKGROUND,
|
||||
"gimp-unified-transform-tool",
|
||||
_("Unified Transform"),
|
||||
|
@ -96,49 +97,59 @@ gimp_unified_transform_tool_register (GimpToolRegisterCallback callback,
|
|||
static void
|
||||
gimp_unified_transform_tool_class_init (GimpUnifiedTransformToolClass *klass)
|
||||
{
|
||||
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
||||
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
|
||||
GimpGenericTransformToolClass *generic_class = GIMP_GENERIC_TRANSFORM_TOOL_CLASS (klass);
|
||||
|
||||
trans_class->prepare = gimp_unified_transform_tool_prepare;
|
||||
trans_class->get_widget = gimp_unified_transform_tool_get_widget;
|
||||
trans_class->recalc_matrix = gimp_unified_transform_tool_recalc_matrix;
|
||||
trans_class->get_undo_desc = gimp_unified_transform_tool_get_undo_desc;
|
||||
tr_class->get_undo_desc = gimp_unified_transform_tool_get_undo_desc;
|
||||
|
||||
tg_class->prepare = gimp_unified_transform_tool_prepare;
|
||||
tg_class->get_widget = gimp_unified_transform_tool_get_widget;
|
||||
tg_class->recalc_matrix = gimp_unified_transform_tool_recalc_matrix;
|
||||
|
||||
generic_class->recalc_points = gimp_unified_transform_tool_recalc_points;
|
||||
|
||||
tr_class->progress_text = _("Unified transform");
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_unified_transform_tool_init (GimpUnifiedTransformTool *unified_tool)
|
||||
{
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (unified_tool);
|
||||
}
|
||||
|
||||
tr_tool->progress_text = _("Unified transform");
|
||||
static gchar *
|
||||
gimp_unified_transform_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
||||
{
|
||||
return g_strdup (C_("undo-type", "Unified Transform"));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_unified_transform_tool_prepare (GimpTransformTool *tr_tool)
|
||||
gimp_unified_transform_tool_prepare (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->prepare (tr_tool);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
|
||||
tr_tool->trans_info[PIVOT_X] = (gdouble) (tr_tool->x1 + tr_tool->x2) / 2.0;
|
||||
tr_tool->trans_info[PIVOT_Y] = (gdouble) (tr_tool->y1 + tr_tool->y2) / 2.0;
|
||||
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->prepare (tg_tool);
|
||||
|
||||
tr_tool->trans_info[X0] = (gdouble) tr_tool->x1;
|
||||
tr_tool->trans_info[Y0] = (gdouble) tr_tool->y1;
|
||||
tr_tool->trans_info[X1] = (gdouble) tr_tool->x2;
|
||||
tr_tool->trans_info[Y1] = (gdouble) tr_tool->y1;
|
||||
tr_tool->trans_info[X2] = (gdouble) tr_tool->x1;
|
||||
tr_tool->trans_info[Y2] = (gdouble) tr_tool->y2;
|
||||
tr_tool->trans_info[X3] = (gdouble) tr_tool->x2;
|
||||
tr_tool->trans_info[Y3] = (gdouble) tr_tool->y2;
|
||||
tg_tool->trans_info[PIVOT_X] = (gdouble) (tr_tool->x1 + tr_tool->x2) / 2.0;
|
||||
tg_tool->trans_info[PIVOT_Y] = (gdouble) (tr_tool->y1 + tr_tool->y2) / 2.0;
|
||||
|
||||
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->y1;
|
||||
tg_tool->trans_info[X2] = (gdouble) tr_tool->x1;
|
||||
tg_tool->trans_info[Y2] = (gdouble) tr_tool->y2;
|
||||
tg_tool->trans_info[X3] = (gdouble) tr_tool->x2;
|
||||
tg_tool->trans_info[Y3] = (gdouble) tr_tool->y2;
|
||||
}
|
||||
|
||||
static GimpToolWidget *
|
||||
gimp_unified_transform_tool_get_widget (GimpTransformTool *tr_tool)
|
||||
gimp_unified_transform_tool_get_widget (GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (tr_tool);
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
||||
GimpToolWidget *widget;
|
||||
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,
|
||||
|
@ -161,16 +172,18 @@ gimp_unified_transform_tool_get_widget (GimpTransformTool *tr_tool)
|
|||
|
||||
g_signal_connect (widget, "changed",
|
||||
G_CALLBACK (gimp_unified_transform_tool_widget_changed),
|
||||
tr_tool);
|
||||
tg_tool);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_unified_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
||||
GimpToolWidget *widget)
|
||||
gimp_unified_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
|
||||
GimpToolWidget *widget)
|
||||
{
|
||||
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool, widget);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
|
||||
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->recalc_matrix (tg_tool, widget);
|
||||
|
||||
if (widget)
|
||||
g_object_set (widget,
|
||||
|
@ -179,68 +192,64 @@ gimp_unified_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
|
|||
"y1", (gdouble) tr_tool->y1,
|
||||
"x2", (gdouble) tr_tool->x2,
|
||||
"y2", (gdouble) tr_tool->y2,
|
||||
"pivot-x", tr_tool->trans_info[PIVOT_X],
|
||||
"pivot-y", tr_tool->trans_info[PIVOT_Y],
|
||||
"pivot-x", tg_tool->trans_info[PIVOT_X],
|
||||
"pivot-y", tg_tool->trans_info[PIVOT_Y],
|
||||
NULL);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gimp_unified_transform_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
||||
{
|
||||
return g_strdup (C_("undo-type", "Unified Transform"));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_unified_transform_tool_recalc_points (GimpGenericTransformTool *generic,
|
||||
GimpToolWidget *widget)
|
||||
{
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (generic);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (generic);
|
||||
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (generic);
|
||||
|
||||
generic->input_points[0] = (GimpVector2) {tr_tool->x1, tr_tool->y1};
|
||||
generic->input_points[1] = (GimpVector2) {tr_tool->x2, tr_tool->y1};
|
||||
generic->input_points[2] = (GimpVector2) {tr_tool->x1, tr_tool->y2};
|
||||
generic->input_points[3] = (GimpVector2) {tr_tool->x2, tr_tool->y2};
|
||||
|
||||
generic->output_points[0] = (GimpVector2) {tr_tool->trans_info[X0],
|
||||
tr_tool->trans_info[Y0]};
|
||||
generic->output_points[1] = (GimpVector2) {tr_tool->trans_info[X1],
|
||||
tr_tool->trans_info[Y1]};
|
||||
generic->output_points[2] = (GimpVector2) {tr_tool->trans_info[X2],
|
||||
tr_tool->trans_info[Y2]};
|
||||
generic->output_points[3] = (GimpVector2) {tr_tool->trans_info[X3],
|
||||
tr_tool->trans_info[Y3]};
|
||||
generic->output_points[0] = (GimpVector2) {tg_tool->trans_info[X0],
|
||||
tg_tool->trans_info[Y0]};
|
||||
generic->output_points[1] = (GimpVector2) {tg_tool->trans_info[X1],
|
||||
tg_tool->trans_info[Y1]};
|
||||
generic->output_points[2] = (GimpVector2) {tg_tool->trans_info[X2],
|
||||
tg_tool->trans_info[Y2]};
|
||||
generic->output_points[3] = (GimpVector2) {tg_tool->trans_info[X3],
|
||||
tg_tool->trans_info[Y3]};
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_unified_transform_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformTool *tr_tool)
|
||||
gimp_unified_transform_tool_widget_changed (GimpToolWidget *widget,
|
||||
GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpMatrix3 *transform;
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
GimpMatrix3 *transform;
|
||||
|
||||
g_object_get (widget,
|
||||
"transform", &transform,
|
||||
"pivot-x", &tr_tool->trans_info[PIVOT_X],
|
||||
"pivot-y", &tr_tool->trans_info[PIVOT_Y],
|
||||
"pivot-x", &tg_tool->trans_info[PIVOT_X],
|
||||
"pivot-y", &tg_tool->trans_info[PIVOT_Y],
|
||||
NULL);
|
||||
|
||||
gimp_matrix3_transform_point (transform,
|
||||
tr_tool->x1, tr_tool->y1,
|
||||
&tr_tool->trans_info[X0],
|
||||
&tr_tool->trans_info[Y0]);
|
||||
&tg_tool->trans_info[X0],
|
||||
&tg_tool->trans_info[Y0]);
|
||||
gimp_matrix3_transform_point (transform,
|
||||
tr_tool->x2, tr_tool->y1,
|
||||
&tr_tool->trans_info[X1],
|
||||
&tr_tool->trans_info[Y1]);
|
||||
&tg_tool->trans_info[X1],
|
||||
&tg_tool->trans_info[Y1]);
|
||||
gimp_matrix3_transform_point (transform,
|
||||
tr_tool->x1, tr_tool->y2,
|
||||
&tr_tool->trans_info[X2],
|
||||
&tr_tool->trans_info[Y2]);
|
||||
&tg_tool->trans_info[X2],
|
||||
&tg_tool->trans_info[Y2]);
|
||||
gimp_matrix3_transform_point (transform,
|
||||
tr_tool->x2, tr_tool->y2,
|
||||
&tr_tool->trans_info[X3],
|
||||
&tr_tool->trans_info[Y3]);
|
||||
&tg_tool->trans_info[X3],
|
||||
&tg_tool->trans_info[Y3]);
|
||||
|
||||
g_free (transform);
|
||||
|
||||
gimp_transform_tool_recalc_matrix (tr_tool, NULL);
|
||||
gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ typedef struct _GimpDrawTool GimpDrawTool;
|
|||
typedef struct _GimpFilterTool GimpFilterTool;
|
||||
typedef struct _GimpGenericTransformTool GimpGenericTransformTool;
|
||||
typedef struct _GimpPaintTool GimpPaintTool;
|
||||
typedef struct _GimpTransformGridTool GimpTransformGridTool;
|
||||
typedef struct _GimpTransformTool GimpTransformTool;
|
||||
|
||||
typedef struct _GimpColorOptions GimpColorOptions;
|
||||
|
|
|
@ -485,6 +485,8 @@ app/tools/gimptexttool.c
|
|||
app/tools/gimptexttool-editor.c
|
||||
app/tools/gimpthresholdtool.c
|
||||
app/tools/gimptool.c
|
||||
app/tools/gimptransformgridoptions.c
|
||||
app/tools/gimptransformgridtool.c
|
||||
app/tools/gimptransformoptions.c
|
||||
app/tools/gimptransformtool.c
|
||||
app/tools/gimpunifiedtransformtool.c
|
||||
|
|
Loading…
Reference in New Issue