FG Spreadshirt Swag
  1. #1
    Minty23185Fresh's Avatar
    Join Date
    Dec 2015
    Location
    Goldstone, CA, USA
    Posts
    1,211
    Blog Entries
    29

    Is the "expanding rectangle" of relation="relative" anchoring a dynamic anchor?

    In the Developer Guide wiki for the windowcontrol API Object, under the setAnchor() function (link) it's stated that:
    "When using a relation other than absolute, an anchor rectangle is internally tracked for the target control. Any "relative" controls anchoring to it will increase this rectangle to encompass that control as well.".

    Is the rectangle supposed to maintain a dynamic anchor?

    What I mean by this is, if I set up a relation relative anchor on say the right side of a control, then plop in a couple windowcontrols, (icons), employing the relative anchoring, is the right anchor supposed to say, rescale the offset, so that the anchor point stays in the (absolute) same position on the form?

    A picture might help. Here is a composite of screen shots. The left panel in the image is of the 5E Character Sheet. The red arrow is where I will "plop" in my controls. The panel to the right is how I want the window to look. Three different extensions have added an icon to the window.

    Untitled1.png

    In the above image, the ruleset definitions of the Name Title bar, have the left anchor essentially at the left edge of the window, the top anchor at the top of the window, and the right anchor at the right edge of the window with an offset that places it just to the left of the token control.

    To get the desired result, my extensions redefine the anchoring of the Name Title's right anchor to include relation="relative". They also redefine the left anchor of the Inspiration Title to have relation="relative". My extensions have the relative relation also on added icon's left anchors.

    So the plopping in part works great, each new control is easily placed where I want it, like ducks in a row. But the problem is, that unless I readjust the Name Title's right anchor offset for each plop, the right anchor (offset) just keeps on marching off to the right instead of staying put, just to the left of the token control.

    Untitled3.png

    Is this the desired behavior? What good is the expanding box if it doesn't keep it's anchor point position? Have I missed setting some property?

    If this is the desired behavior, then I guess I need to reset the offset as each icon loads (in the onInit()).

    Attached are the bare bone, illustrative, extensions. The two are in a single .zip file. Unzip the two folders into your extensions folder. The relevant files are the
    extensions\RELATIVITY TEST A\campaign\TEST_A_record_char.xml
    and the corresponding TEST B file

    the third extension is my Local Dice Tower extension that I am revising (NOTE the currently published copy doesn't work, it hasn't been updated). Here's an illustration of where to put the .zip file contents.

    Untitled2.png
    Attached Files Attached Files
    Last edited by Minty23185Fresh; April 28th, 2022 at 03:31.
    Current Projects:
    Always...
    Community Contributions:
    Extensions: Bardic Inspiration, Druid Wild Shapes, Local Dice Tower, Library Field Filters
    Tutorial Blog Series: "A Neophyte Tackles (coding) the FG Extension".

  2. #2
    When using the relative anchoring, the value of the width/height is added in the direction of the anchor's side.
    (Ex: relative anchoring to left side expands the "relative" position for the left anchor of that control by the offset specified plus the width of the control.)

    In your example Test A,
    * You are anchoring the nametitle to right relative to the "contentanchor" right anchor.
    * Then you are anchoring the inspirationtitle to right relative of the "name" right anchor.
    * And the remaining controls are relative anchoring to the "nametitle" right anchor.
    This means that the nametitle is not even using the same anchor as the other controls. Also, they are defined in the wrong order, because if you are laying out right-to-left, then the rightmost control must be defined first in order to advance the relative anchor appropriately (and the built-in 5E sheet has them defined in left-to-right order, since that isn't needed in the default sheet.)

    The recommended approach is to create an actual "anchor control" on the right side with absolute positioning; then use a right anchor that is relative to the left anchor of the "anchor control".
    Just see lots of examples in the built-in rulesets that use:
    * Every single list item in the built-in rulesets that use the "rightanchor" as an example of a build from right anchor.
    * Most specific record windows in the built-in rulesets use "columnanchor" as an example of a build from top anchor.

    While you can probably try playing around with other options, I'm not really going to dig into trying to figure out the exact behavior in the code, and try to figure a way to explain it all in a way that isn't confusing (as relative anchoring other than in simple cases above can get confusing very fast.) And, the options above just work with lots of examples.

    Regards,
    JPG

  3. #3
    Minty23185Fresh's Avatar
    Join Date
    Dec 2015
    Location
    Goldstone, CA, USA
    Posts
    1,211
    Blog Entries
    29
    Quote Originally Posted by Moon Wizard View Post
    ...
    In your example Test A,
    * You are anchoring the nametitle to right relative to the "contentanchor" right anchor.
    * Then you are anchoring the inspirationtitle to right relative of the "name" right anchor.
    * And the remaining controls are relative anchoring to the "nametitle" right anchor.
    This means that the nametitle is not even using the same anchor as the other controls. Also, they are defined in the wrong order, because if you are laying out right-to-left, then the rightmost control must be defined first in order to advance the relative anchor appropriately (and the built-in 5E sheet has them defined in left-to-right order, since that isn't needed in the default sheet.)
    ...
    I disagree with some of what you've said here, from the standpoint of my intent. I intended to add each extension's control to the right, building from left to right. So given your interpretation of my script I've botched it. And your assistance has helped me understand what I must do.

    I'll add, as you say, an "anchoring" control in between nametitle and token. Each extension's control will anchor left to right within the confines of the anchoring control. Thank you very much Moon Wizard.

    The problem I am trying to solve is, this methodology must accommodate one or more extensions. It is going to be used to prevent extensions from colliding as they add their controls to that area of the form. Right now I am aware of three. damned's Hero Points and Trust Issues extensions and my Local Dice Tower extension. The script must be robust enough to handle users choosing to employ any subset of them.

  4. #4
    Minty23185Fresh's Avatar
    Join Date
    Dec 2015
    Location
    Goldstone, CA, USA
    Posts
    1,211
    Blog Entries
    29
    A follow up please...

    A difficult, at least certainly for me, problem to overcome here is: two controls that are horizontally in line have to both be resizable. The nametitle (and name field below it) resize with a change of window width. The new "extensionanchor" control has to resize during load to accommodate the controls the extensions place within the expanding box (relation="relative").

    The nametitle is anchored on the left (essentially) to the window's left edge (with an offset), and on the right to the window's right edge (with an offset). Changing the window's width, causes the nametitle and name to shrink or grow with it.

    The new "extensionanchor" control is anchored on the right to the window's right edge and has a starting width of say 5.

    I believe I need to re-anchor the nametitle's right anchor to the left edge of the new "extensionanchor" control. This would allow automatic resizing of the nametitle as extensions attach their controls to the new "extensionanchor". The expanding box, attributable to the relative relation anchoring, allows resize for added extension controls.

    It doesn't seem as though "width" provides an implied anchor. When I try to re-anchor nametitle's right anchor (to "extensionanchor" left edge) nametitle is invisible, it has no width (I think because width doesn't provide an "anchorable" edge.)

    So I need an explicit ("anchorable") left edge for "extensionanchor".

    If I explicitly anchor the left edge of "extensionanchor" to the right edge of the nametitle (remember nametitle is anchored on the right to the right edge of the window), I have to programmatically adjust nametitle's right edge offset to make room for added extension controls.

    I can't anchor them to each other "extensionanchor's" left edge to nametitle's right edge. This is ambiguous and it doesn't work.

    I can't anchor "extensioncanchor" to itself either, the left edge to the right edge, with an offset, it's not allowed.

    Suggestions please?

    It looks like the only solution is for the extensions to programmatically readjust nametitle's right anchor's offset. Not the automation I had hoped for.

  5. #5
    Minty23185Fresh's Avatar
    Join Date
    Dec 2015
    Location
    Goldstone, CA, USA
    Posts
    1,211
    Blog Entries
    29
    <light_bulb>On!</light_bulb>

    Maybe a different solution is called for here. Especially considering space limitations.

    Icon cycler control to the rescue.
    Current Projects:
    Always...
    Community Contributions:
    Extensions: Bardic Inspiration, Druid Wild Shapes, Local Dice Tower, Library Field Filters
    Tutorial Blog Series: "A Neophyte Tackles (coding) the FG Extension".

  6. #6
    Actually, it seems like you really need a right anchor; because all the fixed size elements are on the right edge and expand leftward. Then, you would need to reorder the name and inspiration fields, as well as adjust the right anchor of both to be anchored to the rightanchor control via relative anchoring. Then, anything you insert between the rightanchor and the inspiration field would automatically layout.

    However, I don't feel that all of this is necessarily in the best interest of the end user, since all of these additional objects are eating up the real estate for the name field. I get what you are going for, but just the fact that several extension developers are fighting over the space to be "in front, at the top" in a very limited space makes me think that maybe those extension developers should rethink where those options live.

    Regards,
    JPG

  7. #7
    Looking at the sheet posted, there looks to be room in the bottom left and bottom right for icons. There also looks to be room, for now, between special defenses and the HP area that looks like a good place for a row of icons.

  8. #8
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,638
    Blog Entries
    1
    Hi Minty

    I havent had any time to put towards this issue just now. Is there relative anchoring I should use that would make my extension(s) more capable of integrating with others?

  9. #9
    Minty23185Fresh's Avatar
    Join Date
    Dec 2015
    Location
    Goldstone, CA, USA
    Posts
    1,211
    Blog Entries
    29
    Quote Originally Posted by DCrumb View Post
    Looking at the sheet posted, there looks to be room in the bottom left and bottom right for icons. There also looks to be room, for now, between special defenses and the HP area that looks like a good place for a row of icons.
    Agreed. There certainly is more real estate elsewhere.

  10. #10
    Minty23185Fresh's Avatar
    Join Date
    Dec 2015
    Location
    Goldstone, CA, USA
    Posts
    1,211
    Blog Entries
    29
    Quote Originally Posted by damned View Post
    Hi Minty

    I havent had any time to put towards this issue just now. Is there relative anchoring I should use that would make my extension(s) more capable of integrating with others?
    Relative anchoring looks like the ideal solution for ad hoc added controls. It doesn’t matter which order they’re added nor does it matter if they’re added at all (extensions not used). As long as all the ad hoc controls are anchored to the same parent control, the relative anchoring takes care of the housekeeping.

    But as Moon Wizard points out our situation is a bit more problematic since we have two expansions going on: adding controls and form expansion. To handle the later we need to redefine the anchoring for almost all the controls in that row.
    Last edited by Minty23185Fresh; May 3rd, 2022 at 23:05.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
STAR TREK 2d20

Log in

Log in