PDA

View Full Version : Is it possible to change the bounds of a windowclass dynamicly ?



drvolk
July 7th, 2015, 07:52
Hello,

within my "localize extension" project (i am sill working on it) i desided to change the horizonzal tabs into vertical tabs (in the CoreRPG they were used in the charactersheet, npc record sheet and party sheet).
So instead using as tab a icon bitmap with a textinformation in it, i can use a icon bitmap with a textwidget on it, which contains the replaceable textresource.

For that i changed the script "common\scripts\buttongroup_tabs.lua" in CoreRPG and it works quiet well, but i noticed that the place on the bottom of the npc sheet is a little bit to small for the new horizontal tabs, and the same for the party sheet.

So i am looking for a way to change the placement values for the windowclass of these subwindows within the buttongroup_tabs script, so i can do it in a general way.

Is this possible ?

I do not want to replace all the XMLs for the sheet within my extension just for changing the bounds of them a little bit...

jreddin1
July 7th, 2015, 13:38
Hello,

within my "localize extension" project (i am sill working on it) i desided to change the horizonzal tabs into vertical tabs (in the CoreRPG they were used in the charactersheet, npc record sheet and party sheet).
So instead using as tab a icon bitmap with a textinformation in it, i can use a icon bitmap with a textwidget on it, which contains the replaceable textresource.

For that i changed the script "common\scripts\buttongroup_tabs.lua" in CoreRPG and it works quiet well, but i noticed that the place on the bottom of the npc sheet is a little bit to small for the new horizontal tabs, and the same for the party sheet.

So i am looking for a way to change the placement values for the windowclass of these subwindows within the buttongroup_tabs script, so i can do it in a general way.

Is this possible ?

I do not want to replace all the XMLs for the sheet within my extension just for changing the bounds of them a little bit...

I had some stuff that used "<bounds>" that I tried to change dynamically. I couldn't get that to work. Instead, I had to change to anchors, and then use the windowclass "setAnchor" methods to adjust as needed.

It might be possible to dynamically delete bounds and replace with anchors, but I haven't tried that.

drvolk
July 7th, 2015, 14:31
Thanks jreddin1, that sounds interessting!

Concretely for the partysheet for e.g. i want to change the "insidebottomleft" y-offset, which is defined within the following windowclass in an anchor for the windowlist "coinlist":


<windowclass name="ps_inventory">
<script file="ps/scripts/ps_inv.lua" />
<sheetdata>
<windowlist name="coinlist">
<anchored position="insidebottomleft" offset="5,30">
<right anchor="center" offset="-75" />
<top anchor="center" offset="40" />
</anchored>
<frame name="groupbox" offset="5,10,15,10" />
<child>
<backcolor>1A40301E</backcolor>
</child>
<child />
<datasource>.coinlist</datasource>
<class>ps_coin</class>
</windowlist>
</sheetdata>
</windowclass>

Could i access this value somehow with the "setAnchor" function, or is this only avaible for an anchor which is directly defined to an windowclass ?

Trenloe
July 7th, 2015, 16:21
Could i access this value somehow with the "setAnchor" function, or is this only avaible for an anchor which is directly defined to an windowclass ?
The setAnchor method is used against a window control created from a windowclass - so you'd need to use the code each time you wanted to modify a windowcontrol. You don't modify the underlying <windowclass> definition permanently with code.

More info on setAnchor here: https://www.fantasygrounds.com/refdoc/windowcontrol.xcp#setAnchor It states that the target is left, top, right, or bottom so I don't know if this will work with insidebottomleft, give it a go to find out. :)

drvolk
July 9th, 2015, 06:57
The setAnchor method is used against a window control created from a windowclass - so you'd need to use the code each time you wanted to modify a windowcontrol. You don't modify the underlying <windowclass> definition permanently with code.

More info on setAnchor here: https://www.fantasygrounds.com/refdoc/windowcontrol.xcp#setAnchor It states that the target is left, top, right, or bottom so I don't know if this will work with insidebottomleft, give it a go to find out. :)

Thanks a lot Trenloe, but how can i get the "windowcontrol" within the lua script "common\scripts\buttongroup_tabs.lua" with which i could change the Anchor ?

In my example the Anchor is defined within the windowlist "coinlist" of the "ps_inventory" windowclass. This class is used in a "subwindow" (name = inventory) of the windowclass "partysheet_host", which is the main class for the partysheet definition. Within this definition there is also the "tabs" template defined which calls the lua script "common\scripts\buttongroup_tabs.lua".

Trenloe
July 9th, 2015, 14:32
Thanks a lot Trenloe, but how can i get the "windowcontrol" within the lua script "common\scripts\buttongroup_tabs.lua" with which i could change the Anchor ?
See "script block scope" here: https://www.fantasygrounds.com/modguide/scripting.xcp The variable window might get to it for you, but as there are subwindows involved, you may have to use a control hierarchy relative list of variables to get to the top level window - similar to database "dot" notation. Something like window.parent.window (this is just an example). The best way for you to understand the hierarchy is to use Debug.console commands that output the name or class of the controls/windows where your button resides. Start with something like Debug.console("Window class = " .. window.getClass()); this will give you the <windowclass> name of the windowinstance which is referenced in the FG XML. You may then need to do use controt dot notation to work your way up the hierarchy to get to the windowinstance you want.

drvolk
July 10th, 2015, 08:32
Ok, i tried to analyse the structure of the window instances and their initialization processes with help of the Debug command and i noticed that the subwindow was not initialized on that point a tryied to change the Anchor of one of its controls.

I also noticed that a template for the subwindow definition was used, which i could also use to change the bounds for them. So i just redefined this template in my extension and everything works fine :)

But i think currenty FG not realy supports dynamic changes of the GUI elements, which were defined within the XMLs by default, right?. E.g. you do not have a method to get all controls of a window, you only could access them directly, so you have to know there names or at least that they exist within a given window instance.

Trenloe
July 10th, 2015, 08:59
But i think currenty FG not realy supports dynamic changes of the GUI elements, which were defined within the XMLs by default, right?. E.g. you do not have a method to get all controls of a window, you only could access them directly, so you have to know there names or at least that they exist within a given window instance.
In general yes, you need to access the controls with their names and know those names in advance.

What are you trying to do? If you want to resize controls within a window when the window is resized the declare your controls with relative anchoring and they will auto position/resize with the window. See the anchoring section here: https://www.fantasygrounds.com/modguide/windowing.xcp Plus there are numerous examples of relative anchoring within the FG rule sets. There is usually a dummy control that is used as the initial anchor that other controls anchor to using relative anchoring.

drvolk
July 10th, 2015, 11:45
I am trying to change the "tabulator" placements of the CoreRPG ruleset from horizontal alignment into vertical alignment and want to change as less as possible the CoreRPG files.
For that i need a little bit more space at the bottom of the sheets (for placing the horizontal tabs) and a little bit less space at the right side of the sheets (the place which is reserved for the "original tabs", which should disapear within my extension).

The rulesets which are using the CoreRPG as basis layer "do not know" that some space needs to be reserved at the bottom of the sheets and so their controls may use the whole place up to the bottom within their sheets.

But as i wrote , i found a working solution and there is not realy a need to have that "dynamic control" in the framework (would be just nice to have).

In my opinion the FG framework is realy great. You have a free access to all the rulesets and you could change or extend them in nearly every way you like.

And the friendly and helpfull community inspires me to develop also some stuff to give something back to them :)

Many thanks for your support, that helps me a lot to understand the framework of FG much better as before.