[gimp/alxsa-fill-path-solid-colors] core: Replace "Solid Colors" with "FG/BG Colors"
- From: Alx Sa <sawyeralex src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/alxsa-fill-path-solid-colors] core: Replace "Solid Colors" with "FG/BG Colors"
- Date: Sun, 7 Aug 2022 11:47:31 +0000 (UTC)
commit 78382d18855ccd9eddce4f94cbd3eab23eac54c4
Author: Alx Sa <cmyk student gmail com>
Date: Sun Aug 7 11:47:30 2022 +0000
core: Replace "Solid Colors" with "FG/BG Colors"
Replaces "Solid Colors" option in Fill Path with Foreground/Background
Colors options. This allows users to fill with either, rather than
having to switch the foreground color each time.
GIMP_CONTEXT_PROP_MASK_BACKGROUND was added to the fill and stroke
contexts to allow the background color to be recognized.
In places where Solid Color was used as a default, Foreground Color is
now used instead.
app/core/core-enums.c | 6 ++++--
app/core/core-enums.h | 5 +++--
app/core/gimpdrawable-bucket-fill.c | 10 +++++-----
app/core/gimpdrawable-edit.c | 3 ++-
app/core/gimpfilloptions.c | 28 ++++++++++++++++++++++------
app/core/gimpstrokeoptions.c | 1 +
app/display/gimpdisplayshell-dnd.c | 12 ++++++++----
app/widgets/gimpdrawabletreeview.c | 4 ++--
app/widgets/gimpfilleditor.c | 14 ++++++++++++--
9 files changed, 59 insertions(+), 24 deletions(-)
---
diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index 235cd8c2ae..e3356e00be 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -604,14 +604,16 @@ gimp_fill_style_get_type (void)
{
static const GEnumValue values[] =
{
- { GIMP_FILL_STYLE_SOLID, "GIMP_FILL_STYLE_SOLID", "solid" },
+ { GIMP_FILL_STYLE_FG_COLOR, "GIMP_FILL_STYLE_FG_COLOR", "fg-color" },
+ { GIMP_FILL_STYLE_BG_COLOR, "GIMP_FILL_STYLE_BG_COLOR", "bg-color" },
{ GIMP_FILL_STYLE_PATTERN, "GIMP_FILL_STYLE_PATTERN", "pattern" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
- { GIMP_FILL_STYLE_SOLID, NC_("fill-style", "Solid color"), NULL },
+ { GIMP_FILL_STYLE_FG_COLOR, NC_("fill-style", "Foreground color"), NULL },
+ { GIMP_FILL_STYLE_BG_COLOR, NC_("fill-style", "Background color"), NULL },
{ GIMP_FILL_STYLE_PATTERN, NC_("fill-style", "Pattern"), NULL },
{ 0, NULL, NULL }
};
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index cc6d64b179..5fd068cd6e 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -302,8 +302,9 @@ GType gimp_fill_style_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/
{
- GIMP_FILL_STYLE_SOLID, /*< desc="Solid color" >*/
- GIMP_FILL_STYLE_PATTERN /*< desc="Pattern" >*/
+ GIMP_FILL_STYLE_FG_COLOR, /*< desc="Foreground color" >*/
+ GIMP_FILL_STYLE_BG_COLOR, /*< desc="Background color" >*/
+ GIMP_FILL_STYLE_PATTERN /*< desc="Pattern" >*/
} GimpFillStyle;
diff --git a/app/core/gimpdrawable-bucket-fill.c b/app/core/gimpdrawable-bucket-fill.c
index c08973e70d..02732a4732 100644
--- a/app/core/gimpdrawable-bucket-fill.c
+++ b/app/core/gimpdrawable-bucket-fill.c
@@ -412,15 +412,15 @@ gimp_drawable_get_line_art_fill_buffer (GimpDrawable *drawable,
GimpPickable *pickable = gimp_line_art_get_input (line_art);
/* This cannot be a pattern fill. */
- g_return_val_if_fail (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_SOLID,
+ g_return_val_if_fail (gimp_fill_options_get_style (options) != GIMP_FILL_STYLE_PATTERN,
NULL);
/* Meaningful only in above/below layer cases. */
g_return_val_if_fail (GIMP_IS_DRAWABLE (pickable), NULL);
- /* Fill options foreground color is the expected color (can be
- * actual fg or bg in the user context).
- */
- gimp_context_get_foreground (GIMP_CONTEXT (options), &fill_color);
+ if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_FG_COLOR)
+ gimp_context_get_foreground (GIMP_CONTEXT (options), &fill_color);
+ else if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_BG_COLOR)
+ gimp_context_get_background (GIMP_CONTEXT (options), &fill_color);
fill_buffer = gimp_drawable_get_buffer (drawable);
fill_offset_x = gimp_item_get_offset_x (GIMP_ITEM (drawable)) -
diff --git a/app/core/gimpdrawable-edit.c b/app/core/gimpdrawable-edit.c
index b8d9842fdb..e826b530e2 100644
--- a/app/core/gimpdrawable-edit.c
+++ b/app/core/gimpdrawable-edit.c
@@ -79,7 +79,8 @@ gimp_drawable_edit_can_fill_direct (GimpDrawable *drawable,
{
switch (gimp_fill_options_get_style (options))
{
- case GIMP_FILL_STYLE_SOLID:
+ case GIMP_FILL_STYLE_FG_COLOR:
+ case GIMP_FILL_STYLE_BG_COLOR:
return TRUE;
case GIMP_FILL_STYLE_PATTERN:
diff --git a/app/core/gimpfilloptions.c b/app/core/gimpfilloptions.c
index 3cedd587a5..0f9161b40a 100644
--- a/app/core/gimpfilloptions.c
+++ b/app/core/gimpfilloptions.c
@@ -109,7 +109,7 @@ gimp_fill_options_class_init (GimpFillOptionsClass *klass)
_("Style"),
NULL,
GIMP_TYPE_FILL_STYLE,
- GIMP_FILL_STYLE_SOLID,
+ GIMP_FILL_STYLE_FG_COLOR,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_ANTIALIAS,
@@ -265,6 +265,7 @@ gimp_fill_options_new (Gimp *gimp,
{
gimp_context_define_properties (GIMP_CONTEXT (options),
GIMP_CONTEXT_PROP_MASK_FOREGROUND |
+ GIMP_CONTEXT_PROP_MASK_BACKGROUND |
GIMP_CONTEXT_PROP_MASK_PATTERN,
FALSE);
@@ -277,7 +278,7 @@ gimp_fill_options_new (Gimp *gimp,
GimpFillStyle
gimp_fill_options_get_style (GimpFillOptions *options)
{
- g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), GIMP_FILL_STYLE_SOLID);
+ g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), GIMP_FILL_STYLE_FG_COLOR);
return GET_PRIVATE (options)->style;
}
@@ -397,7 +398,7 @@ gimp_fill_options_set_by_fill_type (GimpFillOptions *options,
return FALSE;
}
- gimp_fill_options_set_style (options, GIMP_FILL_STYLE_SOLID);
+ gimp_fill_options_set_style (options, GIMP_FILL_STYLE_FG_COLOR);
gimp_context_set_foreground (GIMP_CONTEXT (options), &color);
private->undo_desc = undo_desc;
@@ -450,8 +451,11 @@ gimp_fill_options_get_undo_desc (GimpFillOptions *options)
switch (private->style)
{
- case GIMP_FILL_STYLE_SOLID:
- return C_("undo-type", "Fill with Solid Color");
+ case GIMP_FILL_STYLE_FG_COLOR:
+ return C_("undo-type", "Fill with Foreground Color");
+
+ case GIMP_FILL_STYLE_BG_COLOR:
+ return C_("undo-type", "Fill with Background Color");
case GIMP_FILL_STYLE_PATTERN:
return C_("undo-type", "Fill with Pattern");
@@ -521,7 +525,7 @@ gimp_fill_options_fill_buffer (GimpFillOptions *options,
switch (gimp_fill_options_get_style (options))
{
- case GIMP_FILL_STYLE_SOLID:
+ case GIMP_FILL_STYLE_FG_COLOR:
{
GimpRGB color;
@@ -533,6 +537,18 @@ gimp_fill_options_fill_buffer (GimpFillOptions *options,
}
break;
+ case GIMP_FILL_STYLE_BG_COLOR:
+ {
+ GimpRGB color;
+
+ gimp_context_get_background (GIMP_CONTEXT (options), &color);
+ gimp_palettes_add_color_history (GIMP_CONTEXT (options)->gimp, &color);
+
+ gimp_drawable_fill_buffer (drawable, buffer,
+ &color, NULL, 0, 0);
+ }
+ break;
+
case GIMP_FILL_STYLE_PATTERN:
{
GimpPattern *pattern;
diff --git a/app/core/gimpstrokeoptions.c b/app/core/gimpstrokeoptions.c
index dda73ead1c..0a94a635dd 100644
--- a/app/core/gimpstrokeoptions.c
+++ b/app/core/gimpstrokeoptions.c
@@ -423,6 +423,7 @@ gimp_stroke_options_new (Gimp *gimp,
{
gimp_context_define_properties (GIMP_CONTEXT (options),
GIMP_CONTEXT_PROP_MASK_FOREGROUND |
+ GIMP_CONTEXT_PROP_MASK_BACKGROUND |
GIMP_CONTEXT_PROP_MASK_PATTERN,
FALSE);
diff --git a/app/display/gimpdisplayshell-dnd.c b/app/display/gimpdisplayshell-dnd.c
index b164842b8c..3fdb81e905 100644
--- a/app/display/gimpdisplayshell-dnd.c
+++ b/app/display/gimpdisplayshell-dnd.c
@@ -384,12 +384,16 @@ gimp_display_shell_dnd_fill (GimpDisplayShell *shell,
/* FIXME: there should be a virtual method for this that the
* GimpTextLayer can override.
*/
- if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_SOLID &&
- gimp_item_is_text_layer (iter->data))
+ if (gimp_item_is_text_layer (iter->data) &&
+ (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_FG_COLOR ||
+ gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_BG_COLOR))
{
GimpRGB color;
- gimp_context_get_foreground (GIMP_CONTEXT (options), &color);
+ if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_FG_COLOR)
+ gimp_context_get_foreground (GIMP_CONTEXT (options), &color);
+ else
+ gimp_context_get_background (GIMP_CONTEXT (options), &color);
gimp_text_layer_set (iter->data, NULL,
"color", &color,
@@ -441,7 +445,7 @@ gimp_display_shell_drop_color (GtkWidget *widget,
GIMP_LOG (DND, NULL);
- gimp_fill_options_set_style (options, GIMP_FILL_STYLE_SOLID);
+ gimp_fill_options_set_style (options, GIMP_FILL_STYLE_FG_COLOR);
gimp_context_set_foreground (GIMP_CONTEXT (options), color);
gimp_display_shell_dnd_fill (shell, options,
diff --git a/app/widgets/gimpdrawabletreeview.c b/app/widgets/gimpdrawabletreeview.c
index 84707cb33f..6054515f5c 100644
--- a/app/widgets/gimpdrawabletreeview.c
+++ b/app/widgets/gimpdrawabletreeview.c
@@ -290,7 +290,7 @@ gimp_drawable_tree_view_drop_color (GimpContainerTreeView *view,
GimpImage *image = gimp_item_get_image (GIMP_ITEM (dest_viewable));
GimpFillOptions *options = gimp_fill_options_new (image->gimp, NULL, FALSE);
- gimp_fill_options_set_style (options, GIMP_FILL_STYLE_SOLID);
+ gimp_fill_options_set_style (options, GIMP_FILL_STYLE_FG_COLOR);
gimp_context_set_foreground (GIMP_CONTEXT (options), color);
gimp_drawable_edit_fill (GIMP_DRAWABLE (dest_viewable),
@@ -399,7 +399,7 @@ gimp_drawable_tree_view_new_color_dropped (GtkWidget *widget,
GimpImage *image = gimp_item_tree_view_get_image (view);
GimpFillOptions *options = gimp_fill_options_new (image->gimp, NULL, FALSE);
- gimp_fill_options_set_style (options, GIMP_FILL_STYLE_SOLID);
+ gimp_fill_options_set_style (options, GIMP_FILL_STYLE_FG_COLOR);
gimp_context_set_foreground (GIMP_CONTEXT (options), color);
gimp_drawable_tree_view_new_dropped (view, options,
diff --git a/app/widgets/gimpfilleditor.c b/app/widgets/gimpfilleditor.c
index 50d110e150..2b4a49663e 100644
--- a/app/widgets/gimpfilleditor.c
+++ b/app/widgets/gimpfilleditor.c
@@ -120,13 +120,23 @@ gimp_fill_editor_constructed (GObject *object)
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
"foreground",
- _("Fill Color"),
+ _("Fill FG 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_SOLID, FALSE);
+ 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);
pattern_box = gimp_prop_pattern_box_new (NULL,
GIMP_CONTEXT (editor->options),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]