Optimization to reduce Handle size by 50%
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / public-api / controls / tool-bar / tool-bar.h
1 #ifndef __DALI_TOOLKIT_TOOL_BAR_H__
2 #define __DALI_TOOLKIT_TOOL_BAR_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/dali.h>
26 #include <dali-toolkit/public-api/controls/alignment/alignment.h>
27
28 namespace Dali DALI_IMPORT_API
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Internal DALI_INTERNAL
35 {
36 // Forward declarations
37 class ToolBar;
38 }
39
40 /**
41  * Provides a tool bar where other controls (Dali::Actor) could be placed.
42  * controls could be added into three different groups: on the left, center or right.
43  * AddControl() and RemoveControl() methods should be used to add and remove controls. The use of Actor's Dali::Actor::Add() method
44  * is not forbidden, it adds controls on the left group with a size of 10% of the total tool bar size.
45  * Dali::Actor::Remove() method does nothing.
46  */
47 class ToolBar : public Control
48 {
49 public:
50   static const Toolkit::Alignment::Padding DEFAULT_PADDING; ///< Default padding space between controls. By default all values are set to 0.
51
52 public:
53   /**
54    * Create a ToolBar handle; this can be initialised with ToolBar::New()
55    * Calling member functions with an uninitialised handle is not allowed.
56    */
57   ToolBar();
58
59   /**
60    * Copy constructor. Creates another handle that points to the same real object
61    * @param handle to copy from
62    */
63   ToolBar( const ToolBar& handle );
64
65   /**
66    * Assignment operator. Changes this handle to point to another real object
67    */
68   ToolBar& operator=( const ToolBar& handle );
69
70   /**
71    * @brief Destructor
72    *
73    * This is non-virtual since derived Handle types must not contain data or virtual methods.
74    */
75   ~ToolBar();
76
77   /**
78    * Create an initialized ToolBar.
79    * @return A handle to a newly allocated Dali resource.
80    */
81   static ToolBar New();
82
83   /**
84    * Downcast an Object handle to ToolBar. If handle points to a ToolBar the
85    * downcast produces valid handle. If not the returned handle is left uninitialized.
86    * @param[in] handle Handle to an object
87    * @return handle to a ToolBar or an uninitialized handle
88    */
89   static ToolBar DownCast( BaseHandle handle );
90
91   /**
92    * Sets a background image.
93    * @param background Actor with the tool bar background.
94    */
95   void SetBackground( Actor background );
96
97   /**
98    * Adds an additional control to the tool bar.
99    * @pre The tool bar needs to be initialized.
100    * @pre The alignment needs to be horizontal.
101    * @param control An Actor with the additional control.
102    * @param relativeSize Control's size as a percentage of the tool bar width.
103    * @param alignment Where to insert controls. Possible values are Toolkit::Alignment::Left, Toolkit::Alignment::Center or Toolkit::Alignment::Right.
104    * @param padding Padding values used for the added control (left, right, top, bottom). By default, no padding is added.
105    */
106   void AddControl( Actor control, float relativeSize, Toolkit::Alignment::Type alignment, const Toolkit::Alignment::Padding& padding = DEFAULT_PADDING );
107
108   /**
109    * Removes a control from the tool bar.
110    * @pre control must have been added before to this tool bar.
111    * @param control The control to be removed.
112    */
113   void RemoveControl( Actor control );
114
115 public: // Not intended for application developers
116
117   /**
118    * Creates a handle using the Toolkit::Internal implementation.
119    * @param[in]  implementation  The Control implementation.
120    */
121   ToolBar( Internal::ToolBar& implementation );
122
123   /**
124    * Allows the creation of this Control from an Internal::CustomActor pointer.
125    * @param[in]  internal  A pointer to the internal CustomActor.
126    */
127   ToolBar( Dali::Internal::CustomActor* internal );
128 };
129
130 } // namespace Toolkit
131
132 } // namespace Dali
133
134 #endif // __DALI_TOOLKIT_TOOL_BAR_H__