10-31-2011 07:08 PM
Hello,
I've been trying to scale some boolean text with some constraints: that the text is locked-to-center, and that the VI scales with window size.
What I want to do is scale the boolean text with the window size in some intelligent way. There is a minimum window size, and hence a minimum font size.
Attached you'll find my current attempt, and see what is going wrong. When the font gets too big with respect to the button size (which Labview is controlling automatically), LabVIEW automatically enlarges the button size - so I get a feedback loop: the font gets bigger because the button gets bigger, and vice-versa! With the result that upon scaling the window and then shrinking it back down, does not return the original font/button size. In fact, if you play with the VI I have now, hit the maximize button a few times and you'll see the button keep growing and growing in size!
Does anyone have any suggestions? I'm pulling my hair out here... Thanks.
10-31-2011 09:16 PM
Instead of using the automatic button scaling that LabVIEW does the way you have it turned on, why don't you explicitly set the size of the boolean itself and its text whenever you have a panel resize event. That way you have direct control over the size of the font and the button and you are fighting against the font size forcing the button size as it is doing with the automatic rescaling.
11-01-2011 12:22 PM
Thanks for the response.
I have thought of that, but disabling the Labview autoscaling isn't really an option; if the user enlarges the panel, none of the buttons get bigger and it looks terrible - I'd have to do that manually for all buttons on the front panel, and that'd be even worse, becuase resize events change button position. The layout would be a mess after a few resizes.
11-01-2011 12:51 PM - edited 11-01-2011 12:52 PM
One of the things I have discovered is the problem doesn't present itself on "slow" window changes - e.g. in small increments, relative to the current window size; perhaps a change of an inch or so in monitor space. Whereas if I change window size rapidly (e.g. a maximize event, followed by another maximize event), this is when the problem happens. Strange, still investigating. . .
Attached is an updated version of the VI I'm using for testing.
11-01-2011 01:45 PM
You need to set the sizes of the buttons as well as the font size when the Panel size event occurs.
You don't necessarily need to kill autoscale for all items. If you have objects that work fine, then leave them alone. Just disable autoscale for the problem buttons and handle them programmatically using references and property nodes.
The problem with anything with autoscaling is that the window could easily mess up after a while. Take something double, half, double, half, numerous times, you won't necessarily wind up with what you started with. The problem with windows is that all the size and location properties are all integer based, but scaling is inherently going to have fractional numbers involved which must be coerced to integers.
Any program that looks like it handles window scaling smoothly is able to do it because the programmers put in a tremendous amount of background code to make sure it happens correctly.
Anything you do with scaling should be based off the new dimensions being proportional to a theorectically perfect window; an original guideline. Don't do things that are proportional to the last window size (which is what LabVIEW autoscaling does) because it quickly falls apart when you deal with large ratios or scaling to very small ratios.