PDA

View Full Version : Can you increase all field widths when a window is made wider



MadBeardMan
October 25th, 2020, 00:42
Evening,

Been trying to work this one out.

I have a window list, it's got:

Name Protection KG Notes
____________ _________ ___ ________

Now what I want when the window is made wider is to increase the width of each based on the new width
Name Protection KG Notes
__________________ __________ ____ __________

And so on. So each field increases in proportion to each other.

I can only find a way to increase one field, the name as the others are inline with it

Cheers,
MBM

Weltenbrand
October 25th, 2020, 11:40
I guess you have to write a onSizeChanged function for the according windoinstances.

MadBeardMan
October 25th, 2020, 13:25
I guess you have to write a onSizeChanged function for the according windoinstances.

Awesome, I shall explore this today!

Cheers,
MBM

MadBeardMan
October 25th, 2020, 14:05
I've got onSizeChanged being called. Is there a way to modify the size of a label at all?

Trenloe
October 25th, 2020, 15:03
I've got onSizeChanged being called. Is there a way to modify the size of a label at all?
Use the various setAnchor API commands. For example, setAnchoredWidth: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/4162011/windowcontrol#setAnchoredWidth

Or do some calculations and use setStaticBounds. Here's an example I use in The Dark Eye extension to calculate the width based off a third of the width of the window:

<script>
function onInit()
self.onSizeChanged = resizeFrames;
end

function resizeFrames(sourceWindow)
local nWidth,_ = getSize();
cas2.setStaticBounds((nWidth/3), 215, (nWidth/3)-15, 250)
end
</script>

You can also look at using calculations with the original relative anchoring in the base XML - for example, <left> parent="" anchor="center" offset="-10"</left> will anchor an the left side of a control to 10 pixels from the center of the window. As you appear to have 4 controls, you may be able the anchor the right side of the second, and the left side of the third control to the center of the window, and adjust the right side of the first/left side of the second and right of the the third/left side of the fourth control using code.

MadBeardMan
October 25th, 2020, 15:25
Hi Chap,

It would be better to be able to say 'this label is 50% of the width, this label is 15%, this label is 20% and this label is 15%'

I tried the setStaticBounds and the label just vanishes.

Is there any example anywhere where a windowlist column is resized and the labels are fixed above?

Cheers,
MBM

Trenloe
October 25th, 2020, 16:08
Is there any example anywhere where a windowlist column is resized and the labels are fixed above?
As column labels are essentially independent of the actual windowlist, the sizing/positioning of the labels has to be handled separately. You can use similar code to what I referred to above for each of the windowlist column labels and the fields within the windowlist, but you can't just say a label outside of a windowlist is positioned above a field within the windowlist.