Updated demos to use DALi clang-format
[platform/core/uifw/dali-demo.git] / examples / frame-callback / frame-callback.h
1 #ifndef DEMO_FRAME_CALLBACK_H
2 #define DEMO_FRAME_CALLBACK_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
21 // EXTERNAL INCLUDES
22 #include <dali/devel-api/update/frame-callback-interface.h>
23 #include <dali/devel-api/update/update-proxy.h>
24 #include <dali/public-api/common/dali-vector.h>
25
26 /**
27  * @brief Implementation of the FrameCallbackInterface.
28  *
29  * When this is used, it will expand the size of the actors the closer they get to the horizontal edge
30  * and make the actor transparent the closer it gets to the middle.
31  */
32 class FrameCallback : public Dali::FrameCallbackInterface
33 {
34 public:
35   /**
36    * @brief Constructor.
37    */
38   FrameCallback();
39
40   /**
41    * @brief Sets the window width.
42    * @param[in]  windowWidth  The window width.
43    */
44   void SetWindowWidth(float windowWidth);
45
46   /**
47    * @brief The actor with the specified ID will be changed when Update() is called.
48    * @param[in]  id  Actor ID of actor which should be changed by the FrameCallback.
49    */
50   void AddId(uint32_t id);
51
52 private:
53   /**
54    * @brief Called when every frame is updated.
55    * @param[in]  updateProxy     Used to set the world-matrix and sizes.
56    * @param[in]  elapsedSeconds  Time elapsed time since the last frame (in seconds)
57    */
58   virtual void Update(Dali::UpdateProxy& updateProxy, float elapsedSeconds);
59
60 private:
61   Dali::Vector<uint32_t> mActorIdContainer; ///< Container of Actor IDs.
62   float                  windowHalfWidth;   ///< Half the width of the window. Center is 0,0 in the world matrix.
63
64   constexpr static float SIZE_MULTIPLIER = 2.0f; ///< Multiplier for the size to set as the actors hit the edge.
65 };
66
67 #endif // DEMO_FRAME_CALLBACK_H