Merge branch 'wip/otte/node-naming' into 'main'

node format: Allow naming textures and nodes

See merge request GNOME/gtk!5740
This commit is contained in:
Benjamin Otte 2023-03-29 11:28:15 +00:00
commit 1449e487d3
13 changed files with 622 additions and 189 deletions

View File

@ -6,15 +6,25 @@ The format is a text format that follows the [CSS syntax rules](https://drafts.c
The grammar of a node text representation using [the CSS value definition syntax](https://drafts.csswg.org/css-values-3/#value-defs) looks like this:
**document**: `<node>\*`
**node**: container { <document> } | `<node-name> { <property>* }`
**node**: container [ "name" ] { <document> } | `<node-type> [ "name" ] { <property>* }` | "name"
**property**: `<property-name>: <node> | <value> ;`
Each node has its own `<node-name>` and supports a custom set of properties, each with their own `<property-name>` and syntax. The following paragraphs document each of the nodes and their properties.
Each node has its own `<node-type>` and supports a custom set of properties, each with their own `<property-name>` and syntax. The following paragraphs document each of the nodes and their properties.
When serializing and the value of a property equals the default value, this value will not be serialized. Serialization aims to produce an output as small as possible.
To embed newlines in strings, use \A. To break a long string into multiple lines, escape the newline with a \.
# Names
### Nodes
Nodes can be given a name by adding a string after the `<node-type>` in their definition. That same node can then be used further down in the document by specifying just the name identifying the node.
### Textures
Just like nodes, textures can be referenced by name. When definining the named texture, the name has to be placed in front of the URL.
# Nodes
### container

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,17 @@
container {
texture-scale {
texture: url("some-10x10-image-with-content.png");
texture: url("data:image/png;base64,\
iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAABhWlDQ1BJQ0MgcHJvZmlsZQAAKJF9\
kT1Iw1AUhU9TpSIVBztIUchQxcEuKuKoVShChVArtOpg8tI/aNKQpLg4Cq4FB38Wqw4uzro6uAqC\
4A+Iq4uToouUeF9SaBHjhcf7OO+ew3v3AUKjwjSraxbQdNtMJxNiNrcqhl4RxDACGENUZpYxJ0kp\
+NbXPXVS3cV5ln/fn9Wn5i0GBETiWWaYNvEG8fSmbXDeJ46wkqwSnxOPm3RB4keuKx6/cS66LPDM\
iJlJzxNHiMViBysdzEqmRjxFHFM1nfKFrMcq5y3OWqXGWvfkLwzn9ZVlrtMaQhKLWIIEEQpqKKMC\
G3HadVIspOk84eOPun6JXAq5ymDkWEAVGmTXD/4Hv2drFSYnvKRwAuh+cZyPESC0CzTrjvN97DjN\
EyD4DFzpbX+1Acx8kl5va7EjoH8buLhua8oecLkDDD4Zsim7UpCWUCgA72f0TTlg4BboXfPm1jrH\
6QOQoVmlboCDQ2C0SNnrPu/u6Zzbvz2t+f0AkpVys4Vzl18AAAAGYktHRABmAGYAZge6Sm0AAAAJ\
cEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfnAx0BLBeZZvBWAAAAGXRFWHRDb21tZW50AENyZWF0\
ZWQgd2l0aCBHSU1QV4EOFwAAACpJREFUGNNj/M/A8J+BgYGB4T+EYmBkZMDGZ2IgErAQMgnGJ9pE\
xhHpRgAVIB4MSL68ZgAAAABJRU5ErkJggg==");
bounds: 0 0 100 100;
filter: nearest;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 334 B

After

Width:  |  Height:  |  Size: 339 B

View File

@ -221,6 +221,10 @@ node_parser_tests = [
'gradient-fail.errors',
'mask-modes.node',
'mask-modes.ref.node',
'node-names.node',
'node-names-everywhere.errors',
'node-names-everywhere.node',
'node-names-everywhere.ref.node',
'radial-gradient.node',
'radial-gradient.ref.node',
'repeating-linear-gradient.node',
@ -232,6 +236,9 @@ node_parser_tests = [
'shadow-fail.node',
'shadow-fail.ref.node',
'shadow-fail.errors',
'string-error.errors',
'string-error.node',
'string-error.ref.node',
'testswitch.node',
'text-fail.node',
'text-fail.ref.node',
@ -239,6 +246,7 @@ node_parser_tests = [
'texture-fail.node',
'texture-fail.ref.node',
'texture-fail.ref.errors',
'texture-names.node',
'texture-scale-filters.node',
'texture-scale-filters.ref.node',
'texture-scale-unknown-filter.errors',

View File

@ -0,0 +1,4 @@
<data>:1:1-6: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
<data>:3:3-8: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
<data>:5:5-10: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
<data>:2:11-16: error: GTK_CSS_PARSER_ERROR_FAILED

View File

@ -0,0 +1,9 @@
"foo";
container "foo" {
"foo";
container "foo" {
"foo";
}
"foo";
}
"foo";

View File

@ -0,0 +1,6 @@
container {
container "node1" {
}
"node1";
}
"node1";

View File

@ -0,0 +1,8 @@
color "node1" {
bounds: 0 0 10 10;
color: rgb(23,42,69);
}
transform {
transform: translate(20, 0);
child: "node1";
}

View File

@ -0,0 +1 @@
<data>:2:12-13: error: GTK_CSS_PARSER_ERROR_SYNTAX

View File

@ -0,0 +1,3 @@
debug {
message: 5;
}

View File

@ -0,0 +1,6 @@
debug {
child: color {
bounds: 0 0 50 50;
color: rgb(255,0,204);
}
}

View File

@ -0,0 +1,10 @@
texture {
bounds: 0 0 1 1;
texture: "texture1" url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWP4z8DwHwAFAAH/q842\
iQAAAABJRU5ErkJggg==\
");
}
texture {
bounds: 2 0 1 1;
texture: "texture1";
}