1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "config.h"
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "apptypes.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "appenv.h"
|
|
|
|
#include "drawable.h"
|
|
|
|
#include "gdisplay.h"
|
1999-08-14 04:50:30 +08:00
|
|
|
#include "gimpbrushlist.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "gimpbrush.h"
|
|
|
|
#include "gimpcontext.h"
|
|
|
|
#include "gimpimage.h"
|
2000-01-14 20:41:00 +08:00
|
|
|
#include "gimpui.h"
|
1999-03-17 13:40:16 +08:00
|
|
|
#include "gradient.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "paint_funcs.h"
|
|
|
|
#include "paint_core.h"
|
1999-04-22 22:34:00 +08:00
|
|
|
#include "paint_options.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "paintbrush.h"
|
|
|
|
#include "selection.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "temp_buf.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "tools.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "tool_options.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "libgimp/gimpmath.h"
|
1999-09-26 03:49:58 +08:00
|
|
|
#include "libgimp/gimpunitmenu.h"
|
2000-04-28 01:27:28 +08:00
|
|
|
|
1998-12-16 08:37:09 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* defines */
|
|
|
|
#define PAINT_LEFT_THRESHOLD 0.05
|
|
|
|
|
1999-07-20 06:42:49 +08:00
|
|
|
/* defaults for the tool options */
|
|
|
|
#define PAINTBRUSH_DEFAULT_INCREMENTAL FALSE
|
1999-09-26 03:49:58 +08:00
|
|
|
#define PAINTBRUSH_DEFAULT_USE_FADE FALSE
|
|
|
|
#define PAINTBRUSH_DEFAULT_FADE_OUT 100.0
|
2000-02-08 04:35:13 +08:00
|
|
|
#define PAINTBRUSH_DEFAULT_FADE_UNIT GIMP_UNIT_PIXEL
|
1999-07-20 06:42:49 +08:00
|
|
|
#define PAINTBRUSH_DEFAULT_USE_GRADIENT FALSE
|
1999-09-26 03:49:58 +08:00
|
|
|
#define PAINTBRUSH_DEFAULT_GRADIENT_LENGTH 100.0
|
2000-02-08 04:35:13 +08:00
|
|
|
#define PAINTBRUSH_DEFAULT_GRADIENT_UNIT GIMP_UNIT_PIXEL
|
1999-07-20 06:42:49 +08:00
|
|
|
#define PAINTBRUSH_DEFAULT_GRADIENT_TYPE LOOP_TRIANGLE
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* the paintbrush structures */
|
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
typedef struct _PaintbrushOptions PaintbrushOptions;
|
|
|
|
struct _PaintbrushOptions
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-04-22 22:34:00 +08:00
|
|
|
PaintOptions paint_options;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gboolean use_fade;
|
|
|
|
gboolean use_fade_d;
|
1999-09-26 03:49:58 +08:00
|
|
|
GtkWidget *use_fade_w;
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gdouble fade_out;
|
|
|
|
gdouble fade_out_d;
|
1999-04-22 22:34:00 +08:00
|
|
|
GtkObject *fade_out_w;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
GimpUnit fade_unit;
|
|
|
|
GimpUnit fade_unit_d;
|
1999-09-26 03:49:58 +08:00
|
|
|
GtkWidget *fade_unit_w;
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gboolean use_gradient;
|
|
|
|
gboolean use_gradient_d;
|
1999-04-22 22:34:00 +08:00
|
|
|
GtkWidget *use_gradient_w;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gdouble gradient_length;
|
|
|
|
gdouble gradient_length_d;
|
1999-04-22 22:34:00 +08:00
|
|
|
GtkObject *gradient_length_w;
|
1999-04-13 01:55:06 +08:00
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
GimpUnit gradient_unit;
|
|
|
|
GimpUnit gradient_unit_d;
|
1999-09-26 03:49:58 +08:00
|
|
|
GtkWidget *gradient_unit_w;
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gint gradient_type;
|
|
|
|
gint gradient_type_d;
|
1999-07-07 02:13:59 +08:00
|
|
|
GtkWidget *gradient_type_w;
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
/* the paint brush tool options */
|
1999-06-22 06:12:07 +08:00
|
|
|
static PaintbrushOptions * paintbrush_options = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* local variables */
|
2000-02-08 04:35:13 +08:00
|
|
|
static gdouble non_gui_fade_out;
|
|
|
|
static gdouble non_gui_gradient_length;
|
|
|
|
static gint non_gui_gradient_type;
|
|
|
|
static gdouble non_gui_incremental;
|
|
|
|
static GimpUnit non_gui_fade_unit;
|
|
|
|
static GimpUnit non_gui_gradient_unit;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* forward function declarations */
|
2000-12-29 23:22:01 +08:00
|
|
|
static void paintbrush_motion (PaintCore *,
|
|
|
|
GimpDrawable *,
|
2000-01-14 20:41:00 +08:00
|
|
|
PaintPressureOptions *,
|
2000-12-29 23:22:01 +08:00
|
|
|
gdouble,
|
|
|
|
gdouble,
|
|
|
|
PaintApplicationMode,
|
2000-01-14 20:41:00 +08:00
|
|
|
GradientPaintMode);
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* functions */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-03-01 09:18:45 +08:00
|
|
|
static void
|
1999-04-13 01:55:06 +08:00
|
|
|
paintbrush_gradient_toggle_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-03-01 09:18:45 +08:00
|
|
|
{
|
1999-04-22 22:34:00 +08:00
|
|
|
PaintbrushOptions *options = paintbrush_options;
|
1998-03-01 09:18:45 +08:00
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
static int incremental_save = FALSE;
|
1998-03-01 09:18:45 +08:00
|
|
|
|
2000-01-14 20:41:00 +08:00
|
|
|
gimp_toggle_button_update (widget, data);
|
1998-03-01 09:18:45 +08:00
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
if (paintbrush_options->use_gradient)
|
|
|
|
{
|
1999-08-20 03:53:30 +08:00
|
|
|
incremental_save = options->paint_options.incremental;
|
|
|
|
gtk_toggle_button_set_active
|
|
|
|
(GTK_TOGGLE_BUTTON (options->paint_options.incremental_w), TRUE);
|
1999-04-13 01:55:06 +08:00
|
|
|
}
|
1999-03-28 13:27:34 +08:00
|
|
|
else
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
1999-08-20 03:53:30 +08:00
|
|
|
gtk_toggle_button_set_active
|
|
|
|
(GTK_TOGGLE_BUTTON (options->paint_options.incremental_w),
|
|
|
|
incremental_save);
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
static void
|
1999-04-13 01:55:06 +08:00
|
|
|
paintbrush_options_reset (void)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
1999-04-22 22:34:00 +08:00
|
|
|
PaintbrushOptions *options = paintbrush_options;
|
1999-09-26 03:49:58 +08:00
|
|
|
GtkWidget *spinbutton;
|
2000-04-28 01:27:28 +08:00
|
|
|
gint digits;
|
1999-04-22 22:34:00 +08:00
|
|
|
|
|
|
|
paint_options_reset ((PaintOptions *) options);
|
1999-04-09 06:25:54 +08:00
|
|
|
|
1999-09-26 03:49:58 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_fade_w),
|
|
|
|
options->use_fade_d);
|
1999-04-09 06:25:54 +08:00
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->fade_out_w),
|
|
|
|
options->fade_out_d);
|
1999-09-26 03:49:58 +08:00
|
|
|
gimp_unit_menu_set_unit (GIMP_UNIT_MENU (options->fade_unit_w),
|
|
|
|
options->fade_unit_d);
|
2000-02-08 04:35:13 +08:00
|
|
|
digits = ((options->fade_unit_d == GIMP_UNIT_PIXEL) ? 0 :
|
|
|
|
((options->fade_unit_d == GIMP_UNIT_PERCENT) ? 2 :
|
1999-09-26 03:49:58 +08:00
|
|
|
(MIN (6, MAX (3, gimp_unit_get_digits (options->fade_unit_d))))));
|
|
|
|
spinbutton = gtk_object_get_data (GTK_OBJECT (options->fade_unit_w), "set_digits");
|
|
|
|
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), digits);
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_gradient_w),
|
|
|
|
options->use_gradient_d);
|
1999-04-09 06:25:54 +08:00
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->gradient_length_w),
|
|
|
|
options->gradient_length_d);
|
1999-09-26 03:49:58 +08:00
|
|
|
gimp_unit_menu_set_unit (GIMP_UNIT_MENU (options->gradient_unit_w),
|
|
|
|
options->gradient_unit_d);
|
2000-02-08 04:35:13 +08:00
|
|
|
digits = ((options->gradient_unit_d == GIMP_UNIT_PIXEL) ? 0 :
|
|
|
|
((options->gradient_unit_d == GIMP_UNIT_PERCENT) ? 2 :
|
1999-09-26 03:49:58 +08:00
|
|
|
(MIN (6, MAX (3, gimp_unit_get_digits (options->gradient_unit_d))))));
|
|
|
|
spinbutton = gtk_object_get_data (GTK_OBJECT (options->gradient_unit_w), "set_digits");
|
|
|
|
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), digits);
|
2000-02-14 06:26:41 +08:00
|
|
|
|
|
|
|
options->gradient_type = options->gradient_type_d;
|
|
|
|
|
1999-07-07 02:13:59 +08:00
|
|
|
gtk_option_menu_set_history (GTK_OPTION_MENU (options->gradient_type_w),
|
|
|
|
options->gradient_type_d);
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
1999-03-28 13:27:34 +08:00
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
static PaintbrushOptions *
|
1999-04-13 01:55:06 +08:00
|
|
|
paintbrush_options_new (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-04-22 22:34:00 +08:00
|
|
|
PaintbrushOptions *options;
|
1999-04-13 01:55:06 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *vbox;
|
1999-04-09 06:25:54 +08:00
|
|
|
GtkWidget *abox;
|
|
|
|
GtkWidget *table;
|
1999-07-07 02:13:59 +08:00
|
|
|
GtkWidget *type_label;
|
1999-09-26 03:49:58 +08:00
|
|
|
GtkWidget *spinbutton;
|
1999-03-19 08:42:27 +08:00
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
/* the new paint tool options structure */
|
1999-10-27 02:27:27 +08:00
|
|
|
options = g_new (PaintbrushOptions, 1);
|
1999-04-22 22:34:00 +08:00
|
|
|
paint_options_init ((PaintOptions *) options,
|
|
|
|
PAINTBRUSH,
|
|
|
|
paintbrush_options_reset);
|
1999-09-09 09:47:54 +08:00
|
|
|
|
1999-09-26 03:49:58 +08:00
|
|
|
options->use_fade =
|
|
|
|
options->use_fade_d = PAINTBRUSH_DEFAULT_USE_FADE;
|
1999-07-20 06:42:49 +08:00
|
|
|
options->fade_out =
|
|
|
|
options->fade_out_d = PAINTBRUSH_DEFAULT_FADE_OUT;
|
1999-09-26 03:49:58 +08:00
|
|
|
options->fade_unit =
|
|
|
|
options->fade_unit_d = PAINTBRUSH_DEFAULT_FADE_UNIT;
|
1999-07-20 06:42:49 +08:00
|
|
|
options->use_gradient =
|
|
|
|
options->use_gradient_d = PAINTBRUSH_DEFAULT_USE_GRADIENT;
|
|
|
|
options->gradient_length =
|
|
|
|
options->gradient_length_d = PAINTBRUSH_DEFAULT_GRADIENT_LENGTH;
|
1999-09-26 03:49:58 +08:00
|
|
|
options->gradient_unit =
|
|
|
|
options->gradient_unit_d = PAINTBRUSH_DEFAULT_GRADIENT_UNIT;
|
1999-07-20 06:42:49 +08:00
|
|
|
options->gradient_type =
|
|
|
|
options->gradient_type_d = PAINTBRUSH_DEFAULT_GRADIENT_TYPE;
|
1999-03-17 13:40:16 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* the main vbox */
|
1999-04-22 22:34:00 +08:00
|
|
|
vbox = ((ToolOptions *) options)->main_vbox;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-26 03:49:58 +08:00
|
|
|
table = gtk_table_new (3, 3, FALSE);
|
1999-04-22 22:34:00 +08:00
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
1999-04-09 06:25:54 +08:00
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
|
1999-09-26 03:49:58 +08:00
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 1, 3);
|
1999-04-09 06:25:54 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
|
1999-09-26 03:49:58 +08:00
|
|
|
/* the use fade toggle */
|
|
|
|
abox = gtk_alignment_new (0.5, 1.0, 1.0, 0.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), abox, 0, 1, 0, 1,
|
1999-04-09 06:25:54 +08:00
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
1999-09-26 03:49:58 +08:00
|
|
|
gtk_widget_show (abox);
|
|
|
|
|
|
|
|
options->use_fade_w =
|
|
|
|
gtk_check_button_new_with_label (_("Fade Out"));
|
|
|
|
gtk_container_add (GTK_CONTAINER (abox), options->use_fade_w);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (options->use_fade_w), "toggled",
|
2000-01-14 20:41:00 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_toggle_button_update),
|
1999-09-26 03:49:58 +08:00
|
|
|
&options->use_fade);
|
|
|
|
gtk_widget_show (options->use_fade_w);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-26 03:49:58 +08:00
|
|
|
/* the fade-out sizeentry */
|
1999-08-14 04:50:30 +08:00
|
|
|
options->fade_out_w =
|
1999-09-26 03:49:58 +08:00
|
|
|
gtk_adjustment_new (options->fade_out_d, 1e-5, 32767.0, 1.0, 50.0, 0.0);
|
|
|
|
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (options->fade_out_w), 1.0, 0.0);
|
|
|
|
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton), GTK_SHADOW_NONE);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
|
|
|
gtk_widget_set_usize (spinbutton, 75, 0);
|
1999-04-09 06:25:54 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (options->fade_out_w), "value_changed",
|
2000-01-14 20:41:00 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
|
1999-04-13 02:09:55 +08:00
|
|
|
&options->fade_out);
|
1999-09-26 03:49:58 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 0, 1);
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
|
|
|
/* the fade-out unitmenu */
|
|
|
|
options->fade_unit_w =
|
|
|
|
gimp_unit_menu_new ("%a", options->fade_unit_d, TRUE, TRUE, TRUE);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (options->fade_unit_w), "unit_changed",
|
2000-01-14 20:41:00 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_unit_menu_update),
|
1999-09-26 03:49:58 +08:00
|
|
|
&options->fade_unit);
|
|
|
|
gtk_object_set_data (GTK_OBJECT (options->fade_unit_w), "set_digits", spinbutton);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), options->fade_unit_w, 2, 3, 0, 1,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (options->fade_unit_w);
|
|
|
|
|
|
|
|
/* automatically set the sensitive state of the fadeout stuff */
|
|
|
|
gtk_widget_set_sensitive (spinbutton, options->use_fade_d);
|
|
|
|
gtk_widget_set_sensitive (options->fade_unit_w, options->use_fade_d);
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_object_set_data (GTK_OBJECT (options->use_fade_w),
|
|
|
|
"set_sensitive", spinbutton);
|
|
|
|
gtk_object_set_data (GTK_OBJECT (spinbutton),
|
|
|
|
"set_sensitive", options->fade_unit_w);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
/* the use gradient toggle */
|
1999-09-26 03:49:58 +08:00
|
|
|
abox = gtk_alignment_new (0.5, 1.0, 1.0, 0.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), abox, 0, 1, 1, 2,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (abox);
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
options->use_gradient_w =
|
|
|
|
gtk_check_button_new_with_label (_("Gradient"));
|
1999-09-26 03:49:58 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (abox), options->use_gradient_w);
|
1999-04-13 01:55:06 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (options->use_gradient_w), "toggled",
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_SIGNAL_FUNC (paintbrush_gradient_toggle_callback),
|
1999-04-13 01:55:06 +08:00
|
|
|
&options->use_gradient);
|
|
|
|
gtk_widget_show (options->use_gradient_w);
|
1999-03-17 13:40:16 +08:00
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
/* the gradient length scale */
|
1999-09-26 03:49:58 +08:00
|
|
|
options->gradient_length_w =
|
|
|
|
gtk_adjustment_new (options->gradient_length_d, 1e-5, 32767.0, 1.0, 50.0, 0.0);
|
|
|
|
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (options->gradient_length_w), 1.0, 0.0);
|
|
|
|
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton), GTK_SHADOW_NONE);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
|
|
|
gtk_widget_set_usize (spinbutton, 75, 0);
|
1999-04-09 06:25:54 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (options->gradient_length_w), "value_changed",
|
2000-01-14 20:41:00 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
|
1999-04-13 01:55:06 +08:00
|
|
|
&options->gradient_length);
|
1999-09-26 03:49:58 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 1, 2);
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
|
|
|
/* the gradient unitmenu */
|
|
|
|
options->gradient_unit_w =
|
|
|
|
gimp_unit_menu_new ("%a", options->gradient_unit_d, TRUE, TRUE, TRUE);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (options->gradient_unit_w), "unit_changed",
|
2000-01-14 20:41:00 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_unit_menu_update),
|
1999-09-26 03:49:58 +08:00
|
|
|
&options->gradient_unit);
|
2000-01-14 20:41:00 +08:00
|
|
|
gtk_object_set_data (GTK_OBJECT (options->gradient_unit_w), "set_digits",
|
|
|
|
spinbutton);
|
1999-09-26 03:49:58 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), options->gradient_unit_w, 2, 3, 1, 2,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (options->gradient_unit_w);
|
1998-03-01 09:18:45 +08:00
|
|
|
|
1999-07-07 02:13:59 +08:00
|
|
|
/* the gradient type */
|
|
|
|
type_label = gtk_label_new (_("Type:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (type_label), 1.0, 0.5);
|
1999-09-26 03:49:58 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), type_label, 0, 1, 2, 3,
|
1999-07-07 02:13:59 +08:00
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (type_label);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-07-07 02:13:59 +08:00
|
|
|
abox = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
|
1999-09-26 03:49:58 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), abox, 1, 3, 2, 3);
|
1999-07-07 02:13:59 +08:00
|
|
|
gtk_widget_show (abox);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2000-02-14 06:26:41 +08:00
|
|
|
options->gradient_type_w = gimp_option_menu_new2
|
|
|
|
(FALSE, gimp_menu_item_update,
|
|
|
|
&options->gradient_type, (gpointer) options->gradient_type_d,
|
|
|
|
|
|
|
|
_("Once Forward"), (gpointer) ONCE_FORWARD, NULL,
|
|
|
|
_("Once Backward"), (gpointer) ONCE_BACKWARDS, NULL,
|
|
|
|
_("Loop Sawtooth"), (gpointer) LOOP_SAWTOOTH, NULL,
|
|
|
|
_("Loop Triangle"), (gpointer) LOOP_TRIANGLE, NULL,
|
|
|
|
|
|
|
|
NULL);
|
1999-07-07 02:13:59 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (abox), options->gradient_type_w);
|
|
|
|
gtk_widget_show (options->gradient_type_w);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-09-26 03:49:58 +08:00
|
|
|
gtk_widget_show (table);
|
|
|
|
|
1999-04-19 02:55:49 +08:00
|
|
|
/* automatically set the sensitive state of the gradient stuff */
|
1999-09-26 03:49:58 +08:00
|
|
|
gtk_widget_set_sensitive (spinbutton, options->use_gradient_d);
|
|
|
|
gtk_widget_set_sensitive (spinbutton, options->use_gradient_d);
|
|
|
|
gtk_widget_set_sensitive (options->gradient_unit_w, options->use_gradient_d);
|
1999-07-07 02:13:59 +08:00
|
|
|
gtk_widget_set_sensitive (options->gradient_type_w, options->use_gradient_d);
|
|
|
|
gtk_widget_set_sensitive (type_label, options->use_gradient_d);
|
1999-08-20 03:53:30 +08:00
|
|
|
gtk_widget_set_sensitive (options->paint_options.incremental_w,
|
|
|
|
! options->use_gradient_d);
|
1999-04-19 02:55:49 +08:00
|
|
|
gtk_object_set_data (GTK_OBJECT (options->use_gradient_w), "set_sensitive",
|
1999-09-26 03:49:58 +08:00
|
|
|
spinbutton);
|
|
|
|
gtk_object_set_data (GTK_OBJECT (spinbutton), "set_sensitive",
|
|
|
|
options->gradient_unit_w);
|
|
|
|
gtk_object_set_data (GTK_OBJECT (options->gradient_unit_w), "set_sensitive",
|
1999-07-07 02:13:59 +08:00
|
|
|
options->gradient_type_w);
|
|
|
|
gtk_object_set_data (GTK_OBJECT (options->gradient_type_w), "set_sensitive",
|
|
|
|
type_label);
|
1999-04-19 02:55:49 +08:00
|
|
|
gtk_object_set_data (GTK_OBJECT (options->use_gradient_w), "inverse_sensitive",
|
1999-08-20 03:53:30 +08:00
|
|
|
options->paint_options.incremental_w);
|
1999-04-19 02:55:49 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
1998-12-16 19:23:30 +08:00
|
|
|
#define TIMED_BRUSH 0
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void *
|
1999-07-07 02:13:59 +08:00
|
|
|
paintbrush_paint_func (PaintCore *paint_core,
|
1998-01-22 15:02:57 +08:00
|
|
|
GimpDrawable *drawable,
|
1999-07-07 02:13:59 +08:00
|
|
|
int state)
|
1999-09-26 03:49:58 +08:00
|
|
|
{
|
|
|
|
GDisplay *gdisp = gdisplay_active ();
|
|
|
|
double fade_out;
|
|
|
|
double gradient_length;
|
|
|
|
double unit_factor;
|
|
|
|
|
1999-09-26 11:39:59 +08:00
|
|
|
g_return_val_if_fail (gdisp != NULL, NULL);
|
1999-09-26 03:49:58 +08:00
|
|
|
|
1998-12-16 19:23:30 +08:00
|
|
|
#if TIMED_BRUSH
|
1999-04-23 14:07:09 +08:00
|
|
|
static GTimer *timer = NULL;
|
1998-12-16 19:23:30 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (state)
|
|
|
|
{
|
2000-12-29 23:22:01 +08:00
|
|
|
case INIT_PAINT:
|
1998-12-16 19:23:30 +08:00
|
|
|
#if TIMED_BRUSH
|
|
|
|
timer = g_timer_new();
|
|
|
|
g_timer_start(timer);
|
|
|
|
#endif /* TIMED_BRUSH */
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
case MOTION_PAINT:
|
1999-09-26 03:49:58 +08:00
|
|
|
switch (paintbrush_options->fade_unit)
|
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
case GIMP_UNIT_PIXEL:
|
1999-09-26 03:49:58 +08:00
|
|
|
fade_out = paintbrush_options->fade_out;
|
|
|
|
break;
|
2000-02-08 04:35:13 +08:00
|
|
|
case GIMP_UNIT_PERCENT:
|
1999-09-26 03:49:58 +08:00
|
|
|
fade_out = MAX (gdisp->gimage->width, gdisp->gimage->height) *
|
|
|
|
paintbrush_options->fade_out / 100;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
unit_factor = gimp_unit_get_factor (paintbrush_options->fade_unit);
|
|
|
|
fade_out = paintbrush_options->fade_out *
|
|
|
|
MAX (gdisp->gimage->xresolution, gdisp->gimage->yresolution) / unit_factor;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (paintbrush_options->gradient_unit)
|
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
case GIMP_UNIT_PIXEL:
|
1999-09-26 03:49:58 +08:00
|
|
|
gradient_length = paintbrush_options->gradient_length;
|
|
|
|
break;
|
2000-02-08 04:35:13 +08:00
|
|
|
case GIMP_UNIT_PERCENT:
|
1999-09-26 03:49:58 +08:00
|
|
|
gradient_length = MAX (gdisp->gimage->width, gdisp->gimage->height) *
|
|
|
|
paintbrush_options->gradient_length / 100;
|
|
|
|
break;
|
|
|
|
default:
|
1999-10-01 06:12:58 +08:00
|
|
|
unit_factor = gimp_unit_get_factor (paintbrush_options->gradient_unit);
|
1999-09-26 03:49:58 +08:00
|
|
|
gradient_length = paintbrush_options->gradient_length *
|
|
|
|
MAX (gdisp->gimage->xresolution, gdisp->gimage->yresolution) / unit_factor;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-05-13 19:12:32 +08:00
|
|
|
paintbrush_motion (paint_core, drawable,
|
1999-09-09 09:47:54 +08:00
|
|
|
paintbrush_options->paint_options.pressure_options,
|
1999-09-26 03:49:58 +08:00
|
|
|
paintbrush_options->use_fade ? fade_out : 0,
|
|
|
|
paintbrush_options->use_gradient ? gradient_length : 0,
|
1999-08-20 03:53:30 +08:00
|
|
|
paintbrush_options->paint_options.incremental,
|
1999-05-13 19:12:32 +08:00
|
|
|
paintbrush_options->gradient_type);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
1999-09-26 03:49:58 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
case FINISH_PAINT :
|
1998-12-16 19:23:30 +08:00
|
|
|
#if TIMED_BRUSH
|
1999-04-23 14:07:09 +08:00
|
|
|
if (timer)
|
|
|
|
{
|
|
|
|
g_timer_stop(timer);
|
2000-04-28 01:27:28 +08:00
|
|
|
g_print ("painting took %f:\n", g_timer_elapsed(timer, NULL));
|
1999-04-23 14:07:09 +08:00
|
|
|
g_timer_destroy(timer);
|
|
|
|
timer = NULL;
|
|
|
|
}
|
1998-12-16 19:23:30 +08:00
|
|
|
#endif /* TIMED_BRUSH */
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Tool *
|
|
|
|
tools_new_paintbrush ()
|
|
|
|
{
|
|
|
|
Tool * tool;
|
|
|
|
PaintCore * private;
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
/* The tool options */
|
|
|
|
if (! paintbrush_options)
|
|
|
|
{
|
|
|
|
paintbrush_options = paintbrush_options_new ();
|
|
|
|
tools_register (PAINTBRUSH, (ToolOptions *) paintbrush_options);
|
1999-04-18 07:18:43 +08:00
|
|
|
|
|
|
|
/* press all default buttons */
|
|
|
|
paintbrush_options_reset ();
|
1999-04-13 01:55:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
tool = paint_core_new (PAINTBRUSH);
|
|
|
|
|
|
|
|
private = (PaintCore *) tool->private;
|
|
|
|
private->paint_func = paintbrush_paint_func;
|
1999-05-13 19:12:32 +08:00
|
|
|
private->pick_colors = TRUE;
|
1999-08-27 05:33:58 +08:00
|
|
|
private->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return tool;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
tools_free_paintbrush (Tool *tool)
|
|
|
|
{
|
|
|
|
paint_core_free (tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
1999-08-20 03:53:30 +08:00
|
|
|
paintbrush_motion (PaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
1999-09-09 09:47:54 +08:00
|
|
|
PaintPressureOptions *pressure_options,
|
1999-08-20 03:53:30 +08:00
|
|
|
double fade_out,
|
|
|
|
double gradient_length,
|
|
|
|
PaintApplicationMode incremental,
|
|
|
|
GradientPaintMode gradient_type)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GImage *gimage;
|
|
|
|
TempBuf * area;
|
1999-09-09 09:47:54 +08:00
|
|
|
gdouble x, paint_left;
|
|
|
|
gdouble position;
|
|
|
|
guchar local_blend = OPAQUE_OPACITY;
|
|
|
|
guchar temp_blend = OPAQUE_OPACITY;
|
|
|
|
guchar col[MAX_CHANNELS];
|
|
|
|
gdouble r,g,b,a;
|
|
|
|
gint mode;
|
|
|
|
gint opacity;
|
|
|
|
gdouble scale;
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-19 07:41:39 +08:00
|
|
|
PaintApplicationMode paint_appl_mode = incremental ? INCREMENTAL : CONSTANT;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-03-17 13:40:16 +08:00
|
|
|
position = 0.0;
|
1998-01-22 15:02:57 +08:00
|
|
|
if (! (gimage = drawable_gimage (drawable)))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
1999-09-09 09:47:54 +08:00
|
|
|
if (pressure_options->size)
|
|
|
|
scale = paint_core->curpressure;
|
|
|
|
else
|
|
|
|
scale = 1.0;
|
1999-08-17 09:05:59 +08:00
|
|
|
|
1999-11-13 09:02:27 +08:00
|
|
|
if (pressure_options->color)
|
|
|
|
gradient_length = 1.0; /* not really used, only for if cases */
|
|
|
|
|
1999-05-15 08:02:47 +08:00
|
|
|
/* Get a region which can be used to paint to */
|
1999-09-09 09:47:54 +08:00
|
|
|
if (! (area = paint_core_get_paint_area (paint_core, drawable, scale)))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* factor in the fade out value */
|
|
|
|
if (fade_out)
|
|
|
|
{
|
|
|
|
/* Model the amount of paint left as a gaussian curve */
|
1999-09-26 03:49:58 +08:00
|
|
|
x = ((double) paint_core->pixel_dist / fade_out);
|
|
|
|
paint_left = exp (- x * x * 5.541); /* ln (1/255) */
|
1999-03-19 08:42:27 +08:00
|
|
|
local_blend = (int) (255 * paint_left);
|
1999-03-17 13:40:16 +08:00
|
|
|
}
|
|
|
|
|
1999-03-19 08:42:27 +08:00
|
|
|
if (local_blend)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* set the alpha channel */
|
1999-03-19 08:42:27 +08:00
|
|
|
temp_blend = local_blend;
|
1999-03-28 13:27:34 +08:00
|
|
|
mode = gradient_type;
|
1999-03-19 08:42:27 +08:00
|
|
|
|
1999-08-20 03:53:30 +08:00
|
|
|
if (gradient_length)
|
1999-03-17 13:40:16 +08:00
|
|
|
{
|
1999-11-13 09:02:27 +08:00
|
|
|
if (pressure_options->color)
|
|
|
|
gradient_get_color_at (gimp_context_get_gradient (NULL),
|
|
|
|
paint_core->curpressure, &r, &g, &b, &a);
|
|
|
|
else
|
|
|
|
paint_core_get_color_from_gradient (paint_core, gradient_length,
|
|
|
|
&r, &g, &b, &a, mode);
|
1999-03-17 13:40:16 +08:00
|
|
|
r = r * 255.0;
|
|
|
|
g = g * 255.0;
|
|
|
|
b = b * 255.0;
|
1999-08-19 11:51:33 +08:00
|
|
|
a = a * 255.0;
|
1999-09-26 03:49:58 +08:00
|
|
|
temp_blend = (gint)((a * local_blend) / 255);
|
1999-03-17 13:40:16 +08:00
|
|
|
col[0] = (gint)r;
|
|
|
|
col[1] = (gint)g;
|
|
|
|
col[2] = (gint)b;
|
1999-09-09 09:47:54 +08:00
|
|
|
col[3] = OPAQUE_OPACITY;
|
1999-03-19 08:42:27 +08:00
|
|
|
/* always use incremental mode with gradients */
|
|
|
|
/* make the gui cool later */
|
1999-08-20 03:53:30 +08:00
|
|
|
paint_appl_mode = INCREMENTAL;
|
1999-11-13 09:02:27 +08:00
|
|
|
color_pixels (temp_buf_data (area), col,
|
|
|
|
area->width * area->height, area->bytes);
|
1999-03-17 13:40:16 +08:00
|
|
|
}
|
1999-08-17 09:05:59 +08:00
|
|
|
/* we check to see if this is a pixmap, if so composite the
|
|
|
|
pixmap image into the are instead of the color */
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
else if (paint_core->brush && paint_core->brush->pixmap)
|
1999-08-14 04:50:30 +08:00
|
|
|
{
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
paint_core_color_area_with_pixmap (paint_core, gimage, drawable,
|
|
|
|
area,
|
1999-09-10 03:11:38 +08:00
|
|
|
scale, SOFT);
|
1999-08-20 03:53:30 +08:00
|
|
|
paint_appl_mode = INCREMENTAL;
|
1999-08-14 04:50:30 +08:00
|
|
|
}
|
1999-11-13 09:02:27 +08:00
|
|
|
else
|
1999-08-14 04:50:30 +08:00
|
|
|
{
|
2000-12-29 23:22:01 +08:00
|
|
|
gimp_image_get_foreground (gimage, drawable, col);
|
1999-11-13 09:02:27 +08:00
|
|
|
col[area->bytes - 1] = OPAQUE_OPACITY;
|
1999-08-14 04:50:30 +08:00
|
|
|
color_pixels (temp_buf_data (area), col,
|
|
|
|
area->width * area->height, area->bytes);
|
|
|
|
}
|
1999-09-09 09:47:54 +08:00
|
|
|
|
1999-09-26 03:49:58 +08:00
|
|
|
opacity = (gdouble)temp_blend;
|
1999-09-09 09:47:54 +08:00
|
|
|
if (pressure_options->opacity)
|
|
|
|
opacity = opacity * 2.0 * paint_core->curpressure;
|
|
|
|
|
1999-09-26 03:49:58 +08:00
|
|
|
paint_core_paste_canvas (paint_core, drawable,
|
|
|
|
MIN (opacity, 255),
|
1999-09-09 09:47:54 +08:00
|
|
|
gimp_context_get_opacity (NULL) * 255,
|
1999-07-06 23:18:25 +08:00
|
|
|
gimp_context_get_paint_mode (NULL),
|
1999-09-09 09:47:54 +08:00
|
|
|
pressure_options->pressure ? PRESSURE : SOFT,
|
|
|
|
scale, paint_appl_mode);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
1999-07-07 02:13:59 +08:00
|
|
|
paintbrush_non_gui_paint_func (PaintCore *paint_core,
|
1998-01-22 15:02:57 +08:00
|
|
|
GimpDrawable *drawable,
|
1999-07-07 02:13:59 +08:00
|
|
|
int state)
|
1999-10-01 06:12:58 +08:00
|
|
|
{
|
|
|
|
GImage *gimage;
|
|
|
|
double fade_out;
|
|
|
|
double gradient_length;
|
|
|
|
double unit_factor;
|
|
|
|
|
|
|
|
if (! (gimage = drawable_gimage (drawable)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
switch (non_gui_fade_unit)
|
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
case GIMP_UNIT_PIXEL:
|
1999-10-01 06:12:58 +08:00
|
|
|
fade_out = non_gui_fade_out;
|
|
|
|
break;
|
2000-02-08 04:35:13 +08:00
|
|
|
case GIMP_UNIT_PERCENT:
|
1999-10-01 06:12:58 +08:00
|
|
|
fade_out = MAX (gimage->width, gimage->height) *
|
|
|
|
non_gui_fade_out / 100;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
unit_factor = gimp_unit_get_factor (non_gui_fade_unit);
|
|
|
|
fade_out = non_gui_fade_out *
|
|
|
|
MAX (gimage->xresolution, gimage->yresolution) / unit_factor;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (non_gui_gradient_unit)
|
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
case GIMP_UNIT_PIXEL:
|
1999-10-01 06:12:58 +08:00
|
|
|
gradient_length = non_gui_gradient_length;
|
|
|
|
break;
|
2000-02-08 04:35:13 +08:00
|
|
|
case GIMP_UNIT_PERCENT:
|
1999-10-01 06:12:58 +08:00
|
|
|
gradient_length = MAX (gimage->width, gimage->height) *
|
|
|
|
non_gui_gradient_length / 100;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
unit_factor = gimp_unit_get_factor (non_gui_gradient_unit);
|
|
|
|
gradient_length = non_gui_gradient_length *
|
|
|
|
MAX (gimage->xresolution, gimage->yresolution) / unit_factor;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-08-20 03:53:30 +08:00
|
|
|
paintbrush_motion (paint_core,drawable,
|
1999-09-09 09:47:54 +08:00
|
|
|
&non_gui_pressure_options,
|
1999-10-01 06:12:58 +08:00
|
|
|
fade_out,
|
|
|
|
gradient_length,
|
1999-08-20 03:53:30 +08:00
|
|
|
non_gui_incremental,
|
|
|
|
non_gui_gradient_type);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-07-20 06:42:49 +08:00
|
|
|
gboolean
|
|
|
|
paintbrush_non_gui_default (GimpDrawable *drawable,
|
|
|
|
int num_strokes,
|
|
|
|
double *stroke_array)
|
|
|
|
{
|
|
|
|
PaintbrushOptions *options = paintbrush_options;
|
2000-02-08 04:35:13 +08:00
|
|
|
gdouble fade_out = PAINTBRUSH_DEFAULT_FADE_OUT;
|
1999-08-20 03:53:30 +08:00
|
|
|
gboolean incremental = PAINTBRUSH_DEFAULT_INCREMENTAL;
|
1999-10-27 02:27:27 +08:00
|
|
|
gboolean use_gradient = PAINTBRUSH_DEFAULT_USE_GRADIENT;
|
|
|
|
gboolean use_fade = PAINTBRUSH_DEFAULT_USE_FADE;
|
2000-02-08 04:35:13 +08:00
|
|
|
gdouble gradient_length = PAINTBRUSH_DEFAULT_GRADIENT_LENGTH;
|
|
|
|
gint gradient_type = PAINTBRUSH_DEFAULT_GRADIENT_TYPE;
|
|
|
|
GimpUnit fade_unit = PAINTBRUSH_DEFAULT_FADE_UNIT;
|
|
|
|
GimpUnit gradient_unit = PAINTBRUSH_DEFAULT_GRADIENT_UNIT;
|
|
|
|
gint i;
|
1999-08-20 03:53:30 +08:00
|
|
|
|
|
|
|
if (options)
|
1999-07-20 06:42:49 +08:00
|
|
|
{
|
1999-08-20 03:53:30 +08:00
|
|
|
fade_out = options->fade_out;
|
|
|
|
incremental = options->paint_options.incremental;
|
|
|
|
use_gradient = options->use_gradient;
|
1999-07-20 06:42:49 +08:00
|
|
|
gradient_length = options->gradient_length;
|
1999-08-20 03:53:30 +08:00
|
|
|
gradient_type = options->gradient_type;
|
1999-10-01 06:12:58 +08:00
|
|
|
use_fade = options->use_fade;
|
|
|
|
fade_unit = options->fade_unit;
|
|
|
|
gradient_unit = options->gradient_unit;
|
1999-07-20 06:42:49 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
if (use_gradient == FALSE)
|
1999-08-20 03:53:30 +08:00
|
|
|
gradient_length = 0.0;
|
1999-07-20 06:42:49 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
if (use_fade == FALSE)
|
1999-10-01 06:12:58 +08:00
|
|
|
fade_out = 0.0;
|
|
|
|
|
1999-07-20 06:42:49 +08:00
|
|
|
/* Hmmm... PDB paintbrush should have gradient type added to it!*/
|
|
|
|
/* thats why the code below is duplicated.
|
|
|
|
*/
|
|
|
|
if (paint_core_init (&non_gui_paint_core, drawable,
|
1999-08-20 03:53:30 +08:00
|
|
|
stroke_array[0], stroke_array[1]))
|
1999-07-20 06:42:49 +08:00
|
|
|
{
|
1999-08-20 03:53:30 +08:00
|
|
|
non_gui_fade_out = fade_out;
|
1999-07-20 06:42:49 +08:00
|
|
|
non_gui_gradient_length = gradient_length;
|
1999-08-20 03:53:30 +08:00
|
|
|
non_gui_gradient_type = gradient_type;
|
|
|
|
non_gui_incremental = incremental;
|
1999-10-01 06:12:58 +08:00
|
|
|
non_gui_fade_unit = fade_unit;
|
|
|
|
non_gui_gradient_unit = gradient_unit;
|
1999-07-20 06:42:49 +08:00
|
|
|
|
|
|
|
/* Set the paint core's paint func */
|
|
|
|
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;
|
|
|
|
|
|
|
|
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
|
|
|
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
|
|
|
|
|
1999-09-02 08:17:25 +08:00
|
|
|
non_gui_paint_core.flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH;
|
|
|
|
|
1999-07-23 07:11:46 +08:00
|
|
|
paintbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
|
1999-07-20 06:42:49 +08:00
|
|
|
|
|
|
|
for (i = 1; i < num_strokes; i++)
|
|
|
|
{
|
|
|
|
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
|
|
|
|
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
|
|
|
|
|
|
|
|
paint_core_interpolate (&non_gui_paint_core, drawable);
|
|
|
|
|
|
|
|
non_gui_paint_core.lastx = non_gui_paint_core.curx;
|
|
|
|
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finish the painting */
|
|
|
|
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
|
|
|
|
|
|
|
/* Cleanup */
|
|
|
|
paint_core_cleanup ();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-04-19 05:22:41 +08:00
|
|
|
gboolean
|
|
|
|
paintbrush_non_gui (GimpDrawable *drawable,
|
1999-07-07 02:13:59 +08:00
|
|
|
int num_strokes,
|
|
|
|
double *stroke_array,
|
|
|
|
double fade_out,
|
|
|
|
int method,
|
|
|
|
double gradient_length)
|
1999-03-17 13:40:16 +08:00
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
int i;
|
|
|
|
|
1999-07-20 06:42:49 +08:00
|
|
|
/* Code duplicated above */
|
1999-04-19 05:22:41 +08:00
|
|
|
if (paint_core_init (&non_gui_paint_core, drawable,
|
1999-04-23 14:07:09 +08:00
|
|
|
stroke_array[0], stroke_array[1]))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-08-20 03:53:30 +08:00
|
|
|
non_gui_fade_out = fade_out;
|
1999-04-19 05:22:41 +08:00
|
|
|
non_gui_gradient_length = gradient_length;
|
1999-08-20 03:53:30 +08:00
|
|
|
non_gui_gradient_type = LOOP_TRIANGLE;
|
|
|
|
non_gui_incremental = method;
|
1999-04-21 07:03:31 +08:00
|
|
|
|
1999-04-19 05:22:41 +08:00
|
|
|
/* Set the paint core's paint func */
|
1999-03-17 13:40:16 +08:00
|
|
|
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;
|
|
|
|
|
|
|
|
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
|
|
|
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
|
|
|
|
|
1999-09-02 08:17:25 +08:00
|
|
|
non_gui_paint_core.flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH;
|
|
|
|
|
1999-03-17 13:40:16 +08:00
|
|
|
if (num_strokes == 1)
|
1999-04-23 14:07:09 +08:00
|
|
|
paintbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
|
1999-03-17 13:40:16 +08:00
|
|
|
|
|
|
|
for (i = 1; i < num_strokes; i++)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
|
|
|
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
|
|
|
|
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
|
1999-03-17 13:40:16 +08:00
|
|
|
|
1999-04-23 14:07:09 +08:00
|
|
|
paint_core_interpolate (&non_gui_paint_core, drawable);
|
1999-03-17 13:40:16 +08:00
|
|
|
|
1999-04-23 14:07:09 +08:00
|
|
|
non_gui_paint_core.lastx = non_gui_paint_core.curx;
|
|
|
|
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
|
|
|
}
|
1999-03-17 13:40:16 +08:00
|
|
|
|
1999-04-19 05:22:41 +08:00
|
|
|
/* Finish the painting */
|
1999-03-17 13:40:16 +08:00
|
|
|
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
|
|
|
|
1999-04-19 05:22:41 +08:00
|
|
|
/* Cleanup */
|
1999-03-17 13:40:16 +08:00
|
|
|
paint_core_cleanup ();
|
1999-04-19 05:22:41 +08:00
|
|
|
return TRUE;
|
1999-03-17 13:40:16 +08:00
|
|
|
}
|
1999-04-19 05:22:41 +08:00
|
|
|
else
|
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|