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

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 28 Jul 2013 15:48:00 +0200 (CEST)

hrev45915 adds 3 changesets to branch 'master'
old head: 3883c02097d4e8819c39d49456d5488c3319bd52
new head: 0aea921993d99c92ba8bc8fc09bf09b334baa83b
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=0aea921+%5E3883c02

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

6c28726: HaikuDepot: Moved some extra classes into .cpp file

cc4fa3b: HaikuDepot: Beginnings of transformation from BTabView

0aea921: HaikuDepot: Show package in info area when selected in list
  
   * Includes fixes along the way. Shows only package title as of
     now.

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

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

6 files changed, 273 insertions(+), 78 deletions(-)
src/apps/haiku-depot/MainWindow.cpp      |  33 +++++-
src/apps/haiku-depot/MainWindow.h        |   4 +
src/apps/haiku-depot/PackageInfoView.cpp | 157 ++++++++++++++++++++++++---
src/apps/haiku-depot/PackageInfoView.h   |  18 ++-
src/apps/haiku-depot/PackageListView.cpp |  79 ++++++++++++++
src/apps/haiku-depot/PackageListView.h   |  60 +---------

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

Commit:      6c28726eabe3f1f3267fbb18fc313f7013b7a928
URL:         http://cgit.haiku-os.org/haiku/commit/?id=6c28726
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Jul 28 13:30:20 2013 UTC

HaikuDepot: Moved some extra classes into .cpp file

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

diff --git a/src/apps/haiku-depot/PackageListView.cpp 
b/src/apps/haiku-depot/PackageListView.cpp
index 9a92470..40b5298 100644
--- a/src/apps/haiku-depot/PackageListView.cpp
+++ b/src/apps/haiku-depot/PackageListView.cpp
@@ -15,6 +15,65 @@
 #define B_TRANSLATION_CONTEXT "PackageListView"
 
 
+// A field type displaying both a bitmap and a string so that the
+// tree display looks nicer (both text and bitmap are indented)
+// TODO: Code-duplication with DriveSetup PartitionList.h
+class BBitmapStringField : public BStringField {
+       typedef BStringField Inherited;
+public:
+                                                               
BBitmapStringField(BBitmap* bitmap,
+                                                                       const 
char* string);
+       virtual                                         ~BBitmapStringField();
+
+                       void                            SetBitmap(BBitmap* 
bitmap);
+                       const BBitmap*          Bitmap() const
+                                                                       { 
return fBitmap; }
+
+private:
+                       BBitmap*                        fBitmap;
+};
+
+
+// BColumn for PackageListView which knows how to render
+// a BBitmapStringField
+// TODO: Code-duplication with DriveSetup PartitionList.h
+class PackageColumn : public BTitledColumn {
+       typedef BTitledColumn Inherited;
+public:
+                                                               
PackageColumn(const char* title,
+                                                                       float 
width, float minWidth,
+                                                                       float 
maxWidth, uint32 truncateMode,
+                                                                       
alignment align = B_ALIGN_LEFT);
+
+       virtual void                            DrawField(BField* field, BRect 
rect,
+                                                                       BView* 
parent);
+       virtual float                           GetPreferredWidth(BField* field,
+                                                                       BView* 
parent) const;
+
+       virtual bool                            AcceptsField(const BField* 
field) const;
+
+       static  void                            InitTextMargin(BView* parent);
+
+private:
+                       uint32                          fTruncateMode;
+       static  float                           sTextMargin;
+};
+
+
+// BRow for the PartitionListView
+class PackageRow : public BRow {
+       typedef BRow Inherited;
+public:
+                                                               
PackageRow(const PackageInfo& package);
+
+                       const PackageInfo&      Package() const
+                                                                       { 
return fPackage; }
+
+private:
+                       PackageInfo                     fPackage;
+};
+
+
 // #pragma mark - BBitmapStringField
 
 
diff --git a/src/apps/haiku-depot/PackageListView.h 
b/src/apps/haiku-depot/PackageListView.h
index cf588f8..eb8a19c 100644
--- a/src/apps/haiku-depot/PackageListView.h
+++ b/src/apps/haiku-depot/PackageListView.h
@@ -12,64 +12,7 @@
 #include "PackageInfo.h"
 
 
-// A field type displaying both a bitmap and a string so that the
-// tree display looks nicer (both text and bitmap are indented)
-// TODO: Code-duplication with DriveSetup PartitionList.h
-class BBitmapStringField : public BStringField {
-       typedef BStringField Inherited;
-public:
-                                                               
BBitmapStringField(BBitmap* bitmap,
-                                                                       const 
char* string);
-       virtual                                         ~BBitmapStringField();
-
-                       void                            SetBitmap(BBitmap* 
bitmap);
-                       const BBitmap*          Bitmap() const
-                                                                       { 
return fBitmap; }
-
-private:
-                       BBitmap*                        fBitmap;
-};
-
-
-// BColumn for PackageListView which knows how to render
-// a BBitmapStringField
-// TODO: Code-duplication with DriveSetup PartitionList.h
-class PackageColumn : public BTitledColumn {
-       typedef BTitledColumn Inherited;
-public:
-                                                               
PackageColumn(const char* title,
-                                                                       float 
width, float minWidth,
-                                                                       float 
maxWidth, uint32 truncateMode,
-                                                                       
alignment align = B_ALIGN_LEFT);
-
-       virtual void                            DrawField(BField* field, BRect 
rect,
-                                                                       BView* 
parent);
-       virtual float                           GetPreferredWidth(BField* field,
-                                                                       BView* 
parent) const;
-
-       virtual bool                            AcceptsField(const BField* 
field) const;
-
-       static  void                            InitTextMargin(BView* parent);
-
-private:
-                       uint32                          fTruncateMode;
-       static  float                           sTextMargin;
-};
-
-
-// BRow for the PartitionListView
-class PackageRow : public BRow {
-       typedef BRow Inherited;
-public:
-                                                               
PackageRow(const PackageInfo& package);
-
-                       const PackageInfo&      Package() const
-                                                                       { 
return fPackage; }
-
-private:
-                       PackageInfo                     fPackage;
-};
-
+class PackageRow;
 
 class PackageListView : public BColumnListView {
 public:

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

Commit:      cc4fa3bf29d018606d50a77681d0e0cbe3a75224
URL:         http://cgit.haiku-os.org/haiku/commit/?id=cc4fa3b
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Jul 28 13:30:53 2013 UTC

HaikuDepot: Beginnings of transformation from BTabView

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

diff --git a/src/apps/haiku-depot/PackageInfoView.cpp 
b/src/apps/haiku-depot/PackageInfoView.cpp
index 662f1ab..9f7af16 100644
--- a/src/apps/haiku-depot/PackageInfoView.cpp
+++ b/src/apps/haiku-depot/PackageInfoView.cpp
@@ -8,6 +8,7 @@
 #include <algorithm>
 #include <stdio.h>
 
+#include <Bitmap.h>
 #include <Button.h>
 #include <Catalog.h>
 #include <LayoutBuilder.h>
@@ -18,24 +19,125 @@
 #define B_TRANSLATION_CONTEXT "PackageInfoView"
 
 
-PackageInfoView::PackageInfoView()
-       :
-       BTabView("package info view", B_WIDTH_FROM_WIDEST)
-{
-       fDescriptionView = new BView("about", 0);
-       AddTab(fDescriptionView);
+class TitleView : public BView {
+public:
+       TitleView()
+               :
+               BView("title view", B_WILL_DRAW),
+               fIcon(NULL),
+               fTitle()
+       {
+               SetViewColor(B_TRANSPARENT_COLOR);
+               SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+               
+               // Title font
+               BFont font;
+               GetFont(&font);
+               font.SetSize(font.Size() * 2.0f);
+               SetFont(&font);
+       }
+       
+       virtual ~TitleView()
+       {
+               Clear();
+       }
 
-       fRatingAndCommentsView = new BView("rating and comments", 0);
-       AddTab(fRatingAndCommentsView);
+       virtual void Draw(BRect updateRect)
+       {
+               BPoint offset(B_ORIGIN);
+               BRect bounds(Bounds());
+               
+               if (fIcon != NULL) {
+                       // TODO: ...
+               }
+               
+               if (fTitle.Length() > 0) {
+                       // TODO: Truncate title
+                       font_height fontHeight;
+                       GetFontHeight(&fontHeight);
+
+                       offset.y = ceilf((bounds.Height() + fontHeight.ascent) 
/ 2.0f);
+                       DrawString(fTitle.String(), offset);
+               }
+       }
 
-       fChangeLogView = new BView("changelog", 0);
-       AddTab(fChangeLogView);
+       virtual BSize MinSize()
+       {
+               BSize size(0.0f, 0.0f);
+               
+               if (fTitle.Length() > 0) {
+                       font_height fontHeight;
+                       GetFontHeight(&fontHeight);
+
+                       size.width = StringWidth(fTitle.String());
+                       size.height = ceilf(fontHeight.ascent + 
fontHeight.descent);
+               }
+               
+               return size;
+       }
+       
+       void SetPackage(const PackageInfo& package)
+       {
+               // TODO: Fetch icon
+               fTitle = package.Title();
+               InvalidateLayout();
+       }
+
+       void Clear()
+       {
+               delete fIcon;
+               fIcon = NULL;
+               fTitle = "";
+       }
 
-       TabAt(0)->SetLabel(B_TRANSLATE("About"));
-       TabAt(1)->SetLabel(B_TRANSLATE("Rating & comments"));
-       TabAt(2)->SetLabel(B_TRANSLATE("Changelog"));
+private:
+       BBitmap*        fIcon;
+       BString         fTitle;
+};
 
-       Select(0);
+
+class PagesView : public BView {
+public:
+       PagesView()
+               :
+               BView("pages view", B_WILL_DRAW)
+       {
+               SetViewColor(B_TRANSPARENT_COLOR);
+               SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+       }
+       
+       virtual ~PagesView()
+       {
+               Clear();
+       }
+
+       virtual void Draw(BRect updateRect)
+       {
+       }
+
+       void SetPackage(const PackageInfo& package)
+       {
+       }
+
+       void Clear()
+       {
+       }
+
+private:
+};
+
+
+PackageInfoView::PackageInfoView()
+       :
+       BGroupView("package info view", B_VERTICAL)
+{
+       fTitleView = new TitleView();
+       fPagesView = new PagesView();
+
+       BLayoutBuilder::Group<>(this)
+               .Add(fTitleView)
+               .Add(fPagesView)
+       ;
 }
 
 
@@ -55,7 +157,24 @@ PackageInfoView::MessageReceived(BMessage* message)
 {
        switch (message->what) {
                default:
-                       BTabView::MessageReceived(message);
+                       BGroupView::MessageReceived(message);
                        break;
        }
 }
+
+
+void
+PackageInfoView::SetPackage(const PackageInfo& package)
+{
+       fTitleView->SetPackage(package);
+       fPagesView->SetPackage(package);
+}
+
+
+void
+PackageInfoView::Clear()
+{
+       fTitleView->Clear();
+       fPagesView->Clear();
+}
+
diff --git a/src/apps/haiku-depot/PackageInfoView.h 
b/src/apps/haiku-depot/PackageInfoView.h
index d174988..683c28e 100644
--- a/src/apps/haiku-depot/PackageInfoView.h
+++ b/src/apps/haiku-depot/PackageInfoView.h
@@ -5,10 +5,16 @@
 #ifndef PACKAGE_INFO_VIEW_H
 #define PACKAGE_INFO_VIEW_H
 
-#include <TabView.h>
+#include <GroupView.h>
 
+#include "PackageInfo.h"
 
-class PackageInfoView : public BTabView {
+
+class TitleView;
+class PagesView;
+
+
+class PackageInfoView : public BGroupView {
 public:
                                                                
PackageInfoView();
        virtual                                         ~PackageInfoView();
@@ -16,10 +22,12 @@ public:
        virtual void                            AttachedToWindow();
        virtual void                            MessageReceived(BMessage* 
message);
 
+                       void                            SetPackage(const 
PackageInfo& package);
+                       void                            Clear();
+
 private:
-                       BView*                          fDescriptionView;
-                       BView*                          fRatingAndCommentsView;
-                       BView*                          fChangeLogView;
+                       TitleView*                      fTitleView;
+                       PagesView*                      fPagesView;
 };
 
 #endif // PACKAGE_INFO_VIEW_H

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

Revision:    hrev45915
Commit:      0aea921993d99c92ba8bc8fc09bf09b334baa83b
URL:         http://cgit.haiku-os.org/haiku/commit/?id=0aea921
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Jul 28 13:46:54 2013 UTC

HaikuDepot: Show package in info area when selected in list

 * Includes fixes along the way. Shows only package title as of
   now.

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

diff --git a/src/apps/haiku-depot/MainWindow.cpp 
b/src/apps/haiku-depot/MainWindow.cpp
index e00ca2c..cfec1a6 100644
--- a/src/apps/haiku-depot/MainWindow.cpp
+++ b/src/apps/haiku-depot/MainWindow.cpp
@@ -88,6 +88,19 @@ MainWindow::MessageReceived(BMessage* message)
                case B_SIMPLE_DATA:
                case B_REFS_RECEIVED:
                        break;
+
+               case MSG_PACKAGE_SELECTED:
+               {
+                       int32 index;
+                       if (message->FindInt32("index", &index) == B_OK
+                               && index >= 0 && index < 
fVisiblePackages.CountItems()) {
+                               
_AdoptPackage(fVisiblePackages.ItemAtFast(index));
+                       } else {
+                               _ClearPackage();
+                       }
+                       break;
+               }
+               
                default:
                        BWindow::MessageReceived(message);
                        break;
@@ -107,16 +120,30 @@ MainWindow::_BuildMenu(BMenuBar* menuBar)
 void
 MainWindow::_AdoptModel()
 {
-       PackageInfoList packages = fModel.CreatePackageList();
+       fVisiblePackages = fModel.CreatePackageList();
        
        fPackageListView->Clear();
-       for (int32 i = 0; i < packages.CountItems(); i++) {
-               fPackageListView->AddPackage(packages.ItemAtFast(i));
+       for (int32 i = 0; i < fVisiblePackages.CountItems(); i++) {
+               fPackageListView->AddPackage(fVisiblePackages.ItemAtFast(i));
        }
 }
 
 
 void
+MainWindow::_AdoptPackage(const PackageInfo& package)
+{
+       fPackageInfoView->SetPackage(package);
+}
+
+
+void
+MainWindow::_ClearPackage()
+{
+       fPackageInfoView->Clear();
+}
+
+
+void
 MainWindow::_InitDummyModel()
 {
        // TODO: The Model could be filled from another thread by 
diff --git a/src/apps/haiku-depot/MainWindow.h 
b/src/apps/haiku-depot/MainWindow.h
index f1aff79..bca9efd 100644
--- a/src/apps/haiku-depot/MainWindow.h
+++ b/src/apps/haiku-depot/MainWindow.h
@@ -33,6 +33,9 @@ public:
 private:
                        void                            _BuildMenu(BMenuBar* 
menuBar);
                        void                            _AdoptModel();
+                       
+                       void                            _AdoptPackage(const 
PackageInfo& package);
+                       void                            _ClearPackage();
 
                        void                            _InitDummyModel();
 
@@ -44,6 +47,7 @@ private:
                        BSplitView*                     fSplitView;
 
                        Model                           fModel;
+                       PackageInfoList         fVisiblePackages;
 };
 
 #endif // MAIN_WINDOW_H
diff --git a/src/apps/haiku-depot/PackageInfoView.cpp 
b/src/apps/haiku-depot/PackageInfoView.cpp
index 9f7af16..3d5e65e 100644
--- a/src/apps/haiku-depot/PackageInfoView.cpp
+++ b/src/apps/haiku-depot/PackageInfoView.cpp
@@ -23,7 +23,7 @@ class TitleView : public BView {
 public:
        TitleView()
                :
-               BView("title view", B_WILL_DRAW),
+               BView("title view", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
                fIcon(NULL),
                fTitle()
        {
@@ -47,6 +47,8 @@ public:
                BPoint offset(B_ORIGIN);
                BRect bounds(Bounds());
                
+               FillRect(updateRect, B_SOLID_LOW);
+               
                if (fIcon != NULL) {
                        // TODO: ...
                }
@@ -81,6 +83,7 @@ public:
                // TODO: Fetch icon
                fTitle = package.Title();
                InvalidateLayout();
+               Invalidate();
        }
 
        void Clear()
@@ -88,6 +91,11 @@ public:
                delete fIcon;
                fIcon = NULL;
                fTitle = "";
+
+               if (Parent() != NULL) {
+                       InvalidateLayout();
+                       Invalidate();
+               }
        }
 
 private:
diff --git a/src/apps/haiku-depot/PackageListView.cpp 
b/src/apps/haiku-depot/PackageListView.cpp
index 40b5298..27e3298 100644
--- a/src/apps/haiku-depot/PackageListView.cpp
+++ b/src/apps/haiku-depot/PackageListView.cpp
@@ -9,6 +9,7 @@
 #include <stdio.h>
 
 #include <Catalog.h>
+#include <Window.h>
 
 
 #undef B_TRANSLATION_CONTEXT
@@ -288,6 +289,8 @@ PackageListView::PackageListView()
                B_TRUNCATE_END), kSizeColumn);
        AddColumn(new PackageColumn(B_TRANSLATE("Status"), 100, 50, 500,
                B_TRUNCATE_END), kStatusColumn);
+
+       SetSortingEnabled(true);
 }
 
 
@@ -315,6 +318,23 @@ PackageListView::MessageReceived(BMessage* message)
 
 
 void
+PackageListView::SelectionChanged()
+{
+       BColumnListView::SelectionChanged();
+       
+       BMessage message(MSG_PACKAGE_SELECTED);
+       
+       BRow* selected = CurrentSelection();
+       int32 index = -1;
+       if (selected != NULL)
+               index = IndexOf(selected);
+       message.AddInt32("index", index);
+       
+       Window()->PostMessage(&message);
+}
+
+
+void
 PackageListView::AddPackage(const PackageInfo& package)
 {
        PackageRow* packageRow = _FindRow(package);
diff --git a/src/apps/haiku-depot/PackageListView.h 
b/src/apps/haiku-depot/PackageListView.h
index eb8a19c..05c57a3 100644
--- a/src/apps/haiku-depot/PackageListView.h
+++ b/src/apps/haiku-depot/PackageListView.h
@@ -14,6 +14,11 @@
 
 class PackageRow;
 
+enum {
+       MSG_PACKAGE_SELECTED            = 'pkgs',
+};
+
+
 class PackageListView : public BColumnListView {
 public:
                                                                
PackageListView();
@@ -22,6 +27,8 @@ public:
        virtual void                            AttachedToWindow();
        virtual void                            MessageReceived(BMessage* 
message);
 
+       virtual void                            SelectionChanged();
+
                        void                            AddPackage(const 
PackageInfo& package);
                        
 private:


Other related posts:

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