PDA

View Full Version : Anchor takin' me down...



Varsuuk
April 16th, 2018, 01:29
So, I am just about done - spent some time rearranging and decided to shrink the middle of the (working) attrbis number boxes section and move the (working) saving throw boxes to upper right.

So, as usual I toss up some guesstimates to see where it puts me before I minimal until like I want it.
But using the anchor vs position anchoring has never given me an issue like this. I suspect it is somehow related to something different about "the anchoring will be done to the window edges." part. But I thought it made sense and I grokked it. But nope.

See below:



<!-- Saving Throws -->
<label name="savingthrow_label">
<anchored height="25">>
<right parent="" anchor="right" offset="-15" />
<!-- <left parent="" anchor="right" offset="-15" /> -->
<top parent="attributeframe" />
</anchored>
<multilinespacing>12</multilinespacing>
<static textres="char_label_savingthrows" />
</label>


Attached is pics of how it appears based on above and above when I comment right and uncomment left...

I EXPECTED the first one to be what I wanted. (Hmm will remove multiline to see if affects this - have to go put kid to be first though, then TWD)

23042
23043

Any clue?

damned
April 16th, 2018, 02:54
Huh? Just anchor it the same way that you have anchored attribute bonuses.

Varsuuk
April 16th, 2018, 08:31
attribute bonuses are mainly setup with to/position setups once the initial key attribute (to hit) is setup within the attribute frame.

The saving throws, as might be inferred from the small excerpt is intended to be bound to right edge (with 15 pixel offset) so as to hug that edge.

I wanted that vs off the attributes bonus frame for a reason likely not worth explaining (part of it amounts to learning) yet. Let’s pretend I was starting with this label and I wanted it to be anchored to right edge of character sheet and below the “Race” line above it.

How could I get that to work using <top> plus <right> or <left> tags plus attributes (parent/anchor/offset)?

damned
April 16th, 2018, 08:54
Sorry I thought it was the word Saving Throws that wasnt right (its not!!!).

Have a look at Inventory sheet and see how that is done.

damned
April 16th, 2018, 08:56
But the reality is - these are 6 static values. There will always be 6, no more, no less, and they will always be in teh same place.
Just code them absolutely.

Varsuuk
April 16th, 2018, 09:17
I’ll look in morning (in bed atm) not sure what mean by inventory sheet... CoreRPG/MoreCore? Also, not sure what six values we are speaking of? At least unless change layout again, will be having 6 numeric boxes that will be rollable below that “Saving Throws” label in a single column.

I don’t use absolute placement anywhere on my sheet as of yet, instead it’s done with anchoring.

it’s really late and I probably just don’t get what you are telling me (eso since haven’t looked for the inv sheet) but I really figured this would be obvious from the anchoring wiki. Set my right edge of the label to the right edge of the window and put and offset to make it not be on the edge.

But I guess I don’t know how to write that?

Varsuuk
April 16th, 2018, 09:20
Oh, one more thing... didn’t feel it germane but rereading saw “they will always be in the same place” - actually I will have at min 2 and possibly 3 layouts on that right edge based on DM options.

But again, was just asking in vacuum how to pin it to a right edge with single edge anchors.

damned
April 16th, 2018, 11:42
<!-- Saving Throws -->
<label name="savingthrow_label">
<anchored height="25">>
<right parent="" anchor="right" offset="-15" />
<!-- <left parent="" anchor="right" offset="-15" /> -->
<top parent="attributeframe" />
</anchored>
<multilinespacing>12</multilinespacing>
<static textres="char_label_savingthrows" />
</label>



Look in the C&C ruleset.
They have used


<string_charabilitylabel name="strength_label">
<anchored to="strength" />
<static textres="strength" />
</string_charabilitylabel>
and

<template name="string_charabilitylabel">
<label>
<anchored position="lefthigh" width="85" height="20" />
<static />
<disabled />
<tooltip />
</label>
</template>

Varsuuk
April 16th, 2018, 13:59
Yes, those work fine. If I wasn’t on my train, I’d post the way did the abilities and would match that (ie using to & position)

I’m trying to find out why the top/bottom/left/right method is not working for me with parent=“” (the window)

