GSoC/GCI Archive
Google Code-in 2011 Haiku

Update Layout Building Code in Translators

completed by: Hannah

mentors: Alex Wilson

During early development of the Haiku Layout API, helper classes were developed to make it easier to code your layout, these classes are:

  • BGridLayoutBuilder
  • BGroupLayoutBuilder
  • BSplitLayoutBuilder

As time progressed, so did the Layout API, and a new approach was developed. The classes above have been replaced with similarly-named inner classes of BLayoutBuilder. These classes are documented on, with an overview of the classes here. As the layout API progresses towards being made public, the older layout builder classes must go. (This is where you come in!!) Luckily, the two approaches end up looking very similar in code, so it isn't too tricky to transition to the new classes.

For this task, you need to replace the usage of the old builder classes with the new ones in the translator config views, that is:

  • src/add-ons/translators/raw
  • src/add-ons/translators/exr
  • src/add-ons/translators/hvif 
  • src/add-ons/translators/tga
  • src/add-ons/translators/webp
  • src/add-ons/translators/gif
  • src/add-ons/translators/sgi
  • src/add-ons/translators/tiff
  • src/add-ons/translators/jpeg
  • src/add-ons/translators/jpeg2000
  • src/add-ons/translators/ppm

This may look intimidating, but lots of the code that needs to be changed was likely copy-pasted between translators, so it will be extremely similar. Furthermore, once you get the hang of it, you will be able to make these changes very quickly. (Feel free to carry that momentum on to the other tasks of this type Haiku has provided :) ).

Tip: Make use of tools such as grep, or the code search app here: for better productivity.

One issue to keep in mind is that many apps/preflets use code like this:

SetLayout(new BGroupLayout(...));

Which should be translated to this:

BGroupLayout* layout = new BGroupLayout();


good luck, and god speed. Please remember to test your changes before adding the patch here :)