Commit Graph

218 Commits

Author SHA1 Message Date
Matthias Clasen
71ee4df357 css: Update affects flags for icons
We want to differentiate what requires recreating the
texture and what doesn't. In particular, the current
flags are not handling symbolic icons right.
2020-01-24 20:55:42 -05:00
Matthias Clasen
a38ba91e35 Add some static assertions
Add assertions that ensure the relationships between
css property IDs that we rely on are preserved.
2020-01-20 22:54:26 -05:00
Matthias Clasen
1efa39672b css: Simplify default values
We no longer need to create one-element arrays or
corners with two identical values.
2020-01-18 08:49:52 +01:00
Timm Bäder
45455f1bdb Remove GtkCssShadowsValue
Previously, we wrapped all GtkCssShadowValues in a GtkCssShadowsValue,
even if it was just one shadow. This causes an unnecessary bloat in
css values.

Make each GtkCssShadowValue able to handle multiple shadows instead, and
use gtk_css_shadow_value* API everywhere.
2020-01-18 08:49:52 +01:00
Timm Bäder
67991ed0f4 Remove GtkCssRgbaValue
The differenciation between a literal color value and an RGBA value
caused problems in various situations. Just treat the two the same but
don't allow access to the rgba value of a non-literal color value.

This gets rid of around 1.6k rgba values in the widget-factory.
2020-01-18 08:49:51 +01:00
Timm Bäder
8d15efba8f cssarrayvalue: Allow calling array API on non-arrays
Just allow calling _get_nth() and _get_n_values() on every kind of css
value. This way we can allow all values in places where only array
values would be allowed before.

This spares us around 1000 array values in the widget factory.

css value stats before:

GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssCornerValue: 556
GtkCssArrayValue: 1130
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
GtkCssColorValue: 1452
SUM: 9415

and after:

GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssCornerValue: 556
GtkCssArrayValue: 143
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
GtkCssColorValue: 1452
GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
SUM: 8428

9415 to 8428 is a 987 reduction (10.4%)
2020-01-18 08:49:51 +01:00
Matthias Clasen
6763443c5d css: Stop supporting builtin images
Change the default value of -gtk-icon-source to 'none',
and stop parsing 'builtin' as a value.
2020-01-10 14:32:06 -05:00
Timm Bäder
5c705ae9a5 cssrgbavalue: Add & use new_white() 2019-09-09 17:36:23 +02:00
Timm Bäder
ad1340cab4 cssrgbavalue: Add a singleton for transparent colors
The most common background color is no background color.
2019-09-09 17:36:23 +02:00
Matthias Clasen
8727b0708e css: Kerning affects text size
Thats the point. And we were missing the proper
flags to make GTK do the right thing when
changing font-kerning in the inspector.
2019-04-18 18:08:10 +00:00
Matthias Clasen
8400d8e75d css: Letterspacing affects text size
It does. And we were missing the proper
flags to make GTK do the right thing when
changing letter-spacing in the inspector.
2019-04-18 17:34:44 +00:00
Benjamin Otte
1cd9396154 css: Review error messages
... and move them from _gtk_css_parser_error() to the proper new error
message.
2019-04-12 19:34:28 +02:00
Benjamin Otte
f0d2f99239 cssparser: Add gtk_css_parser_consume_string()
Well, just rename _gtk_css_parser_read_string() for the new semantics,
but this sounds cooler.
2019-04-12 19:34:28 +02:00
Benjamin Otte
7ccec19501 parser: Get rid of _gtk_css_parser_is_eof()
Use gtk_css_parser_has_token() instead.
2019-04-12 19:34:28 +02:00
Benjamin Otte
93b643c44d css: Make font-weight an integer
This conforms to what Pango does and to the CSS4 spec. And it makes the
parsing code easier. So let's go for it.
2019-04-12 19:34:28 +02:00
Benjamin Otte
dbdb81f411 cssparser: Add gtk_css_parser_consume_ident()
And use it to fix the palette parser.
2019-04-12 19:34:28 +02:00
Benjamin Otte
76fb80f46c cssparser: Introduce gtk_css_parser_try_ident()
... and gtk_css_parser_has_function().
2019-04-12 19:34:28 +02:00
Benjamin Otte
684b6459f1 cssparser: Get rid of _gtk_css_parser_begins_with()
Replace it with calls to gtk_css_parser_has_token().
2019-04-12 19:34:28 +02:00
Matthias Clasen
12442bd1bf Remove support for -gtk-key-bindings: css property
This is no longer used.
2019-02-21 13:56:56 -05:00
Timm Bäder
0ae7c30105 Add & use GTK_CSS_AFFECTS_TRANSFORM
This avoids invalidating the size of all widgets when updating CSS
transforms.

