Add callback function for ofxGuiGroup::minimize() and maximize()?

Hey guys, I want to trigger a custom function every time a ofxGuiGroup object has minimize() or maximize() called on it. This function re-positions the various ofxPanels in my OF app so they are not covering each other up. Ideally, I would be able to pass a function to each ofxGuiGroup object which is called when minimize() or maximize() are used.

It seems the only way to do this would be to edit ofxGuiGroup.cpp’s definitions of minimize() and maximize(), but I’d like to avoid doing this. So I’m thinking I may need to reassess how I’m using the ofxGui library to allow this to happen.

Currently, my app has a set of sub-animations which each has its own ofxPanel gui control panel.

Here is my repository for reference:

Any ideas much appreciated!

1 Like

I can think of 2 possible solutions.

Calculate position of open/close button and inside of mousePressed() function, you can check if user click the button or not.

Use ofSendMessage() in ofxGui::minimize(), maximize(). And receive it in ofApp::messageReceived().
You have to edit oF library but this must be just a single line of addition.

1 Like

Hi @ross_hoyt,

You could also derive your own class from ofxPanel (or any class as appropriate), with an access-specifier of public. With public inheritance, the public and protected members of the base class become the same for the derived class. And polymorphism allows you to redefine various functions in your derived class, so you can customize their behavior. You can also add new functions and objects to your class as needed. And a derived class is often easier to maintain, can be used or recycled with other apps in the future, and doesn’t require any modification of the base class(es).

Alternatively, you could also create your own custom gui class, which would have an ofxPanel object inside it, along with other functions and objects that define the desired behavior of the class.

ofBook has a helpful chapter about object-oriented programming: https://openframeworks.cc/ofBook/chapters/OOPs!.html

1 Like