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