Move/Resize Component on Template Load

Note, this is 7.7 so I'm using functions that have been replaced by system.gui.transform(), but this should still work.

I have a template with a value box that I want to be able to be dynamically placed vertically on the template via a parameter.

So, I've got the template parameter as "valut_position" (in %) and I've got a startup script that resizes and moves the component.

However, I'm not able to get it to the correct position during runtime even though it moves and looks correct in the designer.

def template.propertyChange():
	if event.propertyName == 'componentRunning' or event.propertyName == 'value_position':
		valueBox = event.source.getComponent('Numeric Label')
		valueBoxHeight = 28
		if event.source.value_position > 100:
			posPercent = 0.0
		elif event.source.value_position < 0:
			posPercent = 1.0
			posPercent = 1.0 - ( event.source.value_position / 100.0 )
		Y = ( posPercent * ( event.source.height - valueBoxHeight ) ) - 1

0,25,50,75,100 (from designer):

runtime with value 50 (from client):

I thought it might be due to "componentRunning" never changing because I only saved it while the client was open, but even re-launching the client did not change the outcome.

Layout settings are scaling/relative, layout not enabled.

So, it seems like something funky happens with the scaling of the component during runtime because there are a couple of docked windows, but it doesn't really seem like it should be affected because all of the scaling options are set to relative. A value of 50 (60 does) doesn't put it in the middle anymore.

I don't know why x, y, width, and height aren't just exposed as bindable properties to begin with.

Maybe I could account for that if there was a way to get the scale factor from the component and multiplying it by the 28, before resizing and moving?

In my experience dynamically positioning components, coordinates and dimensions have to be relative to the designer, so if docked windows are changing the dimensions of the window in some way, then x coordinates and width dimensions, have to be scaled from what they are at run time to what they were in the designer. Likewise, y coordinates and height dimensions have to be scaled as well in the same way.

I have no idea how to go about this in 7.7; in 8.1's transform, there is a coordSpace argument that handles this automatically. That said, one work around I've used for explicit scaling is to simply place a path based vision shape in a container, and use its relX, relY, relWidth, and relHeight dimensions against the runtime container dimensions to manually calculate the scaling. If these exist in 7.7, you could use them to dynamically scale your moveComponent coordinates or your resizeComponent dimensions.

All I do is divide one by the other to formulate a ratio [or you could call it a percentage], and then I multiply that ratio against my desired coordinates or dimensions to get the explicit conversion values.


Right, so rel/actual would give me the "scale factor" and I could use that to transform the object.

For the moment, I just ended up making around 8 different value boxes and using a integer input 0-7 to the template, rather than using the %.

I'll have to see if those properties exist in 7.7 (I doubt it).