Commit Graph

58 Commits

Author SHA1 Message Date
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
e0a01ba174 css: Redo for new parser
This commit is still way too big, but I couldn't make it smaller.

It transitions the old CSS parser to the new parser. CSS parsing is now
tokenized, everything else is probably still buggy.
2019-04-12 19:34:28 +02:00
Benjamin Otte
dce8c11b07 cssparser: Drop _gtk_css_parser_has_prefix()
Replace it with has_ident/has_function. The old function is a typical
string matching API, not a tokenizing one.
2019-04-12 19:34:28 +02:00
Benjamin Otte
96f9cbcabf cssimage: Make cross-fade() an array
The new spec at https://drafts.csswg.org/css-images-4/#cross-fade-function
allows infinite images to cross-fade and we want to, too.
2019-04-12 19:34:28 +02:00
Benjamin Otte
799cb39e08 Remove win32 themeing support
It was unused through all of GTK 3, so it is not worth supporting.

The best Windows themes do not make use of it at all.
2019-03-22 22:30:01 +01:00
Benjamin Otte
73b4a62f51 snapshot: Redo debug messages
Instead of every snapshot function having debug messages, have an
explicit gtk_snapshot_push_debug() function that appends a debug node.
2018-04-24 04:06:58 +02:00
Benjamin Otte
e3a717363b snapshot: Remove clip argument from gtk_snapshot_new()
It's not used anymore. And anybody who wants to have a clip on a
newly created snapshot can achieve that using gtk_snapshot_push_clip().
2018-04-05 14:56:38 +02:00
Benjamin Otte
1cfa88ed91 snapshot: Remove renderer
Now that there's no longer a need to keep the renderer around for Cairo
rendering, don't do that then.
2018-03-24 21:57:20 +01:00
Benjamin Otte
4beeb6173b cssimage: Add gtk_css_image_is_invalid()
Use that instead of hacks to guess when an image is considered invalid
according to https://drafts.csswg.org/css-images-4/#invalid-image

Also add a GtkCssImageInvalid that implements the behavior of invalid
images according to the CSS spec so thjat image implementations can
refer to that image.
2018-03-16 06:04:44 +01:00
Benjamin Otte
d774406573 cssimage: Implement dynamic values
No image actually implements it yet, but this is the plumbing.
2018-03-16 06:04:43 +01:00
Matthias Clasen
d55da3fd44 Use GtkSnapshot getters
We can avoid direct struct access and gtksnapshotprivate.h
everywhere.
2018-03-11 00:31:44 -05:00
Matthias Clasen
694f1d8ecd Stop using stack-allocated snapshots
Use the new/free api instead of init/finish
for GtkSnapshot.
2018-03-11 00:31:44 -05:00
Benjamin Otte
95ddb57562 cssimage: Get rid of draw vfunc
All remaining users of that vfunc now implement snapshot using cairo
render nodes (win32 and radial).

Also, GtkCssImageClass.snapshot is now NULL, so if a subclass doesn't
implement it, it will now crash.
Previously it would try to call the draw vfunc.
2018-02-17 08:04:43 +01:00
Benjamin Otte
83fb7a649f css: Merge GtkStyleProviderPrivate into GtkStyleProvider
This is just lots of renaming.

The interface remains private, so the public API does not change, apart
from removing the definition of the Interface object to avoid
subclassing.
2017-10-31 04:33:54 +01:00
Timm Bäder
848d55a187 cssimage: Plug a small memory leak 2017-02-17 18:23:10 +01:00
Benjamin Otte
6055028c96 snapshot: Rename append APIs
Instead of having gtk_snapshot_append_foo_node(), just have
gtk_snapshot_append_foo(). Nobody needs to know that this internally
uses nodes.
2017-01-13 04:46:09 +01:00
Benjamin Otte
a06b1ea1ba cssimage: Scale images to contain, not cover
Images with just an aspect ratio, but without a size, should be scaled
to be fully visible in the given area.
But we scaled them to completely cover the given area, which made them
partially invisible.

