06-22-2011 09:35 AM
I think that I know the answer to this already ( i.e. No ) but wanted to check...
Is it possible to create a custom control such that when it is resized any graphics remain the same size?
i.e. something along the lines of the following image
Why?
I have some buttons with icons on. The buttons are dynamically resized to reflect the user's configuration. Resizing the buttons messes up the icons, and for continuity I wouldn't wish to resize the icons anyway.
I could just position a picture over the button in the correct place, but then the user can't 'click through' the image to switch the button and the code would get pretty messy.
The only other option I can think of is to have all permutations of buttons and sizes ready and then show/hide as appropriate - again, that could get mucky.
Any ideas, tips or hints?
(In case it makes a difference I'm using V8.5)
Thanks,
Ian
Solved! Go to Solution.
06-22-2011 10:15 AM
Ian,
I'm not sure if this will work with a custom button, but you might try creating property nodes for your buttons then setting the size of the pictures to a constant. I've attached a very basic example of holding the text size constant on a stop button when you resize the button.
--Ryan
06-22-2011 10:24 AM
Thanks Ryan,
So far I haven't found a property node for boolean buttons which provides access to images. For example, graphs have plotimages.back/front/middle - this kind of thing would be handy if it existed for booleans. Property nodes would work for picture indicators on their own, but that takes me back to the 'click through' problem when they are positioned over a button.
Text size isn't really an issue as changing the size of a control doesn't affect the text within it.
I've also (optimistically) tried flattening an image to a string and writing that to the Boolean Text.Text property node to see if it would display as an image - unsurprisingly it didn't!
Ian
06-22-2011 10:26 AM
You could make the button transparent and add a picture behind it. Then when you resize the button you are not really changing the picture. You may have to move it to keep it in the center of the button but that is doable.
06-22-2011 10:32 AM
That sounds like a plan! I'll give it a go and post back with what I get.
Thanks Tim.
Ian
06-22-2011 11:31 AM - edited 06-22-2011 11:35 AM
This pretty much does what I was hoping - its not quite as refined as I was hoping, although with a few more event cases I could add mouse-over behaviour etc.
Comments or suggestions for improvements welcome (particulary on how to change my graphics to a 'disabled and grayed' appearance)
Thanks again,
Ian
06-22-2011 11:45 AM
Would there be a way to decrease the transparency of the button slightly when pressed that way you get the darker appearence?
--Ryan
06-22-2011 11:48 AM
Might work.
I realised that I can of course simulate disabled and grayed in exactly the same way as I made the original pictures, namely by setting some controls to that state and copying their appearance into picture constants. Its a bit laborious and will end up with a few extra property nodes floating around but will probably be worth it in the long run in order to get a vaguely appealing UI.
06-22-2011 03:09 PM
I had a little more fun with it than you did. Here you can chage the size of the button and it will change sizes to any size not just four. Let me know what you think.
06-22-2011 03:12 PM
Small Change