void gtk_theming_background_render (GtkStyleContext *context, cairo_t *cr, gdouble x, gdouble y, gdouble width, gdouble height, GtkJunctionSides junction) { GtkThemingBackground bg; gint idx; GtkCssValue *background_image; GtkCssValue *box_shadow; const GdkRGBA *bg_color; background_image = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE); bg_color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR)); box_shadow = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BOX_SHADOW); /* This is the common default case of no background */ if (gtk_rgba_is_clear (bg_color) && _gtk_css_array_value_get_n_values (background_image) == 1 && _gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (background_image, 0)) == NULL && _gtk_css_shadows_value_is_none (box_shadow)) return; bg.context = context; _gtk_theming_background_init_context (&bg, width, height, junction); cairo_save (cr); cairo_translate (cr, x, y); /* Outset shadows */ _gtk_css_shadows_value_paint_box (box_shadow, cr, &bg.boxes[GTK_CSS_AREA_BORDER_BOX], FALSE); _gtk_theming_background_paint_color (&bg, cr, bg_color, background_image); for (idx = _gtk_css_array_value_get_n_values (background_image) - 1; idx >= 0; idx--) { _gtk_theming_background_paint_layer (&bg, idx, cr); } /* Inset shadows */ _gtk_css_shadows_value_paint_box (box_shadow, cr, &bg.boxes[GTK_CSS_AREA_PADDING_BOX], TRUE); cairo_restore (cr); }
void _gtk_theming_background_render (GtkThemingBackground *bg, cairo_t *cr) { gint idx; GtkThemingBackgroundLayer layer; GtkCssValue *background_image; background_image = _gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE); cairo_save (cr); cairo_translate (cr, bg->paint_area.x, bg->paint_area.y); _gtk_theming_background_paint_color (bg, cr, background_image); for (idx = _gtk_css_array_value_get_n_values (background_image) - 1; idx >= 0; idx--) { _gtk_theming_background_init_layer (bg, &layer, background_image, idx); _gtk_theming_background_paint_layer (bg, &layer, cr); } _gtk_theming_background_apply_shadow (bg, cr); cairo_restore (cr); }
gboolean _gtk_theming_background_has_background_image (GtkThemingBackground *bg) { GtkCssImage *image; GtkCssValue *value = _gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE); if (_gtk_css_array_value_get_n_values (value) == 0) return FALSE; image = _gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (value, 0)); return (image != NULL); }
static void _gtk_theming_background_paint_color (GtkThemingBackground *bg, cairo_t *cr, const GdkRGBA *bg_color, GtkCssValue *background_image) { gint n_values = _gtk_css_array_value_get_n_values (background_image); GtkCssArea clip = _gtk_css_area_value_get (_gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_CLIP), n_values - 1)); _gtk_rounded_box_path (&bg->boxes[clip], cr); gdk_cairo_set_source_rgba (cr, bg_color); cairo_fill (cr); }
static void transition_infos_set (TransitionInfo infos[GTK_CSS_PROPERTY_N_PROPERTIES], GtkCssValue *transitions) { guint i; for (i = 0; i < _gtk_css_array_value_get_n_values (transitions); i++) { GtkStyleProperty *property; GtkCssValue *prop_value; prop_value = _gtk_css_array_value_get_nth (transitions, i); if (g_ascii_strcasecmp (_gtk_css_ident_value_get (prop_value), "all") == 0) property = NULL; else { property = _gtk_style_property_lookup (_gtk_css_ident_value_get (prop_value)); if (property == NULL) continue; } transition_info_add (infos, property, i); } }
static void _gtk_theming_background_paint_color (GtkThemingBackground *bg, cairo_t *cr, GtkCssValue *background_image) { GtkRoundedBox clip_box; gint n_values = _gtk_css_array_value_get_n_values (background_image); GtkCssArea clip = _gtk_css_area_value_get (_gtk_css_array_value_get_nth (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_CLIP), n_values - 1)); clip_box = bg->border_box; _gtk_theming_background_apply_clip (bg, &clip_box, clip); cairo_save (cr); _gtk_rounded_box_path (&clip_box, cr); cairo_clip (cr); gdk_cairo_set_source_rgba (cr, &bg->bg_color); cairo_paint (cr); cairo_restore (cr); }
static void gtk_css_computed_values_create_css_animations (GtkCssComputedValues *values, GtkCssComputedValues *parent_values, gint64 timestamp, GtkStyleProviderPrivate *provider, GtkCssComputedValues *source) { GtkCssValue *durations, *delays, *timing_functions, *animations; GtkCssValue *iteration_counts, *directions, *play_states, *fill_modes; guint i; animations = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_NAME); durations = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_DURATION); delays = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_DELAY); timing_functions = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION); iteration_counts = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT); directions = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_DIRECTION); play_states = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE); fill_modes = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_FILL_MODE); for (i = 0; i < _gtk_css_array_value_get_n_values (animations); i++) { GtkStyleAnimation *animation; GtkCssKeyframes *keyframes; const char *name; name = _gtk_css_ident_value_get (_gtk_css_array_value_get_nth (animations, i)); if (g_ascii_strcasecmp (name, "none") == 0) continue; animation = gtk_css_computed_values_find_animation (values, name); if (animation) continue; if (source) animation = gtk_css_computed_values_find_animation (source, name); if (animation) { animation = _gtk_css_animation_copy (GTK_CSS_ANIMATION (animation), timestamp, _gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i))); } else { keyframes = _gtk_style_provider_private_get_keyframes (provider, name); if (keyframes == NULL) continue; keyframes = _gtk_css_keyframes_compute (keyframes, provider, values, parent_values); animation = _gtk_css_animation_new (name, keyframes, timestamp, _gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, i), 100) * G_USEC_PER_SEC, _gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, i), 100) * G_USEC_PER_SEC, _gtk_css_array_value_get_nth (timing_functions, i), _gtk_css_direction_value_get (_gtk_css_array_value_get_nth (directions, i)), _gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)), _gtk_css_fill_mode_value_get (_gtk_css_array_value_get_nth (fill_modes, i)), _gtk_css_number_value_get (_gtk_css_array_value_get_nth (iteration_counts, i), 100)); _gtk_css_keyframes_unref (keyframes); } values->animations = g_slist_prepend (values->animations, animation); } }