frauzufall / ofxGuiExtended

ofParameter based GUI addon for openFrameworks; derived from the core OF ofxGui addon and ofxDOM.
MIT License
113 stars 29 forks source link

any way to make a mouse-clickable image button? #74

Closed moebiussurfing closed 4 years ago

moebiussurfing commented 4 years ago

I would like to make a grid of (thumb) images using ofxGuiGraphics clickable to load/enable an item...

could this be done in some way?

moebiussurfing commented 4 years ago

maybe could create a new control (extending ofxGuiGraphics) like mentioned on the readme?

Adding controls
Controls get automatically created whenever you add a parameter to the GUI.
panel->add(moving);    // creates a toggle
...
You can also add a specific control (this is very useful if you implement your own control classes):
panel->add<ofxGuiLabel>("labeltext");
panel->add<yourControlElementClass>(/* contructor parameters of control element class */);

Anybody know how to do it?

frauzufall commented 4 years ago

Hi @moebiussurfing, sorry I missed a lot of notifications for this repo.. I'll try to take a day off soon where I will look into some open issues. Impossible to make any promises though. Sorry.

frauzufall commented 4 years ago

There are now two new options for any element: background-image and background-size. With the first you specify the path to an image (relative to bin or absolute should work), and background-size can be either scale, cover, or contain. I added their descriptions to the README. The different sizings are demonstrated here. There are also methods to set them not by JSON but via API, I did not test them though.. But the API allows you to set the background image to an ofTexture element, which might be what you would prefer to file paths.

Since you can't directly set the size for a button currently, use the padding to adjust it, see example.

Let me know if you run into any issues!

moebiussurfing commented 4 years ago

thanks @frauzufall !

moebiussurfing commented 4 years ago

I pulled into my fork and it worked perfectly. thanks again.