mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-05 18:31:09 +00:00
color-swatch: add a color-light/color-dark style class for intensity
Themes might want to set different colors on the badge if the displayed color is light or dark. Use a style class for this when we set a color on the swatch.
This commit is contained in:
parent
46187037a3
commit
33e54e45be
@ -612,15 +612,31 @@ void
|
|||||||
gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
|
gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
|
||||||
const GdkRGBA *color)
|
const GdkRGBA *color)
|
||||||
{
|
{
|
||||||
|
GtkStyleContext *context;
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (GTK_WIDGET (swatch));
|
||||||
|
|
||||||
if (!swatch->priv->has_color)
|
if (!swatch->priv->has_color)
|
||||||
|
{
|
||||||
gtk_drag_source_set (GTK_WIDGET (swatch),
|
gtk_drag_source_set (GTK_WIDGET (swatch),
|
||||||
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
|
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
|
||||||
dnd_targets, G_N_ELEMENTS (dnd_targets),
|
dnd_targets, G_N_ELEMENTS (dnd_targets),
|
||||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_style_context_remove_class (context, "color-light");
|
||||||
|
gtk_style_context_remove_class (context, "color-dark");
|
||||||
|
}
|
||||||
|
|
||||||
swatch->priv->has_color = TRUE;
|
swatch->priv->has_color = TRUE;
|
||||||
swatch->priv->color = *color;
|
swatch->priv->color = *color;
|
||||||
|
|
||||||
|
if (INTENSITY (swatch->priv->color.red, swatch->priv->color.green, swatch->priv->color.blue) > 0.5)
|
||||||
|
gtk_style_context_add_class (context, "color-light");
|
||||||
|
else
|
||||||
|
gtk_style_context_add_class (context, "color-dark");
|
||||||
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (swatch));
|
gtk_widget_queue_draw (GTK_WIDGET (swatch));
|
||||||
g_object_notify (G_OBJECT (swatch), "rgba");
|
g_object_notify (G_OBJECT (swatch), "rgba");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user