Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More OO friendly API #42

Open
josch opened this issue Sep 13, 2015 · 0 comments
Open

More OO friendly API #42

josch opened this issue Sep 13, 2015 · 0 comments

Comments

@josch
Copy link
Contributor

josch commented Sep 13, 2015

https://sourceforge.net/p/glui/feature-requests/6/

The GLUI code is all written in C++ and all the widgets
are classes etc, which makes a lot of sense.

BUT! The way to create and add widgets is through a
billion different methods of the GLUI class. And a
different one for add_to_panel vs add to main window??
This is a really odd way to do OO UI code. The GLUI
class should have just one add API that takes a
GLUI_control, and all the code in glui_add_controls.cpp
should instead go into the constructors of the
individual widgets.

In fact the way these things are typically done with
other toolkits is that you just pass in the parent in
the constructor. So instead of

GLUI_Checkbox *cb = myglui->add_checkbox_to_panel(
mypanel, "Check me out!", &value, MY_CB_ID, updateCB);

You would do
GLUI_Checkbox *cb = new GLUI_Checkbox(mypanel, "Check
me out!", &value, MY_CB_ID, updateCB);

It doesn't make for any more typing (actually, a little
less typing in this case) and it means that GLUI
doesn't explicitly have to know about every
GLUI_Control subclass in existence. That means GLUI
becomes more extensible because people can write their
own reusable widget subclasses without having to modify
glui.h to add
GLUI::add_my_ultracool_widget(...) and
GLUI::add_my_ultracool_widget_to_panel(...)
methods.

Plus this will make a lot more sense to people who are
used to other C++ GUI APIs (wxWindows, Qt, FOX, to name
a few).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant