Include required header files directly rather than through dali.h
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / internal / controls / tool-bar / tool-bar-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TOOL_BAR_H__
2 #define __DALI_TOOLKIT_INTERNAL_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 <dali/public-api/common/map-wrapper.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/controls/control-impl.h>
26 #include <dali-toolkit/public-api/controls/tool-bar/tool-bar.h>
27 #include <dali-toolkit/public-api/controls/table-view/table-view.h>
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 class ToolBar;
36
37 namespace Internal
38 {
39
40 /**
41  * ToolBar is a control to create a tool bar.
42  * @see Dali::Toolkit::ToolBar for more details.
43  */
44 class ToolBar : public Control
45 {
46 public:
47
48   /**
49    * Create an initialized ToolBar.
50    * @return A handle to a newly allocated Dali resource.
51    */
52   static Toolkit::ToolBar New();
53
54   /**
55    * @copydoc Dali::Toolkit::View::SetBackground()
56    */
57   void SetBackground( Actor background );
58
59   /**
60    * @copydoc Dali::Toolkit::View::AddControl()
61    */
62   void AddControl( Dali::Actor control, float relativeSize, Toolkit::Alignment::Type alignment, const Toolkit::Alignment::Padding& padding );
63
64   /**
65    * @copydoc Dali::Toolkit::View::RemoveControl()
66    */
67   void RemoveControl( Dali::Actor control );
68
69 private: // From Control
70
71   /**
72    * @copydoc Toolkit::Control::OnInitialize()
73    */
74   virtual void OnInitialize();
75
76   /**
77    * Adds a control using some default values (the control uses 10% of the tool bar space and is placed on the left group).
78    * @param child The control to be added.
79    *
80    * @see Control::OnControlChildAdd()
81    */
82   virtual void OnControlChildAdd(Actor& child);
83
84   /**
85    * Called when the tool-bar is relaid out.
86    * @param[in] size The size allocated.
87    * @param[in/out] container the container to put actors not handled.
88    */
89   virtual void OnRelaidOut( Vector2 size, ActorSizeContainer& container );
90
91 private:
92   /**
93    */
94   class Lock
95   {
96   public:
97     /**
98      * Constructor, sets the lock boolean
99      */
100     Lock( bool& lock )
101     : mLock( lock )
102     {
103       mLock = true;
104     }
105
106     /**
107      * Destructor, releases lock boolean
108      */
109     ~Lock()
110     {
111       mLock = false;
112     }
113   private:
114     bool& mLock;
115   };
116
117   /**
118    * Constructor.
119    * It initializes ToolBar members.
120    */
121   ToolBar();
122
123   /**
124    * A reference counted object may only be deleted by calling Unreference()
125    */
126   virtual ~ToolBar();
127
128 private:
129   Toolkit::TableView mLayout;                   ///< TableView used to place controls.
130   unsigned int       mLeftOffset;               ///< Offset index where the next control is going to be added in the left group.
131   unsigned int       mCenterBase;               ///< Base index where the first control of the center group is placed.
132   unsigned int       mCenterOffset;             ///< Offset index where the next control is going to be added in the center group.
133   unsigned int       mRightBase;                ///< Base index where the first control of the right group is placed.
134   unsigned int       mRightOffset;              ///< Offset index where the next control is going to be added in the right group.
135   float              mLeftRelativeSpace;        ///< Relative space between left and center groups of controls.
136   float              mRightRelativeSpace;       ///< Relative space between center and right groups of controls.
137   float              mAccumulatedRelativeSpace; ///< Stores the total percentage space used by controls.
138   bool               mInitializing;             ///< Allows the use of Actor's API to add controls.
139
140   std::map<Actor/*control*/,Toolkit::Alignment> mControls; ///< Stores a relationship between controls and their alignments used to place them inside the table view.
141 };
142
143 } // namespace Internal
144
145
146 // Helpers for public-api forwarding methods
147
148 inline Toolkit::Internal::ToolBar& GetImpl( Toolkit::ToolBar& toolBar )
149 {
150   DALI_ASSERT_ALWAYS( toolBar );
151
152   Dali::RefObject& handle = toolBar.GetImplementation();
153
154   return static_cast<Toolkit::Internal::ToolBar&>( handle );
155 }
156
157 inline const Toolkit::Internal::ToolBar& GetImpl( const Toolkit::ToolBar& toolBar )
158 {
159   DALI_ASSERT_ALWAYS( toolBar );
160
161   const Dali::RefObject& handle = toolBar.GetImplementation();
162
163   return static_cast<const Toolkit::Internal::ToolBar&>( handle );
164 }
165
166 } // namespace Toolkit
167
168 } // namespace Dali
169
170 #endif // __DALI_TOOLKIT_INTERNAL_TOOL_BAR_H__