In theory, we don't even have to allocate the widget itself, because we
didn't change its size. But we have no way to track that.
2019-02-21 19:47:28 +01:00
Timm Bäder
e2b9f3258e css: Add transform style property 2019-02-21 19:47:28 +01:00
Timm Bäder
3f126c7fc8 Remove GTK_CSS_AFFECTS_CLIP
Clips don't exist anymore and this flag is unused outside of the style
property definitions in gtkcssstylepropertyimpl.c
2018-07-17 17:33:47 +02:00
Benjamin Otte
0afdd84a2a css: Clipping changes don't need a queue_allocate() anymore
Now that queue_draw() isn't restricted to clip anymore, we don't need to
care about clip in the CSS engine either.

We do keep GTK_CSS_AFFECTS_CLIP around though because GtkWindow does
care for the window's size.
2018-04-09 20:20:55 +02:00
Benjamin Otte
927f48d289 css: Remove ability to query css images as cairo patterns
Nobody's doing that. And CSS Images are no longer using Cairo anyway.

If we wanted to support querying them (hint: we don't) we should be
using GdkPaintable.
2018-03-16 06:04:43 +01:00
Matthias Clasen
fb51e438e9 Implement font-variation-settings
This is a CSS font level 4 property that lets us
use font variation settings from css.
2018-01-03 13:07:55 -05:00
Matthias Clasen
559a2bf033 Add a missing include 2017-12-21 12:18:10 -05:00
Matthias Clasen
495d00e925 Fix a mis-merge 2017-12-20 10:36:25 -05:00
Matthias Clasen
22f9562928 Implement font-feature-settings
This is a missing part of the CSS font level 3 module.
2017-12-20 10:31:30 -05:00
Matthias Clasen
d005109133 Drop unused gtkcssstylefuncs.c
Clean up all the places where the header was still
included needlessly.
2017-11-30 18:46:54 -05:00
Benjamin Otte
129dc7d73b css: Add -gtk-icon-size
This will replace GtkIconSize in future patches.
2017-11-15 14:22:16 -05:00
Timm Bäder
4e24cb8588 css: Add GTK_CSS_AFFECTS_ICON_SIZE
And use it in GtkIconHelper. This way, we can avoid resizes when e.g.
the fg color of a symbolic icon changes.
2017-10-14 17:27:55 +02:00
Timm Bäder
9bc7581f1c css: Replace _AFFECTS_TEXT with _TEXT_SIZE and _TEXT_CLIP
It was used to mark css properties that affect widgets with text, but it
caused unnecessary invalidations. E.g. 'color' was marked as
AFFECTS_TEXT but changing just the color of a label should not
automatically queue a resize, which is what the code in
gtk_widget_real_style_updated does.

Replace this flag with GTK_CSS_AFFECTS_TEXT_SIZE and
GTK_CSS_AFFECTS_TEXT_CLIP, which GtkWidget can use only if the widget
actually has text.
2017-10-12 15:42:03 +02:00
Matthias Clasen
6859f0a6d1 css: Use enums instead of idents for font-variant properties
As Benjamin says, ident should only be used if any value
is valid, which is not the case here. So use enums instead,
which should also be more efficient. To handle the more
complicated cases like font-variant-ligatures, we have to
introduce flags-like values.
2017-09-18 23:22:38 -04:00
Matthias Clasen
f87dc24867 Fix a typo
The property is called font-variant-alternates, not -alternatives.
Correct this everywhere.
2017-09-18 18:10:08 -04:00
Matthias Clasen
92398bb1bb css: implement font-variant as a shorthand
Drop the current css2-style font-variant property and
replace it with a shorthand as specified in the css3 fonts
module. Currently, we fully support the font-variant-ligatures,
font-variant-position, font-variant-caps, font-variant-numeric
and font-variant-east-asian subproperties. font-variant-alternatives
is only partially supported.
2017-09-18 14:27:06 -04:00
Matthias Clasen
b91f3ce331 css: Implement font-variant-east-asian
This is translated to the corresponding OpenType features.
2017-09-18 14:26:57 -04:00
Matthias Clasen
8a7f2ca0be css: Implement font-variant-alternatives
This is only a partial implementation, since we don't support
@font-feature-values. The only supported value is historical-forms,
for now.
2017-09-18 14:26:57 -04:00
Matthias Clasen
b99cb70299 css: Implement font-variant-numeric
This gets translated to the corresponding OpenType features.
2017-09-18 14:26:57 -04:00
Matthias Clasen
8525afc408 css: Implement font-variant-caps
This gets translated to the corresponding OpenType features.
2017-09-18 14:26:57 -04:00
Matthias Clasen
01ed84fbef css: Implement font-variant-position
This gets translated to the corresponding OpenType features.
2017-09-18 14:26:57 -04:00
Matthias Clasen
c4cbe5feca css: Implement font-variant-ligatures
This gets translated into corresponding OpenType features.
2017-09-18 14:26:57 -04:00
Matthias Clasen
cee4622567 css: Implement font-kerning
This gets translated to the OpenType feature kern.
2017-09-18 14:26:57 -04:00
Matthias Clasen
793513993b Drop the gtk-key-bindings property
This has been deprecated for a while. Just use the -gtk-prefixed
name.
2017-09-17 16:57:53 -04:00
Matthias Clasen
226aee0828 Drop the icon-shadow property name
This has been deprecated for a while. Just use the -gtk-prefixed
name.
2017-09-17 16:57:53 -04:00
Matthias Clasen
de3179e7c0 Drop aliases for outline radius
The outline-{top,bottom}-{left,right}-radius names have been
deprecated for a while, so lets remove them. Everybody should
just use the -gtk-prefixed names for these properties.
2017-09-17 16:57:53 -04:00
Benjamin Otte
fb47a8d714 css: Remove deprecated number-as-pixels compatibility
Previously, for compatibility with GTK 3.0, we allowed specifying
numbers without units and interpreted them as pixels, even when the CSS
specification didn't.

Remove that now that we can break API.
2017-01-18 04:13:56 +01:00
Benjamin Otte
aa917ce3b7 css: Redo GtkCssAffects
We now have GTK_CSS_AFFECTS_CONTENT for properties that have an effect
on content rendering.

Using GTK_CSS_AFFECTS_ICON is wrong for icon-transform and icon-filter
as they don't change the icon, just how the icon is rendered, so we use
GTK_CSS_AFFECTS_CONTENT for those.

We also introduce GTK_CSS_AFFECTS_POSTEFFECT for opacity and filter -
properties that affect the whole drawing of the widget by applying an
effect after everything is said and done.
2017-01-01 19:53:36 +01:00
Benjamin Otte
959f80e6e9 css: Implement filter
So far, it's only implemented for widgets, not for gadgets.

Not sure how to do it for gadgets without conflicts for widget gadgets
yet...
2016-12-31 02:49:47 +01:00
Benjamin Otte
45fbc25e5e css: Remove -gtk-icon-effect
-gtk-icon-filter replaces this now.
2016-12-31 02:49:47 +01:00
Benjamin Otte
2645b5a7d7 gtk: Implement -gtk-icon-filter
This uses the new GskColorMatrixNode to implement a filter that applies
to icons. It's meant to replace -gtk-icon-effect.
2016-12-31 02:49:47 +01:00