1997-11-25 06:05:25 +08:00
|
|
|
/*
|
|
|
|
flame - cosmic recursive fractal flames
|
|
|
|
Copyright (C) 1997 Scott Draves <spot@cs.cmu.edu>
|
|
|
|
|
|
|
|
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
|
1998-04-13 13:44:11 +08:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
1999-05-29 09:28:24 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2002-02-18 22:34:50 +08:00
|
|
|
|
1999-05-29 09:28:24 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <unistd.h>
|
1999-05-29 09:28:24 +08:00
|
|
|
#endif
|
2002-02-18 22:34:50 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2002-01-30 22:54:27 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning GTK_DISABLE_DEPRECATED
|
|
|
|
#endif
|
|
|
|
#undef GTK_DISABLE_DEPRECATED
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
|
|
|
|
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
#include "flame.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
#define VARIATION_SAME (-2)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-21 01:10:16 +08:00
|
|
|
#define HELP_ID "plug-in-flame"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Declare local functions. */
|
1999-12-27 22:14:53 +08:00
|
|
|
static void query (void);
|
2003-07-02 08:15:09 +08:00
|
|
|
static void run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
|
|
|
static void doit (GimpDrawable *drawable);
|
1999-12-27 22:14:53 +08:00
|
|
|
|
|
|
|
static gint dialog (void);
|
|
|
|
static void set_flame_preview (void);
|
2003-07-02 08:15:09 +08:00
|
|
|
static void load_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void save_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
1999-12-27 22:14:53 +08:00
|
|
|
static void set_edit_preview (void);
|
2003-07-02 08:15:09 +08:00
|
|
|
static void menu_cb (GtkWidget *widget,
|
|
|
|
gpointer data);
|
1999-12-27 22:14:53 +08:00
|
|
|
static void init_mutants (void);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
#define BUFFER_SIZE 10000
|
|
|
|
|
|
|
|
static gchar buffer[BUFFER_SIZE];
|
|
|
|
static GtkWidget *cmap_preview;
|
|
|
|
static GtkWidget *flame_preview;
|
|
|
|
static gint preview_width, preview_height;
|
|
|
|
static GtkWidget *dlg;
|
|
|
|
static GtkWidget *load_button = NULL;
|
|
|
|
static GtkWidget *save_button = NULL;
|
|
|
|
static GtkWidget *file_dlg = NULL;
|
|
|
|
static gint load_save;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
static GtkWidget *edit_dlg = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
#define SCALE_WIDTH 150
|
|
|
|
#define PREVIEW_SIZE 150
|
|
|
|
#define EDIT_PREVIEW_SIZE 85
|
|
|
|
#define NMUTANTS 9
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
static control_point edit_cp;
|
|
|
|
static control_point mutants[NMUTANTS];
|
|
|
|
static GtkWidget *edit_previews[NMUTANTS];
|
|
|
|
static gdouble pick_speed = 0.2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2000-08-22 11:27:14 +08:00
|
|
|
GimpPlugInInfo PLUG_IN_INFO =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
1997-11-25 06:05:25 +08:00
|
|
|
query, /* query_proc */
|
2000-04-01 23:48:48 +08:00
|
|
|
run, /* run_proc */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
#define BLACK_DRAWABLE (-2)
|
|
|
|
#define GRADIENT_DRAWABLE (-3)
|
|
|
|
#define TABLE_DRAWABLE (-4)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
gint randomize; /* superseded */
|
|
|
|
gint variation;
|
|
|
|
gint32 cmap_drawable;
|
1997-11-25 06:05:25 +08:00
|
|
|
control_point cp;
|
|
|
|
} config;
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
static frame_spec f = { 0.0, &config.cp, 1, 0.0 };
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
MAIN ()
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
1999-12-27 22:14:53 +08:00
|
|
|
query (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 11:27:14 +08:00
|
|
|
static GimpParamDef args[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-08-18 20:17:21 +08:00
|
|
|
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
|
|
|
|
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
|
2000-08-22 11:27:14 +08:00
|
|
|
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
gimp_install_procedure ("plug_in_flame",
|
|
|
|
"Creates cosmic recursive fractal flames",
|
|
|
|
"Creates cosmic recursive fractal flames",
|
|
|
|
"Scott Draves",
|
|
|
|
"Scott Draves",
|
|
|
|
"1997",
|
2003-08-05 02:33:25 +08:00
|
|
|
N_("<Image>/Filters/Render/Nature/_Flame..."),
|
2000-04-01 23:48:48 +08:00
|
|
|
"RGB*",
|
2000-08-22 11:27:14 +08:00
|
|
|
GIMP_PLUGIN,
|
2001-12-06 10:28:58 +08:00
|
|
|
G_N_ELEMENTS (args), 0,
|
2000-04-01 23:48:48 +08:00
|
|
|
args, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
maybe_init_cp (void)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
if (0 == config.cp.spatial_oversample)
|
|
|
|
{
|
2003-08-18 20:17:21 +08:00
|
|
|
config.randomize = 0;
|
|
|
|
config.variation = VARIATION_SAME;
|
2000-04-01 23:48:48 +08:00
|
|
|
config.cmap_drawable = GRADIENT_DRAWABLE;
|
2003-08-18 20:17:21 +08:00
|
|
|
|
|
|
|
random_control_point (&config.cp, variation_random);
|
|
|
|
|
|
|
|
config.cp.center[0] = 0.0;
|
|
|
|
config.cp.center[1] = 0.0;
|
|
|
|
config.cp.pixels_per_unit = 100;
|
|
|
|
config.cp.spatial_oversample = 2;
|
|
|
|
config.cp.gamma = 2.0;
|
|
|
|
config.cp.contrast = 1.0;
|
|
|
|
config.cp.brightness = 1.0;
|
2000-04-01 23:48:48 +08:00
|
|
|
config.cp.spatial_filter_radius = 0.75;
|
2003-08-18 20:17:21 +08:00
|
|
|
config.cp.sample_density = 5.0;
|
|
|
|
config.cp.zoom = 0.0;
|
|
|
|
config.cp.nbatches = 1;
|
|
|
|
config.cp.white_level = 200;
|
|
|
|
config.cp.cmap_index = 72;
|
2000-04-01 23:48:48 +08:00
|
|
|
/* cheating */
|
2003-08-18 20:17:21 +08:00
|
|
|
config.cp.width = 256;
|
|
|
|
config.cp.height = 256;
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
run (const gchar *name,
|
|
|
|
gint n_params,
|
|
|
|
const GimpParam *param,
|
2003-07-02 08:15:09 +08:00
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-03-26 00:38:19 +08:00
|
|
|
static GimpParam values[1];
|
|
|
|
GimpDrawable *drawable = NULL;
|
|
|
|
GimpRunMode run_mode;
|
2000-08-22 11:27:14 +08:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = values;
|
|
|
|
|
|
|
|
run_mode = param[0].data.d_int32;
|
2003-08-18 20:17:21 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
|
|
|
|
2000-08-22 11:27:14 +08:00
|
|
|
if (run_mode == GIMP_RUN_NONINTERACTIVE)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2000-08-22 11:27:14 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_get_data ("plug_in_flame", &config);
|
|
|
|
maybe_init_cp ();
|
|
|
|
|
2001-06-21 17:25:06 +08:00
|
|
|
/* reusing a drawable_ID from the last run is a bad idea
|
|
|
|
since the drawable might have vanished (bug #37761) */
|
|
|
|
if (config.cmap_drawable >= 0)
|
|
|
|
config.cmap_drawable = GRADIENT_DRAWABLE;
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
drawable = gimp_drawable_get (param[2].data.d_drawable);
|
|
|
|
config.cp.width = drawable->width;
|
|
|
|
config.cp.height = drawable->height;
|
|
|
|
|
2000-08-22 11:27:14 +08:00
|
|
|
if (run_mode == GIMP_RUN_INTERACTIVE)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
|
|
|
if (!dialog ())
|
|
|
|
{
|
2000-08-22 11:27:14 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-08-22 11:27:14 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2001-06-15 04:07:38 +08:00
|
|
|
if (gimp_drawable_is_rgb (drawable->drawable_id))
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
|
|
|
gimp_progress_init (_("Drawing Flame..."));
|
|
|
|
gimp_tile_cache_ntiles (2 * (drawable->width /
|
|
|
|
gimp_tile_width () + 1));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
doit (drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-22 11:27:14 +08:00
|
|
|
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
2000-04-01 23:48:48 +08:00
|
|
|
gimp_displays_flush ();
|
|
|
|
gimp_set_data ("plug_in_flame", &config, sizeof (config));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-08-22 11:27:14 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
|
|
|
gimp_drawable_detach (drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-08-22 11:27:14 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
1997-11-25 06:05:25 +08:00
|
|
|
values[0].data.d_status = status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-08-18 20:17:21 +08:00
|
|
|
drawable_to_cmap (control_point *cp)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2001-06-21 17:25:06 +08:00
|
|
|
gint i, j;
|
2000-08-22 11:27:14 +08:00
|
|
|
GimpPixelRgn pr;
|
|
|
|
GimpDrawable *d;
|
2001-06-21 17:25:06 +08:00
|
|
|
guchar *p;
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
if (TABLE_DRAWABLE >= config.cmap_drawable)
|
|
|
|
{
|
|
|
|
i = TABLE_DRAWABLE - config.cmap_drawable;
|
|
|
|
get_cmap (i, cp->cmap, 256);
|
|
|
|
}
|
|
|
|
else if (BLACK_DRAWABLE == config.cmap_drawable)
|
|
|
|
{
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
cp->cmap[i][j] = 0.0;
|
|
|
|
}
|
|
|
|
else if (GRADIENT_DRAWABLE == config.cmap_drawable)
|
|
|
|
{
|
2003-08-18 20:17:21 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning FIXME: "reverse" hardcoded to FALSE.
|
|
|
|
#endif
|
|
|
|
gdouble *g = gimp_gradients_sample_uniform (256, FALSE);
|
2000-04-01 23:48:48 +08:00
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
cp->cmap[i][j] = g[i*4 + j];
|
|
|
|
g_free (g);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
d = gimp_drawable_get (config.cmap_drawable);
|
|
|
|
p = g_new (guchar, d->bpp);
|
|
|
|
gimp_pixel_rgn_init (&pr, d, 0, 0,
|
|
|
|
d->width, d->height, FALSE, FALSE);
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
{
|
|
|
|
gimp_pixel_rgn_get_pixel (&pr, p, i % d->width,
|
|
|
|
(i / d->width) % d->height);
|
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
cp->cmap[i][j] =
|
|
|
|
(d->bpp >= 3) ? (p[j] / 255.0) : (p[0]/255.0);
|
|
|
|
}
|
|
|
|
g_free (p);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
2000-08-22 11:27:14 +08:00
|
|
|
doit (GimpDrawable *drawable)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
gint width, height;
|
1997-11-25 06:05:25 +08:00
|
|
|
guchar *tmp;
|
2000-04-01 23:48:48 +08:00
|
|
|
gint bytes;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
width = drawable->width;
|
1997-11-25 06:05:25 +08:00
|
|
|
height = drawable->height;
|
2000-04-01 23:48:48 +08:00
|
|
|
bytes = drawable->bpp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
if (3 != bytes && 4 != bytes)
|
|
|
|
{
|
|
|
|
g_message (_("Flame works only on RGB drawables."));
|
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
tmp = g_new (guchar, width * height * 4);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* render */
|
|
|
|
config.cp.width = width;
|
|
|
|
config.cp.height = height;
|
|
|
|
if (config.randomize)
|
2000-04-01 23:48:48 +08:00
|
|
|
random_control_point (&config.cp, config.variation);
|
|
|
|
drawable_to_cmap (&config.cp);
|
|
|
|
render_rectangle (&f, tmp, width, field_both, 4,
|
|
|
|
gimp_progress_update);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* update destination */
|
2000-04-01 23:48:48 +08:00
|
|
|
if (4 == bytes)
|
|
|
|
{
|
2000-08-22 11:27:14 +08:00
|
|
|
GimpPixelRgn pr;
|
2000-04-01 23:48:48 +08:00
|
|
|
gimp_pixel_rgn_init (&pr, drawable, 0, 0, width, height,
|
|
|
|
TRUE, TRUE);
|
|
|
|
gimp_pixel_rgn_set_rect (&pr, tmp, 0, 0, width, height);
|
|
|
|
}
|
|
|
|
else if (3 == bytes)
|
|
|
|
{
|
|
|
|
gint i, j;
|
2000-08-22 11:27:14 +08:00
|
|
|
GimpPixelRgn src_pr, dst_pr;
|
2000-04-01 23:48:48 +08:00
|
|
|
guchar *sl;
|
|
|
|
|
|
|
|
sl = g_new (guchar, 3 * width);
|
|
|
|
|
|
|
|
gimp_pixel_rgn_init (&src_pr, drawable,
|
|
|
|
0, 0, width, height, FALSE, FALSE);
|
|
|
|
gimp_pixel_rgn_init (&dst_pr, drawable,
|
|
|
|
0, 0, width, height, TRUE, TRUE);
|
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
{
|
|
|
|
guchar *rr = tmp + 4 * i * width;
|
|
|
|
guchar *sld = sl;
|
|
|
|
|
|
|
|
gimp_pixel_rgn_get_rect (&src_pr, sl, 0, i, width, 1);
|
|
|
|
for (j = 0; j < width; j++)
|
|
|
|
{
|
|
|
|
gint k, alpha = rr[3];
|
|
|
|
|
|
|
|
for (k = 0; k < 3; k++)
|
|
|
|
{
|
|
|
|
gint t = (rr[k] + ((sld[k] * (256-alpha)) >> 8));
|
|
|
|
|
|
|
|
if (t > 255) t = 255;
|
|
|
|
sld[k] = t;
|
|
|
|
}
|
|
|
|
rr += 4;
|
|
|
|
sld += 3;
|
|
|
|
}
|
|
|
|
gimp_pixel_rgn_set_rect (&dst_pr, sl, 0, i, width, 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-04-01 23:48:48 +08:00
|
|
|
g_free (sl);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
g_free (tmp);
|
|
|
|
gimp_drawable_flush (drawable);
|
2001-06-15 04:07:38 +08:00
|
|
|
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
|
|
|
gimp_drawable_update (drawable->drawable_id, 0, 0, width, height);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
2004-04-16 00:58:21 +08:00
|
|
|
file_response_callback (GtkFileChooser *chooser,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2003-11-19 22:51:52 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2004-04-16 00:58:21 +08:00
|
|
|
gchar *filename = gtk_file_chooser_get_filename (chooser);
|
2003-11-19 22:51:52 +08:00
|
|
|
|
|
|
|
if (load_save)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
gint i, c;
|
|
|
|
gchar *ss;
|
|
|
|
|
|
|
|
if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR))
|
|
|
|
{
|
2004-01-19 11:06:04 +08:00
|
|
|
g_message (_("'%s' is not a regular file"),
|
|
|
|
gimp_filename_to_utf8 (filename));
|
2004-04-16 00:58:21 +08:00
|
|
|
g_free (filename);
|
2003-11-19 22:51:52 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
f = fopen (filename, "r");
|
|
|
|
|
|
|
|
if (f == NULL)
|
|
|
|
{
|
|
|
|
g_message (_("Could not open '%s' for reading: %s"),
|
2004-01-19 11:06:04 +08:00
|
|
|
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
2004-04-16 00:58:21 +08:00
|
|
|
g_free (filename);
|
2003-11-19 22:51:52 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
ss = buffer;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
c = getc (f);
|
|
|
|
if (EOF == c)
|
|
|
|
break;
|
|
|
|
ss[i++] = c;
|
|
|
|
}
|
|
|
|
while (i < BUFFER_SIZE && ';' != c);
|
|
|
|
parse_control_point (&ss, &config.cp);
|
|
|
|
fclose (f);
|
|
|
|
/* i want to update the existing dialogue, but it's
|
|
|
|
too painful */
|
|
|
|
gimp_set_data ("plug_in_flame", &config, sizeof (config));
|
|
|
|
/* gtk_widget_destroy(dlg); */
|
|
|
|
set_flame_preview ();
|
|
|
|
set_edit_preview ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FILE *f = fopen (filename, "w");
|
|
|
|
|
|
|
|
if (NULL == f)
|
|
|
|
{
|
|
|
|
g_message (_("Could not open '%s' for writing: %s"),
|
2004-01-19 11:06:04 +08:00
|
|
|
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
2004-04-16 00:58:21 +08:00
|
|
|
g_free (filename);
|
2003-11-19 22:51:52 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
print_control_point (f, &config.cp, 0);
|
|
|
|
fclose (f);
|
|
|
|
}
|
2004-04-16 00:58:21 +08:00
|
|
|
|
|
|
|
g_free (filename);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2004-04-16 00:58:21 +08:00
|
|
|
gtk_widget_destroy (GTK_WIDGET (chooser));
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2003-11-19 22:51:52 +08:00
|
|
|
if (! GTK_WIDGET_SENSITIVE (load_button))
|
|
|
|
gtk_widget_set_sensitive (load_button, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-19 22:51:52 +08:00
|
|
|
if (! GTK_WIDGET_SENSITIVE (save_button))
|
|
|
|
gtk_widget_set_sensitive (save_button, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-03-15 12:48:18 +08:00
|
|
|
static void
|
2004-04-16 00:58:21 +08:00
|
|
|
make_file_dlg (const gchar *title,
|
|
|
|
GtkWidget *parent)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2004-04-16 00:58:21 +08:00
|
|
|
file_dlg = gtk_file_chooser_dialog_new (title, GTK_WINDOW (parent),
|
|
|
|
load_save ?
|
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN :
|
|
|
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
2003-11-10 06:44:45 +08:00
|
|
|
|
2004-04-16 00:58:21 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_STOCK_CANCEL,
|
|
|
|
load_save ?
|
|
|
|
GTK_STOCK_OPEN : GTK_STOCK_SAVE,
|
|
|
|
GTK_RESPONSE_OK,
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2004-04-16 00:58:21 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (file_dlg), (gpointer *) &file_dlg);
|
|
|
|
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (file_dlg), GTK_RESPONSE_OK);
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (file_dlg), TRUE);
|
2003-11-19 22:51:52 +08:00
|
|
|
|
|
|
|
g_signal_connect (file_dlg, "delete_event",
|
|
|
|
G_CALLBACK (gtk_true),
|
|
|
|
NULL);
|
|
|
|
g_signal_connect (file_dlg, "response",
|
|
|
|
G_CALLBACK (file_response_callback),
|
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2004-01-21 01:10:16 +08:00
|
|
|
gimp_help_connect (file_dlg, gimp_standard_help_func, HELP_ID, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
randomize_callback (GtkWidget *widget,
|
2000-04-01 23:48:48 +08:00
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
random_control_point (&edit_cp, config.variation);
|
|
|
|
init_mutants ();
|
|
|
|
set_edit_preview ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
edit_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
gtk_widget_hide (widget);
|
|
|
|
|
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
{
|
|
|
|
config.cp = edit_cp;
|
|
|
|
set_flame_preview ();
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
2000-04-01 23:48:48 +08:00
|
|
|
init_mutants (void)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
for (i = 0; i < NMUTANTS; i++)
|
|
|
|
{
|
|
|
|
mutants[i] = edit_cp;
|
|
|
|
random_control_point (mutants + i, config.variation);
|
|
|
|
if (VARIATION_SAME == config.variation)
|
|
|
|
copy_variation (mutants + i, &edit_cp);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
set_edit_preview (void)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
gint y, i, j;
|
|
|
|
guchar *b;
|
|
|
|
control_point pcp;
|
|
|
|
gint nbytes = EDIT_PREVIEW_SIZE * EDIT_PREVIEW_SIZE * 3;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
static frame_spec pf = { 0.0, 0, 1, 0.0 };
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
if (NULL == edit_previews[0])
|
|
|
|
return;
|
|
|
|
|
|
|
|
b = g_new (guchar, nbytes);
|
|
|
|
maybe_init_cp ();
|
|
|
|
drawable_to_cmap (&edit_cp);
|
1997-11-25 06:05:25 +08:00
|
|
|
for (i = 0; i < 3; i++)
|
2000-04-01 23:48:48 +08:00
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
{
|
|
|
|
gint mut = i*3 + j;
|
|
|
|
|
|
|
|
pf.cps = &pcp;
|
|
|
|
if (1 == i && 1 == j)
|
|
|
|
{
|
|
|
|
pcp = edit_cp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
control_point ends[2];
|
|
|
|
ends[0] = edit_cp;
|
|
|
|
ends[1] = mutants[mut];
|
|
|
|
ends[0].time = 0.0;
|
|
|
|
ends[1].time = 1.0;
|
|
|
|
interpolate (ends, 2, pick_speed, &pcp);
|
|
|
|
}
|
|
|
|
pcp.pixels_per_unit =
|
|
|
|
(pcp.pixels_per_unit * EDIT_PREVIEW_SIZE) / pcp.width;
|
|
|
|
pcp.width = EDIT_PREVIEW_SIZE;
|
|
|
|
pcp.height = EDIT_PREVIEW_SIZE;
|
|
|
|
|
|
|
|
pcp.sample_density = 1;
|
|
|
|
pcp.spatial_oversample = 1;
|
|
|
|
pcp.spatial_filter_radius = 0.5;
|
|
|
|
|
|
|
|
drawable_to_cmap (&pcp);
|
|
|
|
|
|
|
|
render_rectangle (&pf, b, EDIT_PREVIEW_SIZE, field_both, 3, NULL);
|
|
|
|
|
|
|
|
for (y = 0; y < EDIT_PREVIEW_SIZE; y++)
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (edit_previews[mut]),
|
|
|
|
b + y * EDIT_PREVIEW_SIZE * 3,
|
|
|
|
0, y, EDIT_PREVIEW_SIZE);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_queue_draw (edit_previews[mut]);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-04-01 23:48:48 +08:00
|
|
|
g_free (b);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
preview_clicked (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2003-01-06 04:38:21 +08:00
|
|
|
gint mut = GPOINTER_TO_INT (data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
if (mut == 4)
|
|
|
|
{
|
|
|
|
control_point t = edit_cp;
|
|
|
|
init_mutants ();
|
|
|
|
edit_cp = t;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
control_point ends[2];
|
|
|
|
ends[0] = edit_cp;
|
|
|
|
ends[1] = mutants[mut];
|
|
|
|
ends[0].time = 0.0;
|
|
|
|
ends[1].time = 1.0;
|
|
|
|
interpolate (ends, 2, pick_speed, &edit_cp);
|
|
|
|
}
|
|
|
|
set_edit_preview ();
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-03-15 12:48:18 +08:00
|
|
|
static void
|
2003-08-18 20:17:21 +08:00
|
|
|
edit_callback (GtkWidget *widget,
|
2003-11-06 23:27:05 +08:00
|
|
|
GtkWidget *parent)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
edit_cp = config.cp;
|
1999-12-27 22:14:53 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
if (edit_dlg == NULL)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *vbox;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *hbox;
|
2000-04-01 23:48:48 +08:00
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *optionmenu;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkObject *adj;
|
2003-11-06 23:27:05 +08:00
|
|
|
gint i, j;
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
edit_dlg = gimp_dialog_new (_("Edit Flame"), "flame",
|
2003-11-06 23:27:05 +08:00
|
|
|
parent, GTK_DIALOG_DESTROY_WITH_PARENT,
|
2004-01-21 01:10:16 +08:00
|
|
|
gimp_standard_help_func, HELP_ID,
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2002-02-05 21:29:46 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
g_signal_connect (edit_dlg, "response",
|
|
|
|
G_CALLBACK (edit_response),
|
|
|
|
edit_dlg);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
main_vbox = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (edit_dlg)->vbox), main_vbox,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
frame = gtk_frame_new (_("Directions"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
table = gtk_table_new (3, 3, FALSE);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), table);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
{
|
|
|
|
gint mut = i * 3 + j;
|
|
|
|
|
|
|
|
edit_previews[mut] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (edit_previews[mut]),
|
|
|
|
EDIT_PREVIEW_SIZE, EDIT_PREVIEW_SIZE);
|
|
|
|
button = gtk_button_new ();
|
|
|
|
gtk_container_add (GTK_CONTAINER(button), edit_previews[mut]);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), button, i, i+1, j, j+1,
|
|
|
|
GTK_EXPAND, GTK_EXPAND, 0, 0);
|
|
|
|
gtk_widget_show (edit_previews[mut]);
|
|
|
|
gtk_widget_show (button);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (preview_clicked),
|
|
|
|
GINT_TO_POINTER (mut));
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
frame = gtk_frame_new( _("Controls"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
table = gtk_table_new (1, 3, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(table);
|
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
|
2002-06-03 03:55:30 +08:00
|
|
|
_("_Speed:"), SCALE_WIDTH, 0,
|
2000-04-01 23:48:48 +08:00
|
|
|
pick_speed,
|
|
|
|
0.05, 0.5, 0.01, 0.1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
NULL, NULL);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&pick_speed);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_edit_preview),
|
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-12-27 22:14:53 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2002-06-03 03:55:30 +08:00
|
|
|
button = gtk_button_new_with_mnemonic( _("_Randomize"));
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect_swapped (button, "clicked",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (randomize_callback),
|
|
|
|
NULL);
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
optionmenu =
|
2003-11-15 02:05:39 +08:00
|
|
|
gimp_int_option_menu_new (FALSE, G_CALLBACK (menu_cb),
|
|
|
|
&config.variation, VARIATION_SAME,
|
|
|
|
|
|
|
|
_("Same"), VARIATION_SAME, NULL,
|
|
|
|
_("Random"), variation_random, NULL,
|
|
|
|
_("Linear"), 0, NULL,
|
|
|
|
_("Sinusoidal"), 1, NULL,
|
|
|
|
_("Spherical"), 2, NULL,
|
|
|
|
_("Swirl"), 3, NULL,
|
|
|
|
_("Horseshoe"), 4, NULL,
|
|
|
|
_("Polar"), 5, NULL,
|
|
|
|
_("Bent"), 6, NULL,
|
|
|
|
|
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), optionmenu, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (optionmenu);
|
|
|
|
|
2002-06-03 03:55:30 +08:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_Variation:"));
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
2002-06-03 03:55:30 +08:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), optionmenu);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
gtk_widget_show (main_vbox);
|
|
|
|
|
|
|
|
init_mutants ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
set_edit_preview ();
|
|
|
|
|
2002-10-25 09:11:24 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (edit_dlg));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
load_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2002-10-25 09:11:24 +08:00
|
|
|
if (! file_dlg)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2004-04-16 00:58:21 +08:00
|
|
|
load_save = 1;
|
|
|
|
make_file_dlg (_("Load Flame"), gtk_widget_get_toplevel (widget));
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (save_button, FALSE);
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
2004-04-16 00:58:21 +08:00
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (file_dlg));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
save_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2004-04-16 00:58:21 +08:00
|
|
|
if (! file_dlg)
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
2004-04-16 00:58:21 +08:00
|
|
|
load_save = 0;
|
|
|
|
make_file_dlg (_("Save Flame"), gtk_widget_get_toplevel (widget));
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (load_button, FALSE);
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
2004-04-16 00:58:21 +08:00
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (file_dlg));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
menu_cb (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
gimp_menu_item_update (widget, data);
|
|
|
|
|
|
|
|
if (VARIATION_SAME != config.variation)
|
|
|
|
random_control_point (&edit_cp, config.variation);
|
|
|
|
init_mutants ();
|
|
|
|
set_edit_preview ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
set_flame_preview (void)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
gint y;
|
1997-11-25 06:05:25 +08:00
|
|
|
guchar *b;
|
|
|
|
control_point pcp;
|
2000-04-01 23:48:48 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static frame_spec pf = {0.0, 0, 1, 0.0};
|
|
|
|
|
|
|
|
if (NULL == flame_preview)
|
|
|
|
return;
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
b = g_new (guchar, preview_width * preview_height * 3);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
maybe_init_cp ();
|
|
|
|
drawable_to_cmap (&config.cp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
pf.cps = &pcp;
|
|
|
|
pcp = config.cp;
|
|
|
|
pcp.pixels_per_unit =
|
|
|
|
(pcp.pixels_per_unit * preview_width) / pcp.width;
|
|
|
|
pcp.width = preview_width;
|
|
|
|
pcp.height = preview_height;
|
|
|
|
pcp.sample_density = 1;
|
|
|
|
pcp.spatial_oversample = 1;
|
|
|
|
pcp.spatial_filter_radius = 0.1;
|
2000-04-01 23:48:48 +08:00
|
|
|
render_rectangle (&pf, b, preview_width, field_both, 3, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
for (y = 0; y < PREVIEW_SIZE; y++)
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (flame_preview),
|
|
|
|
b+y*preview_width*3, 0, y, preview_width);
|
|
|
|
g_free (b);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_queue_draw (flame_preview);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
set_cmap_preview (void)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
gint i, x, y;
|
1997-11-25 06:05:25 +08:00
|
|
|
guchar b[96];
|
|
|
|
|
|
|
|
if (NULL == cmap_preview)
|
|
|
|
return;
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
drawable_to_cmap (&config.cp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
for (y = 0; y < 32; y += 4)
|
|
|
|
{
|
|
|
|
for (x = 0; x < 32; x++)
|
|
|
|
{
|
|
|
|
gint j;
|
|
|
|
|
|
|
|
i = x + (y/4) * 32;
|
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
b[x*3+j] = config.cp.cmap[i][j]*255.0;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (cmap_preview), b, 0, y, 32);
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (cmap_preview), b, 0, y+1, 32);
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (cmap_preview), b, 0, y+2, 32);
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (cmap_preview), b, 0, y+3, 32);
|
|
|
|
}
|
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_queue_draw (cmap_preview);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
gradient_cb (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2003-01-06 04:38:21 +08:00
|
|
|
config.cmap_drawable = GPOINTER_TO_INT (data);
|
1997-11-25 06:05:25 +08:00
|
|
|
set_cmap_preview();
|
|
|
|
set_flame_preview();
|
2000-04-01 23:48:48 +08:00
|
|
|
/* set_edit_preview(); */
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static void
|
|
|
|
cmap_callback (gint32 id,
|
|
|
|
gpointer data)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
config.cmap_drawable = id;
|
|
|
|
set_cmap_preview();
|
|
|
|
set_flame_preview();
|
|
|
|
/* set_edit_preview(); */
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2003-08-18 20:17:21 +08:00
|
|
|
cmap_constrain (gint32 image_id,
|
|
|
|
gint32 drawable_id,
|
|
|
|
gpointer data)
|
|
|
|
{
|
1999-10-17 08:07:55 +08:00
|
|
|
return ! gimp_drawable_is_indexed (drawable_id);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
static gint
|
|
|
|
dialog (void)
|
1999-12-27 22:14:53 +08:00
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
GtkWidget *main_vbox;
|
2002-06-03 03:55:30 +08:00
|
|
|
GtkWidget *notebook;
|
|
|
|
GtkWidget *label;
|
2000-04-01 23:48:48 +08:00
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *abox;
|
|
|
|
GtkWidget *pframe;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *box;
|
2000-04-01 23:48:48 +08:00
|
|
|
GtkObject *adj;
|
2003-11-06 23:27:05 +08:00
|
|
|
gboolean run;
|
2000-05-01 02:17:55 +08:00
|
|
|
|
|
|
|
gimp_ui_init ("flame", TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
dlg = gimp_dialog_new (_("Flame"), "flame",
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL, 0,
|
2004-01-21 01:10:16 +08:00
|
|
|
gimp_standard_help_func, HELP_ID,
|
2000-04-01 23:48:48 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
NULL);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
main_vbox = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (main_vbox);
|
|
|
|
|
|
|
|
box = gtk_hbox_new (FALSE, 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), box, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (box);
|
|
|
|
|
|
|
|
frame = gtk_frame_new (_("Preview"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (abox), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), abox);
|
|
|
|
gtk_widget_show (abox);
|
|
|
|
|
|
|
|
pframe = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (pframe), GTK_SHADOW_IN);
|
|
|
|
gtk_container_add (GTK_CONTAINER (abox), pframe);
|
|
|
|
gtk_widget_show (pframe);
|
|
|
|
|
|
|
|
frame = gtk_frame_new (_("Flame"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
{
|
|
|
|
GtkWidget *vbbox;
|
|
|
|
|
|
|
|
box = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (box), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), box);
|
|
|
|
gtk_widget_show (box);
|
|
|
|
|
|
|
|
vbbox= gtk_vbutton_box_new ();
|
|
|
|
gtk_box_set_homogeneous (GTK_BOX (vbbox), FALSE);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_box_set_spacing (GTK_BOX (vbbox), 4);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (box), vbbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (vbbox);
|
2003-08-18 20:17:21 +08:00
|
|
|
|
2002-09-08 00:31:32 +08:00
|
|
|
button = gtk_button_new_from_stock (GIMP_STOCK_EDIT);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (edit_callback),
|
2003-11-06 23:27:05 +08:00
|
|
|
dlg);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2002-09-08 00:31:32 +08:00
|
|
|
load_button = button = gtk_button_new_from_stock (GTK_STOCK_OPEN);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (load_callback),
|
|
|
|
NULL);
|
|
|
|
|
2002-09-08 00:31:32 +08:00
|
|
|
save_button = button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (save_callback),
|
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
}
|
|
|
|
|
2002-06-03 03:55:30 +08:00
|
|
|
notebook = gtk_notebook_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), notebook, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (notebook);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-12-27 22:14:53 +08:00
|
|
|
box = gtk_vbox_new (FALSE, 4);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (box), 4);
|
2002-06-03 03:55:30 +08:00
|
|
|
label = gtk_label_new_with_mnemonic(_("_Rendering"));
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_widget_show (box);
|
|
|
|
|
|
|
|
table = gtk_table_new (6, 3, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 2, 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
|
2002-09-07 04:44:47 +08:00
|
|
|
_("_Brightness:"), SCALE_WIDTH, 5,
|
2000-04-01 23:48:48 +08:00
|
|
|
config.cp.brightness,
|
|
|
|
0, 5, 0.1, 1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
NULL, NULL);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&config.cp.brightness);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_flame_preview),
|
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
|
2002-09-07 04:44:47 +08:00
|
|
|
_("Co_ntrast:"), SCALE_WIDTH, 5,
|
2000-04-01 23:48:48 +08:00
|
|
|
config.cp.contrast,
|
|
|
|
0, 5, 0.1, 1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
NULL, NULL);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&config.cp.contrast);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_flame_preview),
|
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
|
2002-09-07 04:44:47 +08:00
|
|
|
_("_Gamma:"), SCALE_WIDTH, 5,
|
2000-04-01 23:48:48 +08:00
|
|
|
config.cp.gamma,
|
|
|
|
1, 5, 0.1, 1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
NULL, NULL);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&config.cp.gamma);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_flame_preview),
|
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 3,
|
2002-09-07 04:44:47 +08:00
|
|
|
_("Sample _Density:"), SCALE_WIDTH, 5,
|
2000-04-01 23:48:48 +08:00
|
|
|
config.cp.sample_density,
|
|
|
|
0.1, 20, 1, 5, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
NULL, NULL);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&config.cp.sample_density);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 4,
|
2002-09-07 04:44:47 +08:00
|
|
|
_("Spa_tial Oversample:"), SCALE_WIDTH, 5,
|
2000-04-01 23:48:48 +08:00
|
|
|
config.cp.spatial_oversample,
|
2003-04-12 00:23:56 +08:00
|
|
|
1, 4, 0.01, 0.1, 0,
|
2000-04-01 23:48:48 +08:00
|
|
|
TRUE, 0, 0,
|
|
|
|
NULL, NULL);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_int_adjustment_update),
|
|
|
|
&config.cp.spatial_oversample);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 5,
|
2002-09-07 04:44:47 +08:00
|
|
|
_("Spatial _Filter Radius:"), SCALE_WIDTH, 5,
|
2000-04-01 23:48:48 +08:00
|
|
|
config.cp.spatial_filter_radius,
|
|
|
|
0, 4, 0.2, 1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
NULL, NULL);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&config.cp.spatial_filter_radius);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
{
|
|
|
|
GtkWidget *sep;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *hbox;
|
2000-04-01 23:48:48 +08:00
|
|
|
GtkWidget *label;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *menuitem;
|
2000-04-01 23:48:48 +08:00
|
|
|
GtkWidget *option_menu;
|
1997-11-25 06:05:25 +08:00
|
|
|
gint32 save_drawable = config.cmap_drawable;
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
sep = gtk_hseparator_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), sep, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (sep);
|
|
|
|
|
1999-12-27 22:14:53 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-06-03 03:55:30 +08:00
|
|
|
label = gtk_label_new_with_mnemonic (_("Color_map:"));
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
option_menu = gtk_option_menu_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), option_menu, FALSE, FALSE, 0);
|
2002-06-03 03:55:30 +08:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), option_menu);
|
2000-04-01 23:48:48 +08:00
|
|
|
menu = gimp_drawable_menu_new (cmap_constrain, cmap_callback,
|
|
|
|
0, config.cmap_drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
config.cmap_drawable = save_drawable;
|
|
|
|
#if 0
|
2000-04-01 23:48:48 +08:00
|
|
|
menuitem = gtk_menu_item_new_with_label (_("Black"));
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (menuitem, "activate",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gradient_cb),
|
|
|
|
(gpointer) BLACK_DRAWABLE);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_menu_prepend (GTK_MENU (menu), menuitem);
|
|
|
|
if (BLACK_DRAWABLE == save_drawable)
|
|
|
|
gtk_menu_set_active (GTK_MENU (menu), 0);
|
2003-08-18 20:17:21 +08:00
|
|
|
gtk_widget_show (menuitem);
|
1997-11-25 06:05:25 +08:00
|
|
|
#endif
|
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
static gchar *names[] =
|
|
|
|
{
|
|
|
|
"sunny harvest",
|
|
|
|
"rose",
|
|
|
|
"calcoast09",
|
|
|
|
"klee insula-dulcamara",
|
|
|
|
"ernst anti-pope",
|
|
|
|
"gris josette"
|
|
|
|
};
|
|
|
|
static gint good[] = { 10, 20, 68, 79, 70, 75 };
|
2001-12-06 10:28:58 +08:00
|
|
|
gint i, n = G_N_ELEMENTS (good);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
gint d = TABLE_DRAWABLE - good[i];
|
|
|
|
|
|
|
|
menuitem = gtk_menu_item_new_with_label (names[i]);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (menuitem, "activate",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gradient_cb),
|
2003-01-06 04:38:21 +08:00
|
|
|
GINT_TO_POINTER (d));
|
2001-07-29 18:20:02 +08:00
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
2000-04-01 23:48:48 +08:00
|
|
|
if (d == save_drawable)
|
|
|
|
gtk_menu_set_active (GTK_MENU (menu), 0);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
menuitem = gtk_menu_item_new_with_label (_("Custom Gradient"));
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (menuitem, "activate",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gradient_cb),
|
|
|
|
(gpointer) GRADIENT_DRAWABLE);
|
2001-07-29 18:20:02 +08:00
|
|
|
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
2000-04-01 23:48:48 +08:00
|
|
|
if (GRADIENT_DRAWABLE == save_drawable)
|
|
|
|
gtk_menu_set_active (GTK_MENU (menu), 0);
|
|
|
|
gtk_widget_show (menuitem);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
|
|
|
|
gtk_widget_show (option_menu);
|
|
|
|
|
|
|
|
cmap_preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (cmap_preview), 32, 32);
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), cmap_preview, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (cmap_preview);
|
2000-04-01 23:48:48 +08:00
|
|
|
set_cmap_preview ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
table = gtk_table_new (3, 3, FALSE);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
2002-06-03 03:55:30 +08:00
|
|
|
label = gtk_label_new_with_mnemonic(_("C_amera"));
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, label);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
|
2002-06-03 03:55:30 +08:00
|
|
|
_("_Zoom:"), SCALE_WIDTH, 0,
|
2000-04-01 23:48:48 +08:00
|
|
|
config.cp.zoom,
|
|
|
|
-4, 4, 0.5, 1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
NULL, NULL);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&config.cp.zoom);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_flame_preview),
|
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
|
2002-06-03 03:55:30 +08:00
|
|
|
_("_X:"), SCALE_WIDTH, 0,
|
2000-04-01 23:48:48 +08:00
|
|
|
config.cp.center[0],
|
|
|
|
-2, 2, 0.5, 1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
NULL, NULL);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&config.cp.center[0]);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_flame_preview),
|
|
|
|
NULL);
|
2000-04-01 23:48:48 +08:00
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
|
2002-06-03 03:55:30 +08:00
|
|
|
_("_Y:"), SCALE_WIDTH, 0,
|
2000-04-01 23:48:48 +08:00
|
|
|
config.cp.center[1],
|
|
|
|
-2, 2, 0.5, 1, 2,
|
|
|
|
TRUE, 0, 0,
|
|
|
|
NULL, NULL);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&config.cp.center[1]);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (adj, "value_changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (set_flame_preview),
|
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
flame_preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
|
|
{
|
2000-04-01 23:48:48 +08:00
|
|
|
gdouble aspect = config.cp.width / (double) config.cp.height;
|
|
|
|
|
|
|
|
if (aspect > 1.0)
|
|
|
|
{
|
|
|
|
preview_width = PREVIEW_SIZE;
|
|
|
|
preview_height = PREVIEW_SIZE / aspect;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
preview_width = PREVIEW_SIZE * aspect;
|
|
|
|
preview_height = PREVIEW_SIZE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
gtk_preview_size (GTK_PREVIEW (flame_preview), preview_width, preview_height);
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (pframe), flame_preview);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (flame_preview);
|
2000-04-01 23:48:48 +08:00
|
|
|
set_flame_preview ();
|
1999-12-27 22:14:53 +08:00
|
|
|
|
2000-04-01 23:48:48 +08:00
|
|
|
gtk_widget_show (dlg);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-12 02:11:56 +08:00
|
|
|
run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
|
|
|
gtk_widget_destroy (dlg);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
return run;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|