962ec271d1632008d225ad92b0f420d07f9302e8
[platform/core/uifw/dali-demo.git] / examples / color-transition / color-transition-controller.h
1 #ifndef DALI_DEMO_COLOR_TRANSITION_CONTROLLER_H
2 #define DALI_DEMO_COLOR_TRANSITION_CONTROLLER_H
3 /*
4  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19 #include "dali/public-api/adaptor-framework/window.h"
20 #include "dali/public-api/object/weak-handle.h"
21 #include "dali/public-api/actors/actor.h"
22 #include "dali/public-api/animation/animation.h"
23 #include "dali/public-api/rendering/texture.h"
24 #include "dali/public-api/render-tasks/render-task.h"
25 #include "dali/public-api/render-tasks/render-task-list.h"
26
27 class ColorTransitionController: public Dali::ConnectionTracker
28 {
29 public:
30   using OnFinished = void(*)(void*);
31
32   ColorTransitionController(Dali::WeakHandle<Dali::RenderTaskList> renderTasks, Dali::Actor content, Dali::RenderTaskList tasks, Dali::Vector3 initialColor);
33   ~ColorTransitionController();
34
35   Dali::Actor GetComposite();
36
37   void SetFlowMap(Dali::Texture flowMap);
38
39   void SetUvTransform(float initialRotation, float initialScale, float targetRotation, float targetScale);
40
41   void SetOnFinished(OnFinished onFinished, void* onFinishedData);
42
43   void RequestTransition(float duration, const Dali::Vector3& targetColor);
44
45 private:
46   void OnTransitionFinished(Dali::Animation& anim);
47
48   Dali::Actor mComposite;
49   Dali::Property::Index mPropFlow;
50   Dali::Property::Index mPropUvTransform;
51   Dali::Property::Index mPropRgb[2];
52
53   Dali::RenderTask mRtCompositor;
54
55   Dali::Animation mAnimation;
56
57   OnFinished mOnFinished = nullptr;
58   void* mOnFinishedData = nullptr;
59
60   Dali::WeakHandle<Dali::RenderTaskList> mWeakRenderTasks;
61 };
62
63 #endif //DALI_DEMO_COLOR_TRANSITION_CONTROLLER_H