Commit 15b9be6a authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added enum GimpTransformType which can be one of { LAYER, SELECTION, PATH

2003-05-31  Michael Natterer  <mitch@gimp.org>

	* app/tools/tools-enums.[ch]: added enum GimpTransformType which
	can be one of { LAYER, SELECTION, PATH }

	* app/tools/gimptransformoptions.[ch]: added a GimpTransformType
	property to GimpTransformOptions. Added a GUI for the new
	option.

	* app/tools/gimpflipoptions.[ch]: derive it from
	GimpTransformOptions and add the GUI here, too.

	* app/tools/gimpfliptool.c
	* app/tools/gimptransformtool.[ch]: added support for transforming
	the selection. Added framework for transforming paths (still
	unimplemented).

	* app/tools/gimpselectionoptions.c: small cleanup.

	* libgimpwidgets/gimpstock.[ch]
	* themes/Default/images/Makefile.am
	* themes/Default/images/stock-path-16.png
	* themes/Default/images/stock-path-22.png
	* themes/Default/images/stock-selection-16.png: new icons for the
	new transform options buttons. Simply copied existing ones...
parent 31e12a21
2003-05-31 Michael Natterer <mitch@gimp.org>
* app/tools/tools-enums.[ch]: added enum GimpTransformType which
can be one of { LAYER, SELECTION, PATH }
* app/tools/gimptransformoptions.[ch]: added a GimpTransformType
property to GimpTransformOptions. Added a GUI for the new
option.
* app/tools/gimpflipoptions.[ch]: derive it from
GimpTransformOptions and add the GUI here, too.
* app/tools/gimpfliptool.c
* app/tools/gimptransformtool.[ch]: added support for transforming
the selection. Added framework for transforming paths (still
unimplemented).
* app/tools/gimpselectionoptions.c: small cleanup.
* libgimpwidgets/gimpstock.[ch]
* themes/Default/images/Makefile.am
* themes/Default/images/stock-path-16.png
* themes/Default/images/stock-path-22.png
* themes/Default/images/stock-selection-16.png: new icons for the
new transform options buttons. Simply copied existing ones...
2003-05-30 Tor Lillqvist <tml@iki.fi>
* configure.in: As gimp uses fontconfig directly, check for it.
......@@ -56,7 +56,7 @@ static void gimp_flip_options_get_property (GObject *object,
GParamSpec *pspec);
static GimpToolOptionsClass *parent_class = NULL;
static GimpTransformOptionsClass *parent_class = NULL;
GType
......@@ -79,7 +79,7 @@ gimp_flip_options_get_type (void)
(GInstanceInitFunc) gimp_flip_options_init,
};
type = g_type_register_static (GIMP_TYPE_TOOL_OPTIONS,
type = g_type_register_static (GIMP_TYPE_TRANSFORM_OPTIONS,
"GimpFlipOptions",
&info, 0);
}
......@@ -158,6 +158,8 @@ gimp_flip_options_gui (GimpToolOptions *tool_options)
{
GObject *config;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *frame;
gchar *str;
......@@ -165,8 +167,17 @@ gimp_flip_options_gui (GimpToolOptions *tool_options)
vbox = gimp_tool_options_gui (tool_options);
hbox = gimp_prop_enum_stock_box_new (config, "type", "gimp", 0, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
label = gtk_label_new (_("Affect:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (hbox), label, 0);
gtk_widget_show (label);
/* tool toggle */
str = g_strdup_printf (_("Tool Toggle %s"), gimp_get_mod_name_control ());
str = g_strdup_printf (_("Flip Type %s"), gimp_get_mod_name_control ());
frame = gimp_prop_enum_radio_frame_new (config, "flip-type",
str,
......
......@@ -20,7 +20,7 @@
#define __GIMP_FLIP_OPTIONS_H__
#include "tool_options.h"
#include "gimptransformoptions.h"
#define GIMP_TYPE_FLIP_OPTIONS (gimp_flip_options_get_type ())
......@@ -36,9 +36,9 @@ typedef struct _GimpToolOptionsClass GimpFlipOptionsClass;
struct _GimpFlipOptions
{
GimpToolOptions parent_instance;
GimpTransformOptions parent_instance;
GimpOrientationType flip_type;
GimpOrientationType flip_type;
};
......
......@@ -63,6 +63,7 @@ static void gimp_flip_tool_cursor_update (GimpTool *tool,
GimpDisplay *gdisp);
static TileManager * gimp_flip_tool_transform (GimpTransformTool *tool,
GimpItem *item,
GimpDisplay *gdisp);
......@@ -231,32 +232,27 @@ gimp_flip_tool_cursor_update (GimpTool *tool,
static TileManager *
gimp_flip_tool_transform (GimpTransformTool *trans_tool,
GimpItem *active_item,
GimpDisplay *gdisp)
{
GimpFlipOptions *options;
GimpDrawable *active_drawable;
GimpItem *active_item;
gint off_x, off_y;
gint width, height;
gdouble axis = 0.0;
GimpTransformOptions *tr_options;
GimpFlipOptions *options;
gdouble axis = 0.0;
TileManager *ret = NULL;
options = GIMP_FLIP_OPTIONS (GIMP_TOOL (trans_tool)->tool_info->tool_options);
active_drawable = gimp_image_active_drawable (gdisp->gimage);
active_item = GIMP_ITEM (active_drawable);
tile_manager_get_offsets (trans_tool->original, &off_x, &off_y);
width = tile_manager_width (trans_tool->original);
height = tile_manager_height (trans_tool->original);
tr_options = GIMP_TRANSFORM_OPTIONS (options);
switch (options->flip_type)
{
case GIMP_ORIENTATION_HORIZONTAL:
axis = ((gdouble) off_x + (gdouble) width / 2.0);
axis = ((gdouble) trans_tool->x1 +
(gdouble) (trans_tool->x2 - trans_tool->x1) / 2.0);
break;
case GIMP_ORIENTATION_VERTICAL:
axis = ((gdouble) off_y + (gdouble) height / 2.0);
axis = ((gdouble) trans_tool->y1 +
(gdouble) (trans_tool->y2 - trans_tool->y1) / 2.0);
break;
default:
......@@ -266,7 +262,20 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
if (gimp_item_get_linked (active_item))
gimp_item_linked_flip (active_item, options->flip_type, axis, FALSE);
return gimp_drawable_transform_tiles_flip (active_drawable,
trans_tool->original,
options->flip_type, axis, FALSE);
switch (tr_options->type)
{
case GIMP_TRANSFORM_TYPE_LAYER:
case GIMP_TRANSFORM_TYPE_SELECTION:
ret = gimp_drawable_transform_tiles_flip (GIMP_DRAWABLE (active_item),
trans_tool->original,
options->flip_type, axis,
FALSE);
break;
case GIMP_TRANSFORM_TYPE_PATH:
/* TODO */
break;
}
return ret;
}
......@@ -396,9 +396,8 @@ gimp_selection_options_gui (GimpToolOptions *tool_options)
label = gtk_label_new (_("Mode:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
gtk_box_reorder_child (GTK_BOX (hbox), label, 0);
gtk_widget_show (label);
}
/* the antialias toggle button */
......
......@@ -44,12 +44,12 @@
enum
{
PROP_0,
PROP_TYPE,
PROP_DIRECTION,
PROP_INTERPOLATION,
PROP_CLIP,
PROP_GRID_TYPE,
PROP_GRID_SIZE,
PROP_SHOW_PATH,
PROP_CONSTRAIN_1,
PROP_CONSTRAIN_2
};
......@@ -121,6 +121,11 @@ gimp_transform_options_class_init (GimpTransformOptionsClass *klass)
options_class->reset = gimp_transform_options_reset;
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TYPE,
"type", NULL,
GIMP_TYPE_TRANSFORM_TYPE,
GIMP_TRANSFORM_TYPE_LAYER,
0);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_DIRECTION,
"direction", NULL,
GIMP_TYPE_TRANSFORM_DIRECTION,
......@@ -144,10 +149,6 @@ gimp_transform_options_class_init (GimpTransformOptionsClass *klass)
"grid-size", NULL,
1, 128, 15,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_PATH,
"show-path", NULL,
FALSE,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_1,
"constrain-1", NULL,
FALSE,
......@@ -175,6 +176,9 @@ gimp_transform_options_set_property (GObject *object,
switch (property_id)
{
case PROP_TYPE:
options->type = g_value_get_enum (value);
break;
case PROP_DIRECTION:
options->direction = g_value_get_enum (value);
break;
......@@ -190,9 +194,6 @@ gimp_transform_options_set_property (GObject *object,
case PROP_GRID_SIZE:
options->grid_size = g_value_get_int (value);
break;
case PROP_SHOW_PATH:
options->show_path = g_value_get_boolean (value);
break;
case PROP_CONSTRAIN_1:
options->constrain_1 = g_value_get_boolean (value);
break;
......@@ -217,6 +218,9 @@ gimp_transform_options_get_property (GObject *object,
switch (property_id)
{
case PROP_TYPE:
g_value_set_enum (value, options->type);
break;
case PROP_DIRECTION:
g_value_set_enum (value, options->direction);
break;
......@@ -232,9 +236,6 @@ gimp_transform_options_get_property (GObject *object,
case PROP_GRID_SIZE:
g_value_set_int (value, options->grid_size);
break;
case PROP_SHOW_PATH:
g_value_set_boolean (value, options->show_path);
break;
case PROP_CONSTRAIN_1:
g_value_set_boolean (value, options->constrain_1);
break;
......@@ -270,7 +271,7 @@ gimp_transform_options_reset (GimpToolOptions *tool_options)
GtkWidget *
gimp_transform_options_gui (GimpToolOptions *tool_options)
{
GObject *config;
GObject *config;
GimpTransformOptions *options;
GtkWidget *vbox;
GtkWidget *hbox;
......@@ -280,11 +281,20 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
GtkWidget *optionmenu;
GtkWidget *button;
config = G_OBJECT (tool_options);
config = G_OBJECT (tool_options);
options = GIMP_TRANSFORM_OPTIONS (tool_options);
vbox = gimp_tool_options_gui (tool_options);
hbox = gimp_prop_enum_stock_box_new (config, "type", "gimp", 0, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
label = gtk_label_new (_("Affect:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (hbox), label, 0);
gtk_widget_show (label);
frame = gimp_prop_enum_radio_frame_new (config, "direction",
_("Transform Direction"), 0, 0);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
......@@ -335,11 +345,6 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
1.0, 8.0, 0,
FALSE, 0.0, 0.0);
/* the show_path toggle button */
button = gimp_prop_check_button_new (config, "show-path", _("Show Path"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
if (tool_options->tool_info->tool_type == GIMP_TYPE_ROTATE_TOOL ||
tool_options->tool_info->tool_type == GIMP_TYPE_SCALE_TOOL)
{
......
......@@ -38,12 +38,12 @@ struct _GimpTransformOptions
{
GimpToolOptions parent_instance;
GimpTransformType type;
GimpTransformDirection direction;
GimpInterpolationType interpolation;
gboolean clip;
GimpTransformGridType grid_type;
gint grid_size;
gboolean show_path;
gint grid_size;
gboolean constrain_1;
gboolean constrain_2;
};
......
......@@ -44,14 +44,12 @@
#include "core/gimpimage-undo-push.h"
#include "core/gimpitem-linked.h"
#include "core/gimplayer.h"
#include "core/gimpmarshal.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpviewabledialog.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpprogress.h"
#include "gui/info-dialog.h"
......@@ -110,6 +108,7 @@ static void gimp_transform_tool_draw (GimpDrawTool *draw_tool
static TileManager *
gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpItem *item,
GimpDisplay *gdisp);
static void gimp_transform_tool_reset (GimpTransformTool *tr_tool);
......@@ -131,10 +130,10 @@ static void transform_cancel_callback (GtkWidget *widget,
static void transform_ok_callback (GtkWidget *widget,
GimpTransformTool *tr_tool);
static void gimp_transform_tool_notify_grid (GimpTransformOptions *options,
static void gimp_transform_tool_notify_type (GimpTransformOptions *options,
GParamSpec *pspec,
GimpTransformTool *tr_tool);
static void gimp_transform_tool_notify_path (GimpTransformOptions *options,
static void gimp_transform_tool_notify_grid (GimpTransformOptions *options,
GParamSpec *pspec,
GimpTransformTool *tr_tool);
......@@ -232,7 +231,7 @@ gimp_transform_tool_init (GimpTransformTool *tr_tool)
tr_tool->tgrid_coords = NULL;
tr_tool->notify_connected = FALSE;
tr_tool->show_path = FALSE;
tr_tool->type = GIMP_TRANSFORM_TYPE_LAYER;
tr_tool->shell_desc = NULL;
tr_tool->progress_text = _("Transforming...");
......@@ -322,9 +321,13 @@ gimp_transform_tool_button_press (GimpTool *tool,
if (tr_tool->use_grid && ! tr_tool->notify_connected)
{
tr_tool->show_path =
GIMP_TRANSFORM_OPTIONS (tool->tool_info->tool_options)->show_path;
tr_tool->type =
GIMP_TRANSFORM_OPTIONS (tool->tool_info->tool_options)->type;
g_signal_connect_object (tool->tool_info->tool_options,
"notify::type",
G_CALLBACK (gimp_transform_tool_notify_type),
tr_tool, 0);
g_signal_connect_object (tool->tool_info->tool_options,
"notify::grid-type",
G_CALLBACK (gimp_transform_tool_notify_grid),
......@@ -333,10 +336,6 @@ gimp_transform_tool_button_press (GimpTool *tool,
"notify::grid-size",
G_CALLBACK (gimp_transform_tool_notify_grid),
tr_tool, 0);
g_signal_connect_object (tool->tool_info->tool_options,
"notify::show-path",
G_CALLBACK (gimp_transform_tool_notify_path),
tr_tool, 0);
tr_tool->notify_connected = TRUE;
}
......@@ -748,7 +747,7 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
FALSE);
}
if (tr_tool->show_path)
if (tr_tool->type == GIMP_TRANSFORM_TYPE_PATH)
{
GimpMatrix3 tmp_matrix;
......@@ -770,22 +769,17 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
static TileManager *
gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpItem *active_item,
GimpDisplay *gdisp)
{
GimpTool *tool;
GimpTransformOptions *options;
GimpDrawable *active_drawable;
GimpItem *active_item;
GimpProgress *progress;
gboolean clip_result;
TileManager *ret;
TileManager *ret = NULL;
tool = GIMP_TOOL (tr_tool);
options = GIMP_TRANSFORM_OPTIONS (tool->tool_info->tool_options);
active_drawable = gimp_image_active_drawable (gdisp->gimage);
active_item = GIMP_ITEM (active_drawable);
if (tr_tool->info_dialog)
gtk_widget_set_sensitive (GTK_WIDGET (tr_tool->info_dialog->shell), FALSE);
......@@ -800,23 +794,38 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
gimp_progress_update_and_flush : NULL,
progress);
clip_result = options->clip;
/* always clip unfloated channels so they keep their size */
if (GIMP_IS_CHANNEL (active_drawable) &&
tile_manager_bpp (tr_tool->original) == 1)
clip_result = TRUE;
switch (options->type)
{
case GIMP_TRANSFORM_TYPE_LAYER:
case GIMP_TRANSFORM_TYPE_SELECTION:
{
gboolean clip_result = options->clip;
/* always clip the selction and unfloated channels
* so they keep their size
*/
if (GIMP_IS_CHANNEL (active_item) &&
tile_manager_bpp (tr_tool->original) == 1)
clip_result = TRUE;
ret =
gimp_drawable_transform_tiles_affine (GIMP_DRAWABLE (active_item),
tr_tool->original,
tr_tool->transform,
options->direction,
options->interpolation,
clip_result,
progress ?
gimp_progress_update_and_flush :
NULL,
progress);
}
break;
ret = gimp_drawable_transform_tiles_affine (active_drawable,
tr_tool->original,
tr_tool->transform,
options->direction,
options->interpolation,
clip_result,
progress ?
gimp_progress_update_and_flush :
NULL,
progress);
case GIMP_TRANSFORM_TYPE_PATH:
/* TODO */
break;
}
if (progress)
gimp_progress_end (progress);
......@@ -828,13 +837,16 @@ static void
gimp_transform_tool_doit (GimpTransformTool *tr_tool,
GimpDisplay *gdisp)
{
GimpTool *tool;
TileManager *new_tiles;
gboolean new_layer;
GimpTool *tool;
GimpTransformOptions *options;
GimpItem *active_item;
TileManager *new_tiles;
gboolean new_layer;
gimp_set_busy (gdisp->gimage->gimp);
tool = GIMP_TOOL (tr_tool);
tool = GIMP_TOOL (tr_tool);
options = GIMP_TRANSFORM_OPTIONS (tool->tool_info->tool_options);
/* undraw the tool before we muck around with the transform matrix */
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tr_tool));
......@@ -859,40 +871,86 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool,
*/
tool->drawable = gimp_image_active_drawable (gdisp->gimage);
tr_tool->original = gimp_drawable_transform_cut (tool->drawable,
&new_layer);
switch (options->type)
{
case GIMP_TRANSFORM_TYPE_LAYER:
active_item = (GimpItem *) gimp_image_active_drawable (gdisp->gimage);
tr_tool->original = gimp_drawable_transform_cut (tool->drawable,
&new_layer);
break;
case GIMP_TRANSFORM_TYPE_SELECTION:
active_item = (GimpItem *) gimp_image_get_mask (gdisp->gimage);
tr_tool->original = gimp_drawable_data (GIMP_DRAWABLE (active_item));
tile_manager_set_offsets (tr_tool->original, 0, 0);
break;
case GIMP_TRANSFORM_TYPE_PATH:
active_item = (GimpItem *) gimp_image_get_active_vectors (gdisp->gimage);
tr_tool->original = NULL;
break;
}
/* Send the request for the transformation to the tool...
*/
new_tiles = GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->transform (tr_tool,
active_item,
gdisp);
gimp_transform_tool_prepare (tr_tool, gdisp);
gimp_transform_tool_recalc (tr_tool, gdisp);
if (new_tiles)
switch (options->type)
{
/* paste the new transformed image to the gimage...also implement
* undo...
*/
/* FIXME: we should check if the drawable is still valid */
gimp_drawable_transform_paste (tool->drawable,
new_tiles,
new_layer);
tile_manager_unref (new_tiles);
/* Make a note of the new current drawable (since we may have
* a floating selection, etc now.
*/
tool->drawable = gimp_image_active_drawable (gdisp->gimage);
case GIMP_TRANSFORM_TYPE_LAYER:
if (new_tiles)
{
/* paste the new transformed image to the gimage...also implement
* undo...
*/
/* FIXME: we should check if the drawable is still valid */
gimp_drawable_transform_paste (tool->drawable,
new_tiles,
new_layer);
tile_manager_unref (new_tiles);
}
break;
case GIMP_TRANSFORM_TYPE_SELECTION:
if (new_tiles)
{
gimp_image_mask_push_undo (gdisp->gimage, NULL);
gimp_transform_tool_push_undo (gdisp->gimage, NULL,
tool->ID,
G_TYPE_FROM_INSTANCE (tool),
tr_tool->old_trans_info,
NULL);
GIMP_DRAWABLE (active_item)->tiles = new_tiles;
tile_manager_unref (tr_tool->original);
tr_tool->original = NULL;
GIMP_CHANNEL (active_item)->bounds_known = FALSE;
gimp_image_mask_changed (gdisp->gimage);
}
break;
case GIMP_TRANSFORM_TYPE_PATH:
/* TODO */
break;
}
/* Make a note of the new current drawable (since we may have
* a floating selection, etc now.
*/
tool->drawable = gimp_image_active_drawable (gdisp->gimage);
gimp_transform_tool_push_undo (gdisp->gimage, NULL,
tool->ID,
G_TYPE_FROM_INSTANCE (tool),
tr_tool->old_trans_info,
NULL);
/* push the undo group end */
gimp_image_undo_group_end (gdisp->gimage);
......@@ -980,43 +1038,57 @@ static void
gimp_transform_tool_bounds (GimpTransformTool *tr_tool,
GimpDisplay *gdisp)
{
TileManager *tiles;
GimpDrawable *drawable;
GimpTransformOptions *options;
tiles = tr_tool->original;
drawable = gimp_image_active_drawable (gdisp->gimage);
options =
GIMP_TRANSFORM_OPTIONS (GIMP_TOOL (tr_tool)->tool_info->tool_options);
/* find the boundaries */
if (tiles)
if (tr_tool->original)
{
tile_manager_get_offsets (tiles, &tr_tool->x1, &tr_tool->y1);
tile_manager_get_offsets (tr_tool->original, &tr_tool->x1, &tr_tool->y1);
tr_tool->x2 = tr_tool->x1 + tile_manager_width (tiles);
tr_tool->y2 = tr_tool->y1 + tile_manager_height (tiles);
tr_tool->x2 = tr_tool->x1 + tile_manager_width (tr_tool->original);