Reftest included.
2017-01-13 03:38:36 +01:00
Alexander Larsson
8cabfef9c9 GtkCSSImage: Avoid some type checks
The width/height/aspect getters are called a lot, and almost all
callers already verify it from _gtk_css_image_get_concrete_size (),
so just skip these checks.
2017-01-11 15:28:35 +01:00
Alexander Larsson
65ad2541d7 Snapshot: Only record names if inspector is recording
Otherwise we do a lot of allocations and vprintf calls which are
not used.
2017-01-11 10:22:40 +01:00
Benjamin Otte
429346fa7e cssimage: Implement a fallback draw() vfunc
... that chains into snapshot. This way, we can stop implementing draw()
in GtkCssImage subclasses and focus on snapshot() instead.
2016-12-20 18:01:10 +01:00
Emmanuele Bassi
4cbe079767 Use Graphene init macros for compound literals
The Graphene init macros can now be used for compound literals, which
means we need to update our mixed uses.
2016-11-21 16:21:38 +00:00
Benjamin Otte
6d9725f7fd snapshot: Add infrastructure to snapshot CSS images
Use this infrastructure to render builtin images. Which means from now
on, GtkCheckbutton, GtkSpinner and a few others use snapshots.
2016-11-16 20:51:53 +01:00
Matthias Clasen
d674e9c8fa Drop support for -gtk-gradient
The standard CSS radial-gradient can be used instead, and Adwaita
and HighContrast have been ported over.
2016-11-07 14:46:41 -05:00
Matthias Clasen
2e4b1e72f4 css: Support the image() notation
This lets us do fallback in case an image format is not
supported, and also lets us provide solid-color images.
We don't support image fragment notations.

See ttps://www.w3.org/TR/css3-images/#image-notation

https://bugzilla.gnome.org/show_bug.cgi?id=761318
2016-01-30 00:29:04 -05:00
Matthias Clasen
beec55a22b Add a way to load recolored icons in CSS
This can come in handy to load images that are not in an icon theme,
but still benefit from symbolic recoloring.

https://bugzilla.gnome.org/show_bug.cgi?id=760536
2016-01-14 13:51:15 -05:00
Matthias Clasen
f727ee5687 Implement CSS radial gradients
Implement parsing and drawing of radial gradients according to
http://www.w3.org/TR/css3-images/#radial-gradients.

Transitions are not implemented yet.
2016-01-04 13:59:24 -05:00
Cosimo Cecchi
b821f132d1 GtkCssImage: formatting fixes 2015-11-21 14:52:18 -08:00
Jasper St. Pierre
ce75c835e1 cssimage: Don't start a transition if the start and end are the same
Since a lot of Adwaita sets transition: all, it's easy to end up in a
state where we're making dummy transitions for all of the icons, most of
which we'll never be showing.
2015-08-02 12:57:31 -07:00
Benjamin Otte
da25771e58 cssvalue: Remove GtkCssDependencies
They are not used anymore.
2015-03-18 15:23:31 +01:00
Benjamin Otte
1116914ea0 css: Move scale to GtkStyleProviderPrivate
This way, we can remove it as a separate argument from
gtk_css_value_compute() and allow computation to only depend on one
thing: the style provider.
2015-02-06 11:26:31 +01:00
Benjamin Otte
572f46067f cssstyle: Rename GtkCssComputedValues => GtkCssStyle
This is literally just renaming of the object (and the associated source
files). No other changes are in there.
2015-01-07 14:26:46 +01:00
Benjamin Otte
27b9efbea2 cssimage: Fix size computation for -gtk-icontheme()
For images without a concrete size but with an aspect ratio, we took the
wrong code path.

(I even copied the documentation that said "Otherwise" but didn't put an
else clause there, go me!)
2014-07-23 18:51:26 +02:00
Benjamin Otte
633ec8184d css: Add support for -gtk-icontheme("icon-name")
This allows using icons from the icontheme as images in CSS. The
reasoning is that this allows to give the image control about how it's
scaled (by using the icon theme's scaling method. So we can get crisp
images at different resolutions.
2014-05-14 04:28:33 +02:00
Benjamin Otte
04b7c8e24e cssimage: Remove unused variables 2013-09-06 03:04:09 +02:00
Alexander Larsson
854f5818f8 Sync with changes in the cairo device-scale handling
The version of device scale that landed in upstream cairo
master already inherits the device scale in cairo_create_similar,
so no need to do that in gtk anymore.
2013-09-05 19:30:23 +02:00
Alexander Larsson
499cef1bb0 css: Inherit device scale in _gtk_css_image_get_surface
To handle hidpi support we need to make sure we don't
downscale scaled css images.

Note: If cairo_surface_create_similar starts doing this
by itself we need to back this out.
2013-08-05 16:14:25 +02:00
Alexander Larsson
48ff7d026e CSS: Add -gtk-scaled(image1,image2,...) support for hidpi assets 2013-07-03 14:39:25 +02:00
Alexander Larsson
af2c40bd54 css: Add a scale argument to css-value compute vfunc
We need to be able to compute different GtkCssImage values
depending on the scale, and we need this at compute time so that
we don't need to read any images other than the scale in used (to
e.g. calculate the image size). GtkStyleProviderPrivate is shared
for all style contexts, so its not right.
2013-07-03 14:39:25 +02:00
Benjamin Otte
016647edb1 cssimage: Add a warning for drawing empty images
width and height of an image must be > 0 for the image to get drawn.
It's up to the code further up to ensure that this is not happening.
2012-10-31 11:09:10 +01:00
Benjamin Otte
c13efbf8b0 cssimage: Add an equal vfunc
No implementations for it exist yet.
2012-10-31 11:09:10 +01:00
Benjamin Otte
12683da8f7 gtk: Make functions static that don't need to be non-static
Also remove the starting underscore from function names where
appropriate, as those functions are static now and not exported anymore.

This is part of a bunch of fixes for gcc complaining about
-Wmissing-declarations.
2012-10-02 19:32:51 +02:00
Benjamin Otte
a67bf5fde4 cssimage: Only create fades if we are actually fading 2012-10-02 14:16:36 +02:00
Benjamin Otte
558ffc24c2 cssimage: Make image transition a vfunc 2012-10-02 14:16:36 +02:00
Benjamin Otte
1454ba15ba css: Huge refactoring to avoid computing wrong values
Here's the shortest description of the bug I can come up with:
When computing values, we have 3 kinds of dependencies:
(1) other properties ("currentColor" or em values)
(2) inherited properties ("inherit")
(3) generic things from the theme (@keyframes or @define-color)
Previously, we passed the GtkStyleContext as an argument, because it
provided these 3 things using:
(1) _gtk_style_context_peek_property()
(2) _gtk_style_context_peek_property(gtk_style_context_get_parent())
(3) context->priv->cascade

However, this makes it impossible to lookup values other than the ones
accessible via _gtk_style_context_peek_property(). And this is exactly
what we are doing in gtk_style_context_update_cache(). So when the cache
updates encountered case (1), they were looking up the values from the
wrong style data.

So this large patch essentially does nothing but replace the
context argument in all compute functions with new arguments for the 3
cases above:
(1) values
(2) parent_values
(3) provider

We apparently have a lot of computing code.
2012-09-28 18:27:49 +02:00
Benjamin Otte
e1a1432bd3 cssimage: Implement dependencies for images 2012-08-28 15:42:25 +02:00
Benjamin Otte
9b4ed66218 css: Pass property_id to compute function
This is a reorganization of how value computing should be done.
Previously the GtkCssStyleProperty.compute vfunc was supposed to take
care of special cases when it needed those for computation. However,
this proved to be very complicated in cases where values were nested and
only the last value (of a common type) needed to be special cased.

A common example for this was the fallback handling for unresolvable
colors.

Now, we pass the property's ID along with all compute functions so we
can do the special casing where it's necessary.
Note that no actual changes happen in this commit. This will happen in
follow-ups.
2012-08-28 15:40:56 +02:00
Benjamin Otte
c9f01ffb43 cssimage: No need to pass base file anymore
The file is now part of the GtkCssParser
2012-05-11 16:42:12 +02:00
Benjamin Otte
d853a8f2f7 cssimage: Add GtkCssImageCrossFade
Supports the cross-fade() css notation the way the old CSS3 specs did.

The main reason for adding it is supporting image transitions though.
2012-04-17 08:59:16 +02:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Benjamin Otte
811e848832 css: Implement repeating linear gradients 2012-02-02 03:14:00 +01:00