Пример #1
0
static gboolean
gtk_css_image_radial_equal (GtkCssImage *image1,
                            GtkCssImage *image2)
{
    GtkCssImageRadial *radial1 = GTK_CSS_IMAGE_RADIAL (image1);
    GtkCssImageRadial *radial2 = GTK_CSS_IMAGE_RADIAL (image2);
    guint i;

    if (radial1->repeating != radial2->repeating ||
            radial1->size != radial2->size ||
            !_gtk_css_value_equal (radial1->position, radial2->position) ||
            ((radial1->sizes[0] == NULL) != (radial2->sizes[0] == NULL)) ||
            (radial1->sizes[0] && radial2->sizes[0] && !_gtk_css_value_equal (radial1->sizes[0], radial2->sizes[0])) ||
            ((radial1->sizes[1] == NULL) != (radial2->sizes[1] == NULL)) ||
            (radial1->sizes[1] && radial2->sizes[1] && !_gtk_css_value_equal (radial1->sizes[1], radial2->sizes[1])) ||
            radial1->stops->len != radial2->stops->len)
        return FALSE;

    for (i = 0; i < radial1->stops->len; i++)
    {
        GtkCssImageRadialColorStop *stop1, *stop2;

        stop1 = &g_array_index (radial1->stops, GtkCssImageRadialColorStop, i);
        stop2 = &g_array_index (radial2->stops, GtkCssImageRadialColorStop, i);

        if (!_gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
                !_gtk_css_value_equal (stop1->color, stop2->color))
            return FALSE;
    }

    return TRUE;
}
Пример #2
0
static gboolean
gtk_css_image_linear_equal (GtkCssImage *image1,
                            GtkCssImage *image2)
{
  GtkCssImageLinear *linear1 = GTK_CSS_IMAGE_LINEAR (image1);
  GtkCssImageLinear *linear2 = GTK_CSS_IMAGE_LINEAR (image2);
  guint i;

  if (linear1->repeating != linear2->repeating ||
      linear1->side != linear2->side ||
      (linear1->side == 0 && !_gtk_css_value_equal (linear1->angle, linear2->angle)) ||
      linear1->stops->len != linear2->stops->len)
    return FALSE;

  for (i = 0; i < linear1->stops->len; i++)
    {
      GtkCssImageLinearColorStop *stop1, *stop2;

      stop1 = &g_array_index (linear1->stops, GtkCssImageLinearColorStop, i);
      stop2 = &g_array_index (linear2->stops, GtkCssImageLinearColorStop, i);

      if (!_gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
          !_gtk_css_value_equal (stop1->color, stop2->color))
        return FALSE;
    }

  return TRUE;
}
Пример #3
0
GtkBitmask *
_gtk_css_computed_values_advance (GtkCssComputedValues *values,
                                  gint64                timestamp)
{
    GtkBitmask *changed;
    GPtrArray *old_computed_values;
    GSList *list;
    guint i;

    gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
    gtk_internal_return_val_if_fail (timestamp >= values->current_time, NULL);

    values->current_time = timestamp;
    old_computed_values = values->animated_values;
    values->animated_values = NULL;

    list = values->animations;
    while (list)
    {
        GtkStyleAnimation *animation = list->data;

        list = list->next;

        _gtk_style_animation_set_values (animation,
                                         timestamp,
                                         GTK_CSS_COMPUTED_VALUES (values));

        if (_gtk_style_animation_is_finished (animation, timestamp))
        {
            values->animations = g_slist_remove (values->animations, animation);
            g_object_unref (animation);
        }
    }

    /* figure out changes */
    changed = _gtk_bitmask_new ();

    for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
    {
        GtkCssValue *old_animated, *new_animated;

        old_animated = old_computed_values && i < old_computed_values->len ? g_ptr_array_index (old_computed_values, i) : NULL;
        new_animated = values->animated_values && i < values->animated_values->len ? g_ptr_array_index (values->animated_values, i) : NULL;

        if (!_gtk_css_value_equal0 (old_animated, new_animated))
            changed = _gtk_bitmask_set (changed, i, TRUE);
    }

    if (old_computed_values)
        g_ptr_array_unref (old_computed_values);

    return changed;
}