Commit 1b2b43ab authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

I'm maintaining the helpbrowser (Sven, I dared to add your name, too :-)

2000-01-05  Michael Natterer  <mitch@gimp.org>

	* PLUGIN_MAINTAINERS: I'm maintaining the helpbrowser (Sven, I
	dared to add your name, too :-)

	* app/context_manager.c
	* app/flip_tool.[ch]
	* app/perspective_tool.[ch]
	* app/rotate_tool.[ch]
	* app/scale_tool.[ch]
	* app/shear_tool.[ch]
	* app/transform_core.[ch]
	* app/transform_tool.[ch]
	* app/tools_cmds.c
	* tools/pdbgen/pdb/tools.pdb

	- Show the correct help pages in the transform tools' dialogs.
	- The transform tool button of the toolbox is now always pressed
	  if a transform tool is active (not only for "rotate").
	- Replaced the transform action (CREATING, HANDLE_1, ...) and the
	  transform state (INIT, MOTION, ...) #define's with typed enums.
	- Changed the return type of the *_recalc functions to "void"
	  instead of "void *" and the return type of the *_transform
	  functions to "TileManager *" instead of "void *".
	  (I probably removed an artefact here because all *_recalc
	   functions returned "(void *) 1").
	- Use gboolean instead of int where appropriate.
	- Code cleanup, indentation.
