d4f49dbea258256eda287781a917bed6ba5fd2f1
[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   /**
37    * @brief Constructor.
38    */
39   FrameCallback();
40
41   /**
42    * @brief Sets the window width.
43    * @param[in]  windowWidth  The window width.
44    */
45   void SetWindowWidth( float windowWidth );
46
47   /**
48    * @brief The actor with the specified ID will be changed when Update() is called.
49    * @param[in]  id  Actor ID of actor which should be changed by the FrameCallback.
50    */
51   void AddId( uint32_t id );
52
53 private:
54
55   /**
56    * @brief Called when every frame is updated.
57    * @param[in]  updateProxy     Used to set the world-matrix and sizes.
58    * @param[in]  elapsedSeconds  Time elapsed time since the last frame (in seconds)
59    */
60   virtual void Update( Dali::UpdateProxy& updateProxy, float elapsedSeconds );
61
62 private:
63
64   Dali::Vector< uint32_t > mActorIdContainer; ///< Container of Actor IDs.
65   float windowHalfWidth; ///< Half the width of the window. Center is 0,0 in the world matrix.
66
67   constexpr static float SIZE_MULTIPLIER = 2.0f; ///< Multiplier for the size to set as the actors hit the edge.
68 };
69
70 #endif // DEMO_FRAME_CALLBACK_H