Commit Graph

70 Commits

Author SHA1 Message Date
Alexander Larsson
91dcf4000b css: Convert border style parsing to use enums 2011-11-25 15:36:08 +01:00
Alexander Larsson
d85aabe1e3 Rename GTK_CSS_REPEAT_STYLE_NONE to GTK_CSS_REPEAT_STYLE_STRETCH
This is a private type, and the CSS default value is "stretch", which
is how we were parsing and printing NONE anyway.

With this fix we can use the enum stuff for printing/parsing
2011-11-25 15:36:08 +01:00
Alexander Larsson
2a42fad145 css: Use enum parsing for background repeat style 2011-11-25 15:36:08 +01:00
Alexander Larsson
8fb4b13730 css: Break out enum parse/print helper
We need this to parse non-GValue enums
2011-11-25 15:36:08 +01:00
Alexander Larsson
3e24029415 css: Parse enums with new case-insensitive helper 2011-11-25 15:36:08 +01:00
Alexander Larsson
bc38cf1ff8 win32-theme: Support -gtk-win32-size CSS value 2011-11-17 12:30:08 +01:00
Alexander Larsson
abe6598a13 Add initial cut at win32 theme support for CSS
We now support -gtk-win32-theme-part(class,part,state) in background
and border-image CSS properties. This renders the corresponding
theme part using DrawThemeBackground() and acts as a base for a
CSS based windows theme.

Note that we build the parsing code even on non-win32 so that
all themese will parse the same on all arches. We draw pink instead
of the actual theme parts on non-win32 though.
2011-11-17 12:29:03 +01:00
Alexander Larsson
8b644b40b1 make _gtk_style_property_resolve copy the result to an output value
This is preparation for allowing it to return a newly created
value, rather than just copying one.
2011-11-17 12:27:23 +01:00
Alexander Larsson
c09148ca09 Add GtkStylePropertyContext and use it in when getting style properties
At the toplevel we have _gtk_theming_engine_get, which lets us pass
in a property context with (atm) the size to get the property for.
Then there is a lot of plumbing to push this down into the lower
layers of the style property code until finally hitting
the property resolvers.

