[haiku-bugs] Re: [Haiku] #5525: Implement archiving in layouting classes

  • From: "bonefish" <trac@xxxxxxxxxxxx>
  • Date: Fri, 16 Jul 2010 18:14:01 -0000

#5525: Implement archiving in layouting classes
-------------------------------------+--------------------------------------
  Reporter:  mmadia                  |         Owner:  bonefish      
      Type:  enhancement             |        Status:  in-progress   
  Priority:  normal                  |     Milestone:                
 Component:  Kits/Interface Kit      |       Version:  R1/Development
Resolution:                          |      Keywords:                
Blocked By:  6256, 6257, 6302, 6314  |   Has a Patch:  1             
  Platform:  All                     |      Blocking:  5524          
-------------------------------------+--------------------------------------

Comment (by bonefish):

 ... forgot to mention: I also inserted missing blank lines in
 AbstractLayoutItem.cpp.

 Applied the BTwoDimensionalLayout patch in r37541, though with the
 following style changes:

 {{{
 @@ -197,10 +216,10 @@

         // implementation private
  private:
 -                       BTwoDimensionalLayout*  fLayout;
 -                       CompoundLayouter*       fHLayouter;
 -                       VerticalCompoundLayouter* fVLayouter;
 -                       BList
 fHeightForWidthItems;
 +                       BTwoDimensionalLayout*          fLayout;
 +                       CompoundLayouter*
 fHLayouter;
 +                       VerticalCompoundLayouter*       fVLayouter;
 +                       BList
 fHeightForWidthItems;
 }}}

 Though a bit ugly, this was actually (almost) how it is supposed to look.
 Where the type is too wide it is simple separated by a space from the
 variable name.

 {{{
 +BTwoDimensionalLayout::BTwoDimensionalLayout(BMessage* from)
 +       :
 +       BLayout(from),
 +       fLeftInset(0),
 +       fRightInset(0),
 +       fTopInset(0),
 +       fBottomInset(0),
 +       fHSpacing(0),
 +       fVSpacing(0),
 +       fLocalLayouter(new LocalLayouter(this))
 +{
 +       float LeftInset;
 +       float RightInset;
 +       float TopInset;
 +       float BottomInset;
 +
 +
 +       from->FindFloat(kHSpacingField, &fHSpacing);
 +       from->FindFloat(kVSpacingField, &fVSpacing);
 +}
 }}}

 Lower camel case. Only one blank line.

 {{{
 +status_t
 +BTwoDimensionalLayout::LocalLayouter::AlignLayoutsFromArchive(
 +       BUnarchiver* unarchiver, orientation posture)
 +{
 +       const char* field = kHAlignedLayoutField;
 +       if (posture == B_VERTICAL)
 +               field = kVAlignedLayoutField;
 +
 +       int32 count;
 +       status_t err = unarchiver->ArchiveMessage()->GetInfo(field, NULL,
 &count);
 +       if (err == B_NAME_NOT_FOUND)
 +               return B_OK;
 +
 +       BTwoDimensionalLayout* retriever;
 +       for (int32 i = 0; i < count && err == B_OK; i++) {
 +               err  = unarchiver->FindObject(field, i,
 }}}

 Superfluous space.

 Another remark (I didn't not change anything here):

 {{{
 +status_t
 +BTwoDimensionalLayout::CompoundLayouter::AddAlignedLayoutsToArchive(
 +       BArchiver* archiver, LocalLayouter* requestedBy)
 +{
 +       // The LocalLayouter* that really owns us is at index 0, layouts
 +       // at other indices are aligned to this one.
 +       if (requestedBy != fLocalLayouters.ItemAt(0))
 +               return B_OK;
 +
 +       status_t err;
 +       for (int32 i = fLocalLayouters.CountItems() - 1; i > 0; i--) {
 +               LocalLayouter* layouter =
 (LocalLayouter*)fLocalLayouters.ItemAt(i);
 +
 +               bool wasAvailable;
 +               err = layouter->AddOwnerToArchive(archiver, this,
 wasAvailable);
 +               if (err != B_OK && wasAvailable)
 +                       return err;
 +       }
 +       return B_OK;
 +}
 }}}

 The `wasAvailable` parameter seems superfluous to me.
 `AddOwnerToArchive()` could simply return B_OK, if not available.

 Also, similar to the BAbstractLayoutItem sizes, the insets and the spacing
 fields could be joined respectively.

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

Other related posts: