PDA

View Full Version : Odd Alignment of Control



tdewitt274
August 8th, 2010, 21:11
I was wondering if anyone could tell me if the below behaviour is correct.

I have some code that I'm trying to center align (<position>insidetop</position>) a stringcontrol and then center a numbercontrol below it (<position>below</position>). When I do this, the control seems as if it inherits the width of the genericcontrol (480, not the declared value).



<genericcontrol name="pointsframe">
<frame>
<name>sheetgroup</name>
</frame>
<anchored>
<to>abilitiesframe</to>
<position>belowleft</position>
<offset>0,5</offset>
<size>
<width>480</width>
<height>60</height>
</size>
</anchored>
</genericcontrol>

<stringcontrol name="creationpoints">
<anchored>
<to>pointsframe</to>
<position>insidetop</position>
<offset>15,10</offset>
<size>
<width>68</width>
<height>20</height>
</size>
</anchored>
<font>sheetlabel</font>
<static>Creation</static>
<center />
</stringcontrol>
<numberfield name="crpoints">
<anchored>
<to>creationpoints</to>
<position>below</position>
<offset>0,0</offset>
<size>
<width>35</width>
<height>20</height>
</size>
</anchored>
<font>sheettext</font>
<frame>
<name>modifier</name>
<offset>5,4,5,4</offset>
</frame>
<keyeditframe>
<name>sheetfocus</name>
<offset>5,4,5,4</offset>
</keyeditframe>
</numberfield>


Is there a better way of doing this? I would like to keep the controls centered, as I plan to have one set of controls on the right and left.

Thanks in advance!

Czarisyn
August 8th, 2010, 21:13
usually when I have this issue, I just use <bounds>x,y,w,h</bounds>
its a pain in the arse but it does the job

Moon Wizard
August 9th, 2010, 18:45
Using the position tags will inherit width/height (depending on the tag) unless the position is a corner position. (i.e. position right inherits height, position insidetop inherits width, etc.)

Cheers,
JPG

tdewitt274
August 9th, 2010, 19:13
That makes sense for some of the crazy results I've experienced trying to troubleshoot.

I take it that there is no way to override the inheritance? One would assume (I know ;)) that declaring a height and width in a child would override.

Is there a more appropriate way of doing this than to rely on position?

Thanks!

Moon Wizard
August 9th, 2010, 19:33
When I need more fine-tuned control, I just use a corner position, specify bounds, or specify anchors with width/height. I actually use anchors more than position for the most part.

There is currently no way to override that behavior.

Cheers,
JPG

Zeus
August 9th, 2010, 19:42
I have always avoided using the short notation as it has always caused me issues. I much prefer using the full <anchored> approach with top, left and usually width, height explitictly defined.

I aso find its easier to 'adjust' the positioning, size in script if I have used the above notation. The other positionto approach has sometimes resulted in unpredictable results.

tdewitt274
August 10th, 2010, 05:11
DrZeuss,

Would it be possible to give an example snippet?

Thanks for the suggestions!

Zeus
August 10th, 2010, 08:37
Sure, how about this:



<genericcontrol name="pointsframe">
<frame>
<name>sheetgroup</name>
</frame>
<anchored>
<top>
<parent>abilitiesframe</parent>
<anchor>top</anchor>
<offset>5</offset>
</top>
<left>
<parent>abilitiesframe</parent>
<anchor>left</anchor>
<offset>5</offset>
</left>
<size>
<width>480</width>
<height>60</height>
</size>
</anchored>
</genericcontrol>

<stringcontrol name="creationpoints">
<anchored>
<top>
<parent>pointsframe </parent>
<anchor>top</anchor>
<offset>5</offset>
</top>
<left>
<parent>pointsframe</parent>
<anchor>left</anchor>
<offset>5</offset>
</left>
<size>
<width>68</width>
<height>20</height>
</size>
</anchored>
<font>sheetlabel</font>
<static>Creation</static>
<center />
</stringcontrol>

<numberfield name="crpoints">
<anchored>
<top>
<parent>creationpoints</parent>
<anchor>bottom</anchor>
<offset>2</offset>
</top>
<left>
<parent>creationpoints</parent>
<anchor>left</anchor>
</left>
<size>
<width>35</width>
<height>20</height>
</size>
</anchored>
<font>sheettext</font>
<frame>
<name>modifier</name>
<offset>5,4,5,4</offset>
</frame>
<keyeditframe>
<name>sheetfocus</name>
<offset>5,4,5,4</offset>
</keyeditframe>
</numberfield>

Stitched
August 10th, 2010, 12:52
It would be great if people posted code snippets and then the visual of what it produced. Would help a lot for other people who want to work with visual layouts in FG2 (assuming the code works). Something the "Anatomy of a Ruleset" does really well.

Zeus
August 10th, 2010, 13:17
Stitched - You make a good point. The challenge in this case, I simply used the code from tdewitt274 original post to show the alternative approach to anchoring.

Perhaps tdewitt274 can take a couple of screenshots to show the differences.

tdewitt274
August 10th, 2010, 13:35
Here's the screen shot of the issue (top) and resolution (bottom). I'll need to tweak the good Dr's code, but I don't have the time this morning.

Thanks, DrZeus and everyone else, I'll look into it further tonight.

I think my plan of attack will be to just keep doing my original plan until I have everything in a frame flowing correctly, then adjust the "odd" items. Even with my original code, I noticed that I will still need to do some alignment adjustments.

Thanks again!

Stitched
August 10th, 2010, 14:33
Awesome. Much clearer what the problem is and a good learning exercise.