Skip to content

Commit

Permalink
HaikuDepot: Show number of up and down votes per user rating
Browse files Browse the repository at this point in the history
  • Loading branch information
stippi committed Aug 18, 2013
1 parent c58fcc9 commit 883b8dd
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/apps/haiku-depot/HaikuDepot.rdef
Expand Up @@ -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"
Expand Down
48 changes: 44 additions & 4 deletions src/apps/haiku-depot/PackageInfoView.cpp
Expand Up @@ -763,7 +763,8 @@ class AboutView : public BView {

class RatingItemView : public BGroupView {
public:
RatingItemView(const UserRating& rating)
RatingItemView(const UserRating& rating, const BitmapRef& voteUpIcon,
const BitmapRef& voteDownIcon)
:
BGroupView(B_HORIZONTAL, 0.0f)
{
Expand Down Expand Up @@ -800,7 +801,28 @@ class RatingItemView : public BGroupView {
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());
Expand All @@ -817,6 +839,13 @@ class RatingItemView : public BGroupView {
.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()
Expand All @@ -830,6 +859,12 @@ class RatingItemView : public BGroupView {
RatingView* fRatingView;
BStringView* fRatingLabelView;
BStringView* fPackageVersionView;

BitmapView* fVoteUpIconView;
BStringView* fUpVoteCountView;
BitmapView* fVoteDownIconView;
BStringView* fDownVoteCountView;

TextView* fTextView;
};

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -994,7 +1031,8 @@ class UserRatingsView : public BGroupView {

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);
}
}
Expand All @@ -1021,6 +1059,8 @@ class UserRatingsView : public BGroupView {
private:
BGroupLayout* fRatingContainerLayout;
RatingSummaryView* fRatingSummaryView;
BitmapRef fThumbsUpIcon;
BitmapRef fThumbsDownIcon;
};


Expand Down

0 comments on commit 883b8dd

Please sign in to comment.