(SVN) Any reason why setVisible on a Widget is protected?

christianboutin.com

22-09-2009 01:08:51

I have different menu screens and each screen contains a vector of Widgets. And when I call "hide" on any of those screens I want to hide all the widgets on it.

Also, should I want to animate the buttons, maybe have them appear from outside the screen and move into position. Can I do it considering the setPosition of the Button widget (or any widget) is also protected?

in the header file of the widget there are 2 blocks of "protected:" methods. Under the one I changed to public is the mention :

// The following functions are protected because all inheritted classes should not allow
// public access to them. For example, a MenuItem is a Widget, but should not allow users
// to manipulate its size or position.


So it's obvious that these methods being protected is by design. I wonder if that's the best way to go, or how I can go about turning widgets visible/invisible or moving them around from the outside without those methods. Thanks!

kungfoomasta

22-09-2009 02:03:44

I believe if you set the active sheet to NULL, only the cursor will be drawn on the screen. Or if you swap out one Sheet for another, only the active sheet is drawn.

As the comment suggests, a lot of the setter functions are protected by design. If possible, I would recommend you place all of the widgets onto a Panel (or a few Panels maybe) and toggle visibility of the Panel, instead of each Widget in a list of Widgets. If you have a lot of widgets around the screen, its probably better performance to group them into windows anyway, since each window is a texture, and has to be updated any time any of its children need to be redrawn. (Sheet is a full screen window)

The only other thing I can think of is to try to avoid having a list of Widget*. Maybe a list of Buttons, if you know they're all buttons. Don't have too many great solutions to this problem. :(

christianboutin.com

22-09-2009 02:26:09

You're absolutely correct, I should've thought about that myself :oops: All the elements of the screens should be on their own panel and I could toggle it this way. Will try this out tomorrow (punched out a few minutes ago) Thanks!