Hello! I am wondering what the usual procedure is to convert a Haiku application the the layout API with searching for the parts of code needing to be converted and going from there. I was wondering about this since I’m participating in the Google Code-In and I’d really want to do a task involving converting an application to the layout API.
Generally, you want to find and change the parts that build the GUI. Maybe grep the source files for BButton, BTextView or what widgets appear in the app. Then use the “layout-aware” contructor of those GUI elements, see the HaikuBook and use BLayoutBuilder() instead of adding the elements manually.
I’m not much of a programmer, but I bumbled my way through easy conversions before. As an example, see this commit for TimeTracker.
Generally, it’s helpful to look at examples in code. You can search Haiku’s code.
Most GUI layout code is located in the constructor function of an application’s Window and View classes. Just look in there and find any AddChild() calls which was the old way of constructing the GUI. The LayoutBuilder helper class is definitely the way to go now. Here is a good (but very technical) reference on using the Layout classes directly, but I recommend focusing on the short example of using the builder at the bottom of the page. There is also a good explanation of the proper way to layout with a BBox, which seems to be the exception to normal LayoutBuilder practice:
I also find very helpful looking at the Haiku source code for various preflets (Preferences) since these range fro simple to complex and feature almost every type of GUI element. You can open the preflet, then compare it to the source code to figure out how the layout is achieved:
Thank you for the responses! I will go and look at those places! You may see me working on a layout API conversion task soon!