Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / FUiTouchRotationGestureDetector.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file                FUiTouchRotationGestureDetector.cpp
19  * @brief               This is the implementation file for %TouchRotationGestureDetector class
20  * @version             2.0
21  *
22  * This file contains the implementation of %TouchRotationGestureDetector class.
23  *
24  */
25
26 #include <FUiITouchRotationGestureEventListener.h>
27 #include <FBaseSysLog.h>
28 #include "FUi_TouchRotationGestureDetectorImpl.h"
29
30 namespace Tizen { namespace Ui
31 {
32 TouchRotationGestureDetector::TouchRotationGestureDetector(void)
33 {
34 }
35
36 TouchRotationGestureDetector::~TouchRotationGestureDetector(void)
37 {
38 }
39
40 result
41 TouchRotationGestureDetector::Construct(void)
42 {
43         SysAssertf(__pTouchGestureDetectorImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
44
45         _TouchGestureDetectorImpl* pImpl =  _TouchRotationGestureDetectorImpl::CreateInstanceN(this);
46         result r = GetLastResult();
47         SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
48
49         __pTouchGestureDetectorImpl = pImpl;
50
51         return E_SUCCESS;
52 }
53
54 result
55 TouchRotationGestureDetector::AddRotationGestureEventListener(ITouchRotationGestureEventListener& listener)
56 {
57         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
58
59         result r = __pTouchGestureDetectorImpl->AddGestureEventListener(listener);
60         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
61
62         return E_SUCCESS;
63 }
64
65 result
66 TouchRotationGestureDetector::RemoveRotationGestureEventListener(ITouchRotationGestureEventListener& listener)
67 {
68         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
69
70         result r = __pTouchGestureDetectorImpl->RemoveGestureEventListener(listener);
71         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
72
73         return E_SUCCESS;
74 }
75
76 float
77 TouchRotationGestureDetector::GetAngle(void) const
78 {
79         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
80
81         const _TouchRotationGestureDetectorImpl* pRotationGestureDetectorImpl = _TouchRotationGestureDetectorImpl::GetInstance(*this);
82         SysAssertf(pRotationGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
83
84         return pRotationGestureDetectorImpl->GetAngle();
85 }
86
87 int
88 TouchRotationGestureDetector::GetDistance(void) const
89 {
90         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
91
92         const _TouchRotationGestureDetectorImpl* pRotationGestureDetectorImpl = _TouchRotationGestureDetectorImpl::GetInstance(*this);
93         SysAssertf(pRotationGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
94
95         return pRotationGestureDetectorImpl->GetDistance();
96 }
97
98 }} //Tizen::Ui