mirror of https://github.com/GNOME/gimp.git
Bug 741200 - paint options spacing differs from brush spacing
Add "link" buttons to the tool options that are duplicates of brush properties, so the tool options values can be set to change along with the current brush.
This commit is contained in:
parent
20863440fb
commit
b0dbb2edf2
|
@ -73,6 +73,11 @@
|
|||
#define DEFAULT_SMOOTHING_QUALITY 20
|
||||
#define DEFAULT_SMOOTHING_FACTOR 50
|
||||
|
||||
#define DEFAULT_BRUSH_LINK_SIZE TRUE
|
||||
#define DEFAULT_BRUSH_LINK_ASPECT_RATIO TRUE
|
||||
#define DEFAULT_BRUSH_LINK_ANGLE TRUE
|
||||
#define DEFAULT_BRUSH_LINK_SPACING TRUE
|
||||
#define DEFAULT_BRUSH_LINK_HARDNESS TRUE
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -116,7 +121,13 @@ enum
|
|||
|
||||
PROP_USE_SMOOTHING,
|
||||
PROP_SMOOTHING_QUALITY,
|
||||
PROP_SMOOTHING_FACTOR
|
||||
PROP_SMOOTHING_FACTOR,
|
||||
|
||||
PROP_BRUSH_LINK_SIZE,
|
||||
PROP_BRUSH_LINK_ASPECT_RATIO,
|
||||
PROP_BRUSH_LINK_ANGLE,
|
||||
PROP_BRUSH_LINK_SPACING,
|
||||
PROP_BRUSH_LINK_HARDNESS
|
||||
};
|
||||
|
||||
|
||||
|
@ -130,6 +141,8 @@ static void gimp_paint_options_get_property (GObject *object,
|
|||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_paint_options_brush_changed (GimpContext *context,
|
||||
GimpBrush *brush);
|
||||
|
||||
|
||||
|
||||
|
@ -142,12 +155,15 @@ static void
|
|||
gimp_paint_options_class_init (GimpPaintOptionsClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpContextClass *context_class = GIMP_CONTEXT_CLASS (klass);
|
||||
|
||||
object_class->dispose = gimp_paint_options_dispose;
|
||||
object_class->finalize = gimp_paint_options_finalize;
|
||||
object_class->set_property = gimp_paint_options_set_property;
|
||||
object_class->get_property = gimp_paint_options_get_property;
|
||||
|
||||
context_class->brush_changed = gimp_paint_options_brush_changed;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_PAINT_INFO,
|
||||
g_param_spec_object ("paint-info",
|
||||
NULL, NULL,
|
||||
|
@ -197,6 +213,36 @@ gimp_paint_options_class_init (GimpPaintOptionsClass *klass)
|
|||
0.0, 1.0, DEFAULT_BRUSH_FORCE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_BRUSH_LINK_SIZE,
|
||||
"brush-link-size",
|
||||
_("Link brush size to brush native"),
|
||||
DEFAULT_BRUSH_LINK_SIZE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_BRUSH_LINK_ASPECT_RATIO,
|
||||
"brush-link-aspect-ratio",
|
||||
_("Link brush aspect ratio to brush native"),
|
||||
DEFAULT_BRUSH_LINK_ASPECT_RATIO,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_BRUSH_LINK_ANGLE,
|
||||
"brush-link-angle",
|
||||
_("Link brush angle to brush native"),
|
||||
DEFAULT_BRUSH_LINK_ANGLE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_BRUSH_LINK_SPACING,
|
||||
"brush-link-spacing",
|
||||
_("Link brush spacing to brush native"),
|
||||
DEFAULT_BRUSH_LINK_SPACING,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_BRUSH_LINK_HARDNESS,
|
||||
"brush-link-hardness",
|
||||
_("Link brush hardness to brush native"),
|
||||
DEFAULT_BRUSH_LINK_HARDNESS,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_APPLICATION_MODE,
|
||||
"application-mode", _("Every stamp has its own opacity"),
|
||||
GIMP_TYPE_PAINT_APPLICATION_MODE,
|
||||
|
@ -399,6 +445,26 @@ gimp_paint_options_set_property (GObject *object,
|
|||
options->brush_force = g_value_get_double (value);
|
||||
break;
|
||||
|
||||
case PROP_BRUSH_LINK_SIZE:
|
||||
options->brush_link_size = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_BRUSH_LINK_ASPECT_RATIO:
|
||||
options->brush_link_aspect_ratio = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_BRUSH_LINK_ANGLE:
|
||||
options->brush_link_angle = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_BRUSH_LINK_SPACING:
|
||||
options->brush_link_spacing = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_BRUSH_LINK_HARDNESS:
|
||||
options->brush_link_hardness = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_APPLICATION_MODE:
|
||||
options->application_mode = g_value_get_enum (value);
|
||||
break;
|
||||
|
@ -539,6 +605,26 @@ gimp_paint_options_get_property (GObject *object,
|
|||
g_value_set_double (value, options->brush_force);
|
||||
break;
|
||||
|
||||
case PROP_BRUSH_LINK_SIZE:
|
||||
g_value_set_boolean (value, options->brush_link_size);
|
||||
break;
|
||||
|
||||
case PROP_BRUSH_LINK_ASPECT_RATIO:
|
||||
g_value_set_boolean (value, options->brush_link_aspect_ratio);
|
||||
break;
|
||||
|
||||
case PROP_BRUSH_LINK_ANGLE:
|
||||
g_value_set_boolean (value, options->brush_link_angle);
|
||||
break;
|
||||
|
||||
case PROP_BRUSH_LINK_SPACING:
|
||||
g_value_set_boolean (value, options->brush_link_spacing);
|
||||
break;
|
||||
|
||||
case PROP_BRUSH_LINK_HARDNESS:
|
||||
g_value_set_boolean (value, options->brush_link_hardness);
|
||||
break;
|
||||
|
||||
case PROP_APPLICATION_MODE:
|
||||
g_value_set_enum (value, options->application_mode);
|
||||
break;
|
||||
|
@ -629,6 +715,34 @@ gimp_paint_options_get_property (GObject *object,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_paint_options_brush_changed (GimpContext *context,
|
||||
GimpBrush *brush)
|
||||
{
|
||||
GimpPaintOptions *options = GIMP_PAINT_OPTIONS (context);
|
||||
|
||||
if (GIMP_IS_BRUSH (brush))
|
||||
{
|
||||
if (options->brush_link_size)
|
||||
gimp_paint_options_set_default_brush_size (options, brush);
|
||||
|
||||
if (options->brush_link_aspect_ratio)
|
||||
g_object_set (options,
|
||||
"brush-aspect-ratio", 0.0,
|
||||
NULL);
|
||||
|
||||
if (options->brush_link_angle)
|
||||
g_object_set (options,
|
||||
"brush-angle", 0.0,
|
||||
NULL);
|
||||
|
||||
if (options->brush_link_spacing)
|
||||
gimp_paint_options_set_default_brush_spacing (options, brush);
|
||||
|
||||
if (options->brush_link_hardness)
|
||||
gimp_paint_options_set_default_brush_hardness (options, brush);
|
||||
}
|
||||
}
|
||||
|
||||
GimpPaintOptions *
|
||||
gimp_paint_options_new (GimpPaintInfo *paint_info)
|
||||
|
@ -876,6 +990,12 @@ gimp_paint_options_copy_brush_props (GimpPaintOptions *src,
|
|||
gdouble brush_hardness;
|
||||
gdouble brush_force;
|
||||
|
||||
gboolean brush_link_size;
|
||||
gboolean brush_link_aspect_ratio;
|
||||
gboolean brush_link_angle;
|
||||
gboolean brush_link_spacing;
|
||||
gboolean brush_link_hardness;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PAINT_OPTIONS (src));
|
||||
g_return_if_fail (GIMP_IS_PAINT_OPTIONS (dest));
|
||||
|
||||
|
@ -887,6 +1007,11 @@ gimp_paint_options_copy_brush_props (GimpPaintOptions *src,
|
|||
"brush-spacing", &brush_spacing,
|
||||
"brush-hardness", &brush_hardness,
|
||||
"brush-force", &brush_force,
|
||||
"brush-link-size", &brush_link_size,
|
||||
"brush-link-angle", &brush_link_angle,
|
||||
"brush-link-aspect-ratio", &brush_link_aspect_ratio,
|
||||
"brush-link-spacing", &brush_link_spacing,
|
||||
"brush-link-hardness", &brush_link_hardness,
|
||||
NULL);
|
||||
|
||||
g_object_set (dest,
|
||||
|
@ -897,6 +1022,11 @@ gimp_paint_options_copy_brush_props (GimpPaintOptions *src,
|
|||
"brush-spacing", brush_spacing,
|
||||
"brush-hardness", brush_hardness,
|
||||
"brush-force", brush_force,
|
||||
"brush-link-size", brush_link_size,
|
||||
"brush-link-angle", brush_link_angle,
|
||||
"brush-link-aspect-ratio", brush_link_aspect_ratio,
|
||||
"brush-link-spacing", brush_link_spacing,
|
||||
"brush-link-hardness", brush_link_hardness,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,12 @@ struct _GimpPaintOptions
|
|||
gdouble brush_hardness;
|
||||
gdouble brush_force;
|
||||
|
||||
gboolean brush_link_size;
|
||||
gboolean brush_link_aspect_ratio;
|
||||
gboolean brush_link_angle;
|
||||
gboolean brush_link_spacing;
|
||||
gboolean brush_link_hardness;
|
||||
|
||||
GimpPaintApplicationMode application_mode;
|
||||
GimpPaintApplicationMode application_mode_save;
|
||||
|
||||
|
|
|
@ -73,10 +73,11 @@ static GtkWidget * jitter_options_gui (GimpPaintOptions *paint_options,
|
|||
static GtkWidget * smoothing_options_gui (GimpPaintOptions *paint_options,
|
||||
GType tool_type);
|
||||
|
||||
static GtkWidget * gimp_paint_options_gui_scale_with_reset_button
|
||||
static GtkWidget * gimp_paint_options_gui_scale_with_buttons
|
||||
(GObject *config,
|
||||
gchar *prop_name,
|
||||
gchar *prop_descr,
|
||||
gchar *link_prop_name,
|
||||
gchar *reset_tooltip,
|
||||
gdouble step_increment,
|
||||
gdouble page_increment,
|
||||
|
@ -85,7 +86,8 @@ static GtkWidget * gimp_paint_options_gui_scale_with_reset_button
|
|||
gdouble scale_max,
|
||||
gdouble factor,
|
||||
gdouble gamma,
|
||||
GCallback reset_callback);
|
||||
GCallback reset_callback,
|
||||
GtkSizeGroup *link_group);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
@ -140,6 +142,7 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
|
|||
/* the brush */
|
||||
if (g_type_is_a (tool_type, GIMP_TYPE_BRUSH_TOOL))
|
||||
{
|
||||
GtkSizeGroup *link_group;
|
||||
GtkWidget *button;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *hbox;
|
||||
|
@ -151,54 +154,58 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
|
|||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
hbox = gimp_paint_options_gui_scale_with_reset_button
|
||||
(config, "brush-size", _("Size"),
|
||||
link_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
|
||||
hbox = gimp_paint_options_gui_scale_with_buttons
|
||||
(config, "brush-size", _("Size"), "brush-link-size",
|
||||
_("Reset size to brush's native size"),
|
||||
1.0, 10.0, 2, 1.0, 1000.0, 1.0, 1.7,
|
||||
G_CALLBACK (gimp_paint_options_gui_reset_size));
|
||||
G_CALLBACK (gimp_paint_options_gui_reset_size), link_group);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
hbox = gimp_paint_options_gui_scale_with_reset_button
|
||||
(config, "brush-aspect-ratio", _("Aspect Ratio"),
|
||||
hbox = gimp_paint_options_gui_scale_with_buttons
|
||||
(config, "brush-aspect-ratio", _("Aspect Ratio"), "brush-link-aspect-ratio",
|
||||
_("Reset aspect ratio to brush's native"),
|
||||
0.1, 1.0, 2, -20.0, 20.0, 1.0, 1.0,
|
||||
G_CALLBACK (gimp_paint_options_gui_reset_aspect_ratio));
|
||||
G_CALLBACK (gimp_paint_options_gui_reset_aspect_ratio), link_group);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
hbox = gimp_paint_options_gui_scale_with_reset_button
|
||||
(config, "brush-angle", _("Angle"),
|
||||
hbox = gimp_paint_options_gui_scale_with_buttons
|
||||
(config, "brush-angle", _("Angle"), "brush-link-angle",
|
||||
_("Reset angle to zero"),
|
||||
0.1, 1.0, 2, -180.0, 180.0, 1.0, 1.0,
|
||||
G_CALLBACK (gimp_paint_options_gui_reset_angle));
|
||||
G_CALLBACK (gimp_paint_options_gui_reset_angle), link_group);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
hbox = gimp_paint_options_gui_scale_with_reset_button
|
||||
(config, "brush-spacing", _("Spacing"),
|
||||
hbox = gimp_paint_options_gui_scale_with_buttons
|
||||
(config, "brush-spacing", _("Spacing"), "brush-link-spacing",
|
||||
_("Reset spacing to brush's native spacing"),
|
||||
0.1, 1.0, 1, 1.0, 200.0, 100.0, 1.7,
|
||||
G_CALLBACK (gimp_paint_options_gui_reset_spacing));
|
||||
G_CALLBACK (gimp_paint_options_gui_reset_spacing), link_group);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
hbox = gimp_paint_options_gui_scale_with_reset_button
|
||||
(config, "brush-hardness", _("Hardness"),
|
||||
hbox = gimp_paint_options_gui_scale_with_buttons
|
||||
(config, "brush-hardness", _("Hardness"), "brush-link-hardness",
|
||||
_("Reset hardness to default"),
|
||||
0.1, 1.0, 1, 0.0, 100.0, 100.0, 1.0,
|
||||
G_CALLBACK (gimp_paint_options_gui_reset_hardness));
|
||||
G_CALLBACK (gimp_paint_options_gui_reset_hardness), link_group);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
hbox = gimp_paint_options_gui_scale_with_reset_button
|
||||
(config, "brush-force", _("Force"),
|
||||
hbox = gimp_paint_options_gui_scale_with_buttons
|
||||
(config, "brush-force", _("Force"), NULL,
|
||||
_("Reset force to default"),
|
||||
0.1, 1.0, 1, 0.0, 100.0, 100.0, 1.0,
|
||||
G_CALLBACK (gimp_paint_options_gui_reset_force));
|
||||
G_CALLBACK (gimp_paint_options_gui_reset_force), link_group);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
g_object_unref (link_group);
|
||||
|
||||
button = gimp_prop_dynamics_box_new (NULL, GIMP_CONTEXT (tool_options),
|
||||
_("Dynamics"), 2,
|
||||
"dynamics-view-type",
|
||||
|
@ -467,9 +474,10 @@ gimp_paint_options_gui_reset_force (GtkWidget *button,
|
|||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_paint_options_gui_scale_with_reset_button (GObject *config,
|
||||
gimp_paint_options_gui_scale_with_buttons (GObject *config,
|
||||
gchar *prop_name,
|
||||
gchar *prop_descr,
|
||||
gchar *link_prop_name,
|
||||
gchar *reset_tooltip,
|
||||
gdouble step_increment,
|
||||
gdouble page_increment,
|
||||
|
@ -478,13 +486,14 @@ gimp_paint_options_gui_scale_with_reset_button (GObject *config,
|
|||
gdouble scale_max,
|
||||
gdouble factor,
|
||||
gdouble gamma,
|
||||
GCallback reset_callback)
|
||||
GCallback reset_callback,
|
||||
GtkSizeGroup *link_group)
|
||||
{
|
||||
GtkWidget *scale;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *button;
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
|
||||
scale = gimp_prop_spin_scale_new (config, prop_name,
|
||||
prop_descr,
|
||||
|
@ -511,5 +520,34 @@ gimp_paint_options_gui_scale_with_reset_button (GObject *config,
|
|||
gimp_help_set_help_data (button,
|
||||
reset_tooltip, NULL);
|
||||
|
||||
if (link_prop_name)
|
||||
{
|
||||
GtkWidget *image;
|
||||
|
||||
button = gtk_toggle_button_new ();
|
||||
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
||||
|
||||
image = gtk_image_new_from_icon_name (GIMP_STOCK_LINKED,
|
||||
GTK_ICON_SIZE_MENU);
|
||||
gtk_container_add (GTK_CONTAINER (button), image);
|
||||
gtk_widget_show (image);
|
||||
|
||||
g_object_bind_property (config, link_prop_name,
|
||||
button, "active",
|
||||
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
button = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
}
|
||||
|
||||
gtk_size_group_add_widget (link_group, button);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gimp_help_set_help_data (button,
|
||||
_("Link to brush default"), NULL);
|
||||
|
||||
return hbox;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue