hrev48208 adds 12 changesets to branch 'master' old head: eac94f5db9c4fc3e20c9b92ad2a6d2c66a80eef6 new head: 0a9c90292136464a55830f495ee5377915f47085 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=0a9c902+%5Eeac94f5 ---------------------------------------------------------------------------- 6072a7e: HaikuDepot: Added "prominence" member to PackageInfo 9f40cd4: HaikuDepot: Retrieve prominence values from web app 3d869af: HaikuDepot: Separate MessagePackageListener... ...into MessagePackageListener and OnePackageMessagePackageListener. The first one doesn't know which package(s) it's listening to. But it can filter the change notifications now and only react to certain changes. The second one knows which package it's listening to. 0c169ac: HaikuDepot: Add some getters to Model. For category, depot and search terms filter. 64458d2: HaikuDepot: Only list featured packages once. da65110: HaikuDepot: Properly add featured packages. * Rework existing package listener mechanism to report any interesting changes. Listen for prominence changes in addition to package state. * Add featured packages to the FeaturedPackagesView when their prominence is retrived, and also in _AdoptModel(). * In _AdoptModel(), show the featured packages view when no search filters are active and installed packages are not shown either. Otherwise show the list of all packages matching the current filtering. 419dc64: HaikuDepot: Feature packages with prominence <= 200 a3056e4: HaikuDepot: Move selection message constant to MainWindow.h 1f3c1ef: HaikuDepot: Select clicked featured packages dfbf4d3: HaikuDepot: Fix click detection in featured packages Take window activation and parent bounds (a featured package scrolled outside the visible region within the parent) into account. 6f6ad91: HaikuDepot: Improve featured package items Show the summary instead of the version. The layout still sucks, but I will have to implement some kind of row/flow BLayout to get what I initially had in mind. Another TODO is to highlight the clicked item somehow. 0a9c902: HaikuDepot: Show a "Featured packages" label Also remove the left-over separator in the Tools menu. [ Stephan Aßmus <superstippi@xxxxxx> ] ---------------------------------------------------------------------------- 14 files changed, 286 insertions(+), 59 deletions(-) src/apps/haikudepot/model/Model.cpp | 62 ++++++++++- src/apps/haikudepot/model/Model.h | 3 + src/apps/haikudepot/model/PackageInfo.cpp | 16 +++ src/apps/haikudepot/model/PackageInfo.h | 7 ++ src/apps/haikudepot/model/PackageInfoListener.h | 3 +- src/apps/haikudepot/ui/FeaturedPackagesView.cpp | 107 ++++++++++++++----- src/apps/haikudepot/ui/MainWindow.cpp | 67 +++++++++--- src/apps/haikudepot/ui/MainWindow.h | 3 + .../haikudepot/ui/MessagePackageListener.cpp | 41 +++++-- src/apps/haikudepot/ui/MessagePackageListener.h | 21 +++- src/apps/haikudepot/ui/PackageInfoView.cpp | 2 +- src/apps/haikudepot/ui/PackageInfoView.h | 6 +- src/apps/haikudepot/ui/PackageListView.cpp | 2 + src/apps/haikudepot/ui/PackageListView.h | 5 - ############################################################################ Commit: 6072a7e41787e6d7fb72c5dfb186f5df6721f41f URL: http://cgit.haiku-os.org/haiku/commit/?id=6072a7e Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sat Nov 1 21:44:27 2014 UTC HaikuDepot: Added "prominence" member to PackageInfo ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/model/PackageInfo.cpp b/src/apps/haikudepot/model/PackageInfo.cpp index c2b5ecd..7abf257 100644 --- a/src/apps/haikudepot/model/PackageInfo.cpp +++ b/src/apps/haikudepot/model/PackageInfo.cpp @@ -463,6 +463,7 @@ PackageInfo::PackageInfo() fChangelog(), fUserRatings(), fCachedRatingSummary(), + fProminence(0.0f), fScreenshotInfos(), fScreenshots(), fState(NONE), @@ -487,6 +488,7 @@ PackageInfo::PackageInfo(const BPackageInfo& info) fChangelog(), fUserRatings(), fCachedRatingSummary(), + fProminence(0.0f), fScreenshotInfos(), fScreenshots(), fState(NONE), @@ -525,6 +527,7 @@ PackageInfo::PackageInfo(const BString& title, fCategories(), fUserRatings(), fCachedRatingSummary(), + fProminence(0.0f), fScreenshotInfos(), fScreenshots(), fState(NONE), @@ -550,6 +553,7 @@ PackageInfo::PackageInfo(const PackageInfo& other) fCategories(other.fCategories), fUserRatings(other.fUserRatings), fCachedRatingSummary(other.fCachedRatingSummary), + fProminence(other.fProminence), fScreenshotInfos(other.fScreenshotInfos), fScreenshots(other.fScreenshots), fState(other.fState), @@ -577,6 +581,7 @@ PackageInfo::operator=(const PackageInfo& other) fCategories = other.fCategories; fUserRatings = other.fUserRatings; fCachedRatingSummary = other.fCachedRatingSummary; + fProminence = other.fProminence; fScreenshotInfos = other.fScreenshotInfos; fScreenshots = other.fScreenshots; fState = other.fState; @@ -605,6 +610,7 @@ PackageInfo::operator==(const PackageInfo& other) const && fCategories == other.fCategories && fUserRatings == other.fUserRatings && fCachedRatingSummary == other.fCachedRatingSummary + && fProminence == other.fProminence && fScreenshotInfos == other.fScreenshotInfos && fScreenshots == other.fScreenshots && fState == other.fState @@ -832,6 +838,16 @@ PackageInfo::CalculateRatingSummary() const void +PackageInfo::SetProminence(float prominence) +{ + if (fProminence != prominence) { + fProminence = prominence; + _NotifyListeners(PKG_CHANGED_PROMINENCE); + } +} + + +void PackageInfo::ClearScreenshotInfos() { fScreenshotInfos.Clear(); diff --git a/src/apps/haikudepot/model/PackageInfo.h b/src/apps/haikudepot/model/PackageInfo.h index 2bf374a..c4f5389 100644 --- a/src/apps/haikudepot/model/PackageInfo.h +++ b/src/apps/haikudepot/model/PackageInfo.h @@ -317,6 +317,12 @@ public: void SetRatingSummary(const RatingSummary& summary); RatingSummary CalculateRatingSummary() const; + void SetProminence(float prominence); + float Prominence() const + { return fProminence; } + bool HasProminence() const + { return fProminence != 0.0f; } + void ClearScreenshotInfos(); bool AddScreenshotInfo(const ScreenshotInfo& info); const ScreenshotInfoList& ScreenshotInfos() const @@ -348,6 +354,7 @@ private: CategoryList fCategories; UserRatingList fUserRatings; RatingSummary fCachedRatingSummary; + float fProminence; ScreenshotInfoList fScreenshotInfos; BitmapList fScreenshots; PackageState fState; diff --git a/src/apps/haikudepot/model/PackageInfoListener.h b/src/apps/haikudepot/model/PackageInfoListener.h index 9c145fe..04eb07e 100644 --- a/src/apps/haikudepot/model/PackageInfoListener.h +++ b/src/apps/haikudepot/model/PackageInfoListener.h @@ -17,7 +17,8 @@ enum { PKG_CHANGED_STATE = 1 << 4, PKG_CHANGED_ICON = 1 << 5, PKG_CHANGED_CHANGELOG = 1 << 6, - PKG_CHANGED_CATEGORIES = 1 << 7 + PKG_CHANGED_CATEGORIES = 1 << 7, + PKG_CHANGED_PROMINENCE = 1 << 8 // ... }; ############################################################################ Commit: 9f40cd412176bcb816e1b462da4adc382a76086d URL: http://cgit.haiku-os.org/haiku/commit/?id=9f40cd4 Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sat Nov 1 22:43:21 2014 UTC HaikuDepot: Retrieve prominence values from web app ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/model/Model.cpp b/src/apps/haikudepot/model/Model.cpp index dc75960..aeae2c3 100644 --- a/src/apps/haikudepot/model/Model.cpp +++ b/src/apps/haikudepot/model/Model.cpp @@ -1059,6 +1059,13 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data) append_word_list(foundInfo, "rating"); } + double prominenceOrdering; + if (data.FindDouble("prominenceOrdering", &prominenceOrdering) == B_OK) { + package->SetProminence(prominenceOrdering); + + append_word_list(foundInfo, "prominence"); + } + BMessage screenshots; if (data.FindMessage("pkgScreenshots", &screenshots) == B_OK) { package->ClearScreenshotInfos(); ############################################################################ Commit: 3d869af5e4bcefcb8fdc4118cad3f104f71e9a0e URL: http://cgit.haiku-os.org/haiku/commit/?id=3d869af Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sat Nov 1 22:43:50 2014 UTC HaikuDepot: Separate MessagePackageListener... ...into MessagePackageListener and OnePackageMessagePackageListener. The first one doesn't know which package(s) it's listening to. But it can filter the change notifications now and only react to certain changes. The second one knows which package it's listening to. ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp index 7e0289d..4a09bf4 100644 --- a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp +++ b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp @@ -36,7 +36,8 @@ public: PackageView() : BGroupView("package view", B_HORIZONTAL), - fPackageListener(new(std::nothrow) MessagePackageListener(this)) + fPackageListener( + new(std::nothrow) OnePackageMessagePackageListener(this)) { SetViewColor(255, 255, 255); @@ -145,7 +146,7 @@ public: } private: - MessagePackageListener* fPackageListener; + OnePackageMessagePackageListener* fPackageListener; BitmapView* fIconView; diff --git a/src/apps/haikudepot/ui/MessagePackageListener.cpp b/src/apps/haikudepot/ui/MessagePackageListener.cpp index c0d7f92..b80bac4 100644 --- a/src/apps/haikudepot/ui/MessagePackageListener.cpp +++ b/src/apps/haikudepot/ui/MessagePackageListener.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2013-214, Stephan Aßmus <superstippi@xxxxxx>. + * Copyright 2013-2014, Stephan Aßmus <superstippi@xxxxxx>. * All rights reserved. Distributed under the terms of the MIT License. */ @@ -12,9 +12,13 @@ #include "PackageInfo.h" -MessagePackageListener::MessagePackageListener(BView* view) +// #pragma mark - MessagePackageListener + + +MessagePackageListener::MessagePackageListener(BHandler* target) : - fView(view) + fTarget(target), + fChangesMask(0xffffffff) { } @@ -27,7 +31,10 @@ MessagePackageListener::~MessagePackageListener() void MessagePackageListener::PackageChanged(const PackageInfoEvent& event) { - BMessenger messenger(fView); + if ((event.Changes() & fChangesMask) == 0) + return; + + BMessenger messenger(fTarget); if (!messenger.IsValid()) return; @@ -40,7 +47,29 @@ MessagePackageListener::PackageChanged(const PackageInfoEvent& event) void -MessagePackageListener::SetPackage(const PackageInfoRef& package) +MessagePackageListener::SetChangesMask(uint32 mask) +{ + fChangesMask = mask; +} + + +// #pragma mark - OnePackageMessagePackageListener + + +OnePackageMessagePackageListener::OnePackageMessagePackageListener(BHandler* target) + : + MessagePackageListener(target) +{ +} + + +OnePackageMessagePackageListener::~OnePackageMessagePackageListener() +{ +} + + +void +OnePackageMessagePackageListener::SetPackage(const PackageInfoRef& package) { if (fPackage == package) return; @@ -58,7 +87,7 @@ MessagePackageListener::SetPackage(const PackageInfoRef& package) const PackageInfoRef& -MessagePackageListener::Package() const +OnePackageMessagePackageListener::Package() const { return fPackage; } diff --git a/src/apps/haikudepot/ui/MessagePackageListener.h b/src/apps/haikudepot/ui/MessagePackageListener.h index f00b540..935ec1f 100644 --- a/src/apps/haikudepot/ui/MessagePackageListener.h +++ b/src/apps/haikudepot/ui/MessagePackageListener.h @@ -1,5 +1,5 @@ /* - * Copyright 2013-214, Stephan Aßmus <superstippi@xxxxxx>. + * Copyright 2013-2014, Stephan Aßmus <superstippi@xxxxxx>. * All rights reserved. Distributed under the terms of the MIT License. */ #ifndef MESSAGE_PACKAGE_LISTENER_H @@ -13,21 +13,34 @@ enum { MSG_UPDATE_PACKAGE = 'updp' }; -class BView; +class BHandler; class MessagePackageListener : public PackageInfoListener { public: - MessagePackageListener(BView* view); + MessagePackageListener(BHandler* target); virtual ~MessagePackageListener(); virtual void PackageChanged(const PackageInfoEvent& event); + void SetChangesMask(uint32 mask); + +private: + BHandler* fTarget; + uint32 fChangesMask; +}; + + +class OnePackageMessagePackageListener : public MessagePackageListener { +public: + OnePackageMessagePackageListener( + BHandler* target); + virtual ~OnePackageMessagePackageListener(); + void SetPackage(const PackageInfoRef& package); const PackageInfoRef& Package() const; private: - BView* fView; PackageInfoRef fPackage; }; diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp b/src/apps/haikudepot/ui/PackageInfoView.cpp index d6d5ca2..f3c0bcf 100644 --- a/src/apps/haikudepot/ui/PackageInfoView.cpp +++ b/src/apps/haikudepot/ui/PackageInfoView.cpp @@ -1266,7 +1266,7 @@ PackageInfoView::PackageInfoView(BLocker* modelLock, : BView("package info view", 0), fModelLock(modelLock), - fPackageListener(new(std::nothrow) MessagePackageListener(this)) + fPackageListener(new(std::nothrow) OnePackageMessagePackageListener(this)) { fCardLayout = new BCardLayout(); SetLayout(fCardLayout); diff --git a/src/apps/haikudepot/ui/PackageInfoView.h b/src/apps/haikudepot/ui/PackageInfoView.h index 1adb741..7cfbdec 100644 --- a/src/apps/haikudepot/ui/PackageInfoView.h +++ b/src/apps/haikudepot/ui/PackageInfoView.h @@ -13,11 +13,11 @@ class BCardLayout; class BLocker; -class MessagePackageListener; -class TitleView; +class OnePackageMessagePackageListener; class PackageActionHandler; class PackageActionView; class PagesView; +class TitleView; enum { MSG_VOTE_UP = 'vtup', @@ -49,7 +49,7 @@ private: PagesView* fPagesView; PackageInfoRef fPackage; - MessagePackageListener* fPackageListener; + OnePackageMessagePackageListener* fPackageListener; }; #endif // PACKAGE_INFO_VIEW_H ############################################################################ Commit: 0c169ace2edb1bbaffbbce243d56e72cc25b7123 URL: http://cgit.haiku-os.org/haiku/commit/?id=0c169ac Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sat Nov 1 23:42:42 2014 UTC HaikuDepot: Add some getters to Model. For category, depot and search terms filter. ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/model/Model.cpp b/src/apps/haikudepot/model/Model.cpp index aeae2c3..ae399f8 100644 --- a/src/apps/haikudepot/model/Model.cpp +++ b/src/apps/haikudepot/model/Model.cpp @@ -70,6 +70,11 @@ public: return fDepot.Packages().Contains(package); } + const BString& Depot() const + { + return fDepot.Name(); + } + private: DepotInfo fDepot; }; @@ -99,6 +104,11 @@ public: return false; } + const BString& Category() const + { + return fCategory; + } + private: BString fCategory; }; @@ -235,6 +245,20 @@ public: return true; } + BString SearchTerms() const + { + BString searchTerms; + for (int32 i = 0; i < fSearchTerms.CountItems(); i++) { + const BString& term = fSearchTerms.ItemAtFast(i); + if (term.IsEmpty()) + continue; + if (!searchTerms.IsEmpty()) + searchTerms.Append(" "); + searchTerms.Append(term); + } + return searchTerms; + } + private: bool _TextContains(BString text, const BString& string) const { @@ -244,7 +268,7 @@ private: } private: - List<BString, false> fSearchTerms; + StringList fSearchTerms; }; @@ -477,6 +501,17 @@ Model::SetCategory(const BString& category) } +BString +Model::Category() const +{ + CategoryFilter* filter + = dynamic_cast<CategoryFilter*>(fCategoryFilter.Get()); + if (filter == NULL) + return ""; + return filter->Category(); +} + + void Model::SetDepot(const BString& depot) { @@ -484,6 +519,13 @@ Model::SetDepot(const BString& depot) } +BString +Model::Depot() const +{ + return fDepotFilter; +} + + void Model::SetSearchTerms(const BString& searchTerms) { @@ -498,6 +540,17 @@ Model::SetSearchTerms(const BString& searchTerms) } +BString +Model::SearchTerms() const +{ + SearchTermsFilter* filter + = dynamic_cast<SearchTermsFilter*>(fSearchTermsFilter.Get()); + if (filter == NULL) + return ""; + return filter->SearchTerms(); +} + + void Model::SetShowAvailablePackages(bool show) { diff --git a/src/apps/haikudepot/model/Model.h b/src/apps/haikudepot/model/Model.h index 81fa09e..e8dd1d6 100644 --- a/src/apps/haikudepot/model/Model.h +++ b/src/apps/haikudepot/model/Model.h @@ -91,8 +91,11 @@ public: // Configure PackageFilters void SetCategory(const BString& category); + BString Category() const; void SetDepot(const BString& depot); + BString Depot() const; void SetSearchTerms(const BString& searchTerms); + BString SearchTerms() const; void SetShowAvailablePackages(bool show); bool ShowAvailablePackages() const ############################################################################ Commit: 64458d227ce0e494acad9fa284817466fceec4b4 URL: http://cgit.haiku-os.org/haiku/commit/?id=64458d2 Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sat Nov 1 23:43:31 2014 UTC HaikuDepot: Only list featured packages once. ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp index 4a09bf4..e48531a 100644 --- a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp +++ b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp @@ -189,9 +189,6 @@ FeaturedPackagesView::~FeaturedPackagesView() void FeaturedPackagesView::AddPackage(const PackageInfoRef& package) { - PackageView* view = new PackageView(); - view->SetPackage(package); - // Find insertion index (alphabetical) int32 index = 0; for (int32 i = 0; BLayoutItem* item = fPackageListLayout->ItemAt(i); i++) { @@ -200,12 +197,18 @@ FeaturedPackagesView::AddPackage(const PackageInfoRef& package) break; BString title = view->PackageTitle(); - if (title.Compare(package->Title()) >= 0) - break; + if (title == package->Title()) { + // Don't add packages more than once + return; + } - index++; + if (title.Compare(package->Title()) < 0) + index++; } + PackageView* view = new PackageView(); + view->SetPackage(package); + fPackageListLayout->AddView(index, view); } ############################################################################ Commit: da6511046d7247e18adb9302a97c15713b91d217 URL: http://cgit.haiku-os.org/haiku/commit/?id=da65110 Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sat Nov 1 23:44:02 2014 UTC HaikuDepot: Properly add featured packages. * Rework existing package listener mechanism to report any interesting changes. Listen for prominence changes in addition to package state. * Add featured packages to the FeaturedPackagesView when their prominence is retrived, and also in _AdoptModel(). * In _AdoptModel(), show the featured packages view when no search filters are active and installed packages are not shown either. Otherwise show the list of all packages matching the current filtering. ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/ui/MainWindow.cpp b/src/apps/haikudepot/ui/MainWindow.cpp index 35fe32b..fd17ca5 100644 --- a/src/apps/haikudepot/ui/MainWindow.cpp +++ b/src/apps/haikudepot/ui/MainWindow.cpp @@ -61,7 +61,7 @@ enum { MSG_LOG_IN = 'lgin', MSG_LOG_OUT = 'lgot', MSG_AUTHORIZATION_CHANGED = 'athc', - MSG_PACKAGE_STATE_CHANGED = 'mpsc', + MSG_PACKAGE_CHANGED = 'pchd', MSG_SHOW_AVAILABLE_PACKAGES = 'savl', MSG_SHOW_INSTALLED_PACKAGES = 'sins', @@ -147,7 +147,7 @@ MainWindow::MainWindow(BRect frame, const BMessage& settings) listArea->AddChild(fFeaturedPackagesView); listArea->AddChild(fPackageListView); - fListLayout->SetVisibleItem((int32)1); + fListLayout->SetVisibleItem((int32)0); BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f) .AddGroup(B_HORIZONTAL, 0.0f) @@ -398,13 +398,23 @@ MainWindow::MessageReceived(BMessage* message) break; } - case MSG_PACKAGE_STATE_CHANGED: + case MSG_PACKAGE_CHANGED: { PackageInfo* info; if (message->FindPointer("package", (void**)&info) == B_OK) { PackageInfoRef ref(info, true); - BAutolock locker(fModel.Lock()); - fModel.SetPackageState(ref, ref->State()); + uint32 changes; + if (message->FindUInt32("changes", &changes) != B_OK) + changes = 0; + if ((changes & PKG_CHANGED_STATE) != 0) { + BAutolock locker(fModel.Lock()); + fModel.SetPackageState(ref, ref->State()); + } + if ((changes & PKG_CHANGED_PROMINENCE) != 0) { + BAutolock locker(fModel.Lock()); + if (_IsProminentPackage(ref)) + fFeaturedPackagesView->AddPackage(ref); + } } break; } @@ -444,10 +454,12 @@ MainWindow::StoreSettings(BMessage& settings) const void MainWindow::PackageChanged(const PackageInfoEvent& event) { - if ((event.Changes() & PKG_CHANGED_STATE) != 0) { + uint32 whatchedChanges = PKG_CHANGED_STATE | PKG_CHANGED_PROMINENCE; + if ((event.Changes() & whatchedChanges) != 0) { PackageInfoRef ref(event.Package()); - BMessage message(MSG_PACKAGE_STATE_CHANGED); + BMessage message(MSG_PACKAGE_CHANGED); message.AddPointer("package", ref.Get()); + message.AddUInt32("changes", event.Changes()); ref.Detach(); // reference needs to be released by MessageReceived(); PostMessage(&message); @@ -563,8 +575,8 @@ MainWindow::_AdoptModel() const PackageInfoRef& package = fVisiblePackages.ItemAtFast(i); fPackageListView->AddPackage(package); - - if (package->Title() == "beam" || package->Title() == "caya") + + if (_IsProminentPackage(package)) fFeaturedPackagesView->AddPackage(package); } @@ -573,6 +585,23 @@ MainWindow::_AdoptModel() fShowInstalledPackagesItem->SetMarked(fModel.ShowInstalledPackages()); fShowSourcePackagesItem->SetMarked(fModel.ShowSourcePackages()); fShowDevelopPackagesItem->SetMarked(fModel.ShowDevelopPackages()); + + if (fModel.Category() != "" + || fModel.Depot() != "" + || fModel.SearchTerms() != "" + || fModel.ShowInstalledPackages()) { + fListLayout->SetVisibleItem((int32)1); + } else { + fListLayout->SetVisibleItem((int32)0); + } +} + + +bool +MainWindow::_IsProminentPackage(const PackageInfoRef& package) const +{ + return package->HasProminence() && package->Prominence() <= 100 + && package->State() != ACTIVATED; } diff --git a/src/apps/haikudepot/ui/MainWindow.h b/src/apps/haikudepot/ui/MainWindow.h index f65be77..95e18a9 100644 --- a/src/apps/haikudepot/ui/MainWindow.h +++ b/src/apps/haikudepot/ui/MainWindow.h @@ -63,6 +63,8 @@ private: void _InitWorkerThreads(); void _AdoptModel(); + bool _IsProminentPackage( + const PackageInfoRef& package) const; void _AdoptPackage(const PackageInfoRef& package); void _ClearPackage(); ############################################################################ Commit: 419dc642f51c44f8efa83a2be455649539f2407b URL: http://cgit.haiku-os.org/haiku/commit/?id=419dc64 Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sun Nov 2 00:05:16 2014 UTC HaikuDepot: Feature packages with prominence <= 200 ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/ui/MainWindow.cpp b/src/apps/haikudepot/ui/MainWindow.cpp index fd17ca5..41da60a 100644 --- a/src/apps/haikudepot/ui/MainWindow.cpp +++ b/src/apps/haikudepot/ui/MainWindow.cpp @@ -600,7 +600,7 @@ MainWindow::_AdoptModel() bool MainWindow::_IsProminentPackage(const PackageInfoRef& package) const { - return package->HasProminence() && package->Prominence() <= 100 + return package->HasProminence() && package->Prominence() <= 200 && package->State() != ACTIVATED; } ############################################################################ Commit: a3056e412a838cccf2968e660262128bfabe0f56 URL: http://cgit.haiku-os.org/haiku/commit/?id=a3056e4 Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sun Nov 2 00:05:58 2014 UTC HaikuDepot: Move selection message constant to MainWindow.h ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/ui/MainWindow.h b/src/apps/haikudepot/ui/MainWindow.h index 95e18a9..819e8f3 100644 --- a/src/apps/haikudepot/ui/MainWindow.h +++ b/src/apps/haikudepot/ui/MainWindow.h @@ -27,6 +27,7 @@ class PackageListView; enum { MSG_MAIN_WINDOW_CLOSED = 'mwcl', + MSG_PACKAGE_SELECTED = 'pkgs', }; diff --git a/src/apps/haikudepot/ui/PackageListView.cpp b/src/apps/haikudepot/ui/PackageListView.cpp index 5a04e23..bb5c591 100644 --- a/src/apps/haikudepot/ui/PackageListView.cpp +++ b/src/apps/haikudepot/ui/PackageListView.cpp @@ -15,6 +15,8 @@ #include <ScrollBar.h> #include <Window.h> +#include "MainWindow.h" + #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "PackageListView" diff --git a/src/apps/haikudepot/ui/PackageListView.h b/src/apps/haikudepot/ui/PackageListView.h index 44716aa..b7eb82e 100644 --- a/src/apps/haikudepot/ui/PackageListView.h +++ b/src/apps/haikudepot/ui/PackageListView.h @@ -17,11 +17,6 @@ class PackageRow; class PackageListener; -enum { - MSG_PACKAGE_SELECTED = 'pkgs', -}; - - class PackageListView : public BColumnListView { public: PackageListView(BLocker* modelLock); ############################################################################ Commit: 1f3c1ef1c5a1d36390fb72946cd92eb2fa09d469 URL: http://cgit.haiku-os.org/haiku/commit/?id=1f3c1ef Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sun Nov 2 00:06:29 2014 UTC HaikuDepot: Select clicked featured packages ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp index e48531a..e502284 100644 --- a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp +++ b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp @@ -16,6 +16,7 @@ #include <SpaceLayoutItem.h> #include "BitmapView.h" +#include "MainWindow.h" #include "MessagePackageListener.h" #include "RatingView.h" #include "ScrollableGroupView.h" @@ -40,6 +41,7 @@ public: new(std::nothrow) OnePackageMessagePackageListener(this)) { SetViewColor(255, 255, 255); + SetEventMask(B_POINTER_EVENTS); fIconView = new BitmapView("package icon view"); fTitleView = new BStringView("package title view", ""); @@ -106,6 +108,15 @@ public: } } } + + virtual void MouseDown(BPoint where) + { + if (Bounds().Contains(where)) { + BMessage message(MSG_PACKAGE_SELECTED); + message.AddString("title", PackageTitle()); + Window()->PostMessage(&message); + } + } void SetPackage(const PackageInfoRef& package) { ############################################################################ Commit: dfbf4d3885af5855811bd3d9a19c5e3baff0ee03 URL: http://cgit.haiku-os.org/haiku/commit/?id=dfbf4d3 Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sun Nov 2 00:21:15 2014 UTC HaikuDepot: Fix click detection in featured packages Take window activation and parent bounds (a featured package scrolled outside the visible region within the parent) into account. ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp index e502284..e7978c5 100644 --- a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp +++ b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp @@ -111,7 +111,12 @@ public: virtual void MouseDown(BPoint where) { - if (Bounds().Contains(where)) { + BRect bounds = Bounds(); + BRect parentBounds = Parent()->Bounds(); + ConvertFromParent(&parentBounds); + bounds = bounds & parentBounds; + + if (bounds.Contains(where) && Window()->IsActive()) { BMessage message(MSG_PACKAGE_SELECTED); message.AddString("title", PackageTitle()); Window()->PostMessage(&message); ############################################################################ Commit: 6f6ad9153b4cedabe77a70543e6d5cebbc7567a6 URL: http://cgit.haiku-os.org/haiku/commit/?id=6f6ad91 Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sun Nov 2 00:36:19 2014 UTC HaikuDepot: Improve featured package items Show the summary instead of the version. The layout still sucks, but I will have to implement some kind of row/flow BLayout to get what I initially had in mind. Another TODO is to highlight the clicked item somehow. ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp index e7978c5..eb4e75d 100644 --- a/src/apps/haikudepot/ui/FeaturedPackagesView.cpp +++ b/src/apps/haikudepot/ui/FeaturedPackagesView.cpp @@ -17,6 +17,7 @@ #include "BitmapView.h" #include "MainWindow.h" +#include "MarkupTextView.h" #include "MessagePackageListener.h" #include "RatingView.h" #include "ScrollableGroupView.h" @@ -64,14 +65,22 @@ public: fPublisherView->SetFont(&font); fPublisherView->SetHighColor(kLightBlack); - // slightly bigger font - GetFont(&font); - font.SetSize(ceilf(font.Size() * 1.2f)); - // Version info - fVersionInfo = new BStringView("package version info", ""); - fVersionInfo->SetFont(&font); - fVersionInfo->SetHighColor(kLightBlack); + fSummaryView = new MarkupTextView("package summary"); + + // Rating view + fRatingView = new RatingView("package rating view"); + + fAvgRating = new BStringView("package average rating", ""); + fAvgRating->SetFont(&font); + fAvgRating->SetHighColor(kLightBlack); + + fVoteInfo = new BStringView("package vote info", ""); + // small font + GetFont(&font); + font.SetSize(std::max(9.0f, floorf(font.Size() * 0.85f))); + fVoteInfo->SetFont(&font); + fVoteInfo->SetHighColor(kLightBlack); BLayoutBuilder::Group<>(this) .Add(fIconView) @@ -81,11 +90,14 @@ public: .SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)) .End() .AddGlue(0.1f) - .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING, 2.0f) - .Add(fVersionInfo) - .AddGlue() - .SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)) + .AddGroup(B_HORIZONTAL, 0.8f) + .Add(fRatingView) + .Add(fAvgRating) + .Add(fVoteInfo) .End() + .AddGlue(0.2f) + .Add(fSummaryView, 2.0f) + .SetInsets(B_USE_WINDOW_INSETS) ; @@ -138,9 +150,29 @@ public: BString publisher = package->Publisher().Name(); fPublisherView->SetText(publisher); - BString version = B_TRANSLATE("%Version%"); - version.ReplaceAll("%Version%", package->Version().ToString()); - fVersionInfo->SetText(version); + BString summary = package->ShortDescription(); + fSummaryView->SetText(summary); + + RatingSummary ratingSummary = package->CalculateRatingSummary(); + + fRatingView->SetRating(ratingSummary.averageRating); + + if (ratingSummary.ratingCount > 0) { + BString avgRating; + avgRating.SetToFormat("%.1f", ratingSummary.averageRating); + fAvgRating->SetText(avgRating); + + BString votes; + votes.SetToFormat("%d", ratingSummary.ratingCount); + + BString voteInfo(B_TRANSLATE("(%Votes%)")); + voteInfo.ReplaceAll("%Votes%", votes); + + fVoteInfo->SetText(voteInfo); + } else { + fAvgRating->SetText(""); + fVoteInfo->SetText(""); + } InvalidateLayout(); Invalidate(); @@ -153,7 +185,10 @@ public: fIconView->SetBitmap(NULL); fTitleView->SetText(""); fPublisherView->SetText(""); - fVersionInfo->SetText(""); + fSummaryView->SetText(""); + fRatingView->SetRating(-1.0f); + fAvgRating->SetText(""); + fVoteInfo->SetText(""); } const char* PackageTitle() const @@ -169,7 +204,11 @@ private: BStringView* fTitleView; BStringView* fPublisherView; - BStringView* fVersionInfo; + MarkupTextView* fSummaryView; + + RatingView* fRatingView; + BStringView* fAvgRating; + BStringView* fVoteInfo; }; ############################################################################ Revision: hrev48208 Commit: 0a9c90292136464a55830f495ee5377915f47085 URL: http://cgit.haiku-os.org/haiku/commit/?id=0a9c902 Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sun Nov 2 01:00:51 2014 UTC HaikuDepot: Show a "Featured packages" label Also remove the left-over separator in the Tools menu. ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/ui/MainWindow.cpp b/src/apps/haikudepot/ui/MainWindow.cpp index 41da60a..1a103b1 100644 --- a/src/apps/haikudepot/ui/MainWindow.cpp +++ b/src/apps/haikudepot/ui/MainWindow.cpp @@ -23,6 +23,7 @@ #include <Messenger.h> #include <ScrollView.h> #include <StringList.h> +#include <StringView.h> #include <TabView.h> #include <package/Context.h> @@ -139,14 +140,24 @@ MainWindow::MainWindow(BRect frame, const BMessage& settings) fSplitView = new BSplitView(B_VERTICAL, 5.0f); - BView* listArea = new BView("list area", 0); + BGroupView* featuredPackagesGroup = new BGroupView(B_VERTICAL); + BStringView* featuredPackagesTitle = new BStringView( + "featured packages title", B_TRANSLATE("Featured packages")); + BFont font(be_bold_font); + font.SetSize(font.Size() * 1.3f); + featuredPackagesTitle->SetFont(&font); + featuredPackagesGroup->SetExplicitMaxSize( + BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); + BLayoutBuilder::Group<>(featuredPackagesGroup) + .Add(featuredPackagesTitle) + .Add(fFeaturedPackagesView) + ; + BView* listArea = new BView("list area", 0); fListLayout = new BCardLayout(); listArea->SetLayout(fListLayout); - - listArea->AddChild(fFeaturedPackagesView); + listArea->AddChild(featuredPackagesGroup); listArea->AddChild(fPackageListView); - fListLayout->SetVisibleItem((int32)0); BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f) @@ -493,7 +504,6 @@ MainWindow::_BuildMenu(BMenuBar* menuBar) BMenu* menu = new BMenu(B_TRANSLATE("Tools")); menu->AddItem(new BMenuItem(B_TRANSLATE("Refresh depots"), new BMessage(MSG_REFRESH_DEPOTS))); - menu->AddSeparatorItem(); menuBar->AddItem(menu);