2000-05-23 21:00:40 +08:00
|
|
|
/*
|
2007-06-06 16:44:52 +08:00
|
|
|
* illusion.c -- This is a plug-in for GIMP 1.0
|
2003-11-06 23:27:05 +08:00
|
|
|
*
|
2000-05-23 21:00:40 +08:00
|
|
|
* Copyright (C) 1997 Hirotsuna Mizuno
|
|
|
|
* s1041150@u-aizu.ac.jp
|
|
|
|
*
|
|
|
|
* Preview and new mode added May 2000 by tim copperfield
|
2003-12-11 06:50:26 +08:00
|
|
|
* timecop@japan.co.jp
|
|
|
|
* http://www.ne.jp/asahi/linux/timecop
|
2001-10-19 07:09:40 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* 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.
|
2001-10-19 07:09:40 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* 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.
|
2001-10-19 07:09:40 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2000-05-23 21:00:40 +08:00
|
|
|
*
|
|
|
|
*/
|
1997-12-09 13:57:33 +08:00
|
|
|
|
1999-12-29 04:04:19 +08:00
|
|
|
#include "config.h"
|
2000-01-07 18:39:33 +08:00
|
|
|
|
2000-10-01 04:13:06 +08:00
|
|
|
#include <string.h>
|
2000-01-07 18:39:33 +08:00
|
|
|
|
2000-01-18 01:02:26 +08:00
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
2000-01-07 18:39:33 +08:00
|
|
|
|
1999-12-29 04:04:19 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2005-03-04 23:12:29 +08:00
|
|
|
|
2006-06-27 21:08:28 +08:00
|
|
|
#define PLUG_IN_PROC "plug-in-illusion"
|
2005-08-14 06:52:41 +08:00
|
|
|
#define PLUG_IN_BINARY "illusion"
|
2000-05-23 21:00:40 +08:00
|
|
|
#define PLUG_IN_VERSION "v0.8 (May 14 2000)"
|
|
|
|
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2000-05-02 01:01:18 +08:00
|
|
|
static void query (void);
|
2003-07-02 20:03:08 +08:00
|
|
|
static void run (const gchar *name,
|
2003-12-11 06:50:26 +08:00
|
|
|
gint nparam,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
2000-01-18 01:02:26 +08:00
|
|
|
|
2004-10-03 02:26:41 +08:00
|
|
|
static void illusion (GimpDrawable *drawable);
|
|
|
|
static void illusion_preview (GimpPreview *preview,
|
|
|
|
GimpDrawable *drawable);
|
|
|
|
static gboolean illusion_dialog (GimpDrawable *drawable);
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2000-01-18 01:02:26 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2004-10-03 02:26:41 +08:00
|
|
|
gint32 division;
|
|
|
|
gboolean type1;
|
|
|
|
gboolean type2;
|
2000-05-23 21:00:40 +08:00
|
|
|
} IllValues;
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2006-05-16 20:26:20 +08:00
|
|
|
const GimpPlugInInfo PLUG_IN_INFO =
|
2000-01-18 01:02:26 +08:00
|
|
|
{
|
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
2000-05-23 21:00:40 +08:00
|
|
|
run /* run_proc */
|
1997-12-09 13:57:33 +08:00
|
|
|
};
|
|
|
|
|
2000-05-23 21:00:40 +08:00
|
|
|
static IllValues parameters =
|
2000-01-18 01:02:26 +08:00
|
|
|
{
|
2004-10-03 02:26:41 +08:00
|
|
|
8, /* division */
|
|
|
|
TRUE, /* type 1 */
|
2005-09-20 06:58:16 +08:00
|
|
|
FALSE /* type 2 */
|
1997-12-09 13:57:33 +08:00
|
|
|
};
|
|
|
|
|
2000-01-18 01:02:26 +08:00
|
|
|
MAIN ()
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2000-01-18 01:02:26 +08:00
|
|
|
static void
|
|
|
|
query (void)
|
1997-12-09 13:57:33 +08:00
|
|
|
{
|
2006-05-16 20:26:20 +08:00
|
|
|
static const GimpParamDef args[] =
|
2000-01-07 18:39:33 +08:00
|
|
|
{
|
2009-01-20 04:11:36 +08:00
|
|
|
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
|
2009-04-12 00:57:42 +08:00
|
|
|
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
|
|
|
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
|
|
|
|
{ GIMP_PDB_INT32, "division", "The number of divisions" },
|
|
|
|
{ GIMP_PDB_INT32, "type", "Illusion type { TYPE1 (0), TYPE2 (1) }" }
|
1997-12-09 13:57:33 +08:00
|
|
|
};
|
1999-12-29 04:04:19 +08:00
|
|
|
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_install_procedure (PLUG_IN_PROC,
|
2006-03-16 05:10:34 +08:00
|
|
|
N_("Superimpose many altered copies of the image"),
|
2003-12-11 06:50:26 +08:00
|
|
|
"produce illusion",
|
|
|
|
"Hirotsuna Mizuno <s1041150@u-aizu.ac.jp>",
|
|
|
|
"Hirotsuna Mizuno",
|
|
|
|
PLUG_IN_VERSION,
|
2004-05-07 21:15:52 +08:00
|
|
|
N_("_Illusion..."),
|
2003-12-11 06:50:26 +08:00
|
|
|
"RGB*, GRAY*",
|
|
|
|
GIMP_PLUGIN,
|
|
|
|
G_N_ELEMENTS (args), 0,
|
|
|
|
args, NULL);
|
2004-05-07 21:15:52 +08:00
|
|
|
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Filters/Map");
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|
|
|
|
|
2000-01-07 18:39:33 +08:00
|
|
|
static void
|
2003-07-02 20:03:08 +08:00
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *params,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1997-12-09 13:57:33 +08:00
|
|
|
{
|
2001-12-29 21:26:29 +08:00
|
|
|
static GimpParam returnv[1];
|
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
2004-09-02 09:23:09 +08:00
|
|
|
GimpRunMode run_mode;
|
2004-10-03 02:26:41 +08:00
|
|
|
GimpDrawable *drawable;
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
|
|
|
|
2004-10-03 02:26:41 +08:00
|
|
|
/* get the drawable info */
|
1997-12-09 13:57:33 +08:00
|
|
|
run_mode = params[0].data.d_int32;
|
2000-01-07 18:39:33 +08:00
|
|
|
drawable = gimp_drawable_get (params[2].data.d_drawable);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-18 01:02:26 +08:00
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = returnv;
|
1997-12-09 13:57:33 +08:00
|
|
|
|
|
|
|
/* switch the run mode */
|
2000-01-07 18:39:33 +08:00
|
|
|
switch (run_mode)
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_get_data (PLUG_IN_PROC, ¶meters);
|
2004-10-03 02:26:41 +08:00
|
|
|
if (! illusion_dialog (drawable))
|
2003-12-11 06:50:26 +08:00
|
|
|
return;
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_set_data (PLUG_IN_PROC, ¶meters, sizeof (IllValues));
|
2000-01-07 18:39:33 +08:00
|
|
|
break;
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
2001-10-19 18:40:47 +08:00
|
|
|
if (nparams != 5)
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
2000-01-07 18:39:33 +08:00
|
|
|
else
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
parameters.division = params[3].data.d_int32;
|
2001-10-19 18:40:47 +08:00
|
|
|
if (params[4].data.d_int32 == 0)
|
|
|
|
{
|
2004-10-03 02:26:41 +08:00
|
|
|
parameters.type1 = TRUE;
|
|
|
|
parameters.type2 = FALSE;
|
2001-10-19 18:40:47 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-10-03 02:26:41 +08:00
|
|
|
parameters.type1 = FALSE;
|
|
|
|
parameters.type2 = TRUE;
|
2001-10-19 18:40:47 +08:00
|
|
|
}
|
2003-12-11 06:50:26 +08:00
|
|
|
}
|
2000-01-07 18:39:33 +08:00
|
|
|
break;
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_get_data (PLUG_IN_PROC, ¶meters);
|
2000-01-07 18:39:33 +08:00
|
|
|
break;
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
2000-01-07 18:39:33 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
if (gimp_drawable_is_rgb (drawable->drawable_id) ||
|
2003-12-11 06:50:26 +08:00
|
|
|
gimp_drawable_is_gray (drawable->drawable_id))
|
|
|
|
{
|
|
|
|
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width() + 1));
|
2005-09-30 16:16:10 +08:00
|
|
|
gimp_progress_init (_("Illusion"));
|
2004-10-03 02:26:41 +08:00
|
|
|
illusion (drawable);
|
2003-12-11 06:50:26 +08:00
|
|
|
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
|
|
|
gimp_displays_flush ();
|
|
|
|
}
|
2000-01-07 18:39:33 +08:00
|
|
|
else
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
|
|
|
}
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
returnv[0].type = GIMP_PDB_STATUS;
|
1997-12-09 13:57:33 +08:00
|
|
|
returnv[0].data.d_status = status;
|
|
|
|
|
2000-01-07 18:39:33 +08:00
|
|
|
gimp_drawable_detach (drawable);
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|
|
|
|
|
2003-09-25 04:17:43 +08:00
|
|
|
typedef struct {
|
|
|
|
GimpPixelFetcher *pft;
|
2003-12-11 06:50:26 +08:00
|
|
|
gdouble center_x;
|
|
|
|
gdouble center_y;
|
|
|
|
gdouble scale;
|
|
|
|
gdouble offset;
|
|
|
|
gboolean has_alpha;
|
2003-09-25 04:17:43 +08:00
|
|
|
} IllusionParam_t;
|
|
|
|
|
2000-01-07 18:39:33 +08:00
|
|
|
static void
|
2004-10-03 02:26:41 +08:00
|
|
|
illusion_func (gint x,
|
|
|
|
gint y,
|
2003-12-11 06:50:26 +08:00
|
|
|
const guchar *src,
|
2004-10-03 02:26:41 +08:00
|
|
|
guchar *dest,
|
|
|
|
gint bpp,
|
|
|
|
gpointer data)
|
1997-12-09 13:57:33 +08:00
|
|
|
{
|
2003-09-25 04:17:43 +08:00
|
|
|
IllusionParam_t *param = (IllusionParam_t*) data;
|
2004-10-03 02:26:41 +08:00
|
|
|
gint xx, yy, b;
|
|
|
|
gdouble radius, cx, cy, angle;
|
|
|
|
guchar pixel[4];
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
cy = ((gdouble) y - param->center_y) / param->scale;
|
2003-09-25 04:17:43 +08:00
|
|
|
cx = ((gdouble) x - param->center_x) / param->scale;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-09-25 04:17:43 +08:00
|
|
|
angle = floor (atan2 (cy, cx) * parameters.division / G_PI_2)
|
|
|
|
* G_PI_2 / parameters.division + (G_PI / parameters.division);
|
|
|
|
radius = sqrt ((gdouble) (cx * cx + cy * cy));
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (parameters.type1)
|
2000-01-07 18:39:33 +08:00
|
|
|
{
|
2003-09-25 04:17:43 +08:00
|
|
|
xx = x - param->offset * cos (angle);
|
|
|
|
yy = y - param->offset * sin (angle);
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
2003-12-11 06:50:26 +08:00
|
|
|
else /* Type 2 */
|
2003-09-25 04:17:43 +08:00
|
|
|
{
|
|
|
|
xx = x - param->offset * sin (angle);
|
|
|
|
yy = y - param->offset * cos (angle);
|
2000-01-07 18:39:33 +08:00
|
|
|
}
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2003-12-27 01:26:36 +08:00
|
|
|
gimp_pixel_fetcher_get_pixel (param->pft, xx, yy, pixel);
|
2000-01-07 18:39:33 +08:00
|
|
|
|
2003-09-25 04:17:43 +08:00
|
|
|
if (param->has_alpha)
|
2000-01-07 18:39:33 +08:00
|
|
|
{
|
2003-09-25 04:17:43 +08:00
|
|
|
guint alpha1 = src[bpp - 1];
|
|
|
|
guint alpha2 = pixel[bpp - 1];
|
2003-09-25 06:01:53 +08:00
|
|
|
guint alpha = (1 - radius) * alpha1 + radius * alpha2;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-09-25 04:17:43 +08:00
|
|
|
if ((dest[bpp - 1] = (alpha >> 1)))
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
|
|
|
for (b = 0; b < bpp - 1; b++)
|
|
|
|
dest[b] = ((1 - radius) * src[b] * alpha1 +
|
|
|
|
radius * pixel[b] * alpha2) / alpha;
|
|
|
|
}
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|
2003-09-25 04:17:43 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for (b = 0; b < bpp; b++)
|
2003-12-11 06:50:26 +08:00
|
|
|
dest[b] = (1 - radius) * src[b] + radius * pixel[b];
|
2003-09-25 04:17:43 +08:00
|
|
|
}
|
|
|
|
}
|
2000-01-07 18:39:33 +08:00
|
|
|
|
2003-09-25 04:17:43 +08:00
|
|
|
static void
|
2004-10-03 02:26:41 +08:00
|
|
|
illusion (GimpDrawable *drawable)
|
2003-09-25 04:17:43 +08:00
|
|
|
{
|
2004-03-13 06:46:25 +08:00
|
|
|
IllusionParam_t param;
|
2003-09-25 04:17:43 +08:00
|
|
|
GimpRgnIterator *iter;
|
2004-03-13 06:46:25 +08:00
|
|
|
gint width, height;
|
|
|
|
gint x1, y1, x2, y2;
|
2003-09-25 04:17:43 +08:00
|
|
|
|
|
|
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
2004-03-13 06:46:25 +08:00
|
|
|
width = x2 - x1;
|
2003-09-25 04:17:43 +08:00
|
|
|
height = y2 - y1;
|
|
|
|
|
2004-03-13 06:46:25 +08:00
|
|
|
param.pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
2003-12-27 01:26:36 +08:00
|
|
|
gimp_pixel_fetcher_set_edge_mode (param.pft, GIMP_PIXEL_FETCHER_EDGE_SMEAR);
|
2004-03-13 06:46:25 +08:00
|
|
|
|
2003-09-25 04:17:43 +08:00
|
|
|
param.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
|
|
|
param.center_x = (x1 + x2) / 2.0;
|
|
|
|
param.center_y = (y1 + y2) / 2.0;
|
|
|
|
param.scale = sqrt (width * width + height * height) / 2;
|
|
|
|
param.offset = (gint) (param.scale / 2);
|
|
|
|
|
2004-09-02 09:23:09 +08:00
|
|
|
iter = gimp_rgn_iterator_new (drawable, 0);
|
2003-09-25 04:17:43 +08:00
|
|
|
gimp_rgn_iterator_src_dest (iter, illusion_func, ¶m);
|
|
|
|
gimp_rgn_iterator_free (iter);
|
|
|
|
|
|
|
|
gimp_pixel_fetcher_destroy (param.pft);
|
2000-05-23 21:00:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-10-03 02:26:41 +08:00
|
|
|
illusion_preview (GimpPreview *preview,
|
|
|
|
GimpDrawable *drawable)
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2007-08-31 00:44:10 +08:00
|
|
|
{
|
|
|
|
gint x, y;
|
|
|
|
gint sx, sy;
|
|
|
|
gint preview_width, preview_height;
|
|
|
|
guchar *src;
|
|
|
|
guchar *dest;
|
|
|
|
guchar *src_pixel;
|
|
|
|
guchar *dest_pixel;
|
|
|
|
gint bpp;
|
|
|
|
IllusionParam_t param;
|
|
|
|
gint width, height;
|
|
|
|
gint x1, y1, x2, y2;
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2007-08-31 00:44:10 +08:00
|
|
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
|
|
|
width = x2 - x1;
|
|
|
|
height = y2 - y1;
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2007-08-31 00:44:10 +08:00
|
|
|
param.pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
|
|
|
gimp_pixel_fetcher_set_edge_mode (param.pft, GIMP_PIXEL_FETCHER_EDGE_SMEAR);
|
2007-05-12 00:44:10 +08:00
|
|
|
|
2007-08-31 00:44:10 +08:00
|
|
|
param.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
|
|
|
param.center_x = (x1 + x2) / 2.0;
|
|
|
|
param.center_y = (y1 + y2) / 2.0;
|
|
|
|
param.scale = sqrt (width * width + height * height) / 2;
|
|
|
|
param.offset = (gint) (param.scale / 2);
|
2007-05-12 00:44:10 +08:00
|
|
|
|
2007-08-31 00:44:10 +08:00
|
|
|
src = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
|
|
|
|
&preview_width, &preview_height, &bpp);
|
|
|
|
dest = g_malloc (preview_width * preview_height * bpp);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2007-08-31 00:44:10 +08:00
|
|
|
src_pixel = src;
|
|
|
|
dest_pixel = dest;
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2007-08-31 00:44:10 +08:00
|
|
|
for (y = 0; y < preview_height; y++)
|
2000-05-23 21:00:40 +08:00
|
|
|
{
|
2007-08-31 00:44:10 +08:00
|
|
|
for (x = 0; x < preview_width; x++)
|
2003-12-11 06:50:26 +08:00
|
|
|
{
|
2007-08-31 00:44:10 +08:00
|
|
|
gimp_preview_untransform (preview, x, y, &sx, &sy);
|
2003-12-11 06:50:26 +08:00
|
|
|
|
2007-08-31 00:44:10 +08:00
|
|
|
illusion_func (sx, sy,
|
|
|
|
src_pixel, dest_pixel,
|
|
|
|
bpp,
|
|
|
|
(gpointer) ¶m);
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2007-08-31 00:44:10 +08:00
|
|
|
src_pixel += bpp;
|
|
|
|
dest_pixel += bpp;
|
2003-12-11 06:50:26 +08:00
|
|
|
}
|
2000-05-23 21:00:40 +08:00
|
|
|
}
|
|
|
|
|
2007-08-31 00:44:10 +08:00
|
|
|
gimp_pixel_fetcher_destroy (param.pft);
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2007-08-31 00:44:10 +08:00
|
|
|
gimp_preview_draw_buffer (preview, dest, preview_width * bpp);
|
|
|
|
g_free (dest);
|
|
|
|
g_free (src);
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|
|
|
|
|
2000-05-02 01:01:18 +08:00
|
|
|
static gboolean
|
2004-10-03 02:26:41 +08:00
|
|
|
illusion_dialog (GimpDrawable *drawable)
|
1997-12-09 13:57:33 +08:00
|
|
|
{
|
2004-10-03 02:26:41 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *preview;
|
2000-01-18 01:02:26 +08:00
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkObject *adj;
|
2000-05-23 21:00:40 +08:00
|
|
|
GtkWidget *radio;
|
|
|
|
GSList *group = NULL;
|
2003-11-06 23:27:05 +08:00
|
|
|
gboolean run;
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY, TRUE);
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2005-08-14 06:52:41 +08:00
|
|
|
dialog = gimp_dialog_new (_("Illusion"), PLUG_IN_BINARY,
|
2004-10-03 02:26:41 +08:00
|
|
|
NULL, 0,
|
2005-08-14 06:52:41 +08:00
|
|
|
gimp_standard_help_func, PLUG_IN_PROC,
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2004-10-03 02:26:41 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-10-03 02:26:41 +08:00
|
|
|
NULL);
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2005-02-09 04:40:33 +08:00
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2005-08-14 06:52:41 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2005-02-09 04:40:33 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gimp_window_set_transient (GTK_WINDOW (dialog));
|
2005-09-06 05:40:29 +08:00
|
|
|
|
2004-10-03 02:26:41 +08:00
|
|
|
main_vbox = gtk_vbox_new (FALSE, 12);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
|
2009-07-16 00:57:12 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
|
|
|
main_vbox);
|
2004-10-03 02:26:41 +08:00
|
|
|
gtk_widget_show (main_vbox);
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2005-09-20 06:58:16 +08:00
|
|
|
preview = gimp_zoom_preview_new (drawable);
|
2008-07-21 21:41:00 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), preview, TRUE, TRUE, 0);
|
2004-08-07 08:49:05 +08:00
|
|
|
gtk_widget_show (preview);
|
2005-08-14 06:52:41 +08:00
|
|
|
|
2004-10-03 02:26:41 +08:00
|
|
|
g_signal_connect (preview, "invalidated",
|
2005-08-14 06:52:41 +08:00
|
|
|
G_CALLBACK (illusion_preview),
|
|
|
|
drawable);
|
2003-12-11 05:13:29 +08:00
|
|
|
|
|
|
|
table = gtk_table_new (3, 2, FALSE);
|
2004-05-19 01:06:06 +08:00
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
2004-10-03 02:26:41 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0);
|
2003-12-11 05:13:29 +08:00
|
|
|
gtk_widget_show (table);
|
2000-01-18 01:02:26 +08:00
|
|
|
|
|
|
|
spinbutton = gimp_spin_button_new (&adj, parameters.division,
|
2003-12-11 06:50:26 +08:00
|
|
|
-32, 64, 1, 10, 0, 1, 0);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
2004-05-19 01:06:06 +08:00
|
|
|
_("_Divisions:"), 0.0, 0.5,
|
2003-12-11 06:50:26 +08:00
|
|
|
spinbutton, 1, TRUE);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (adj, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_int_adjustment_update),
|
|
|
|
¶meters.division);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect_swapped (adj, "value-changed",
|
2004-10-03 02:26:41 +08:00
|
|
|
G_CALLBACK (gimp_preview_invalidate),
|
|
|
|
preview);
|
2000-05-23 21:00:40 +08:00
|
|
|
|
2002-05-31 19:39:27 +08:00
|
|
|
radio = gtk_radio_button_new_with_mnemonic (group, _("Mode _1"));
|
2001-12-29 21:26:29 +08:00
|
|
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio));
|
|
|
|
gtk_table_attach (GTK_TABLE (table), radio, 0, 2, 1, 2,
|
|
|
|
GTK_FILL, GTK_FILL, 0, 0);
|
2000-05-23 21:00:40 +08:00
|
|
|
gtk_widget_show (radio);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (radio, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
¶meters.type1);
|
2004-10-03 02:26:41 +08:00
|
|
|
g_signal_connect_swapped (radio, "toggled",
|
|
|
|
G_CALLBACK (gimp_preview_invalidate),
|
|
|
|
preview);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), parameters.type1);
|
|
|
|
|
2002-05-31 19:39:27 +08:00
|
|
|
radio = gtk_radio_button_new_with_mnemonic (group, _("Mode _2"));
|
2001-12-29 21:26:29 +08:00
|
|
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio));
|
|
|
|
gtk_table_attach (GTK_TABLE (table), radio, 0, 2, 2, 3,
|
|
|
|
GTK_FILL, GTK_FILL, 0, 0);
|
2000-05-23 21:00:40 +08:00
|
|
|
gtk_widget_show (radio);
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (radio, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
¶meters.type2);
|
2004-10-03 02:26:41 +08:00
|
|
|
g_signal_connect_swapped (radio, "toggled",
|
|
|
|
G_CALLBACK (gimp_preview_invalidate),
|
|
|
|
preview);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), parameters.type2);
|
|
|
|
|
2004-10-03 02:26:41 +08:00
|
|
|
gtk_widget_show (dialog);
|
2004-08-07 08:49:05 +08:00
|
|
|
|
2004-10-03 02:26:41 +08:00
|
|
|
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-10-03 02:26:41 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
1997-12-09 13:57:33 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
return run;
|
1997-12-09 13:57:33 +08:00
|
|
|
}
|