Using a background image in Mel Window


#1

Hey all,

searched the internet but didnt find anything related to this.
Say I want to make a UI for a difficult rig. I want to have a background image there in order to place some buttons over it at some places, like at the shoulder for example or the knee. Is it even possible to have background images in a mel window ? If yes how ? Can you point me in the right direction ? I think it should be possible somehow, the UV editor does display images… If it is not possible is there any other way than this :
http://www.creativecrash.com/maya/tutorials/scripting/mel/c/fast-easy-flexible-selection-ui-method
I mean I could like make a panel into a window, but id prefer to have a normal window since i need some buttons as well …

Well any help will be very appreciated !

Thanks in advance and kind regards,

TekniX


#2

Check out the ‘image’ mel command. :slight_smile:


#3

Hey JayG !

wow. that was a lot easier than I thought it would be… Well, it is actually quite shamefull for me that I didnt find that command myself. So double thank you :wink: one for answering and one more for answering an easy question !

Kind regards

TekniX


#4

The problem you have in MEL is that the only way to OVERLAY controls (i.e. a button over an image) is by using formLayout… however, Maya/MEL is so stupidly written, that for overlapping controls to be clickable, they have to be created in REVERSE order, which is counter-intuitive.

For example:


window;
formLayout frm;
	string $i = `image -i "c:/image.bmp"`;
	string $b1 = `button -l "CLICK ME!"`;
	string $b2 = `button -l "CLICK HIM!"`;
setParent ..;
formLayout -e
	-af $i top 0 -af $i left 0 -af $i right 0 -af $i bottom 0
	-af $b1 top 20 -af $b1 left 4 -an $b1 right -an $b1 bottom
	-af $b2 top 20 -an $b2 left -af $b2 right 4 -an $b2 bottom
	frm;
showWindow;

The buttons cannot be clicked, because the image was created first, so takes priority for clicking. Simply cut the image line and place it AFTER the two buttons (where any normal person would assume the image would draw AFTER the buttons) and it will work fine.

However, MEL based UI images are not scaleable, so any ui you make based on this idea will need to be a fixed size.

:nathaN


#5

man thank you so much ! :slight_smile: . Havent started yet, but that would have given me some really painfull headache untill i found that out ! So thank you very very much for posting this here !
Where do you live :slight_smile: ? If youre in Munich ill invite you for a beer :stuck_out_tongue: .

Cheers

TekniX


#6

Good call on the formLayout trick Nathan. I completely forgot about how annoying ‘image’ is. Even with all that said too it’s still prone to do weird things. Sometimes if you have your formLayout inside a tabLayout if you switch tabs it will redraw your image on top of your buttons and that sort of thing.


#7

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.