[haiku-development] Re: BBox and layout

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 07 May 2012 09:15:05 +0200

On 07.05.2012 00:34, Ingo Weinhold wrote:
Alex Wilson wrote:
My first solution is to just leave the label added to the BBox while
calling BView::DoLayout and just move it back to the right position
afterwards. This works fine but why BView::DoLayout layouts the label view
at all? I mean the label is not part of any layout class so it should be
ignored or what is the policy here?

The reason the label is laid out is because it is a child of the view, and
all children are part of the layout (or a nested layout). [...]

Having worked for a while with Qt now, I'm no longer convinced that implementing the 
"adding to view adds to layout" automatism was a wise decision. The other way 
around is obviously useful (and also implemented that way in Qt), but occasionally one 
does want to manage a child view independently of the layout. A common example is an 
overlay, though that can generally not be implemented that way in Haiku due to the 
(unfortunately) missing Z-order between siblings. Anyway, it might be a good idea to 
remove that automatism before we go beta, since I think it is rarely relied upon (usually 
one adds children to the layout anyway, particularly when using a layout builder), but 
annoying when one explicitly doesn't want it.

It probably depends on what one is used to. I've never found it weird that BView::AddChild() and BLayout::AddItem() result in the same thing. In SWT, there is no method to add wigdets to a layout, the layouts always work on all children. Some of the layout implementations however support an "exclude" property in the layout data that can be associated with a child widget.

But I would be fine either way, just giving some input.

Best regards,
-Stephan

Other related posts: