|
1 /* |
|
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: The pause handling control for the slideshow |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <alf/alfenv.h> |
|
22 #include <alf/alfdisplay.h> |
|
23 #include <alf/alfevent.h> |
|
24 |
|
25 #include <glxlog.h> |
|
26 #include <glxtracer.h> |
|
27 #include <glxpanic.h> |
|
28 #include "shwslideshowengine.h" |
|
29 #include "shwgesturecontrol.h" |
|
30 |
|
31 using namespace GestureHelper; |
|
32 |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // NewL. |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CShwGestureControl* CShwGestureControl::NewL( CAlfEnv& aEnv,CAlfDisplay& aDisplay) |
|
39 { |
|
40 TRACER("CShwGestureControl::NewL"); |
|
41 GLX_LOG_INFO( "CShwGestureControl::NewL" ); |
|
42 CShwGestureControl* self = new(ELeave)CShwGestureControl(); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL( aEnv,aDisplay); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // ConstructL. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 void CShwGestureControl::ConstructL( CAlfEnv& aEnv,CAlfDisplay& aDisplay) |
|
54 { |
|
55 TRACER("CShwGestureControl::ConstructL"); |
|
56 GLX_LOG_INFO( "CShwGestureControl::ConstructL" ); |
|
57 CAlfControl::ConstructL(aEnv); |
|
58 BindDisplay(aDisplay); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CShwGestureControl. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CShwGestureControl::CShwGestureControl( ) |
|
66 { |
|
67 TRACER("CShwGestureControl::CShwGestureControl"); |
|
68 //no implementation |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // ~CShwGestureControl. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CShwGestureControl::~CShwGestureControl() |
|
76 { |
|
77 TRACER("CShwGestureControl::~CShwGestureControl"); |
|
78 iObservers.ResetAndDestroy(); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // AddObserverL |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CShwGestureControl::AddObserverL(MShwGestureObserver* aObserver) |
|
86 { |
|
87 TRACER("CShwGestureControl::AddObserverL"); |
|
88 GLX_LOG_INFO("CShwGestureControl::AddObserverL"); |
|
89 __ASSERT_DEBUG( NULL != aObserver , Panic(EGlxPanicNullPointer)); |
|
90 |
|
91 // dont want to observe the same thing again and again. |
|
92 if (iObservers.Find(aObserver) == KErrNotFound) |
|
93 { |
|
94 iObservers.AppendL(aObserver); |
|
95 GLX_LOG_INFO1("CShwGestureControl::AddObserverL Observer Added " |
|
96 "observer count now [%d]", iObservers.Count()); |
|
97 } |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // RemoveObserver |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CShwGestureControl::RemoveObserver(MShwGestureObserver* aObserver) |
|
105 { |
|
106 TRACER("CShwGestureControl::RemoveObserver"); |
|
107 GLX_LOG_INFO("CShwGestureControl::RemoveObserver"); |
|
108 TInt observerPosition = iObservers.Find(aObserver); |
|
109 if (observerPosition != KErrNotFound) |
|
110 { |
|
111 iObservers.Remove(observerPosition); |
|
112 GLX_LOG_INFO1("CShwGestureControl::RemoveObserver One Observer removed " |
|
113 "observer count now [%d]", iObservers.Count()); |
|
114 } |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // HandleGestureL. |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CShwGestureControl::HandleGestureL( const GestureHelper::MGestureEvent& aEvent ) |
|
122 { |
|
123 TRACER("CShwGestureControl::HandleGestureL"); |
|
124 GLX_LOG_INFO1( "CShwGestureControl::HandleGestureL(%d)", aEvent.Code( MGestureEvent::EAxisBoth )); |
|
125 |
|
126 // No one is listening, Do not resolve the events for the listeners |
|
127 if (iObservers.Count() > 0) |
|
128 { |
|
129 MShwGestureObserver::TShwGestureEventType aType = MShwGestureObserver::ENoEvent; |
|
130 switch ( aEvent.Code( MGestureEvent::EAxisBoth ) ) |
|
131 { |
|
132 case EGestureSwipeLeft: |
|
133 { |
|
134 aType = MShwGestureObserver::ESwipeLeft ; |
|
135 break; |
|
136 } |
|
137 case EGestureSwipeRight: |
|
138 { |
|
139 aType = MShwGestureObserver::ESwipeRight; |
|
140 break; |
|
141 } |
|
142 case EGestureTap: |
|
143 { |
|
144 aType = MShwGestureObserver::ETapEvent; |
|
145 break; |
|
146 } |
|
147 default: |
|
148 { |
|
149 // we are interested in only |
|
150 // swipe left(EGestureSwipeLeft) |
|
151 // swipe right(EGestureSwipeRight) |
|
152 // and tap events |
|
153 // we wont be handling any other case yet. |
|
154 break; |
|
155 } |
|
156 } |
|
157 for (TInt index = 0 ; index < iObservers.Count() ; index ++) |
|
158 { |
|
159 if (MShwGestureObserver::ENoEvent != aType ) |
|
160 { |
|
161 iObservers[index]->HandleShwGestureEventL(aType); |
|
162 } |
|
163 } |
|
164 } |
|
165 } |
|
166 |
|
167 //end of file |
|
168 |