app: in GimpItemTreeView, use color tag of parent for children with no tag
Add gimp_item_get_merged_color_tag(), which returns the color tag of the nearest ancestor (including the current item) that has a color tag other than NONE. Use this function in GimpItemTreeView, instead of gimp_item_get_color_tag(), to set the cell color of items, so that item's with a NONE color tag inherit the color of their parent. Add a boolean "inherited" parameter to gimp_get_color_tag_color(), which indicates if the color tag is the item's actual color tag, or an inherited color tag, and modify the returned color accordingly, so that inherited colors are less saturated/lighter than non-inherited ones.
This commit is contained in:
@ -60,7 +60,7 @@ items_actions_setup (GimpActionGroup *group,
|
||||
gimp_action_group_set_action_context (group, action,
|
||||
gimp_get_user_context (group->gimp));
|
||||
|
||||
gimp_get_color_tag_color (value->value, &color);
|
||||
gimp_get_color_tag_color (value->value, &color, FALSE);
|
||||
gimp_action_group_set_action_color (group, action, &color, FALSE);
|
||||
}
|
||||
}
|
||||
@ -95,7 +95,7 @@ items_actions_update (GimpActionGroup *group,
|
||||
can_lock_pos = gimp_item_can_lock_position (item);
|
||||
|
||||
has_color_tag = gimp_get_color_tag_color (gimp_item_get_color_tag (item),
|
||||
&tag_color);
|
||||
&tag_color, FALSE);
|
||||
}
|
||||
|
||||
#define SET_SENSITIVE(action,condition) \
|
||||
|
@ -2203,6 +2203,24 @@ gimp_item_get_color_tag (GimpItem *item)
|
||||
return GET_PRIVATE (item)->color_tag;
|
||||
}
|
||||
|
||||
GimpColorTag
|
||||
gimp_item_get_merged_color_tag (GimpItem *item)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_ITEM (item), GIMP_COLOR_TAG_NONE);
|
||||
|
||||
if (gimp_item_get_color_tag (item) == GIMP_COLOR_TAG_NONE)
|
||||
{
|
||||
GimpItem *parent;
|
||||
|
||||
parent = GIMP_ITEM (gimp_viewable_get_parent (GIMP_VIEWABLE (item)));
|
||||
|
||||
if (parent)
|
||||
return gimp_item_get_merged_color_tag (parent);
|
||||
}
|
||||
|
||||
return gimp_item_get_color_tag (item);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_item_set_lock_content (GimpItem *item,
|
||||
gboolean lock_content,
|
||||
|
@ -339,6 +339,7 @@ void gimp_item_set_color_tag (GimpItem *item,
|
||||
GimpColorTag color_tag,
|
||||
gboolean push_undo);
|
||||
GimpColorTag gimp_item_get_color_tag (GimpItem *item);
|
||||
GimpColorTag gimp_item_get_merged_color_tag (GimpItem *item);
|
||||
|
||||
void gimp_item_set_lock_content (GimpItem *item,
|
||||
gboolean lock_content,
|
||||
|
@ -228,7 +228,7 @@ item_options_dialog_new (GimpImage *image,
|
||||
color_tag = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (radio),
|
||||
"gimp-item-data"));
|
||||
|
||||
if (gimp_get_color_tag_color (color_tag, &color))
|
||||
if (gimp_get_color_tag_color (color_tag, &color, FALSE))
|
||||
{
|
||||
GtkSettings *settings = gtk_widget_get_settings (dialog);
|
||||
gint w, h;
|
||||
|
@ -990,8 +990,10 @@ gimp_item_tree_view_insert_item (GimpContainerView *view,
|
||||
|
||||
item_view->priv->inserting_item = FALSE;
|
||||
|
||||
has_color = gimp_get_color_tag_color (gimp_item_get_color_tag (item),
|
||||
&color);
|
||||
has_color = gimp_get_color_tag_color (gimp_item_get_merged_color_tag (item),
|
||||
&color,
|
||||
gimp_item_get_color_tag (item) ==
|
||||
GIMP_COLOR_TAG_NONE);
|
||||
if (has_color)
|
||||
gimp_rgb_get_gdk_color (&color, &gdk_color);
|
||||
|
||||
@ -1406,12 +1408,15 @@ gimp_item_tree_view_color_tag_changed (GimpItem *item,
|
||||
|
||||
if (iter)
|
||||
{
|
||||
GimpRGB color;
|
||||
GdkColor gdk_color;
|
||||
gboolean has_color;
|
||||
GimpContainer *children;
|
||||
GimpRGB color;
|
||||
GdkColor gdk_color;
|
||||
gboolean has_color;
|
||||
|
||||
has_color = gimp_get_color_tag_color (gimp_item_get_color_tag (item),
|
||||
&color);
|
||||
has_color = gimp_get_color_tag_color (gimp_item_get_merged_color_tag (item),
|
||||
&color,
|
||||
gimp_item_get_color_tag (item) ==
|
||||
GIMP_COLOR_TAG_NONE);
|
||||
if (has_color)
|
||||
gimp_rgb_get_gdk_color (&color, &gdk_color);
|
||||
|
||||
@ -1419,6 +1424,13 @@ gimp_item_tree_view_color_tag_changed (GimpItem *item,
|
||||
view->priv->model_column_color_tag,
|
||||
has_color ? &gdk_color : NULL,
|
||||
-1);
|
||||
|
||||
children = gimp_viewable_get_children (GIMP_VIEWABLE (item));
|
||||
|
||||
if (children)
|
||||
gimp_container_foreach (children,
|
||||
(GFunc) gimp_item_tree_view_color_tag_changed,
|
||||
view);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1161,7 +1161,8 @@ gimp_get_message_icon_name (GimpMessageSeverity severity)
|
||||
|
||||
gboolean
|
||||
gimp_get_color_tag_color (GimpColorTag color_tag,
|
||||
GimpRGB *color)
|
||||
GimpRGB *color,
|
||||
gboolean inherited)
|
||||
{
|
||||
static const struct
|
||||
{
|
||||
@ -1183,6 +1184,7 @@ gimp_get_color_tag_color (GimpColorTag color_tag,
|
||||
};
|
||||
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
g_return_val_if_fail (color_tag < G_N_ELEMENTS (colors), FALSE);
|
||||
|
||||
if (color_tag > GIMP_COLOR_TAG_NONE)
|
||||
{
|
||||
@ -1192,6 +1194,12 @@ gimp_get_color_tag_color (GimpColorTag color_tag,
|
||||
colors[color_tag].b,
|
||||
255);
|
||||
|
||||
if (inherited)
|
||||
{
|
||||
gimp_rgb_composite (color, &(GimpRGB) {1.0, 1.0, 1.0, 0.2},
|
||||
GIMP_RGB_COMPOSITE_NORMAL);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,8 @@ void gimp_widget_set_accel_help (GtkWidget *widget
|
||||
|
||||
const gchar * gimp_get_message_icon_name (GimpMessageSeverity severity);
|
||||
gboolean gimp_get_color_tag_color (GimpColorTag color_tag,
|
||||
GimpRGB *color);
|
||||
GimpRGB *color,
|
||||
gboolean inherited);
|
||||
|
||||
void gimp_pango_layout_set_scale (PangoLayout *layout,
|
||||
double scale);
|
||||
|
Reference in New Issue
Block a user