Issue #15575: add arg to color button prop widget to choose context awareness.

In particular, for indexed images, color choice will happen within the
colormap.

The following uses are made context-aware:

* Test tool options color;
* Fill colors.

These other uses will not be context-aware:

* Padding, quick-mask and padding colors;
* Out-of-gamut colors;
* Generically generated color buttons (e.g. in filter dialogs);
* Foreground selection's mask color;
* Grid colors.
This commit is contained in:
Jehan 2026-02-03 12:15:14 +01:00
parent c34fe3e94f
commit 9417565ea2
9 changed files with 15 additions and 8 deletions

View file

@ -241,7 +241,7 @@ prefs_color_button_add (GObject *config,
has_alpha = gimp_param_spec_color_has_alpha (pspec);
button = gimp_prop_color_button_new (config, property_name,
title,
title, FALSE,
PREFS_COLOR_BUTTON_WIDTH,
PREFS_COLOR_BUTTON_HEIGHT,
has_alpha ?

View file

@ -1452,7 +1452,7 @@ prefs_dialog_new (Gimp *gimp,
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
button = gimp_prop_color_button_new (color_config, "out-of-gamut-color",
_("Select Warning Color"),
_("Select Warning Color"), FALSE,
PREFS_COLOR_BUTTON_WIDTH,
PREFS_COLOR_BUTTON_HEIGHT,
GIMP_COLOR_AREA_FLAT);

View file

@ -373,7 +373,7 @@ gimp_prop_widget_new_from_pspec (GObject *config,
button = gimp_prop_color_button_new (config, pspec->name,
g_param_spec_get_nick (pspec),
128, 24,
FALSE, 128, 24,
has_alpha ?
GIMP_COLOR_AREA_SMALL_CHECKS :
GIMP_COLOR_AREA_FLAT);

View file

@ -339,7 +339,7 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
/* mask color */
button = gimp_prop_color_button_new (config, "mask-color",
NULL,
NULL, FALSE,
128, 24,
GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button),

View file

@ -859,7 +859,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
gtk_size_group_add_widget (size_group, button);
button = gimp_prop_color_button_new (config, "foreground", _("Text Color"),
40, 24, GIMP_COLOR_AREA_FLAT);
TRUE, 40, 24, GIMP_COLOR_AREA_FLAT);
gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button),
GIMP_CONTEXT (options));

View file

@ -143,7 +143,7 @@ gimp_fill_editor_constructed (GObject *object)
{
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
"foreground",
_("Fill Color"),
_("Fill Color"), TRUE,
1, 24,
GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
@ -162,7 +162,7 @@ gimp_fill_editor_constructed (GObject *object)
{
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
"foreground",
_("Fill Color"),
_("Fill Color"), TRUE,
1, 24,
GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
@ -173,7 +173,7 @@ gimp_fill_editor_constructed (GObject *object)
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
"background",
_("Fill BG Color"),
_("Fill BG Color"), TRUE,
1, 24,
GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),

View file

@ -148,6 +148,7 @@ gimp_grid_editor_constructed (GObject *object)
color_button = gimp_prop_color_button_new (G_OBJECT (editor->grid), "fgcolor",
_("Change grid foreground color"),
FALSE,
GRID_EDITOR_COLOR_BUTTON_WIDTH,
GRID_EDITOR_COLOR_BUTTON_HEIGHT,
GIMP_COLOR_AREA_FLAT);
@ -162,6 +163,7 @@ gimp_grid_editor_constructed (GObject *object)
color_button = gimp_prop_color_button_new (G_OBJECT (editor->grid), "bgcolor",
_("Change grid background color"),
FALSE,
GRID_EDITOR_COLOR_BUTTON_WIDTH,
GRID_EDITOR_COLOR_BUTTON_HEIGHT,
GIMP_COLOR_AREA_FLAT);

View file

@ -347,6 +347,7 @@ static void gimp_prop_gegl_color_button_notify (GObject *config,
* gimp_prop_color_button_new:
* @config: #GimpConfig object to which property is attached.
* @property_name: Name of #GeglColor property.
* @user_context_aware: whether color selection should be context-aware.
* @title: Title of the #GimpColorPanel that is to be created
* @width: Width of color button.
* @height: Height of color button.
@ -365,6 +366,7 @@ GtkWidget *
gimp_prop_color_button_new (GObject *config,
const gchar *property_name,
const gchar *title,
gboolean user_context_aware,
gint width,
gint height,
GimpColorAreaType type)
@ -386,6 +388,8 @@ gimp_prop_color_button_new (GObject *config,
NULL);
button = gimp_color_panel_new (title, color, type, width, height);
gimp_color_panel_set_user_context_aware (GIMP_COLOR_PANEL (button),
user_context_aware);
g_clear_object (&color);
set_param_spec (G_OBJECT (button), button, param_spec);

View file

@ -49,6 +49,7 @@ GtkWidget * gimp_prop_layer_mode_box_new (GObject *config,
GtkWidget * gimp_prop_color_button_new (GObject *config,
const gchar *property_name,
const gchar *title,
gboolean user_context_aware,
gint width,
gint height,
GimpColorAreaType type);