parent 5e4e7d88
2000-01-05 Michael Natterer <mitch@gimp.org>
* PLUGIN_MAINTAINERS: I'm maintaining the helpbrowser (Sven, I
dared to add your name, too :-)
* app/context_manager.c
* app/flip_tool.[ch]
* app/perspective_tool.[ch]
* app/rotate_tool.[ch]
* app/scale_tool.[ch]
* app/shear_tool.[ch]
* app/transform_core.[ch]
* app/transform_tool.[ch]
* app/tools_cmds.c
* tools/pdbgen/pdb/tools.pdb
- Show the correct help pages in the transform tools' dialogs.
- The transform tool button of the toolbox is now always pressed
if a transform tool is active (not only for "rotate").
- Replaced the transform action (CREATING, HANDLE_1, ...) and the
transform state (INIT, MOTION, ...) #define's with typed enums.
- Changed the return type of the *_recalc functions to "void"
instead of "void *" and the return type of the *_transform
functions to "TileManager *" instead of "void *".
(I probably removed an artefact here because all *_recalc
functions returned "(void *) 1").
- Use gboolean instead of int where appropriate.
- Code cleanup, indentation.
Wed Jan 5 11:35:10 CET 2000 Sven Neumann <sven@gimp.org>
* app/gimpimage.c: In gimp_image_merge_visible_layers and
......
......@@ -459,8 +459,8 @@ SIZE : 7.1 kB in 1 file (only C files counted)
COMMENT :
-----------
NAME : helpbrowser
AUTHOR : Sven Neumann <sven@gimp.org>, Michael Natterer <mitschel@cs.tu-berlin.de>
MAINTAINER :
AUTHOR : Sven Neumann <sven@gimp.org>, Michael Natterer <mitch@gimp.org>
MAINTAINER : Sven Neumann <sven@gimp.org>, Michael Natterer <mitch@gimp.org>
SIZE : 32.7 kB in 2 files (only C files counted)
COMMENT :
-----------
......
......@@ -59,6 +59,13 @@ context_manager_tool_changed (GimpContext *context,
}
}
tools_select (tool_type);
if (tool_type == SCALE ||
tool_type == SHEAR ||
tool_type == PERSPECTIVE)
tool_type = ROTATE;
if (! GTK_TOGGLE_BUTTON (tool_info[tool_type].tool_widget)->active)
{
gtk_signal_handler_block_by_data
......@@ -69,8 +76,6 @@ context_manager_tool_changed (GimpContext *context,
gtk_signal_handler_unblock_by_data
(GTK_OBJECT (tool_info[tool_type].tool_widget), (gpointer) tool_type);
}
tools_select (tool_type);
}
static void
......
......@@ -25,7 +25,6 @@
#include "gimage_mask.h"
#include "temp_buf.h"
#include "tool_options_ui.h"
#include "transform_core.h"
#include "paths_dialogP.h"
#include "undo.h"
......@@ -40,13 +39,14 @@
/* the flip structures */
typedef struct _FlipOptions FlipOptions;
struct _FlipOptions
{
ToolOptions tool_options;
ToolOptions tool_options;
ToolType type;
ToolType type_d;
GtkWidget *type_w[2];
InternalOrientationType type;
InternalOrientationType type_d;
GtkWidget *type_w[2];
};
static FlipOptions *flip_options = NULL;
......@@ -76,7 +76,7 @@ flip_options_new (void)
gint type_value[2] = { ORIENTATION_HORIZONTAL, ORIENTATION_VERTICAL };
/* the new flip tool options structure */
options = (FlipOptions *) g_malloc (sizeof (FlipOptions));
options = g_new (FlipOptions, 1);
tool_options_init ((ToolOptions *) options,
_("Flip Tool Options"),
flip_options_reset);
......@@ -119,35 +119,35 @@ flip_modifier_key_func (Tool *tool,
}
}
void *
flip_tool_transform (Tool *tool,
gpointer gdisp_ptr,
int state)
TileManager *
flip_tool_transform (Tool *tool,
gpointer gdisp_ptr,
TransformState state)
{
TransformCore * transform_core;
GDisplay *gdisp;
TransformCore *transform_core;
GDisplay *gdisp;
transform_core = (TransformCore *) tool->private;
gdisp = (GDisplay *) gdisp_ptr;
switch (state)
{
case INIT :
case INIT:
transform_info = NULL;
break;
case MOTION :
case MOTION:
break;
case RECALC :
case RECALC:
break;
case FINISH :
case FINISH:
/* transform_core->trans_info[FLIP] *= -1.0;*/
return flip_tool_flip (gdisp->gimage,
gimage_active_drawable (gdisp->gimage),
transform_core->original,
(int)transform_core->trans_info[FLIP_INFO],
(int) transform_core->trans_info[FLIP_INFO],
flip_options->type);
break;
}
......@@ -160,9 +160,9 @@ flip_cursor_update (Tool *tool,
GdkEventMotion *mevent,
gpointer gdisp_ptr)
{
GDisplay *gdisp;
Layer *layer;
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
GDisplay *gdisp;
Layer *layer;
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
gdisp = (GDisplay *) gdisp_ptr;
......@@ -196,7 +196,7 @@ flip_cursor_update (Tool *tool,
Tool *
tools_new_flip (void)
{
Tool * tool;
Tool * tool;
TransformCore * private;
/* The tool options */
......@@ -206,13 +206,13 @@ tools_new_flip (void)
tools_register (FLIP, (ToolOptions *) flip_options);
}
tool = transform_core_new (FLIP, NON_INTERACTIVE);
tool = transform_core_new (FLIP, FALSE);
private = tool->private;
private->trans_func = flip_tool_transform;
private->trans_func = flip_tool_transform;
private->trans_info[FLIP_INFO] = -1.0;
tool->modifier_key_func = flip_modifier_key_func;
tool->modifier_key_func = flip_modifier_key_func;
tool->cursor_update_func = flip_cursor_update;
return tool;
......@@ -232,8 +232,8 @@ flip_tool_flip (GimpImage *gimage,
InternalOrientationType type)
{
TileManager *new;
PixelRegion srcPR, destPR;
int i;
PixelRegion srcPR, destPR;
gint i;
if (!orig)
return NULL;
......@@ -258,14 +258,16 @@ flip_tool_flip (GimpImage *gimage,
for (i = 0; i < orig->width; i++)
{
pixel_region_init (&srcPR, orig, i, 0, 1, orig->height, FALSE);
pixel_region_init (&destPR, new, (orig->width - i - 1), 0, 1, orig->height, TRUE);
pixel_region_init (&destPR, new,
(orig->width - i - 1), 0, 1, orig->height, TRUE);
copy_region (&srcPR, &destPR);
}
else
for (i = 0; i < orig->height; i++)
{
pixel_region_init (&srcPR, orig, 0, i, orig->width, 1, FALSE);
pixel_region_init (&destPR, new, 0, (orig->height - i - 1), orig->width, 1, TRUE);
pixel_region_init (&destPR, new,
0, (orig->height - i - 1), orig->width, 1, TRUE);
copy_region (&srcPR, &destPR);
}
......@@ -273,10 +275,10 @@ flip_tool_flip (GimpImage *gimage,
/* Note that the undo structures etc are setup before we enter this
* function.
*/
if(type == ORIENTATION_HORIZONTAL)
paths_transform_flip_horz(gimage);
if (type == ORIENTATION_HORIZONTAL)
paths_transform_flip_horz (gimage);
else
paths_transform_flip_vert(gimage);
paths_transform_flip_vert (gimage);
}
return new;
......
......@@ -19,17 +19,21 @@
#define __FLIP_TOOL_H__
#include "tools.h"
#include "transform_core.h"
/* Flip tool functions */
#include "gimpimage.h"
TileManager * flip_tool_transform (Tool *tool,
gpointer gdisp_ptr,
TransformState state);
void * flip_tool_transform (Tool *, gpointer, int);
TileManager * flip_tool_flip (GimpImage *gimage,
GimpDrawable *drawable,
TileManager *orig,
gint flip,
InternalOrientationType type);
TileManager * flip_tool_flip (GimpImage *, GimpDrawable *,
TileManager *, int, InternalOrientationType);
Tool * tools_new_flip (void);
void tools_free_flip_tool (Tool *);
Tool * tools_new_flip (void);
void tools_free_flip_tool (Tool *tool);
#endif /* __FLIP_TOOL_H__ */
......@@ -22,8 +22,6 @@
#include "info_dialog.h"
#include "perspective_tool.h"
#include "selection.h"
#include "tools.h"
#include "transform_core.h"
#include "transform_tool.h"
#include "undo.h"
......@@ -33,32 +31,33 @@
/* storage for information dialog fields */
static char matrix_row_buf [3][MAX_INFO_BUF];
static gchar matrix_row_buf [3][MAX_INFO_BUF];
/* forward function declarations */
static void * perspective_tool_recalc (Tool *, void *);
static void perspective_tool_motion (Tool *, void *);
static void perspective_info_update (Tool *);
void *
perspective_tool_transform (Tool *tool,
gpointer gdisp_ptr,
int state)
static void perspective_tool_recalc (Tool *, void *);
static void perspective_tool_motion (Tool *, void *);
static void perspective_info_update (Tool *);
TileManager *
perspective_tool_transform (Tool *tool,
gpointer gdisp_ptr,
TransformState state)
{
GDisplay * gdisp;
TransformCore * transform_core;
GDisplay *gdisp;
TransformCore *transform_core;
gdisp = (GDisplay *) gdisp_ptr;
transform_core = (TransformCore *) tool->private;
switch (state)
{
case INIT :
case INIT:
if (!transform_info)
{
transform_info =
info_dialog_new (_("Perspective Transform Information"),
tools_help_func, NULL);
gimp_standard_help_func,
"tools/transform_perspective.html");
info_dialog_add_label (transform_info, _("Matrix:"),
matrix_row_buf[0]);
info_dialog_add_label (transform_info, "", matrix_row_buf[1]);
......@@ -78,17 +77,16 @@ perspective_tool_transform (Tool *tool,
return NULL;
break;
case MOTION :
case MOTION:
perspective_tool_motion (tool, gdisp_ptr);
return (perspective_tool_recalc (tool, gdisp_ptr));
perspective_tool_recalc (tool, gdisp_ptr);
break;
case RECALC :
return (perspective_tool_recalc (tool, gdisp_ptr));
case RECALC:
perspective_tool_recalc (tool, gdisp_ptr);
break;
case FINISH :
case FINISH:
/* Let the transform core handle the inverse mapping */
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
return
......@@ -104,14 +102,13 @@ perspective_tool_transform (Tool *tool,
return NULL;
}
Tool *
tools_new_perspective_tool ()
tools_new_perspective_tool (void)
{
Tool * tool;
TransformCore * private;
Tool *tool;
TransformCore *private;
tool = transform_core_new (PERSPECTIVE, INTERACTIVE);
tool = transform_core_new (PERSPECTIVE, TRUE);
private = tool->private;
......@@ -132,26 +129,24 @@ tools_new_perspective_tool ()
return tool;
}
void
tools_free_perspective_tool (Tool *tool)
{
transform_core_free (tool);
}
static void
perspective_info_update (Tool *tool)
{
TransformCore * transform_core;
int i;
TransformCore *transform_core;
gint i;
transform_core = (TransformCore *) tool->private;
for (i = 0; i < 3; i++)
{
char *p = matrix_row_buf[i];
int j;
gchar *p = matrix_row_buf[i];
gint j;
for (j = 0; j < 3; j++)
{
......@@ -162,18 +157,17 @@ perspective_info_update (Tool *tool)
info_dialog_update (transform_info);
info_dialog_popup (transform_info);
return;
}
static void
perspective_tool_motion (Tool *tool,
void *gdisp_ptr)
{
GDisplay * gdisp;
TransformCore * transform_core;
int diff_x, diff_y;
GDisplay *gdisp;
TransformCore *transform_core;
gint diff_x, diff_y;
gdisp = (GDisplay *) gdisp_ptr;
transform_core = (TransformCore *) tool->private;
......@@ -183,36 +177,36 @@ perspective_tool_motion (Tool *tool,
switch (transform_core->function)
{
case HANDLE_1 :
case HANDLE_1:
transform_core->trans_info [X0] += diff_x;
transform_core->trans_info [Y0] += diff_y;
break;
case HANDLE_2 :
case HANDLE_2:
transform_core->trans_info [X1] += diff_x;
transform_core->trans_info [Y1] += diff_y;
break;
case HANDLE_3 :
case HANDLE_3:
transform_core->trans_info [X2] += diff_x;
transform_core->trans_info [Y2] += diff_y;
break;
case HANDLE_4 :
case HANDLE_4:
transform_core->trans_info [X3] += diff_x;
transform_core->trans_info [Y3] += diff_y;
break;
default :
return;
default:
break;
}
}
static void *
static void
perspective_tool_recalc (Tool *tool,
void *gdisp_ptr)
{
TransformCore * transform_core;
GDisplay * gdisp;
GimpMatrix m;
double cx, cy;
double scalex, scaley;
TransformCore *transform_core;
GDisplay *gdisp;
GimpMatrix m;
gdouble cx, cy;
gdouble scalex, scaley;
gdisp = (GDisplay *) tool->gdisp_ptr;
transform_core = (TransformCore *) tool->private;
......@@ -226,6 +220,7 @@ perspective_tool_recalc (Tool *tool,
cy = transform_core->y1;
scalex = 1.0;
scaley = 1.0;
if (transform_core->x2 - transform_core->x1)
scalex = 1.0 / (transform_core->x2 - transform_core->x1);
if (transform_core->y2 - transform_core->y1)
......@@ -238,21 +233,18 @@ perspective_tool_recalc (Tool *tool,
gimp_matrix_mult (m, transform_core->transform);
/* transform the bounding box */
transform_bounding_box (tool);
transform_core_transform_bounding_box (tool);
/* update the information dialog */
perspective_info_update (tool);
return (void *) 1;
}
void
perspective_find_transform (double *coords,
GimpMatrix m)
perspective_find_transform (gdouble *coords,
GimpMatrix matrix)
{
double dx1, dx2, dx3, dy1, dy2, dy3;
double det1, det2;
gdouble dx1, dx2, dx3, dy1, dy2, dy3;
gdouble det1, det2;
dx1 = coords[X1] - coords[X3];
dx2 = coords[X2] - coords[X3];
......@@ -265,53 +257,54 @@ perspective_find_transform (double *coords,
/* Is the mapping affine? */
if ((dx3 == 0.0) && (dy3 == 0.0))
{
m[0][0] = coords[X1] - coords[X0];
m[0][1] = coords[X3] - coords[X1];
m[0][2] = coords[X0];
m[1][0] = coords[Y1] - coords[Y0];
m[1][1] = coords[Y3] - coords[Y1];
m[1][2] = coords[Y0];
m[2][0] = 0.0;
m[2][1] = 0.0;
matrix[0][0] = coords[X1] - coords[X0];
matrix[0][1] = coords[X3] - coords[X1];
matrix[0][2] = coords[X0];
matrix[1][0] = coords[Y1] - coords[Y0];
matrix[1][1] = coords[Y3] - coords[Y1];
matrix[1][2] = coords[Y0];
matrix[2][0] = 0.0;
matrix[2][1] = 0.0;
}
else
{
det1 = dx3 * dy2 - dy3 * dx2;
det2 = dx1 * dy2 - dy1 * dx2;
m[2][0] = det1 / det2;
matrix[2][0] = det1 / det2;
det1 = dx1 * dy3 - dy1 * dx3;
det2 = dx1 * dy2 - dy1 * dx2;
m[2][1] = det1 / det2;
matrix[2][1] = det1 / det2;
m[0][0] = coords[X1] - coords[X0] + m[2][0] * coords[X1];
m[0][1] = coords[X2] - coords[X0] + m[2][1] * coords[X2];
m[0][2] = coords[X0];
matrix[0][0] = coords[X1] - coords[X0] + matrix[2][0] * coords[X1];
matrix[0][1] = coords[X2] - coords[X0] + matrix[2][1] * coords[X2];
matrix[0][2] = coords[X0];
m[1][0] = coords[Y1] - coords[Y0] + m[2][0] * coords[Y1];
m[1][1] = coords[Y2] - coords[Y0] + m[2][1] * coords[Y2];
m[1][2] = coords[Y0];
matrix[1][0] = coords[Y1] - coords[Y0] + matrix[2][0] * coords[Y1];
matrix[1][1] = coords[Y2] - coords[Y0] + matrix[2][1] * coords[Y2];
matrix[1][2] = coords[Y0];
}
m[2][2] = 1.0;
matrix[2][2] = 1.0;
}
void *
TileManager *
perspective_tool_perspective (GImage *gimage,
GimpDrawable *drawable,
GDisplay *gdisp,
TileManager *float_tiles,
int interpolation,
gboolean interpolation,
GimpMatrix matrix)
{
void *ret;
gimp_progress *progress;
TileManager *ret;
progress = progress_start (gdisp, _("Perspective..."), FALSE, NULL, NULL);
ret = transform_core_do (gimage, drawable, float_tiles,
interpolation, matrix,
progress? progress_update_and_flush:NULL, progress);
progress ? progress_update_and_flush : NULL,
progress);
if (progress)
progress_end (progress);
......
......@@ -19,15 +19,21 @@
#define __PERSPECTIVE_TOOL_H__
#include "tools.h"
#include "transform_core.h"
void * perspective_tool_transform (Tool *, gpointer, int);
void * perspective_tool_perspective (GimpImage *, GimpDrawable *,
GDisplay *, TileManager *,
int, GimpMatrix);
void perspective_find_transform (double *, GimpMatrix);
TileManager * perspective_tool_transform (Tool *tool,
gpointer gdisp_ptr,
TransformState state);
TileManager * perspective_tool_perspective (GimpImage *gimage,
GimpDrawable *drawable,
GDisplay *gdisp,
TileManager *float_tiles,
gboolean interpolation,
GimpMatrix matrix);
void perspective_find_transform (gdouble *coords,
GimpMatrix matrix);
Tool * tools_new_perspective_tool (void);
void tools_free_perspective_tool (Tool *);
Tool * tools_new_perspective_tool (void);
void tools_free_perspective_tool (Tool *tool);
#endif /* __PERSPECTIVE_TOOL_H__ */
......@@ -24,8 +24,6 @@
#include "info_dialog.h"
#include "rotate_tool.h"
#include "selection.h"
#include "tools.h"
#include "transform_core.h"
#include "transform_tool.h"
#include "undo.h"
......@@ -52,7 +50,7 @@ static gdouble center_vals[2];
static GtkWidget *sizeentry;
/* forward function declarations */
static void * rotate_tool_recalc (Tool *, void *);
static void rotate_tool_recalc (Tool *, void *);
static void rotate_tool_motion (Tool *, void *);
static void rotate_info_update (Tool *);
......@@ -60,10 +58,10 @@ static void rotate_info_update (Tool *);
static void rotate_angle_changed (GtkWidget *entry, gpointer data);
static void rotate_center_changed (GtkWidget *entry, gpointer data);
void *
rotate_tool_transform (Tool *tool,
gpointer gdisp_ptr,
int state)
TileManager *
rotate_tool_transform (Tool *tool,
gpointer gdisp_ptr,
TransformState state)
{
TransformCore *transform_core;
GDisplay *gdisp;
......@@ -75,7 +73,7 @@ rotate_tool_transform (Tool *tool,
switch (state)
{
case INIT :
case INIT:
angle_val = 0.0;
center_vals[0] = transform_core->cx;
center_vals[1] = transform_core->cy;
......@@ -83,7 +81,8 @@ rotate_tool_transform (Tool *tool,
if (!transform_info)
{
transform_info = info_dialog_new (_("Rotation Information"),
tools_help_func, NULL);
gimp_standard_help_func,
"tools/transform_rotate.html");
widget =
info_dialog_add_spinbutton (transform_info, _("Angle:"),
......@@ -161,17 +160,16 @@ rotate_tool_transform (Tool *tool,
return NULL;
break;
case MOTION :
case MOTION:
rotate_tool_motion (tool, gdisp_ptr);
return rotate_tool_recalc (tool, gdisp_ptr);
rotate_tool_recalc (tool, gdisp_ptr);
break;
case RECALC :
return rotate_tool_recalc (tool, gdisp_ptr);
case RECALC:
rotate_tool_recalc (tool, gdisp_ptr);
break;
case FINISH :
case FINISH:
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
return rotate_tool_rotate (gdisp->gimage,
gimage_active_drawable (gdisp->gimage),
......@@ -187,12 +185,12 @@ rotate_tool_transform (Tool *tool,
}
Tool *
tools_new_rotate_tool ()
tools_new_rotate_tool (void)
{