2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2002-02-21 16:02:30 +00:00
|
|
|
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2002-02-21 16:02:30 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2002-02-21 16:02:30 +00:00
|
|
|
* (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
|
2009-01-17 22:28:01 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2002-02-21 16:02:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-09 20:24:04 +00:00
|
|
|
#include <gegl.h>
|
2002-02-21 16:02:30 +00:00
|
|
|
|
2003-07-16 11:25:37 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2007-04-09 11:54:44 +00:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2005-01-25 19:11:26 +00:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2003-07-16 11:25:37 +00:00
|
|
|
|
2002-02-21 16:02:30 +00:00
|
|
|
#include "paint-types.h"
|
|
|
|
|
2003-02-05 14:39:40 +00:00
|
|
|
#include "core/gimp.h"
|
2003-07-16 11:25:37 +00:00
|
|
|
#include "core/gimpimage.h"
|
2003-07-22 14:24:11 +00:00
|
|
|
#include "core/gimpgradient.h"
|
2004-08-31 13:20:57 +00:00
|
|
|
#include "core/gimppaintinfo.h"
|
2002-11-27 22:55:03 +00:00
|
|
|
|
2002-02-21 16:02:30 +00:00
|
|
|
#include "gimppaintoptions.h"
|
|
|
|
|
2009-03-19 20:40:43 +00:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
2002-02-21 16:02:30 +00:00
|
|
|
|
2009-02-08 12:55:20 +00:00
|
|
|
#define DEFAULT_BRUSH_SCALE 1.0
|
2009-04-25 17:53:09 +00:00
|
|
|
#define DEFAULT_BRUSH_ASPECT_RATIO 1.0
|
2009-02-08 12:55:20 +00:00
|
|
|
#define DEFAULT_BRUSH_ANGLE 0.0
|
|
|
|
|
|
|
|
#define DEFAULT_APPLICATION_MODE GIMP_PAINT_CONSTANT
|
|
|
|
#define DEFAULT_HARD FALSE
|
|
|
|
|
|
|
|
#define DEFAULT_USE_FADE FALSE
|
|
|
|
#define DEFAULT_FADE_LENGTH 100.0
|
|
|
|
#define DEFAULT_FADE_UNIT GIMP_UNIT_PIXEL
|
|
|
|
|
|
|
|
#define DEFAULT_USE_JITTER FALSE
|
|
|
|
#define DEFAULT_JITTER_AMOUNT 0.2
|
|
|
|
|
|
|
|
#define DEFAULT_USE_GRADIENT FALSE
|
|
|
|
#define DEFAULT_GRADIENT_REVERSE FALSE
|
|
|
|
#define DEFAULT_GRADIENT_REPEAT GIMP_REPEAT_TRIANGULAR
|
|
|
|
#define DEFAULT_GRADIENT_LENGTH 100.0
|
|
|
|
#define DEFAULT_GRADIENT_UNIT GIMP_UNIT_PIXEL
|
2002-02-21 16:02:30 +00:00
|
|
|
|
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2008-04-25 10:52:01 +00:00
|
|
|
|
2004-08-31 13:20:57 +00:00
|
|
|
PROP_PAINT_INFO,
|
2009-02-05 21:47:57 +00:00
|
|
|
|
2006-11-16 15:11:27 +00:00
|
|
|
PROP_BRUSH_SCALE,
|
2009-04-25 17:53:09 +00:00
|
|
|
PROP_BRUSH_ASPECT_RATIO,
|
2009-02-05 21:47:57 +00:00
|
|
|
PROP_BRUSH_ANGLE,
|
|
|
|
|
2003-03-24 17:58:28 +00:00
|
|
|
PROP_APPLICATION_MODE,
|
2003-07-14 14:50:41 +00:00
|
|
|
PROP_HARD,
|
2008-04-25 10:52:01 +00:00
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
PROP_USE_FADE,
|
|
|
|
PROP_FADE_LENGTH,
|
|
|
|
PROP_FADE_UNIT,
|
2008-04-25 10:52:01 +00:00
|
|
|
|
|
|
|
PROP_USE_JITTER,
|
|
|
|
PROP_JITTER_AMOUNT,
|
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
PROP_USE_GRADIENT,
|
2003-07-22 14:24:11 +00:00
|
|
|
PROP_GRADIENT_REVERSE,
|
|
|
|
PROP_GRADIENT_REPEAT,
|
2003-02-07 17:12:21 +00:00
|
|
|
PROP_GRADIENT_LENGTH,
|
2005-10-03 19:03:14 +00:00
|
|
|
PROP_GRADIENT_UNIT,
|
2006-01-14 00:09:22 +00:00
|
|
|
|
|
|
|
PROP_BRUSH_VIEW_TYPE,
|
|
|
|
PROP_BRUSH_VIEW_SIZE,
|
|
|
|
PROP_PATTERN_VIEW_TYPE,
|
|
|
|
PROP_PATTERN_VIEW_SIZE,
|
|
|
|
PROP_GRADIENT_VIEW_TYPE,
|
|
|
|
PROP_GRADIENT_VIEW_SIZE
|
2003-02-07 17:12:21 +00:00
|
|
|
};
|
2002-02-21 16:02:30 +00:00
|
|
|
|
|
|
|
|
2008-05-22 16:38:57 +00:00
|
|
|
static void gimp_paint_options_finalize (GObject *object);
|
|
|
|
static void gimp_paint_options_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_paint_options_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_paint_options_notify (GObject *object,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
2003-02-05 14:39:40 +00:00
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
|
2007-07-17 10:04:06 +00:00
|
|
|
G_DEFINE_TYPE (GimpPaintOptions, gimp_paint_options, GIMP_TYPE_TOOL_OPTIONS)
|
2003-02-07 17:12:21 +00:00
|
|
|
|
2005-12-07 21:11:53 +00:00
|
|
|
#define parent_class gimp_paint_options_parent_class
|
2002-02-21 16:02:30 +00:00
|
|
|
|
|
|
|
|
2003-07-14 14:50:41 +00:00
|
|
|
static void
|
2003-02-05 14:39:40 +00:00
|
|
|
gimp_paint_options_class_init (GimpPaintOptionsClass *klass)
|
2002-02-21 16:02:30 +00:00
|
|
|
{
|
2004-09-24 12:01:35 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2003-02-07 17:12:21 +00:00
|
|
|
|
2003-07-15 15:38:24 +00:00
|
|
|
object_class->finalize = gimp_paint_options_finalize;
|
2003-02-07 17:12:21 +00:00
|
|
|
object_class->set_property = gimp_paint_options_set_property;
|
|
|
|
object_class->get_property = gimp_paint_options_get_property;
|
|
|
|
object_class->notify = gimp_paint_options_notify;
|
|
|
|
|
2004-08-31 13:20:57 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_PAINT_INFO,
|
|
|
|
g_param_spec_object ("paint-info",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_PAINT_INFO,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_READWRITE |
|
2004-08-31 13:20:57 +00:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2006-11-16 15:11:27 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_BRUSH_SCALE,
|
2009-03-19 20:40:43 +00:00
|
|
|
"brush-scale", _("Brush Scale"),
|
2007-03-14 08:07:21 +00:00
|
|
|
0.01, 10.0, DEFAULT_BRUSH_SCALE,
|
2006-11-16 15:11:27 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2009-04-25 17:53:09 +00:00
|
|
|
|
|
|
|
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_BRUSH_ASPECT_RATIO,
|
2009-04-27 09:01:11 +00:00
|
|
|
"brush-aspect-ratio", _("Brush Aspect Ratio"),
|
2009-04-25 17:53:09 +00:00
|
|
|
0.01, 10.0, DEFAULT_BRUSH_ASPECT_RATIO,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2009-02-05 21:47:57 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_BRUSH_ANGLE,
|
2009-03-19 20:40:43 +00:00
|
|
|
"brush-angle", _("Brush Angle"),
|
2009-02-05 21:47:57 +00:00
|
|
|
-180.0, 180.0, DEFAULT_BRUSH_ANGLE,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
|
|
|
|
2003-03-24 17:58:28 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_APPLICATION_MODE,
|
|
|
|
"application-mode", NULL,
|
|
|
|
GIMP_TYPE_PAINT_APPLICATION_MODE,
|
|
|
|
DEFAULT_APPLICATION_MODE,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-07-14 14:50:41 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_HARD,
|
|
|
|
"hard", NULL,
|
|
|
|
DEFAULT_HARD,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-07 17:12:21 +00:00
|
|
|
|
|
|
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_USE_FADE,
|
|
|
|
"use-fade", NULL,
|
|
|
|
DEFAULT_USE_FADE,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-07 17:12:21 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_FADE_LENGTH,
|
|
|
|
"fade-length", NULL,
|
2003-04-13 13:55:09 +00:00
|
|
|
0.0, 32767.0, DEFAULT_FADE_LENGTH,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-07 17:12:21 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_UNIT (object_class, PROP_FADE_UNIT,
|
|
|
|
"fade-unit", NULL,
|
2003-07-17 15:22:21 +00:00
|
|
|
TRUE, TRUE, DEFAULT_FADE_UNIT,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-07 17:12:21 +00:00
|
|
|
|
2005-10-03 19:03:14 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_USE_JITTER,
|
|
|
|
"use-jitter", NULL,
|
|
|
|
DEFAULT_USE_JITTER,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2005-10-03 19:03:14 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_JITTER_AMOUNT,
|
|
|
|
"jitter-amount", NULL,
|
|
|
|
0.0, 50.0, DEFAULT_JITTER_AMOUNT,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-07 17:12:21 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_USE_GRADIENT,
|
|
|
|
"use-gradient", NULL,
|
2006-01-18 20:29:40 +00:00
|
|
|
DEFAULT_USE_GRADIENT,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-07-22 14:24:11 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_GRADIENT_REVERSE,
|
|
|
|
"gradient-reverse", NULL,
|
2006-01-18 20:29:40 +00:00
|
|
|
DEFAULT_GRADIENT_REVERSE,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-07-22 14:24:11 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_GRADIENT_REPEAT,
|
|
|
|
"gradient-repeat", NULL,
|
|
|
|
GIMP_TYPE_REPEAT_MODE,
|
|
|
|
DEFAULT_GRADIENT_REPEAT,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-07 17:12:21 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_GRADIENT_LENGTH,
|
|
|
|
"gradient-length", NULL,
|
2003-04-13 13:55:09 +00:00
|
|
|
0.0, 32767.0, DEFAULT_GRADIENT_LENGTH,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-07 17:12:21 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_UNIT (object_class, PROP_GRADIENT_UNIT,
|
|
|
|
"gradient-unit", NULL,
|
2003-07-17 15:22:21 +00:00
|
|
|
TRUE, TRUE, DEFAULT_GRADIENT_UNIT,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2006-01-14 00:09:22 +00:00
|
|
|
|
|
|
|
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_BRUSH_VIEW_TYPE,
|
|
|
|
"brush-view-type", NULL,
|
|
|
|
GIMP_TYPE_VIEW_TYPE,
|
|
|
|
GIMP_VIEW_TYPE_GRID,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2006-01-14 00:09:22 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_BRUSH_VIEW_SIZE,
|
|
|
|
"brush-view-size", NULL,
|
|
|
|
GIMP_VIEW_SIZE_TINY,
|
|
|
|
GIMP_VIEWABLE_MAX_BUTTON_SIZE,
|
|
|
|
GIMP_VIEW_SIZE_SMALL,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2006-01-14 00:09:22 +00:00
|
|
|
|
|
|
|
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_PATTERN_VIEW_TYPE,
|
|
|
|
"pattern-view-type", NULL,
|
|
|
|
GIMP_TYPE_VIEW_TYPE,
|
|
|
|
GIMP_VIEW_TYPE_GRID,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2006-01-14 00:09:22 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_PATTERN_VIEW_SIZE,
|
|
|
|
"pattern-view-size", NULL,
|
|
|
|
GIMP_VIEW_SIZE_TINY,
|
|
|
|
GIMP_VIEWABLE_MAX_BUTTON_SIZE,
|
|
|
|
GIMP_VIEW_SIZE_SMALL,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2006-01-14 00:09:22 +00:00
|
|
|
|
|
|
|
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_GRADIENT_VIEW_TYPE,
|
|
|
|
"gradient-view-type", NULL,
|
|
|
|
GIMP_TYPE_VIEW_TYPE,
|
|
|
|
GIMP_VIEW_TYPE_LIST,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2006-01-14 00:09:22 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_GRADIENT_VIEW_SIZE,
|
|
|
|
"gradient-view-size", NULL,
|
|
|
|
GIMP_VIEW_SIZE_TINY,
|
|
|
|
GIMP_VIEWABLE_MAX_BUTTON_SIZE,
|
|
|
|
GIMP_VIEW_SIZE_LARGE,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-05 14:39:40 +00:00
|
|
|
}
|
2002-02-21 16:02:30 +00:00
|
|
|
|
2003-02-05 14:39:40 +00:00
|
|
|
static void
|
|
|
|
gimp_paint_options_init (GimpPaintOptions *options)
|
|
|
|
{
|
2003-03-24 17:58:28 +00:00
|
|
|
options->application_mode_save = DEFAULT_APPLICATION_MODE;
|
2002-02-21 16:02:30 +00:00
|
|
|
|
2009-02-08 12:55:20 +00:00
|
|
|
options->fade_options = g_slice_new0 (GimpFadeOptions);
|
|
|
|
options->jitter_options = g_slice_new0 (GimpJitterOptions);
|
|
|
|
options->gradient_options = g_slice_new0 (GimpGradientOptions);
|
2002-02-21 16:02:30 +00:00
|
|
|
}
|
|
|
|
|
2003-07-15 15:38:24 +00:00
|
|
|
static void
|
|
|
|
gimp_paint_options_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpPaintOptions *options = GIMP_PAINT_OPTIONS (object);
|
|
|
|
|
2004-08-31 13:20:57 +00:00
|
|
|
if (options->paint_info)
|
|
|
|
g_object_unref (options->paint_info);
|
|
|
|
|
2007-05-23 13:49:06 +00:00
|
|
|
g_slice_free (GimpFadeOptions, options->fade_options);
|
|
|
|
g_slice_free (GimpJitterOptions, options->jitter_options);
|
2008-04-25 10:52:01 +00:00
|
|
|
g_slice_free (GimpGradientOptions, options->gradient_options);
|
2003-07-15 15:38:24 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
static void
|
|
|
|
gimp_paint_options_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2003-02-05 14:39:40 +00:00
|
|
|
{
|
2009-02-08 12:55:20 +00:00
|
|
|
GimpPaintOptions *options = GIMP_PAINT_OPTIONS (object);
|
|
|
|
GimpFadeOptions *fade_options = options->fade_options;
|
|
|
|
GimpJitterOptions *jitter_options = options->jitter_options;
|
|
|
|
GimpGradientOptions *gradient_options = options->gradient_options;
|
2003-02-05 14:39:40 +00:00
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
switch (property_id)
|
|
|
|
{
|
2004-08-31 13:20:57 +00:00
|
|
|
case PROP_PAINT_INFO:
|
2008-07-23 06:47:23 +00:00
|
|
|
options->paint_info = g_value_dup_object (value);
|
2004-08-31 13:20:57 +00:00
|
|
|
break;
|
|
|
|
|
2006-11-16 15:11:27 +00:00
|
|
|
case PROP_BRUSH_SCALE:
|
|
|
|
options->brush_scale = g_value_get_double (value);
|
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2009-04-25 17:53:09 +00:00
|
|
|
case PROP_BRUSH_ASPECT_RATIO:
|
|
|
|
options->brush_aspect_ratio = g_value_get_double (value);
|
|
|
|
break;
|
|
|
|
|
2009-02-05 21:47:57 +00:00
|
|
|
case PROP_BRUSH_ANGLE:
|
2009-02-10 21:07:35 +00:00
|
|
|
options->brush_angle = - 1.0 * g_value_get_double (value) / 360.0; /* let's make the angle mathematically correct */
|
2009-02-05 21:47:57 +00:00
|
|
|
break;
|
|
|
|
|
2003-03-24 17:58:28 +00:00
|
|
|
case PROP_APPLICATION_MODE:
|
|
|
|
options->application_mode = g_value_get_enum (value);
|
2003-02-07 17:12:21 +00:00
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2003-07-14 14:50:41 +00:00
|
|
|
case PROP_HARD:
|
|
|
|
options->hard = g_value_get_boolean (value);
|
|
|
|
break;
|
2003-02-07 17:12:21 +00:00
|
|
|
|
|
|
|
case PROP_USE_FADE:
|
2003-07-15 15:38:24 +00:00
|
|
|
fade_options->use_fade = g_value_get_boolean (value);
|
2003-02-07 17:12:21 +00:00
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
case PROP_FADE_LENGTH:
|
2003-07-15 15:38:24 +00:00
|
|
|
fade_options->fade_length = g_value_get_double (value);
|
2003-02-07 17:12:21 +00:00
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
case PROP_FADE_UNIT:
|
2003-07-15 15:38:24 +00:00
|
|
|
fade_options->fade_unit = g_value_get_int (value);
|
2003-02-07 17:12:21 +00:00
|
|
|
break;
|
|
|
|
|
2005-10-03 19:03:14 +00:00
|
|
|
case PROP_USE_JITTER:
|
|
|
|
jitter_options->use_jitter = g_value_get_boolean (value);
|
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2005-10-03 19:03:14 +00:00
|
|
|
case PROP_JITTER_AMOUNT:
|
|
|
|
jitter_options->jitter_amount = g_value_get_double (value);
|
|
|
|
break;
|
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
case PROP_USE_GRADIENT:
|
|
|
|
gradient_options->use_gradient = g_value_get_boolean (value);
|
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2003-07-22 14:24:11 +00:00
|
|
|
case PROP_GRADIENT_REVERSE:
|
|
|
|
gradient_options->gradient_reverse = g_value_get_boolean (value);
|
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2003-07-22 14:24:11 +00:00
|
|
|
case PROP_GRADIENT_REPEAT:
|
|
|
|
gradient_options->gradient_repeat = g_value_get_enum (value);
|
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
case PROP_GRADIENT_LENGTH:
|
|
|
|
gradient_options->gradient_length = g_value_get_double (value);
|
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
case PROP_GRADIENT_UNIT:
|
|
|
|
gradient_options->gradient_unit = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
|
2006-01-14 00:09:22 +00:00
|
|
|
case PROP_BRUSH_VIEW_TYPE:
|
|
|
|
options->brush_view_type = g_value_get_enum (value);
|
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2006-01-14 00:09:22 +00:00
|
|
|
case PROP_BRUSH_VIEW_SIZE:
|
|
|
|
options->brush_view_size = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_PATTERN_VIEW_TYPE:
|
|
|
|
options->pattern_view_type = g_value_get_enum (value);
|
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2006-01-14 00:09:22 +00:00
|
|
|
case PROP_PATTERN_VIEW_SIZE:
|
|
|
|
options->pattern_view_size = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_GRADIENT_VIEW_TYPE:
|
|
|
|
options->gradient_view_type = g_value_get_enum (value);
|
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2006-01-14 00:09:22 +00:00
|
|
|
case PROP_GRADIENT_VIEW_SIZE:
|
|
|
|
options->gradient_view_size = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2003-02-05 14:39:40 +00:00
|
|
|
}
|
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
static void
|
|
|
|
gimp_paint_options_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2009-02-08 12:55:20 +00:00
|
|
|
GimpPaintOptions *options = GIMP_PAINT_OPTIONS (object);
|
|
|
|
GimpFadeOptions *fade_options = options->fade_options;
|
|
|
|
GimpJitterOptions *jitter_options = options->jitter_options;
|
|
|
|
GimpGradientOptions *gradient_options = options->gradient_options;
|
2002-02-21 16:02:30 +00:00
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
switch (property_id)
|
|
|
|
{
|
2004-08-31 13:20:57 +00:00
|
|
|
case PROP_PAINT_INFO:
|
|
|
|
g_value_set_object (value, options->paint_info);
|
|
|
|
break;
|
|
|
|
|
2006-11-16 15:11:27 +00:00
|
|
|
case PROP_BRUSH_SCALE:
|
|
|
|
g_value_set_double (value, options->brush_scale);
|
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2009-04-25 17:53:09 +00:00
|
|
|
case PROP_BRUSH_ASPECT_RATIO:
|
|
|
|
g_value_set_double (value, options->brush_aspect_ratio);
|
|
|
|
break;
|
|
|
|
|
2009-02-05 21:47:57 +00:00
|
|
|
case PROP_BRUSH_ANGLE:
|
2009-02-10 21:07:35 +00:00
|
|
|
g_value_set_double (value, - 1.0 * options->brush_angle * 360.0); /* mathematically correct -> intuitively correct */
|
2009-02-05 21:47:57 +00:00
|
|
|
break;
|
|
|
|
|
2003-03-24 17:58:28 +00:00
|
|
|
case PROP_APPLICATION_MODE:
|
|
|
|
g_value_set_enum (value, options->application_mode);
|
2003-02-07 17:12:21 +00:00
|
|
|
break;
|
2008-07-23 06:47:23 +00:00
|
|
|
|
2003-07-14 14:50:41 +00:00
|
|
|
case PROP_HARD:
|
|
|
|
g_value_set_boolean (value, options->hard);
|
|
|
|
break;
|
2009-07-22 17:55:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
case PROP_USE_FADE:
|
|
|
|
g_value_set_boolean (value, fade_options->use_fade);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_FADE_LENGTH:
|
|
|
|
g_value_set_double (value, fade_options->fade_length);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_FADE_UNIT:
|
|
|
|
g_value_set_int (value, fade_options->fade_unit);
|
|
|
|
break;
|
|
|
|
|
2009-07-22 17:43:37 +00:00
|
|
|
case PROP_USE_JITTER:
|
2009-07-22 17:55:34 +00:00
|
|
|
g_value_set_boolean (value, jitter_options->use_jitter);
|
2009-07-22 17:43:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_JITTER_AMOUNT:
|
2009-07-22 17:55:34 +00:00
|
|
|
g_value_set_double (value, jitter_options->jitter_amount);
|
2009-07-22 17:43:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_USE_GRADIENT:
|
2009-07-22 17:55:34 +00:00
|
|
|
g_value_set_boolean (value, gradient_options->use_gradient);
|
2009-07-22 17:43:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_GRADIENT_REVERSE:
|
2009-07-22 17:55:34 +00:00
|
|
|
g_value_set_boolean (value, gradient_options->gradient_reverse);
|
2009-07-22 17:43:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_GRADIENT_REPEAT:
|
2009-07-22 17:55:34 +00:00
|
|
|
g_value_set_enum (value, gradient_options->gradient_repeat);
|
2009-07-22 17:43:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_GRADIENT_LENGTH:
|
2009-07-22 17:55:34 +00:00
|
|
|
g_value_set_double (value, gradient_options->gradient_length);
|
2009-07-22 17:43:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_GRADIENT_UNIT:
|
2009-07-22 17:55:34 +00:00
|
|
|
g_value_set_int (value, gradient_options->gradient_unit);
|
2009-07-22 17:43:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_BRUSH_VIEW_TYPE:
|
2009-07-22 17:55:34 +00:00
|
|
|
g_value_set_enum (value, options->brush_view_type);
|
2009-07-22 17:43:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_BRUSH_VIEW_SIZE:
|
2009-07-22 17:55:34 +00:00
|
|
|
g_value_set_int (value, options->brush_view_size);
|
2009-07-22 17:43:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_PATTERN_VIEW_TYPE:
|
2009-07-22 17:55:34 +00:00
|
|
|
g_value_set_enum (value, options->pattern_view_type);
|
2009-07-22 17:43:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_PATTERN_VIEW_SIZE:
|
2009-07-22 17:55:34 +00:00
|
|
|
g_value_set_int (value, options->pattern_view_size);
|
2009-07-22 17:43:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_GRADIENT_VIEW_TYPE:
|
2009-07-22 17:55:34 +00:00
|
|
|
g_value_set_enum (value, options->gradient_view_type);
|
2009-07-22 17:43:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_GRADIENT_VIEW_SIZE:
|
2009-07-22 17:55:34 +00:00
|
|
|
g_value_set_int (value, options->gradient_view_size);
|
2009-07-22 17:43:37 +00:00
|
|
|
break;
|
2003-02-07 17:12:21 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_paint_options_notify (GObject *object,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2004-09-24 12:01:35 +00:00
|
|
|
GimpPaintOptions *options = GIMP_PAINT_OPTIONS (object);
|
2002-02-21 16:02:30 +00:00
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
if (pspec->param_id == PROP_USE_GRADIENT)
|
|
|
|
{
|
|
|
|
if (options->gradient_options->use_gradient)
|
|
|
|
{
|
2003-03-24 17:58:28 +00:00
|
|
|
options->application_mode_save = options->application_mode;
|
|
|
|
options->application_mode = GIMP_PAINT_INCREMENTAL;
|
2003-02-07 17:12:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-03-24 17:58:28 +00:00
|
|
|
options->application_mode = options->application_mode_save;
|
2003-02-07 17:12:21 +00:00
|
|
|
}
|
|
|
|
|
2003-03-24 17:58:28 +00:00
|
|
|
g_object_notify (object, "application-mode");
|
2003-02-07 17:12:21 +00:00
|
|
|
}
|
2002-02-21 16:02:30 +00:00
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
if (G_OBJECT_CLASS (parent_class)->notify)
|
|
|
|
G_OBJECT_CLASS (parent_class)->notify (object, pspec);
|
2002-02-21 16:02:30 +00:00
|
|
|
}
|
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
GimpPaintOptions *
|
2004-08-31 13:20:57 +00:00
|
|
|
gimp_paint_options_new (GimpPaintInfo *paint_info)
|
2002-02-21 16:02:30 +00:00
|
|
|
{
|
2003-02-07 17:12:21 +00:00
|
|
|
GimpPaintOptions *options;
|
|
|
|
|
2004-08-31 13:20:57 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_PAINT_INFO (paint_info), NULL);
|
2003-02-07 17:12:21 +00:00
|
|
|
|
2004-08-31 13:20:57 +00:00
|
|
|
options = g_object_new (paint_info->paint_options_type,
|
|
|
|
"gimp", paint_info->gimp,
|
2009-08-29 10:40:40 +00:00
|
|
|
"name", gimp_object_get_name (paint_info),
|
2004-08-31 13:20:57 +00:00
|
|
|
"paint-info", paint_info,
|
2003-02-07 17:12:21 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
return options;
|
2002-02-21 16:02:30 +00:00
|
|
|
}
|
2003-07-14 14:50:41 +00:00
|
|
|
|
2003-07-16 11:25:37 +00:00
|
|
|
gdouble
|
|
|
|
gimp_paint_options_get_fade (GimpPaintOptions *paint_options,
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image,
|
2003-07-16 11:25:37 +00:00
|
|
|
gdouble pixel_dist)
|
|
|
|
{
|
|
|
|
GimpFadeOptions *fade_options;
|
2009-07-02 17:45:32 +00:00
|
|
|
gdouble z = -1.0;
|
|
|
|
|
2003-07-16 11:25:37 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options),
|
|
|
|
GIMP_OPACITY_OPAQUE);
|
2006-03-28 17:08:36 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), GIMP_OPACITY_OPAQUE);
|
2003-07-16 11:25:37 +00:00
|
|
|
|
|
|
|
fade_options = paint_options->fade_options;
|
|
|
|
|
|
|
|
if (fade_options->use_fade)
|
|
|
|
{
|
|
|
|
gdouble fade_out = 0.0;
|
|
|
|
gdouble unit_factor;
|
|
|
|
|
|
|
|
switch (fade_options->fade_unit)
|
|
|
|
{
|
|
|
|
case GIMP_UNIT_PIXEL:
|
|
|
|
fade_out = fade_options->fade_length;
|
|
|
|
break;
|
|
|
|
case GIMP_UNIT_PERCENT:
|
2007-12-25 16:21:40 +00:00
|
|
|
fade_out = (MAX (gimp_image_get_width (image),
|
|
|
|
gimp_image_get_height (image)) *
|
2003-07-16 11:25:37 +00:00
|
|
|
fade_options->fade_length / 100);
|
|
|
|
break;
|
|
|
|
default:
|
2007-12-26 17:33:41 +00:00
|
|
|
{
|
|
|
|
gdouble xres;
|
|
|
|
gdouble yres;
|
|
|
|
|
|
|
|
gimp_image_get_resolution (image, &xres, &yres);
|
|
|
|
|
|
|
|
unit_factor = gimp_unit_get_factor (fade_options->fade_unit);
|
|
|
|
fade_out = (fade_options->fade_length *
|
|
|
|
MAX (xres, yres) / unit_factor);
|
|
|
|
}
|
2003-07-16 11:25:37 +00:00
|
|
|
break;
|
2009-07-02 17:45:32 +00:00
|
|
|
}
|
2009-07-21 19:27:29 +00:00
|
|
|
|
2003-07-16 11:25:37 +00:00
|
|
|
/* factor in the fade out value */
|
|
|
|
if (fade_out > 0.0)
|
|
|
|
{
|
|
|
|
gdouble x;
|
|
|
|
|
|
|
|
/* Model the amount of paint left as a gaussian curve */
|
|
|
|
x = pixel_dist / fade_out;
|
2009-07-05 18:03:34 +00:00
|
|
|
z = exp (- x * x * 5.541);
|
2009-07-02 17:45:32 +00:00
|
|
|
return z; /* ln (1/255) */
|
2003-07-16 11:25:37 +00:00
|
|
|
|
|
|
|
}
|
2009-07-21 19:27:29 +00:00
|
|
|
|
2003-07-16 11:25:37 +00:00
|
|
|
return GIMP_OPACITY_TRANSPARENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GIMP_OPACITY_OPAQUE;
|
|
|
|
}
|
|
|
|
|
2005-10-03 19:03:14 +00:00
|
|
|
gdouble
|
|
|
|
gimp_paint_options_get_jitter (GimpPaintOptions *paint_options,
|
2006-04-12 12:49:29 +00:00
|
|
|
GimpImage *image)
|
2005-10-03 19:03:14 +00:00
|
|
|
{
|
|
|
|
GimpJitterOptions *jitter_options;
|
|
|
|
|
2008-04-25 13:39:36 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), 0.0);
|
|
|
|
|
2005-10-03 19:03:14 +00:00
|
|
|
jitter_options = paint_options->jitter_options;
|
|
|
|
|
|
|
|
if (jitter_options->use_jitter)
|
|
|
|
return jitter_options->jitter_amount;
|
|
|
|
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2003-07-22 14:24:11 +00:00
|
|
|
gboolean
|
|
|
|
gimp_paint_options_get_gradient_color (GimpPaintOptions *paint_options,
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image,
|
2008-05-10 10:03:21 +00:00
|
|
|
gdouble grad_point,
|
2003-07-22 14:24:11 +00:00
|
|
|
gdouble pixel_dist,
|
|
|
|
GimpRGB *color)
|
|
|
|
{
|
|
|
|
GimpGradientOptions *gradient_options;
|
|
|
|
GimpGradient *gradient;
|
2009-10-03 13:54:10 +00:00
|
|
|
GimpDynamics *dynamics;
|
2003-07-22 14:24:11 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), FALSE);
|
2006-03-28 17:08:36 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
|
2003-07-22 14:24:11 +00:00
|
|
|
g_return_val_if_fail (color != NULL, FALSE);
|
|
|
|
|
|
|
|
gradient_options = paint_options->gradient_options;
|
|
|
|
|
|
|
|
gradient = gimp_context_get_gradient (GIMP_CONTEXT (paint_options));
|
2009-10-03 13:54:10 +00:00
|
|
|
|
|
|
|
dynamics = gimp_context_get_dynamics (GIMP_CONTEXT (paint_options));
|
|
|
|
|
|
|
|
if (gimp_dynamics_output_get_enabled(dynamics->color_dynamics))
|
2003-07-22 14:24:11 +00:00
|
|
|
{
|
2006-08-29 21:44:51 +00:00
|
|
|
gimp_gradient_get_color_at (gradient, GIMP_CONTEXT (paint_options),
|
2008-05-10 10:03:21 +00:00
|
|
|
NULL, grad_point,
|
2003-07-22 14:24:11 +00:00
|
|
|
gradient_options->gradient_reverse,
|
|
|
|
color);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2009-10-03 13:54:10 +00:00
|
|
|
else if (gradient_options->use_gradient)
|
2003-07-22 14:24:11 +00:00
|
|
|
{
|
|
|
|
gdouble gradient_length = 0.0;
|
|
|
|
gdouble unit_factor;
|
|
|
|
gdouble pos;
|
|
|
|
|
|
|
|
switch (gradient_options->gradient_unit)
|
|
|
|
{
|
|
|
|
case GIMP_UNIT_PIXEL:
|
|
|
|
gradient_length = gradient_options->gradient_length;
|
|
|
|
break;
|
|
|
|
case GIMP_UNIT_PERCENT:
|
2007-12-25 16:21:40 +00:00
|
|
|
gradient_length = (MAX (gimp_image_get_width (image),
|
|
|
|
gimp_image_get_height (image)) *
|
2003-07-22 14:24:11 +00:00
|
|
|
gradient_options->gradient_length / 100);
|
|
|
|
break;
|
|
|
|
default:
|
2007-12-26 17:33:41 +00:00
|
|
|
{
|
|
|
|
gdouble xres;
|
|
|
|
gdouble yres;
|
|
|
|
|
|
|
|
gimp_image_get_resolution (image, &xres, &yres);
|
|
|
|
|
|
|
|
unit_factor = gimp_unit_get_factor (gradient_options->gradient_unit);
|
|
|
|
gradient_length = (gradient_options->gradient_length *
|
|
|
|
MAX (xres, yres) / unit_factor);
|
|
|
|
}
|
2003-07-22 14:24:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gradient_length > 0.0)
|
|
|
|
pos = pixel_dist / gradient_length;
|
|
|
|
else
|
|
|
|
pos = 1.0;
|
|
|
|
|
|
|
|
/* for no repeat, set pos close to 1.0 after the first chunk */
|
|
|
|
if (gradient_options->gradient_repeat == GIMP_REPEAT_NONE && pos >= 1.0)
|
|
|
|
pos = 0.9999999;
|
|
|
|
|
|
|
|
if (((gint) pos & 1) &&
|
|
|
|
gradient_options->gradient_repeat != GIMP_REPEAT_SAWTOOTH)
|
|
|
|
pos = 1.0 - (pos - (gint) pos);
|
|
|
|
else
|
|
|
|
pos = pos - (gint) pos;
|
|
|
|
|
2006-08-29 21:44:51 +00:00
|
|
|
gimp_gradient_get_color_at (gradient, GIMP_CONTEXT (paint_options),
|
|
|
|
NULL, pos,
|
2003-07-22 14:24:11 +00:00
|
|
|
gradient_options->gradient_reverse,
|
|
|
|
color);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-07-14 14:50:41 +00:00
|
|
|
GimpBrushApplicationMode
|
|
|
|
gimp_paint_options_get_brush_mode (GimpPaintOptions *paint_options)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), GIMP_BRUSH_SOFT);
|
|
|
|
|
|
|
|
if (paint_options->hard)
|
|
|
|
return GIMP_BRUSH_HARD;
|
|
|
|
|
2009-07-21 19:27:29 +00:00
|
|
|
/* if (paint_options->pressure_options->hardness ||
|
2008-05-22 16:38:57 +00:00
|
|
|
paint_options->velocity_options->hardness ||
|
|
|
|
paint_options->random_options->hardness)
|
2009-07-21 19:27:29 +00:00
|
|
|
return GIMP_BRUSH_PRESSURE;*/
|
|
|
|
|
2003-07-14 14:50:41 +00:00
|
|
|
return GIMP_BRUSH_SOFT;
|
|
|
|
}
|
2008-05-10 10:03:21 +00:00
|
|
|
|
|
|
|
|
2008-05-22 16:38:57 +00:00
|
|
|
|