Adding a Button to Child Window
« on: 28 June 2016, 06:40:29 »
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

  • *****
  • 1163
    • View Profile
    • Texus's Blog
Re: Adding a Button to Child Window
« Reply #1 on: 28 June 2016, 12:14:05 »
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.

Re: Adding a Button to Child Window
« Reply #2 on: 28 June 2016, 19:37:35 »
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!
« Last Edit: 28 June 2016, 19:44:56 by Ruckamongus »