Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ColumnLayout.h
1 /*
2  * Copyright (C) 2014 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com>
17  */
18 
19 #ifndef UNITY_SCOPES_COLUMNLAYOUT_H
20 #define UNITY_SCOPES_COLUMNLAYOUT_H
21 
22 #include <unity/scopes/Variant.h>
23 #include <memory>
24 #include <list>
25 #include <vector>
26 #include <unity/util/DefinesPtrs.h>
27 
28 namespace unity
29 {
30 
31 namespace scopes
32 {
33 
34 namespace internal
35 {
36 class ColumnLayoutImpl;
37 }
38 
39 class ColumnLayout final
40 {
41 public:
43  UNITY_DEFINES_PTRS(ColumnLayout);
45 
51  explicit ColumnLayout(int num_of_columns);
52 
56  //{@
57  ColumnLayout(ColumnLayout const& other);
59  ColumnLayout& operator=(ColumnLayout const& other);
60  ColumnLayout& operator=(ColumnLayout&&);
62 
64  ~ColumnLayout();
66 
76  void add_column(std::vector<std::string> widget_ids);
77 
82  int size() const noexcept;
83 
88  int number_of_columns() const noexcept;
89 
96  std::vector<std::string> column(int index) const;
97 
99  VariantMap serialize() const;
101 
102 private:
103  ColumnLayout(internal::ColumnLayoutImpl *impl);
104  std::unique_ptr<internal::ColumnLayoutImpl> p;
105  friend class internal::ColumnLayoutImpl;
106 };
107 
112 typedef std::list<ColumnLayout> ColumnLayoutList;
113 
114 } // namespace scopes
115 
116 } // namespace unity
117 
118 #endif
std::list< ColumnLayout > ColumnLayoutList
List of column layouts (see unity::scopes::ColumnLayout)
Definition: ColumnLayout.h:112
std::vector< std::string > column(int index) const
Retrieve the list of widgets for given column.
Definition: ColumnLayout.cpp:114
int size() const noexcept
Get the current number of columns in this layout.
Definition: ColumnLayout.cpp:104
void add_column(std::vector< std::string > widget_ids)
Adds a new column and assigns widgets to it.
Definition: ColumnLayout.cpp:99
ColumnLayout(int num_of_columns)
Creates a layout definition that expects num_of_columns columns to be added with ColumnLayout::add_co...
Definition: ColumnLayout.cpp:61
int number_of_columns() const noexcept
Get the number of columns expected by this layout as specified in the constructor.
Definition: ColumnLayout.cpp:109
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:39
Defines a layout for preview widgets with given column setup.
Definition: ColumnLayout.h:39