mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-10-06 01:12:40 +02:00
core: Add color/pattern only fill options
Resolves issue with #8461. This provides a conditional value for the fill options to only show a color and pattern, rather than fore/background colors. Currently only used for the text editor.
This commit is contained in:
@@ -587,6 +587,35 @@ gimp_dynamics_output_type_get_type (void)
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_custom_style_get_type (void)
|
||||
{
|
||||
static const GEnumValue values[] =
|
||||
{
|
||||
{ GIMP_CUSTOM_STYLE_SOLID_COLOR, "GIMP_CUSTOM_STYLE_SOLID_COLOR", "solid-color" },
|
||||
{ GIMP_CUSTOM_STYLE_PATTERN, "GIMP_CUSTOM_STYLE_PATTERN", "pattern" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static const GimpEnumDesc descs[] =
|
||||
{
|
||||
{ GIMP_CUSTOM_STYLE_SOLID_COLOR, NC_("custom-style", "Solid color"), NULL },
|
||||
{ GIMP_CUSTOM_STYLE_PATTERN, NC_("custom-style", "Pattern"), NULL },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static GType type = 0;
|
||||
|
||||
if (G_UNLIKELY (! type))
|
||||
{
|
||||
type = g_enum_register_static ("GimpCustomStyle", values);
|
||||
gimp_type_set_translation_context (type, "custom-style");
|
||||
gimp_enum_set_value_descriptions (type, descs);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_fill_style_get_type (void)
|
||||
{
|
||||
|
@@ -290,6 +290,16 @@ typedef enum /*< pdb-skip >*/
|
||||
} GimpDynamicsOutputType;
|
||||
|
||||
|
||||
#define GIMP_TYPE_CUSTOM_STYLE (gimp_custom_style_get_type ())
|
||||
|
||||
GType gimp_custom_style_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef enum /*< pdb-skip >*/
|
||||
{
|
||||
GIMP_CUSTOM_STYLE_SOLID_COLOR, /*< desc="Solid color" >*/
|
||||
GIMP_CUSTOM_STYLE_PATTERN /*< desc="Pattern" >*/
|
||||
} GimpCustomStyle;
|
||||
|
||||
#define GIMP_TYPE_FILL_STYLE (gimp_fill_style_get_type ())
|
||||
|
||||
GType gimp_fill_style_get_type (void) G_GNUC_CONST;
|
||||
|
@@ -48,6 +48,7 @@ enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_STYLE,
|
||||
PROP_CUSTOM_STYLE,
|
||||
PROP_ANTIALIAS,
|
||||
PROP_FEATHER,
|
||||
PROP_FEATHER_RADIUS,
|
||||
@@ -60,10 +61,11 @@ typedef struct _GimpFillOptionsPrivate GimpFillOptionsPrivate;
|
||||
|
||||
struct _GimpFillOptionsPrivate
|
||||
{
|
||||
GimpFillStyle style;
|
||||
gboolean antialias;
|
||||
gboolean feather;
|
||||
gdouble feather_radius;
|
||||
GimpFillStyle style;
|
||||
GimpCustomStyle custom_style;
|
||||
gboolean antialias;
|
||||
gboolean feather;
|
||||
gdouble feather_radius;
|
||||
|
||||
GimpViewType pattern_view_type;
|
||||
GimpViewSize pattern_view_size;
|
||||
@@ -113,6 +115,14 @@ gimp_fill_options_class_init (GimpFillOptionsClass *klass)
|
||||
GIMP_FILL_STYLE_FG_COLOR,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_ENUM (object_class, PROP_CUSTOM_STYLE,
|
||||
"custom-style",
|
||||
_("Custom style"),
|
||||
NULL,
|
||||
GIMP_TYPE_CUSTOM_STYLE,
|
||||
GIMP_CUSTOM_STYLE_SOLID_COLOR,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_ANTIALIAS,
|
||||
"antialias",
|
||||
_("Antialiasing"),
|
||||
@@ -177,6 +187,10 @@ gimp_fill_options_set_property (GObject *object,
|
||||
private->style = g_value_get_enum (value);
|
||||
private->undo_desc = NULL;
|
||||
break;
|
||||
case PROP_CUSTOM_STYLE:
|
||||
private->custom_style = g_value_get_enum (value);
|
||||
private->undo_desc = NULL;
|
||||
break;
|
||||
case PROP_ANTIALIAS:
|
||||
private->antialias = g_value_get_boolean (value);
|
||||
break;
|
||||
@@ -213,6 +227,9 @@ gimp_fill_options_get_property (GObject *object,
|
||||
case PROP_STYLE:
|
||||
g_value_set_enum (value, private->style);
|
||||
break;
|
||||
case PROP_CUSTOM_STYLE:
|
||||
g_value_set_enum (value, private->custom_style);
|
||||
break;
|
||||
case PROP_ANTIALIAS:
|
||||
g_value_set_boolean (value, private->antialias);
|
||||
break;
|
||||
@@ -293,6 +310,24 @@ gimp_fill_options_set_style (GimpFillOptions *options,
|
||||
g_object_set (options, "style", style, NULL);
|
||||
}
|
||||
|
||||
GimpCustomStyle
|
||||
gimp_fill_options_get_custom_style (GimpFillOptions *options)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options),
|
||||
GIMP_CUSTOM_STYLE_SOLID_COLOR);
|
||||
|
||||
return GET_PRIVATE (options)->custom_style;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_fill_options_set_custom_style (GimpFillOptions *options,
|
||||
GimpCustomStyle custom_style)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_FILL_OPTIONS (options));
|
||||
|
||||
g_object_set (options, "custom-style", custom_style, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_fill_options_get_antialias (GimpFillOptions *options)
|
||||
{
|
||||
|
@@ -56,6 +56,11 @@ GimpFillStyle gimp_fill_options_get_style (GimpFillOptions *optio
|
||||
void gimp_fill_options_set_style (GimpFillOptions *options,
|
||||
GimpFillStyle style);
|
||||
|
||||
GimpCustomStyle gimp_fill_options_get_custom_style
|
||||
(GimpFillOptions *options);
|
||||
void gimp_fill_options_set_custom_style (GimpFillOptions *options,
|
||||
GimpCustomStyle custom_style);
|
||||
|
||||
gboolean gimp_fill_options_get_antialias (GimpFillOptions *options);
|
||||
void gimp_fill_options_set_antialias (GimpFillOptions *options,
|
||||
gboolean antialias);
|
||||
|
@@ -138,7 +138,7 @@ fill_dialog_new (GList *items,
|
||||
main_vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
fill_editor = gimp_fill_editor_new (private->options, FALSE);
|
||||
fill_editor = gimp_fill_editor_new (private->options, FALSE, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), fill_editor, FALSE, FALSE, 0);
|
||||
gtk_widget_show (fill_editor);
|
||||
|
||||
|
@@ -2601,7 +2601,7 @@ prefs_dialog_new (Gimp *gimp,
|
||||
GTK_CONTAINER (vbox), FALSE);
|
||||
|
||||
editor = gimp_fill_editor_new (GIMP_DIALOG_CONFIG (object)->fill_options,
|
||||
FALSE);
|
||||
FALSE, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), editor, FALSE, FALSE, 0);
|
||||
gtk_widget_show (editor);
|
||||
|
||||
@@ -2617,7 +2617,7 @@ prefs_dialog_new (Gimp *gimp,
|
||||
*/
|
||||
editor = gimp_stroke_editor_new (GIMP_DIALOG_CONFIG (object)->stroke_options,
|
||||
gimp_template_get_resolution_y (core_config->default_image),
|
||||
FALSE);
|
||||
FALSE, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), editor, FALSE, FALSE, 0);
|
||||
gtk_widget_show (editor);
|
||||
|
||||
|
@@ -180,7 +180,8 @@ stroke_dialog_new (GList *items,
|
||||
|
||||
gimp_image_get_resolution (image, &xres, &yres);
|
||||
|
||||
stroke_editor = gimp_stroke_editor_new (private->options, yres, FALSE);
|
||||
stroke_editor = gimp_stroke_editor_new (private->options, yres, FALSE,
|
||||
FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), stroke_editor);
|
||||
gtk_widget_show (stroke_editor);
|
||||
|
||||
|
@@ -333,9 +333,9 @@ gimp_text_class_init (GimpTextClass *klass)
|
||||
GIMP_PARAM_WRITABLE));
|
||||
|
||||
GIMP_CONFIG_PROP_ENUM (object_class, PROP_OUTLINE_STYLE,
|
||||
"outline-style", NULL, NULL,
|
||||
GIMP_TYPE_FILL_STYLE,
|
||||
GIMP_FILL_STYLE_FG_COLOR,
|
||||
"outline-custom-style", NULL, NULL,
|
||||
GIMP_TYPE_CUSTOM_STYLE,
|
||||
GIMP_CUSTOM_STYLE_SOLID_COLOR,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
GIMP_CONFIG_PROP_OBJECT (object_class, PROP_OUTLINE_PATTERN,
|
||||
"outline-pattern", NULL, NULL,
|
||||
|
@@ -50,7 +50,7 @@ struct _GimpText
|
||||
gchar *language;
|
||||
GimpTextDirection base_dir;
|
||||
GimpRGB color;
|
||||
GimpFillStyle outline_style;
|
||||
GimpCustomStyle outline_style;
|
||||
GimpPattern *outline_pattern;
|
||||
GimpRGB outline_foreground;
|
||||
gdouble outline_width;
|
||||
|
@@ -981,7 +981,7 @@ gimp_text_layer_render_layout (GimpTextLayer *layer,
|
||||
if (text->outline_dash_info)
|
||||
gimp_text_layer_set_dash_info (cr, text->outline_width, text->outline_dash_offset, text->outline_dash_info);
|
||||
|
||||
if (text->outline_style == GIMP_FILL_STYLE_PATTERN && text->outline_pattern)
|
||||
if (text->outline_style == GIMP_CUSTOM_STYLE_PATTERN && text->outline_pattern)
|
||||
{
|
||||
GimpTempBuf *tempbuf = gimp_pattern_get_mask (text->outline_pattern);
|
||||
cairo_surface_t *surface = gimp_temp_buf_create_cairo_surface (tempbuf);
|
||||
|
@@ -279,10 +279,10 @@ gimp_text_options_class_init (GimpTextOptionsClass *klass)
|
||||
GIMP_PARAM_STATIC_STRINGS |
|
||||
GIMP_CONFIG_PARAM_DEFAULTS);
|
||||
GIMP_CONFIG_PROP_ENUM (object_class, PROP_OUTLINE_STYLE,
|
||||
"outline-style",
|
||||
"outline-custom-style",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_FILL_STYLE,
|
||||
GIMP_FILL_STYLE_FG_COLOR,
|
||||
GIMP_TYPE_CUSTOM_STYLE,
|
||||
GIMP_CUSTOM_STYLE_SOLID_COLOR,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
GIMP_CONFIG_PROP_RGB (object_class, PROP_OUTLINE_FOREGROUND,
|
||||
"outline-foreground",
|
||||
@@ -627,7 +627,7 @@ gimp_text_options_reset (GimpConfig *config)
|
||||
gimp_config_reset_property (object, "box-mode");
|
||||
|
||||
gimp_config_reset_property (object, "outline");
|
||||
gimp_config_reset_property (object, "outline-style");
|
||||
gimp_config_reset_property (object, "outline-custom-style");
|
||||
gimp_config_reset_property (object, "outline-foreground");
|
||||
gimp_config_reset_property (object, "outline-pattern");
|
||||
gimp_config_reset_property (object, "outline-width");
|
||||
@@ -917,7 +917,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
|
||||
g_object_bind_property (options, "outline-" #a, \
|
||||
stroke_options, #a, \
|
||||
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE)
|
||||
BIND (style);
|
||||
BIND (custom-style);
|
||||
BIND (foreground);
|
||||
BIND (pattern);
|
||||
BIND (width);
|
||||
@@ -929,7 +929,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
|
||||
BIND (dash-offset);
|
||||
BIND (dash-info);
|
||||
|
||||
editor = gimp_stroke_editor_new (stroke_options, 72.0, TRUE);
|
||||
editor = gimp_stroke_editor_new (stroke_options, 72.0, TRUE, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (outline_frame), editor);
|
||||
gtk_widget_show (editor);
|
||||
|
||||
|
@@ -50,7 +50,7 @@ struct _GimpTextOptions
|
||||
GimpTextBoxMode box_mode;
|
||||
|
||||
GimpTextOutline outline;
|
||||
GimpFillStyle outline_style;
|
||||
GimpCustomStyle outline_style;
|
||||
GimpRGB outline_foreground;
|
||||
GimpPattern *outline_pattern;
|
||||
gdouble outline_width;
|
||||
|
@@ -43,7 +43,8 @@ enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_OPTIONS,
|
||||
PROP_EDIT_CONTEXT
|
||||
PROP_EDIT_CONTEXT,
|
||||
PROP_USE_CUSTOM_STYLE
|
||||
};
|
||||
|
||||
|
||||
@@ -87,6 +88,13 @@ gimp_fill_editor_class_init (GimpFillEditorClass *klass)
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_EDIT_CONTEXT,
|
||||
g_param_spec_boolean ("use-custom-style",
|
||||
NULL, NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -109,8 +117,17 @@ gimp_fill_editor_constructed (GObject *object)
|
||||
|
||||
gimp_assert (GIMP_IS_FILL_OPTIONS (editor->options));
|
||||
|
||||
box = gimp_prop_enum_radio_box_new (G_OBJECT (editor->options), "style",
|
||||
0, 0);
|
||||
g_object_get (object,
|
||||
"use-custom-style", &editor->use_custom_style,
|
||||
NULL);
|
||||
|
||||
if (editor->use_custom_style)
|
||||
box = gimp_prop_enum_radio_box_new (G_OBJECT (editor->options),
|
||||
"custom-style", 0, 0);
|
||||
else
|
||||
box = gimp_prop_enum_radio_box_new (G_OBJECT (editor->options), "style",
|
||||
0, 0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (editor), box, FALSE, FALSE, 0);
|
||||
|
||||
if (editor->edit_context)
|
||||
@@ -118,25 +135,40 @@ gimp_fill_editor_constructed (GObject *object)
|
||||
GtkWidget *color_button;
|
||||
GtkWidget *pattern_box;
|
||||
|
||||
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
|
||||
"foreground",
|
||||
_("Fill Color"),
|
||||
1, 24,
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS);
|
||||
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
|
||||
GIMP_CONTEXT (editor->options));
|
||||
gimp_enum_radio_box_add (GTK_BOX (box), color_button,
|
||||
GIMP_FILL_STYLE_FG_COLOR, FALSE);
|
||||
if (editor->use_custom_style)
|
||||
{
|
||||
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
|
||||
"foreground",
|
||||
_("Fill Color"),
|
||||
1, 24,
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS);
|
||||
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
|
||||
GIMP_CONTEXT (editor->options));
|
||||
gimp_enum_radio_box_add (GTK_BOX (box), color_button,
|
||||
GIMP_CUSTOM_STYLE_SOLID_COLOR, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
|
||||
"foreground",
|
||||
_("Fill Color"),
|
||||
1, 24,
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS);
|
||||
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
|
||||
GIMP_CONTEXT (editor->options));
|
||||
gimp_enum_radio_box_add (GTK_BOX (box), color_button,
|
||||
GIMP_FILL_STYLE_FG_COLOR, FALSE);
|
||||
|
||||
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
|
||||
"background",
|
||||
_("Fill BG Color"),
|
||||
1, 24,
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS);
|
||||
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
|
||||
GIMP_CONTEXT (editor->options));
|
||||
gimp_enum_radio_box_add (GTK_BOX (box), color_button,
|
||||
GIMP_FILL_STYLE_BG_COLOR, FALSE);
|
||||
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
|
||||
"background",
|
||||
_("Fill BG Color"),
|
||||
1, 24,
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS);
|
||||
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
|
||||
GIMP_CONTEXT (editor->options));
|
||||
gimp_enum_radio_box_add (GTK_BOX (box), color_button,
|
||||
GIMP_FILL_STYLE_BG_COLOR, FALSE);
|
||||
}
|
||||
|
||||
pattern_box = gimp_prop_pattern_box_new (NULL,
|
||||
GIMP_CONTEXT (editor->options),
|
||||
@@ -144,7 +176,10 @@ gimp_fill_editor_constructed (GObject *object)
|
||||
"pattern-view-type",
|
||||
"pattern-view-size");
|
||||
gimp_enum_radio_box_add (GTK_BOX (box), pattern_box,
|
||||
GIMP_FILL_STYLE_PATTERN, FALSE);
|
||||
(editor->use_custom_style ?
|
||||
GIMP_CUSTOM_STYLE_PATTERN :
|
||||
GIMP_FILL_STYLE_PATTERN),
|
||||
FALSE);
|
||||
}
|
||||
|
||||
button = gimp_prop_check_button_new (G_OBJECT (editor->options),
|
||||
@@ -183,6 +218,10 @@ gimp_fill_editor_set_property (GObject *object,
|
||||
editor->edit_context = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_USE_CUSTOM_STYLE:
|
||||
editor->use_custom_style = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
@@ -207,6 +246,10 @@ gimp_fill_editor_get_property (GObject *object,
|
||||
g_value_set_boolean (value, editor->edit_context);
|
||||
break;
|
||||
|
||||
case PROP_USE_CUSTOM_STYLE:
|
||||
g_value_set_boolean (value, editor->use_custom_style);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
@@ -215,12 +258,14 @@ gimp_fill_editor_get_property (GObject *object,
|
||||
|
||||
GtkWidget *
|
||||
gimp_fill_editor_new (GimpFillOptions *options,
|
||||
gboolean edit_context)
|
||||
gboolean edit_context,
|
||||
gboolean use_custom_style)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), NULL);
|
||||
|
||||
return g_object_new (GIMP_TYPE_FILL_EDITOR,
|
||||
"options", options,
|
||||
"edit-context", edit_context ? TRUE : FALSE,
|
||||
"options", options,
|
||||
"edit-context", edit_context ? TRUE : FALSE,
|
||||
"use_custom_style", use_custom_style ? TRUE : FALSE,
|
||||
NULL);
|
||||
}
|
||||
|
@@ -38,6 +38,7 @@ struct _GimpFillEditor
|
||||
|
||||
GimpFillOptions *options;
|
||||
gboolean edit_context;
|
||||
gboolean use_custom_style; /* For solid color and pattern only */
|
||||
};
|
||||
|
||||
struct _GimpFillEditorClass
|
||||
@@ -49,7 +50,8 @@ struct _GimpFillEditorClass
|
||||
GType gimp_fill_editor_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_fill_editor_new (GimpFillOptions *options,
|
||||
gboolean edit_context);
|
||||
gboolean edit_context,
|
||||
gboolean use_custom_style);
|
||||
|
||||
|
||||
#endif /* __GIMP_FILL_EDITOR_H__ */
|
||||
|
@@ -308,14 +308,16 @@ gimp_stroke_editor_get_property (GObject *object,
|
||||
GtkWidget *
|
||||
gimp_stroke_editor_new (GimpStrokeOptions *options,
|
||||
gdouble resolution,
|
||||
gboolean edit_context)
|
||||
gboolean edit_context,
|
||||
gboolean use_custom_style)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), NULL);
|
||||
|
||||
return g_object_new (GIMP_TYPE_STROKE_EDITOR,
|
||||
"options", options,
|
||||
"resolution", resolution,
|
||||
"edit-context", edit_context ? TRUE : FALSE,
|
||||
"options", options,
|
||||
"resolution", resolution,
|
||||
"edit-context", edit_context ? TRUE : FALSE,
|
||||
"use-custom-style", use_custom_style ? TRUE: FALSE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
@@ -52,7 +52,8 @@ GType gimp_stroke_editor_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_stroke_editor_new (GimpStrokeOptions *options,
|
||||
gdouble resolution,
|
||||
gboolean edit_context);
|
||||
gboolean edit_context,
|
||||
gboolean use_custom_style);
|
||||
|
||||
|
||||
#endif /* __GIMP_STROKE_EDITOR_H__ */
|
||||
|
Reference in New Issue
Block a user