BListView with LayoutAPI?

So I tried shoving a BView with a BLayout into a BListItem and got it to mostly work in a BListView, but then there are occasional weird drawing issues and it felt fragile and hacky. It seems like the paradigm is broken by the fact that the BListView is a BView but then the BListItem is not. Is there a clean/easy way to do it that I am missing?

Or is it just easier to use the DrawItem method and lay it out manually as intended?

Do you really need your parent view to be a BListView?

The idea of BListView is that the items are relatively simple things and not views on their own. This saves a lot of view layouting and message passing, and implements most of the logic in BListView, with the items just telling the view what space they need.

If your items need to be views, you could replace your BListView with a BGroupView(B_VERTICAL) which will lay out your items (views) one above the other.

If you just need layouting, I think it is possible to use BLayout classes without pairing them with BViews, so it would be possible to make a variant of BListView that lays out its items in this way? But I don’t think we have an example of this already, and if there are unexpected problems in doing so.

well, I already have a working BView class with a GridLayout in it, and it works fine. I was looking at converting to a BListView as a gateway to a BOutlineListView, as I ultimately want a hierarchical list and was hoping the BOutlineListView would help to manage at least the rendering of the hierarchy.

I also saw how QuickLaunch handles drag-n-drop to reorder items and it looks nicer than my list so I was hoping to get some of that goodness for “free” - but my GridLayout-based list already uses BLayouts in BViews and I didn’t want to rewrite the whole thing.

I think BOutlineListView already does not work so well even in simple cases, mainly because of its confusing API. It is on the list of things we want to remove and replace.

Maybe it is possible to make a TreeLayout that works a bit similarly to BCardLayout to show and hide the children views?

There is also another option if you want to do this: have your existing views render offscreen to a BBitmap. Then have a BListItem subclass that just draws this bitmap in the BListView, and if needed, forwards BMessages to the offscreen view (for mouse and keyboard events or higher level messages depending on how much interactivity you need). Not very efficient, but it should be workable?

Hmmm. Sounds like my best bet is probably to enhance what I already have working to add any features I need. I’ll have to give it some more thought. Thanks for the feedback @PulkoMandy