[haiku-commits] haiku: hrev52108 - in src/apps/haikudepot: ui model

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 16 Jul 2018 23:40:22 -0400 (EDT)

hrev52108 adds 2 changesets to branch 'master'
old head: 4a88aa503ad4155a20931e263d24343043994ea9
new head: 0da0829bbc7ebcdbf9fcabfdd1380e4e9134003e
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=0da0829bbc7e+%5E4a88aa503ad4

----------------------------------------------------------------------------

146a80c1cf6d: HaikuDepot: Refactor & fix layout initialization in 
RatingItemView.
  
  BLayoutBuilder is designed for single-shot use; i.e., a "one-liner"
  of .AddLayout(), .Add(), and .End()s and no variable storage.
  This is basically the only coherent way to use the class, as otherwise
  it becomes unclear what state it's even in, and in the case of functions
  like these with multiple branches for different options, that is doubly true.
  
  It seems that in certain cases, the final SetInsets() after the End()
  was winding up one before the "beginning" of the builder and thus attempting
  to set the insets of NULL. Rather than analyze the function to determine
  under what control-flow this occured (since it only happened for some
  packages, and not others), I've opted here for the more systemic solution
  to remove usage of BLayoutBuilder entirely, and just create straight BLayouts.
  
  Fixes #14214.

0da0829bbc7e: HaikuDepot: Display the last copyright line instead of the first.
  
  As Diver notes in #13006:
  > I saw a few youtube videos with Haiku review where people were confused
  > with package copyright year in HaikuDepot. They though this was when the
  > package was last updated. HaikuDepot also only shows the very first line of
  > copyright year, so if it's multiline (which is quite often) they see very
  > old timestamps.
  
  We should eventually display some sort of modified time as well as all
  of the copyright lines, but at the very least, we can display the last line
  instead of the first line, which usually is much newer than the first.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

2 files changed, 14 insertions(+), 18 deletions(-)
src/apps/haikudepot/model/PackageInfo.cpp  |  2 +-
src/apps/haikudepot/ui/PackageInfoView.cpp | 30 +++++++++++---------------

############################################################################

Commit:      146a80c1cf6dca883d28aa1693078d700104ee57
URL:         https://git.haiku-os.org/haiku/commit/?id=146a80c1cf6d
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Tue Jul 17 02:50:18 2018 UTC

Ticket:      https://dev.haiku-os.org/ticket/14214

HaikuDepot: Refactor & fix layout initialization in RatingItemView.

BLayoutBuilder is designed for single-shot use; i.e., a "one-liner"
of .AddLayout(), .Add(), and .End()s and no variable storage.
This is basically the only coherent way to use the class, as otherwise
it becomes unclear what state it's even in, and in the case of functions
like these with multiple branches for different options, that is doubly true.

It seems that in certain cases, the final SetInsets() after the End()
was winding up one before the "beginning" of the builder and thus attempting
to set the insets of NULL. Rather than analyze the function to determine
under what control-flow this occured (since it only happened for some
packages, and not others), I've opted here for the more systemic solution
to remove usage of BLayoutBuilder entirely, and just create straight BLayouts.

Fixes #14214.

----------------------------------------------------------------------------

diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp 
b/src/apps/haikudepot/ui/PackageInfoView.cpp
index 59c54020ab..b390109fa8 100644
--- a/src/apps/haikudepot/ui/PackageInfoView.cpp
+++ b/src/apps/haikudepot/ui/PackageInfoView.cpp
@@ -874,25 +874,24 @@ public:
        {
                SetViewUIColor(B_PANEL_BACKGROUND_COLOR, kContentTint);
 
-               BLayoutBuilder::Group<BLayoutBuilder::Group<void*> > 
verticalGroup =
-                       BLayoutBuilder::Group<>(this)
-                               .AddGroup(B_VERTICAL, 0.0f);
+               BGroupLayout* verticalGroup = new BGroupLayout(B_VERTICAL, 
0.0f);
+               GroupLayout()->AddItem(verticalGroup);
 
                {
                        BStringView* userNicknameView = new 
BStringView("user-nickname",
                                rating.User().NickName());
                        userNicknameView->SetFont(be_bold_font);
-                       verticalGroup.Add(userNicknameView);
+                       verticalGroup->AddView(userNicknameView);
                }
 
-               BLayoutBuilder::Group<BLayoutBuilder::Group<
-                       BLayoutBuilder::Group<void *> > > ratingGroup =
-                               verticalGroup.AddGroup(B_HORIZONTAL, 
B_USE_DEFAULT_SPACING);
+               BGroupLayout* ratingGroup =
+                       new BGroupLayout(B_HORIZONTAL, B_USE_DEFAULT_SPACING);
+               verticalGroup->AddItem(ratingGroup);
 
                if (rating.Rating() >= 0) {
                        RatingView* ratingView = new RatingView("package rating 
view");
                        ratingView->SetRating(rating.Rating());
-                       ratingGroup.Add(ratingView);
+                       ratingGroup->AddView(ratingView);
                }
 
                {
@@ -913,11 +912,10 @@ public:
                                ratingContextDescription);
                        BFont versionFont(be_plain_font);
                        ratingContextView->SetFont(&versionFont);
-                       ratingGroup.Add(ratingContextView);
+                       ratingGroup->AddView(ratingContextView);
                }
 
-               ratingGroup.AddGlue();
-               ratingGroup.End();
+               ratingGroup->AddItem(BSpaceLayoutItem::CreateGlue());
 
                if (rating.Comment() > 0) {
                        TextView* textView = new TextView("rating-text");
@@ -925,14 +923,12 @@ public:
                        paragraphStyle.SetJustify(true);
                        textView->SetParagraphStyle(paragraphStyle);
                        textView->SetText(rating.Comment());
-                       verticalGroup.AddStrut(8.0f);
-                       verticalGroup.Add(textView);
-                       verticalGroup.AddStrut(8.0f);
+                       
verticalGroup->AddItem(BSpaceLayoutItem::CreateVerticalStrut(8.0f));
+                       verticalGroup->AddView(textView);
+                       
verticalGroup->AddItem(BSpaceLayoutItem::CreateVerticalStrut(8.0f));
                }
 
-               verticalGroup
-                       .End()
-                       .SetInsets(B_USE_DEFAULT_SPACING);
+               verticalGroup->SetInsets(B_USE_DEFAULT_SPACING);
 
                SetFlags(Flags() | B_WILL_DRAW);
        }

############################################################################

Revision:    hrev52108
Commit:      0da0829bbc7ebcdbf9fcabfdd1380e4e9134003e
URL:         https://git.haiku-os.org/haiku/commit/?id=0da0829bbc7e
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Tue Jul 17 03:00:23 2018 UTC

Ticket:      https://dev.haiku-os.org/ticket/13006

HaikuDepot: Display the last copyright line instead of the first.

As Diver notes in #13006:

I saw a few youtube videos with Haiku review where people were confused
with package copyright year in HaikuDepot. They though this was when the
package was last updated. HaikuDepot also only shows the very first line of
copyright year, so if it's multiline (which is quite often) they see very
old timestamps.

We should eventually display some sort of modified time as well as all
of the copyright lines, but at the very least, we can display the last line
instead of the first line, which usually is much newer than the first.

----------------------------------------------------------------------------

diff --git a/src/apps/haikudepot/model/PackageInfo.cpp 
b/src/apps/haikudepot/model/PackageInfo.cpp
index 7eed1adab1..24551d5693 100644
--- a/src/apps/haikudepot/model/PackageInfo.cpp
+++ b/src/apps/haikudepot/model/PackageInfo.cpp
@@ -526,7 +526,7 @@ PackageInfo::PackageInfo(const BPackageInfo& info)
        BString publisherName = info.Vendor();
        const BStringList& rightsList = info.CopyrightList();
        if (rightsList.CountStrings() > 0)
-               publisherName = rightsList.StringAt(0);
+               publisherName = rightsList.Last();
        if (!publisherName.IsEmpty())
                publisherName.Prepend("© ");
 


Other related posts: