forked from AuroraMiddleware/gtk
Merge branch 'initial-style' into 'master'
Make it easy to recognize initial style values See merge request GNOME/gtk!1375
This commit is contained in:
commit
27223f7956
@ -739,7 +739,7 @@ gtk_css_background_create_initial_values (void)
|
||||
{
|
||||
GtkCssBackgroundValues *values;
|
||||
|
||||
values = (GtkCssBackgroundValues *)gtk_css_values_new (GTK_CSS_BACKGROUND_VALUES);
|
||||
values = (GtkCssBackgroundValues *)gtk_css_values_new (GTK_CSS_BACKGROUND_INITIAL_VALUES);
|
||||
|
||||
values->background_color = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_COLOR, NULL, NULL, NULL);
|
||||
values->box_shadow = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BOX_SHADOW, NULL, NULL, NULL);
|
||||
@ -759,7 +759,7 @@ gtk_css_border_create_initial_values (void)
|
||||
{
|
||||
GtkCssBorderValues *values;
|
||||
|
||||
values = (GtkCssBorderValues *)gtk_css_values_new (GTK_CSS_BORDER_VALUES);
|
||||
values = (GtkCssBorderValues *)gtk_css_values_new (GTK_CSS_BORDER_INITIAL_VALUES);
|
||||
|
||||
values->border_top_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_STYLE, NULL, NULL, NULL);
|
||||
values->border_top_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_WIDTH, NULL, NULL, NULL);
|
||||
@ -790,7 +790,7 @@ gtk_css_outline_create_initial_values (void)
|
||||
{
|
||||
GtkCssOutlineValues *values;
|
||||
|
||||
values = (GtkCssOutlineValues *)gtk_css_values_new (GTK_CSS_OUTLINE_VALUES);
|
||||
values = (GtkCssOutlineValues *)gtk_css_values_new (GTK_CSS_OUTLINE_INITIAL_VALUES);
|
||||
|
||||
values->outline_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_STYLE, NULL, NULL, NULL);
|
||||
values->outline_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_WIDTH, NULL, NULL, NULL);
|
||||
@ -821,7 +821,7 @@ gtk_css_font_variant_create_initial_values (void)
|
||||
{
|
||||
GtkCssFontVariantValues *values;
|
||||
|
||||
values = (GtkCssFontVariantValues *)gtk_css_values_new (GTK_CSS_FONT_VARIANT_VALUES);
|
||||
values = (GtkCssFontVariantValues *)gtk_css_values_new (GTK_CSS_FONT_VARIANT_INITIAL_VALUES);
|
||||
|
||||
values->text_decoration_line = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_DECORATION_LINE, NULL, NULL, NULL);
|
||||
values->text_decoration_color = NULL;
|
||||
@ -842,7 +842,7 @@ gtk_css_animation_create_initial_values (void)
|
||||
{
|
||||
GtkCssAnimationValues *values;
|
||||
|
||||
values = (GtkCssAnimationValues *)gtk_css_values_new (GTK_CSS_ANIMATION_VALUES);
|
||||
values = (GtkCssAnimationValues *)gtk_css_values_new (GTK_CSS_ANIMATION_INITIAL_VALUES);
|
||||
|
||||
values->animation_name = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_NAME, NULL, NULL, NULL);
|
||||
values->animation_duration = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_DURATION, NULL, NULL, NULL);
|
||||
@ -861,7 +861,7 @@ gtk_css_transition_create_initial_values (void)
|
||||
{
|
||||
GtkCssTransitionValues *values;
|
||||
|
||||
values = (GtkCssTransitionValues *)gtk_css_values_new (GTK_CSS_TRANSITION_VALUES);
|
||||
values = (GtkCssTransitionValues *)gtk_css_values_new (GTK_CSS_TRANSITION_INITIAL_VALUES);
|
||||
|
||||
values->transition_property = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_PROPERTY, NULL, NULL, NULL);
|
||||
values->transition_duration = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_DURATION, NULL, NULL, NULL);
|
||||
@ -876,7 +876,7 @@ gtk_css_size_create_initial_values (void)
|
||||
{
|
||||
GtkCssSizeValues *values;
|
||||
|
||||
values = (GtkCssSizeValues *)gtk_css_values_new (GTK_CSS_SIZE_VALUES);
|
||||
values = (GtkCssSizeValues *)gtk_css_values_new (GTK_CSS_SIZE_INITIAL_VALUES);
|
||||
|
||||
values->margin_top = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_TOP, NULL, NULL, NULL);
|
||||
values->margin_left = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_LEFT, NULL, NULL, NULL);
|
||||
@ -898,7 +898,7 @@ gtk_css_other_create_initial_values (void)
|
||||
{
|
||||
GtkCssOtherValues *values;
|
||||
|
||||
values = (GtkCssOtherValues *)gtk_css_values_new (GTK_CSS_OTHER_VALUES);
|
||||
values = (GtkCssOtherValues *)gtk_css_values_new (GTK_CSS_OTHER_INITIAL_VALUES);
|
||||
|
||||
values->icon_source = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_SOURCE, NULL, NULL, NULL);
|
||||
values->icon_transform = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_TRANSFORM, NULL, NULL, NULL);
|
||||
|
@ -690,15 +690,26 @@ gtk_css_style_get_pango_font (GtkCssStyle *style)
|
||||
|
||||
static int values_size[] = {
|
||||
sizeof (GtkCssCoreValues),
|
||||
sizeof (GtkCssCoreValues),
|
||||
sizeof (GtkCssBackgroundValues),
|
||||
sizeof (GtkCssBackgroundValues),
|
||||
sizeof (GtkCssBorderValues),
|
||||
sizeof (GtkCssBorderValues),
|
||||
sizeof (GtkCssIconValues),
|
||||
sizeof (GtkCssIconValues),
|
||||
sizeof (GtkCssOutlineValues),
|
||||
sizeof (GtkCssOutlineValues),
|
||||
sizeof (GtkCssFontValues),
|
||||
sizeof (GtkCssFontValues),
|
||||
sizeof (GtkCssFontVariantValues),
|
||||
sizeof (GtkCssFontVariantValues),
|
||||
sizeof (GtkCssAnimationValues),
|
||||
sizeof (GtkCssAnimationValues),
|
||||
sizeof (GtkCssTransitionValues),
|
||||
sizeof (GtkCssTransitionValues),
|
||||
sizeof (GtkCssSizeValues),
|
||||
sizeof (GtkCssSizeValues),
|
||||
sizeof (GtkCssOtherValues),
|
||||
sizeof (GtkCssOtherValues)
|
||||
};
|
||||
|
||||
@ -746,7 +757,7 @@ gtk_css_values_copy (GtkCssValues *values)
|
||||
GtkCssValue **v, **v2;
|
||||
int i;
|
||||
|
||||
copy = gtk_css_values_new (values->type);
|
||||
copy = gtk_css_values_new (values->type - (values->type % 2));
|
||||
|
||||
v = GET_VALUES (values);
|
||||
v2 = GET_VALUES (copy);
|
||||
@ -767,7 +778,7 @@ gtk_css_values_new (GtkCssValuesType type)
|
||||
|
||||
values = (GtkCssValues *)g_malloc0 (values_size[type]);
|
||||
values->ref_count = 1;
|
||||
values->type = type;
|
||||
values->type = type - (type % 2);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
@ -37,16 +37,27 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef enum {
|
||||
GTK_CSS_CORE_VALUES,
|
||||
GTK_CSS_CORE_INITIAL_VALUES,
|
||||
GTK_CSS_BACKGROUND_VALUES,
|
||||
GTK_CSS_BACKGROUND_INITIAL_VALUES,
|
||||
GTK_CSS_BORDER_VALUES,
|
||||
GTK_CSS_BORDER_INITIAL_VALUES,
|
||||
GTK_CSS_ICON_VALUES,
|
||||
GTK_CSS_ICON_INITIAL_VALUES,
|
||||
GTK_CSS_OUTLINE_VALUES,
|
||||
GTK_CSS_OUTLINE_INITIAL_VALUES,
|
||||
GTK_CSS_FONT_VALUES,
|
||||
GTK_CSS_FONT_INITIAL_VALUES,
|
||||
GTK_CSS_FONT_VARIANT_VALUES,
|
||||
GTK_CSS_FONT_VARIANT_INITIAL_VALUES,
|
||||
GTK_CSS_ANIMATION_VALUES,
|
||||
GTK_CSS_ANIMATION_INITIAL_VALUES,
|
||||
GTK_CSS_TRANSITION_VALUES,
|
||||
GTK_CSS_TRANSITION_INITIAL_VALUES,
|
||||
GTK_CSS_SIZE_VALUES,
|
||||
GTK_CSS_OTHER_VALUES
|
||||
GTK_CSS_SIZE_INITIAL_VALUES,
|
||||
GTK_CSS_OTHER_VALUES,
|
||||
GTK_CSS_OTHER_INITIAL_VALUES,
|
||||
} GtkCssValuesType;
|
||||
|
||||
typedef struct _GtkCssValues GtkCssValues;
|
||||
|
@ -261,14 +261,25 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkCssBackgroundValues *background = boxes->style->background;
|
||||
GtkCssValue *background_image = background->background_image;
|
||||
const GdkRGBA *bg_color = gtk_css_color_value_get_rgba (background->background_color);
|
||||
const GtkCssValue *box_shadow = background->box_shadow;
|
||||
const gboolean has_bg_color = !gdk_rgba_is_clear (bg_color);
|
||||
const gboolean has_bg_image = _gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (background_image, 0)) != NULL;
|
||||
const gboolean has_shadow = !gtk_css_shadow_value_is_none (box_shadow);
|
||||
GtkCssValue *background_image;
|
||||
const GdkRGBA *bg_color;
|
||||
const GtkCssValue *box_shadow;
|
||||
gboolean has_bg_color;
|
||||
gboolean has_bg_image;
|
||||
gboolean has_shadow;
|
||||
gint idx;
|
||||
|
||||
if (background->base.type == GTK_CSS_BACKGROUND_INITIAL_VALUES)
|
||||
return;
|
||||
|
||||
background_image = background->background_image;
|
||||
bg_color = gtk_css_color_value_get_rgba (background->background_color);
|
||||
box_shadow = background->box_shadow;
|
||||
|
||||
has_bg_color = !gdk_rgba_is_clear (bg_color);
|
||||
has_bg_image = _gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (background_image, 0)) != NULL;
|
||||
has_shadow = !gtk_css_shadow_value_is_none (box_shadow);
|
||||
|
||||
/* This is the common default case of no background */
|
||||
if (!has_bg_color && !has_bg_image && !has_shadow)
|
||||
return;
|
||||
|
@ -657,6 +657,9 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
|
||||
|
||||
border = boxes->style->border;
|
||||
|
||||
if (border->base.type == GTK_CSS_BORDER_INITIAL_VALUES)
|
||||
return;
|
||||
|
||||
if (gtk_border_image_init (&border_image, boxes->style))
|
||||
{
|
||||
cairo_t *cr;
|
||||
|
Loading…
Reference in New Issue
Block a user