gimp/plug-ins/common/scatter_hsv.c

619 lines
16 KiB
C
Raw Normal View History

1997-11-25 06:05:25 +08:00
/* scatter_hsv.c -- This is a plug-in for the GIMP (1.0's API)
* Author: Shuji Narazaki <narazaki@InetQ.or.jp>
* Time-stamp: <2000-01-08 02:49:39 yasuhiro>
1997-11-25 06:05:25 +08:00
* Version: 0.42
*
* Copyright (C) 1997 Shuji Narazaki <narazaki@InetQ.or.jp>
*
* 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.
1997-11-25 06:05:25 +08:00
*/
#include "config.h"
1997-11-25 06:05:25 +08:00
#include <stdio.h>
#include <stdlib.h>
derive from GtkDrawingArea instead of deprecated GtkPreview. 2002-01-30 Sven Neumann <sven@gimp.org> * libgimpwidgets/gimpcolorarea.[ch]: derive from GtkDrawingArea instead of deprecated GtkPreview. * app/nav_window.c * app/gui/brush-editor.c * app/gui/buffers-commands.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/device-status-dialog.c * app/gui/dialogs-constructors.c * app/gui/file-open-dialog.c * app/gui/gradient-editor.c * app/gui/indicator-area.c * app/gui/info-window.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palettes-commands.c * app/gui/test-commands.c * app/gui/tool-options-dialog.c * app/gui/toolbox.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpdnd.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpimagedock.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.c * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.c * libgimp/gimpbrushmenu.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * plug-ins/FractalExplorer/Dialogs.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/blinds.c * plug-ins/common/curve_bend.c * plug-ins/common/depthmerge.c * plug-ins/common/despeckle.c * plug-ins/common/destripe.c * plug-ins/common/diffraction.c * plug-ins/common/emboss.c * plug-ins/common/exchange.c * plug-ins/common/flarefx.c * plug-ins/common/fractaltrace.c * plug-ins/common/glasstile.c * plug-ins/common/gqbist.c * plug-ins/common/grid.c * plug-ins/common/illusion.c * plug-ins/common/iwarp.c * plug-ins/common/jigsaw.c * plug-ins/common/mapcolor.c * plug-ins/common/max_rgb.c * plug-ins/common/newsprint.c * plug-ins/common/nlfilt.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/sharpen.c * plug-ins/common/sinus.c * plug-ins/common/tileit.c * plug-ins/common/video.c * plug-ins/common/waves.c * plug-ins/common/whirlpinch.c * plug-ins/common/wind.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/gimpressionist/brush.c * plug-ins/mosaic/mosaic.c * plug-ins/rcm/rcm_dialog.c: define GTK_DISABLE_DEPRECATED to make it compile. We really need a generic plug-in preview system that doesn't use GtkPreview.
2002-01-30 22:54:27 +08:00
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#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
#define PLUG_IN_NAME "plug_in_scatter_hsv"
#define SHORT_NAME "scatter_hsv"
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static GimpPDBStatusType scatter_hsv (gint32 drawable_id);
static void scatter_hsv_scatter (guchar *r,
guchar *g,
guchar *b);
static gint randomize_value (gint now,
gint min,
gint max,
gint mod_p,
gint rand_max);
static gint scatter_hsv_dialog (void);
static void scatter_hsv_ok_callback (GtkWidget *widget,
gpointer data);
static gint preview_event_handler (GtkWidget *widget,
GdkEvent *event);
static void scatter_hsv_preview_update (void);
static void scatter_hsv_iscale_update (GtkAdjustment *adjustment,
gpointer data);
#define PROGRESS_UPDATE_NUM 100
#define PREVIEW_WIDTH 128
#define PREVIEW_HEIGHT 128
#define SCALE_WIDTH 100
changed "Number of Colors" to "Max Number of Colors" to clarify what this 2002-09-06 Michael Natterer <mitch@gimp.org> * app/gui/convert-dialog.c: changed "Number of Colors" to "Max Number of Colors" to clarify what this parameter does. (fixes #92194). * app/gui/menus.c: use GIMP_STOCK_INFO for "View/Info Window". Specify spibutton sizes in chars, not pixels (eek) all over the place. Also removed explicit sizes where the GtkSpinButton default size does not disturbe tabular widget layouts. * libgimpwidgets/gimpwidgets.c: removed the hardcoded width of 75 pixels in gimp_spin_button_new(). Changed gimp_scale_entry_new() and gimp_coordinates_new() to interpret their "spinbutton_width" parameters as chars if < 16, and as pixels otherwise. This gives reasonable results and doesn't cause unchanged plug-ins to suddenly have spinbuttons of dozens of chars width :) * libgimpwidgets/gimpsizeentry.c: added the same heuristic here. * libgimpwidgets/gimpquerybox.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/tools/gimpairbrushtool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpdodgeburntool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpposterizetool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.c * app/widgets/gimppaletteeditor.c: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/bumpmap.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/depthmerge.c * plug-ins/common/despeckle.c * plug-ins/common/diffraction.c * plug-ins/common/emboss.c * plug-ins/common/film.c * plug-ins/common/flarefx.c * plug-ins/common/fractaltrace.c * plug-ins/common/gauss_iir.c * plug-ins/common/gauss_rle.c * plug-ins/common/glasstile.c * plug-ins/common/grid.c * plug-ins/common/illusion.c * plug-ins/common/iwarp.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/max_rgb.c * plug-ins/common/mblur.c * plug-ins/common/newsprint.c * plug-ins/common/nova.c * plug-ins/common/pixelize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/spread.c * plug-ins/common/tile.c * plug-ins/common/tileit.c * plug-ins/common/unsharp.c * plug-ins/common/vpropagate.c * plug-ins/common/waves.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/mosaic/mosaic.c * plug-ins/rcm/rcm_dialog.c: changed accordingly, which involves removals of gtk_widget_set_size_request(spinbutton), removal of lots of explicit spinbutton sizes in gimp_scale_entry_new(), and adding of new ones because GtkSpinButton's auto-size trashed tabular layouts. Lots of cleanup & indentation while browsing the plug-ins' code. Changed spacings, moved toggle buttons into frame titles, use stock items, stuff...
2002-09-07 04:44:47 +08:00
#define ENTRY_WIDTH 3
static gint preview_width = PREVIEW_WIDTH;
static gint preview_height = PREVIEW_HEIGHT;
static GimpRunMode run_mode;
GimpPlugInInfo PLUG_IN_INFO =
1997-11-25 06:05:25 +08:00
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
1997-11-25 06:05:25 +08:00
};
typedef struct
{ /* gint, gdouble, and so on */
gint holdness;
gint hue_distance;
gint saturation_distance;
gint value_distance;
} ValueType;
static ValueType VALS =
{
2,
3,
10,
10
1997-11-25 06:05:25 +08:00
};
typedef struct
{
gboolean run;
1997-11-25 06:05:25 +08:00
} Interface;
static Interface INTERFACE =
{
FALSE
};
static gint drawable_id;
static GtkWidget *preview;
static gint preview_start_x = 0;
static gint preview_start_y = 0;
static guchar *preview_buffer = NULL;
static gint preview_offset_x = 0;
static gint preview_offset_y = 0;
static gint preview_dragging = FALSE;
static gint preview_drag_start_x = 0;
static gint preview_drag_start_y = 0;
1997-11-25 06:05:25 +08:00
MAIN ()
1997-11-25 06:05:25 +08:00
static void
query (void)
1997-11-25 06:05:25 +08:00
{
static GimpParamDef args [] =
1997-11-25 06:05:25 +08:00
{
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{ GIMP_PDB_IMAGE, "image", "Input image (not used)"},
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable"},
{ GIMP_PDB_INT32, "holdness", "convolution strength"},
{ GIMP_PDB_INT32, "hue_distance", "distribution distance on hue axis [0,255]"},
{ GIMP_PDB_INT32, "saturation_distance", "distribution distance on saturation axis [0,255]"},
{ GIMP_PDB_INT32, "value_distance", "distribution distance on value axis [0,255]"}
1997-11-25 06:05:25 +08:00
};
1997-11-25 06:05:25 +08:00
gimp_install_procedure (PLUG_IN_NAME,
"Scattering pixel values in HSV space",
"Scattering pixel values in HSV space",
1997-11-25 06:05:25 +08:00
"Shuji Narazaki (narazaki@InetQ.or.jp)",
"Shuji Narazaki",
"1997",
N_("<Image>/Filters/Noise/S_catter HSV..."),
1997-11-25 06:05:25 +08:00
"RGB*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
1997-11-25 06:05:25 +08:00
}
static void
run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
1997-11-25 06:05:25 +08:00
{
static GimpParam values[1];
GimpPDBStatusType status = GIMP_PDB_EXECUTION_ERROR;
1997-11-25 06:05:25 +08:00
INIT_I18N ();
1997-11-25 06:05:25 +08:00
run_mode = param[0].data.d_int32;
drawable_id = param[2].data.d_int32;
*nreturn_vals = 1;
*return_vals = values;
1997-11-25 06:05:25 +08:00
values[0].type = GIMP_PDB_STATUS;
1997-11-25 06:05:25 +08:00
values[0].data.d_status = status;
switch (run_mode)
1997-11-25 06:05:25 +08:00
{
case GIMP_RUN_INTERACTIVE:
1997-11-25 06:05:25 +08:00
gimp_get_data (PLUG_IN_NAME, &VALS);
if (!gimp_drawable_is_rgb (drawable_id))
1997-11-25 06:05:25 +08:00
{
Cleaned up and improved the message system: 2003-06-13 Michael Natterer <mitch@gimp.org> Cleaned up and improved the message system: * app/core/gimp.[ch]: added "const gchar *domain" to GimpMessageFunc (a NULL domain means the message is from the GIMP core, everything else is a plug-in). * app/errors.c: pass "domain == NULL" to gimp_message(). * tools/pdbgen/pdb/message.pdb: derive the message domain from the current plug-in's menu_path (evil hack but works reasonably well). * app/pdb/message_cmds.c: regenerated. * app/widgets/gimpwidgets-utils.[ch] (gimp_message_box): added a header showing the message domain and changed the dialog layout to follow the HIG more closely. * app/gui/error-console-dialog.[ch]: removed. * app/widgets/gimperrorconsole.[ch] * app/gui/error-console-commands.[ch] * app/gui/error-console-menu.[ch]: new files containing a re-implementation of the error console dialog. * app/gui/Makefile.am * app/gui/dialogs-constructors.c * app/gui/gui.c * app/gui/menus.c * app/widgets/Makefile.am * app/widgets/widgets-types.h: changed accordingly. * app/display/gimpprogress.c: added more spacing and removed the separator (more HIG compliant). * plug-ins/[most plug-ins].c: Changed lots of messages and progress strings: - Removed plug-in names from messages since that's automatically covered by "domain" now. - Put all filenames in ''. - Changed "Loading" to "Opening". - Added "..." to all progress messages. - Cleaned up all file open/save error messages to look the same and include g_strerror(errno). - Removed special casing for progress bars and *always* show them, not only if run_mode != GIMP_RUN_NONINTERACTIVE (we can't expect all plug-ins to do this correctly but need to hack the core to sort out unwanted progress bars). Unrelated: - Cleaned up indentation, spacing, #includes, coding style and other stuff while I was at all these files.
2003-06-13 22:37:00 +08:00
g_message ("Cannot operate on non-RGB drawables.");
1997-11-25 06:05:25 +08:00
return;
}
if (! scatter_hsv_dialog ())
1997-11-25 06:05:25 +08:00
return;
break;
case GIMP_RUN_NONINTERACTIVE:
1997-11-25 06:05:25 +08:00
VALS.holdness = param[3].data.d_int32;
VALS.hue_distance = param[4].data.d_int32;
VALS.saturation_distance = param[5].data.d_int32;
VALS.value_distance = param[6].data.d_int32;
break;
case GIMP_RUN_WITH_LAST_VALS:
1997-11-25 06:05:25 +08:00
gimp_get_data (PLUG_IN_NAME, &VALS);
break;
}
status = scatter_hsv (drawable_id);
1997-11-25 06:05:25 +08:00
if (run_mode != GIMP_RUN_NONINTERACTIVE)
1997-11-25 06:05:25 +08:00
gimp_displays_flush();
if (run_mode == GIMP_RUN_INTERACTIVE && status == GIMP_PDB_SUCCESS )
1997-11-25 06:05:25 +08:00
gimp_set_data (PLUG_IN_NAME, &VALS, sizeof (ValueType));
values[0].type = GIMP_PDB_STATUS;
1997-11-25 06:05:25 +08:00
values[0].data.d_status = status;
}
static void
scatter_hsv_func (const guchar *src,
guchar *dest,
gint bpp,
gpointer data)
{
guchar h, s, v;
h = src[0];
s = src[1];
v = src[2];
scatter_hsv_scatter (&h, &s, &v);
dest[0] = h;
dest[1] = s;
dest[2] = v;
if (bpp == 4)
dest[3] = src[3];
}
static GimpPDBStatusType
scatter_hsv (gint32 drawable_id)
1997-11-25 06:05:25 +08:00
{
GimpDrawable *drawable;
1997-11-25 06:05:25 +08:00
drawable = gimp_drawable_get (drawable_id);
gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width () + 1));
Cleaned up and improved the message system: 2003-06-13 Michael Natterer <mitch@gimp.org> Cleaned up and improved the message system: * app/core/gimp.[ch]: added "const gchar *domain" to GimpMessageFunc (a NULL domain means the message is from the GIMP core, everything else is a plug-in). * app/errors.c: pass "domain == NULL" to gimp_message(). * tools/pdbgen/pdb/message.pdb: derive the message domain from the current plug-in's menu_path (evil hack but works reasonably well). * app/pdb/message_cmds.c: regenerated. * app/widgets/gimpwidgets-utils.[ch] (gimp_message_box): added a header showing the message domain and changed the dialog layout to follow the HIG more closely. * app/gui/error-console-dialog.[ch]: removed. * app/widgets/gimperrorconsole.[ch] * app/gui/error-console-commands.[ch] * app/gui/error-console-menu.[ch]: new files containing a re-implementation of the error console dialog. * app/gui/Makefile.am * app/gui/dialogs-constructors.c * app/gui/gui.c * app/gui/menus.c * app/widgets/Makefile.am * app/widgets/widgets-types.h: changed accordingly. * app/display/gimpprogress.c: added more spacing and removed the separator (more HIG compliant). * plug-ins/[most plug-ins].c: Changed lots of messages and progress strings: - Removed plug-in names from messages since that's automatically covered by "domain" now. - Put all filenames in ''. - Changed "Loading" to "Opening". - Added "..." to all progress messages. - Cleaned up all file open/save error messages to look the same and include g_strerror(errno). - Removed special casing for progress bars and *always* show them, not only if run_mode != GIMP_RUN_NONINTERACTIVE (we can't expect all plug-ins to do this correctly but need to hack the core to sort out unwanted progress bars). Unrelated: - Cleaned up indentation, spacing, #includes, coding style and other stuff while I was at all these files.
2003-06-13 22:37:00 +08:00
gimp_progress_init (_("Scattering HSV..."));
1997-11-25 06:05:25 +08:00
gimp_rgn_iterate2 (drawable, run_mode, scatter_hsv_func, NULL);
1997-11-25 06:05:25 +08:00
gimp_drawable_detach (drawable);
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c 2002-11-20 Dave Neary <bolsh@gimp.org> * configure.in * app/core/gimpbrushpipe.c * app/gui/about-dialog.c * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.c * libgimpmath/gimpmath.h * libgimpwidgets/gimpwidgets.c * plug-ins/common/CML_explorer.c * plug-ins/common/blur.c * plug-ins/common/cubism.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/gqbist.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/warp.c * plug-ins/common/wind.c * plug-ins/flame/cmap.c * plug-ins/flame/flame.c * plug-ins/flame/libifs.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/plasma.c * plug-ins/gimpressionist/repaint.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c * plug-ins/maze/maze.h * plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX, G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(), srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand* equivalent. Programs which require seed setting for reproducible results, and anything in the core, gets a dedicated GRand * for the lifetime required. Programs which only ever used random numbers for tossing a coin, rolling a dice, etc use g_random functions. For the rest, judgement was used. Where it was easy, a GRand * object was used and g_rand_* functions were preferred. This fixes bug #67386 in HEAD.
2002-11-20 17:27:48 +08:00
return GIMP_PDB_SUCCESS;
1997-11-25 06:05:25 +08:00
}
static gint
randomize_value (gint now,
gint min,
gint max,
gint mod_p,
gint rand_max)
1997-11-25 06:05:25 +08:00
{
gint flag, new, steps, index;
gdouble rand_val;
1997-11-25 06:05:25 +08:00
steps = max - min + 1;
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c 2002-11-20 Dave Neary <bolsh@gimp.org> * configure.in * app/core/gimpbrushpipe.c * app/gui/about-dialog.c * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.c * libgimpmath/gimpmath.h * libgimpwidgets/gimpwidgets.c * plug-ins/common/CML_explorer.c * plug-ins/common/blur.c * plug-ins/common/cubism.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/gqbist.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/warp.c * plug-ins/common/wind.c * plug-ins/flame/cmap.c * plug-ins/flame/flame.c * plug-ins/flame/libifs.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/plasma.c * plug-ins/gimpressionist/repaint.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c * plug-ins/maze/maze.h * plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX, G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(), srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand* equivalent. Programs which require seed setting for reproducible results, and anything in the core, gets a dedicated GRand * for the lifetime required. Programs which only ever used random numbers for tossing a coin, rolling a dice, etc use g_random functions. For the rest, judgement was used. Where it was easy, a GRand * object was used and g_rand_* functions were preferred. This fixes bug #67386 in HEAD.
2002-11-20 17:27:48 +08:00
rand_val = g_random_double ();
1997-11-25 06:05:25 +08:00
for (index = 1; index < VALS.holdness; index++)
{
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c 2002-11-20 Dave Neary <bolsh@gimp.org> * configure.in * app/core/gimpbrushpipe.c * app/gui/about-dialog.c * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.c * libgimpmath/gimpmath.h * libgimpwidgets/gimpwidgets.c * plug-ins/common/CML_explorer.c * plug-ins/common/blur.c * plug-ins/common/cubism.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/gqbist.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/warp.c * plug-ins/common/wind.c * plug-ins/flame/cmap.c * plug-ins/flame/flame.c * plug-ins/flame/libifs.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/plasma.c * plug-ins/gimpressionist/repaint.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c * plug-ins/maze/maze.h * plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX, G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(), srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand* equivalent. Programs which require seed setting for reproducible results, and anything in the core, gets a dedicated GRand * for the lifetime required. Programs which only ever used random numbers for tossing a coin, rolling a dice, etc use g_random functions. For the rest, judgement was used. Where it was easy, a GRand * object was used and g_rand_* functions were preferred. This fixes bug #67386 in HEAD.
2002-11-20 17:27:48 +08:00
double tmp = g_random_double ();
1997-11-25 06:05:25 +08:00
if (tmp < rand_val)
rand_val = tmp;
}
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c 2002-11-20 Dave Neary <bolsh@gimp.org> * configure.in * app/core/gimpbrushpipe.c * app/gui/about-dialog.c * app/paint-funcs/paint-funcs-generic.h * app/paint-funcs/paint-funcs.c * libgimpmath/gimpmath.h * libgimpwidgets/gimpwidgets.c * plug-ins/common/CML_explorer.c * plug-ins/common/blur.c * plug-ins/common/cubism.c * plug-ins/common/gee.c * plug-ins/common/gee_zoom.c * plug-ins/common/gqbist.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/noisify.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/plasma.c * plug-ins/common/randomize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/smooth_palette.c * plug-ins/common/snoise.c * plug-ins/common/sparkle.c * plug-ins/common/spheredesigner.c * plug-ins/common/spread.c * plug-ins/common/warp.c * plug-ins/common/wind.c * plug-ins/flame/cmap.c * plug-ins/flame/flame.c * plug-ins/flame/libifs.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/gimpressionist/gimpressionist.h * plug-ins/gimpressionist/plasma.c * plug-ins/gimpressionist/repaint.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/maze/algorithms.c * plug-ins/maze/maze.c * plug-ins/maze/maze.h * plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX, G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(), srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand* equivalent. Programs which require seed setting for reproducible results, and anything in the core, gets a dedicated GRand * for the lifetime required. Programs which only ever used random numbers for tossing a coin, rolling a dice, etc use g_random functions. For the rest, judgement was used. Where it was easy, a GRand * object was used and g_rand_* functions were preferred. This fixes bug #67386 in HEAD.
2002-11-20 17:27:48 +08:00
if (g_random_double () < 0.5)
flag = -1;
else
flag = 1;
1997-11-25 06:05:25 +08:00
new = now + flag * ((int) (rand_max * rand_val) % steps);
if (new < min)
{
if (mod_p == 1)
new += steps;
else
new = min;
}
if (max < new)
{
if (mod_p == 1)
new -= steps;
else
new = max;
}
return new;
}
2002-05-26 02:10:04 +08:00
static void scatter_hsv_scatter (guchar *r,
guchar *g,
guchar *b)
1997-11-25 06:05:25 +08:00
{
gint h, s, v;
gint h1, s1, v1;
gint h2, s2, v2;
1997-11-25 06:05:25 +08:00
h = *r; s = *g; v = *b;
gimp_rgb_to_hsv_int (&h, &s, &v);
1997-11-25 06:05:25 +08:00
if (0 < VALS.hue_distance)
h = randomize_value (h, 0, 255, 1, VALS.hue_distance);
if ((0 < VALS.saturation_distance))
s = randomize_value (s, 0, 255, 0, VALS.saturation_distance);
if ((0 < VALS.value_distance))
v = randomize_value (v, 0, 255, 0, VALS.value_distance);
h1 = h; s1 = s; v1 = v;
gimp_hsv_to_rgb_int (&h, &s, &v); /* don't believe ! */
1997-11-25 06:05:25 +08:00
h2 = h; s2 = s; v2 = v;
gimp_rgb_to_hsv_int (&h2, &s2, &v2); /* h2 should be h1. But... */
1997-11-25 06:05:25 +08:00
if ((abs (h1 - h2) <= VALS.hue_distance)
&& (abs (s1 - s2) <= VALS.saturation_distance)
&& (abs (v1 - v2) <= VALS.value_distance))
{
*r = h;
*g = s;
*b = v;
}
}
/* dialog stuff */
static gint
scatter_hsv_dialog (void)
1997-11-25 06:05:25 +08:00
{
GtkWidget *dlg;
GtkWidget *vbox;
GtkWidget *frame;
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
GtkWidget *pframe;
GtkWidget *abox;
GtkWidget *table;
GtkObject *adj;
1997-11-25 06:05:25 +08:00
gimp_ui_init (SHORT_NAME, TRUE);
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
dlg = gimp_dialog_new (_("Scatter HSV"), SHORT_NAME,
gimp_standard_help_func, "filters/scatter_hsv.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
2001-08-04 03:52:08 +08:00
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
GTK_STOCK_OK, scatter_hsv_ok_callback,
NULL, NULL, NULL, TRUE, FALSE,
NULL);
g_signal_connect (dlg, "destroy",
G_CALLBACK (gtk_main_quit),
NULL);
vbox = gtk_vbox_new (FALSE, 6);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dlg)->vbox), vbox);
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
frame = gtk_frame_new (_("Preview (1:4) - Right Click to Jump"));
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
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_set_border_width (GTK_CONTAINER (pframe), 4);
gtk_container_add (GTK_CONTAINER (abox), pframe);
gtk_widget_show (pframe);
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
{
gint width = gimp_drawable_width (drawable_id);
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
gint height = gimp_drawable_height (drawable_id);
preview_width = (PREVIEW_WIDTH < width) ? PREVIEW_WIDTH : width;
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
preview_height = (PREVIEW_HEIGHT < height) ? PREVIEW_HEIGHT : height;
}
gtk_preview_size (GTK_PREVIEW (preview), preview_width * 2, preview_height);
scatter_hsv_preview_update ();
gtk_container_add (GTK_CONTAINER (pframe), preview);
gtk_widget_set_events (preview,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
gtk_widget_show (preview);
g_signal_connect (preview, "event",
G_CALLBACK (preview_event_handler),
NULL);
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
gtk_widget_show (frame);
table = gimp_parameter_settings_new (vbox, 4, 3);
1997-11-25 06:05:25 +08:00
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
changed "Number of Colors" to "Max Number of Colors" to clarify what this 2002-09-06 Michael Natterer <mitch@gimp.org> * app/gui/convert-dialog.c: changed "Number of Colors" to "Max Number of Colors" to clarify what this parameter does. (fixes #92194). * app/gui/menus.c: use GIMP_STOCK_INFO for "View/Info Window". Specify spibutton sizes in chars, not pixels (eek) all over the place. Also removed explicit sizes where the GtkSpinButton default size does not disturbe tabular widget layouts. * libgimpwidgets/gimpwidgets.c: removed the hardcoded width of 75 pixels in gimp_spin_button_new(). Changed gimp_scale_entry_new() and gimp_coordinates_new() to interpret their "spinbutton_width" parameters as chars if < 16, and as pixels otherwise. This gives reasonable results and doesn't cause unchanged plug-ins to suddenly have spinbuttons of dozens of chars width :) * libgimpwidgets/gimpsizeentry.c: added the same heuristic here. * libgimpwidgets/gimpquerybox.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/tools/gimpairbrushtool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpdodgeburntool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpposterizetool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.c * app/widgets/gimppaletteeditor.c: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/bumpmap.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/depthmerge.c * plug-ins/common/despeckle.c * plug-ins/common/diffraction.c * plug-ins/common/emboss.c * plug-ins/common/film.c * plug-ins/common/flarefx.c * plug-ins/common/fractaltrace.c * plug-ins/common/gauss_iir.c * plug-ins/common/gauss_rle.c * plug-ins/common/glasstile.c * plug-ins/common/grid.c * plug-ins/common/illusion.c * plug-ins/common/iwarp.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/max_rgb.c * plug-ins/common/mblur.c * plug-ins/common/newsprint.c * plug-ins/common/nova.c * plug-ins/common/pixelize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/spread.c * plug-ins/common/tile.c * plug-ins/common/tileit.c * plug-ins/common/unsharp.c * plug-ins/common/vpropagate.c * plug-ins/common/waves.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/mosaic/mosaic.c * plug-ins/rcm/rcm_dialog.c: changed accordingly, which involves removals of gtk_widget_set_size_request(spinbutton), removal of lots of explicit spinbutton sizes in gimp_scale_entry_new(), and adding of new ones because GtkSpinButton's auto-size trashed tabular layouts. Lots of cleanup & indentation while browsing the plug-ins' code. Changed spacings, moved toggle buttons into frame titles, use stock items, stuff...
2002-09-07 04:44:47 +08:00
_("_Holdness:"), SCALE_WIDTH, ENTRY_WIDTH,
VALS.holdness, 1, 8, 1, 2, 0,
TRUE, 0, 0,
NULL, NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (scatter_hsv_iscale_update),
&VALS.holdness);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
changed "Number of Colors" to "Max Number of Colors" to clarify what this 2002-09-06 Michael Natterer <mitch@gimp.org> * app/gui/convert-dialog.c: changed "Number of Colors" to "Max Number of Colors" to clarify what this parameter does. (fixes #92194). * app/gui/menus.c: use GIMP_STOCK_INFO for "View/Info Window". Specify spibutton sizes in chars, not pixels (eek) all over the place. Also removed explicit sizes where the GtkSpinButton default size does not disturbe tabular widget layouts. * libgimpwidgets/gimpwidgets.c: removed the hardcoded width of 75 pixels in gimp_spin_button_new(). Changed gimp_scale_entry_new() and gimp_coordinates_new() to interpret their "spinbutton_width" parameters as chars if < 16, and as pixels otherwise. This gives reasonable results and doesn't cause unchanged plug-ins to suddenly have spinbuttons of dozens of chars width :) * libgimpwidgets/gimpsizeentry.c: added the same heuristic here. * libgimpwidgets/gimpquerybox.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/tools/gimpairbrushtool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpdodgeburntool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpposterizetool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.c * app/widgets/gimppaletteeditor.c: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/bumpmap.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/depthmerge.c * plug-ins/common/despeckle.c * plug-ins/common/diffraction.c * plug-ins/common/emboss.c * plug-ins/common/film.c * plug-ins/common/flarefx.c * plug-ins/common/fractaltrace.c * plug-ins/common/gauss_iir.c * plug-ins/common/gauss_rle.c * plug-ins/common/glasstile.c * plug-ins/common/grid.c * plug-ins/common/illusion.c * plug-ins/common/iwarp.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/max_rgb.c * plug-ins/common/mblur.c * plug-ins/common/newsprint.c * plug-ins/common/nova.c * plug-ins/common/pixelize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/spread.c * plug-ins/common/tile.c * plug-ins/common/tileit.c * plug-ins/common/unsharp.c * plug-ins/common/vpropagate.c * plug-ins/common/waves.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/mosaic/mosaic.c * plug-ins/rcm/rcm_dialog.c: changed accordingly, which involves removals of gtk_widget_set_size_request(spinbutton), removal of lots of explicit spinbutton sizes in gimp_scale_entry_new(), and adding of new ones because GtkSpinButton's auto-size trashed tabular layouts. Lots of cleanup & indentation while browsing the plug-ins' code. Changed spacings, moved toggle buttons into frame titles, use stock items, stuff...
2002-09-07 04:44:47 +08:00
_("H_ue:"), SCALE_WIDTH, ENTRY_WIDTH,
VALS.hue_distance, 0, 255, 1, 8, 0,
TRUE, 0, 0,
NULL, NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (scatter_hsv_iscale_update),
&VALS.hue_distance);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
changed "Number of Colors" to "Max Number of Colors" to clarify what this 2002-09-06 Michael Natterer <mitch@gimp.org> * app/gui/convert-dialog.c: changed "Number of Colors" to "Max Number of Colors" to clarify what this parameter does. (fixes #92194). * app/gui/menus.c: use GIMP_STOCK_INFO for "View/Info Window". Specify spibutton sizes in chars, not pixels (eek) all over the place. Also removed explicit sizes where the GtkSpinButton default size does not disturbe tabular widget layouts. * libgimpwidgets/gimpwidgets.c: removed the hardcoded width of 75 pixels in gimp_spin_button_new(). Changed gimp_scale_entry_new() and gimp_coordinates_new() to interpret their "spinbutton_width" parameters as chars if < 16, and as pixels otherwise. This gives reasonable results and doesn't cause unchanged plug-ins to suddenly have spinbuttons of dozens of chars width :) * libgimpwidgets/gimpsizeentry.c: added the same heuristic here. * libgimpwidgets/gimpquerybox.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/tools/gimpairbrushtool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpdodgeburntool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpposterizetool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.c * app/widgets/gimppaletteeditor.c: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/bumpmap.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/depthmerge.c * plug-ins/common/despeckle.c * plug-ins/common/diffraction.c * plug-ins/common/emboss.c * plug-ins/common/film.c * plug-ins/common/flarefx.c * plug-ins/common/fractaltrace.c * plug-ins/common/gauss_iir.c * plug-ins/common/gauss_rle.c * plug-ins/common/glasstile.c * plug-ins/common/grid.c * plug-ins/common/illusion.c * plug-ins/common/iwarp.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/max_rgb.c * plug-ins/common/mblur.c * plug-ins/common/newsprint.c * plug-ins/common/nova.c * plug-ins/common/pixelize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/spread.c * plug-ins/common/tile.c * plug-ins/common/tileit.c * plug-ins/common/unsharp.c * plug-ins/common/vpropagate.c * plug-ins/common/waves.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/mosaic/mosaic.c * plug-ins/rcm/rcm_dialog.c: changed accordingly, which involves removals of gtk_widget_set_size_request(spinbutton), removal of lots of explicit spinbutton sizes in gimp_scale_entry_new(), and adding of new ones because GtkSpinButton's auto-size trashed tabular layouts. Lots of cleanup & indentation while browsing the plug-ins' code. Changed spacings, moved toggle buttons into frame titles, use stock items, stuff...
2002-09-07 04:44:47 +08:00
_("_Saturation:"), SCALE_WIDTH, ENTRY_WIDTH,
VALS.saturation_distance, 0, 255, 1, 8, 0,
TRUE, 0, 0,
NULL, NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (scatter_hsv_iscale_update),
&VALS.saturation_distance);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 3,
changed "Number of Colors" to "Max Number of Colors" to clarify what this 2002-09-06 Michael Natterer <mitch@gimp.org> * app/gui/convert-dialog.c: changed "Number of Colors" to "Max Number of Colors" to clarify what this parameter does. (fixes #92194). * app/gui/menus.c: use GIMP_STOCK_INFO for "View/Info Window". Specify spibutton sizes in chars, not pixels (eek) all over the place. Also removed explicit sizes where the GtkSpinButton default size does not disturbe tabular widget layouts. * libgimpwidgets/gimpwidgets.c: removed the hardcoded width of 75 pixels in gimp_spin_button_new(). Changed gimp_scale_entry_new() and gimp_coordinates_new() to interpret their "spinbutton_width" parameters as chars if < 16, and as pixels otherwise. This gives reasonable results and doesn't cause unchanged plug-ins to suddenly have spinbuttons of dozens of chars width :) * libgimpwidgets/gimpsizeentry.c: added the same heuristic here. * libgimpwidgets/gimpquerybox.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/tools/gimpairbrushtool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpdodgeburntool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpposterizetool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.c * app/widgets/gimppaletteeditor.c: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/common/AlienMap.c * plug-ins/common/AlienMap2.c * plug-ins/common/CML_explorer.c * plug-ins/common/bumpmap.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/depthmerge.c * plug-ins/common/despeckle.c * plug-ins/common/diffraction.c * plug-ins/common/emboss.c * plug-ins/common/film.c * plug-ins/common/flarefx.c * plug-ins/common/fractaltrace.c * plug-ins/common/gauss_iir.c * plug-ins/common/gauss_rle.c * plug-ins/common/glasstile.c * plug-ins/common/grid.c * plug-ins/common/illusion.c * plug-ins/common/iwarp.c * plug-ins/common/jigsaw.c * plug-ins/common/lic.c * plug-ins/common/max_rgb.c * plug-ins/common/mblur.c * plug-ins/common/newsprint.c * plug-ins/common/nova.c * plug-ins/common/pixelize.c * plug-ins/common/sample_colorize.c * plug-ins/common/scatter_hsv.c * plug-ins/common/shift.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/spread.c * plug-ins/common/tile.c * plug-ins/common/tileit.c * plug-ins/common/unsharp.c * plug-ins/common/vpropagate.c * plug-ins/common/waves.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/mosaic/mosaic.c * plug-ins/rcm/rcm_dialog.c: changed accordingly, which involves removals of gtk_widget_set_size_request(spinbutton), removal of lots of explicit spinbutton sizes in gimp_scale_entry_new(), and adding of new ones because GtkSpinButton's auto-size trashed tabular layouts. Lots of cleanup & indentation while browsing the plug-ins' code. Changed spacings, moved toggle buttons into frame titles, use stock items, stuff...
2002-09-07 04:44:47 +08:00
_("_Value:"), SCALE_WIDTH, ENTRY_WIDTH,
VALS.value_distance, 0, 255, 1, 8, 0,
TRUE, 0, 0,
NULL, NULL);
g_signal_connect (adj, "value_changed",
G_CALLBACK (scatter_hsv_iscale_update),
&VALS.value_distance);
1997-11-25 06:05:25 +08:00
gtk_widget_show (vbox);
gtk_widget_show (dlg);
gtk_main ();
gdk_flush ();
return INTERFACE.run;
}
static gint
preview_event_handler (GtkWidget *widget,
GdkEvent *event)
1997-11-25 06:05:25 +08:00
{
gint x, y;
gint dx, dy;
GdkEventButton *bevent;
gtk_widget_get_pointer (widget, &x, &y);
bevent = (GdkEventButton *) event;
switch (event->type)
{
case GDK_BUTTON_PRESS:
if (x < preview_width)
{
if (bevent->button == 3)
{
preview_offset_x = - x;
preview_offset_y = - y;
scatter_hsv_preview_update ();
}
else
{
preview_dragging = TRUE;
preview_drag_start_x = x;
preview_drag_start_y = y;
gtk_grab_add (widget);
}
}
break;
case GDK_BUTTON_RELEASE:
if (preview_dragging)
{
gtk_grab_remove (widget);
preview_dragging = FALSE;
scatter_hsv_preview_update ();
}
break;
case GDK_MOTION_NOTIFY:
if (preview_dragging)
{
dx = x - preview_drag_start_x;
dy = y - preview_drag_start_y;
preview_drag_start_x = x;
preview_drag_start_y = y;
if ((dx == 0) && (dy == 0))
break;
preview_offset_x = MAX (preview_offset_x - dx, 0);
preview_offset_y = MAX (preview_offset_y - dy, 0);
scatter_hsv_preview_update ();
}
break;
default:
break;
}
return FALSE;
}
static void
scatter_hsv_preview_update (void)
1997-11-25 06:05:25 +08:00
{
GimpDrawable *drawable;
GimpPixelRgn src_rgn;
1997-11-25 06:05:25 +08:00
gint scale;
gint x, y, dx, dy;
gint bound_start_x, bound_start_y, bound_end_x, bound_end_y;
gint src_has_alpha = FALSE;
gint src_is_gray = FALSE;
gint src_bpp, src_bpl;
guchar data[3];
gdouble shift_rate;
drawable = gimp_drawable_get (drawable_id);
gimp_drawable_mask_bounds (drawable_id,
&bound_start_x, &bound_start_y,
&bound_end_x, &bound_end_y);
src_has_alpha = gimp_drawable_has_alpha (drawable_id);
1999-10-17 08:07:55 +08:00
src_is_gray = gimp_drawable_is_gray (drawable_id);
1997-11-25 06:05:25 +08:00
src_bpp = (src_is_gray ? 1 : 3) + (src_has_alpha ? 1 : 0);
src_bpl = preview_width * src_bpp;
if (! preview_buffer)
preview_buffer = g_new (guchar, src_bpl * preview_height);
1997-11-25 06:05:25 +08:00
if (preview_offset_x < 0)
preview_offset_x = (bound_end_x - bound_start_x) * (- preview_offset_x) / preview_width;
if (preview_offset_y < 0)
preview_offset_y = (bound_end_y - bound_start_y) * (- preview_offset_y) / preview_height;
preview_start_x = CLAMP (bound_start_x + preview_offset_x,
bound_start_x, MAX (bound_end_x - preview_width, 0));
preview_start_y = CLAMP (bound_start_y + preview_offset_y,
bound_start_y, MAX (bound_end_y - preview_height, 0));
if (preview_start_x == bound_start_x)
preview_offset_x = 0;
if (preview_start_y == bound_start_y)
preview_offset_y =0;
gimp_pixel_rgn_init (&src_rgn, drawable, preview_start_x, preview_start_y,
preview_width, preview_height,
FALSE, FALSE);
/* Since it's small, get whole data before processing. */
gimp_pixel_rgn_get_rect (&src_rgn, preview_buffer,
preview_start_x, preview_start_y,
preview_width, preview_height);
scale = 4;
shift_rate = (gdouble) (scale - 1) / ( 2 * scale);
for (y = 0; y < preview_height/4; y++)
{
for (x = 0; x < preview_width/4; x++)
{
gint pos;
gint i;
pos = (gint)(y + preview_height * shift_rate) * src_bpl
+ (gint)(x + preview_width * shift_rate) * src_bpp;
for (i = 0; i < src_bpp; i++)
data[i] = preview_buffer[pos + i];
scatter_hsv_scatter (data+0, data+1, data+2);
for (dy = 0; dy < scale; dy++)
for (dx = 0; dx < scale; dx++)
gtk_preview_draw_row (GTK_PREVIEW (preview), data,
preview_width + x * scale + dx,
y * scale + dy, 1);
}
}
for (y = 0; y < preview_height; y ++)
for (x = 0; x < preview_width; x++)
{
gint i;
for (i = 0; i < src_bpp; i++)
data[i] = preview_buffer[y * src_bpl + x * src_bpp + i];
scatter_hsv_scatter (data+0, data+1, data+2);
gtk_preview_draw_row (GTK_PREVIEW (preview), data, x, y, 1);
}
gtk_widget_queue_draw (preview);
1997-11-25 06:05:25 +08:00
}
static void
scatter_hsv_ok_callback (GtkWidget *widget,
gpointer data)
1997-11-25 06:05:25 +08:00
{
INTERFACE.run = TRUE;
1997-11-25 06:05:25 +08:00
gtk_widget_destroy (GTK_WIDGET (data));
}
static void
scatter_hsv_iscale_update (GtkAdjustment *adjustment,
gpointer data)
{
gimp_int_adjustment_update (adjustment, data);
1997-11-25 06:05:25 +08:00
scatter_hsv_preview_update ();
1997-11-25 06:05:25 +08:00
}