[haiku-development] Re: BBox and layout

On Tue, 08 May 2012 11:46:27 +1200, Alex Wilson <yourpalal2@xxxxxxxxx> wrote:

no that would just make thinks more complicated and mix BView and BLayout
more then necessary. As said before the BView::AddChild api is not
sufficient to create arbitrary layouts. For example, a beginner who creates a simple BGroupLayout using AddChild would face the problem that he is not
able to add a BSpacerLayoutItem. That is very confusing.


I don't think this is necessarily a big problem. You can add spacers to a
group layout using the AddChild(BLayoutItem* method). In the case of a

Oh yes, missed that there is also a AddChild(BLayoutItem* method)...

BGridLayout, for instance would an api user really expect the layout to be
created to their liking using just AddChild()?

exactly, the user would use the special BGridLayout's methods, but what does happened if BView::AddChild adds something to BGridLayout? Its a bit random...

Using just BLayout for layout stuff is much cleaner. Furthermore, a
separation would make it possible to add a view to multiple layouts and
switch between the different layouts on the fly :)


I don't understand what you mean by that. A view can only have one parent
view, and that's an unchangeable part of the api. However, if you want to
have a very flat view hierarchy and use nested layouts, you could
potentially have a view in multiple layouts, using multiple layouts.

what I'm meant is that you have e.g. two slightly different layouts and you can switch between them using SetLayout. The current solution would disassemble the old layout in this case. Each view is only child of exactly one parent but it could still be child of an unconnected layout...

ps. I would even remove the main AddItem(...) and AddView(...) from
BLayout. Already in a grid layout I would not be sure what it will do or if it is allowed to used these methods. Each specialized layout should provide
appropriated methods by itself.


They're a bit uncomfortable in some contexts, but I think they're useful to
keep the simple things simple.

Yeah, but why not add this simple methods where they really make sense, i.e. in BGroupLayout and maybe BGridLayout. But IMHO they do not belong into the BLayout interface because they are not meaningful for all layouts.

cheers,
        Clemens

Other related posts: