Boost logo

Boost :

Subject: Re: [boost] [gui] Help with a little experiment.
From: michi7x7 (michi_at_[hidden])
Date: 2011-06-18 12:58:29


>
> windows<dialog, some_tag_for_selecting_gui_backend> w;
>
> w = frame("Choose a File to Open")
> [
> listbox<columns,no_icons>(pos_x,pos_y)
> [
> on_select = ...
> , on_move = ...
> ]
> ,
> button("&OK", on_click =&do_ok)
> | button("&Cancel", on_click =&do_cancel)
> ];
>

Hi all,

Yeah, I've thought of making a GUI-Framework using Proto too,
however, there are a few problems that came to my mind.

1.) It needs a consistent Syntax. Grouping AND actions with [ ] is no good.

2.) It must be possible to generate some sort of MVC (or better MVP)
layout, which can later be used to modify the layout and access data.

3.) Backends should be interchangeably easily, but not dynamically.

So what I thought of was something like that:

namespace gui = name_me::gtk::gui;

gui::handle<bool> checked;

gui::button but;
gui::window wnd;
gui::toggle check(&checked);

wnd = window(title="just an example", resizeable=false) [
  label("click me:") | check = checkbox()
  -
  but = button("Close")
];

but.clicked() = [&]() {
  std::cout << "window " << wnd.title() << " closed!\n";
  std::cout << "The checkbox was " << checked << std::endl;
  wnd.hide();
};

| can be used to place widgets side by side (HBox), - places them in an
vertical container (VBox). Grouping is done using [ ].

gui::xyz are controllers that can be used to change the gui and can be
bound to specific values (like checked above). Every controller can be
used as if it was the real widget and any change is transmitted
immediately. If a controller is assigned to a new widget (following
polymorphic rules, so a toogle_button can be assigned to a gui::button),
the widget is replaced.

The Widget-Properties can be set using the DESL and (name=xyz) or using
the controllers accessor (ctr.name()).

So far for my ideas,

michi7x7


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk