Exemplo n.º 1
0
static GtkCssValue *
gtk_css_value_bg_size_compute (GtkCssValue             *value,
                               guint                    property_id,
                               GtkStyleProviderPrivate *provider,
			       int                      scale,
                               GtkCssComputedValues    *values,
                               GtkCssComputedValues    *parent_values,
                               GtkCssDependencies      *dependencies)
{
  GtkCssValue *x, *y;
  GtkCssDependencies x_deps, y_deps;

  if (value->x == NULL && value->y == NULL)
    return _gtk_css_value_ref (value);

  x_deps = y_deps = 0;
  x = y = NULL;

  if (value->x)
    x = _gtk_css_value_compute (value->x, property_id, provider, scale, values, parent_values, &x_deps);

  if (value->y)
    y = _gtk_css_value_compute (value->y, property_id, provider, scale, values, parent_values, &y_deps);

  *dependencies = _gtk_css_dependencies_union (x_deps, y_deps);

  return _gtk_css_bg_size_value_new (value->x ? x : NULL,
                                     value->y ? y : NULL);
}
Exemplo n.º 2
0
GtkCssValue *
_gtk_css_bg_size_value_parse (GtkCssParser *parser)
{
  GtkCssValue *x, *y;

  if (_gtk_css_parser_try (parser, "cover", TRUE))
    return _gtk_css_value_ref (&cover_singleton);
  else if (_gtk_css_parser_try (parser, "contain", TRUE))
    return _gtk_css_value_ref (&contain_singleton);

  if (_gtk_css_parser_try (parser, "auto", TRUE))
    x = NULL;
  else
    {
      x = _gtk_css_number_value_parse (parser,
                                       GTK_CSS_POSITIVE_ONLY
                                       | GTK_CSS_PARSE_PERCENT
                                       | GTK_CSS_PARSE_LENGTH);
      if (x == NULL)
        return NULL;
    }

  if (_gtk_css_parser_try (parser, "auto", TRUE))
    y = NULL;
  else if (!gtk_css_number_value_can_parse (parser))
    y = NULL;
  else
    {
      y = _gtk_css_number_value_parse (parser,
                                       GTK_CSS_POSITIVE_ONLY
                                       | GTK_CSS_PARSE_PERCENT
                                       | GTK_CSS_PARSE_LENGTH);
      if (y == NULL)
        {
          _gtk_css_value_unref (x);
          return NULL;
        }
    }

  return _gtk_css_bg_size_value_new (x, y);
}
Exemplo n.º 3
0
static GtkCssValue *
gtk_css_value_bg_size_transition (GtkCssValue *start,
                                  GtkCssValue *end,
                                  guint        property_id,
                                  double       progress)
{
  GtkCssValue *x, *y;

  if (start->cover)
    return end->cover ? _gtk_css_value_ref (end) : NULL;
  if (start->contain)
    return end->contain ? _gtk_css_value_ref (end) : NULL;

  if ((start->x != NULL) ^ (end->x != NULL) ||
      (start->y != NULL) ^ (end->y != NULL))
    return NULL;

  if (start->x)
    {
      x = _gtk_css_value_transition (start->x, end->x, property_id, progress);
      if (x == NULL)
        return NULL;
    }
  else
    x = NULL;

  if (start->y)
    {
      y = _gtk_css_value_transition (start->y, end->y, property_id, progress);
      if (y == NULL)
        {
          _gtk_css_value_unref (x);
          return NULL;
        }
    }
  else
    y = NULL;

  return _gtk_css_bg_size_value_new (x, y);
}
Exemplo n.º 4
0
static GtkCssValue *
gtk_css_value_bg_size_compute (GtkCssValue             *value,
                               guint                    property_id,
                               GtkStyleProviderPrivate *provider,
                               GtkCssStyle             *style,
                               GtkCssStyle             *parent_style)
{
  GtkCssValue *x, *y;

  if (value->x == NULL && value->y == NULL)
    return _gtk_css_value_ref (value);

  x = y = NULL;

  if (value->x)
    x = _gtk_css_value_compute (value->x, property_id, provider, style, parent_style);

  if (value->y)
    y = _gtk_css_value_compute (value->y, property_id, provider, style, parent_style);

  return _gtk_css_bg_size_value_new (value->x ? x : NULL,
                                     value->y ? y : NULL);
}