[dali_1.3.7] Merge branch 'devel/master'
[platform/core/uifw/dali-demo.git] / examples / text-label / expanding-buttons-impl.h
1 #ifndef DALI_DEMO_INTERNAL_EXPANDING_BUTTONS_IMPL_H
2 #define DALI_DEMO_INTERNAL_EXPANDING_BUTTONS_IMPL_H
3
4 /*
5  * Copyright (c) 2018 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 #include "expanding-buttons.h"
21 #include <dali-toolkit/public-api/controls/control-impl.h>
22 #include <dali/public-api/object/weak-handle.h>
23
24 namespace Demo
25 {
26
27 namespace Internal // To use TypeRegistry, handle and body classes need the same name
28 {
29
30 class ExpandingButtons : public Dali::Toolkit::Internal::Control
31 {
32 public:
33
34   /**
35    * Instantiate a new ExpandingButtons object
36    */
37   static Demo::ExpandingButtons New();
38
39   /**
40    * Constructor
41    */
42   ExpandingButtons();
43
44   /**
45    * Destructor
46    */
47   ~ExpandingButtons();
48
49 public: // API
50
51   void RegisterButton( Dali::Toolkit::Control& control );
52
53   void Expand();
54
55   void Collapse();
56
57 public: // Signals
58
59   Demo::ExpandingButtons::ExpandingButtonsSignalType& CollapsingSignal();
60
61 private: // From Control
62
63   /**
64    * @copydoc Toolkit::Control::OnInitialize()
65    */
66   virtual void OnInitialize() override;
67
68   /**
69    * @copydoc Toolkit::Control::OnRelayout()
70    */
71   virtual void OnRelayout( const Dali::Vector2& targetSize, Dali::RelayoutContainer& container ) override;
72
73 private:
74
75   /**
76    * Callback when expand or collapse animation ends.
77    */
78   void OnExpandAnimationFinished( Dali::Animation& animation );
79
80   /**
81    * Called when the main button clicked.
82    */
83   bool OnExpandButtonClicked( Dali::Toolkit::Button button );
84
85
86 private:
87   //undefined
88   ExpandingButtons( const ExpandingButtons& );
89   ExpandingButtons& operator=( const ExpandingButtons& );
90
91 private:
92
93   std::vector< Dali::WeakHandle< Dali::Toolkit::Control> > mExpandingControls;
94
95   Dali::Animation mExpandCollapseAnimation;
96
97   bool mStyleButtonsHidden;
98
99   Dali::Size mButtonSize; // Size of the buttons, used in animation calculations.
100
101   Dali::Toolkit::PushButton mExpandButton; // Main button that is clicked to expand/collapse.
102
103   Demo::ExpandingButtons::ExpandingButtonsSignalType mCollapsedSignal;
104 };
105
106 } // Internal
107
108 inline Internal::ExpandingButtons& GetImpl( Demo::ExpandingButtons& handle )
109 {
110   DALI_ASSERT_ALWAYS( handle );
111   Dali::RefObject& object = handle.GetImplementation();
112   return static_cast<Internal::ExpandingButtons&>(object);
113 }
114
115 inline const Internal::ExpandingButtons& GetImpl( const Demo::ExpandingButtons& handle )
116 {
117   DALI_ASSERT_ALWAYS( handle );
118   const Dali::RefObject& object = handle.GetImplementation();
119   return static_cast<const Internal::ExpandingButtons&>(object);
120 }
121
122 } // Demo
123
124 #endif //  DALI_DEMO_INTERNAL_EXPANDING_BUTTONS_IMPL_H