Commit edbc8e4f authored by Benjamin Otte's avatar Benjamin Otte

cssvalue: Add a value for border-radius corner properties

... and convert those properties to this value.
parent 05f2249d
......@@ -425,6 +425,7 @@ gtk_private_h_sources = \
gtkcontainerprivate.h \
gtkcssarrayvalueprivate.h \
gtkcsscomputedvaluesprivate.h \
gtkcsscornervalueprivate.h \
gtkcsscustompropertyprivate.h \
gtkcsseasevalueprivate.h \
gtkcssenumvalueprivate.h \
......@@ -633,6 +634,7 @@ gtk_base_c_sources = \
gtkcontainer.c \
gtkcssarrayvalue.c \
gtkcsscomputedvalues.c \
gtkcsscornervalue.c \
gtkcsscustomproperty.c \
gtkcsseasevalue.c \
gtkcssenumvalue.c \
......
/* GTK - The GIMP Toolkit
* Copyright (C) 2011 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcsscornervalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
GtkCssValue *x;
GtkCssValue *y;
};
static void
gtk_css_value_corner_free (GtkCssValue *value)
{
_gtk_css_value_unref (value->x);
_gtk_css_value_unref (value->y);
g_slice_free (GtkCssValue, value);
}
static gboolean
gtk_css_value_corner_equal (const GtkCssValue *corner1,
const GtkCssValue *corner2)
{
return _gtk_css_value_equal (corner1->x, corner2->x)
&& _gtk_css_value_equal (corner1->y, corner2->y);
}
static GtkCssValue *
gtk_css_value_corner_transition (GtkCssValue *start,
GtkCssValue *end,
double progress)
{
GtkCssValue *x, *y;
x = _gtk_css_value_transition (start->x, end->x, progress);
if (x == NULL)
return NULL;
y = _gtk_css_value_transition (start->y, end->y, progress);
if (y == NULL)
{
_gtk_css_value_unref (x);
return NULL;
}
return _gtk_css_corner_value_new (x, y);
}
static void
gtk_css_value_corner_print (const GtkCssValue *corner,
GString *string)
{
_gtk_css_value_print (corner->x, string);
if (!_gtk_css_value_equal (corner->x, corner->y))
{
g_string_append_c (string, ' ');
_gtk_css_value_print (corner->y, string);
}
}
static const GtkCssValueClass GTK_CSS_VALUE_CORNER = {
gtk_css_value_corner_free,
gtk_css_value_corner_equal,
gtk_css_value_corner_transition,
gtk_css_value_corner_print
};
GtkCssValue *
_gtk_css_corner_value_new (GtkCssValue *x,
GtkCssValue *y)
{
GtkCssValue *result;
result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_CORNER);
result->x = x;
result->y = y;
return result;
}
GtkCssValue *
_gtk_css_corner_value_parse (GtkCssParser *parser)
{
GtkCssValue *x, *y;
x = _gtk_css_number_value_parse (parser,
GTK_CSS_POSITIVE_ONLY
| GTK_CSS_PARSE_PERCENT
| GTK_CSS_NUMBER_AS_PIXELS
| GTK_CSS_PARSE_LENGTH);
if (x == NULL)
return NULL;
if (!_gtk_css_parser_has_number (parser))
y = _gtk_css_value_ref (x);
else
{
y = _gtk_css_number_value_parse (parser,
GTK_CSS_POSITIVE_ONLY
| GTK_CSS_PARSE_PERCENT
| GTK_CSS_NUMBER_AS_PIXELS
| GTK_CSS_PARSE_LENGTH);
if (y == NULL)
{
_gtk_css_value_unref (x);
return NULL;
}
}
return _gtk_css_corner_value_new (x, y);
}
double
_gtk_css_corner_value_get_x (const GtkCssValue *corner,
double one_hundred_percent)
{
g_return_val_if_fail (corner != NULL, 0.0);
g_return_val_if_fail (corner->class == &GTK_CSS_VALUE_CORNER, 0.0);
return _gtk_css_number_value_get (corner->x, one_hundred_percent);
}
double
_gtk_css_corner_value_get_y (const GtkCssValue *corner,
double one_hundred_percent)
{
g_return_val_if_fail (corner != NULL, 0.0);
g_return_val_if_fail (corner->class == &GTK_CSS_VALUE_CORNER, 0.0);
return _gtk_css_number_value_get (corner->y, one_hundred_percent);
}
GtkCssValue *
_gtk_css_corner_value_compute (GtkCssValue *corner,
GtkStyleContext *context)
{
GtkCssValue *x, *y;
g_return_val_if_fail (corner->class == &GTK_CSS_VALUE_CORNER, NULL);
x = _gtk_css_number_value_compute (corner->x, context);
y = _gtk_css_number_value_compute (corner->y, context);
if (x == corner->x && y == corner->y)
{
_gtk_css_value_unref (x);
_gtk_css_value_unref (y);
return _gtk_css_value_ref (corner);
}
return _gtk_css_corner_value_new (x, y);
}
/*
* Copyright © 2012 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Alexander Larsson <alexl@gnome.org>
*/
#ifndef __GTK_CSS_CORNER_VALUE_PRIVATE_H__
#define __GTK_CSS_CORNER_VALUE_PRIVATE_H__
#include "gtkcssparserprivate.h"
#include "gtkcssvalueprivate.h"
G_BEGIN_DECLS
GtkCssValue * _gtk_css_corner_value_new (GtkCssValue *x,
GtkCssValue *y);
GtkCssValue * _gtk_css_corner_value_parse (GtkCssParser *parser);
double _gtk_css_corner_value_get_x (const GtkCssValue *corner,
double one_hundred_percent);
double _gtk_css_corner_value_get_y (const GtkCssValue *corner,
double one_hundred_percent);
GtkCssValue * _gtk_css_corner_value_compute (GtkCssValue *corner,
GtkStyleContext *context);
G_END_DECLS
#endif /* __GTK_CSS_CORNER_VALUE_PRIVATE_H__ */
......@@ -25,6 +25,7 @@
#include <math.h>
#include "gtkcssarrayvalueprivate.h"
#include "gtkcsscornervalueprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkcssimageprivate.h"
#include "gtkcssimagevalueprivate.h"
......@@ -132,70 +133,79 @@ parse_border_radius (GtkCssShorthandProperty *shorthand,
GtkCssParser *parser,
GFile *base)
{
GtkCssBorderCornerRadius borders[4];
GtkCssValue *x[4] = { NULL, }, *y[4] = { NULL, };
guint i;
for (i = 0; i < G_N_ELEMENTS (borders); i++)
for (i = 0; i < 4; i++)
{
if (!_gtk_css_parser_has_number (parser))
break;
if (!_gtk_css_parser_read_number (parser,
&borders[i].horizontal,
GTK_CSS_POSITIVE_ONLY
| GTK_CSS_PARSE_PERCENT
| GTK_CSS_NUMBER_AS_PIXELS
| GTK_CSS_PARSE_LENGTH))
return FALSE;
x[i] = _gtk_css_number_value_parse (parser,
GTK_CSS_POSITIVE_ONLY
| GTK_CSS_PARSE_PERCENT
| GTK_CSS_NUMBER_AS_PIXELS
| GTK_CSS_PARSE_LENGTH);
if (x[i] == NULL)
goto fail;
}
if (i == 0)
{
_gtk_css_parser_error (parser, "Expected a number");
return FALSE;
goto fail;
}
/* The magic (i - 1) >> 1 below makes it take the correct value
* according to spec. Feel free to check the 4 cases */
for (; i < G_N_ELEMENTS (borders); i++)
borders[i].horizontal = borders[(i - 1) >> 1].horizontal;
for (; i < 4; i++)
x[i] = _gtk_css_value_ref (x[(i - 1) >> 1]);
if (_gtk_css_parser_try (parser, "/", TRUE))
{
for (i = 0; i < G_N_ELEMENTS (borders); i++)
for (i = 0; i < 4; i++)
{
if (!_gtk_css_parser_has_number (parser))
break;
if (!_gtk_css_parser_read_number (parser,
&borders[i].vertical,
GTK_CSS_POSITIVE_ONLY
| GTK_CSS_PARSE_PERCENT
| GTK_CSS_NUMBER_AS_PIXELS
| GTK_CSS_PARSE_LENGTH))
return FALSE;
y[i] = _gtk_css_number_value_parse (parser,
GTK_CSS_POSITIVE_ONLY
| GTK_CSS_PARSE_PERCENT
| GTK_CSS_NUMBER_AS_PIXELS
| GTK_CSS_PARSE_LENGTH);
if (y[i] == NULL)
goto fail;
}
if (i == 0)
{
_gtk_css_parser_error (parser, "Expected a number");
return FALSE;
goto fail;
}
for (; i < G_N_ELEMENTS (borders); i++)
borders[i].vertical = borders[(i - 1) >> 1].vertical;
for (; i < 4; i++)
y[i] = _gtk_css_value_ref (y[(i - 1) >> 1]);
}
else
{
for (i = 0; i < G_N_ELEMENTS (borders); i++)
borders[i].vertical = borders[i].horizontal;
for (i = 0; i < 4; i++)
y[i] = _gtk_css_value_ref (x[i]);
}
for (i = 0; i < G_N_ELEMENTS (borders); i++)
for (i = 0; i < 4; i++)
{
values[i] = _gtk_css_value_new_from_border_corner_radius (&borders[i]);
values[i] = _gtk_css_corner_value_new (x[i], y[i]);
}
return TRUE;
fail:
for (i = 0; i < 4; i++)
{
if (x[i])
_gtk_css_value_unref (x[i]);
if (y[i])
_gtk_css_value_unref (y[i]);
}
return FALSE;
}
static gboolean
......@@ -603,19 +613,19 @@ unpack_border_radius (GtkCssShorthandProperty *shorthand,
GtkStateFlags state,
const GValue *value)
{
GtkCssBorderCornerRadius border;
GValue v = G_VALUE_INIT;
GtkCssValue *css_value;
guint i;
_gtk_css_number_init (&border.horizontal, g_value_get_int (value), GTK_CSS_PX);
border.vertical = border.horizontal;
g_value_init (&v, GTK_TYPE_CSS_BORDER_CORNER_RADIUS);
g_value_set_boxed (&v, &border);
css_value = _gtk_css_corner_value_new (_gtk_css_number_value_new (g_value_get_int (value), GTK_CSS_PX),
_gtk_css_number_value_new (g_value_get_int (value), GTK_CSS_PX));
for (i = 0; i < 4; i++)
_gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, i)), props, state, &v);
_gtk_style_properties_set_property_by_property (props,
_gtk_css_shorthand_property_get_subproperty (shorthand, i),
state,
css_value);
g_value_unset (&v);
_gtk_css_value_unref (css_value);
}
static void
......@@ -624,7 +634,6 @@ pack_border_radius (GtkCssShorthandProperty *shorthand,
GtkStyleQueryFunc query_func,
gpointer query_data)
{
const GtkCssBorderCornerRadius *top_left;
GtkCssStyleProperty *prop;
GtkCssValue *v;
int i = 0;
......@@ -632,11 +641,7 @@ pack_border_radius (GtkCssShorthandProperty *shorthand,
prop = GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("border-top-left-radius"));
v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
if (v)
{
top_left = _gtk_css_value_get_border_corner_radius (v);
if (top_left)
i = top_left->horizontal.value;
}
i = _gtk_css_corner_value_get_x (v, 100);
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, i);
......
......@@ -41,6 +41,7 @@
#include "gtkanimationdescription.h"
#include "gtkbindings.h"
#include "gtkcssarrayvalueprivate.h"
#include "gtkcsscornervalueprivate.h"
#include "gtkcsseasevalueprivate.h"
#include "gtkcssimagegradientprivate.h"
#include "gtkcssimageprivate.h"
......@@ -502,45 +503,15 @@ border_corner_radius_value_parse (GtkCssStyleProperty *property,
GtkCssParser *parser,
GFile *base)
{
GtkCssBorderCornerRadius corner;
if (!_gtk_css_parser_read_number (parser,
&corner.horizontal,
GTK_CSS_POSITIVE_ONLY
| GTK_CSS_PARSE_PERCENT
| GTK_CSS_NUMBER_AS_PIXELS
| GTK_CSS_PARSE_LENGTH))
return FALSE;
if (!_gtk_css_parser_has_number (parser))
corner.vertical = corner.horizontal;
else if (!_gtk_css_parser_read_number (parser,
&corner.vertical,
GTK_CSS_POSITIVE_ONLY
| GTK_CSS_PARSE_PERCENT
| GTK_CSS_NUMBER_AS_PIXELS
| GTK_CSS_PARSE_LENGTH))
return FALSE;
return _gtk_css_value_new_from_border_corner_radius (&corner);
return _gtk_css_corner_value_parse (parser);
}
static void
border_corner_radius_value_print (GtkCssStyleProperty *property,
const GtkCssValue *value,
GString *string)
static GtkCssValue *
border_corner_radius_value_compute (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *specified)
{
const GtkCssBorderCornerRadius *corner;
corner = _gtk_css_value_get_border_corner_radius (value);
_gtk_css_number_print (&corner->horizontal, string);
if (!_gtk_css_number_equal (&corner->horizontal, &corner->vertical))
{
g_string_append_c (string, ' ');
_gtk_css_number_print (&corner->vertical, string);
}
return _gtk_css_corner_value_compute (specified, context);
}
static GtkCssValue *
......@@ -1236,7 +1207,6 @@ _gtk_css_style_property_init_properties (void)
{
GtkCssBackgroundSize default_background_size = { GTK_CSS_NUMBER_INIT (0, GTK_CSS_PX), GTK_CSS_NUMBER_INIT (0, GTK_CSS_PX), FALSE, FALSE };
GtkCssBackgroundPosition default_background_position = { GTK_CSS_NUMBER_INIT (0, GTK_CSS_PERCENT), GTK_CSS_NUMBER_INIT (0, GTK_CSS_PERCENT)};
GtkCssBorderCornerRadius no_corner_radius = { GTK_CSS_NUMBER_INIT (0, GTK_CSS_PX), GTK_CSS_NUMBER_INIT (0, GTK_CSS_PX) };
GtkBorder border_of_ones = { 1, 1, 1, 1 };
GtkCssBorderImageRepeat border_image_repeat = { GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_STRETCH };
......@@ -1547,48 +1517,52 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-top-left-radius",
GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS,
GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
G_TYPE_NONE,
0,
border_corner_radius_value_parse,
border_corner_radius_value_print,
NULL,
query_simple,
assign_simple,
border_corner_radius_value_compute,
NULL,
NULL,
NULL,
_gtk_css_value_new_from_border_corner_radius (&no_corner_radius));
_gtk_css_corner_value_new (_gtk_css_number_value_new (0, GTK_CSS_PX),
_gtk_css_number_value_new (0, GTK_CSS_PX)));
gtk_css_style_property_register ("border-top-right-radius",
GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS,
GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
G_TYPE_NONE,
0,
border_corner_radius_value_parse,
border_corner_radius_value_print,
NULL,
query_simple,
assign_simple,
border_corner_radius_value_compute,
NULL,
NULL,
_gtk_css_value_new_from_border_corner_radius (&no_corner_radius));
NULL,
_gtk_css_corner_value_new (_gtk_css_number_value_new (0, GTK_CSS_PX),
_gtk_css_number_value_new (0, GTK_CSS_PX)));
gtk_css_style_property_register ("border-bottom-right-radius",
GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS,
GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
G_TYPE_NONE,
0,
border_corner_radius_value_parse,
border_corner_radius_value_print,
NULL,
query_simple,
assign_simple,
border_corner_radius_value_compute,
NULL,
_gtk_css_value_new_from_border_corner_radius (&no_corner_radius));
NULL,
NULL,
_gtk_css_corner_value_new (_gtk_css_number_value_new (0, GTK_CSS_PX),
_gtk_css_number_value_new (0, GTK_CSS_PX)));
gtk_css_style_property_register ("border-bottom-left-radius",
GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS,
GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
G_TYPE_NONE,
0,
border_corner_radius_value_parse,
border_corner_radius_value_print,
NULL,
query_simple,
assign_simple,
border_corner_radius_value_compute,
NULL,
NULL,
NULL,
_gtk_css_value_new_from_border_corner_radius (&no_corner_radius));
_gtk_css_corner_value_new (_gtk_css_number_value_new (0, GTK_CSS_PX),
_gtk_css_number_value_new (0, GTK_CSS_PX)));
gtk_css_style_property_register ("outline-style",
GTK_CSS_PROPERTY_OUTLINE_STYLE,
......
......@@ -34,7 +34,6 @@ G_DEFINE_BOXED_TYPE (TypeName, type_name, type_name ## _copy, g_free)
DEFINE_BOXED_TYPE_WITH_COPY_FUNC (GtkCssBackgroundSize, _gtk_css_background_size)
DEFINE_BOXED_TYPE_WITH_COPY_FUNC (GtkCssBackgroundPosition, _gtk_css_background_position)
DEFINE_BOXED_TYPE_WITH_COPY_FUNC (GtkCssBorderCornerRadius, _gtk_css_border_corner_radius)
DEFINE_BOXED_TYPE_WITH_COPY_FUNC (GtkCssBorderImageRepeat, _gtk_css_border_image_repeat)
typedef struct _GtkCssChangeTranslation GtkCssChangeTranslation;
......
......@@ -189,7 +189,6 @@ typedef enum /*< skip >*/ {
typedef struct _GtkCssNumber GtkCssNumber;
typedef struct _GtkCssBackgroundSize GtkCssBackgroundSize;
typedef struct _GtkCssBackgroundPosition GtkCssBackgroundPosition;
typedef struct _GtkCssBorderCornerRadius GtkCssBorderCornerRadius;
typedef struct _GtkCssBorderImageRepeat GtkCssBorderImageRepeat;
struct _GtkCssNumber {
......@@ -209,11 +208,6 @@ struct _GtkCssBackgroundPosition {
GtkCssNumber y;
};
struct _GtkCssBorderCornerRadius {
GtkCssNumber horizontal;
GtkCssNumber vertical;
};
struct _GtkCssBorderImageRepeat {
GtkCssBorderRepeatStyle vrepeat;
GtkCssBorderRepeatStyle hrepeat;
......@@ -221,12 +215,10 @@ struct _GtkCssBorderImageRepeat {
#define GTK_TYPE_CSS_BACKGROUND_SIZE _gtk_css_background_size_get_type ()
#define GTK_TYPE_CSS_BACKGROUND_POSITION _gtk_css_background_position_get_type ()
#define GTK_TYPE_CSS_BORDER_CORNER_RADIUS _gtk_css_border_corner_radius_get_type ()
#define GTK_TYPE_CSS_BORDER_IMAGE_REPEAT _gtk_css_border_image_repeat_get_type ()
GType _gtk_css_background_size_get_type (void);
GType _gtk_css_background_position_get_type (void);
GType _gtk_css_border_corner_radius_get_type (void);
GType _gtk_css_border_image_repeat_get_type (void);
GtkCssChange _gtk_css_change_for_sibling (GtkCssChange match);
......
......@@ -311,17 +311,6 @@ _gtk_css_value_new_from_background_position (const GtkCssBackgroundPosition *v)
return value;
}
GtkCssValue *
_gtk_css_value_new_from_border_corner_radius (const GtkCssBorderCornerRadius *v)
{
GtkCssValue *value;
value = gtk_css_value_new (GTK_TYPE_CSS_BORDER_CORNER_RADIUS);
value->u.ptr = g_boxed_copy0 (GTK_TYPE_CSS_BORDER_CORNER_RADIUS, v);
return value;
}
GtkCssValue *
_gtk_css_value_new_from_border_image_repeat (const GtkCssBorderImageRepeat *v)
{
......@@ -579,13 +568,6 @@ _gtk_css_value_get_border_image_repeat (const GtkCssValue *value)
return value->u.ptr;
}
const GtkCssBorderCornerRadius *
_gtk_css_value_get_border_corner_radius (const GtkCssValue *value)
{
g_return_val_if_fail (_gtk_css_value_holds (value, GTK_TYPE_CSS_BORDER_CORNER_RADIUS), NULL);
return value->u.ptr;
}
GtkGradient *
_gtk_css_value_get_gradient (const GtkCssValue *value)
{
......
......@@ -92,7 +92,6 @@ GtkCssValue *_gtk_css_value_new_from_theming_engine (GtkThemingEngine
GtkCssValue *_gtk_css_value_new_take_binding_sets (GPtrArray *array);
GtkCssValue *_gtk_css_value_new_from_background_size (const GtkCssBackgroundSize *v);
GtkCssValue *_gtk_css_value_new_from_background_position (const GtkCssBackgroundPosition *v);
GtkCssValue *_gtk_css_value_new_from_border_corner_radius (const GtkCssBorderCornerRadius *v);
GtkCssValue *_gtk_css_value_new_from_border_image_repeat (const GtkCssBorderImageRepeat *v);
void _gtk_css_value_init_gvalue (const GtkCssValue *value,
GValue *g_value);
......@@ -106,7 +105,6 @@ const char ** _gtk_css_value_get_strv (const
GtkSymbolicColor *_gtk_css_value_get_symbolic_color (const GtkCssValue *value);
const GtkCssBackgroundSize *_gtk_css_value_get_background_size (const GtkCssValue *value);
const GtkCssBackgroundPosition *_gtk_css_value_get_background_position (const GtkCssValue *value);
const GtkCssBorderCornerRadius *_gtk_css_value_get_border_corner_radius (const GtkCssValue *value);
const GtkCssBorderImageRepeat *_gtk_css_value_get_border_image_repeat (const GtkCssValue *value);
GtkGradient *_gtk_css_value_get_gradient (const GtkCssValue *value);
......
......@@ -18,6 +18,10 @@
#include "config.h"
#include "gtkroundedboxprivate.h"
#include "gtkcsscornervalueprivate.h"
#include "gtkcsstypesprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkthemingengineprivate.h"
#include <string.h>
......@@ -74,38 +78,38 @@ gtk_rounded_box_clamp_border_radius (GtkRoundedBox *box)
box->corner[GTK_CSS_BOTTOM_LEFT].vertical *= factor;
}
void
static void
_gtk_rounded_box_apply_border_radius (GtkRoundedBox *box,
GtkCssBorderCornerRadius **corner,
GtkCssValue **corner,
GtkJunctionSides junction)
{
if (corner[GTK_CSS_TOP_LEFT] && (junction & GTK_JUNCTION_CORNER_TOPLEFT) == 0)
{
box->corner[GTK_CSS_TOP_LEFT].horizontal = _gtk_css_number_get (&corner[GTK_CSS_TOP_LEFT]->horizontal,
box->box.width);
box->corner[GTK_CSS_TOP_LEFT].vertical = _gtk_css_number_get (&corner[GTK_CSS_TOP_LEFT]->vertical,
box->box.height);
box->corner[GTK_CSS_TOP_LEFT].horizontal = _gtk_css_corner_value_get_x (corner[GTK_CSS_TOP_LEFT],
box->box.width);
box->corner[GTK_CSS_TOP_LEFT].vertical = _gtk_css_corner_value_get_y (corner[GTK_CSS_TOP_LEFT],
box->box.height);
}
if (corner[GTK_CSS_TOP_RIGHT] && (junction & GTK_JUNCTION_CORNER_TOPRIGHT) == 0)
{
box->corner[GTK_CSS_TOP_RIGHT].horizontal = _gtk_css_number_get (&corner[GTK_CSS_TOP_RIGHT]->horizontal,
box->box.width);
box->corner[GTK_CSS_TOP_RIGHT].vertical = _gtk_css_number_get (&corner[GTK_CSS_TOP_RIGHT]->vertical,
box->box.height);
box->corner[GTK_CSS_TOP_RIGHT].horizontal = _gtk_css_corner_value_get_x (corner[GTK_CSS_TOP_RIGHT],
box->box.width);
box->corner[GTK_CSS_TOP_RIGHT].vertical = _gtk_css_corner_value_get_y (corner[GTK_CSS_TOP_RIGHT],
box->box.height);
}
if (corner[GTK_CSS_BOTTOM_RIGHT] && (junction & GTK_JUNCTION_CORNER_BOTTOMRIGHT) == 0)
{
box->corner[GTK_CSS_BOTTOM_RIGHT].horizontal = _gtk_css_number_get (&corner[GTK_CSS_BOTTOM_RIGHT]->horizontal,
box->box.width);
box->corner[GTK_CSS_BOTTOM_RIGHT].vertical = _gtk_css_number_get (&corner[GTK_CSS_BOTTOM_RIGHT]->vertical,
box->box.height);
box->corner[GTK_CSS_BOTTOM_RIGHT].horizontal = _gtk_css_corner_value_get_x (corner[GTK_CSS_BOTTOM_RIGHT],
box->box.width);
box->corner[GTK_CSS_BOTTOM_RIGHT].vertical = _gtk_css_corner_value_get_y (corner[GTK_CSS_BOTTOM_RIGHT],
box->box.height);
}
if (corner[GTK_CSS_BOTTOM_LEFT] && (junction & GTK_JUNCTION_CORNER_BOTTOMLEFT) == 0)
{
box->corner[GTK_CSS_BOTTOM_LEFT].horizontal = _gtk_css_number_get (&corner[GTK_CSS_BOTTOM_LEFT]->horizontal,
box->box.width);
box->corner[GTK_CSS_BOTTOM_LEFT].vertical = _gtk_css_number_get (&corner[GTK_CSS_BOTTOM_LEFT]->vertical,
box->box.height);
box->corner[GTK_CSS_BOTTOM_LEFT].horizontal = _gtk_css_corner_value_get_x (corner[GTK_CSS_BOTTOM_LEFT],
box->box.width);
box->corner[GTK_CSS_BOTTOM_LEFT].vertical = _gtk_css_corner_value_get_y (corner[GTK_CSS_BOTTOM_LEFT],
box->box.height);
}
gtk_rounded_box_clamp_border_radius (box);
......@@ -114,35 +118,24 @@ _gtk_rounded_box_apply_border_radius (GtkRoundedBox *box,
void
_gtk_rounded_box_apply_border_radius_for_context (GtkRoundedBox *box,
GtkStyleContext *context,
GtkStateFlags state,
GtkJunctionSides junction)
{
GtkCssBorderCornerRadius *corner[4];
guint i;
gtk_style_context_get (context, state,
/* Can't use border-radius as it's an int for
* backwards compat */
"border-top-left-radius", &corner[GTK_CSS_TOP_LEFT],
"border-top-right-radius", &corner[GTK_CSS_TOP_RIGHT],
"border-bottom-right-radius", &corner[GTK_CSS_BOTTOM_RIGHT],
"border-bottom-left-radius", &corner[GTK_CSS_BOTTOM_LEFT],
NULL);
GtkCssValue *corner[4];
_gtk_rounded_box_apply_border_radius (box, corner, junction);
corner[GTK_CSS_TOP_LEFT] = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS);
corner[GTK_CSS_TOP_RIGHT] = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS);
corner[GTK_CSS_BOTTOM_LEFT] = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS);
corner[GTK_CSS_BOTTOM_RIGHT] = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS);
for (i = 0; i < 4; i++)
g_free (corner[i]);
_gtk_rounded_box_apply_border_radius (box, corner, junction);
}
void