Commit 47f987f8 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/Makefile.am lowlevel stuff taken out of the transform tool.

2001-03-31  Michael Natterer  <mitch@gimp.org>

	* app/Makefile.am
	* app/pixel_surround.[ch]: lowlevel stuff taken out of the transform
	tool.

	* app/tools/gimpscaletool.[ch]: minor cleanups, declare
	gimp_scale_tool_register() publically.

	* app/tools/gimptransformtool.[ch]: removed the PixelSurround stuff,
	hardcode tr_tool->interactive to TRUE, removed the no_draw() function,
	register the tool options, misc. other fixes and bad hacks that need
	to go away.

	(All this non-interactive stuff needs to be done outside the tool
	system. A "non-interactive tool" is just pure nonsense)

	* app/tools/gimptool.h: spacing.

	* app/tools/tool_manager.c: tool_manager_register_tool_options():
	return after warning, don't simply continue and crash.

	* app/tools/tools.c: register the bezier select tool.
parent c32c1455
2001-03-31 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
* app/pixel_surround.[ch]: lowlevel stuff taken out of the transform
tool.
* app/tools/gimpscaletool.[ch]: minor cleanups, declare
gimp_scale_tool_register() publically.
* app/tools/gimptransformtool.[ch]: removed the PixelSurround stuff,
hardcode tr_tool->interactive to TRUE, removed the no_draw() function,
register the tool options, misc. other fixes and bad hacks that need
to go away.
(All this non-interactive stuff needs to be done outside the tool
system. A "non-interactive tool" is just pure nonsense)
* app/tools/gimptool.h: spacing.
* app/tools/tool_manager.c: tool_manager_register_tool_options():
return after warning, don't simply continue and crash.
* app/tools/tools.c: register the bezier select tool.
2001-03-30 Michael Natterer <mitch@gimp.org>
* app/devices.c
......
......@@ -86,9 +86,6 @@ gimp_SOURCES = \
errors.h \
equalize.c \
equalize.h \
## fileops.c \
## fileops.h \
## fileopsP.h \
file-open.c \
file-open.h \
file-save.c \
......@@ -288,6 +285,8 @@ gimp_SOURCES = \
pixel_processor.h \
pixel_region.c \
pixel_region.h \
pixel_surround.c \
pixel_surround.h \
temp_buf.c \
temp_buf.h \
tile.c \
......
/* The GIMP -- an 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "apptypes.h"
#include "gimpimage.h"
#include "pixel_region.h"
#include "pixel_surround.h"
#include "tile_manager.h"
#include "tile.h"
void
pixel_surround_init (PixelSurround *ps,
TileManager *tm,
gint w,
gint h,
guchar bg[MAX_CHANNELS])
{
gint i;
for (i = 0; i < MAX_CHANNELS; ++i)
{
ps->bg[i] = bg[i];
}
ps->tile = NULL;
ps->mgr = tm;
ps->bpp = tile_manager_bpp (tm);
ps->w = w;
ps->h = h;
/* make sure buffer is big enough */
ps->buff_size = w * h * ps->bpp;
ps->buff = g_malloc (ps->buff_size);
ps->row_stride = 0;
}
guchar *
pixel_surround_lock (PixelSurround *ps,
gint x,
gint y)
{
gint i, j;
guchar *k;
guchar *ptr;
ps->tile = tile_manager_get_tile (ps->mgr, x, y, TRUE, FALSE);
i = x % TILE_WIDTH;
j = y % TILE_HEIGHT;
/* do we have the whole region? */
if (ps->tile &&
(i < (tile_ewidth(ps->tile) - ps->w)) &&
(j < (tile_eheight(ps->tile) - ps->h)))
{
ps->row_stride = tile_ewidth (ps->tile) * ps->bpp;
/* is this really the correct way? */
return tile_data_pointer (ps->tile, i, j);
}
/* nope, do this the hard way (for now) */
if (ps->tile)
{
tile_release (ps->tile, FALSE);
ps->tile = 0;
}
/* copy pixels, one by one */
/* no, this is not the best way, but it's much better than before */
ptr = ps->buff;
for (j = y; j < y+ps->h; ++j)
{
for (i = x; i < x+ps->w; ++i)
{
Tile *tile = tile_manager_get_tile (ps->mgr, i, j, TRUE, FALSE);
if (tile)
{
guchar *buff = tile_data_pointer (tile,
i % TILE_WIDTH,
j % TILE_HEIGHT);
for (k = buff; k < buff+ps->bpp; ++k, ++ptr)
{
*ptr = *k;
}
tile_release (tile, FALSE);
}
else
{
for (k = ps->bg; k < ps->bg+ps->bpp; ++k, ++ptr)
{
*ptr = *k;
}
}
}
}
ps->row_stride = ps->w * ps->bpp;
return ps->buff;
}
gint
pixel_surround_rowstride (PixelSurround *ps)
{
return ps->row_stride;
}
void
pixel_surround_release (PixelSurround *ps)
{
/* always get new tile (for now), so release the old one */
if (ps->tile)
{
tile_release (ps->tile, FALSE);
ps->tile = 0;
}
}
void
pixel_surround_clear (PixelSurround *ps)
{
if (ps->buff)
{
g_free (ps->buff);
ps->buff = 0;
ps->buff_size = 0;
}
}
/* The GIMP -- an 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PIXEL_SURROUND_H__
#define __PIXEL_SURROUND_H__
/* PixelSurround describes a (read-only)
* region around a pixel in a tile manager
*/
typedef struct _PixelSurround
{
Tile *tile;
TileManager *mgr;
guchar *buff;
gint buff_size;
gint bpp;
gint w;
gint h;
guchar bg[MAX_CHANNELS];
gint row_stride;
} PixelSurround;
void pixel_surround_init (PixelSurround *ps,
TileManager *tm,
gint w,
gint h,
guchar bg[MAX_CHANNELS]);
/* return a pointer to a buffer which contains all the surrounding pixels
* strategy: if we are in the middle of a tile, use the tile storage
* otherwise just copy into our own malloced buffer and return that
*/
guchar * pixel_surround_lock (PixelSurround *ps,
gint x,
gint y);
gint pixel_surround_rowstride (PixelSurround *ps);
void pixel_surround_release (PixelSurround *ps);
void pixel_surround_clear (PixelSurround *ps);
#endif /* __PIXEL_SURROUND_H__ */
This diff is collapsed.
This diff is collapsed.
/* The GIMP -- an 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "apptypes.h"
#include "gimpimage.h"
#include "pixel_region.h"
#include "pixel_surround.h"
#include "tile_manager.h"
#include "tile.h"
void
pixel_surround_init (PixelSurround *ps,
TileManager *tm,
gint w,
gint h,
guchar bg[MAX_CHANNELS])
{
gint i;
for (i = 0; i < MAX_CHANNELS; ++i)
{
ps->bg[i] = bg[i];
}
ps->tile = NULL;
ps->mgr = tm;
ps->bpp = tile_manager_bpp (tm);
ps->w = w;
ps->h = h;
/* make sure buffer is big enough */
ps->buff_size = w * h * ps->bpp;
ps->buff = g_malloc (ps->buff_size);
ps->row_stride = 0;
}
guchar *
pixel_surround_lock (PixelSurround *ps,
gint x,
gint y)
{
gint i, j;
guchar *k;
guchar *ptr;
ps->tile = tile_manager_get_tile (ps->mgr, x, y, TRUE, FALSE);
i = x % TILE_WIDTH;
j = y % TILE_HEIGHT;
/* do we have the whole region? */
if (ps->tile &&
(i < (tile_ewidth(ps->tile) - ps->w)) &&
(j < (tile_eheight(ps->tile) - ps->h)))
{
ps->row_stride = tile_ewidth (ps->tile) * ps->bpp;
/* is this really the correct way? */
return tile_data_pointer (ps->tile, i, j);
}
/* nope, do this the hard way (for now) */
if (ps->tile)
{
tile_release (ps->tile, FALSE);
ps->tile = 0;
}
/* copy pixels, one by one */
/* no, this is not the best way, but it's much better than before */
ptr = ps->buff;
for (j = y; j < y+ps->h; ++j)
{
for (i = x; i < x+ps->w; ++i)
{
Tile *tile = tile_manager_get_tile (ps->mgr, i, j, TRUE, FALSE);
if (tile)
{
guchar *buff = tile_data_pointer (tile,
i % TILE_WIDTH,
j % TILE_HEIGHT);
for (k = buff; k < buff+ps->bpp; ++k, ++ptr)
{
*ptr = *k;
}
tile_release (tile, FALSE);
}
else
{
for (k = ps->bg; k < ps->bg+ps->bpp; ++k, ++ptr)
{
*ptr = *k;
}
}
}
}
ps->row_stride = ps->w * ps->bpp;
return ps->buff;
}
gint
pixel_surround_rowstride (PixelSurround *ps)
{
return ps->row_stride;
}
void
pixel_surround_release (PixelSurround *ps)
{
/* always get new tile (for now), so release the old one */
if (ps->tile)
{
tile_release (ps->tile, FALSE);
ps->tile = 0;
}
}
void
pixel_surround_clear (PixelSurround *ps)
{
if (ps->buff)
{
g_free (ps->buff);
ps->buff = 0;
ps->buff_size = 0;
}
}
/* The GIMP -- an 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PIXEL_SURROUND_H__
#define __PIXEL_SURROUND_H__
/* PixelSurround describes a (read-only)
* region around a pixel in a tile manager
*/
typedef struct _PixelSurround
{
Tile *tile;
TileManager *mgr;
guchar *buff;
gint buff_size;
gint bpp;
gint w;
gint h;
guchar bg[MAX_CHANNELS];
gint row_stride;
} PixelSurround;
void pixel_surround_init (PixelSurround *ps,
TileManager *tm,
gint w,
gint h,
guchar bg[MAX_CHANNELS]);
/* return a pointer to a buffer which contains all the surrounding pixels
* strategy: if we are in the middle of a tile, use the tile storage
* otherwise just copy into our own malloced buffer and return that
*/
guchar * pixel_surround_lock (PixelSurround *ps,
gint x,
gint y);
gint pixel_surround_rowstride (PixelSurround *ps);
void pixel_surround_release (PixelSurround *ps);
void pixel_surround_clear (PixelSurround *ps);
#endif /* __PIXEL_SURROUND_H__ */
......@@ -35,8 +35,6 @@
#include "tile_manager.h"
#include "undo.h"
#include "pixmaps2.h"
#include "tools/tool_options.h"
#include "tools/gimptool.h"
#include "tools/gimpdrawtool.h"
......@@ -48,6 +46,8 @@
#include "libgimp/gimpintl.h"
#include "pixmaps2.h"
/* forward function declarations */
static TileManager * gimp_scale_tool_transform (GimpTransformTool *tool,
......@@ -65,7 +65,7 @@ static void gimp_scale_tool_unit_changed (GtkWidget *widget,
gpointer data);
static void gimp_scale_tool_class_init (GimpScaleToolClass *klass);
static void gimp_scale_tool_init (GimpScaleTool *sc_tool);
static void gimp_scale_tool_init (GimpScaleTool *sc_tool);
/* storage for information dialog fields */
......@@ -79,6 +79,7 @@ static gchar y_ratio_buf[MAX_INFO_BUF];
static GtkWidget *sizeentry = NULL;
static GimpTransformToolClass *parent_class = NULL;
void
gimp_scale_tool_register (void)
{
......@@ -90,7 +91,7 @@ gimp_scale_tool_register (void)
N_("/Tools/Color Picker"), "<shift>T",
NULL, "tools/transform.html",
(const gchar **) scale_bits);
}
}
GtkType
gimp_scale_tool_get_type (void)
......@@ -136,14 +137,13 @@ gimp_scale_tool_class_init (GimpScaleToolClass *klass)
static void
gimp_scale_tool_init (GimpScaleTool *sc_tool)
{
/*GimpTool *tool;*/
GimpTool *tool;
GimpTransformTool *tr_tool;
/* tool = GIMP_TOOL (sc_tool); */
tool = GIMP_TOOL (sc_tool);
tr_tool = GIMP_TRANSFORM_TOOL (sc_tool);
/* FIXME! tool->tool_cursor = GIMP_RESIZE_TOOL_CURSOR; */
tool->tool_cursor = GIMP_RESIZE_TOOL_CURSOR;
/* set the scale specific transformation attributes */
tr_tool->trans_info[X0] = 0.0;
......@@ -291,9 +291,9 @@ gimp_scale_tool_info_update (GimpScaleTool *sc_tool)
static GimpUnit label_unit = GIMP_UNIT_PIXEL;
tool = GIMP_TOOL (sc_tool);
tr_tool = GIMP_TRANSFORM_TOOL (sc_tool);
unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (sizeentry));;
tool = GIMP_TOOL (sc_tool);
tr_tool = GIMP_TRANSFORM_TOOL (sc_tool);
unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (sizeentry));;
/* Find original sizes */
x1 = tr_tool->x1;
......@@ -362,7 +362,7 @@ gimp_scale_tool_size_changed (GtkWidget *widget,
tr_tool = GIMP_TRANSFORM_TOOL(tool);
dr_tool = GIMP_DRAW_TOOL(tool);
width = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0));
width = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0));
height = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1));
if ((width != (tr_tool->trans_info[X1] -
......@@ -385,12 +385,12 @@ static void
gimp_scale_tool_unit_changed (GtkWidget *widget,
gpointer data)
{
gimp_scale_tool_info_update (GIMP_SCALE_TOOL(data));
gimp_scale_tool_info_update (GIMP_SCALE_TOOL (data));
}
static void
gimp_scale_tool_motion (GimpScaleTool *sc_tool,
GDisplay *gdisp)
gimp_scale_tool_motion (GimpScaleTool *sc_tool,
GDisplay *gdisp)
{
GimpTransformTool *tr_tool;
gdouble ratio;
......@@ -439,7 +439,9 @@ gimp_scale_tool_motion (GimpScaleTool *sc_tool,
y2 = &tr_tool->trans_info [Y0];
dir_x = dir_y = -1;
break;
default :
case TRANSFORM_HANDLE_CENTER:
return;
default:
return;
}
......@@ -496,8 +498,8 @@ gimp_scale_tool_motion (GimpScaleTool *sc_tool,
}
static void
gimp_scale_tool_recalc (GimpScaleTool *sc_tool,
GDisplay *gdisp)
gimp_scale_tool_recalc (GimpScaleTool *sc_tool,
GDisplay *gdisp)
{
GimpTransformTool *tr_tool;
gint x1, y1, x2, y2;
......@@ -505,7 +507,7 @@ gimp_scale_tool_recalc (GimpScaleTool *sc_tool,
gint cx, cy;
gdouble scalex, scaley;
tr_tool = GIMP_TRANSFORM_TOOL(sc_tool);
tr_tool = GIMP_TRANSFORM_TOOL (sc_tool);
x1 = (int) tr_tool->trans_info [X0];
y1 = (int) tr_tool->trans_info [Y0];
......@@ -540,7 +542,11 @@ gimp_scale_tool_recalc (GimpScaleTool *sc_tool,
diffx = x1 - tr_tool->x1;
diffy = y1 - tr_tool->y1;
break;
default :
case TRANSFORM_HANDLE_CENTER:
cx = x1; cy = y1;
diffx = diffy = 0;
break;
default:
cx = x1; cy = y1;
diffx = diffy = 0;
break;
......
......@@ -19,34 +19,40 @@
#ifndef __GIMP_SCALE_TOOL_H__
#define __GIMP_SCALE_TOOL_H__
#include "tools/gimptransformtool.h"