Commit Graph

37 Commits

Author SHA1 Message Date
Benjamin Otte
67b893c5f8 win32 theme: Add a way to query border of theme parts 2016-02-17 04:49:26 +01:00
Benjamin Otte
f425b5549c win32: Add support for -gtk-win32-part-width/height to CSS
It's unused by now, but I want it for min-width of checks/radios.
2016-02-15 04:41:12 +01:00
Benjamin Otte
3b19db425e css: Add a number value handling win32 sizes 2016-02-15 04:41:12 +01:00
Benjamin Otte
93eec3e52f css: Implement transitions for numbers of different units
We now can transition from 10px to 100%.

Note that this requires a teensy tiny hack in
gtk_css_value_transition(), but so be it.
2016-02-13 04:49:08 +01:00
Benjamin Otte
4a9fa1e750 css: Add API to handle order when printing calc()
Also, add some tests and update old ones to print calc() statements
correctly.
2016-02-13 04:49:08 +01:00
Benjamin Otte
65dd9da44a css: Add support for sums to calc()
This requires adding code to do math on number values:
  gtk_css_number_value_multiply()
and
  gtk_css_number_value_try_add()
were added to achieve that.

Some tests are included.
2016-02-13 04:49:08 +01:00
Benjamin Otte
cd6dc954f2 css: Add initial support for calc()
So far, calc() only supports literals, ie it's completely useless.
2016-02-13 04:49:08 +01:00
Benjamin Otte
a52ecd2be6 css: Add gtk_css_number_value_can_parse()
Use it instead of _gtk_css_parser_has_number().

We need that once we introduce calc() support.
2016-02-13 04:49:08 +01:00
Benjamin Otte
b246d55472 css: Turn number values into a virtual type
GtkCssNumberValue is now a base class for numbers.

Actual numbers are now implemented in GtkCssDimensionValue. The name is
borrowed from the CSS spec, so there.
2016-02-13 04:49:07 +01:00
Benjamin Otte
e2d966eda5 cssnumbervalue: Remove gtk_css_number_value_get_unit()
This is in preparation for calc(), as calc(50% - 5px) is valid CSS
but has 2 units. Instead, add a function to query a value's dimension
(so we can differentiate lengths from numbers) and add a function to
query if the value contains percentages.
2016-02-13 04:49:07 +01:00
Benjamin Otte
5444442974 css: Convert numbers with GTK's dpi
Don't hardcode 96 for dpi, but instead use the value of the -gtk-dpi
property (that mirrors the GdkScreen's dpi if it wasn't set explicitly).

This makes these values scale when the large font setting in
control-center is enabled.
2016-02-05 14:52:09 +01:00
Benjamin Otte
e35e6abbb2 css: Properly convert em, ex and rem to pixels
The previous code converted to pt.
2016-02-05 14:52:09 +01:00
Benjamin Otte
0e7691c12e css: Add rem unit
Good luck, Lapo.
2016-02-04 19:37:44 +01:00
Chun-wei Fan
c0bc0a9ac2 gtkcssnumbervalue.c: Include fallback-c89.c to fix build
... on older Visual Studio versions, where isinf() is not available, and
copy the isinf() implementation from gdk/fallback-c89.c to
gtk/fallback-c89.c.
2015-12-23 19:23:17 +08:00
Matthias Clasen
d92111256f fix printing of numbers
We should be printing infinite, not inf.
2015-12-22 22:29:22 -05: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
Sebastian Keller
728bce2cf8 css: Move "border-style: none" special case to CssValueNumber
This fixes the background being shifted by the border-width even though
the border-style was none.
2015-01-21 16:20:42 +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
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
Alexander Larsson
7d21ec23f6 Add singleton for css number 1.0
This will be nice as this is will be the default for opacity.

https://bugzilla.gnome.org/show_bug.cgi?id=687842
2013-02-07 11:11:38 +01:00
Benjamin Otte
5942099f00 cssvalue: Parse font sizes properly
As the last CSS property, font-size now is a proper number (when it's
not a keyword).
2012-12-01 16:27:45 +01:00
Benjamin Otte
25271fe781 css: Move special case code for border widths
We need to store the border widths independant of them being set to 0 by
border styles, because otherwise we'd need to track that dependency and
recompute on changes, and I don't want to add more entries to
GtkCssDependencies just for this special case.

By moving the code that does the setting to 0 from the compute stage to
the query stage, we can achieve this.

Now we need to just be aware that the actual value stored is not set to
0 when we use gtk_css_computed_values_get_value().
2012-10-02 14:16:35 +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
e3fc081c5d cssvalue: Pass property ID to transition function
This is to allow animating arrays properly. I'm not really thrilled
about this solution (we leak propertys into the values again...), but
it's the best I can come up with - I prefer it to having N different
array types...
2012-09-03 12:54:14 +02:00
Benjamin Otte
012526241a cssvalue: First step of proper dependency tracking
Instead of using the EVERYTHING aka FIXME value for tdependencies,
actually compute the dependencies in a bunch of simple cases.
2012-08-28 15:42:24 +02:00
Benjamin Otte
0e2f35ed88 css: Introduce dependencies for value computations
When values are computed, they might depend on various other values and
we need to track this so we can update the values when those other
values change. This is the first step in making that happen.

This patch does not do any dependency tracking at all, instead it uses
GTK_CSS_DEPENDS_ON_EVERYTHING as a sort of FIXME.
2012-08-28 15:42:23 +02:00
Benjamin Otte
c0df9067dc css: Move special case for 0px borders
This is in preparation for the next commits.
2012-08-28 15:40:56 +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
9b953829fb css: Introduce _gtk_css_value_compute()
This commit is essentially a large reorganization. Instead of all value
subtypes having their own compute function, there is the general
_gtk_css_value_compute() function that then calls a vfunc on the
subtype.
2012-08-28 15:40:56 +02:00
Benjamin Otte
dcd54e20d1 css: Remove GtkCssNumber
It's completely replaced by GtkCssNumberValue now.
2012-04-17 08:59:19 +02:00
Benjamin Otte
1170ecfd2e cssvalue: Convert border-image-width to border value 2012-04-17 08:59:19 +02:00
Benjamin Otte
662d6787f3 css: Add <time> type to css number stuff 2012-04-17 08:59:16 +02:00
Benjamin Otte
31565139ba stylecontext: Convert _gtk_style_context_peek_property()
Take the property id instead of the name.
2012-04-17 08:59:15 +02:00
Benjamin Otte
1a9dfab825 cssvalue: Add _gtk_css_value_transition()
Returns a value that transitions between start and end or %NULL if the
values cannot be transitioned.

So far, all implementations but numbers and rgba return NULL.
2012-04-17 08:59:15 +02:00
Benjamin Otte
bf92f2f7ac cssvalue: Do a hacky conversion of font-size to a number value
Just store the value as px for now.

The font-size property needs a complete makeover anyway.
2012-04-17 08:59:15 +02:00
Benjamin Otte
a33df2d1d6 cssvalue: Split number values into their own class 2012-04-17 08:59:13 +02:00