26
|
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: Control Implementation with utilities for slider widget.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// Toolkit includes
|
|
19 |
#include <alf/alfenv.h>
|
|
20 |
#include <alf/alfroster.h>
|
|
21 |
#include <alf/alfdisplay.h>
|
|
22 |
|
|
23 |
// Widget model includes
|
|
24 |
#include <alf/alfwidgeteventhandler.h>
|
|
25 |
#include <alf/alfwidgetevents.h>
|
|
26 |
#include "alf/alfattribute.h"
|
|
27 |
#include <alf/alfutil.h>
|
|
28 |
#include "alf/alfmodeloperation.h"
|
|
29 |
#include <alf/alfcontrolgroup.h>
|
|
30 |
|
|
31 |
// libc includes
|
|
32 |
#include <libc/string.h>
|
|
33 |
#include <libc/stdlib.h>
|
|
34 |
#include <mul/mulevent.h>
|
|
35 |
|
|
36 |
//Widget includes
|
|
37 |
|
|
38 |
//Internal includes
|
|
39 |
#include "mulslidercontrol.h"
|
|
40 |
#include "mulsliderwidget.h"
|
|
41 |
#include "mulslidermodel.h"
|
|
42 |
#include "imulsliderbaseelementinternal.h"
|
|
43 |
|
|
44 |
//namespaces
|
|
45 |
using namespace osncore;
|
|
46 |
using namespace mulsliderwidget;
|
|
47 |
|
|
48 |
|
|
49 |
namespace Alf
|
|
50 |
{
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
// Constructor.
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
MulSliderControl::MulSliderControl(CAlfEnv& aEnv) :
|
|
56 |
CAlfWidgetControl(aEnv)
|
|
57 |
{
|
|
58 |
mLayoutHeight = -1; //this means that the first draw is yet to happen.
|
|
59 |
mLayoutWidth = -1; //this means that the first draw is yet to happen.
|
|
60 |
mDragTactileFeedbackStarted = false;
|
|
61 |
mEnableTactile = false; // Next statement will make it true
|
|
62 |
mTactilefdbInstance = NULL;
|
|
63 |
EnableTactileFeedback(true);
|
|
64 |
}
|
|
65 |
|
|
66 |
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
// Destructor.
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
MulSliderControl::~MulSliderControl()
|
|
72 |
{
|
|
73 |
|
|
74 |
}
|
|
75 |
|
|
76 |
|
|
77 |
// ---------------------------------------------------------------------------
|
|
78 |
// Notifies the owner that the layout of a visual has been recalculated.
|
|
79 |
// Called only when the EAlfVisualFlagLayoutUpdateNotification flag has
|
|
80 |
// been set for the visual.
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
void MulSliderControl::VisualLayoutUpdated(CAlfVisual& aVisual)
|
|
84 |
{
|
|
85 |
|
|
86 |
TPoint visualSize = aVisual.Size().IntValueNow();
|
|
87 |
|
|
88 |
if((mLayoutWidth == -1 && visualSize.iX) == 0 ||
|
|
89 |
(mLayoutHeight == -1 && visualSize.iY) == 0)
|
|
90 |
{
|
|
91 |
//return; /*No size assigned yet*/
|
|
92 |
}
|
|
93 |
else
|
|
94 |
{
|
|
95 |
//do nothing
|
|
96 |
}
|
|
97 |
|
|
98 |
if(mLayoutWidth == visualSize.iX &&
|
|
99 |
mLayoutHeight == visualSize.iY)
|
|
100 |
{
|
|
101 |
//return; /* No change in layout size */
|
|
102 |
}
|
|
103 |
else
|
|
104 |
{
|
|
105 |
//do nothing
|
|
106 |
}
|
|
107 |
|
|
108 |
mLayoutWidth = visualSize.iX;
|
|
109 |
mLayoutHeight = visualSize.iY;
|
|
110 |
IAlfElement* baseelement = findElement ("BaseElement");
|
|
111 |
IMulSliderBaseElementInternal* elementInternal =
|
|
112 |
static_cast<IMulSliderBaseElementInternal*> (
|
|
113 |
baseelement->makeInterface(IMulSliderBaseElementInternal::type()));
|
|
114 |
if(elementInternal)
|
|
115 |
{
|
|
116 |
elementInternal->baseLayoutSizeChanged();
|
|
117 |
}
|
|
118 |
else
|
|
119 |
{
|
|
120 |
//do nothing
|
|
121 |
}
|
|
122 |
}
|
|
123 |
|
|
124 |
|
|
125 |
// ---------------------------------------------------------------------------
|
|
126 |
// Returns top level layout.
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
CAlfLayout* MulSliderControl::ContainerLayout(
|
|
130 |
const CAlfControl* /*aConnected*/) const
|
|
131 |
{
|
|
132 |
if(VisualCount())
|
|
133 |
{
|
|
134 |
//Return the root layout of the control
|
|
135 |
return(static_cast<CAlfLayout*> (&Visual(0)));
|
|
136 |
}
|
|
137 |
else
|
|
138 |
{
|
|
139 |
return NULL;
|
|
140 |
}
|
|
141 |
}
|
|
142 |
|
|
143 |
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
// From base class CAlfWidgetControl
|
|
146 |
// Handle Alfred events.
|
|
147 |
// ---------------------------------------------------------------------------
|
|
148 |
//
|
|
149 |
AlfEventStatus MulSliderControl::handleEvent( const TAlfEvent& aEvent )
|
|
150 |
{
|
|
151 |
AlfEventStatus ret = EEventNotHandled;
|
|
152 |
IAlfElement *base = findElement("BaseElement");
|
|
153 |
if(base)
|
|
154 |
{
|
|
155 |
IAlfWidgetEventHandler* element =
|
|
156 |
static_cast<IAlfWidgetEventHandler*> (
|
|
157 |
base->makeInterface(IAlfWidgetEventHandler::type()));
|
|
158 |
|
|
159 |
if(aEvent.IsCustomEvent())
|
|
160 |
{
|
|
161 |
if(aEvent.CustomParameter() == EEventMissedPointerUp)
|
|
162 |
{
|
|
163 |
ret = element->offerEvent(*this,aEvent);
|
|
164 |
}
|
|
165 |
}
|
|
166 |
else if(aEvent.IsKeyEvent() ||
|
|
167 |
aEvent.IsPointerEvent())
|
|
168 |
{
|
|
169 |
// if the type of base element is slider , then
|
|
170 |
// convert the event to custom event
|
|
171 |
IMulSliderBaseElementInternal* elementInternal =
|
|
172 |
static_cast<IMulSliderBaseElementInternal*> (
|
|
173 |
base->makeInterface(IMulSliderBaseElementInternal::type()));
|
|
174 |
ret = element->offerEvent(*this , aEvent);
|
|
175 |
}
|
|
176 |
else
|
|
177 |
{
|
|
178 |
}
|
|
179 |
}
|
|
180 |
return ret;
|
|
181 |
}
|
|
182 |
|
|
183 |
|
|
184 |
// ---------------------------------------------------------------------------
|
|
185 |
// From base class CAlfWidgetControl.
|
|
186 |
// Notification that data is about to change in the data model.
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
void MulSliderControl::dataChanging(const AlfModelOperation& /*aOperation*/)
|
|
190 |
{}
|
|
191 |
|
|
192 |
|
|
193 |
// ---------------------------------------------------------------------------
|
|
194 |
// From class IAlfInterfaceBase.
|
|
195 |
// Getter for interfaces provided by the list widget.
|
|
196 |
// ---------------------------------------------------------------------------
|
|
197 |
//
|
|
198 |
IAlfInterfaceBase* MulSliderControl::makeInterface(const IfId& aType)
|
|
199 |
{
|
|
200 |
UString param(aType.mImplementationId);
|
|
201 |
|
|
202 |
return CAlfWidgetControl::makeInterface(aType);
|
|
203 |
}
|
|
204 |
|
|
205 |
// ---------------------------------------------------------------------------
|
|
206 |
//
|
|
207 |
// removeAndDestroyElement
|
|
208 |
//
|
|
209 |
// ---------------------------------------------------------------------------
|
|
210 |
//
|
|
211 |
void MulSliderControl::removeAndDestroyElement(const IAlfElement& /*aElement*/)
|
|
212 |
{
|
|
213 |
// reset the variables
|
|
214 |
mLayoutWidth = -1;
|
|
215 |
mLayoutHeight = -1;
|
|
216 |
|
|
217 |
CAlfWidgetControl::removeAndDestroyElement(*findElement("BaseElement"));
|
|
218 |
}
|
|
219 |
//----------------------------------------------------------------------
|
|
220 |
//
|
|
221 |
//enableTactileFeedback
|
|
222 |
//----------------------------------------------------------------------
|
|
223 |
void MulSliderControl::EnableTactileFeedback(bool aEnabled)
|
|
224 |
{
|
|
225 |
if (!mTactilefdbInstance)
|
|
226 |
{
|
|
227 |
mEnableTactile = aEnabled;
|
|
228 |
mTactilefdbInstance = MTouchFeedback::Instance();
|
|
229 |
}
|
|
230 |
}
|
|
231 |
//----------------------------------------------------------------------
|
|
232 |
//TactileEffectOnTouch
|
|
233 |
//
|
|
234 |
//----------------------------------------------------------------------
|
|
235 |
void MulSliderControl::TactileEffectOnTouchandHold()
|
|
236 |
{
|
|
237 |
if (mTactilefdbInstance)
|
|
238 |
{
|
|
239 |
mTactilefdbInstance->InstantFeedback(ETouchFeedbackSlider);
|
|
240 |
}
|
|
241 |
}
|
|
242 |
//----------------------------------------------------------------------
|
|
243 |
//TactileEffectOnDrag
|
|
244 |
//
|
|
245 |
//----------------------------------------------------------------------
|
|
246 |
void MulSliderControl::TactileEffectOnDrag(TAlfEvent& aEvent, int aIntensity)
|
|
247 |
{
|
|
248 |
if (mTactilefdbInstance)
|
|
249 |
{
|
|
250 |
CCoeControl* ccoecntrl = static_cast<CCoeControl*>(Display()->ObjectProvider());
|
|
251 |
TInt intensity = aIntensity;
|
|
252 |
TTimeIntervalMicroSeconds32 timespan = 400000;
|
|
253 |
mTactilefdbInstance->StartFeedback(ccoecntrl,ETouchDynamicSlider,&aEvent.PointerEvent(),intensity,timespan);
|
|
254 |
mDragTactileFeedbackStarted = true;
|
|
255 |
}
|
|
256 |
}
|
|
257 |
//-------------------------------------------------------------------------------
|
|
258 |
//
|
|
259 |
// TactileEffectOnRelease
|
|
260 |
//--------------------------------------------------------------------------------
|
|
261 |
//
|
|
262 |
void MulSliderControl::TactileEffectOnRelease()
|
|
263 |
{
|
|
264 |
if (mTactilefdbInstance)
|
|
265 |
{
|
|
266 |
if ( mDragTactileFeedbackStarted )
|
|
267 |
{
|
|
268 |
// Touch Release on Thumb after drag
|
|
269 |
CCoeControl* ccoecntrl = static_cast<CCoeControl*>(Display()->ObjectProvider());
|
|
270 |
mTactilefdbInstance->StopFeedback(ccoecntrl);
|
|
271 |
mDragTactileFeedbackStarted = false;
|
|
272 |
}
|
|
273 |
else
|
|
274 |
{
|
|
275 |
// Touch Release on thumb
|
|
276 |
mTactilefdbInstance->InstantFeedback(ETouchFeedbackSlider);
|
|
277 |
}
|
|
278 |
}
|
|
279 |
}
|
|
280 |
}//End of namespace Alf
|
|
281 |
//End of File
|
|
282 |
|