Commit 24c39e39 authored by David Neary's avatar David Neary
Browse files

Enabled the rest of the transform tools and changed some of the options


Enabled the rest of the transform tools and changed some of
the options stuff in transform_options_new(). There are one or two
outstanding (non-critical) runtime problems in that function.
parent 6c0ad19a
......@@ -79,10 +79,6 @@ struct _TransformOptions
{
ToolOptions tool_options;
GtkType type;
GtkType type_d;
GtkWidget *type_w[4]; /* 4 radio buttons */
gboolean smoothing;
gboolean smoothing_d;
GtkWidget *smoothing_w;
......@@ -167,8 +163,6 @@ static void gimp_transform_tool_control (GimpTool *tool,
static void gimp_transform_tool_draw (GimpDrawTool *draw_tool);
static void gimp_transform_tool_change_type (GtkType new_type);
static TransformOptions * transform_options_new (void);
static void transform_options_reset (ToolOptions *tool_options);
......@@ -1791,16 +1785,6 @@ gimp_transform_tool_show_path_update (GtkWidget *widget,
gimp_transform_tool_showpath_changed (0); /* resume */
}
/* FIXME Do we still want to do this this way? Perhaps we should make
separate icons for each tool. */
static void
gimp_transform_tool_type_callback (GtkWidget *widget,
gpointer data)
{
gimp_transform_tool_change_type ((GtkType) data);
}
static void
gimp_transform_tool_direction_callback (GtkWidget *widget,
gpointer data)
......@@ -1830,15 +1814,6 @@ transform_options_reset (ToolOptions *tool_options)
options = (TransformOptions *) tool_options;
/* FIXME this is gross. */
gtk_toggle_button_set_active (((options->type_d == GIMP_TYPE_ROTATE_TOOL) ?
GTK_TOGGLE_BUTTON (options->type_w[0]) :
((options->type_d == GIMP_TYPE_SCALE_TOOL) ?
GTK_TOGGLE_BUTTON (options->type_w[1]) :
((options->type_d == GIMP_TYPE_SHEAR_TOOL) ?
GTK_TOGGLE_BUTTON (options->type_w[2]) :
GTK_TOGGLE_BUTTON (options->type_w[3])))),
TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->smoothing_w),
options->smoothing_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->showpath_w),
......@@ -1861,8 +1836,8 @@ transform_options_new (void)
TransformOptions *options;
GtkWidget *table;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *hbox2;
GtkWidget *label;
GtkWidget *frame;
GtkWidget *fbox;
......@@ -1872,7 +1847,6 @@ transform_options_new (void)
tool_options_init ((ToolOptions *) options,
transform_options_reset);
options->type = options->type_d = GIMP_TYPE_SCALE_TOOL; /* FIXME: GIMP_TYPE_ROTATE_TOOL; */
options->smoothing = options->smoothing_d = TRUE;
options->showpath = options->showpath_d = TRUE;
options->clip = options->clip_d = FALSE;
......@@ -1880,42 +1854,11 @@ transform_options_new (void)
options->grid_size = options->grid_size_d = 32;
options->show_grid = options->show_grid_d = TRUE;
/* the main table */
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), table,
FALSE, FALSE, 0);
/* the left vbox */
vbox = gtk_vbox_new (FALSE, 2);
gtk_table_attach_defaults (GTK_TABLE (table), vbox, 0, 1, 0, 1);
/* the transform type radio buttons */
frame =
gimp_radio_group_new (TRUE, _("Transform"),
_("Rotation"), gimp_transform_tool_type_callback,
GIMP_TYPE_ROTATE_TOOL, NULL, &options->type_w[0], TRUE,
_("Scaling"), gimp_transform_tool_type_callback,
GIMP_TYPE_SCALE_TOOL, NULL, &options->type_w[1], FALSE,
_("Shearing"), gimp_transform_tool_type_callback,
GIMP_TYPE_SHEAR_TOOL, NULL, &options->type_w[2], FALSE,
_("Perspective"), gimp_transform_tool_type_callback,
GIMP_TYPE_PERSPECTIVE_TOOL, NULL, &options->type_w[3], FALSE,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
gtk_widget_show (vbox);
/* the right vbox */
vbox = gtk_vbox_new (FALSE, 2);
gtk_table_attach_defaults (GTK_TABLE (table), vbox, 1, 2, 0, 1);
/* the top hbox (containing two frames) */
hbox2 = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), hbox2,
FALSE, FALSE, 0);
/* the second radio frame and box, for transform direction */
frame = gimp_radio_group_new (TRUE, _("Tool Paradigm"),
......@@ -1930,12 +1873,12 @@ transform_options_new (void)
NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox2), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
/* the grid frame */
frame = gtk_frame_new (NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox2), frame, FALSE, FALSE, 0);
fbox = gtk_vbox_new (FALSE, 1);
gtk_container_set_border_width (GTK_CONTAINER (fbox), 2);
......@@ -1977,7 +1920,13 @@ transform_options_new (void)
gtk_widget_show (fbox);
gtk_widget_show (frame);
gtk_widget_show (vbox);
gtk_widget_show (hbox2);
/* the main table */
table = gtk_table_new (1, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), table,
FALSE, FALSE, 0);
/* the smoothing toggle button */
options->smoothing_w = gtk_check_button_new_with_label (_("Smoothing"));
......@@ -1985,7 +1934,7 @@ transform_options_new (void)
GTK_SIGNAL_FUNC (gimp_toggle_button_update),
&options->smoothing);
gtk_table_attach_defaults (GTK_TABLE (table),
options->smoothing_w, 0, 1, 1, 2);
options->smoothing_w, 0, 1, 0, 1);
gtk_widget_show (options->smoothing_w);
/* the showpath toggle button */
......@@ -1994,7 +1943,7 @@ transform_options_new (void)
GTK_SIGNAL_FUNC (gimp_transform_tool_show_path_update),
&options->showpath);
gtk_table_attach_defaults (GTK_TABLE (table),
options->showpath_w, 1, 2, 1, 2);
options->showpath_w, 1, 2, 0, 1);
gtk_widget_show (options->showpath_w);
gtk_widget_show (table);
......@@ -2011,25 +1960,6 @@ transform_options_new (void)
return options;
}
static void
gimp_transform_tool_change_type (GtkType new_type)
{
if (transform_options->type != new_type)
{
GimpToolInfo *tool_info;
/* change the type, free the old tool, create the new tool */
transform_options->type = new_type;
tool_info = tool_manager_get_info_by_type (new_type);
if (gimp_context_get_tool (gimp_context_get_user ()) != tool_info)
gimp_context_set_tool (gimp_context_get_user (), tool_info);
else
gimp_context_tool_changed (gimp_context_get_user ());
}
}
gboolean
gimp_transform_tool_smoothing (void)
{
......
......@@ -79,10 +79,6 @@ struct _TransformOptions
{
ToolOptions tool_options;
GtkType type;
GtkType type_d;
GtkWidget *type_w[4]; /* 4 radio buttons */
gboolean smoothing;
gboolean smoothing_d;
GtkWidget *smoothing_w;
......@@ -167,8 +163,6 @@ static void gimp_transform_tool_control (GimpTool *tool,
static void gimp_transform_tool_draw (GimpDrawTool *draw_tool);
static void gimp_transform_tool_change_type (GtkType new_type);
static TransformOptions * transform_options_new (void);
static void transform_options_reset (ToolOptions *tool_options);
......@@ -1791,16 +1785,6 @@ gimp_transform_tool_show_path_update (GtkWidget *widget,
gimp_transform_tool_showpath_changed (0); /* resume */
}
/* FIXME Do we still want to do this this way? Perhaps we should make
separate icons for each tool. */
static void
gimp_transform_tool_type_callback (GtkWidget *widget,
gpointer data)
{
gimp_transform_tool_change_type ((GtkType) data);
}
static void
gimp_transform_tool_direction_callback (GtkWidget *widget,
gpointer data)
......@@ -1830,15 +1814,6 @@ transform_options_reset (ToolOptions *tool_options)
options = (TransformOptions *) tool_options;
/* FIXME this is gross. */
gtk_toggle_button_set_active (((options->type_d == GIMP_TYPE_ROTATE_TOOL) ?
GTK_TOGGLE_BUTTON (options->type_w[0]) :
((options->type_d == GIMP_TYPE_SCALE_TOOL) ?
GTK_TOGGLE_BUTTON (options->type_w[1]) :
((options->type_d == GIMP_TYPE_SHEAR_TOOL) ?
GTK_TOGGLE_BUTTON (options->type_w[2]) :
GTK_TOGGLE_BUTTON (options->type_w[3])))),
TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->smoothing_w),
options->smoothing_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->showpath_w),
......@@ -1861,8 +1836,8 @@ transform_options_new (void)
TransformOptions *options;
GtkWidget *table;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *hbox2;
GtkWidget *label;
GtkWidget *frame;
GtkWidget *fbox;
......@@ -1872,7 +1847,6 @@ transform_options_new (void)
tool_options_init ((ToolOptions *) options,
transform_options_reset);
options->type = options->type_d = GIMP_TYPE_SCALE_TOOL; /* FIXME: GIMP_TYPE_ROTATE_TOOL; */
options->smoothing = options->smoothing_d = TRUE;
options->showpath = options->showpath_d = TRUE;
options->clip = options->clip_d = FALSE;
......@@ -1880,42 +1854,11 @@ transform_options_new (void)
options->grid_size = options->grid_size_d = 32;
options->show_grid = options->show_grid_d = TRUE;
/* the main table */
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), table,
FALSE, FALSE, 0);
/* the left vbox */
vbox = gtk_vbox_new (FALSE, 2);
gtk_table_attach_defaults (GTK_TABLE (table), vbox, 0, 1, 0, 1);
/* the transform type radio buttons */
frame =
gimp_radio_group_new (TRUE, _("Transform"),
_("Rotation"), gimp_transform_tool_type_callback,
GIMP_TYPE_ROTATE_TOOL, NULL, &options->type_w[0], TRUE,
_("Scaling"), gimp_transform_tool_type_callback,
GIMP_TYPE_SCALE_TOOL, NULL, &options->type_w[1], FALSE,
_("Shearing"), gimp_transform_tool_type_callback,
GIMP_TYPE_SHEAR_TOOL, NULL, &options->type_w[2], FALSE,
_("Perspective"), gimp_transform_tool_type_callback,
GIMP_TYPE_PERSPECTIVE_TOOL, NULL, &options->type_w[3], FALSE,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
gtk_widget_show (vbox);
/* the right vbox */
vbox = gtk_vbox_new (FALSE, 2);
gtk_table_attach_defaults (GTK_TABLE (table), vbox, 1, 2, 0, 1);
/* the top hbox (containing two frames) */
hbox2 = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), hbox2,
FALSE, FALSE, 0);
/* the second radio frame and box, for transform direction */
frame = gimp_radio_group_new (TRUE, _("Tool Paradigm"),
......@@ -1930,12 +1873,12 @@ transform_options_new (void)
NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox2), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
/* the grid frame */
frame = gtk_frame_new (NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox2), frame, FALSE, FALSE, 0);
fbox = gtk_vbox_new (FALSE, 1);
gtk_container_set_border_width (GTK_CONTAINER (fbox), 2);
......@@ -1977,7 +1920,13 @@ transform_options_new (void)
gtk_widget_show (fbox);
gtk_widget_show (frame);
gtk_widget_show (vbox);
gtk_widget_show (hbox2);
/* the main table */
table = gtk_table_new (1, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), table,
FALSE, FALSE, 0);
/* the smoothing toggle button */
options->smoothing_w = gtk_check_button_new_with_label (_("Smoothing"));
......@@ -1985,7 +1934,7 @@ transform_options_new (void)
GTK_SIGNAL_FUNC (gimp_toggle_button_update),
&options->smoothing);
gtk_table_attach_defaults (GTK_TABLE (table),
options->smoothing_w, 0, 1, 1, 2);
options->smoothing_w, 0, 1, 0, 1);
gtk_widget_show (options->smoothing_w);
/* the showpath toggle button */
......@@ -1994,7 +1943,7 @@ transform_options_new (void)
GTK_SIGNAL_FUNC (gimp_transform_tool_show_path_update),
&options->showpath);
gtk_table_attach_defaults (GTK_TABLE (table),
options->showpath_w, 1, 2, 1, 2);
options->showpath_w, 1, 2, 0, 1);
gtk_widget_show (options->showpath_w);
gtk_widget_show (table);
......@@ -2011,25 +1960,6 @@ transform_options_new (void)
return options;
}
static void
gimp_transform_tool_change_type (GtkType new_type)
{
if (transform_options->type != new_type)
{
GimpToolInfo *tool_info;
/* change the type, free the old tool, create the new tool */
transform_options->type = new_type;
tool_info = tool_manager_get_info_by_type (new_type);
if (gimp_context_get_tool (gimp_context_get_user ()) != tool_info)
gimp_context_set_tool (gimp_context_get_user (), tool_info);
else
gimp_context_tool_changed (gimp_context_get_user ());
}
}
gboolean
gimp_transform_tool_smoothing (void)
{
......
......@@ -2157,7 +2157,7 @@ perspective_invoker (Argument *args)
/* Determine the perspective transform that maps from
* the unit cube to the trans_info coordinates
*/
perspective_find_transform (trans_info, m);
gimp_perspective_tool_find_transform (trans_info, m);
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
cx = (gdouble) offset_x;
......@@ -2176,7 +2176,7 @@ perspective_invoker (Argument *args)
gimp_matrix3_mult (m, matrix);
/* Perspective the buffer */
new_tiles = perspective_tool_perspective (gimage, drawable, NULL,
new_tiles = gimp_perspective_tool_perspective (gimage, drawable, NULL,
float_tiles, interpolation,
matrix);
......@@ -2428,7 +2428,7 @@ rotate_invoker (Argument *args)
gimp_matrix3_translate (matrix, +cx, +cy);
/* Rotate the buffer */
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle,
new_tiles = gimp_rotate_tool_rotate (gimage, drawable, NULL, angle,
float_tiles, interpolation, matrix);
/* Free the cut/copied buffer */
......@@ -2696,7 +2696,7 @@ shear_invoker (Argument *args)
gimp_matrix3_translate (matrix, +cx, +cy);
/* Shear the buffer */
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles,
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
interpolation, matrix);
/* Free the cut/copied buffer */
......
......@@ -626,7 +626,6 @@ static char *pencil_bits [] =
/* Image name: perspective */
/*
#define perspective_width 22
#define perspective_height 22
static char *perspective_bits [] =
......@@ -654,7 +653,6 @@ static char *perspective_bits [] =
"......................",
"......................"
};
*/
/* GIMP icon image format -- S. Kimball, P. Mattis */
/* Image name: rect */
......@@ -690,7 +688,6 @@ static char *rect_bits [] =
/* Image name: rotate */
/*
#define rotate_width 22
#define rotate_height 22
static char *rotate_bits [] =
......@@ -718,7 +715,6 @@ static char *rotate_bits [] =
"....aaa....eaee.......",
"............ee........"
};
*/
/* GIMP icon image format -- S. Kimball, P. Mattis */
/* Image name: scale */
......@@ -787,10 +783,9 @@ static char *sharpen_bits [] =
/* Image name: skew */
/*
#define skew_width 22
#define skew_height 22
static char *skew_bits [] =
#define shear_width 22
#define shear_height 22
static char *shear_bits [] =
{
"......................",
"......................",
......@@ -815,7 +810,7 @@ static char *skew_bits [] =
"......................",
"......................"
};
*/
/* GIMP icon image format -- S. Kimball, P. Mattis */
/* Image name: text */
......
......@@ -58,18 +58,18 @@ libapptools_la_SOURCES = \
gimppathtool.h \
gimppenciltool.c \
gimppenciltool.h \
## gimpperspectivetool.c \
## gimpperspectivetool.h \
gimpperspectivetool.c \
gimpperspectivetool.h \
gimprectselecttool.c \
gimprectselecttool.h \
## gimprotatetool.c \
## gimprotatetool.h \
gimprotatetool.c \
gimprotatetool.h \
gimpscaletool.c \
gimpscaletool.h \
gimpselectiontool.c \
gimpselectiontool.h \
## gimpsheartool.c \
## gimpsheartool.h \
gimpsheartool.c \
gimpsheartool.h \
gimpsmudgetool.c \
gimpsmudgetool.h \
gimptexttool.c \
......
......@@ -30,42 +30,212 @@
#include "gimage_mask.h"
#include "gimpimage.h"
#include "gimpprogress.h"
#include "info_dialog.h"
#include "gui/info-dialog.h"
#include "selection.h"
#include "tile_manager.h"
#include "undo.h"
#include "perspective_tool.h"
#include "tools.h"
#include "transform_core.h"
#include "transform_tool.h"
#include "gimpperspectivetool.h"
#include "tool_manager.h"
#include "tool_options.h"
#include "libgimp/gimpintl.h"
#include "pixmaps2.h"
/* forward function declarations */
static TileManager * perspective_tool_transform (Tool *tool,
GDisplay *gdisp,
TransformState state);
static void perspective_tool_recalc (Tool *tool,
GDisplay *gdisp);
static void perspective_tool_motion (Tool *tool,
GDisplay *gdisp);
static void perspective_info_update (Tool *tool);
static void gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass);
static void gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool);
static void gimp_perspective_tool_destroy (GtkObject *object);
static TileManager * gimp_perspective_tool_transform (GimpTransformTool *transform_tool,
GDisplay *gdisp,
TransformState state);
static void perspective_tool_recalc (GimpTool *tool,
GDisplay *gdisp);
static void perspective_tool_motion (GimpTool *tool,
GDisplay *gdisp);
static void perspective_info_update (GimpTool *tool);
/* storage for information dialog fields */
static gchar matrix_row_buf [3][MAX_INFO_BUF];
static GimpTransformToolClass *parent_class = NULL;
/* public functions */
void
gimp_perspective_tool_register (void)
{
tool_manager_register_tool (GIMP_TYPE_PERSPECTIVE_TOOL,
FALSE,
"gimp:perspective_tool",
_("Perspective Tool"),
_("Change perspective of the layer or selection"),
N_("/Tools/Transform Tools/Perspective"), "<shift>P",
NULL, "tools/perspective.html",
(const gchar **) perspective_bits);
}
GtkType
gimp_perspective_tool_get_type (void)
{
static GtkType tool_type = 0;
if (! tool_type)
{
GtkTypeInfo tool_info =
{
"GimpPerspectiveTool",
sizeof (GimpPerspectiveTool),
sizeof (GimpPerspectiveToolClass),
(GtkClassInitFunc) gimp_perspective_tool_class_init,
(GtkObjectInitFunc) gimp_perspective_tool_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
tool_type = gtk_type_unique (GIMP_TYPE_TRANSFORM_TOOL, &tool_info);
}
return tool_type;
}
TileManager *
gimp_perspective_tool_perspective (GimpImage *gimage,
GimpDrawable *drawable,
GDisplay *gdisp,
TileManager *float_tiles,
gboolean interpolation,
GimpMatrix3 matrix)
{
GimpProgress *progress;
TileManager *ret;
progress = progress_start (gdisp, _("Perspective..."), FALSE, NULL, NULL);
ret = gimp_transform_tool_do (gimage, drawable, float_tiles,
interpolation, matrix,
progress ? progress_update_and_flush :
(GimpProgressFunc) NULL,
progress);
if (progress)
progress_end (progress);
return ret;
}
void
gimp_perspective_tool_find_transform (gdouble *coords,
GimpMatrix3 matrix)
{
gdouble dx1, dx2, dx3, dy1, dy2, dy3;
gdouble det1, det2;
dx1 = coords[X1] - coords[X3];
dx2 = coords[X2] - coords[X3];
dx3 = coords[X0] - coords[X1] + coords[X3] - coords[X2];