[haiku-development] Re: CodyCam patch

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 26 Jan 2009 17:37:54 +0100

Hi Michael,

welcome on bord!

On 2009-01-26 at 17:23:44 [+0100], Michael Kanis <mkanis@xxxxxx> wrote:
> Now I try to learn about the API and play a bit with the source. I 
> attached a patch to make CodyCam use layout managers. This may not be 
> high priority, but it's listed as a beginners task. :-)
> 
> The patch has still two glitches, though. First, the labels for the input 
> fields are positioned centered which looks weird, and second, I don't 
> really know how to set the /correct/ window size at startup. (Test this 
> with font size 18 e.g.)
> Do you've got any tips for me?

I've looked through your patch and it's pretty good. The reason for these 
problems you mention is that you need to set a layout on the window itself 
(like fWindow->SetLayout(new BGroupLayout(B_HORIZONTAL))). Then you can 
create and add the background view also by the means of the layout 
management and the B_AUTO_UPDATE_SIZE_LIMITS flag, which you have correctly 
added, will then do it's work. The problem here is that the layout 
hierarchy chain is broken by adding the background view via the old API.

About the second problem, with the labels... You can do it like you did, 
with BStringViews, and you could set an alignment for them. But this has 
some drawbacks: Real BTextControl and BMenuField labels will also 
focus/open the embedded controls when you click the label. Therefor you 
should use the CreateLabelLayoutItem() method that both of these classes 
provide, and AddItem() the returned BLayoutItem instead of the 
BStringViews. Then instead of adding the BTextControls directly, you add 
CreateTextViewLayoutItem(). For the BMenuFields, it's 
CreateMenuBarLayoutItem(). Again, you can set a BAlignment on the returned 
BLayoutItem objects.

As far as coding style is concerned, you did pretty well. Just make sure 
you keep to the 80 chars per line limit and stick to one style of "char* " 
versus "char *", to keep it consistent in the file.

Thanks a lot for your work, it's very much appreciated!

Best regards,
-Stephan


Other related posts: