gimp/plug-ins/ifscompose/ifscompose.c

2942 lines
82 KiB
C
Raw Normal View History

1997-11-24 22:05:25 +00:00
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* IfsCompose is a interface for creating IFS fractals by
* direct manipulation.
* Copyright (C) 1997 Owen Taylor
*
* 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-24 22:05:25 +00:00
*/
/* TODO
* ----
*
* 1. Run in non-interactive mode (need to figure out useful
* way for a script to give the 19N paramters for an image).
* Perhaps just support saving parameters to a file, script
* passes file name.
* 2. Save settings on a per-layer basis (long term, needs GIMP
* support to do properly). Load/save from affine parameters?
* 3. Figure out if we need multiple phases for supersampled
* brushes.
* 4. (minor) Make undo work correctly when focus is in entry widget.
*/
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc 1999-09-01 Tor Lillqvist <tml@iki.fi> * app/appenv.h * libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc from app/appenv.h here, so plug-ins can use them, too. Remove some commented-out old stuff in appenv.h. * libgimp/gimp.h: Include gimpmath.h. * libgimp/gimp.c (gimp_main): Win32: Don't install signal handlers, we can't do anything useful in the handler ourselves anyway (it would be nice to print out a backtrace, but that seems pretty hard to do, even if not impossible). Let Windows inform the user about the crash. If the plug-in was compiled with MSVC, and the user also has it, she is offered a chance to start the debugger automatically anyway. * app/*several*.c: Include gimpmath.h for G_PI etc. Don't include <math.h>, as gimpmath.h includes it. * plug-ins/*/*many*.c: Include config.h. Don't include <math.h>. Remove all the duplicated definitions of G_PI and rint(). Use RINT() instead of rint(). * app/app_procs.[ch]: app_exit() takes a gboolean. * app/batch.c * app/commands.c * app/interface.c: Call app_exit() with FALSE or TRUE. * app/main.c (on_error): Call gimp_fatal_error. (main): Don't install any signal handler on Win32 here, either. * app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format the message and call MessageBox with it. g_on_error_query doesn't do anything useful on Win32, and printf'ing a message to stdout or stderr doesn't do anything, either, in a windowing application.
1999-09-01 20:30:56 +00:00
#include "config.h"
1997-11-24 22:05:25 +00:00
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c 2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 13:26:29 +00:00
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c 2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 13:26:29 +00:00
#include "ifscompose.h"
1999-11-17 14:39:11 +00:00
#include "libgimp/stdplugins-intl.h"
1997-11-24 22:05:25 +00:00
#define SCALE_WIDTH 150
#define ENTRY_WIDTH 60
#define DESIGN_AREA_MAX_SIZE 300
1997-11-24 22:05:25 +00:00
#define PREVIEW_RENDER_CHUNK 10000
#define UNDO_LEVELS 24
1997-11-24 22:05:25 +00:00
#define IFSCOMPOSE_PARASITE "ifscompose-parasite"
#define IFSCOMPOSE_DATA "plug_in_ifscompose"
typedef enum
{
1997-11-24 22:05:25 +00:00
OP_TRANSLATE,
OP_ROTATE, /* or scale */
1997-11-24 22:05:25 +00:00
OP_STRETCH
} DesignOp;
typedef enum
{
1997-11-24 22:05:25 +00:00
VALUE_PAIR_INT,
VALUE_PAIR_DOUBLE
1997-11-24 22:05:25 +00:00
} ValuePairType;
typedef struct
{
GtkObject *adjustment;
GtkWidget *scale;
GtkWidget *entry;
ValuePairType type;
union
{
1997-11-24 22:05:25 +00:00
gdouble *d;
gint *i;
} data;
gint entry_handler_id;
} ValuePair;
typedef struct
{
IfsComposeVals ifsvals;
AffElement **elements;
gint *element_selected;
gint current_element;
1997-11-24 22:05:25 +00:00
} UndoItem;
typedef struct
{
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
GimpRGB *color;
1997-11-24 22:05:25 +00:00
GtkWidget *hbox;
GtkWidget *orig_preview;
2000-01-26 14:14:54 +00:00
GtkWidget *button;
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
gboolean fixed_point;
1997-11-24 22:05:25 +00:00
} ColorMap;
typedef struct
{
GtkWidget *dialog;
ValuePair *iterations_pair;
ValuePair *subdivide_pair;
ValuePair *radius_pair;
ValuePair *memory_pair;
} IfsOptionsDialog;
typedef struct
{
GtkWidget *area;
GtkWidget *op_menu;
GdkPixmap *pixmap;
DesignOp op;
gdouble op_x;
gdouble op_y;
gdouble op_xcenter;
gdouble op_ycenter;
gdouble op_center_x;
gdouble op_center_y;
guint button_state;
gint num_selected;
GdkGC *selected_gc;
1997-11-24 22:05:25 +00:00
} IfsDesignArea;
typedef struct
{
ValuePair *prob_pair;
ValuePair *x_pair;
ValuePair *y_pair;
ValuePair *scale_pair;
ValuePair *angle_pair;
ValuePair *asym_pair;
ValuePair *shear_pair;
GtkWidget *flip_check_button;
ColorMap *red_cmap;
ColorMap *green_cmap;
ColorMap *blue_cmap;
ColorMap *black_cmap;
ColorMap *target_cmap;
ValuePair *hue_scale_pair;
ValuePair *value_scale_pair;
GtkWidget *simple_button;
GtkWidget *full_button;
GtkWidget *current_frame;
GtkWidget *move_button;
gint move_handler;
1997-11-24 22:05:25 +00:00
GtkWidget *rotate_button;
gint rotate_handler;
1997-11-24 22:05:25 +00:00
GtkWidget *stretch_button;
gint stretch_handler;
1997-11-24 22:05:25 +00:00
GtkWidget *undo_button;
GtkWidget *undo_menu_item;
GtkWidget *redo_button;
GtkWidget *redo_menu_item;
GtkWidget *delete_button;
GtkWidget *delete_menu_item;
1997-11-24 22:05:25 +00:00
GtkWidget *preview;
guchar *preview_data;
gint preview_iterations;
1997-11-24 22:05:25 +00:00
gint drawable_width;
gint drawable_height;
1997-11-24 22:05:25 +00:00
AffElement *selected_orig;
gint current_element;
AffElementVals current_vals;
1997-11-24 22:05:25 +00:00
gboolean auto_preview;
gboolean in_update; /* true if we're currently in
1997-11-24 22:05:25 +00:00
update_values() - don't do anything
on updates */
} IfsDialog;
typedef struct
{
gboolean run;
1997-11-24 22:05:25 +00:00
} IfsComposeInterface;
/* Declare local functions.
*/
static void query (void);
static void run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
1997-11-24 22:05:25 +00:00
/* user interface functions */
static gint ifs_compose_dialog (GimpDrawable *drawable);
static void ifs_options_dialog (void);
static GtkWidget *ifs_compose_trans_page (void);
static GtkWidget *ifs_compose_color_page (void);
static void design_op_menu_popup (gint button, guint32 activate_time);
static void design_op_menu_create (GtkWidget *window);
static void design_area_create (GtkWidget *window, gint design_width,
gint design_height);
1997-11-24 22:05:25 +00:00
/* functions for drawing design window */
static void update_values (void);
static void set_current_element (gint index);
static gint design_area_expose (GtkWidget *widget,
GdkEventExpose *event);
static gint design_area_button_press (GtkWidget *widget,
GdkEventButton *event);
static gint design_area_button_release (GtkWidget *widget,
GdkEventButton *event);
static void design_area_select_all_callback (GtkWidget *w, gpointer data);
static gint design_area_configure (GtkWidget *widget,
GdkEventConfigure *event);
static gint design_area_motion (GtkWidget *widget,
GdkEventMotion *event);
static void design_area_redraw (void);
1997-11-24 22:05:25 +00:00
/* Undo ring functions */
static void undo_begin (void);
static void undo_update (gint element);
static void undo_exchange (gint el);
static void undo (void);
static void redo (void);
static void recompute_center (gboolean save_undo);
static void recompute_center_cb (GtkWidget *widget,
gpointer data);
static void ifs_compose (GimpDrawable *drawable);
static ColorMap *color_map_create (gchar *name,
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
GimpRGB *orig_color,
GimpRGB *data,
gboolean fixed_point);
static void color_map_color_changed_cb (GtkWidget *widget,
ColorMap *color_map);
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
static void color_map_update (ColorMap *color_map);
1997-11-24 22:05:25 +00:00
/* interface functions */
static void simple_color_toggled (GtkWidget *widget, gpointer data);
static void simple_color_set_sensitive (void);
static void val_changed_update (void);
static ValuePair *value_pair_create (gpointer data,
gdouble lower,
gdouble upper,
gboolean create_scale,
ValuePairType type);
static void value_pair_update (ValuePair *value_pair);
static void value_pair_entry_callback (GtkWidget *w,
ValuePair *value_pair);
static void value_pair_destroy_callback (GtkWidget *widget,
ValuePair *value_pair);
static void value_pair_scale_callback (GtkAdjustment *adjustment,
ValuePair *value_pair);
static void auto_preview_callback (GtkWidget *widget, gpointer data);
static void design_op_callback (GtkWidget *widget, gpointer data);
static void design_op_update_callback (GtkWidget *widget, gpointer data);
static void flip_check_button_callback (GtkWidget *widget, gpointer data);
static gint preview_idle_render (gpointer data);
1997-11-24 22:05:25 +00:00
static void ifs_compose_preview (void);
static void ifs_compose_set_defaults (void);
1997-11-24 22:05:25 +00:00
static void ifs_compose_defaults_callback (GtkWidget *widget,
gpointer data);
static void ifs_compose_new_callback (GtkWidget *widget,
gpointer data);
static void ifs_compose_delete_callback (GtkWidget *widget,
gpointer data);
static void ifs_compose_load_callback (GtkWidget *widget,
gpointer data);
static void ifs_compose_save_callback (GtkWidget *widget,
gpointer data);
static void ifs_compose_ok_callback (GtkWidget *widget,
GtkWidget *window);
1997-11-24 22:05:25 +00:00
/*
* Some static variables
*/
static IfsDialog *ifsD = NULL;
static IfsOptionsDialog *ifsOptD = NULL;
static IfsDesignArea *ifsDesign = NULL;
1997-11-24 22:05:25 +00:00
static AffElement **elements = NULL;
static gint *element_selected = NULL;
/* labels are generated by printing this int */
static gint count_for_naming = 0;
1997-11-24 22:05:25 +00:00
static UndoItem undo_ring[UNDO_LEVELS];
static gint undo_cur = -1;
static gint undo_num = 0;
static gint undo_start = 0;
1997-11-24 22:05:25 +00:00
1997-11-24 22:05:25 +00:00
/* num_elements = 0, signals not inited */
static IfsComposeVals ifsvals =
{
0, /* num_elements */
50000, /* iterations */
4096, /* max_memory */
4, /* subdivide */
0.75, /* radius */
1.0, /* aspect ratio */
0.5, /* center_x */
0.5, /* center_y */
1997-11-24 22:05:25 +00:00
};
static IfsComposeInterface ifscint =
1997-11-24 22:05:25 +00:00
{
FALSE, /* run */
};
GimpPlugInInfo PLUG_IN_INFO =
1997-11-24 22:05:25 +00:00
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
};
MAIN ()
static void
query (void)
1997-11-24 22:05:25 +00:00
{
static GimpParamDef args[] =
1997-11-24 22:05:25 +00:00
{
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
{ GIMP_PDB_IMAGE, "image", "Input image" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
1997-11-24 22:05:25 +00:00
};
static GimpParamDef *return_vals = NULL;
1997-11-24 22:05:25 +00:00
static int nreturn_vals = 0;
gimp_install_procedure ("plug_in_ifs_compose",
2000-01-31 02:32:30 +00:00
"Create an Iterated Function System Fractal",
"Interactively create an Iterated Function System fractal. "
"Use the window on the upper left to adjust the component "
"transformations of the fractal. The operation that is performed "
"is selected by the buttons underneath the window, or from a "
"menu popped up by the right mouse button. The fractal will be "
"rendered with a transparent background if the current image has "
"a transparent background.",
1997-11-24 22:05:25 +00:00
"Owen Taylor",
"Owen Taylor",
"1997",
N_("<Image>/Filters/Render/Nature/IfsCompose..."),
1997-11-24 22:05:25 +00:00
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), nreturn_vals,
1997-11-24 22:05:25 +00:00
args, return_vals);
}
static void
run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
1997-11-24 22:05:25 +00:00
{
static GimpParam values[1];
GimpDrawable *active_drawable;
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpParasite *parasite = NULL;
guint32 image_id;
gboolean found_parasite;
1997-11-24 22:05:25 +00:00
run_mode = param[0].data.d_int32;
values[0].type = GIMP_PDB_STATUS;
1997-11-24 22:05:25 +00:00
values[0].data.d_status = status;
*nreturn_vals = 1;
*return_vals = values;
INIT_I18N ();
image_id = param[1].data.d_image;
1997-11-24 22:05:25 +00:00
active_drawable = gimp_drawable_get (param[2].data.d_drawable);
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
/* Possibly retrieve data; first look for a parasite -
* if not found, fall back to global values
*/
parasite = gimp_drawable_parasite_find (active_drawable->drawable_id,
IFSCOMPOSE_PARASITE);
found_parasite = FALSE;
if (parasite)
{
found_parasite = ifsvals_parse_string (gimp_parasite_data (parasite),
&ifsvals, &elements);
gimp_parasite_free (parasite);
}
if (!found_parasite)
{
gint length;
length = gimp_get_data_size (IFSCOMPOSE_DATA);
if (length)
1997-11-24 22:05:25 +00:00
{
gchar *data = g_new (gchar, length);
gimp_get_data (IFSCOMPOSE_DATA, data);
ifsvals_parse_string (data, &ifsvals, &elements);
g_free (data);
1997-11-24 22:05:25 +00:00
}
}
/* after ifsvals_parse_string, need to set up naming */
count_for_naming = ifsvals.num_elements;
1997-11-24 22:05:25 +00:00
/* First acquire information with a dialog */
if (! ifs_compose_dialog (active_drawable))
return;
break;
case GIMP_RUN_NONINTERACTIVE:
1997-11-24 22:05:25 +00:00
/* Make sure all the arguments are there! */
status = GIMP_PDB_CALLING_ERROR;
1997-11-24 22:05:25 +00:00
break;
case GIMP_RUN_WITH_LAST_VALS:
1997-11-24 22:05:25 +00:00
/* Possibly retrieve data */
{
gint length;
length = gimp_get_data_size (IFSCOMPOSE_DATA);
if (length)
{
gchar *data = g_new (gchar, length);
gimp_get_data (IFSCOMPOSE_DATA, data);
ifsvals_parse_string (data, &ifsvals, &elements);
g_free (data);
}
else
{
ifs_compose_set_defaults ();
}
}
1997-11-24 22:05:25 +00:00
break;
default:
break;
}
/* Render the fractal */
if ((status == GIMP_PDB_SUCCESS) &&
(gimp_drawable_is_rgb (active_drawable->drawable_id) ||
gimp_drawable_is_gray (active_drawable->drawable_id)))
1997-11-24 22:05:25 +00:00
{
/* set the tile cache size so that the operation works well */
gimp_tile_cache_ntiles (2 * (MAX (active_drawable->width,
active_drawable->height) /
1997-11-24 22:05:25 +00:00
gimp_tile_width () + 1));
if (run_mode == GIMP_RUN_INTERACTIVE)
{
gchar *str;
GimpParasite *parasite;
gimp_undo_push_group_start (image_id);
/* run the effect */
ifs_compose (active_drawable);
/* Store data for next invocation - both globally and
* as a parasite on this layer
*/
str = ifsvals_stringify (&ifsvals, elements);
gimp_set_data (IFSCOMPOSE_DATA, str, strlen (str) + 1);
parasite = gimp_parasite_new (IFSCOMPOSE_PARASITE,
GIMP_PARASITE_PERSISTENT |
GIMP_PARASITE_UNDOABLE,
strlen (str) + 1, str);
gimp_drawable_parasite_attach (active_drawable->drawable_id,
parasite);
gimp_parasite_free (parasite);
g_free (str);
gimp_undo_push_group_end (image_id);
}
else
{
/* run the effect */
ifs_compose (active_drawable);
}
/* If the run mode is interactive, flush the displays */
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush ();
1997-11-24 22:05:25 +00:00
}
else if (status == GIMP_PDB_SUCCESS)
1997-11-24 22:05:25 +00:00
{
status = GIMP_PDB_EXECUTION_ERROR;
1997-11-24 22:05:25 +00:00
}
values[0].data.d_status = status;
gimp_drawable_detach (active_drawable);
}
static GtkWidget *
ifs_compose_trans_page (void)
1997-11-24 22:05:25 +00:00
{
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *label;
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
1997-11-24 22:05:25 +00:00
table = gtk_table_new (3, 6, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_col_spacing (GTK_TABLE (table), 1, 6);
gtk_table_set_col_spacing (GTK_TABLE (table), 3, 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_row_spacing (GTK_TABLE (table), 1, 4);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
1997-11-24 22:05:25 +00:00
/* X */
label = gtk_label_new (_("X:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
1997-11-24 22:05:25 +00:00
ifsD->x_pair = value_pair_create (&ifsD->current_vals.x, 0.0, 1.0, FALSE,
VALUE_PAIR_DOUBLE);
gtk_table_attach (GTK_TABLE (table), ifsD->x_pair->entry, 1, 2, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->x_pair->entry);
/* Y */
label = gtk_label_new (_("Y:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
1997-11-24 22:05:25 +00:00
ifsD->y_pair = value_pair_create (&ifsD->current_vals.y, 0.0, 1.0, FALSE,
VALUE_PAIR_DOUBLE);
gtk_table_attach (GTK_TABLE (table), ifsD->y_pair->entry, 1, 2, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->y_pair->entry);
/* Scale */
label = gtk_label_new (_("Scale:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
1997-11-24 22:05:25 +00:00
ifsD->scale_pair = value_pair_create (&ifsD->current_vals.scale, 0.0, 1.0,
FALSE, VALUE_PAIR_DOUBLE);
gtk_table_attach (GTK_TABLE (table), ifsD->scale_pair->entry, 3, 4, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->scale_pair->entry);
/* Angle */
label = gtk_label_new (_("Angle:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0);
gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
1997-11-24 22:05:25 +00:00
ifsD->angle_pair = value_pair_create (&ifsD->current_vals.theta, -180, 180,
FALSE, VALUE_PAIR_DOUBLE);
gtk_table_attach (GTK_TABLE (table), ifsD->angle_pair->entry, 3, 4, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->angle_pair->entry);
/* Asym */
label = gtk_label_new (_("Asymmetry:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 4, 5, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
1997-11-24 22:05:25 +00:00
ifsD->asym_pair = value_pair_create (&ifsD->current_vals.asym, 0.10, 10.0,
FALSE, VALUE_PAIR_DOUBLE);
gtk_table_attach (GTK_TABLE (table), ifsD->asym_pair->entry, 5, 6, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->asym_pair->entry);
/* Shear */
label = gtk_label_new (_("Shear:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 4, 5, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
1997-11-24 22:05:25 +00:00
ifsD->shear_pair = value_pair_create (&ifsD->current_vals.shear, -10.0, 10.0,
FALSE, VALUE_PAIR_DOUBLE);
gtk_table_attach (GTK_TABLE (table), ifsD->shear_pair->entry, 5, 6, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->shear_pair->entry);
/* Flip */
1999-11-17 14:39:11 +00:00
ifsD->flip_check_button = gtk_check_button_new_with_label (_("Flip"));
gtk_table_attach (GTK_TABLE (table), ifsD->flip_check_button, 0, 6, 2, 3,
GTK_FILL, GTK_FILL, 0, 0);
g_signal_connect (ifsD->flip_check_button, "toggled",
G_CALLBACK (flip_check_button_callback),
NULL);
gtk_widget_show (ifsD->flip_check_button);
1997-11-24 22:05:25 +00:00
return vbox;
}
static GtkWidget *
ifs_compose_color_page (void)
1997-11-24 22:05:25 +00:00
{
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *label;
GSList *group = NULL;
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
GimpRGB color;
1997-11-24 22:05:25 +00:00
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
1997-11-24 22:05:25 +00:00
table = gtk_table_new (3, 5, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
1997-11-24 22:05:25 +00:00
/* Simple color control section */
1999-11-17 14:39:11 +00:00
ifsD->simple_button = gtk_radio_button_new_with_label (group, _("Simple"));
gtk_table_attach (GTK_TABLE (table), ifsD->simple_button, 0, 1, 0, 2,
GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
group = gtk_radio_button_group (GTK_RADIO_BUTTON (ifsD->simple_button));
g_signal_connect (ifsD->simple_button, "toggled",
G_CALLBACK (simple_color_toggled),
NULL);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->simple_button);
ifsD->target_cmap = color_map_create (_("IfsCompose: Target"), NULL,
&ifsD->current_vals.target_color, TRUE);
gtk_table_attach (GTK_TABLE (table), ifsD->target_cmap->hbox, 1, 2, 0, 2,
GTK_FILL, 0, 0, 0);
gtk_widget_show (ifsD->target_cmap->hbox);
label = gtk_label_new (_("Scale Hue by:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
1997-11-24 22:05:25 +00:00
ifsD->hue_scale_pair = value_pair_create (&ifsD->current_vals.hue_scale,
0.0, 1.0, TRUE, VALUE_PAIR_DOUBLE);
gtk_table_attach (GTK_TABLE (table), ifsD->hue_scale_pair->scale, 3, 4, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->hue_scale_pair->scale);
gtk_table_attach (GTK_TABLE (table), ifsD->hue_scale_pair->entry, 4, 5, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->hue_scale_pair->entry);
label = gtk_label_new (_("Scale Value by:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
1997-11-24 22:05:25 +00:00
ifsD->value_scale_pair = value_pair_create (&ifsD->current_vals.value_scale,
0.0, 1.0, TRUE, VALUE_PAIR_DOUBLE);
gtk_table_attach (GTK_TABLE (table), ifsD->value_scale_pair->scale,
3, 4, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->value_scale_pair->scale);
gtk_table_attach (GTK_TABLE (table), ifsD->value_scale_pair->entry,
4, 5, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->value_scale_pair->entry);
/* Full color control section */
1999-11-17 14:39:11 +00:00
ifsD->full_button = gtk_radio_button_new_with_label (group, _("Full"));
gtk_table_attach (GTK_TABLE (table), ifsD->full_button, 0, 1, 2, 3,
GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
group = gtk_radio_button_group (GTK_RADIO_BUTTON (ifsD->full_button));
gtk_widget_show (ifsD->full_button);
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
gimp_rgb_set (&color, 1.0, 0.0, 0.0);
ifsD->red_cmap = color_map_create (_("IfsCompose: Red"), &color,
&ifsD->current_vals.red_color, FALSE);
gtk_table_attach (GTK_TABLE (table), ifsD->red_cmap->hbox, 1, 2, 2, 3,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (ifsD->red_cmap->hbox);
1997-11-24 22:05:25 +00:00
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
gimp_rgb_set (&color, 0.0, 1.0, 0.0);
ifsD->green_cmap = color_map_create ( _("IfsCompose: Green"), &color,
&ifsD->current_vals.green_color, FALSE);
gtk_table_attach (GTK_TABLE (table), ifsD->green_cmap->hbox, 2, 3, 2, 3,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (ifsD->green_cmap->hbox);
1997-11-24 22:05:25 +00:00
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
gimp_rgb_set (&color, 0.0, 0.0, 1.0);
ifsD->blue_cmap = color_map_create (_("IfsCompose: Blue"), &color,
&ifsD->current_vals.blue_color, FALSE);
gtk_table_attach (GTK_TABLE (table), ifsD->blue_cmap->hbox, 3, 4, 2, 3,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (ifsD->blue_cmap->hbox);
1997-11-24 22:05:25 +00:00
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
gimp_rgb_set (&color, 0.0, 0.0, 0.0);
ifsD->black_cmap = color_map_create (_("IfsCompose: Black"), &color,
&ifsD->current_vals.black_color, FALSE);
gtk_table_attach (GTK_TABLE (table), ifsD->black_cmap->hbox, 4, 5, 2, 3,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (ifsD->black_cmap->hbox);
1997-11-24 22:05:25 +00:00
return vbox;
}
static gint
ifs_compose_dialog (GimpDrawable *drawable)
1997-11-24 22:05:25 +00:00
{
GtkWidget *dlg;
GtkWidget *label;
GtkWidget *button;
GtkWidget *check_button;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *util_hbox;
GtkWidget *main_vbox;
GtkWidget *alignment;
GtkWidget *aspect_frame;
GtkWidget *notebook;
GtkWidget *page;
gint design_width;
gint design_height;
1997-11-24 22:05:25 +00:00
design_width = drawable->width;
1997-11-24 22:05:25 +00:00
design_height = drawable->height;
if (design_width > design_height)
{
if (design_width > DESIGN_AREA_MAX_SIZE)
{
design_height = design_height * DESIGN_AREA_MAX_SIZE / design_width;
design_width = DESIGN_AREA_MAX_SIZE;
}
}
else
{
if (design_height > DESIGN_AREA_MAX_SIZE)
{
design_width = design_width * DESIGN_AREA_MAX_SIZE / design_height;
design_height = DESIGN_AREA_MAX_SIZE;
}
}
ifsD = g_new (IfsDialog, 1);
ifsD->auto_preview = TRUE;
1997-11-24 22:05:25 +00:00
ifsD->drawable_width = drawable->width;
ifsD->drawable_height = drawable->height;
ifsD->selected_orig = NULL;
ifsD->preview_data = NULL;
ifsD->preview_iterations = 0;
ifsD->in_update = 0;
gimprc.in replaced "color-cube" by "min-colors". 2000-04-30 Michael Natterer <mitch@gimp.org> * gimprc.in * app/gimprc.[ch]: replaced "color-cube" by "min-colors". * app/app_procs.c: read unitrc/gimprc before displaying the splash. * app/colormaps.c: set min_colors and install_cmap before initializing GdkRGB. * app/gimprc.[ch] * app/gimpunit.c: don't call the splash's progress_update function. * app/plug_in.c: pass min_colors instead of color_cube to plugins. * app/preferences_dialog.c: widget for min_colors. * libgimp/gimp.[ch]: s/color_cube/min_colors/ but left gimp_color_cube() there for source level compatibility. * libgimp/gimpprotocol.[ch]: changed the GPConfig message accordinly and increased the gimp protocol version number because the change breaks binary compatibility. Also actually pass the use_xshm variable over the wire (was only in the GPConfig struct before). Was it the right thing to do to increase the version number?? * libgimp/gimpui.c (gimp_ui_init): use the same code as the app for initializing GdkRGB. Never explicitly activate Gdk's SHM usage (only switch it off). * app/main.c * libgimp/gimp.c: reverted the handling of all signals except SIGCHLD back to plain old signal() because those signals are fatal anyway and sigaction() as used by gimp_signal_*() made debugging (stacktrace) impossible. * plug-ins/AlienMap/AlienMap.c * plug-ins/AlienMap2/AlienMap2.c * plug-ins/FractalExplorer/Dialogs.c * plug-ins/bmp/bmp.c * plug-ins/borderaverage/borderaverage.c * plug-ins/dbbrowser/dbbrowser.c * plug-ins/faxg3/faxg3.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp.c * plug-ins/fp/fp_gtk.c * plug-ins/gdyntext/Makefile.am * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/helpbrowser/helpbrowser.c * plug-ins/ifscompose/ifscompose.c * plug-ins/imagemap/Makefile.am * plug-ins/imagemap/imap_main.c * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print.c * plug-ins/rcm/rcm_dialog.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/Makefile.am * plug-ins/sel2path/sel2path.c * plug-ins/sgi/sgi.c * plug-ins/sinus/sinus.c * plug-ins/struc/struc.c * plug-ins/webbrowser/webbrowser.c * plug-ins/winsnap/winsnap.c * plug-ins/xjt/xjt.c: use gimp_ui_init(). * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c: only switch Gdk SHM usage off, never on. Don't use gimp_ui_init() here because of libgck.
2000-04-30 18:17:55 +00:00
gimp_ui_init ("ifscompose", TRUE);
1997-11-24 22:05:25 +00:00
dlg = gimp_dialog_new (_("IfsCompose"), "ifscompose",
gimp_standard_help_func, "filters/ifscompose.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GIMP_STOCK_RESET, ifs_compose_defaults_callback,
NULL, NULL, NULL, FALSE, FALSE,
GTK_STOCK_OPEN, ifs_compose_load_callback,
NULL, NULL, NULL, FALSE, FALSE,
GTK_STOCK_SAVE, ifs_compose_save_callback,
NULL, NULL, NULL, FALSE, FALSE,
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
GTK_STOCK_OK, ifs_compose_ok_callback,
NULL, NULL, NULL, TRUE, FALSE,
1997-11-24 22:05:25 +00:00
NULL);
1997-11-24 22:05:25 +00:00
g_object_add_weak_pointer (G_OBJECT (dlg), (gpointer *) &dlg);
g_signal_connect (dlg, "destroy",
G_CALLBACK (gtk_main_quit),
NULL);
1997-11-24 22:05:25 +00:00
/* The main vbox */
main_vbox = gtk_vbox_new (FALSE, 6);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox,
TRUE, TRUE, 0);
1997-11-24 22:05:25 +00:00
/* The design area */
hbox = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
aspect_frame = gtk_aspect_frame_new (NULL,
0.5, 0.5,
(gdouble) design_width / design_height,
0);
1997-11-24 22:05:25 +00:00
gtk_frame_set_shadow_type (GTK_FRAME (aspect_frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (hbox), aspect_frame, TRUE, TRUE, 0);
design_area_create (dlg, design_width, design_height);
1997-11-24 22:05:25 +00:00
gtk_container_add (GTK_CONTAINER (aspect_frame), ifsDesign->area);
gtk_widget_show (ifsDesign->area);
gtk_widget_show (aspect_frame);
/* The Preview */
1997-11-24 22:05:25 +00:00
aspect_frame = gtk_aspect_frame_new (NULL,
0.5, 0.5,
(gdouble) design_width / design_height,
0);
1997-11-24 22:05:25 +00:00
gtk_frame_set_shadow_type (GTK_FRAME (aspect_frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (hbox), aspect_frame, TRUE, TRUE, 0);
ifsD->preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (ifsD->preview), design_width, design_height);
1997-11-24 22:05:25 +00:00
gtk_container_add (GTK_CONTAINER (aspect_frame), ifsD->preview);
gtk_widget_show (ifsD->preview);
gtk_widget_show (aspect_frame);
gtk_widget_show (hbox);
/* Iterations and preview options */
hbox = gtk_hbox_new (TRUE, 4);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
alignment = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
gtk_box_pack_start (GTK_BOX (hbox), alignment, TRUE, TRUE, 0);
1997-11-24 22:05:25 +00:00
util_hbox = gtk_hbox_new (FALSE, 4);
gtk_container_add (GTK_CONTAINER (alignment), util_hbox);
1997-11-24 22:05:25 +00:00
ifsD->move_button = gtk_toggle_button_new_with_label (_("Move"));
gtk_box_pack_start (GTK_BOX (util_hbox), ifsD->move_button,
TRUE, TRUE, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->move_button);
ifsD->move_handler =
g_signal_connect (ifsD->move_button, "toggled",
G_CALLBACK (design_op_callback),
GINT_TO_POINTER (OP_TRANSLATE));
1997-11-24 22:05:25 +00:00
ifsD->rotate_button = gtk_toggle_button_new_with_label (_("Rotate/Scale"));
gtk_box_pack_start (GTK_BOX (util_hbox), ifsD->rotate_button,
TRUE, TRUE, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->rotate_button);
ifsD->rotate_handler =
g_signal_connect (ifsD->rotate_button, "toggled",
G_CALLBACK (design_op_callback),
GINT_TO_POINTER (OP_ROTATE));
1997-11-24 22:05:25 +00:00
ifsD->stretch_button = gtk_toggle_button_new_with_label (_("Stretch"));
gtk_box_pack_start (GTK_BOX (util_hbox), ifsD->stretch_button,
TRUE, TRUE, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsD->stretch_button);
ifsD->stretch_handler =
g_signal_connect (ifsD->stretch_button, "toggled",
G_CALLBACK (design_op_callback),
GINT_TO_POINTER (OP_STRETCH));
1997-11-24 22:05:25 +00:00
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ifsD->move_button), TRUE);
1997-11-24 22:05:25 +00:00
gtk_widget_show (alignment);
1997-11-24 22:05:25 +00:00
gtk_widget_show (util_hbox);
alignment = gtk_alignment_new (1.0, 0.5, 0.0, 0.0);
1997-11-24 22:05:25 +00:00
gtk_box_pack_start (GTK_BOX (hbox), alignment, TRUE, TRUE, 0);
util_hbox = gtk_hbox_new (FALSE, 4);
gtk_container_add (GTK_CONTAINER (alignment), util_hbox);
1997-11-24 22:05:25 +00:00
1999-11-17 14:39:11 +00:00
button = gtk_button_new_with_label (_("Render Options"));
g_signal_connect (button, "clicked",
G_CALLBACK (ifs_options_dialog),
NULL);
gtk_box_pack_start (GTK_BOX (util_hbox), button, TRUE, TRUE, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (button);
1999-11-17 14:39:11 +00:00
button = gtk_button_new_with_label (_("Preview"));
g_signal_connect (button, "clicked",
G_CALLBACK (ifs_compose_preview),
NULL);
gtk_box_pack_start (GTK_BOX (util_hbox), button, TRUE, TRUE, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (button);
1999-11-17 14:39:11 +00:00
check_button = gtk_check_button_new_with_label (_("Auto"));
gtk_box_pack_start (GTK_BOX (util_hbox), check_button, TRUE, TRUE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
ifsD->auto_preview);
g_signal_connect (check_button, "toggled",
G_CALLBACK (auto_preview_callback),
NULL);
1997-11-24 22:05:25 +00:00
gtk_widget_show (check_button);
gtk_widget_show (util_hbox);
gtk_widget_show (alignment);
gtk_widget_show (hbox);
/* second util row */
hbox = gtk_hbox_new (TRUE, 4);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
alignment = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
gtk_box_pack_start (GTK_BOX (hbox), alignment, TRUE, TRUE, 0);
util_hbox = gtk_hbox_new (FALSE, 4);
gtk_container_add (GTK_CONTAINER (alignment), util_hbox);
button = gtk_button_new_from_stock (GTK_STOCK_NEW);
g_signal_connect (button, "clicked",
G_CALLBACK (ifs_compose_new_callback), NULL);
gtk_box_pack_start (GTK_BOX (util_hbox), button, TRUE, TRUE, 0);
gtk_widget_show (button);
ifsD->delete_button = gtk_button_new_from_stock (GTK_STOCK_DELETE);
g_signal_connect (ifsD->delete_button, "clicked",
G_CALLBACK (ifs_compose_delete_callback), NULL);
gtk_box_pack_start (GTK_BOX (util_hbox), ifsD->delete_button, TRUE, TRUE, 0);
gtk_widget_show (ifsD->delete_button);
ifsD->undo_button = gtk_button_new_from_stock (GTK_STOCK_UNDO);
gtk_box_pack_start (GTK_BOX (util_hbox), ifsD->undo_button,
TRUE, TRUE, 0);
g_signal_connect (ifsD->undo_button, "clicked",
G_CALLBACK (undo), NULL);
gtk_widget_set_sensitive (ifsD->undo_button, FALSE);
gtk_widget_show (ifsD->undo_button);
ifsD->redo_button = gtk_button_new_from_stock (GTK_STOCK_REDO);
gtk_box_pack_start (GTK_BOX (util_hbox), ifsD->redo_button,
TRUE, TRUE, 0);
g_signal_connect (ifsD->redo_button, "clicked",
G_CALLBACK (redo), NULL);
gtk_widget_set_sensitive (ifsD->redo_button, FALSE);
gtk_widget_show (ifsD->redo_button);
button = gtk_button_new_with_mnemonic (_("Select _All"));
gtk_box_pack_start (GTK_BOX (util_hbox), button,
TRUE, TRUE, 0);
g_signal_connect (button, "clicked",
G_CALLBACK (design_area_select_all_callback), NULL);
gtk_widget_show (button);
button = gtk_button_new_with_mnemonic (_("Recompute _Center"));
gtk_box_pack_start (GTK_BOX (util_hbox), button, TRUE, TRUE, 0);
g_signal_connect (button, "clicked",
G_CALLBACK (recompute_center_cb), NULL);
gtk_widget_show (button);
gtk_widget_show (util_hbox);
gtk_widget_show (alignment);
gtk_widget_show (hbox);
1997-11-24 22:05:25 +00:00
/* The current transformation frame */
ifsD->current_frame = gtk_frame_new (NULL);
1997-11-24 22:05:25 +00:00
gtk_frame_set_shadow_type (GTK_FRAME (ifsD->current_frame),
GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start (GTK_BOX (main_vbox), ifsD->current_frame,
FALSE, FALSE, 0);
1997-11-24 22:05:25 +00:00
vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
gtk_container_add (GTK_CONTAINER (ifsD->current_frame), vbox);
1997-11-24 22:05:25 +00:00
/* The notebook */
notebook = gtk_notebook_new ();
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
gtk_box_pack_start (GTK_BOX (vbox), notebook, FALSE, FALSE, 0);
gtk_widget_show (notebook);
1997-11-24 22:05:25 +00:00
page = ifs_compose_trans_page ();
label = gtk_label_new (_("Spatial Transformation"));
gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
gtk_widget_show (page);
1997-11-24 22:05:25 +00:00
page = ifs_compose_color_page ();
label = gtk_label_new (_("Color Transformation"));
gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
gtk_widget_show (page);
1997-11-24 22:05:25 +00:00
/* The probability entry */
hbox = gtk_hbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
1999-11-17 14:39:11 +00:00
label = gtk_label_new (_("Relative Probability:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (label);
ifsD->prob_pair = value_pair_create (&ifsD->current_vals.prob, 0.0, 5.0, TRUE,
VALUE_PAIR_DOUBLE);
1997-11-24 22:05:25 +00:00
gtk_box_pack_start (GTK_BOX (hbox), ifsD->prob_pair->scale, TRUE, TRUE, 0);
gtk_widget_show (ifsD->prob_pair->scale);
gtk_box_pack_start (GTK_BOX (hbox), ifsD->prob_pair->entry, FALSE, TRUE, 0);
gtk_widget_show (ifsD->prob_pair->entry);
gtk_widget_show (hbox);
gtk_widget_show (vbox);
gtk_widget_show (ifsD->current_frame);
1997-11-24 22:05:25 +00:00
gtk_widget_show (main_vbox);
if (ifsvals.num_elements == 0)
{
ifs_compose_set_defaults ();
1997-11-24 22:05:25 +00:00
if (ifsD->auto_preview)
ifs_compose_preview ();
1997-11-24 22:05:25 +00:00
}
else
{
gint i;
gdouble ratio = (gdouble) ifsD->drawable_height / ifsD->drawable_width;
1997-11-24 22:05:25 +00:00
element_selected = g_new (gint, ifsvals.num_elements);
1997-11-24 22:05:25 +00:00
element_selected[0] = TRUE;
for (i = 1; i < ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
element_selected[i] = FALSE;
if (ratio != ifsvals.aspect_ratio)
{
/* Adjust things so that what fit onto the old image, fits
onto the new image */
Aff2 t1, t2, t3;
1997-11-24 22:05:25 +00:00
gdouble x_offset, y_offset;
gdouble center_x, center_y;
gdouble scale;
if (ratio < ifsvals.aspect_ratio)
{
scale = ratio/ifsvals.aspect_ratio;
x_offset = (1-scale)/2;
y_offset = 0;
}
else
{
scale = 1;
x_offset = 0;
y_offset = (ratio - ifsvals.aspect_ratio)/2;
}
aff2_scale (&t1, scale, 0);
aff2_translate (&t2, x_offset, y_offset);
aff2_compose (&t3, &t2, &t1);
aff2_invert (&t1, &t3);
1997-11-24 22:05:25 +00:00
aff2_apply (&t3, ifsvals.center_x, ifsvals.center_y, &center_x,
&center_y);
1997-11-24 22:05:25 +00:00
for (i = 0; i < ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
{
aff_element_compute_trans (elements[i],1, ifsvals.aspect_ratio,
ifsvals.center_x, ifsvals.center_y);
aff2_compose (&t2, &elements[i]->trans, &t1);
aff2_compose (&elements[i]->trans, &t3, &t2);
aff_element_decompose_trans (elements[i],&elements[i]->trans,
1, ifsvals.aspect_ratio,
center_x, center_y);
1997-11-24 22:05:25 +00:00
}
ifsvals.center_x = center_x;
ifsvals.center_y = center_y;
ifsvals.aspect_ratio = ratio;
}
for (i = 0; i < ifsvals.num_elements; i++)
aff_element_compute_color_trans (elements[i]);
1997-11-24 22:05:25 +00:00
/* boundary and spatial transformations will be computed
when the design_area gets a ConfigureNotify event */
set_current_element (0);
1997-11-24 22:05:25 +00:00
if (ifsD->auto_preview)
ifs_compose_preview ();
1997-11-24 22:05:25 +00:00
ifsD->selected_orig = g_new (AffElement, ifsvals.num_elements);
1997-11-24 22:05:25 +00:00
}
gtk_widget_show (dlg);
gtk_main ();
g_object_unref (ifsDesign->op_menu);
if (dlg)
gtk_widget_destroy (dlg);
1997-11-24 22:05:25 +00:00
if (ifsOptD)
gtk_widget_destroy (ifsOptD->dialog);
1997-11-24 22:05:25 +00:00
gdk_flush ();
g_object_unref (ifsDesign->selected_gc);
1997-11-24 22:05:25 +00:00
g_free (ifsD);
1997-11-24 22:05:25 +00:00
return ifscint.run;
}
static void
design_area_create (GtkWidget *window,
gint design_width,
gint design_height)
1997-11-24 22:05:25 +00:00
{
ifsDesign = g_new (IfsDesignArea, 1);
1997-11-24 22:05:25 +00:00
ifsDesign->op = OP_TRANSLATE;
1997-11-24 22:05:25 +00:00
ifsDesign->button_state = 0;
ifsDesign->pixmap = NULL;
ifsDesign->selected_gc = NULL;
1997-11-24 22:05:25 +00:00
ifsDesign->area = gtk_drawing_area_new ();
gtk_widget_set_size_request (ifsDesign->area, design_width, design_height);
g_signal_connect (ifsDesign->area, "expose_event",
G_CALLBACK (design_area_expose),
NULL);
g_signal_connect (ifsDesign->area, "button_press_event",
G_CALLBACK (design_area_button_press),
NULL);
g_signal_connect (ifsDesign->area, "button_release_event",
G_CALLBACK (design_area_button_release),
NULL);
g_signal_connect (ifsDesign->area, "motion_notify_event",
G_CALLBACK (design_area_motion),
NULL);
g_signal_connect (ifsDesign->area, "configure_event",
G_CALLBACK (design_area_configure),
NULL);
1997-11-24 22:05:25 +00:00
gtk_widget_set_events (ifsDesign->area,
GDK_EXPOSURE_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK |
1997-11-24 22:05:25 +00:00
GDK_POINTER_MOTION_HINT_MASK);
design_op_menu_create (window);
1997-11-24 22:05:25 +00:00
}
static void
design_op_menu_create (GtkWidget *window)
1997-11-24 22:05:25 +00:00
{
static GtkItemFactoryEntry menu_items[] = {
{ "/Move", "M", design_op_update_callback,
OP_TRANSLATE, "<RadioItem>", NULL },
{ "/Rotate\\/Scale", "R", design_op_update_callback,
OP_ROTATE, "/Move", NULL },
{ "/Stretch", "S", design_op_update_callback,
OP_STRETCH, "/Move", NULL },
{ "/sep1", NULL, NULL, 0, "<Separator>", NULL },
{ "/New", "<control>N", ifs_compose_new_callback,
0, "<StockItem>", GTK_STOCK_NEW },
{ "/Delete", "<control>D", ifs_compose_delete_callback,
0, "<StockItem>", GTK_STOCK_DELETE },
{ "/Undo", "<control>Z", undo,
0, "<StockItem>", GTK_STOCK_UNDO },
{ "/Redo", "<control>R", redo,
0, "<StockItem>", GTK_STOCK_REDO },
{ "/Select All", "<control>A", design_area_select_all_callback,
0, NULL, NULL },
{ "/Recompute Center", "<control>C", recompute_center_cb,
0, NULL, NULL },
};
1997-11-24 22:05:25 +00:00
GtkAccelGroup *accel_group;
GtkItemFactory *item_factory;
1997-11-24 22:05:25 +00:00
accel_group = gtk_accel_group_new ();
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
1997-11-24 22:05:25 +00:00
item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<main>",
accel_group);
gtk_item_factory_create_items (item_factory,
sizeof(menu_items)/sizeof(GtkItemFactoryEntry),
menu_items, NULL);
ifsDesign->op_menu = gtk_item_factory_get_widget (item_factory, "<main>");
g_object_ref (ifsDesign->op_menu);
gtk_object_sink (GTK_OBJECT (ifsDesign->op_menu));
gtk_accel_group_lock (accel_group);
ifsD->undo_menu_item = gtk_item_factory_get_widget (item_factory, "/Undo");
gtk_widget_set_sensitive (ifsD->undo_menu_item, FALSE);
ifsD->redo_menu_item = gtk_item_factory_get_widget (item_factory, "/Redo");
gtk_widget_set_sensitive (ifsD->redo_menu_item, FALSE);
ifsD->delete_menu_item = gtk_item_factory_get_widget (item_factory, "/Delete");
1997-11-24 22:05:25 +00:00
}
static void
design_op_menu_popup (gint button,
guint32 activate_time)
1997-11-24 22:05:25 +00:00
{
gtk_menu_popup (GTK_MENU (ifsDesign->op_menu),
NULL, NULL, NULL, NULL,
button, activate_time);
1997-11-24 22:05:25 +00:00
}
static void
ifs_options_dialog (void)
1997-11-24 22:05:25 +00:00
{
GtkWidget *table;
GtkWidget *label;
if (!ifsOptD)
{
ifsOptD = g_new (IfsOptionsDialog, 1);
1997-11-24 22:05:25 +00:00
ifsOptD->dialog =
gimp_dialog_new (_("IfsCompose Options"), "ifscompose",
gimp_standard_help_func, "filters/ifscompose.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
2001-08-03 19:52:08 +00:00
GTK_STOCK_CLOSE, gtk_widget_hide,
NULL, 1, NULL, TRUE, TRUE,
NULL);
1997-11-24 22:05:25 +00:00
/* Table of options */
table = gtk_table_new (4, 3, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table), 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (ifsOptD->dialog)->vbox), table,
FALSE, FALSE, 0);
gtk_widget_show (table);
label = gtk_label_new (_("Max. Memory:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
ifsOptD->memory_pair = value_pair_create (&ifsvals.max_memory,
1, 1000000, FALSE,
VALUE_PAIR_INT);
gtk_table_attach (GTK_TABLE (table), ifsOptD->memory_pair->entry,
1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsOptD->memory_pair->entry);
label = gtk_label_new (_("Iterations:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
1997-11-24 22:05:25 +00:00
ifsOptD->iterations_pair = value_pair_create (&ifsvals.iterations,
1, 10000000, FALSE,
VALUE_PAIR_INT);
gtk_table_attach (GTK_TABLE (table), ifsOptD->iterations_pair->entry,
1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsOptD->iterations_pair->entry);
gtk_widget_show (label);
label = gtk_label_new (_("Subdivide:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
ifsOptD->subdivide_pair = value_pair_create (&ifsvals.subdivide,
1, 10, FALSE,
VALUE_PAIR_INT);
gtk_table_attach (GTK_TABLE (table), ifsOptD->subdivide_pair->entry,
1, 2, 2, 3, GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsOptD->subdivide_pair->entry);
label = gtk_label_new (_("Spot Radius:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
ifsOptD->radius_pair = value_pair_create (&ifsvals.radius,
0, 5, TRUE,
VALUE_PAIR_DOUBLE);
gtk_table_attach (GTK_TABLE (table), ifsOptD->radius_pair->scale,
1, 2, 3, 4, GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsOptD->radius_pair->scale);
gtk_table_attach (GTK_TABLE (table), ifsOptD->radius_pair->entry,
2, 3, 3, 4, GTK_FILL, GTK_FILL, 0, 0);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsOptD->radius_pair->entry);
value_pair_update (ifsOptD->iterations_pair);
value_pair_update (ifsOptD->subdivide_pair);
value_pair_update (ifsOptD->memory_pair);
value_pair_update (ifsOptD->radius_pair);
1997-11-24 22:05:25 +00:00
gtk_widget_show (ifsOptD->dialog);
}
else
{
if (!GTK_WIDGET_VISIBLE (ifsOptD->dialog))
gtk_widget_show (ifsOptD->dialog);
}
}
static void
ifs_compose (GimpDrawable *drawable)
1997-11-24 22:05:25 +00:00
{
GimpImageType type = gimp_drawable_type (drawable->drawable_id);
gchar *buffer;
gint width = drawable->width;
gint height = drawable->height;
gint num_bands, band_height, band_y, band_no;
gint i, j;
guchar *data;
guchar *mask = NULL;
guchar *nhits;
guchar rc, gc, bc;
GimpRGB color;
1997-11-24 22:05:25 +00:00
num_bands = ceil((gdouble)(width*height*SQR(ifsvals.subdivide)*5)
/ (1024 * ifsvals.max_memory));
band_height = (height + num_bands - 1) / num_bands;
1997-11-24 22:05:25 +00:00
if (band_height > height)
band_height = height;
tools/pdbgen/lib.pl tools/pdbgen/pdb.pl tools/pdbgen/pdb/channel.pdb 2001-01-25 Sven Neumann <sven@gimp.org> * tools/pdbgen/lib.pl * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: changed these with the help of Yosh. PDB functions take GimpRGB as color type now. * app/plug_in.c * app/pdb/channel_cmds.c * app/pdb/internal_procs.c * app/pdb/palette_cmds.c * app/pdb/procedural_db.[ch] * app/pdb/tools_cmds.c * libgimp/gimp.[ch] * libgimp/gimpchannel.[ch] * libgimp/gimpchannel_pdb.[ch] * libgimp/gimppalette_pdb.[ch] * libgimp/gimpprotocol.[ch] * libgimp/gimptools_pdb.[ch]: incremented Gimp protocol version and changed color type from array of chars to GimpRGB. * libgimp/Makefile.am * libgimp/gimppalette.[ch]: removed these files again * app/libgimp_glue.[ch] * libgimpwidgets/gimpcolorbutton.c * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_preview.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/psd.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/tiff.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gap/gap_filter_iterators.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gdyntext/gdyntext.c * plug-ins/gfig/gfig.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu.c * plug-ins/xjt/xjt.c: changed accordingly. A few plug-ins need to be looked at more closely after this change. I tried to put FIXME comments into those.
2001-01-25 01:20:05 +00:00
mask = g_new (guchar, width * band_height * SQR (ifsvals.subdivide));
data = g_new (guchar, width * band_height * SQR (ifsvals.subdivide) * 3);
nhits = g_new (guchar, width * band_height * SQR (ifsvals.subdivide));
tools/pdbgen/lib.pl tools/pdbgen/pdb.pl tools/pdbgen/pdb/channel.pdb 2001-01-25 Sven Neumann <sven@gimp.org> * tools/pdbgen/lib.pl * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: changed these with the help of Yosh. PDB functions take GimpRGB as color type now. * app/plug_in.c * app/pdb/channel_cmds.c * app/pdb/internal_procs.c * app/pdb/palette_cmds.c * app/pdb/procedural_db.[ch] * app/pdb/tools_cmds.c * libgimp/gimp.[ch] * libgimp/gimpchannel.[ch] * libgimp/gimpchannel_pdb.[ch] * libgimp/gimppalette_pdb.[ch] * libgimp/gimpprotocol.[ch] * libgimp/gimptools_pdb.[ch]: incremented Gimp protocol version and changed color type from array of chars to GimpRGB. * libgimp/Makefile.am * libgimp/gimppalette.[ch]: removed these files again * app/libgimp_glue.[ch] * libgimpwidgets/gimpcolorbutton.c * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_preview.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/psd.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/tiff.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gap/gap_filter_iterators.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gdyntext/gdyntext.c * plug-ins/gfig/gfig.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu.c * plug-ins/xjt/xjt.c: changed accordingly. A few plug-ins need to be looked at more closely after this change. I tried to put FIXME comments into those.
2001-01-25 01:20:05 +00:00
gimp_palette_get_background (&color);
gimp_rgb_get_uchar (&color, &rc, &gc, &bc);
1997-11-24 22:05:25 +00:00
band_y = 0;
for (band_no = 0; band_no < num_bands; band_no++)
{
guchar *ptr;
guchar *maskptr;
guchar *dest;
guchar *destrow;
guchar maskval;
GimpPixelRgn dest_rgn;
1997-11-24 22:05:25 +00:00
gint progress;
gint max_progress;
gpointer pr;
buffer = g_strdup_printf (_("Rendering IFS (%d/%d)..."),
band_no+1, num_bands);
gimp_progress_init (buffer);
g_free (buffer);
1997-11-24 22:05:25 +00:00
/* render the band to a buffer */
if (band_y + band_height > height)
band_height = height - band_y;
/* we don't need to clear data since we store nhits */
memset(mask, 0, width*band_height*SQR(ifsvals.subdivide));
memset(nhits, 0, width*band_height*SQR(ifsvals.subdivide));
ifs_render (elements, ifsvals.num_elements, width, height, ifsvals.iterations,
1997-11-24 22:05:25 +00:00
&ifsvals, band_y, band_height, data, mask, nhits, FALSE);
/* transfer the image to the drawable */
buffer = g_strdup_printf (_("Copying IFS to image (%d/%d)..."),
band_no+1, num_bands);
gimp_progress_init (buffer);
g_free (buffer);
1997-11-24 22:05:25 +00:00
progress = 0;
max_progress = band_height * width;
gimp_pixel_rgn_init (&dest_rgn, drawable, 0, band_y,
width, band_height, TRUE, TRUE);
for (pr = gimp_pixel_rgns_register (1, &dest_rgn); pr != NULL; pr = gimp_pixel_rgns_process (pr))
{
destrow = dest_rgn.data;
for (j = dest_rgn.y; j < (dest_rgn.y + dest_rgn.h); j++)
{
dest = destrow;
for (i = dest_rgn.x; i < (dest_rgn.x + dest_rgn.w); i++)
{
/* Accumulate a reduced pixel */
gint ii, jj;
1997-11-24 22:05:25 +00:00
gint rtot=0;
gint btot=0;
gint gtot=0;
gint mtot=0;
for (jj = 0; jj < ifsvals.subdivide; jj++)
1997-11-24 22:05:25 +00:00
{
ptr = data + 3 *
(((j-band_y)*ifsvals.subdivide+jj)*ifsvals.subdivide*width +
i*ifsvals.subdivide);
maskptr = mask +
((j-band_y)*ifsvals.subdivide+jj)*ifsvals.subdivide*width +
i*ifsvals.subdivide;
for (ii = 0; ii < ifsvals.subdivide; ii++)
1997-11-24 22:05:25 +00:00
{
maskval = *maskptr++;
mtot += maskval;
rtot += maskval* *ptr++;
gtot += maskval* *ptr++;
btot += maskval* *ptr++;
}
}
if (mtot)
{
rtot /= mtot;
gtot /= mtot;
btot /= mtot;
mtot /= SQR(ifsvals.subdivide);
}
/* and store it */
switch (type)
{
case GIMP_GRAY_IMAGE:
1997-11-24 22:05:25 +00:00
*dest++ = (mtot*(rtot+btot+gtot)+
(255-mtot)*(rc+gc+bc))/(3*255);
break;
case GIMP_GRAYA_IMAGE:
1997-11-24 22:05:25 +00:00
*dest++ = (rtot+btot+gtot)/3;
*dest++ = mtot;
break;
case GIMP_RGB_IMAGE:
1997-11-24 22:05:25 +00:00
*dest++ = (mtot*rtot + (255-mtot)*rc)/255;
*dest++ = (mtot*gtot + (255-mtot)*gc)/255;
*dest++ = (mtot*btot + (255-mtot)*bc)/255;
break;
case GIMP_RGBA_IMAGE:
1997-11-24 22:05:25 +00:00
*dest++ = rtot;
*dest++ = gtot;
*dest++ = btot;
*dest++ = mtot;
break;
case GIMP_INDEXED_IMAGE:
case GIMP_INDEXEDA_IMAGE:
g_error ("Indexed images not supported by IfsCompose");
1997-11-24 22:05:25 +00:00
break;
}
}
destrow += dest_rgn.rowstride;
1997-11-24 22:05:25 +00:00
}
progress += dest_rgn.w * dest_rgn.h;
gimp_progress_update ((gdouble) progress / (gdouble) max_progress);
}
band_y += band_height;
}
g_free (mask);
g_free (data);
g_free (nhits);
1997-11-24 22:05:25 +00:00
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
gimp_drawable_update (drawable->drawable_id, 0, 0, width, height);
1997-11-24 22:05:25 +00:00
}
static void
update_values (void)
1997-11-24 22:05:25 +00:00
{
ifsD->in_update = TRUE;
ifsD->current_vals = elements[ifsD->current_element]->v;
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc 1999-09-01 Tor Lillqvist <tml@iki.fi> * app/appenv.h * libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc from app/appenv.h here, so plug-ins can use them, too. Remove some commented-out old stuff in appenv.h. * libgimp/gimp.h: Include gimpmath.h. * libgimp/gimp.c (gimp_main): Win32: Don't install signal handlers, we can't do anything useful in the handler ourselves anyway (it would be nice to print out a backtrace, but that seems pretty hard to do, even if not impossible). Let Windows inform the user about the crash. If the plug-in was compiled with MSVC, and the user also has it, she is offered a chance to start the debugger automatically anyway. * app/*several*.c: Include gimpmath.h for G_PI etc. Don't include <math.h>, as gimpmath.h includes it. * plug-ins/*/*many*.c: Include config.h. Don't include <math.h>. Remove all the duplicated definitions of G_PI and rint(). Use RINT() instead of rint(). * app/app_procs.[ch]: app_exit() takes a gboolean. * app/batch.c * app/commands.c * app/interface.c: Call app_exit() with FALSE or TRUE. * app/main.c (on_error): Call gimp_fatal_error. (main): Don't install any signal handler on Win32 here, either. * app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format the message and call MessageBox with it. g_on_error_query doesn't do anything useful on Win32, and printf'ing a message to stdout or stderr doesn't do anything, either, in a windowing application.
1999-09-01 20:30:56 +00:00
ifsD->current_vals.theta *= 180/G_PI;
1997-11-24 22:05:25 +00:00
value_pair_update (ifsD->prob_pair);
value_pair_update (ifsD->x_pair);
value_pair_update (ifsD->y_pair);
value_pair_update (ifsD->scale_pair);
value_pair_update (ifsD->angle_pair);
value_pair_update (ifsD->asym_pair);
value_pair_update (ifsD->shear_pair);
color_map_update (ifsD->red_cmap);
color_map_update (ifsD->green_cmap);
color_map_update (ifsD->blue_cmap);
color_map_update (ifsD->black_cmap);
color_map_update (ifsD->target_cmap);
value_pair_update (ifsD->hue_scale_pair);
value_pair_update (ifsD->value_scale_pair);
1997-11-24 22:05:25 +00:00
if (elements[ifsD->current_element]->v.simple_color)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ifsD->simple_button),
TRUE);
1997-11-24 22:05:25 +00:00
else
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ifsD->full_button),
1997-11-24 22:05:25 +00:00
TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ifsD->flip_check_button),
elements[ifsD->current_element]->v.flip);
1997-11-24 22:05:25 +00:00
ifsD->in_update = FALSE;
simple_color_set_sensitive ();
1997-11-24 22:05:25 +00:00
}
static void
set_current_element (gint index)
1997-11-24 22:05:25 +00:00
{
gchar *frame_name = g_strdup_printf (_("Transformation %s"),
elements[index]->name);
1997-11-24 22:05:25 +00:00
ifsD->current_element = index;
gtk_frame_set_label (GTK_FRAME (ifsD->current_frame),frame_name);
g_free (frame_name);
1997-11-24 22:05:25 +00:00
update_values ();
1997-11-24 22:05:25 +00:00
}
static gint
design_area_expose (GtkWidget *widget,
GdkEventExpose *event)
1997-11-24 22:05:25 +00:00
{
gint i;
gint cx, cy;
1997-11-24 22:05:25 +00:00
if (!ifsDesign->selected_gc)
{
ifsDesign->selected_gc = gdk_gc_new (ifsDesign->area->window);
gdk_gc_set_line_attributes (ifsDesign->selected_gc, 2,
GDK_LINE_SOLID, GDK_CAP_ROUND,
1997-11-24 22:05:25 +00:00
GDK_JOIN_ROUND);
}
gdk_draw_rectangle (ifsDesign->pixmap,
1997-11-24 22:05:25 +00:00
widget->style->bg_gc[widget->state],
TRUE,
event->area.x,
event->area.y,
event->area.width, event->area.height);
1997-11-24 22:05:25 +00:00
/* draw an indicator for the center */
cx = ifsvals.center_x * widget->allocation.width;
cy = ifsvals.center_y * widget->allocation.width;
gdk_draw_line (ifsDesign->pixmap,
1997-11-24 22:05:25 +00:00
widget->style->fg_gc[widget->state],
cx - 10, cy, cx + 10, cy);
gdk_draw_line (ifsDesign->pixmap,
1997-11-24 22:05:25 +00:00
widget->style->fg_gc[widget->state],
cx, cy - 10, cx, cy + 10);
for (i = 0; i < ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
{
aff_element_draw (elements[i], element_selected[i],
1997-11-24 22:05:25 +00:00
widget->allocation.width,
widget->allocation.height,
ifsDesign->pixmap,
widget->style->fg_gc[widget->state],
ifsDesign->selected_gc,
need to link with pangof2 2001-09-22 Hans Breuer <hans@breuer.org> * app/makefile.msc : need to link with pangof2 * app/display/display-funcs.h : new file to provide prototype gdisplays_selection_visibility () * app/core/gimpimage-mask.c : * app/core/gimplayer.c : use it * app/core/makefile.msc : generate gimpmarshal.[hc] * app/gui/makefile.msc : add error-console-dialog.obj, also more trying for building as dll * app/tools/gimpinktool.c(965) : avoid "fatal error C1021: invalid preprocessor command 'warning'", by wrapping it in #ifdef __GNUC__ * app/tools/makefile.msc : add FREETYPE2_CFLAGS * app/widgets/gimpfontselction-dialog.c : use g_strcasecmp () * app/tools/makefile.msc : add FREETYPE2_CFLAGS and gimpfontselction* * libgimp/gimp.def : * libgimpwidgets/gimpwidgets.def : updated externals * libgimpwidgets/makefile.msc : add gimpstock * plug-ins/makefile.msc : gflare doesn't require EXTRA_gflare anymore * plug-ins/common/spheredesigner.c : * plug-ins/helpbrowser/helpbrowser.c : * plug-ins/imagemap/imap_main.c : remove _help_accel from gimp_help_connect () * plug-ins/gap/gap_mov_dialog.c : * plug-ins/gap/gap_navigator_dialog.c : remove references to use_xshm and gimp_color_cube () * plug-ins/gfig/gfig.c : don't access ->klass, but use G_OBJECT_GET_CLASS * plug-ins/gimpressionist/repaint.c : the GtkButton::child field is moved to the parent GtkBin. * plug-ins/ifscompose/ifscompose.c : the GtkStyle::font field isn't public anymore, use accessor gtk_style_get_font () * plug-ins/imagemap/imap_preferences.c : reflect GTK2 API change gtk_notebook_set_current_page ()
2001-09-22 19:47:27 +00:00
gtk_style_get_font (ifsDesign->area->style));
1997-11-24 22:05:25 +00:00
}
gdk_draw_drawable (widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
ifsDesign->pixmap,
event->area.x, event->area.y,
event->area.x, event->area.y,
event->area.width, event->area.height);
1997-11-24 22:05:25 +00:00
return FALSE;
}
static gint
design_area_configure (GtkWidget *widget,
GdkEventConfigure *event)
1997-11-24 22:05:25 +00:00
{
gint i;
1997-11-24 22:05:25 +00:00
gdouble width = widget->allocation.width;
gdouble height = widget->allocation.height;
for (i = 0; i < ifsvals.num_elements; i++)
aff_element_compute_trans (elements[i],width, height,
1997-11-24 22:05:25 +00:00
ifsvals.center_x, ifsvals.center_y);
for (i = 0; i < ifsvals.num_elements; i++)
aff_element_compute_boundary (elements[i],width, height,
1997-11-24 22:05:25 +00:00
elements, ifsvals.num_elements);
if (ifsDesign->pixmap)
{
g_object_unref (ifsDesign->pixmap);
1997-11-24 22:05:25 +00:00
}
ifsDesign->pixmap = gdk_pixmap_new (widget->window,
1997-11-24 22:05:25 +00:00
widget->allocation.width,
widget->allocation.height,
gtk_preview_get_visual ()->depth);
1997-11-24 22:05:25 +00:00
return FALSE;
}
static gint
design_area_button_press (GtkWidget *widget,
GdkEventButton *event)
1997-11-24 22:05:25 +00:00
{
gint i;
gdouble width = ifsDesign->area->allocation.width;
gint old_current;
gtk_widget_grab_focus (widget);
1997-11-24 22:05:25 +00:00
if (event->button != 1 ||
(ifsDesign->button_state & GDK_BUTTON1_MASK))
{
if (event->button == 3)
design_op_menu_popup (event->button, event->time);
1997-11-24 22:05:25 +00:00
return FALSE;
}
old_current = ifsD->current_element;
ifsD->current_element = -1;
/* Find out where the button press was */
for (i = 0; i < ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
{
if (ipolygon_contains (elements[i]->click_boundary, event->x, event->y))
1997-11-24 22:05:25 +00:00
{
set_current_element (i);
1997-11-24 22:05:25 +00:00
break;
}
}
/* if the user started manipulating an object, set up a new
position on the undo ring */
if (ifsD->current_element >= 0)
undo_begin ();
1997-11-24 22:05:25 +00:00
if (!(event->state & GDK_SHIFT_MASK)
&& ( (ifsD->current_element<0)
|| !element_selected[ifsD->current_element] ))
{
for (i = 0; i < ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
element_selected[i] = 0;
}
if (ifsD->current_element >= 0)
{
ifsDesign->button_state |= GDK_BUTTON1_MASK;
element_selected[ifsD->current_element] = TRUE;
ifsDesign->num_selected = 0;
ifsDesign->op_xcenter = 0.0;
ifsDesign->op_ycenter = 0.0;
for (i = 0; i < ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
{
if (element_selected[i])
{
ifsD->selected_orig[i] = *elements[i];
ifsDesign->op_xcenter += elements[i]->v.x;
ifsDesign->op_ycenter += elements[i]->v.y;
ifsDesign->num_selected++;
undo_update (i);
1997-11-24 22:05:25 +00:00
}
}
ifsDesign->op_xcenter /= ifsDesign->num_selected;
ifsDesign->op_ycenter /= ifsDesign->num_selected;
ifsDesign->op_x = (gdouble)event->x / width;
ifsDesign->op_y = (gdouble)event->y / width;
1997-11-24 22:05:25 +00:00
ifsDesign->op_center_x = ifsvals.center_x;
ifsDesign->op_center_y = ifsvals.center_y;
}
else
{
ifsD->current_element = old_current;
element_selected[old_current] = TRUE;
}
design_area_redraw ();
1997-11-24 22:05:25 +00:00
return FALSE;
}
static gint
design_area_button_release (GtkWidget *widget,
GdkEventButton *event)
1997-11-24 22:05:25 +00:00
{
if (event->button == 1 &&
(ifsDesign->button_state & GDK_BUTTON1_MASK))
{
ifsDesign->button_state &= ~GDK_BUTTON1_MASK;
if (ifsD->auto_preview)
ifs_compose_preview ();
1997-11-24 22:05:25 +00:00
}
return FALSE;
}
static gint
design_area_motion (GtkWidget *widget,
GdkEventMotion *event)
1997-11-24 22:05:25 +00:00
{
gint i;
gdouble xo;
gdouble yo;
gdouble xn;
gdouble yn;
gint px, py;
1997-11-24 22:05:25 +00:00
gdouble width = ifsDesign->area->allocation.width;
gdouble height = ifsDesign->area->allocation.height;
Aff2 trans, t1, t2, t3;
1997-11-24 22:05:25 +00:00
if (!(ifsDesign->button_state & GDK_BUTTON1_MASK)) return FALSE;
if (event->is_hint)
{
gtk_widget_get_pointer (ifsDesign->area, &px, &py);
1997-11-24 22:05:25 +00:00
event->x = px;
event->y = py;
}
xo = (ifsDesign->op_x - ifsDesign->op_xcenter);
yo = (ifsDesign->op_y - ifsDesign->op_ycenter);
xn = (gdouble) event->x / width - ifsDesign->op_xcenter;
yn = (gdouble) event->y / width - ifsDesign->op_ycenter;
1997-11-24 22:05:25 +00:00
switch (ifsDesign->op)
{
case OP_ROTATE:
{
aff2_translate (&t1,-ifsDesign->op_xcenter*width,
1997-11-24 22:05:25 +00:00
-ifsDesign->op_ycenter*width);
aff2_scale (&t2,
1997-11-24 22:05:25 +00:00
sqrt((SQR(xn)+SQR(yn))/(SQR(xo)+SQR(yo))),
0);
aff2_compose (&t3, &t2, &t1);
aff2_rotate (&t1, - atan2(yn, xn) + atan2(yo, xo));
aff2_compose (&t2, &t1, &t3);
aff2_translate (&t3, ifsDesign->op_xcenter*width,
1997-11-24 22:05:25 +00:00
ifsDesign->op_ycenter*width);
aff2_compose (&trans, &t3, &t2);
1997-11-24 22:05:25 +00:00
break;
}
case OP_STRETCH:
{
aff2_translate (&t1,-ifsDesign->op_xcenter*width,
1997-11-24 22:05:25 +00:00
-ifsDesign->op_ycenter*width);
aff2_compute_stretch (&t2, xo, yo, xn, yn);
aff2_compose (&t3, &t2, &t1);
aff2_translate (&t1, ifsDesign->op_xcenter*width,
1997-11-24 22:05:25 +00:00
ifsDesign->op_ycenter*width);
aff2_compose (&trans, &t1, &t3);
1997-11-24 22:05:25 +00:00
break;
}
case OP_TRANSLATE:
{
aff2_translate (&trans,(xn-xo)*width,(yn-yo)*width);
1997-11-24 22:05:25 +00:00
break;
}
}
for (i = 0; i < ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
if (element_selected[i])
{
if (ifsDesign->num_selected == ifsvals.num_elements)
{
gdouble cx, cy;
aff2_invert (&t1, &trans);
aff2_compose (&t2, &trans, &ifsD->selected_orig[i].trans);
aff2_compose (&elements[i]->trans, &t2, &t1);
1997-11-24 22:05:25 +00:00
cx = ifsDesign->op_center_x * width;
cy = ifsDesign->op_center_y * width;
aff2_apply (&trans, cx, cy, &cx, &cy);
1997-11-24 22:05:25 +00:00
ifsvals.center_x = cx / width;
ifsvals.center_y = cy / width;
}
else
{
aff2_compose (&elements[i]->trans, &trans,
1997-11-24 22:05:25 +00:00
&ifsD->selected_orig[i].trans);
}
aff_element_decompose_trans (elements[i],&elements[i]->trans,
width, height, ifsvals.center_x,
1997-11-24 22:05:25 +00:00
ifsvals.center_y);
aff_element_compute_trans (elements[i],width, height,
1997-11-24 22:05:25 +00:00
ifsvals.center_x, ifsvals.center_y);
}
update_values ();
design_area_redraw ();
1997-11-24 22:05:25 +00:00
return FALSE;
}
static void
design_area_redraw (void)
1997-11-24 22:05:25 +00:00
{
gdouble width = ifsDesign->area->allocation.width;
1997-11-24 22:05:25 +00:00
gdouble height = ifsDesign->area->allocation.height;
gint i;
1997-11-24 22:05:25 +00:00
for (i = 0; i < ifsvals.num_elements; i++)
aff_element_compute_boundary (elements[i],width, height,
elements, ifsvals.num_elements);
gtk_widget_queue_draw (ifsDesign->area);
1997-11-24 22:05:25 +00:00
}
/* Undo ring functions */
static void
undo_begin (void)
1997-11-24 22:05:25 +00:00
{
gint i, j;
1997-11-24 22:05:25 +00:00
gint to_delete;
gint new_index;
if (undo_cur == UNDO_LEVELS-1)
{
to_delete = 1;
undo_start = (undo_start + 1) % UNDO_LEVELS;
1997-11-24 22:05:25 +00:00
}
else
{
undo_cur++;
to_delete = undo_num - undo_cur;
}
undo_num = undo_num - to_delete + 1;
new_index = (undo_start + undo_cur) % UNDO_LEVELS;
1997-11-24 22:05:25 +00:00
/* remove any redo elements or the oldest element if necessary */
for (j = new_index; to_delete > 0; j = (j+1) % UNDO_LEVELS, to_delete--)
1997-11-24 22:05:25 +00:00
{
for (i = 0; i < undo_ring[j].ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
if (undo_ring[j].elements[i])
aff_element_free (undo_ring[j].elements[i]);
g_free (undo_ring[j].elements);
g_free (undo_ring[j].element_selected);
1997-11-24 22:05:25 +00:00
}
undo_ring[new_index].ifsvals = ifsvals;
undo_ring[new_index].elements = g_new (AffElement *,ifsvals.num_elements);
undo_ring[new_index].element_selected = g_new (gint, ifsvals.num_elements);
1997-11-24 22:05:25 +00:00
undo_ring[new_index].current_element = ifsD->current_element;
for (i = 0; i < ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
{
undo_ring[new_index].elements[i] = NULL;
undo_ring[new_index].element_selected[i] = element_selected[i];
}
gtk_widget_set_sensitive (ifsD->undo_button, undo_cur >= 0);
gtk_widget_set_sensitive (ifsD->undo_menu_item, undo_cur >= 0);
gtk_widget_set_sensitive (ifsD->redo_button, undo_cur != undo_num-1);
gtk_widget_set_sensitive (ifsD->redo_menu_item, undo_cur != undo_num-1);
1997-11-24 22:05:25 +00:00
}
static void
undo_update (gint el)
1997-11-24 22:05:25 +00:00
{
AffElement *elem;
/* initialize */
elem = NULL;
if (!undo_ring[(undo_start + undo_cur) % UNDO_LEVELS].elements[el])
undo_ring[(undo_start + undo_cur) % UNDO_LEVELS].elements[el]
= elem = g_new (AffElement, 1);
1997-11-24 22:05:25 +00:00
*elem = *elements[el];
elem->draw_boundary = NULL;
elem->click_boundary = NULL;
}
static void
undo_exchange (gint el)
1997-11-24 22:05:25 +00:00
{
gint i;
AffElement **telements;
gint *tselected;
IfsComposeVals tifsvals;
gint tcurrent;
gdouble width = ifsDesign->area->allocation.width;
gdouble height = ifsDesign->area->allocation.height;
/* swap the arrays and values*/
telements = elements;
elements = undo_ring[el].elements;
undo_ring[el].elements = telements;
tifsvals = ifsvals;
ifsvals = undo_ring[el].ifsvals;
undo_ring[el].ifsvals = tifsvals;
tselected = element_selected;
element_selected = undo_ring[el].element_selected;
undo_ring[el].element_selected = tselected;
tcurrent = ifsD->current_element;
ifsD->current_element = undo_ring[el].current_element;
undo_ring[el].current_element = tcurrent;
/* now swap back any unchanged elements */
for (i = 0; i < ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
if (!elements[i])
{
elements[i] = undo_ring[el].elements[i];
undo_ring[el].elements[i] = 0;
}
else
aff_element_compute_trans (elements[i],width, height,
ifsvals.center_x, ifsvals.center_y);
1997-11-24 22:05:25 +00:00
set_current_element (ifsD->current_element);
1997-11-24 22:05:25 +00:00
design_area_redraw ();
1997-11-24 22:05:25 +00:00
if (ifsD->auto_preview)
ifs_compose_preview ();
1997-11-24 22:05:25 +00:00
}
static void
undo (void)
1997-11-24 22:05:25 +00:00
{
if (undo_cur >= 0)
{
undo_exchange ((undo_start + undo_cur) % UNDO_LEVELS);
1997-11-24 22:05:25 +00:00
undo_cur--;
}
gtk_widget_set_sensitive (ifsD->undo_button, undo_cur >= 0);
gtk_widget_set_sensitive (ifsD->undo_menu_item, undo_cur >= 0);
gtk_widget_set_sensitive (ifsD->redo_button, undo_cur != undo_num-1);
gtk_widget_set_sensitive (ifsD->redo_menu_item, undo_cur != undo_num-1);
1997-11-24 22:05:25 +00:00
}
static void
redo (void)
1997-11-24 22:05:25 +00:00
{
if (undo_cur != undo_num - 1)
{
undo_cur++;
undo_exchange ((undo_start + undo_cur) % UNDO_LEVELS);
1997-11-24 22:05:25 +00:00
}
gtk_widget_set_sensitive (ifsD->undo_button, undo_cur >= 0);
gtk_widget_set_sensitive (ifsD->undo_menu_item, undo_cur >= 0);
gtk_widget_set_sensitive (ifsD->redo_button, undo_cur != undo_num-1);
gtk_widget_set_sensitive (ifsD->redo_menu_item, undo_cur != undo_num-1);
1997-11-24 22:05:25 +00:00
}
static void
design_area_select_all_callback (GtkWidget *w,
gpointer data)
1997-11-24 22:05:25 +00:00
{
gint i;
for (i = 0; i < ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
element_selected[i] = TRUE;
design_area_redraw ();
1997-11-24 22:05:25 +00:00
}
/* Interface functions */
static void
val_changed_update (void)
1997-11-24 22:05:25 +00:00
{
gdouble width = ifsDesign->area->allocation.width;
gdouble height = ifsDesign->area->allocation.height;
AffElement *cur = elements[ifsD->current_element];
if (ifsD->in_update)
return;
undo_begin ();
undo_update (ifsD->current_element);
1997-11-24 22:05:25 +00:00
cur->v = ifsD->current_vals;
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc 1999-09-01 Tor Lillqvist <tml@iki.fi> * app/appenv.h * libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc from app/appenv.h here, so plug-ins can use them, too. Remove some commented-out old stuff in appenv.h. * libgimp/gimp.h: Include gimpmath.h. * libgimp/gimp.c (gimp_main): Win32: Don't install signal handlers, we can't do anything useful in the handler ourselves anyway (it would be nice to print out a backtrace, but that seems pretty hard to do, even if not impossible). Let Windows inform the user about the crash. If the plug-in was compiled with MSVC, and the user also has it, she is offered a chance to start the debugger automatically anyway. * app/*several*.c: Include gimpmath.h for G_PI etc. Don't include <math.h>, as gimpmath.h includes it. * plug-ins/*/*many*.c: Include config.h. Don't include <math.h>. Remove all the duplicated definitions of G_PI and rint(). Use RINT() instead of rint(). * app/app_procs.[ch]: app_exit() takes a gboolean. * app/batch.c * app/commands.c * app/interface.c: Call app_exit() with FALSE or TRUE. * app/main.c (on_error): Call gimp_fatal_error. (main): Don't install any signal handler on Win32 here, either. * app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format the message and call MessageBox with it. g_on_error_query doesn't do anything useful on Win32, and printf'ing a message to stdout or stderr doesn't do anything, either, in a windowing application.
1999-09-01 20:30:56 +00:00
cur->v.theta *= G_PI/180.0;
aff_element_compute_trans (cur, width, height,
1997-11-24 22:05:25 +00:00
ifsvals.center_x, ifsvals.center_y);
aff_element_compute_color_trans (cur);
1997-11-24 22:05:25 +00:00
design_area_redraw ();
1997-11-24 22:05:25 +00:00
if (ifsD->auto_preview)
ifs_compose_preview ();
1997-11-24 22:05:25 +00:00
}
/* Pseudo-widget representing a color mapping */
#define COLOR_SAMPLE_SIZE 30
static ColorMap *
color_map_create (gchar *name,
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
GimpRGB *orig_color,
GimpRGB *data,
gboolean fixed_point)
1997-11-24 22:05:25 +00:00
{
GtkWidget *frame;
2000-01-26 14:14:54 +00:00
GtkWidget *arrow;
1997-11-24 22:05:25 +00:00
ColorMap *color_map = g_new (ColorMap, 1);
1997-11-24 22:05:25 +00:00
gimp_rgb_set_alpha (data, 1.0);
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
color_map->color = data;
color_map->fixed_point = fixed_point;
color_map->hbox = gtk_hbox_new (FALSE, 2);
1997-11-24 22:05:25 +00:00
2000-01-26 14:14:54 +00:00
frame = gtk_frame_new (NULL);
1997-11-24 22:05:25 +00:00
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
2000-01-26 14:14:54 +00:00
gtk_box_pack_start (GTK_BOX (color_map->hbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
1997-11-24 22:05:25 +00:00
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
color_map->orig_preview =
gimp_color_area_new (fixed_point ? data : orig_color,
GIMP_COLOR_AREA_FLAT, 0);
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
gtk_drag_dest_unset (color_map->orig_preview);
gtk_widget_set_size_request (color_map->orig_preview,
COLOR_SAMPLE_SIZE, COLOR_SAMPLE_SIZE);
gtk_container_add (GTK_CONTAINER (frame), color_map->orig_preview);
2000-01-26 14:14:54 +00:00
gtk_widget_show (color_map->orig_preview);
1997-11-24 22:05:25 +00:00
2000-01-26 14:14:54 +00:00
arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (color_map->hbox), arrow, FALSE, FALSE, 0);
gtk_widget_show (arrow);
1997-11-24 22:05:25 +00:00
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
color_map->button = gimp_color_button_new (name,
COLOR_SAMPLE_SIZE,
COLOR_SAMPLE_SIZE,
data,
GIMP_COLOR_AREA_FLAT);
2000-01-26 14:14:54 +00:00
gtk_box_pack_start (GTK_BOX (color_map->hbox), color_map->button,
FALSE, FALSE, 0);
gtk_widget_show (color_map->button);
1997-11-24 22:05:25 +00:00
g_signal_connect (color_map->button, "color_changed",
G_CALLBACK (gimp_color_button_get_color),
data);
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
g_signal_connect (color_map->button, "color_changed",
G_CALLBACK (color_map_color_changed_cb),
color_map);
1997-11-24 22:05:25 +00:00
return color_map;
}
static void
2000-01-26 15:50:24 +00:00
color_map_color_changed_cb (GtkWidget *widget,
ColorMap *color_map)
1997-11-24 22:05:25 +00:00
{
if (ifsD->in_update)
return;
2000-01-26 14:14:54 +00:00
undo_begin ();
undo_update (ifsD->current_element);
2000-01-26 15:50:24 +00:00
1997-11-24 22:05:25 +00:00
elements[ifsD->current_element]->v = ifsD->current_vals;
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc 1999-09-01 Tor Lillqvist <tml@iki.fi> * app/appenv.h * libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc from app/appenv.h here, so plug-ins can use them, too. Remove some commented-out old stuff in appenv.h. * libgimp/gimp.h: Include gimpmath.h. * libgimp/gimp.c (gimp_main): Win32: Don't install signal handlers, we can't do anything useful in the handler ourselves anyway (it would be nice to print out a backtrace, but that seems pretty hard to do, even if not impossible). Let Windows inform the user about the crash. If the plug-in was compiled with MSVC, and the user also has it, she is offered a chance to start the debugger automatically anyway. * app/*several*.c: Include gimpmath.h for G_PI etc. Don't include <math.h>, as gimpmath.h includes it. * plug-ins/*/*many*.c: Include config.h. Don't include <math.h>. Remove all the duplicated definitions of G_PI and rint(). Use RINT() instead of rint(). * app/app_procs.[ch]: app_exit() takes a gboolean. * app/batch.c * app/commands.c * app/interface.c: Call app_exit() with FALSE or TRUE. * app/main.c (on_error): Call gimp_fatal_error. (main): Don't install any signal handler on Win32 here, either. * app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format the message and call MessageBox with it. g_on_error_query doesn't do anything useful on Win32, and printf'ing a message to stdout or stderr doesn't do anything, either, in a windowing application.
1999-09-01 20:30:56 +00:00
elements[ifsD->current_element]->v.theta *= G_PI/180.0;
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
aff_element_compute_color_trans (elements[ifsD->current_element]);
1997-11-24 22:05:25 +00:00
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
update_values ();
1997-11-24 22:05:25 +00:00
if (ifsD->auto_preview)
ifs_compose_preview ();
1997-11-24 22:05:25 +00:00
}
static void
color_map_update (ColorMap *color_map)
1997-11-24 22:05:25 +00:00
{
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
gimp_color_button_set_color (GIMP_COLOR_BUTTON (color_map->button),
color_map->color);
1997-11-24 22:05:25 +00:00
2000-01-26 14:14:54 +00:00
if (color_map->fixed_point)
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
gimp_color_area_set_color (GIMP_COLOR_AREA (color_map->orig_preview),
color_map->color);
1997-11-24 22:05:25 +00:00
}
static void
simple_color_set_sensitive (void)
1997-11-24 22:05:25 +00:00
{
gint sc = elements[ifsD->current_element]->v.simple_color;
gtk_widget_set_sensitive (ifsD->target_cmap->hbox, sc);
gtk_widget_set_sensitive (ifsD->hue_scale_pair->scale, sc);
gtk_widget_set_sensitive (ifsD->hue_scale_pair->entry, sc);
gtk_widget_set_sensitive (ifsD->value_scale_pair->scale, sc);
gtk_widget_set_sensitive (ifsD->value_scale_pair->entry, sc);
1997-11-24 22:05:25 +00:00
gtk_widget_set_sensitive (ifsD->red_cmap->hbox, !sc);
gtk_widget_set_sensitive (ifsD->green_cmap->hbox, !sc);
gtk_widget_set_sensitive (ifsD->blue_cmap->hbox, !sc);
gtk_widget_set_sensitive (ifsD->black_cmap->hbox, !sc);
1997-11-24 22:05:25 +00:00
}
static void
simple_color_toggled (GtkWidget *widget,
gpointer data)
1997-11-24 22:05:25 +00:00
{
AffElement *cur = elements[ifsD->current_element];
cur->v.simple_color = GTK_TOGGLE_BUTTON (widget)->active;
1997-11-24 22:05:25 +00:00
ifsD->current_vals.simple_color = cur->v.simple_color;
if (cur->v.simple_color)
aff_element_compute_color_trans (cur);
val_changed_update ();
simple_color_set_sensitive ();
1997-11-24 22:05:25 +00:00
}
/* Generic mechanism for scale/entry combination (possibly without
scale) */
static ValuePair *
value_pair_create (gpointer data,
gdouble lower,
gdouble upper,
gboolean create_scale,
ValuePairType type)
1997-11-24 22:05:25 +00:00
{
ValuePair *value_pair = g_new (ValuePair, 1);
1997-11-24 22:05:25 +00:00
value_pair->data.d = data;
value_pair->type = type;
value_pair->adjustment =
gtk_adjustment_new (1.0, lower, upper,
(upper-lower) / 100, (upper-lower) / 10,
0.0);
/* We need to sink the adjustment, since we may not create a scale for
* it, so nobody will assume the initial refcount
*/
g_object_ref (value_pair->adjustment);
gtk_object_sink (value_pair->adjustment);
g_signal_connect (value_pair->adjustment, "value_changed",
G_CALLBACK (value_pair_scale_callback),
value_pair);
1997-11-24 22:05:25 +00:00
if (create_scale)
{
value_pair->scale =
gtk_hscale_new (GTK_ADJUSTMENT (value_pair->adjustment));
gtk_widget_ref (value_pair->scale);
1997-11-24 22:05:25 +00:00
if (type == VALUE_PAIR_INT)
gtk_scale_set_digits (GTK_SCALE (value_pair->scale), 0);
else
gtk_scale_set_digits (GTK_SCALE (value_pair->scale), 2);
gtk_scale_set_draw_value (GTK_SCALE (value_pair->scale), FALSE);
gtk_range_set_update_policy (GTK_RANGE (value_pair->scale),
GTK_UPDATE_DELAYED);
1997-11-24 22:05:25 +00:00
}
else
value_pair->scale = NULL;
/* We destroy the value pair when the entry is destroyed, so
* we don't need to hold a refcount on the entry
*/
1997-11-24 22:05:25 +00:00
value_pair->entry = gtk_entry_new ();
gtk_widget_set_size_request (value_pair->entry, ENTRY_WIDTH, -1);
1997-11-24 22:05:25 +00:00
value_pair->entry_handler_id =
g_signal_connect (value_pair->entry, "changed",
G_CALLBACK (value_pair_entry_callback),
value_pair);
g_signal_connect (value_pair->entry, "destroy",
G_CALLBACK (value_pair_destroy_callback),
value_pair);
1997-11-24 22:05:25 +00:00
return value_pair;
}
static void
value_pair_update (ValuePair *value_pair)
1997-11-24 22:05:25 +00:00
{
gchar buffer[32];
if (value_pair->type == VALUE_PAIR_INT)
{
gtk_adjustment_set_value (GTK_ADJUSTMENT (value_pair->adjustment),
*value_pair->data.i);
1997-11-24 22:05:25 +00:00
sprintf (buffer, "%d", *value_pair->data.i);
}
else
{
gtk_adjustment_set_value (GTK_ADJUSTMENT (value_pair->adjustment),
*value_pair->data.d);
1997-11-24 22:05:25 +00:00
sprintf (buffer, "%0.2f", *value_pair->data.d);
}
g_signal_handler_block (value_pair->entry,
value_pair->entry_handler_id);
1997-11-24 22:05:25 +00:00
gtk_entry_set_text (GTK_ENTRY (value_pair->entry), buffer);
g_signal_handler_unblock (value_pair->entry,
value_pair->entry_handler_id);
1997-11-24 22:05:25 +00:00
}
static void
value_pair_scale_callback (GtkAdjustment *adjustment,
ValuePair *value_pair)
1997-11-24 22:05:25 +00:00
{
gchar buffer[32];
gint changed = FALSE;
if (value_pair->type == VALUE_PAIR_DOUBLE)
{
if ((gdouble) *value_pair->data.d != adjustment->value)
1997-11-24 22:05:25 +00:00
{
changed = TRUE;
*value_pair->data.d = adjustment->value;
sprintf (buffer, "%0.2f", adjustment->value);
}
}
else
{
if (*value_pair->data.i != (gint) adjustment->value)
1997-11-24 22:05:25 +00:00
{
changed = TRUE;
*value_pair->data.i = adjustment->value;
sprintf (buffer, "%d", (gint) adjustment->value);
1997-11-24 22:05:25 +00:00
}
}
1997-11-24 22:05:25 +00:00
if (changed)
{
g_signal_handler_block (value_pair->entry,
value_pair->entry_handler_id);
1997-11-24 22:05:25 +00:00
gtk_entry_set_text (GTK_ENTRY (value_pair->entry), buffer);
g_signal_handler_unblock (value_pair->entry,
value_pair->entry_handler_id);
val_changed_update ();
1997-11-24 22:05:25 +00:00
}
}
static void
value_pair_entry_callback (GtkWidget *widget,
ValuePair *value_pair)
1997-11-24 22:05:25 +00:00
{
GtkAdjustment *adjustment = GTK_ADJUSTMENT (value_pair->adjustment);
1997-11-24 22:05:25 +00:00
gdouble new_value;
gdouble old_value;
if (value_pair->type == VALUE_PAIR_INT)
{
old_value = *value_pair->data.i;
new_value = atoi(gtk_entry_get_text (GTK_ENTRY (widget)));
1997-11-24 22:05:25 +00:00
}
else
{
old_value = *value_pair->data.d;
new_value = atof(gtk_entry_get_text (GTK_ENTRY (widget)));
1997-11-24 22:05:25 +00:00
}
if (floor(0.5+old_value*10000) != floor(0.5+new_value*10000))
{
if ((new_value >= adjustment->lower) &&
(new_value <= adjustment->upper))
{
if (value_pair->type == VALUE_PAIR_INT)
*value_pair->data.i = new_value;
else
*value_pair->data.d = new_value;
gtk_adjustment_set_value (adjustment, new_value);
1997-11-24 22:05:25 +00:00
}
}
}
static void
value_pair_destroy_callback (GtkWidget *widget,
ValuePair *value_pair)
{
if (value_pair->scale)
g_object_unref (value_pair->scale);
g_object_unref (value_pair->adjustment);
}
1997-11-24 22:05:25 +00:00
static void
design_op_callback (GtkWidget *widget,
gpointer data)
1997-11-24 22:05:25 +00:00
{
DesignOp op = GPOINTER_TO_INT (data);
1997-11-24 22:05:25 +00:00
if (op != ifsDesign->op)
{
switch (ifsDesign->op)
{
case OP_TRANSLATE:
g_signal_handler_block (ifsD->move_button,
ifsD->move_handler);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ifsD->move_button),
FALSE);
g_signal_handler_unblock (ifsD->move_button,
ifsD->move_handler);
1997-11-24 22:05:25 +00:00
break;
case OP_ROTATE:
g_signal_handler_block (ifsD->rotate_button,
ifsD->rotate_handler);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ifsD->rotate_button),
FALSE);
g_signal_handler_unblock (ifsD->rotate_button,
ifsD->rotate_handler);
1997-11-24 22:05:25 +00:00
break;
case OP_STRETCH:
g_signal_handler_block (ifsD->stretch_button,
ifsD->stretch_handler);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ifsD->stretch_button),
FALSE);
g_signal_handler_unblock (ifsD->stretch_button,
ifsD->stretch_handler);
1997-11-24 22:05:25 +00:00
break;
}
ifsDesign->op = op;
}
else
{
GTK_TOGGLE_BUTTON (widget)->active = TRUE;
1997-11-24 22:05:25 +00:00
}
}
static void
design_op_update_callback (GtkWidget *widget,
gpointer data)
1997-11-24 22:05:25 +00:00
{
DesignOp op = GPOINTER_TO_INT (data);
1997-11-24 22:05:25 +00:00
if (op == ifsDesign->op)
return;
switch (op)
1997-11-24 22:05:25 +00:00
{
case OP_TRANSLATE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ifsD->move_button),
TRUE);
break;
case OP_ROTATE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ifsD->rotate_button),
TRUE);
break;
case OP_STRETCH:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ifsD->stretch_button),
TRUE);
break;
1997-11-24 22:05:25 +00:00
}
}
static void
recompute_center_cb (GtkWidget *widget,
gpointer data)
1997-11-24 22:05:25 +00:00
{
recompute_center (TRUE);
1997-11-24 22:05:25 +00:00
}
static void
recompute_center (gboolean save_undo)
1997-11-24 22:05:25 +00:00
{
gint i;
gdouble x, y;
1997-11-24 22:05:25 +00:00
gdouble center_x = 0.0;
gdouble center_y = 0.0;
gdouble width = ifsDesign->area->allocation.width;
gdouble height = ifsDesign->area->allocation.height;
if (save_undo)
undo_begin ();
1997-11-24 22:05:25 +00:00
for (i = 0; i < ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
{
if (save_undo)
undo_update (i);
aff_element_compute_trans (elements[i],1, ifsvals.aspect_ratio,
1997-11-24 22:05:25 +00:00
ifsvals.center_x, ifsvals.center_y);
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
aff2_fixed_point (&elements[i]->trans, &x, &y);
1997-11-24 22:05:25 +00:00
center_x += x;
center_y += y;
}
ifsvals.center_x = center_x/ifsvals.num_elements;
ifsvals.center_y = center_y/ifsvals.num_elements;
for (i = 0; i < ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
{
aff_element_decompose_trans (elements[i],&elements[i]->trans,
1, ifsvals.aspect_ratio,
1997-11-24 22:05:25 +00:00
ifsvals.center_x, ifsvals.center_y);
}
if (width > 1 && height > 1)
{
for (i = 0; i < ifsvals.num_elements; i++)
aff_element_compute_trans (elements[i],width, height,
1997-11-24 22:05:25 +00:00
ifsvals.center_x, ifsvals.center_y);
design_area_redraw ();
update_values ();
1997-11-24 22:05:25 +00:00
}
}
static void
auto_preview_callback (GtkWidget *widget,
gpointer data)
1997-11-24 22:05:25 +00:00
{
if (ifsD->auto_preview)
{
ifsD->auto_preview = FALSE;
1997-11-24 22:05:25 +00:00
}
else
{
ifsD->auto_preview = TRUE;
ifs_compose_preview ();
1997-11-24 22:05:25 +00:00
}
}
static void
flip_check_button_callback (GtkWidget *widget,
gpointer data)
1997-11-24 22:05:25 +00:00
{
guint i;
gdouble width = ifsDesign->area->allocation.width;
gdouble height = ifsDesign->area->allocation.height;
gboolean active;
if (ifsD->in_update)
return;
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
undo_begin ();
for (i = 0; i < ifsvals.num_elements; i++)
{
if (element_selected[i])
{
undo_update (i);
elements[i]->v.flip = active;
aff_element_compute_trans (elements[i], width, height,
ifsvals.center_x, ifsvals.center_y);
}
}
update_values ();
design_area_redraw ();
if (ifsD->auto_preview)
ifs_compose_preview ();
1997-11-24 22:05:25 +00:00
}
static void
ifs_compose_set_defaults (void)
1997-11-24 22:05:25 +00:00
{
finished new GimpColorArea widget which uses GimpRGB and handles DND and 2001-01-10 Sven Neumann <sven@gimp.org> * libgimp/gimpcolorarea.[ch]: finished new GimpColorArea widget which uses GimpRGB and handles DND and alpha channel. * libgimp/gimpcolorbutton.[ch]: use GimpColorArea. The API of the GimpColorButton has changed! * libgimp/gimpwidgets.[ch]: added temporary function gimp_color_update_uchar() to ease migration of plug-ins to GimpRGB. This function will go away. * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_ui.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/sinus.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/ifscompose/ifscompose.[ch] * plug-ins/ifscompose/ifscompose_storage.c * plug-ins/ifscompose/ifscompose_utils.c * plug-ins/script-fu/script-fu-scripts.c: use new GimpColorArea and GimpColorButton. Started to introduce GimpRGB color type. This change might have broken some of these plug-ins. This is work in progress. * libgimp/Makefile.am: added GimpColorArea and GimpColorButton to libgimpi. * app/gimpcontext.[ch]: added gimp_palette_get_[fore|back]ground() functions so the app can link against libgimp/gimpcolorbutton.o. These functions will go away. * app/gimpdnd.c: use a GimpColorArea for DND
2001-01-10 22:49:45 +00:00
gint i;
GimpRGB color;
1997-11-24 22:05:25 +00:00
tools/pdbgen/lib.pl tools/pdbgen/pdb.pl tools/pdbgen/pdb/channel.pdb 2001-01-25 Sven Neumann <sven@gimp.org> * tools/pdbgen/lib.pl * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: changed these with the help of Yosh. PDB functions take GimpRGB as color type now. * app/plug_in.c * app/pdb/channel_cmds.c * app/pdb/internal_procs.c * app/pdb/palette_cmds.c * app/pdb/procedural_db.[ch] * app/pdb/tools_cmds.c * libgimp/gimp.[ch] * libgimp/gimpchannel.[ch] * libgimp/gimpchannel_pdb.[ch] * libgimp/gimppalette_pdb.[ch] * libgimp/gimpprotocol.[ch] * libgimp/gimptools_pdb.[ch]: incremented Gimp protocol version and changed color type from array of chars to GimpRGB. * libgimp/Makefile.am * libgimp/gimppalette.[ch]: removed these files again * app/libgimp_glue.[ch] * libgimpwidgets/gimpcolorbutton.c * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_preview.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/psd.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/tiff.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gap/gap_filter_iterators.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gdyntext/gdyntext.c * plug-ins/gfig/gfig.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu.c * plug-ins/xjt/xjt.c: changed accordingly. A few plug-ins need to be looked at more closely after this change. I tried to put FIXME comments into those.
2001-01-25 01:20:05 +00:00
gimp_palette_get_foreground (&color);
1997-11-24 22:05:25 +00:00
ifsvals.aspect_ratio =
(gdouble)ifsD->drawable_height / ifsD->drawable_width;
1997-11-24 22:05:25 +00:00
for (i = 0; i < ifsvals.num_elements; i++)
aff_element_free (elements[i]);
count_for_naming = 0;
1997-11-24 22:05:25 +00:00
ifsvals.num_elements = 3;
elements = g_realloc (elements, ifsvals.num_elements * sizeof(AffElement *));
element_selected = g_realloc (element_selected,
ifsvals.num_elements * sizeof(gint));
1997-11-24 22:05:25 +00:00
elements[0] = aff_element_new (0.3, 0.37 * ifsvals.aspect_ratio, &color,
++count_for_naming);
1997-11-24 22:05:25 +00:00
element_selected[0] = FALSE;
elements[1] = aff_element_new (0.7, 0.37 * ifsvals.aspect_ratio, &color,
++count_for_naming);
1997-11-24 22:05:25 +00:00
element_selected[1] = FALSE;
elements[2] = aff_element_new (0.5, 0.7 * ifsvals.aspect_ratio, &color,
++count_for_naming);
1997-11-24 22:05:25 +00:00
element_selected[2] = FALSE;
ifsvals.center_x = 0.5;
ifsvals.center_y = 0.5 * ifsvals.aspect_ratio;
ifsvals.iterations = ifsD->drawable_height * ifsD->drawable_width;
ifsvals.subdivide = 3;
1997-11-24 22:05:25 +00:00
ifsvals.max_memory = 4096;
if (ifsOptD)
{
value_pair_update (ifsOptD->iterations_pair);
value_pair_update (ifsOptD->subdivide_pair);
value_pair_update (ifsOptD->radius_pair);
value_pair_update (ifsOptD->memory_pair);
1997-11-24 22:05:25 +00:00
}
ifsvals.radius = 0.7;
set_current_element (0);
1997-11-24 22:05:25 +00:00
element_selected[0] = TRUE;
recompute_center (FALSE);
1997-11-24 22:05:25 +00:00
if (ifsD->selected_orig)
g_free (ifsD->selected_orig);
1997-11-24 22:05:25 +00:00
ifsD->selected_orig = g_new (AffElement, ifsvals.num_elements);
1997-11-24 22:05:25 +00:00
}
static void
ifs_compose_defaults_callback (GtkWidget *widget,
gpointer data)
1997-11-24 22:05:25 +00:00
{
gint i;
gdouble width = ifsDesign->area->allocation.width;
1997-11-24 22:05:25 +00:00
gdouble height = ifsDesign->area->allocation.height;
undo_begin ();
for (i = 0; i < ifsvals.num_elements; i++)
undo_update (i);
1997-11-24 22:05:25 +00:00
ifs_compose_set_defaults ();
1997-11-24 22:05:25 +00:00
if (ifsD->auto_preview)
ifs_compose_preview ();
1997-11-24 22:05:25 +00:00
for (i = 0; i < ifsvals.num_elements; i++)
aff_element_compute_trans (elements[i], width, height,
ifsvals.center_x, ifsvals.center_y);
1997-11-24 22:05:25 +00:00
design_area_redraw ();
1997-11-24 22:05:25 +00:00
}
/* show a transient message dialog */
static void
ifscompose_message_dialog (GtkMessageType type,
GtkWindow *parent,
const gchar *title,
const gchar *message)
{
GtkWidget *dlg;
dlg = gtk_message_dialog_new (parent, 0, type, GTK_BUTTONS_OK, message);
gtk_window_set_transient_for (GTK_WINDOW (dlg), parent);
if (title)
gtk_window_set_title (GTK_WINDOW (dlg), title);
gtk_window_set_wmclass (GTK_WINDOW (dlg), "message", "Gimp");
gtk_dialog_run (GTK_DIALOG (dlg));
gtk_widget_destroy (dlg);
}
/* save an ifs file */
static void
ifsfile_save (GtkWidget *widget,
GtkWidget *file_select)
{
const gchar *filename;
gchar *str;
FILE *fh;
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_select));
str = ifsvals_stringify (&ifsvals, elements);
fh = fopen (filename, "w");
if (fh)
{
fputs (str, fh);
fclose (fh);
gtk_widget_hide (file_select);
}
else
{
gchar *message = g_strdup_printf (_("Cannot save file '%s'.\n"
"Check the path and permissions."),
filename);
ifscompose_message_dialog (GTK_MESSAGE_ERROR, GTK_WINDOW (file_select),
"Save failed", message);
g_free (message);
}
}
/* replace ifsvals and elements with specified new values
* recompute and update everything necessary */
static void
ifsfile_replace_ifsvals (IfsComposeVals *new_ifsvals,
AffElement **new_elements)
{
gdouble width = ifsDesign->area->allocation.width;
gdouble height = ifsDesign->area->allocation.height;
guint i;
for (i = 0; i < ifsvals.num_elements; i++)
aff_element_free (elements[i]);
free(elements);
ifsvals = *new_ifsvals;
elements = new_elements;
for (i = 0; i < ifsvals.num_elements; i++)
{
aff_element_compute_trans (elements[i], width, height,
ifsvals.center_x, ifsvals.center_y);
aff_element_compute_color_trans (elements[i]);
}
element_selected = g_realloc (element_selected,
ifsvals.num_elements * sizeof(gint));
for (i = 0; i < ifsvals.num_elements; i++)
element_selected[i] = FALSE;
if (ifsOptD)
{
value_pair_update (ifsOptD->iterations_pair);
value_pair_update (ifsOptD->subdivide_pair);
value_pair_update (ifsOptD->radius_pair);
value_pair_update (ifsOptD->memory_pair);
}
set_current_element (0);
element_selected[0] = TRUE;
recompute_center (FALSE);
if (ifsD->selected_orig)
g_free (ifsD->selected_orig);
ifsD->selected_orig = g_new (AffElement, ifsvals.num_elements);
}
/* load an ifs file */
static void
ifsfile_load (GtkWidget *widget,
GtkWidget *file_select)
{
const gchar *filename;
gchar *buffer;
AffElement **new_elements;
IfsComposeVals new_ifsvals;
GError *error = NULL;
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_select));
if (g_file_get_contents (filename, &buffer, NULL, &error))
{
if (ifsvals_parse_string (buffer, &new_ifsvals, &new_elements))
{
guint i;
undo_begin ();
for (i = 0; i < ifsvals.num_elements; i++)
undo_update (i);
ifsfile_replace_ifsvals (&new_ifsvals, new_elements);
if (ifsD->auto_preview)
ifs_compose_preview ();
gtk_widget_hide (file_select);
design_area_redraw ();
}
else
{
gchar *message = g_strdup_printf (_("File '%s' doesn't seem to be "
"an IFS Compose file."),
filename);
ifscompose_message_dialog (GTK_MESSAGE_ERROR,
GTK_WINDOW (file_select),
_("Load failed"), message);
g_free (message);
}
g_free (buffer);
}
else
{
ifscompose_message_dialog (GTK_MESSAGE_ERROR,
GTK_WINDOW (file_select),
_("Load failed"), error->message);
g_error_free (error);
}
}
static void
ifs_compose_save_callback (GtkWidget *widget,
gpointer data)
{
static GtkWidget *file_select = NULL;
if (!file_select)
{
file_select = gtk_file_selection_new (_("Save as IFS file"));
gimp_help_connect (file_select, gimp_standard_help_func,
"filters/ifscompose.html");
g_signal_connect (GTK_FILE_SELECTION (file_select)->ok_button, "clicked",
G_CALLBACK (ifsfile_save),
file_select);
g_signal_connect_swapped (GTK_FILE_SELECTION (file_select)->cancel_button,
"clicked",
G_CALLBACK (gtk_widget_hide),
file_select);
}
gtk_window_present (GTK_WINDOW (file_select));
}
static void
ifs_compose_load_callback (GtkWidget *widget,
gpointer data)
{
static GtkWidget *file_select = NULL;
if (!file_select)
{
file_select = gtk_file_selection_new (_("Load IFS file"));
gimp_help_connect (file_select, gimp_standard_help_func,
"filters/ifscompose.html");
g_signal_connect (GTK_FILE_SELECTION (file_select)->ok_button, "clicked",
G_CALLBACK (ifsfile_load),
file_select);
g_signal_connect_swapped (GTK_FILE_SELECTION (file_select)->cancel_button,
"clicked",
G_CALLBACK (gtk_widget_hide),
file_select);
}
gtk_window_present (GTK_WINDOW (file_select));
}
1997-11-24 22:05:25 +00:00
static void
ifs_compose_new_callback (GtkWidget *widget,
gpointer data)
{
GimpRGB color;
gdouble width = ifsDesign->area->allocation.width;
gdouble height = ifsDesign->area->allocation.height;
gint i;
1997-11-24 22:05:25 +00:00
AffElement *elem;
undo_begin ();
1997-11-24 22:05:25 +00:00
tools/pdbgen/lib.pl tools/pdbgen/pdb.pl tools/pdbgen/pdb/channel.pdb 2001-01-25 Sven Neumann <sven@gimp.org> * tools/pdbgen/lib.pl * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: changed these with the help of Yosh. PDB functions take GimpRGB as color type now. * app/plug_in.c * app/pdb/channel_cmds.c * app/pdb/internal_procs.c * app/pdb/palette_cmds.c * app/pdb/procedural_db.[ch] * app/pdb/tools_cmds.c * libgimp/gimp.[ch] * libgimp/gimpchannel.[ch] * libgimp/gimpchannel_pdb.[ch] * libgimp/gimppalette_pdb.[ch] * libgimp/gimpprotocol.[ch] * libgimp/gimptools_pdb.[ch]: incremented Gimp protocol version and changed color type from array of chars to GimpRGB. * libgimp/Makefile.am * libgimp/gimppalette.[ch]: removed these files again * app/libgimp_glue.[ch] * libgimpwidgets/gimpcolorbutton.c * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_preview.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/psd.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/tiff.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gap/gap_filter_iterators.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gdyntext/gdyntext.c * plug-ins/gfig/gfig.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu.c * plug-ins/xjt/xjt.c: changed accordingly. A few plug-ins need to be looked at more closely after this change. I tried to put FIXME comments into those.
2001-01-25 01:20:05 +00:00
gimp_palette_get_foreground (&color);
1997-11-24 22:05:25 +00:00
elem = aff_element_new (0.5, 0.5 * height / width, &color,
++count_for_naming);
1997-11-24 22:05:25 +00:00
ifsvals.num_elements++;
elements = g_realloc (elements, ifsvals.num_elements * sizeof (AffElement *));
element_selected = g_realloc (element_selected,
ifsvals.num_elements * sizeof (gint));
1997-11-24 22:05:25 +00:00
for (i = 0; i < ifsvals.num_elements-1; i++)
1997-11-24 22:05:25 +00:00
element_selected[i] = FALSE;
element_selected[ifsvals.num_elements-1] = TRUE;
elements[ifsvals.num_elements-1] = elem;
set_current_element (ifsvals.num_elements-1);
1997-11-24 22:05:25 +00:00
ifsD->selected_orig = g_realloc (ifsD->selected_orig,
1997-11-24 22:05:25 +00:00
ifsvals.num_elements*sizeof(AffElement));
aff_element_compute_trans (elem, width, height,
1997-11-24 22:05:25 +00:00
ifsvals.center_x, ifsvals.center_y);
design_area_redraw ();
1997-11-24 22:05:25 +00:00
if (ifsD->auto_preview)
ifs_compose_preview ();
if (ifsvals.num_elements > 2)
{
gtk_widget_set_sensitive (ifsD->delete_button, TRUE);
gtk_widget_set_sensitive (ifsD->delete_menu_item, TRUE);
}
1997-11-24 22:05:25 +00:00
}
static void
ifs_compose_delete_callback (GtkWidget *widget,
gpointer data)
{
gint i;
gint new_current;
undo_begin ();
undo_update (ifsD->current_element);
1997-11-24 22:05:25 +00:00
aff_element_free (elements[ifsD->current_element]);
1997-11-24 22:05:25 +00:00
if (ifsD->current_element < ifsvals.num_elements-1)
{
undo_update (ifsvals.num_elements-1);
1997-11-24 22:05:25 +00:00
elements[ifsD->current_element] = elements[ifsvals.num_elements-1];
new_current = ifsD->current_element;
}
else
new_current = ifsvals.num_elements-2;
ifsvals.num_elements--;
for (i = 0; i < ifsvals.num_elements; i++)
1997-11-24 22:05:25 +00:00
if (element_selected[i])
{
new_current = i;
break;
}
element_selected[new_current] = TRUE;
set_current_element (new_current);
1997-11-24 22:05:25 +00:00
design_area_redraw ();
1997-11-24 22:05:25 +00:00
if (ifsD->auto_preview)
ifs_compose_preview ();
if (ifsvals.num_elements == 2)
{
gtk_widget_set_sensitive (ifsD->delete_button, FALSE);
gtk_widget_set_sensitive (ifsD->delete_menu_item, FALSE);
}
1997-11-24 22:05:25 +00:00
}
static gint
preview_idle_render (gpointer data)
1997-11-24 22:05:25 +00:00
{
gint width = GTK_WIDGET (ifsD->preview)->requisition.width;
gint height = GTK_WIDGET (ifsD->preview)->requisition.height;
gint iterations = PREVIEW_RENDER_CHUNK;
1997-11-24 22:05:25 +00:00
gint i;
if (iterations > ifsD->preview_iterations)
iterations = ifsD->preview_iterations;
for (i = 0; i < ifsvals.num_elements; i++)
aff_element_compute_trans (elements[i], width, height,
1997-11-24 22:05:25 +00:00
ifsvals.center_x, ifsvals.center_y);
ifs_render (elements, ifsvals.num_elements, width, height,
iterations,&ifsvals, 0, height,
ifsD->preview_data, NULL, NULL, TRUE);
1997-11-24 22:05:25 +00:00
for (i = 0; i < ifsvals.num_elements; i++)
aff_element_compute_trans (elements[i],
1997-11-24 22:05:25 +00:00
ifsDesign->area->allocation.width,
ifsDesign->area->allocation.height,
ifsvals.center_x, ifsvals.center_y);
ifsD->preview_iterations -= iterations;
for (i = 0; i < height; i++)
gtk_preview_draw_row (GTK_PREVIEW (ifsD->preview),
ifsD->preview_data + i * width * 3,
0, i, width);
gtk_widget_queue_draw (ifsD->preview);
1997-11-24 22:05:25 +00:00
return (ifsD->preview_iterations != 0);
}
static void
ifs_compose_preview (void)
1997-11-24 22:05:25 +00:00
{
/* Expansion isn't really supported for previews */
gint i;
gint width = GTK_WIDGET (ifsD->preview)->requisition.width;
gint height = GTK_WIDGET (ifsD->preview)->requisition.height;
guchar rc, gc, bc;
guchar *ptr;
GimpRGB color;
1997-11-24 22:05:25 +00:00
if (!ifsD->preview_data)
tools/pdbgen/lib.pl tools/pdbgen/pdb.pl tools/pdbgen/pdb/channel.pdb 2001-01-25 Sven Neumann <sven@gimp.org> * tools/pdbgen/lib.pl * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: changed these with the help of Yosh. PDB functions take GimpRGB as color type now. * app/plug_in.c * app/pdb/channel_cmds.c * app/pdb/internal_procs.c * app/pdb/palette_cmds.c * app/pdb/procedural_db.[ch] * app/pdb/tools_cmds.c * libgimp/gimp.[ch] * libgimp/gimpchannel.[ch] * libgimp/gimpchannel_pdb.[ch] * libgimp/gimppalette_pdb.[ch] * libgimp/gimpprotocol.[ch] * libgimp/gimptools_pdb.[ch]: incremented Gimp protocol version and changed color type from array of chars to GimpRGB. * libgimp/Makefile.am * libgimp/gimppalette.[ch]: removed these files again * app/libgimp_glue.[ch] * libgimpwidgets/gimpcolorbutton.c * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_preview.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/psd.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/tiff.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gap/gap_filter_iterators.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gdyntext/gdyntext.c * plug-ins/gfig/gfig.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu.c * plug-ins/xjt/xjt.c: changed accordingly. A few plug-ins need to be looked at more closely after this change. I tried to put FIXME comments into those.
2001-01-25 01:20:05 +00:00
ifsD->preview_data = g_new (guchar, 3 * width * height);
1997-11-24 22:05:25 +00:00
tools/pdbgen/lib.pl tools/pdbgen/pdb.pl tools/pdbgen/pdb/channel.pdb 2001-01-25 Sven Neumann <sven@gimp.org> * tools/pdbgen/lib.pl * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: changed these with the help of Yosh. PDB functions take GimpRGB as color type now. * app/plug_in.c * app/pdb/channel_cmds.c * app/pdb/internal_procs.c * app/pdb/palette_cmds.c * app/pdb/procedural_db.[ch] * app/pdb/tools_cmds.c * libgimp/gimp.[ch] * libgimp/gimpchannel.[ch] * libgimp/gimpchannel_pdb.[ch] * libgimp/gimppalette_pdb.[ch] * libgimp/gimpprotocol.[ch] * libgimp/gimptools_pdb.[ch]: incremented Gimp protocol version and changed color type from array of chars to GimpRGB. * libgimp/Makefile.am * libgimp/gimppalette.[ch]: removed these files again * app/libgimp_glue.[ch] * libgimpwidgets/gimpcolorbutton.c * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_preview.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colorify.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/nova.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/psd.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/tiff.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gap/gap_filter_iterators.c * plug-ins/gap/gap_mov_dialog.c * plug-ins/gdyntext/gdyntext.c * plug-ins/gfig/gfig.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu.c * plug-ins/xjt/xjt.c: changed accordingly. A few plug-ins need to be looked at more closely after this change. I tried to put FIXME comments into those.
2001-01-25 01:20:05 +00:00
gimp_palette_get_background (&color);
gimp_rgb_get_uchar (&color, &rc, &gc, &bc);
1997-11-24 22:05:25 +00:00
ptr = ifsD->preview_data;
for (i = 0; i < width * height; i++)
1997-11-24 22:05:25 +00:00
{
*ptr++ = rc;
*ptr++ = gc;
*ptr++ = bc;
}
if (ifsD->preview_iterations == 0)
g_idle_add (preview_idle_render, NULL);
1997-11-24 22:05:25 +00:00
ifsD->preview_iterations =
ifsvals.iterations * ((gdouble) width * height /
(ifsD->drawable_width * ifsD->drawable_height));
1997-11-24 22:05:25 +00:00
}
static void
ifs_compose_ok_callback (GtkWidget *widget,
GtkWidget *window)
1997-11-24 22:05:25 +00:00
{
ifscint.run = TRUE;
gtk_widget_destroy (window);
1997-11-24 22:05:25 +00:00
}