Boost logo

Boost :

Subject: Re: [boost] [gui] Help with a little experiment.
From: Germán Diago (germandiago_at_[hidden])
Date: 2011-06-19 13:31:01

Thank you all for your feedback.

2011/6/19 Gwenio <urulokiurae_at_[hidden]>:
> On 6/18/2011 10:24 AM, Joel falcou wrote:

> - A library for designing dialogs and forms
> - A library for specifying bindings between the interface and the
> application's data (or creating a view of it).

I think I will start by these two fundamental libraries on top of gtk.

I want that the specification of the gui can directly be embedded in C++
at compile time and that signals and bindings can also be given at
runtime by name.

I'll start by the compile-time way of doing things and I'll see if I can
extend it later for runtime. The layout generated with the DSEL will
contain widgets with the exact same type that given in the interface.
This is not desirable sometimes, so I'm planning to give a way to
override it.
Now I'm trying to design a little currency converter as a proof of concept.
The goal is to be able to specify a layout with its bindings and its logic.

I came up with a solution like this for the example (C++0x syntax all).
It felt more natural to follow a MVVM model. For now this is just fiction
because I want to figure out how to make a specification that meets the goals
described, namely:

1 - Library for designing dialogs and forms.
2 - Library for data binding (compile-time).

After that:

3 - To be able to bind data and signals at runtime by name (difficult in c++)
4 - To be able to make layout more flexible by specifying that
where a Button was put, for example, could go any Widget.

I've also changed the syntax for the layout based on feedback:

#define VIEWMODEL_NAME ViewModel
#include <gui/layout.hpp>
#include <gui/bindings.hpp>

//My Model
class CurrencyConverter {
        float euros_, dollars_;

//My View Model
class ViewModel {
        CurrencyConverter & converter_;
        Binding<float> euros_ = converter_.euros_;
        Binding<float> dollars_ = converter_.dollars_;

        ViewModel(CurrencyConverter & converter) : converter_(converter) {}
        void convertCurrency(Button & button);

//This is my View Class
auto gui_def
Window(title="Currency converter")[
                HBox[Label(text="dollars") | Entry(changed=BINDING(dollars_)],
                HBox[Label(text="euros") | Entry(changed=BINDING(euros_)]
                Button(align=Align::Right, clicked=SIGNAL(convertCurrency)

int main(int argc, char * argv[]) {
        CurrencyConverter converter;
        ViewModel viewmodel(converter);

        auto gui = instantiate(gui_def, viewmodel);

        return 0;


As always, feedback is welcome.

Boost list run by bdawes at, gregod at, cpdaniel at, john at