I need this because I will be adding a property resolver for win32
theme parts, and they render differently depending on the size
(i.e. they don't scale linearly). The idea is that the code
to get the background properties will pass in the final size
and we will resolve the theme part specification to that particular
size.

If the old non-context calls are used we just hardcode a size
of 100x100.
2011-11-17 12:27:22 +01:00
Alexander Larsson
e953465e33 Save a generic boxes source in GtkImageBorder
We used to special handle gradient, but we want to be able to store
other sources (that will eventually resolve to cairo patterns).
For instance, this is needed to handle win32 theme part sources.
2011-11-17 12:27:21 +01:00
Marc-André Lureau
3b436eec6d css: start background-repeat
By default, a background image is stretched. Instead, it is worth to
have a tiled background.

This patch allows background surfaces to be repeated or not, and should
be compatible with future extensions and CSS.

https://bugzilla.gnome.org/show_bug.cgi?id=663522
2011-11-08 11:10:44 -05:00
Marc-André Lureau
ee7ac4fa44 Rename s/GtkCssRepeatStyle/GtkCssBorderRepeatStyle/g
https://bugzilla.gnome.org/show_bug.cgi?id=663522
2011-11-08 11:10:41 -05:00
Javier Jardón
0853ce3077 Use G_VALUE_INIT
Instead of an explicit { 0, } when declaring the variable.
2011-10-15 16:45:16 +01:00
Benjamin Otte
1e36e40e29 styleproperty: Allow 'transparent' keyword for background-color 2011-09-26 16:00:26 +02:00
Benjamin Otte
205d0eb4da styleproperty: Default to transparent background-color 2011-09-26 16:00:26 +02:00
Benjamin Otte
61525f0662 styleproperty: Use the long form to register background-color
We want to set a default value.
2011-09-26 16:00:25 +02:00
Benjamin Otte
71c3f7e93d styleproperty: Improve error message
We do dsupport that feature still and don't want to scare people into
thinking everything broke.
2011-08-26 16:26:28 +02:00
Chun-wei Fan
ad73ed298d Include C89 fallback code
gtk/gtkborderimage.c, gtk/gtklabel.c and gtk/gtkstyleproperty.c call
round() and/or rint(), which was only available in C99 compilers.

This adds the inclusion of the fallback implementation (gtk/fallback-c89.c)
to define these functions if they are not initially made available by the
compiler.

Also remove the rint() implementation in gtk/gtklabel.c as it is now in
the fallback implmentation.
2011-08-20 11:17:44 +08:00
Ignacio Casal Quinteiro
92e1d27475 Fix warning 2011-08-06 19:02:16 +02:00
Felix Riemann
e8486fdf71 gtkstyleproperty: fix small memory leak
The released value is a string array and thus g_free is not sufficient.

https://bugzilla.gnome.org/show_bug.cgi?id=655173
2011-07-23 21:40:59 +02:00
Benjamin Otte
9062060304 css: Don't print both border-image-repeat values when they're identical 2011-07-21 02:43:54 +02:00
Benjamin Otte
72bc10a61c css: Ensure that font shorthand parsing sets font name and size 2011-07-21 02:43:54 +02:00
Benjamin Otte
5a1e1579b3 styleproperty: dump image surfaces as PNG data URLs
We're not able to load that (yet?), but it's useful for producing
diffable test dumps.
2011-07-21 02:43:54 +02:00
Benjamin Otte
9e36bea907 styleproperty: An unnamed engine equals the default engine 2011-07-21 02:43:54 +02:00
Benjamin Otte
6aa000f65b styleproperties: Add unset functions for shorthands
This fixes calls to gtk_style_properties_unset_property() for
shorthand properties.

https://bugzilla.gnome.org/show_bug.cgi?id=654678
2011-07-19 11:58:22 +02:00
Benjamin Otte
68ebc77a9a styleproperties: Add an unset vfunc to style properties
This makes unsetting work for shorthands.
2011-07-19 11:58:22 +02:00
Benjamin Otte
7b2f8949dd styleproperty: Fix leak 2011-07-06 20:41:31 +02:00
Benjamin Otte
0d253b67f4 css: Make font property a shorthand
... and implement the CSS font properties:
- font-size
- font-style
- font-family
- font-weight
- font-variant

This is the second try at this. The first was backed out previously due
to bugginess. Let's hope this one survives a bit longer.

Also makes the font-family CSS test work again.
2011-06-15 12:52:53 +02:00
Benjamin Otte
3aa73bebea styleproperty: Add border-*-color style properties
And make border-color a shorthand
2011-06-13 15:01:52 +02:00
Benjamin Otte
abc239f444 styleproperty: The default border color is the normal color 2011-06-13 15:01:52 +02:00
Benjamin Otte
ba7d1c2104 styleproperty: Make default_value() take a state
Because of this, resolve() needs to take a state, too. This is so that
we can have default values depend on other values (like border color).
2011-06-13 15:01:52 +02:00
Benjamin Otte
3a1da7f09c styleproperty: Resolve NULL RGBAs to pink
.. instead of returning NULL and crashing.

Fixes no-colors reftest
2011-06-11 10:44:16 +02:00
Benjamin Otte
8861f6dbfb styleproperty: Fall back to default values, instead of recursing
Copy/paste error. The original commit message even explains this.
2011-06-11 10:38:23 +02:00
Benjamin Otte
7dbea94fd2 styleproperty: Add a default value func for border-image-width
This is necessary because we want to use NULL as the default value. But
the default value for borders is { 0, 0, 0, 0 } and not NULL.

Fixes border-image-gradient and border-image-repeat reftests.
2011-06-11 09:29:43 +02:00
Benjamin Otte
590aadd056 styleproperty: Parse shadow options in any order
The CSS spec allows random ordering of various properties, so we should,
too.
2011-06-11 09:29:43 +02:00
Cosimo Cecchi
6b5b5cb305 styleproperty: register the box-shadow property 2011-06-11 09:29:43 +02:00
Cosimo Cecchi
3d1407a01a border-image: add support for border-image-width too
It's useful to set a slice size != border-width, as backgrounds are
clipped to border-width too.

As slices can be half-transparent and overlap the background,
this would not fill the border box properly if we only use a single
property for specifying the width.

Also, this brings us even closer to CSS3.
2011-06-09 20:01:57 -04:00
Cosimo Cecchi
ef78d5b730 styleproperties: add an 'icon-shadow' style property
It's a custom property with the same semantics of text-shadow, which
works on icons and icon-like UI elements, such as spinners, arrows and
separators.
2011-06-09 23:17:09 +02:00
Benjamin Otte
9606633d94 border-image-repeat: Fix order of hrepeat and vrepeat 2011-06-09 05:51:54 +02:00
Benjamin Otte
c0a6b1fb90 borderimage: No need to resolve
border-image is a shorthand, so it's unpacked unresolved and repacked
resolved.
2011-06-09 05:51:54 +02:00
Cosimo Cecchi
4e95e6ae21 border-image: move private types to gtkcsstypes.c 2011-06-09 05:51:54 +02:00
Cosimo Cecchi
e3dd437b67 styleproperty: turn border-image into a shorthand property
It's composed by
- border-image-source: a cairo_pattern_t holding an image from file or a
  gradient
- border-image-slice: a GtkBorder containing the slice offsets to apply
  on the image
- border-image-repeat: a GtkRepeatType for the image

We deviate from pure CSS3 in the following ways:

* border-image-width is assumed to be always 1, i.e. always equal to
  what's specified by border-width. I don't think it's a particularly
  useful property to have, but we could add it later if needed.
* border-image-outset is absent, as we can't render outside of the
  allocation yet.

https://bugzilla.gnome.org/show_bug.cgi?id=651194
2011-06-09 05:51:54 +02:00
Benjamin Otte
2e6bb2a0c9 Revert "css: Make font property a shorthand"
The hack in gtk_style_context_get_font() was causing segfaults in
combobox code. This is not acceptable and I'm not awake enough to fix
it, so just reverting until it's fixed sanely is easiest.

This reverts commit cf6bfbdb17.
2011-06-02 02:31:44 +02:00
Benjamin Otte
1845849596 styleproperty: Move resolving code
Also, resolving now always succeeds - if it doesn't we fall back to the
default value right here, instead of later.
2011-06-02 02:03:52 +02:00
Benjamin Otte
cc3afc7c0f Revert "API: Add API to set style properties to be inherit"
Inheritance is now done using style property flags, so thereis no ned
anymore to clobber the pspec flags namespace.
Also, there is no need to expose this functionality in the public API
without exposing more of the styleproperty API.

This essentially reverts commit 9bfd3d2eec.
2011-06-02 02:03:52 +02:00
Benjamin Otte
9f0e993b60 styleproperty: Use the new flags for inheritance
Instead of gtk_style_param_set_inherit()
2011-06-02 02:03:52 +02:00
Benjamin Otte
4feddc6190 styleproperty: Add flags
This allows to set a bunch of specific features, like inheritance in
here, without having to molest the psec.
2011-06-02 02:03:52 +02:00
Benjamin Otte
fd4ffbb6da styleproperty: Add _gtk_style_property_is_inherit()
And use it instead of gtk_style_param_get_inherit()
2011-06-02 02:03:52 +02:00
Benjamin Otte
cf6bfbdb17 css: Make font property a shorthand
... and implement the CSS font properties:
- font-size
- font-style
- font-family
- font-weight
- font-variant
2011-06-02 02:03:52 +02:00
Benjamin Otte
8d77fcb2d5 styleproperty: Factor out the string print function
We print strings in lots of places.
2011-06-02 02:03:52 +02:00