Adding a Button to Child Window

Started by Ruckamongus, 28 June 2016, 06:40:29

Ruckamongus

Hey Texus,

I was wondering about your thoughts on the best approach to adding a button to the child window. In a project I'm porting to C++ I had a nice little GUI effect I liked. Some child windows could be closed or mildly hidden. For example:



The image on the right is what happens when the leftmost button is pressed. I'd like to add that button conditionally to some TGUI child windows. Would I be better off modifying the child window class directly or inheriting from it and adding it in? I don't foresee having more buttons than the two (so 0, 1, or 2 at most). Thoughts?

texus

It seems like all the functions from which the close button is used can be overridden, so it would be possible to do it with a new widget that inherits from it. However you would have to copy the implementation of many functions so you might just as well edit ChildWindow directly.

Everywhere where you find the m_closeButton in the code you probable have to change some code for the new button. I think the hardest part may be setPosition, but if you know that the text is always going to be centered then you will only have to implement one of the three title alignments.

Feel free to send me the modified code after you implemented it, I could use it to officially add support for a minimize button later.

Ruckamongus

#2
Sounds good. That's kind of what I thought, but I figured it doesn't hurt to get your opinion on it first. I'll send a PR whenever I get around to making it work the way I want. Thanks, Texus!