[haiku-bugs] Re: [Haiku] #6407: BLayout should derive from BLayoutItem, and should function without a BView.

  • From: "yourpalal" <trac@xxxxxxxxxxxx>
  • Date: Sat, 31 Jul 2010 17:40:13 -0000

#6407: BLayout should derive from BLayoutItem, and should function without a
BView.
---------------------------------+------------------------------------------
  Reporter:  yourpalal           |         Owner:  yourpalal        
      Type:  enhancement         |        Status:  in-progress      
  Priority:  normal              |     Milestone:                   
 Component:  Kits/Interface Kit  |       Version:  R1/Development   
Resolution:                      |      Keywords:  layout, gsoc2010,
Blocked By:                      |   Has a Patch:  0                
  Platform:  All                 |      Blocking:  5524             
---------------------------------+------------------------------------------

Comment (by yourpalal):

 Replying to [comment:2 tangobravo]:
 > Just out of interest, what's the need for a viewless BLayout? What's the
 use-case?

 Basically, there are two places where it will be useful:
 *It will allow for nested layouts, so that instead of this kind of thing:

 BGroupView* myGroupView = new BGroupView(B_HORIZONTAL);
 BGroupView* nestedGroup;
 myGroupView->GroupLayout()->AddView(nestedGroup = new
 BGroupView(B_VERTICAL), 5);
 nestedGroup->AddChild(new BButton("a"));
 nestedGroup->AddChild(new BButton("a"));
 myGroupView->GroupLayout()->AddView(nestedGroup = new
 BGroupView(B_VERTICAL), 2);
 nestedGroup->AddChild(new BButton("b"));
 nestedGroup->AddChild(new BButton("b"));
 nestedGroup->AddChild(new BButton("b"));

 You could forego the creation of the nestedGroup BView, and simply add
 BGroupLayouts to myGroupView. This way, we avoid the overhead of having
 another two views in there, when their only purpose is to host a
 BGroupLayout. This also means that all those BButtons will be children of
 myGroupView. (That's not really an advantage, but I thought I'd mention
 it)
 An even more 'extreme' scenario might be to avoid adding any
 organizational views at all to your window (of course, BWindow::fTopView
 will still be there).

 *Another use case is laying out objects that are not strictly related to
 BViews. (Composing a document for example, you could use many nested
 layouts for the different elements).

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/6407#comment:3>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: