[haiku-commits] haiku: hrev45971 - src/apps/haiku-depot

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 18 Aug 2013 11:01:02 +0200 (CEST)

hrev45971 adds 1 changeset to branch 'master'
old head: c58fcc9888a59a3a5b89740afff4025ea7f63cad
new head: 883b8dd0b9be3798b6cf822c9a64470a63fc1afa
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=883b8dd+%5Ec58fcc9

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

883b8dd: HaikuDepot: Show number of up and down votes per user rating

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

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

Revision:    hrev45971
Commit:      883b8dd0b9be3798b6cf822c9a64470a63fc1afa
URL:         http://cgit.haiku-os.org/haiku/commit/?id=883b8dd
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Aug 18 08:59:52 2013 UTC

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

2 files changed, 59 insertions(+), 4 deletions(-)
src/apps/haiku-depot/HaikuDepot.rdef     | 15 +++++++++
src/apps/haiku-depot/PackageInfoView.cpp | 48 +++++++++++++++++++++++++---

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

diff --git a/src/apps/haiku-depot/HaikuDepot.rdef 
b/src/apps/haiku-depot/HaikuDepot.rdef
index 22472d5..ed9547b 100644
--- a/src/apps/haiku-depot/HaikuDepot.rdef
+++ b/src/apps/haiku-depot/HaikuDepot.rdef
@@ -49,6 +49,21 @@ resource(501, "star") #'VICN' array {
        $"C59EC928BEF3C457B84FC928BAD5C165010A00010000"
 };
 
+resource(502, "thumbs up") #'VICN' array {
+       $"6E63696601020016020000003DC000BD80000000004B30004960000056FF4A01"
+       $"060DF6FFFF0358404C4E4C524CC3AF4C3E5046503A50364EBC65C5F5344C3041"
+       $"3046303F383C343C3C3C3F3A3F3A3F383C323CBB103C303E2C3C2C402C403040"
+       $"2E40344638C16DBB23483C50404C405440010A00010000"
+};
+
+resource(503, "thumbs down") #'VICN' array {
+       $"6E63696601020016020000003DC000BD80000000004B30004960000056FF4A01"
+       $"060DF6FFFF035440344A344E34C217343A30423036303232BACDB98A30342C3F"
+       $"2C3A2C413444304438443B463B463B48384E38C46F38503A5438543C543C503C"
+       $"523C4C4248BFD5C45C44444C4048405040010A00010000"
+};
+
+
 resource(601, "WonderBrush icon") #'VICN' array {
        $"6E6369662604015F03010000020006023B24000000000000003B24004A570046"
        $"240000E9C06AFFC7903302000602A83D70BA60513A6051A83D704A1085461F33"
diff --git a/src/apps/haiku-depot/PackageInfoView.cpp 
b/src/apps/haiku-depot/PackageInfoView.cpp
index d97f613..959c39d 100644
--- a/src/apps/haiku-depot/PackageInfoView.cpp
+++ b/src/apps/haiku-depot/PackageInfoView.cpp
@@ -763,7 +763,8 @@ private:
 
 class RatingItemView : public BGroupView {
 public:
-       RatingItemView(const UserRating& rating)
+       RatingItemView(const UserRating& rating, const BitmapRef& voteUpIcon,
+               const BitmapRef& voteDownIcon)
                :
                BGroupView(B_HORIZONTAL, 0.0f)
        {
@@ -800,7 +801,28 @@ public:
                versionFont.SetSize(std::max(9.0f, floorf(versionFont.Size() * 
0.85f)));
                fPackageVersionView->SetFont(&versionFont);
                fPackageVersionView->SetHighColor(kLightBlack);
-       
+
+               fVoteUpIconView = new BitmapView("vote up icon");
+               fUpVoteCountView = new BStringView("up vote count", "");
+               fVoteDownIconView = new BitmapView("vote down icon");
+               fDownVoteCountView = new BStringView("up vote count", "");
+               
+               fVoteUpIconView->SetBitmap(
+                       voteUpIcon->Bitmap(SharedBitmap::SIZE_16));
+               fVoteDownIconView->SetBitmap(
+                       voteDownIcon->Bitmap(SharedBitmap::SIZE_16));
+
+               fUpVoteCountView->SetFont(&versionFont);
+               fUpVoteCountView->SetHighColor(kLightBlack);
+               fDownVoteCountView->SetFont(&versionFont);
+               fDownVoteCountView->SetHighColor(kLightBlack);
+
+               BString voteCountLabel;
+               voteCountLabel.SetToFormat("%ld", rating.UpVotes());
+               fUpVoteCountView->SetText(voteCountLabel);
+               voteCountLabel.SetToFormat("%ld", rating.DownVotes());
+               fDownVoteCountView->SetText(voteCountLabel);
+
                fTextView = new TextView("rating text");
                fTextView->SetViewColor(ViewColor());
                fTextView->SetText(rating.Comment());
@@ -817,6 +839,13 @@ public:
                                        .AddGlue(0.1f)
                                        .Add(fPackageVersionView)
                                        .AddGlue(5.0f)
+                                       .AddGroup(B_HORIZONTAL, 0.0f, 0.0f)
+                                               .Add(fVoteUpIconView)
+                                               .Add(fUpVoteCountView)
+                                               
.AddStrut(B_USE_HALF_ITEM_SPACING)
+                                               .Add(fVoteDownIconView)
+                                               .Add(fDownVoteCountView)
+                                       .End()
                                .End()
                                .Add(fTextView)
                        .End()
@@ -830,6 +859,12 @@ private:
        RatingView*             fRatingView;
        BStringView*    fRatingLabelView;
        BStringView*    fPackageVersionView;
+
+       BitmapView*             fVoteUpIconView;
+       BStringView*    fUpVoteCountView;
+       BitmapView*             fVoteDownIconView;
+       BStringView*    fDownVoteCountView;
+
        TextView*               fTextView;
 };
 
@@ -951,7 +986,9 @@ class UserRatingsView : public BGroupView {
 public:
        UserRatingsView()
                :
-               BGroupView("package ratings view", B_HORIZONTAL)
+               BGroupView("package ratings view", B_HORIZONTAL),
+               fThumbsUpIcon(BitmapRef(new SharedBitmap(502), true)),
+               fThumbsDownIcon(BitmapRef(new SharedBitmap(503), true))
        {
                SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
                        kContentTint));
@@ -994,7 +1031,8 @@ public:
                
                for (int i = userRatings.CountItems() - 1; i >= 0; i--) {
                        const UserRating& rating = userRatings.ItemAtFast(i);
-                       RatingItemView* view = new RatingItemView(rating);
+                       RatingItemView* view = new RatingItemView(rating, 
fThumbsUpIcon,
+                               fThumbsDownIcon);
                        fRatingContainerLayout->AddView(0, view);
                }
        }
@@ -1021,6 +1059,8 @@ public:
 private:
        BGroupLayout*                   fRatingContainerLayout;
        RatingSummaryView*              fRatingSummaryView;
+       BitmapRef                               fThumbsUpIcon;
+       BitmapRef                               fThumbsDownIcon;
 };
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev45971 - src/apps/haiku-depot - superstippi