Re: GUI library - another one

dave@boost-consulting.com 03/04/04 08:59AM >>> button("click me") doesn't have to be a widget. Think expression templates. It can just build up a type to be used by window to add a button.
Well said. This exemplifies the reason why most gui toolkits are so horrible to use, they allow implementation technicalities to dictate interface. Having to decide where an object is going to live before any of its properties can be set is a clear violation of object oriented design principles but we live with these kind of problems all the time for supposed technical reasons.

Jesse Booher wrote:
dave@boost-consulting.com 03/04/04 08:59AM >>>
Well said. This exemplifies the reason why most gui toolkits are so horrible to use, they allow implementation technicalities to dictate interface. Having to decide where an object is going to live before any of its properties can be set is a clear violation of object oriented design principles but we live with these kind of problems all the time for supposed technical reasons.
Borland's VCL doens't limit you like this. TForm* F = new TForm(0); TButton* B = new TButton(0); (// 0 = null owner) B->Caption = "Click Me"; // should be B->SetCaption(..) in c++ B->OnClick = BClickHandler; // (this uses __closure extension) B->Parent = F; ... TForm* F2 = new TForm(0); B->Parent = F2; ... delete B; // removes it from the form it is on You can move components about which I like the freedom to do. And they certainly don't need a parent to have their properties set. Thanks Russell

button("click me") doesn't have to be a widget. Think expression templates. It can just build up a type to be used by window to add a button.
Well said. This exemplifies the reason why most gui toolkits are so horrible to use, they allow implementation technicalities to dictate interface. Having to decide where an object is going to live before any of its properties can be set is a clear violation of object oriented design principles but we live with these kind of problems all the time for supposed technical reasons.
Hear, hear! Given the huge number of half- to three-quarter-baked GUI solutions floating around, I think that anything that's proposed for boost should very carefully consider abstracting the problem in a way which allows the most (or at least one of the) sensible and intuitive syntaxes and then allow the design to drive implementation. ------------------------------------------------------------------------ --------------------------- Matthias Schabel, Ph.D. Utah Center for Advanced Imaging Research 729 Arapeen Drive Salt Lake City, UT 84108 801-587-9413 (work) 801-585-3592 (fax) 801-706-5760 (cell) 801-484-0811 (home) mschabel at ucair med utah edu

Hi Jesse Booher wrote:
dave@boost-consulting.com 03/04/04 08:59AM >>> button("click me") doesn't have to be a widget. Think expression templates. It can just build up a type to be used by window to add a button.
Well said. This exemplifies the reason why most gui toolkits are so horrible to use, they allow implementation technicalities to dictate interface. Having to decide where an object is going to live before any of its properties can be set is a clear violation of object oriented design principles but we live with these kind of problems all the time for supposed technical reasons.
Okay, you make a good point. On the other hand, I think that requiring child elements to have an explicit owner is good design; the problem is that the constructor syntax for widgets doesn't make it clear that they are in fact being constructed by the owning window. If the syntax were: window w("Test"); button b = w.spawn("button"); b.label("Click me"); w.contain(b); then the situation would be much clearer. At a broader level, I'd argue that there is a good reason to use this document/elements design because the type of the widgets have to match the type of window they're going to go into. Does that sound strange? Consider a linux implementation that allowed a run-time choice between a Qt and a GTK interface - or even both at the same time. It would clearly be an error to put a Qt widget into a GTK window. The document/elements model prevents this type of abuse. But as I said yesterday, I'm not religious :-). If my opinion is in the minority, I'll happily adapt the interface. Regards David Turner

Russel wrote:
But this wouldn't catch at compile time me writing
label l = w.spawn("button");
True. You'll get a bad_cast exception. That's why you're encouraged to use the constructor form rather than using window.spawn directly. I might even decide to enforce that constraint by careful use of protected:. Regards David Turner

David Turner wrote:
window w("Test"); button b = w.spawn("button"); b.label("Click me"); w.contain(b);
Excuse me butting in, but this is redundant information: // b belongs to w button b = w.spawn("button"); // b belongs to w w.contain(b); It seems to me that you're trying to fit two concepts into one box, the widget and its properties. All this jumping through hoops occurs because you're trying to manipulate a "widget that must belong to a window" when in actual fact you're interested only in its properties: button_properties bp; bp.label("Click me"); bp.size(10,10); bp.foreground_color(red); window w; w.add_widget(bp); Persumably, therefore, the button_widget's constructor would be struct button_widget { button_widget(window const &, button_properties const &); }; Regards, Angus

Angus Leeming wrote:
David Turner wrote:
window w("Test"); button b = w.spawn("button"); b.label("Click me"); w.contain(b);
Excuse me butting in, but this is redundant information: // b belongs to w button b = w.spawn("button"); // b belongs to w w.contain(b);
No, they are _not_ redundant. Writing "w.contain(b)" doesn't mean b now belongs to w. It says nothing about ownership. What it says is that w _contains_ b. On the other hand, w.spawn("button") says something about the genealogy of the button. It says it's the spawn of the window, and therefore belongs _somewhere_ in the window's hierarchy tree. Not necessarily as the direct child of the window. I should point out that that windows can only contain one widget. However, that widget might be a grid widget. This is an auto-sizing framework.
It seems to me that you're trying to fit two concepts into one box, the widget and its properties. All this jumping through hoops occurs because you're trying to manipulate a "widget that must belong to a window" when in actual fact you're interested only in its properties:
Yes I am trying to fit two concepts into one box, but those aren't the two concepts in question. The sticking point is that the window is both a container of a widget, *and* the factory for all widgets that will ultimately be contained within the window's widget hierarchy. Again, I appeal to the W3C DOM: body = document.createElement("body"); document.appendChild(body); div = document.createElement("div"); body.appendChild(div); Regards David Turner

"David Turner" <dkturner@telkomsa.net> writes:
Hi
Jesse Booher wrote:
dave@boost-consulting.com 03/04/04 08:59AM >>> button("click me") doesn't have to be a widget. Think expression templates. It can just build up a type to be used by window to add a button.
Well said. This exemplifies the reason why most gui toolkits are so horrible to use, they allow implementation technicalities to dictate interface. Having to decide where an object is going to live before any of its properties can be set is a clear violation of object oriented design principles but we live with these kind of problems all the time for supposed technical reasons.
Okay, you make a good point. On the other hand, I think that requiring child elements to have an explicit owner is good design; the problem is that the constructor syntax for widgets doesn't make it clear that they are in fact being constructed by the owning window.
You're still missing the point. The fact that the owning window constructs the child is an implementation detail that has nothing to do with the window structure/layout the user is trying to represent. The syntax for describing a window should be declarative, not imperative. -- Dave Abrahams Boost Consulting www.boost-consulting.com

Dave Abrahams wrote:
"David Turner" <dkturner@telkomsa.net> writes:
Okay, you make a good point. On the other hand, I think that requiring child elements to have an explicit owner is good design; the problem is that the constructor syntax for widgets doesn't make it clear that they are in fact being constructed by the owning window.
You're still missing the point. The fact that the owning window constructs the child is an implementation detail that has nothing to do with the window structure/layout the user is trying to represent. The syntax for describing a window should be declarative, not imperative.
I'm well aware of the fact that owner windows are an implementation detail. I also know full well that if I wanted to, I could cope with a change of ownership. The point *I'm* making is that there are design and utility considerations as well as implementation considerations. By design, the window is the factory for all other widgets. A button in one window isn't necessarily the same thing as a button in another window; just as a bold font in one document isn't necessarily the same as a bold font in another. One cannot say in general that elements can be exchanged between documents. Similarly, one cannot say in general that widgets can be exchanged between windows. If you think this is a weak argument, then I'll be happy to change the interface. But please think very carefully about all the implications of having free widgets first. I believe this slight interface oddity is a small price to pay. Regards David Turner

David Abrahams wrote:
You're still missing the point. The fact that the owning window constructs the child is an implementation detail that has nothing to do with the window structure/layout the user is trying to represent. The syntax for describing a window should be declarative, not imperative.
David Turner responded:
I'm well aware of the fact that owner windows are an implementation detail. I also know full well that if I wanted to, I could cope with a change of ownership.
I think you are missing the point a tiny bit. David (lot of those here...) Abrahams tried to accentuate the syntactical/expressionist properties of the GUI tree. I too think you gain a lot by keeping them as ASTs as long as possible, which are subsequently traversed by the particular GUI implementation (in your case, the "window" instance.) I would not go that far to suggest the use of BGL to express the abstractly syntactical tree, but almost ;-) Just to make sure there are no wrapper glues in that part. /David

Hi
From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of David Bergman
David Abrahams wrote:
You're still missing the point. The fact that the owning window constructs the child is an implementation detail that has nothing to do with the window structure/layout the user is trying to represent. The syntax for describing a window should be declarative, not imperative.
David Turner responded:
I'm well aware of the fact that owner windows are an implementation detail. I also know full well that if I wanted to, I could cope with a change of ownership.
I think you are missing the point a tiny bit. David (lot of those here...) Abrahams tried to accentuate the syntactical/expressionist properties of the GUI tree. I too think you gain a lot by keeping them as ASTs as long as possible, which are subsequently traversed by the particular GUI implementation (in your case, the "window" instance.)
Gah. you're right. I *am* missing the point. I was replying from Jesse Booher's thread. Looking at your other post, I see you're tending towards the idea of using the widget tree as a context rather than as an entity. This may or may not work. The main problem I have with it is that the metaphor doesn't adequately capture the user's expectations. In particular, the monadic or instantaneous nature of the transformation from expression to reality is a problem. User interfaces are interactive by nature. While the "gui expressions" approach is great for visualization of data, it doesn't really address the needs of, say, an "enter your name" dialog. But perhaps I'm mistaken? I can see that there is some argument to be made for the idea of a user interface as a sort of question-and-answer session, so that we might want to do things like: std::string name; (window("Enter your name") + textentry()) >> name; However, there are two reasons not to take this route: (a) it can be relatively easily implemented post-hoc, and (b) it tackles a slightly different problem domain. * I seem to be alone in my support for the widgets-are-owned-by-windows concept. That being the case, it makes sense to look at removing the requirement that widgets be spawned from windows. However, I would still like to have a WidgetFactory of sorts. In particular, I'm thinking about eventually supporting multiple factories for a run-time decision about which back-end to use. For example, it would be extremely nice to have a piece of software support command-line switches like --text-mode, --gtk, and --qt. Any suggestions as to how this should be done? Regards David Turner

"David Turner" <dkturner@telkomsa.net> writes:
You're still missing the point. The fact that the owning window constructs the child is an implementation detail that has nothing to do with the window structure/layout the user is trying to represent. The syntax for describing a window should be declarative, not imperative.
I'm well aware of the fact that owner windows are an implementation detail. I also know full well that if I wanted to, I could cope with a change of ownership.
The point *I'm* making is that there are design and utility considerations as well as implementation considerations. By design, the window is the factory for all other widgets. A button in one window isn't necessarily the same thing as a button in another window; just as a bold font in one document isn't necessarily the same as a bold font in another.
One cannot say in general that elements can be exchanged between documents. Similarly, one cannot say in general that widgets can be exchanged between windows.
If you think this is a weak argument, then I'll be happy to change the interface. But please think very carefully about all the implications of having free widgets first. I believe this slight interface oddity is a small price to pay.
I'm not interested in the free/not free debate, and I don't have an opinion on it. I'm only interested in the syntax for building windows. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (7)
-
Angus Leeming
-
David Abrahams
-
David Bergman
-
David Turner
-
Jesse Booher
-
Matthias Schabel
-
Russell Hind