
Germán Diago wrote:
Hello. I'm trying to implement a little experiment of what I see should be the future of c++ guis. For that I'm going to need a handful of proto and fusion, and I have some questions. Besides that, there have been many times that a GUI for boost has been discussed. As I have some questions and something to expose, I thought it would be a good idea to post this message in both boost users and boost developers.
I don't have an entire proposal for this, but for now I'm experimenting how a GUI framework should look like in my opinion.
My opinion is that it should be AS declarative as possible, so, taking as a backend the gtk framework, I came with a syntax like the following one:
#define CONTROLLER_CLASS GuiController #include <Gui/Layout.h> #include <iostream>
class GuiController { void onEntryChanged(Entry & entry) { auto text = entry.getText(); std::cout << text << std::endl; }
void onButtonClick(Button & button) { std::cout << "Button was clicked" << std::endl; } };
auto gui_definition = Window(title="Hello, world!") << VBox(expand=true) << HBox(expand=true) << Label(text="Name:") && Entry[SLOT(onEntryChanged)]) << End(HBox); << Button(text="hello")[SLOT(onButtonClick)]; << End(VBox) << End(Window);
The properties are mapped to objects like title corresponding to the gtk properties. The << operator means insert into and the << End(WidgetName) means that no more widgets should be inserted inside that closed widget. The && operator means put widgets at the same level. Regarding signals, they're put inside operator[]. That gui definition would be used like this
template <class UI, class Controller> ?? createGUI(UIDefinition & ui_def, Controller & controller);
int main(int argc, char * argv[]) { GuiController controller; auto window = createGUI(gui_definition, controller);
window.show_all(); window.run(); }
The function createGUI would generate a GUI from the definition and it would bind SLOTS automagically. It's very little code making use of a DSEL. The problem is that I must learn a lot of proto to code this, but if it works, do you think it would be an improvement? It's all compiler-checkable and the code is very short. After this first step I could start thinking beyond gtk and separate the library in backend and frotend so that not just gtk+ is used.
Hi, while reading your post I remembered XMLTalk : [1] http://tinyurl.com/6fv9oqf. XmlTalk is a Java FRAMEWORK FOR AUTOMATIC GUI RENDERING FROM XML SPECS based on the MVC. Apologies if this this could be considered old technology now but that inspired me long time ago. Note that I'm not used to make GUI. Even if you provide a DSEL for GUI definition you should provide another DSL (XML or something else) for people that are not familiar with C++. Maybe XmlTalk would inspire you also.
My question is:
Can I make something like End(VBox) work with boost.proto? I mean if it's possible to close the expression for a VBox with end and insert the next widget to the same level that the HBox.
Thanks for your time and feedback is welcome.
What about using [] as scope operator Window(title="Hello, world!") [ VBox(expand=true) [ HBox(expand=true) [ Label(text="Name:") && Entry[SLOT(onEntryChanged)] ] // End(HBox); << Button(text="hello")[SLOT(onButtonClick)]; ] // End(VBox) ]; // End(Window); Best, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/gui-Help-with-a-little-experiment-tp36076... Sent from the Boost - Dev mailing list archive at Nabble.com.