From d543cbfcf635e2ca662172561252ba642c6debfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 8 Dec 2013 14:14:39 +0100 Subject: [PATCH] HaikuDepot: Show message when no package is selected. the instable layout was irritating. Clicking a package and having the package info area expand upward could even lead to the clicked packed to be hidden in the listview. Now a message is displayed and the package info area already has the correct height. --- src/apps/haiku-depot/PackageInfoView.cpp | 34 +++++++++++++++++++----- src/apps/haiku-depot/PackageInfoView.h | 4 ++- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/apps/haiku-depot/PackageInfoView.cpp b/src/apps/haiku-depot/PackageInfoView.cpp index 9042386c24..0ab5a54374 100644 --- a/src/apps/haiku-depot/PackageInfoView.cpp +++ b/src/apps/haiku-depot/PackageInfoView.cpp @@ -1303,17 +1303,39 @@ private: PackageInfoView::PackageInfoView(BLocker* modelLock, PackageActionHandler* handler) : - BGroupView("package info view", B_VERTICAL), + BView("package info view", 0), fModelLock(modelLock), fPackageListener(new(std::nothrow) Listener(this)) { + fCardLayout = new BCardLayout(); + SetLayout(fCardLayout); + + BGroupView* noPackageCard = new BGroupView("no package card", B_VERTICAL); + AddChild(noPackageCard); + + BStringView* noPackageView = new BStringView("no package view", + B_TRANSLATE("Click a package to view information")); + noPackageView->SetHighColor(kLightBlack); + noPackageView->SetExplicitAlignment(BAlignment( + B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER)); + + BLayoutBuilder::Group<>(noPackageCard) + .Add(noPackageView) + .SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)) + ; + + BGroupView* packageCard = new BGroupView("package card", B_VERTICAL); + AddChild(packageCard); + + fCardLayout->SetVisibleItem(0L); + fTitleView = new TitleView(); fPackageActionView = new PackageActionView(handler); fPackageActionView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); fPagesView = new PagesView(); - BLayoutBuilder::Group<>(this) + BLayoutBuilder::Group<>(packageCard) .AddGroup(B_HORIZONTAL, 0.0f) .Add(fTitleView, 6.0f) .Add(fPackageActionView, 1.0f) @@ -1378,7 +1400,7 @@ PackageInfoView::MessageReceived(BMessage* message) break; } default: - BGroupView::MessageReceived(message); + BView::MessageReceived(message); break; } } @@ -1395,8 +1417,7 @@ PackageInfoView::SetPackage(const PackageInfoRef& packageRef) fPackageActionView->SetPackage(package); fPagesView->SetPackage(package); - if (fPagesView->IsHidden(fPagesView)) - fPagesView->Show(); + fCardLayout->SetVisibleItem(1L); fPackageListener->SetPackage(packageRef); } @@ -1409,8 +1430,7 @@ PackageInfoView::Clear() fPackageActionView->Clear(); fPagesView->Clear(); - if (!fPagesView->IsHidden(fPagesView)) - fPagesView->Hide(); + fCardLayout->SetVisibleItem(0L); BAutolock _(fModelLock); diff --git a/src/apps/haiku-depot/PackageInfoView.h b/src/apps/haiku-depot/PackageInfoView.h index c5dac54159..eb2848f346 100644 --- a/src/apps/haiku-depot/PackageInfoView.h +++ b/src/apps/haiku-depot/PackageInfoView.h @@ -11,6 +11,7 @@ #include "PackageInfoListener.h" +class BCardLayout; class BLocker; class TitleView; class PackageActionHandler; @@ -23,7 +24,7 @@ enum { }; -class PackageInfoView : public BGroupView { +class PackageInfoView : public BView { public: PackageInfoView(BLocker* modelLock, PackageActionHandler* handler); @@ -41,6 +42,7 @@ private: private: BLocker* fModelLock; + BCardLayout* fCardLayout; TitleView* fTitleView; PackageActionView* fPackageActionView; PagesView* fPagesView;