[haiku-commits] BRANCH haiku.master [52c07497235d] headers/os/interface src/kits/interface

  • From: haiku.master <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 27 Dec 2015 05:37:01 +0100 (CET)

added 2 changesets to branch 'refs/remotes/haiku/master'
old head: c09a549146f9e11603e6ea2434412e43279ef436
new head: 52c07497235d833c3438bf42c2472f0fb7d45283

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

5f2db70ffb61: Interface Kit: Add BCardView

Signed-off-by: Augustin Cavalier <waddlesplash@xxxxxxxxx>

52c07497235d: BLayoutBuilder: Add support for BCardLayout

Signed-off-by: Augustin Cavalier <waddlesplash@xxxxxxxxx>

[ Markus Himmel <markus@xxxxxxxxxxxxxxxxx> ]

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

4 files changed, 586 insertions(+)
headers/os/interface/CardView.h | 47 ++++
headers/os/interface/LayoutBuilder.h | 457 +++++++++++++++++++++++++++++++
src/kits/interface/CardView.cpp | 81 ++++++
src/kits/interface/Jamfile | 1 +

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

Commit: 5f2db70ffb61959e967b7380fd9253be3a13cfdd
Author: Markus Himmel <markus@xxxxxxxxxxxxxxxxx>
Date: Sat Dec 26 21:12:29 2015 UTC
Committer: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Commit-Date: Sun Dec 27 01:13:22 2015 UTC

Interface Kit: Add BCardView

Signed-off-by: Augustin Cavalier <waddlesplash@xxxxxxxxx>

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

diff --git a/headers/os/interface/CardView.h b/headers/os/interface/CardView.h
new file mode 100644
index 0000000..4973aa9
--- /dev/null
+++ b/headers/os/interface/CardView.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2015, Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _CARD_VIEW_H
+#define _CARD_VIEW_H
+
+#include <View.h>
+
+class BCardLayout;
+
+class BCardView : public BView {
+public:
+ BCardView();
+ BCardView(const
char* name);
+
BCardView(BMessage* from);
+ virtual ~BCardView();
+
+ virtual void SetLayout(BLayout* layout);
+ BCardLayout* CardLayout() const;
+
+ static BArchivable* Instantiate(BMessage* from);
+
+ virtual status_t Perform(perform_code d, void*
arg);
+
+private:
+
+ // FBC padding - prevent breaking compatibility when methods are added
+ virtual void _ReservedCardView1();
+ virtual void _ReservedCardView2();
+ virtual void _ReservedCardView3();
+ virtual void _ReservedCardView4();
+ virtual void _ReservedCardView5();
+ virtual void _ReservedCardView6();
+ virtual void _ReservedCardView7();
+ virtual void _ReservedCardView8();
+ virtual void _ReservedCardView9();
+ virtual void _ReservedCardView10();
+
+ // forbitten methods
+ BCardView(const
BCardView&);
+ void operator =(const
BCardView&);
+
+ uint32 _reserved[10];
+};
+
+#endif // _CARD_VIEW_H
diff --git a/src/kits/interface/CardView.cpp b/src/kits/interface/CardView.cpp
new file mode 100644
index 0000000..25c31c7
--- /dev/null
+++ b/src/kits/interface/CardView.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2015, Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT license.
+ */
+
+
+#include <CardLayout.h>
+#include <CardView.h>
+
+
+BCardView::BCardView()
+ :
+ BView(NULL, 0, new BCardLayout())
+{
+ SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+}
+
+
+BCardView::BCardView(const char* name)
+ :
+ BView(name, 0, new BCardLayout())
+{
+ SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+}
+
+
+BCardView::BCardView(BMessage* from)
+ :
+ BView(from)
+{
+}
+
+
+BCardView::~BCardView()
+{
+}
+
+
+void
+BCardView::SetLayout(BLayout* layout)
+{
+ if (dynamic_cast<BCardLayout*>(layout) == NULL)
+ return;
+
+ BView::SetLayout(layout);
+}
+
+
+BCardLayout*
+BCardView::CardLayout() const
+{
+ return static_cast<BCardLayout*>(GetLayout());
+}
+
+
+BArchivable*
+BCardView::Instantiate(BMessage* from)
+{
+ if (validate_instantiation(from, "BCardView"))
+ return new BCardView(from);
+ return NULL;
+}
+
+
+status_t
+BCardView::Perform(perform_code d, void* arg)
+{
+ return BView::Perform(d, arg);
+}
+
+
+void BCardView::_ReservedCardView1() {}
+void BCardView::_ReservedCardView2() {}
+void BCardView::_ReservedCardView3() {}
+void BCardView::_ReservedCardView4() {}
+void BCardView::_ReservedCardView5() {}
+void BCardView::_ReservedCardView6() {}
+void BCardView::_ReservedCardView7() {}
+void BCardView::_ReservedCardView8() {}
+void BCardView::_ReservedCardView9() {}
+void BCardView::_ReservedCardView10() {}
diff --git a/src/kits/interface/Jamfile b/src/kits/interface/Jamfile
index cec0540..c02b07b 100644
--- a/src/kits/interface/Jamfile
+++ b/src/kits/interface/Jamfile
@@ -51,6 +51,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
Box.cpp
Button.cpp
CardLayout.cpp
+ CardView.cpp
ChannelControl.cpp
ChannelSlider.cpp
CheckBox.cpp

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

Commit: 52c07497235d833c3438bf42c2472f0fb7d45283
Author: Markus Himmel <markus@xxxxxxxxxxxxxxxxx>
Date: Sat Dec 26 23:12:01 2015 UTC
Committer: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Commit-Date: Sun Dec 27 01:13:25 2015 UTC

BLayoutBuilder: Add support for BCardLayout

Signed-off-by: Augustin Cavalier <waddlesplash@xxxxxxxxx>

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

diff --git a/headers/os/interface/LayoutBuilder.h
b/headers/os/interface/LayoutBuilder.h
index 5f7c721..1c54716 100644
--- a/headers/os/interface/LayoutBuilder.h
+++ b/headers/os/interface/LayoutBuilder.h
@@ -8,6 +8,8 @@

#include <new>

+#include <CardLayout.h>
+#include <CardView.h>
#include <GridLayout.h>
#include <GridView.h>
#include <GroupLayout.h>
@@ -27,6 +29,7 @@ template<typename ParentBuilder> class Base;
template<typename ParentBuilder = void*> class Group;
template<typename ParentBuilder = void*> class Grid;
template<typename ParentBuilder = void*> class Split;
+template<typename ParentBuilder = void*> class Cards;
template<typename ParentBuilder = void*> class Menu;
template<typename ParentBuilder = void*> class MenuItem;

@@ -53,6 +56,7 @@ public:
typedef Group<ThisBuilder> GroupBuilder;
typedef Grid<ThisBuilder> GridBuilder;
typedef Split<ThisBuilder> SplitBuilder;
+ typedef Cards<ThisBuilder> CardBuilder;

public:
inline Group(orientation
orientation = B_HORIZONTAL,
@@ -99,6 +103,12 @@ public:
inline SplitBuilder AddSplit(BSplitView* splitView,
float
weight = 1.0f);

+ inline CardBuilder AddCards(float weight = 1.0f);
+ inline CardBuilder AddCards(BCardLayout*
cardLayout,
+ float
weight = 1.0f);
+ inline CardBuilder AddCards(BCardView* cardView,
+ float
weight = 1.0f);
+
inline ThisBuilder& AddGlue(float weight = 1.0f);
inline ThisBuilder& AddStrut(float size);

@@ -126,6 +136,7 @@ public:
typedef Group<ThisBuilder> GroupBuilder;
typedef Grid<ThisBuilder> GridBuilder;
typedef Split<ThisBuilder> SplitBuilder;
+ typedef Cards<ThisBuilder> CardBuilder;

public:
inline Grid(float horizontal
@@ -192,6 +203,15 @@ public:
int32
row, int32 columnCount = 1,
int32
rowCount = 1);

+ inline CardBuilder AddCards(int32 column, int32
row,
+ int32
columnCount = 1, int32 rowCount = 1);
+ inline CardBuilder AddCards(BCardLayout*
cardLayout, int32 column,
+ int32
row, int32 columnCount = 1,
+ int32
rowCount = 1);
+ inline CardBuilder AddCards(BCardView* cardView,
int32 column,
+ int32
row, int32 columnCount = 1,
+ int32
rowCount = 1);
+
inline ThisBuilder& AddGlue(int32 column, int32 row,
int32
columnCount = 1, int32 rowCount = 1);

@@ -226,6 +246,7 @@ public:
typedef Group<ThisBuilder> GroupBuilder;
typedef Grid<ThisBuilder> GridBuilder;
typedef Split<ThisBuilder> SplitBuilder;
+ typedef Cards<ThisBuilder> CardBuilder;

public:
inline Split(orientation
orientation = B_HORIZONTAL,
@@ -264,6 +285,12 @@ public:
inline SplitBuilder AddSplit(BSplitView* splitView,
float
weight = 1.0f);

+ inline CardBuilder AddCards(float weight = 1.0f);
+ inline CardBuilder AddCards(BCardLayout*
cardLayout,
+ float
weight = 1.0f);
+ inline CardBuilder AddCards(BCardView* cardView,
+ float
weight = 1.0f);
+
inline ThisBuilder& SetCollapsible(bool collapsible);
inline ThisBuilder& SetCollapsible(int32 index, bool
collapsible);
inline ThisBuilder& SetCollapsible(int32 first, int32 last,
@@ -280,6 +307,62 @@ private:
BSplitView* fView;
};

+template<typename ParentBuilder>
+class Cards : public Base<ParentBuilder> {
+public:
+ typedef Cards<ParentBuilder> ThisBuilder;
+ typedef Group<ThisBuilder> GroupBuilder;
+ typedef Grid<ThisBuilder> GridBuilder;
+ typedef Split<ThisBuilder> SplitBuilder;
+ typedef Cards<ThisBuilder> CardBuilder;
+
+public:
+ inline Cards();
+ inline Cards(BWindow* window);
+ inline Cards(BView* view);
+ inline Cards(BCardLayout*
layout);
+ inline Cards(BCardView* view);
+
+ inline BCardLayout* Layout() const;
+ inline BView* View() const;
+ inline ThisBuilder& GetLayout(BCardLayout** _layout);
+ inline ThisBuilder& GetView(BView** _view);
+
+ inline ThisBuilder& Add(BView* view);
+ inline ThisBuilder& Add(BLayoutItem* item);
+
+ inline GroupBuilder AddGroup(orientation orientation,
+ float
spacing = B_USE_DEFAULT_SPACING);
+ inline GroupBuilder AddGroup(BGroupView* groupView);
+ inline GroupBuilder AddGroup(BGroupLayout* groupLayout);
+
+ inline GridBuilder AddGrid(float horizontal
+
= B_USE_DEFAULT_SPACING,
+ float
vertical = B_USE_DEFAULT_SPACING);
+ inline GridBuilder AddGrid(BGridLayout*
gridLayout);
+ inline GridBuilder AddGrid(BGridView* gridView);
+
+ inline SplitBuilder AddSplit(orientation orientation,
+ float
spacing = B_USE_DEFAULT_SPACING);
+ inline SplitBuilder AddSplit(BSplitView* splitView);
+
+ inline CardBuilder AddCards();
+ inline CardBuilder AddCards(BCardLayout*
cardLayout);
+ inline CardBuilder AddCards(BCardView* cardView);
+
+ inline ThisBuilder& SetExplicitMinSize(BSize size);
+ inline ThisBuilder& SetExplicitMaxSize(BSize size);
+ inline ThisBuilder& SetExplicitPreferredSize(BSize size);
+ inline ThisBuilder& SetExplicitAlignment(BAlignment
alignment);
+
+ inline ThisBuilder& SetVisibleItem(int32 index);
+
+ inline operator BCardLayout*();
+
+private:
+ BCardLayout* fLayout;
+};
+

template<typename ParentBuilder>
class Menu : public Base<ParentBuilder> {
@@ -570,6 +653,39 @@ Group<ParentBuilder>::AddSplit(BSplitView* splitView,
float weight)


template<typename ParentBuilder>
+typename Group<ParentBuilder>::CardBuilder
+Group<ParentBuilder>::AddCards(float weight)
+{
+ CardBuilder builder;
+ builder.SetParent(this);
+ fLayout->AddView(builder.View(), weight);
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Group<ParentBuilder>::CardBuilder
+Group<ParentBuilder>::AddCards(BCardLayout* cardLayout, float weight)
+{
+ CardBuilder builder(cardLayout);
+ builder.SetParent(this);
+ fLayout->AddView(builder.View(), weight);
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Group<ParentBuilder>::CardBuilder
+Group<ParentBuilder>::AddCards(BCardView* cardView, float weight)
+{
+ CardBuilder builder(cardView);
+ builder.SetParent(this);
+ fLayout->AddView(builder.View(), weight);
+ return builder;
+}
+
+
+template<typename ParentBuilder>
typename Group<ParentBuilder>::ThisBuilder&
Group<ParentBuilder>::AddGlue(float weight)
{
@@ -885,6 +1001,42 @@ Grid<ParentBuilder>::AddSplit(BSplitView* splitView,
int32 column, int32 row,


template<typename ParentBuilder>
+typename Grid<ParentBuilder>::CardBuilder
+Grid<ParentBuilder>::AddCards(int32 column, int32 row, int32 columnCount,
+ int32 rowCount)
+{
+ CardBuilder builder;
+ builder.SetParent(this);
+ fLayout->AddView(builder.View(), column, row, columnCount, rowCount);
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Grid<ParentBuilder>::CardBuilder
+Grid<ParentBuilder>::AddCards(BCardLayout* cardLayout, int32 column, int32 row,
+ int32 columnCount, int32 rowCount)
+{
+ CardBuilder builder(cardLayout);
+ builder.SetParent(this);
+ fLayout->AddView(builder.View(), column, row, columnCount, rowCount);
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Grid<ParentBuilder>::CardBuilder
+Grid<ParentBuilder>::AddCards(BCardView* cardView, int32 column, int32 row,
+ int32 columnCount, int32 rowCount)
+{
+ CardBuilder builder(cardView);
+ builder.SetParent(this);
+ fLayout->AddView(builder.View(), column, row, columnCount, rowCount);
+ return builder;
+}
+
+
+template<typename ParentBuilder>
typename Grid<ParentBuilder>::ThisBuilder&
Grid<ParentBuilder>::AddGlue(int32 column, int32 row, int32 columnCount,
int32 rowCount)
@@ -1173,6 +1325,39 @@ Split<ParentBuilder>::AddSplit(orientation orientation,
float spacing,


template<typename ParentBuilder>
+typename Split<ParentBuilder>::CardBuilder
+Split<ParentBuilder>::AddCards(float weight)
+{
+ CardBuilder builder;
+ builder.SetParent(this);
+ fView->AddChild(builder.View(), weight);
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Split<ParentBuilder>::CardBuilder
+Split<ParentBuilder>::AddCards(BCardLayout* cardLayout, float weight)
+{
+ CardBuilder builder(cardLayout);
+ builder.SetParent(this);
+ fView->AddChild(builder.View(), weight);
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Split<ParentBuilder>::CardBuilder
+Split<ParentBuilder>::AddCards(BCardView* cardView, float weight)
+{
+ CardBuilder builder(cardView);
+ builder.SetParent(this);
+ fView->AddChild(builder.View(), weight);
+ return builder;
+}
+
+
+template<typename ParentBuilder>
typename Split<ParentBuilder>::ThisBuilder&
Split<ParentBuilder>::SetCollapsible(bool collapsible)
{
@@ -1234,6 +1419,278 @@ Split<ParentBuilder>::operator BSplitView*()
}


+// #pragma mark - Cards
+
+
+template<typename ParentBuilder>
+Cards<ParentBuilder>::Cards()
+ :
+ fLayout((new BCardView())->CardLayout())
+{
+}
+
+
+template<typename ParentBuilder>
+Cards<ParentBuilder>::Cards(BWindow* window)
+ :
+ fLayout(new BCardLayout())
+{
+ window->SetLayout(fLayout);
+
+ fLayout->Owner()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+}
+
+
+template<typename ParentBuilder>
+Cards<ParentBuilder>::Cards(BView* view)
+ :
+ fLayout(new BCardLayout())
+{
+ view->SetLayout(fLayout);
+ view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+}
+
+
+template<typename ParentBuilder>
+Cards<ParentBuilder>::Cards(BCardLayout* layout)
+ :
+ fLayout(layout)
+{
+}
+
+
+template<typename ParentBuilder>
+Cards<ParentBuilder>::Cards(BCardView* view)
+ :
+ fLayout(view->CardLayout())
+{
+}
+
+
+template<typename ParentBuilder>
+BCardLayout*
+Cards<ParentBuilder>::Layout() const
+{
+ return fLayout;
+}
+
+
+template<typename ParentBuilder>
+BView*
+Cards<ParentBuilder>::View() const
+{
+ return fLayout->Owner();
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::ThisBuilder&
+Cards<ParentBuilder>::GetLayout(BCardLayout** _layout)
+{
+ *_layout = fLayout;
+ return *this;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::ThisBuilder&
+Cards<ParentBuilder>::GetView(BView** _view)
+{
+ *_view = fLayout->Owner();
+ return *this;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::ThisBuilder&
+Cards<ParentBuilder>::Add(BView* view)
+{
+ fLayout->AddView(view);
+ return *this;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::ThisBuilder&
+Cards<ParentBuilder>::Add(BLayoutItem* item)
+{
+ fLayout->AddItem(item);
+ return *this;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::GroupBuilder
+Cards<ParentBuilder>::AddGroup(orientation orientation, float spacing)
+{
+ GroupBuilder builder(new BGroupLayout(orientation, spacing));
+ builder.SetParent(this);
+ fLayout->AddItem(builder.Layout());
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::GroupBuilder
+Cards<ParentBuilder>::AddGroup(BGroupView* groupView)
+{
+ GroupBuilder builder(groupView);
+ builder.SetParent(this);
+ fLayout->AddItem(builder.Layout());
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::GroupBuilder
+Cards<ParentBuilder>::AddGroup(BGroupLayout* groupLayout)
+{
+ GroupBuilder builder(groupLayout);
+ builder.SetParent(this);
+ fLayout->AddItem(builder.Layout());
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::GridBuilder
+Cards<ParentBuilder>::AddGrid(float horizontal, float vertical)
+{
+ GridBuilder builder(horizontal, vertical);
+ builder.SetParent(this);
+ fLayout->AddItem(builder.Layout());
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::GridBuilder
+Cards<ParentBuilder>::AddGrid(BGridLayout* gridLayout)
+{
+ GridBuilder builder(gridLayout);
+ builder.SetParent(this);
+ fLayout->AddItem(builder.Layout());
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::GridBuilder
+Cards<ParentBuilder>::AddGrid(BGridView* gridView)
+{
+ GridBuilder builder(gridView);
+ builder.SetParent(this);
+ fLayout->AddItem(builder.Layout());
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::SplitBuilder
+Cards<ParentBuilder>::AddSplit(orientation orientation, float spacing)
+{
+ SplitBuilder builder(orientation, spacing);
+ builder.SetParent(this);
+ fLayout->AddView(builder.View());
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::SplitBuilder
+Cards<ParentBuilder>::AddSplit(BSplitView* splitView)
+{
+ SplitBuilder builder(splitView);
+ builder.SetParent(this);
+ fLayout->AddView(builder.View());
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::CardBuilder
+Cards<ParentBuilder>::AddCards()
+{
+ CardBuilder builder;
+ builder.SetParent(this);
+ fLayout->AddView(builder.View());
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::CardBuilder
+Cards<ParentBuilder>::AddCards(BCardLayout* cardLayout)
+{
+ CardBuilder builder(cardLayout);
+ builder.SetParent(this);
+ fLayout->AddView(builder.View());
+ return builder;
+}
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::CardBuilder
+Cards<ParentBuilder>::AddCards(BCardView* cardView)
+{
+ CardBuilder builder(cardView);
+ builder.SetParent(this);
+ fLayout->AddView(builder.View());
+ return builder;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::ThisBuilder&
+Cards<ParentBuilder>::SetExplicitMinSize(BSize size)
+{
+ fLayout->SetExplicitMinSize(size);
+ return *this;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::ThisBuilder&
+Cards<ParentBuilder>::SetExplicitMaxSize(BSize size)
+{
+ fLayout->SetExplicitMaxSize(size);
+ return *this;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::ThisBuilder&
+Cards<ParentBuilder>::SetExplicitPreferredSize(BSize size)
+{
+ fLayout->SetExplicitPreferredSize(size);
+ return *this;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::ThisBuilder&
+Cards<ParentBuilder>::SetExplicitAlignment(BAlignment alignment)
+{
+ fLayout->SetExplicitAlignment(alignment);
+ return *this;
+}
+
+
+template<typename ParentBuilder>
+typename Cards<ParentBuilder>::ThisBuilder&
+Cards<ParentBuilder>::SetVisibleItem(int32 item)
+{
+ fLayout->SetVisibleItem(item);
+ return *this;
+}
+
+
+template<typename ParentBuilder>
+Cards<ParentBuilder>::operator BCardLayout*()
+{
+ return fLayout;
+}
+
+
// #pragma mark - Menu




Other related posts: