Boost logo

Boost :

Subject: Re: [boost] Thoughts for a GUI (Primitives) Library
From: Matus Chochlik (chochlik_at_[hidden])
Date: 2010-09-09 06:33:52


On Wed, Sep 8, 2010 at 2:31 PM, Alec Chapman <archapm_at_[hidden]> wrote:
> Robert Ramey wrote:
>> To make progress in this area.  Someone has to:
>>
>> a) define a doable task
>> b) do it
>> c) submit it for everyone to pick at it
>> d) go back and re-do it
>> e) loop until it's accepted.
>
> Completely agree.  Here would be my shot at this.  I know it's very
> manageable in scope and would still be useful in my projects, but those
> aren't very demanding.  The question is if people think it could be more
> broadly useful.
>
> Initially the library would simply provide a general method for binding data
> and broadly specifying layout.  To actually render the controls, it would
> internally wrap an existing third party library and provide a way of
> accessing the underlying controls for low level display settings (actually,
> it would offer a choice of existing third party libraries to make it easy to
> use in existing projects).

+1

>
> To give a quick idea of what I'm proposing, the closest analog seems to be
> data binding in WPF, though I'm not terribly familiar with this so people
> may know of better examples.  The basic idea is that any class that models
> something like the property map concept or iterator concept would
> automatically have a reasonable default view which could also be completely
> changed.  More complex dialogs could easily be created by nesting these
> types inside each other.
>
> A view basically consists of a list of subviews (eg particular controls) and
> a layout for them (eg vertical list).  I think this is a fairly well
> established idea already.  What would be nice is if I could define default
> views for arbitrary classes through template specialization.  For example,
> suppose I had an existing employee class:
>
> struct Employee {
>    int id,
>    string name
> };
>
> Then defining a default view might go something like this:
>
> template<>
> View default_view(Employee& e)
> {
>    View v;
>    v.set_layout(vertical_list); //accepts certain predefined layouts or an
> arbitrary function
>    v << employee.id; //add the first subview;  this calls default_view<int>
>    v.add_sub_view(default_view(employee.name)); //the previous line could
> equivalently be written like this
>    return v;
> }
>
> Suppose I have an object of type Employee:  Employee employee = { 999, "Joe
> Smith" }; I could then call show(employee) or equivalently
> show(default_view(employee)) to pop up a window for display/editing.

The Mirror reflection library (http://bit.ly/bn7iYM), does something similar
for input dialogs for constructing new instances of nested types
with possibly multiple constructors. Look for the factory generator utility
in the docs. Here (http://bit.ly/bqNqah) can also be found some images
of gui dialogs automatically generated by this lib.

Besides this factory generator I'm also working on a similar generator for
viewers/manipulators of existing instances. These would create a reusable
gui object that would accept instances of a given type and would allow
to view or even manipulate them. I'm planning to add this utility in the
next release of the library.

[snip]

BR

Matus


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