i’m stumped. Those two you linked avoid the issue. I bet if I did to=“racesomethingstring” position=“bottomright” and a horiz,vertical offset it would work since I don’t reference window. And in the end, will probably go that route in any event once I learn about this. It’s just that I hate to leave gaps when I try to do something and it fails, I want to understand it.

There’s something I am doing wrong or there is a weirdly (unlikely) unreported bug in wiki anchor instructions. When I get home from work will try grepping for anchor=right or left where parent=“” which may never appear due to parent=“” is equivalent of not supplying parent at all. But that’s my next step if no clues.

damned
April 16th, 2018, 15:02
I dunno... but Moon Wizard does it the way I posted...

Trenloe
April 16th, 2018, 15:05
It's good practice to anchor controls and labels within a frame. Then you can easily move the frame around and the controls automatically move with the frame. It is not good practice to use purely static anchoring for standard controls - unless they are at the very top level.

Varsuuk
April 16th, 2018, 16:47
Damned/Trenloe - I got that it was best to use anchoring versus having literal X,Y positions. Note sure if that is what you mean or if I am still using what you call "static anchoring" unintentionally. Below you will see the (snippet of start/end) of the Attribute Bonus section.

I am not trying to give exact location on Window - I wanted to give OFFSET to window edge (see initial post "code" section) - As you can see below, I use the anchoring method. I still have to try/learn the "RELATIVE" option (reminded of that in Damned's damn fine video) to use that when appropriate/better.





...
<!-- Column One -->
<!-- Bonus to Hit -->
<number_bonusfield_base name="strength_bonustohit"
source="abilities.strength.bonustohit_melee">
<anchored>
<top parent="strength" anchor="top" />
<right parent="attributebonusframe" anchor="center" offset="-10" />
</anchored>
<!-- <description textres="TEXT-TO-DISPLAY-WHILE-DRAGGING" /> -->
</number_bonusfield_base>

<label_charattributebonus name="strength_bonustohit_label">
<anchored to="strength_bonustohit" />
<static textres="char_label_attribute_bonuses_bonus_to_hit" />
<tooltip textres="char_label_attribute_bonuses_bonus_to_hit_descript ion" />
</label_charattributebonus>

<!-- Open Doors -->
<number_bonusfield name="strength_opendoors"
source="abilities.strength.opendoors">
<anchored to="strength_bonustohit" />
<rollable />
</number_bonusfield>

<label_charattributebonus name="strength_opendoors_label">
<anchored to="strength_opendoors" />
<static textres="char_label_attribute_bonuses_open_doors" />
<tooltip textres="char_label_attribute_bonuses_open_doors_descriptio n" />
</label_charattributebonus>
...

<!-- Column Two -->

<!-- Armor Class Bonus -->
<number_bonusfield name="dexterity_armorbonus"
source="abilities.dexterity.armorbonus">
<anchored to="attributebonusframe" position="insidetopright"
offset="20">
<top parent="strength_bonustohit" anchor="top" />
</anchored>
</number_bonusfield>

<label_charattributebonus name="dexterity_armorbonus_label">
<anchored to="dexterity_armorbonus" />
<static textres="char_label_attribute_bonuses_armor_bonus" />
<tooltip textres="char_label_attribute_bonuses_armor_bonus_descripti on" />
</label_charattributebonus>

<!-- Hitpoint Bonus -->
<number_bonusfield name="constitution_hitpointbonus"
source="abilities.constitution.hitpointbonus">
<anchored to="dexterity_armorbonus" />
</number_bonusfield>

<label_charattributebonus name="constitution_hitpointbonus_label">
<anchored to="constitution_hitpointbonus" />
<static textres="char_label_attribute_bonuses_hitpoint_bonus" />
<tooltip textres="char_label_attribute_bonuses_hitpoint_bonus_descri ption" />
</label_charattributebonus>
...




OK - so I tried (on laptop at work....muhahaha) to do what I thought would work - even though still wanted to know why other doesn't... and IT didn't work so I have messed something else up that I haven't gotten so... guess back to drawing board...

I don't get it...


<frame_char name="classlevelframe">
<anchored to="contentanchor" position="insidetop" offset="0,10"
height="55"/>
</frame_char>

<stringcontrol_charclasslevel name="classlevel">
<anchored to="classlevelframe" position="insidetopleft" offset="15,12" width="255" height="20" />
</stringcontrol_charclasslevel>


<labelbelow name="class_level_label">
<anchored to="classlevel" />
<center />
<static textres="char_classes_and_level_title" />
</labelbelow>

<detailsbutton_charclasslevel name="detailbutton_classlevel">
<anchored to="classlevel" position="righthigh" offset="0,0" />
</detailsbutton_charclasslevel>

<stringu name="race">
<anchored to="classlevel" position="right" offset="40,0">
<right parent="classlevelframe" anchor="right" offset="-15" />
</anchored>
</stringu>

<labelbelow name="race_label">
<anchored to="race" />
<center />
<static textres="char_label_race" />
</labelbelow>

<linkifnotemptyfield>
<description field="race" />
</linkifnotemptyfield>

...

<!-- Saving Throws -->
<label name="savingthrow_label">
<anchored to="classlevelframe" position="belowright"
offset="0,10" height="25" />
<multilinespacing>12</multilinespacing>
<static textres="char_label_savingthrows" />
</label>


But doubt can look at it until maybe lunch. Atm, more confused, I refused to do it this way only because wanted to figure out why the way from Wiki wasn't working. So the good news is way from Wiki will likely work once I find my brain fart.

See result of using above now (no longer offsetting from parent window, using same style I always use instead):
23054

After uploading pick, I went - hmm maybe I AM flipping out and set it to opposite of what I thought, "belowleft" and it isn't what I want BUT it appears where I'd EXPECT it to appear, indented from left edge of frame and down a bit... why doesn't it do same from right?

Sorry for so much included code - I DID try to limit it to a few lines at first posts but I think I was being misunderstood on what I wanted to do. Also... I'm still a bit embarrassed at layout - learning this stuff and xml code will probably be more best-practice-y as I continue with this (I always go back to refactor as I work) ;)

Varsuuk
April 16th, 2018, 16:58
WOAH ... OK - writing these posts usually lead me to think to try something or realize something because it forces me to write the issue history and assumptions plus what I've tried. So, I stared at "label", nothing about that should have hidden data since it's low level not a template.

So what else..

Multiline... OK, well, that's a complication - let me remove that so I can rule it out, it works fine elsewhere but still... start small work up...

Removed multiline:
23055

So, I still do not know the issue and how to get my multiline setup (sure, can put 2 labels if all else fails) but NOW I have a clue where I didn't before posting these things ;)

Will now definitely work on it at lunch and ummm... get back to our replatforming project here at work /sheepishgrin ;)


PS: I was just trying to get placement alignment - once that was done was going to resize the window (and because I did all via anchors EVERYTHING moves correctly with it when I do it hehehe - love that) but didn't at time of the screenshot yet.

Trenloe
April 16th, 2018, 17:17
So, I stared at "label", nothing about that should have hidden data since it's low level not a template.
It is a template. It isn't a base FG control - it's not documented in the API reference. Search for template name="label" Like I've said before - don't assume! ;-)

Glad you got it working. You said in your first post you were going to remove multilinespacing - why didn't you?!? ;-)

Let's see in JPG has any ideas why that would make a difference to the anchoring behaviour...

Varsuuk
April 16th, 2018, 19:51
Yeah, I knew it wasn’t a base control since I searched and found it and came up with my own variation of the label template which I ended up not using. But I forgot and mule-umed:)

But yeah... about the multi line... blast, I DID forget to remove it to just do a sanity check.

No good excuse but yeah, I have so little free time I do all this coding at 1-3am or on commute or while listening to Pluralsight Java classes at work hehheh :(

Couple that with my bad memory/ADHD and I am go off too soon when sleeping on it would be better. I apologize for that. Hopefully soon I get to pay it forward :)

Moon Wizard
April 17th, 2018, 02:34
So...I sort of scanned through this thread, but there's a lot to digest, and it's unclear to me what's being asked.

If you are still looking for information, can I get some help distilling to a specific question I can answer? Something short and sweet? ;)

Thanks,
JPG

damned
April 17th, 2018, 03:03
So...I sort of scanned through this thread, but there's a lot to digest, and it's unclear to me what's being asked.

If you are still looking for information, can I get some help distilling to a specific question I can answer? Something short and sweet? ;)

Thanks,
JPG

Varsuuk doesnt do Short and he definitely doesnt do sweet!
It usually takes me two or three days to work out what the actual question is...
:bandit:

Varsuuk
April 17th, 2018, 03:09
Putting <multiline>#</multiline> within a <label> ... </label> pair makes it go wonky when anchoring To right edge of window regardless which of two methods used (position or anchor)

*drops mic*

Varsuuk
April 17th, 2018, 03:16
*** MOON READ PREVIOUS POST - it should be enough ***

I couldn’t resist Damned, my friend - but you are TOO RIGHT (again, I AM diagnosed with ADHD and have quite the hyperactive mind...ok...mouth)

Moon my initial example shows one of the two ways it goes wrong. Check out JUST the code section and attached pictures, forget the post itself the code and pic tell a 1024 words...

It seems to be he <multiline> which I’ve used elsewhere fine (will not explain to keep short)

I used multi to label stuff below a number box like:

Armor
Class

I played with multiline value, settled on 12 when control was 25 high because “looked right” not because fully got that rag.

But really, the short post is enough ;) no need to read this.

Regards,
Varsuuk
“There are 10 kinda of people in the world, those that understand binary and those who don’t”


*** MOON READ PREVIOUS POST - it should be enough ***

Moon Wizard
April 17th, 2018, 22:39
I think that the issue is that "right anchor" is being confused with "right aligned". Fantasy Grounds doesn't support right aligned text fields, only left aligned and center aligned.

You can "fake" right alignment for single-line text fields by using a right anchor with no left anchor. However, as soon as you add a left anchor or width (which is needed to do multiline), you can't fake that anymore. If you really want to do multiline right-aligned labels, you'll need to set up each line as its own string label.

Regards,
JPG

Varsuuk
April 18th, 2018, 02:51
Thanks - I too came to workaround of multiple labels.

Thing is I am not trying to reall RIGHT align the TEXT. I was trying to set the right edge of the stringcontrol to the right edge of the charsheet window. That's it.
My mistake is that I thought I didn't need to give it a width if I gave it a string:
Saving Throw => would make the left edge X pixels to left. X = # of pixels needed to display 12 characters.
Saving\nThrow => would make the left edge Y pixels to left. Y = # of pixels needed to display the bigger of 6 or 5 characters (pehaps it always defaults to width of first line and not "max of")

But that ISN'T the case - it may work in regular string control (again, I am not caring about forcing right aligned text - that was a SIDE-EFFECT I didn't even notice honestly lol, that's why took several rereads of what you wrote above to understand all this about "right aligning" and I erased my entire original reply) but with multiline it cannot figure out the automatic/inferred width. With single line, it infers the width.

I cannot try this today or at least not until VERY late - not near laptop where code is. But I will see if my original code works where I tell it a WIDTH as well (or give it a left align)


BTW, is there any rule of thumb when guestimating how wide to make a label when it is Font size X and N characters wide? I just adjust width until it stops cutting off the letters ;)
Thanks Moon for the help.

Varsuuk
April 18th, 2018, 04:38
OK - taxes are done - my civic gift of letting Fed/State have several thousand dollar interest free loan for a year or so is finis.

I quickly took the problematic code and just tossed in wdth="50" (just pulled out of air) and it works. So I am very glad I didn't just move one, because I learned what the true problem was, not the multiline alone but as JPG stated, the fact multiline cannot work without real or implied width.



<!-- Saving Throws -->
<label name="savingthrow_label">
<anchored width="60" height="25">>
<right parent="" anchor="right" offset="-15" />
<top parent="attributeframe" offset="5" />
</anchored>
<multilinespacing>12</multilinespacing>
<static textres="char_label_savingthrows" />
</label>


23078

I'll tidy up with overall and race frame width after I place the vertical numcontrols under the label so know better what to change.