[haiku-development] Re: BBox and layout
- From: Clemens Zeidler <clemens.zeidler@xxxxxxxxxxxxxx>
- To: haiku-development@xxxxxxxxxxxxx
- Date: Fri, 11 May 2012 09:39:02 +1200
BLayout* layout = new BGroupLayout(); box->SetLayout(layout); // sets the content area offset layout->SetInset(..); // overwrites the offset again So this would goes wrong quite often because you can't expect developers keeping the order when to call SetLayout.It can go wrong, but particularly with the default insets I would challengethat it happens very often. I think in most cases people wouldn't meddlewith the insets at all. It's not possible to prevent people from using theAPI incorectly in either case.However, BBox setter and getter for a default inset are a solution but IMHO not very intuitive...IMO they are. Using default values that can be changed by setters is a common idiom in the interface kit/layout API (e.g. think of the default spacing).
What I meant with not very intuitive is that you have to call BBox::SetContentAreaInset() to set the layout inset. Normally you would call BLayout::SetInset(). Furthermore, all sub-sequential calls to BLayout::SetLayout ignore the BBox inset.
Point 1. should work fine but from my own experience I would just try to call SetLayout on the BBox to set the layout in the content area. That would result in a messed up BBox.Again, we cannot always prevent people from using the API incorrectly. Particularly when they don't manage to RTFM. :-)
no one RTFM :-)
Another problem occurs if you want, for whatever reasons, a content layout that is bigger than the content area. You can't do that in this solution.I guess you could set negative insets.
Yes right this child layout approach would definitely be a solution. However, SetContentLayout compared to SetLayout makes the dev to RTFM -> bad! Overwriting SetLayout and let BBox::SetLayout call _SetContentLayout would be a solution here (hacky, though and would change internal behaviour).
I don't think BView::SetInset is duplicated functionality. One can see BView as a kind of a special "super layout" that holds only one childlayout. From this point of view it also deserves a SetInset method like areal BLayout.I can only repeat my reasoning: It would be rarely used functionality (mainly for BBox, where such an API would therefore be better placed) andyou can easily achieve the same by nesting layouts. An additional layout ischeap, so there really is nothing speaking against doing that.
Its really not a common case but it is handy for all types of container views. For example, to display a layout created by an external source with an intended inset. Sure, that can be solved by adding a container layout with a fix inset but hmmmm don't like it.... setting the inset to BView directly seems to be more straight forward.
Regards,
Clemens
- References:
- [haiku-development] Re: BBox and layout
- From: Ingo Weinhold
- [haiku-development] Re: BBox and layout
- From: Clemens
- [haiku-development] Re: BBox and layout
- From: Ingo Weinhold
- [haiku-development] Re: BBox and layout
Other related posts:
- » [haiku-development] BBox and layout - Clemens
- » [haiku-development] Re: BBox and layout - Alex Wilson
- » [haiku-development] Re: BBox and layout - Ingo Weinhold
- » [haiku-development] Re: BBox and layout - Clemens
- » [haiku-development] Re: BBox and layout - Clemens
- » [haiku-development] Re: BBox and layout - Stephan Aßmus
- » [haiku-development] Re: BBox and layout - Axel Dörfler
- » [haiku-development] Re: BBox and layout - Clemens Zeidler
- » [haiku-development] Re: BBox and layout - Alex Wilson
- » [haiku-development] Re: BBox and layout - Alex Wilson
- » [haiku-development] Re: BBox and layout - clemens . zeidler
- » [haiku-development] Re: BBox and layout - Clemens
- » [haiku-development] Re: BBox and layout - Alex Wilson
- » [haiku-development] Re: BBox and layout - Alex Wilson
- » [haiku-development] Re: BBox and layout - Clemens
- » [haiku-development] Re: BBox and layout - Clemens
- » [haiku-development] Re: BBox and layout - Clemens
- » [haiku-development] Re: BBox and layout - Alex Wilson
- » [haiku-development] Re: BBox and layout - Axel Dörfler
- » [haiku-development] Re: BBox and layout - Alex Wilson
- » [haiku-development] Re: BBox and layout - Alex Wilson
- » [haiku-development] Re: BBox and layout - Clemens
- » [haiku-development] Re: BBox and layout - Ingo Weinhold
- » [haiku-development] Re: BBox and layout - Clemens
- » [haiku-development] Re: BBox and layout - Ingo Weinhold
- » [haiku-development] Re: BBox and layout - Stephan Aßmus
- » [haiku-development] Re: BBox and layout - Clemens
- » [haiku-development] Re: BBox and layout - Clemens
- » [haiku-development] Re: BBox and layout - Ingo Weinhold
- » [haiku-development] Re: BBox and layout - pulkomandy
- » [haiku-development] Re: BBox and layout - Clemens Zeidler
- » [haiku-development] Re: BBox and layout - Clemens Zeidler
- » [haiku-development] Re: BBox and layout - Ingo Weinhold
- » [haiku-development] Re: BBox and layout - Alex Wilson
- » [haiku-development] Re: BBox and layout - Clemens Zeidler
- » [haiku-development] Re: BBox and layout - Ingo Weinhold
- » [haiku-development] Re: BBox and layout - Clemens
- » [haiku-development] Re: BBox and layout - Ingo Weinhold
- » [haiku-development] Re: BBox and layout - Clemens Zeidler
- » [haiku-development] Re: BBox and layout - Ingo Weinhold