|
Boost : |
Subject: Re: [boost] [gui] Help with a little experiment.
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2011-06-18 22:39:39
On Sat, Jun 18, 2011 at 7:05 AM, Germán Diago <germandiago_at_[hidden]> wrote:
At Adobe we designed an Eve-like (see
http://stlab.adobe.com/group__asl__overview.html) DSEL, that would
make the Eve example:
layout clipping_path
{
view dialog(name: "Clipping Path")
{
column(child_horizontal: align_fill)
{
popup(name: "Path:", bind: @path, items:
[
{ name: "None", value: empty },
{ name: "Path 1", value: 1 },
{ name: "Path 2", value: 2 }
]);
edit_number(name: "Flatness:", digits: 9, bind: @flatness);
}
button(name: "OK", default: true, bind: @result);
}
}
look something like this:
View * MyClass::create_clipping_path
{
return dialog(name = "Clipping Path")
[
column(child_horizontal = align_fill)
[
popup(name = "Path:", bindto = &m_path, items = _
[
_(name = "None", value = nullptr),
_(name = "Path 1", value = 1),
_(name = "Path 2", value = 2)
],
edit_number(name = "Flatness:", digits = 9, bindto = &m_flatness)
],
button(name = "OK", def = true, bindto = &m_result)
];
}
And your example:
>
>
> 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);
>
I think would be:
View *MyClass::hello_world()
{
return Window(title="Hello, world!")
[
VBox(expand=true)
[
HBox(expand=true)
[
Label(text="Name:"),
Entry(onChange = onEntryChanged)
],
Button(text="hello", onClick = onButtonClick)
]
];
}
Note that the syntax closely modeled XML, but without the verbosity.
ie it has unique, unordered, attributes (inside the brackets) and
non-unique, ordered elements, [inside the square brackets].
It also, given a "mapping struct", figured out which attributes could
be passed to a widget constructor, and which needed to be set
separately. ie for Button, if its constructor took a std::string, but
not an "onClick" function, the Button would be constructed via,
essentially:
button = new Button("hello");
button->set(onClick, onButtonClick);
Tony
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk