Sie sind nicht angemeldet.

a.pu

Schüler

  • »a.pu« ist der Autor dieses Themas

Beiträge: 120

Beruf: software engineer, author of krpano syntax highlighting, bundler and style guide

  • Nachricht senden

1

Freitag, 14. Februar 2020, 20:00

Separate layer structure from layer properties

Hi!

I feel a bit stuck with a quite simple trick which does not work...

I've got this piece of code in one file:

Quellcode

1
2
3
4
5
6
7
8
<!-- STRUCTURE -->
<layer name="layer1">
	<layer name="layer2"/>
</layer>

<!-- PROPERTIES -->
<layer name="layer1" keep="true" --- and all layer properties go here --- />
<layer name="layer2" keep="true" --- and all layer properties go here ---/>


It does not work!
Layer 2 does not recognize layer1 as parent

I don't want to specify parent in "properties" part like this:

Quellcode

1
2
3
4
5
6
7
8
<!-- STRUCTURE -->
<layer name="layer1">
	<layer name="layer2"/>
</layer>

<!-- PROPERTIES -->
<layer name="layer1" keep="true" --- and all layer properties go here --- />
<layer name="layer2" keep="true" parent="layer1" --- and all layer properties go here ---/>


because "structure" part won't make sense this way. And I'd like to have structure part as a description of parent-child relationship between two layers.

I remember about property overriding but it seems not to work here.
What am I doing wrong?

2

Freitag, 14. Februar 2020, 20:31

It seems to me that you need to write this way?

Quellcode

1
2
3
4
5
6
7
8
<!-- STRUCTURE -->
<layer name="layer1" style="layer1" >
	<layer name="layer2" style="layer2" />
</layer>

<!-- PROPERTIES -->
<style name="layer1" keep="true" --- and all layer properties go here --- />
<style name="layer2" keep="true" --- and all layer properties go here ---/>

a.pu

Schüler

  • »a.pu« ist der Autor dieses Themas

Beiträge: 120

Beruf: software engineer, author of krpano syntax highlighting, bundler and style guide

  • Nachricht senden

3

Freitag, 14. Februar 2020, 20:42

It seems to me that you need to write this way?

Quellcode

1
2
3
4
5
6
7
8
<!-- STRUCTURE -->
<layer name="layer1" style="layer1" >
	<layer name="layer2" style="layer2" />
</layer>

<!-- PROPERTIES -->
<style name="layer1" keep="true" --- and all layer properties go here --- />
<style name="layer2" keep="true" --- and all layer properties go here ---/>


Viable idea, it will work
Now we need to figure out why overriding doesn't :)

4

Freitag, 14. Februar 2020, 20:53

What exactly? With this entry, layer1 parent of layer2

a.pu

Schüler

  • »a.pu« ist der Autor dieses Themas

Beiträge: 120

Beruf: software engineer, author of krpano syntax highlighting, bundler and style guide

  • Nachricht senden

5

Freitag, 14. Februar 2020, 20:56

What exactly? With this entry, layer1 parent of layer2


I mean overriding in my sample piece of code.
Yours will work well

6

Freitag, 14. Februar 2020, 21:04

In your version, the lower layers will overwrite the upper ones and there is no sense in the upper record

a.pu

Schüler

  • »a.pu« ist der Autor dieses Themas

Beiträge: 120

Beruf: software engineer, author of krpano syntax highlighting, bundler and style guide

  • Nachricht senden

7

Samstag, 15. Februar 2020, 08:22

In your version, the lower layers will overwrite the upper ones and there is no sense in the upper record


Klaus, help! *confused*

8

Samstag, 15. Februar 2020, 09:19

san7 already gave the answer

you cant define two elements with name="layer1" in the same xml, anyway. that should trigger an xml error.
that works only using two xml files, and then the second one overwrites the definition of the first one.

a.pu

Schüler

  • »a.pu« ist der Autor dieses Themas

Beiträge: 120

Beruf: software engineer, author of krpano syntax highlighting, bundler and style guide

  • Nachricht senden

9

Samstag, 15. Februar 2020, 14:35

san7 already gave the answer

you cant define two elements with name="layer1" in the same xml, anyway. that should trigger an xml error.
that works only using two xml files, and then the second one overwrites the definition of the first one.


there won't be an XML error if you define two layers with same names in one file.

I've checked my code in different projects where layer data is split to different files and it seems that parent-child relationship can not be overridden, only overwritten. In each case I had to specify "parent" property to make things work correct.

Shame shame, I wished parent property to be overrideable too...

10

Montag, 17. Februar 2020, 12:14

i guess the parenting / parent attribute is maybe a special case
but you can do that by an action, ofc

a.pu

Schüler

  • »a.pu« ist der Autor dieses Themas

Beiträge: 120

Beruf: software engineer, author of krpano syntax highlighting, bundler and style guide

  • Nachricht senden

11

Mittwoch, 26. Februar 2020, 13:43

Klaus, can you please comment on this topic?

12

Donnerstag, 27. Februar 2020, 10:09

Hi,

redefining xml elements to add or overwrite settings from them is possible,
but the xml tree-structure itself would need to be redefined too.

That 'flattening' of the xml structure to the named layers elements happens later after the xml parsing.

That means when you have a structure like this:

Quellcode

1
2
3
<layer name="layer1" style="layer1" >
	<layer name="layer2" style="layer2" />
</layer>


and want to add properites later, then the same xml structure need to be defined again:

Quellcode

1
2
3
<layer name="layer1" properties="here" ...>
	<layer name="layer2" properties="here" ... />
</layer>


See the 'vtourskin_design_ultra_light.xml' (in the 'tempaltes/xml/skin/' folder) as example - there this is done too.

Alternatively could use use actions to define the properties, then the xml structure doesn't matter anymore, e.g. this way:

Quellcode

1
2
3
4
5
<action autorun="preinit">
  set(layer[layer1], setting1=value1, setting2=value2, setting3=value3);
  set(layer[layer2], setting1=value1, setting2=value2, setting3=value3);
  ...
</action>


Best regards,
Klaus