License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-core.git] / dali / internal / event / events / hit-test-algorithm-impl.h
1 #ifndef __DALI_INTERNAL_HIT_TEST_ALGORITHM_H__
2 #define __DALI_INTERNAL_HIT_TEST_ALGORITHM_H__
3
4 /*
5  * Copyright (c) 2014 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 // INTERNAL INCLUDES
22 #include <dali/public-api/events/hit-test-algorithm.h>
23 #include <dali/public-api/render-tasks/render-task.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 /**
32  * This namespace is provided for application developers to do hit test for the actors.
33  */
34 namespace HitTestAlgorithm
35 {
36
37 struct Results
38 {
39   Dali::RenderTask renderTask;       ///< The render-task displaying the actor.
40   Dali::Actor      actor;            ///< The hit actor.
41   Vector2          actorCoordinates; ///< The actor coordinates.
42   Vector4          rayOrigin;        ///< The point of origin of the ray.
43   Vector4          rayDirection;     ///< The direction vector of the ray.
44 };
45
46 /**
47  * @copydoc Dali::HitTestAlgorithm::HitTest(Stage stage, const Vector2& screenCoordinates, Results& results, HitTestFunction func )
48  */
49 void HitTest( Stage& stage, const Vector2& screenCoordinates, Dali::HitTestAlgorithm::Results& results, Dali::HitTestAlgorithm::HitTestFunction func );
50
51 /**
52  * Given screen coordinates, this method returns the hit actor & the local coordinates relative to the actor etc.
53  * @param[in] stage The stage.
54  * @param[in] screenCoordinates The screen coordinates.
55  * @param[out] results The results of the hit-test.
56  *
57  * <h3>Hit Test Algorithm:</h3>
58  *
59  * - The system overlay RenderTaskList is hit-tested first.
60  * - If no hit then the regular RenderTaskList is used to hit test the on stage actors.
61  * - The bulk of the hit test algorithm is described in Dali::Actor.
62  * - In each RenderTask's its viewing parameters (the view and projection matrices, and the viewport)
63  *   are used to build a picking ray into the scene which is used for our ray tests when hit testing
64  *   an actor within each layer.
65  * - If an actor is deemed to be hittable, then a quicker ray sphere test on the actor is performed
66  *   first to determine if the ray is in the actor's proximity.
67  * - If this is also successful, then a more accurate ray test is performed to see if we have a hit.
68  *
69  * - NOTE: Currently, we prefer a child hit over a parent (regardless of the distance from the
70  *   camera) unless the parent is a RenderableActor but this is subject to change.
71  */
72 void HitTest( Stage& stage, const Vector2& screenCoordinates, Results& results );
73
74 /**
75  * Hit test specific to a given RenderTask
76  * @param[in] stage The stage.
77  * @param[in] renderTask The render task for hit test
78  * @param[in] screenCoordinates The screen coordinates.
79  * @param[out] results The results of the hit-test.
80  * @param[in] func The function to use in the hit-test algorithm.
81  */
82 void HitTest( Stage& stage, RenderTask& renderTask, const Vector2& screenCoordinates,
83               Dali::HitTestAlgorithm::Results& results, Dali::HitTestAlgorithm::HitTestFunction func );
84
85 } // namespace HitTestAlgorithm
86
87 } // namespace Internal
88
89 } // namespace Dali
90
91 #endif // __DALI_INTERNAL_HIT_TEST_ALGORITHM_H__