TabbedFrame: A DirectGUI Multi-page Control

TabbedFrame allows one to keep multiple “pages” of DirectGUI controls, and to flip between them by clicking on button-tabs at the top of the TabbedFrame.

The repository below contains the “TabbedFrame” class itself, and a simple example-program.

It’s perhaps not implemented in a perfectly DirectGUI-ish style, but I have tried to hew to that style fairly closely, at least.

2 Likes

I’ve started to integrate the tabbed frame in my app for the preference panel but I encountered a problem that prevent proper integration:

I’m using windows to embed the widget, the window is a simple DirectFrame, with minimal decoration attached to it, and the widget is reparented to the frame. So when the window is dragged, the widget is moved along and (in the future) when resized the widget it modified as well.

It works fine with the frame of the TabbedFrame widget, however the tab buttons are not reparented to the given parent, instead they seem to be directly reparented to aspect2d, so when I move the window, the buttons stay in place.

I think there should be a main frame, under witch the pane frame and all the tab buttons are reparented, though it might have impact on the scale and position parameters.

Ah, yeah, you’re perhaps correct in that!

Hmm… It shouldn’t complicate usage overmuch–after all, most work is expected to be done in the TabbedFrame’s “pages”, rather than in the TabbedFrame itself. However, as you say, it may complicate parameter-application a bit. That said, it may be possible to work around that, redirecting the parameters to the primary frame, rather than the “handle” frame…

I’ll give this some thought, I think; if I make changes, I’ll post again here, I intend!

UPDATE!

(Pinging @eldee for their attention on this.)

I’ve now fixed the above issue, I believe: the tab-buttons of a TabbedFrame should now move (and even scale) with the frame.

The solution was actually pretty simple: I just parented the buttons to the main frame. No additional frame required, at least as far as my testing has shown.

I’ve also updated the example-program to demonstrate this new behaviour.

(PS: Sorry that it took me so long to get to this!)

2 Likes

Thanks for the update, I integrated it into my app and now I have a fancy preference window based on TabbedFrame and the layout system by @Epihaius :slight_smile:

Just one small bug (or misunderstanding by me), you assume that tab_scale is a float, or it could be a vector if the screen does not have the same scaling for X and Y. Usually DirectGui objects use a three components tuple for their scale (X, 1, Y). Using a tuple cause the following line to crash

Ah, excellent–I’m very glad that it works! :smiley:

Ah, thank you for the report, and good point. That’s something that I can fix, I daresay! :slight_smile:

I’ve made an issue for it here:

You should be able to follow that issue to be notified once I’ve fixed it; I’ll likely post in this thread, too.

Minor update: I’ve committed what I believe to be a fix for the above issue. TabbeFrame should now accept things like tuples or Vec3s for the value of “tab_scale”, along with its preexisting acceptance of single floats in that parameter.