PDA

View Full Version : Relative control anchoring



mcortez
November 3rd, 2018, 23:32
I'm having a bit of a problem with relative control anchoring, I thought I understood how to use it - and in one quick test it worked fine. But now I'm having problems and I'm not sure where I'm going wrong -- or if the fact that I'm doing some layering/overriding of a window class from MoreCore, from an extension is causing problems.

So here's what I'm trying to do, and it works well enough with absolute positioning:

25199

And that's using this code:



<?xml version="1.0" encoding="iso-8859-1"?>
<root version="3.3" release="1">
<announcement text="Parameterized Rolls v.1 for MoreCore" font="emotefont" icon="rulesetlogo_CoreRPG" />
<properties>
<name>Parameterized Rolls</name>
<version>1</version>
<author>MCortez</author>
<description>Adds the ability to have a separate fields to provide parameters to rolls</description>
<ruleset><name>MoreCore</name></ruleset>
</properties>
<base>

<windowclass name="cli_rolls" merge="merge">
<sheetdata>
<simplestring name="name">
<anchored position="insidetopleft" offset="0,0" height="18">
<right parent="rightanchor" anchor="left" relation="relative" offset="-81" />
</anchored>
</simplestring>
<number_standard name="param1">
<anchored to="name" position="right" width="9" offset="4,0" />
<default>0</default>
</number_standard>
<number_standard name="param2">
<anchored to="name" position="right" width="9" offset="24,0" />
<default>0</default>
</number_standard>
<number_standard name="param3">
<anchored to="name" position="right" width="9" offset="44,0" />
<default>0</default>
</number_standard>
<button_rolls_type name="rollstype">
<anchored to="name" position="right" width="18" offset="60,0" />
</button_rolls_type>
</sheetdata>
</windowclass>

</base>
</root>


But when I try to switch to using relative positioning, this is what I end up with:

25200

And here's the the bits that I changed, which is basically just adding the relation parameter, and adjusting the offset parameter to be my desired spacing between controls:



<number_standard name="param1">
<anchored to="name" position="right" width="9" offset="4,0" relation="relative" />
<default>0</default>
</number_standard>
<number_standard name="param2">
<anchored to="name" position="right" width="9" offset="4,0" relation="relative" />
<default>0</default>
</number_standard>
<number_standard name="param3">
<anchored to="name" position="right" width="9" offset="4,0" relation="relative" />
<default>0</default>
</number_standard>
<button_rolls_type name="rollstype">
<anchored to="name" position="right" width="18" offset="4,0" relation="relative" />
</button_rolls_type>



Have I been staring into my monitor too long, and I'm missing something simple?

Any suggestions would be greatly appreciated!

damned
November 4th, 2018, 01:05
The existing code uses:


<button_rolls_type name="rollstype">
<anchored to="name" position="righthigh" width="18" offset="2" />
<script file="common/scripts/morecore_rolls.lua" />
</button_rolls_type>

So try using righthigh instead of right.

Ken L
November 4th, 2018, 01:21
The anchor param is made of multiple parts. Your relation args look good, but I think you forgot about your anchor 'base'

In this case, you want the "left" part of the control anchored to be relatively "right" of the previous control where both controls are anchored to the same parent.

ie:



<genericcontrol name="foobar">
<anchored width="10" height="10" />
<left parent="name" anchor="right" relation="relative" offset="5" />
<anchored/>
</genericcontrol>


Note that



<genericcontrol name="foobar" >
<anchored to="name" width="10" height="10" />
<left anchor="right" relation="relative" offset="5" />
<anchored/>
</genericcontrol>


is the same thing as it just forced the parent to each of the left/top/bottom/whatever if not specified. Anchoring is one of the poorly documented framework parameters.

mcortez
November 4th, 2018, 01:57
Thank you both!

Ken L - it looks like you hit it on the head, apparently the relation="relative" attribute only seems to work (at least in this situation) if an explicit <left/> <right/> <top/> or <bottom/> tag is provided.

I would have thought that it would be able to get that from position="right" attribute - seeing as it worked exactly as expected if I left out the relative attribute. The left side of the new control was being anchored to the right side of the anchoring object, and the offsets were behaving as expected - but as soon as that relative attribute got added, things went wonky...