2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/system/common/timer-impl.h>
22 // Ecore is littered with C style cast
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wold-style-cast"
25 #include <Win32WindowSystem.h>
39 void TimerSourceFunc (void *data)
41 Timer* timer = static_cast<Timer*>(data);
43 bool keepRunning = timer->Tick();
48 * Struct to hide away Ecore implementation details
52 Impl( unsigned int milliSec ) :
60 unsigned int mInterval;
63 TimerPtr Timer::New( unsigned int milliSec )
65 TimerPtr timer( new Timer( milliSec ) );
69 Timer::Timer( unsigned int milliSec )
70 : mImpl(new Impl(milliSec))
87 mImpl->mId = Win32WindowSystem::SetTimer( mImpl->mInterval, TimerSourceFunc, this );
95 Win32WindowSystem::KillTimer( mImpl->mId );
100 void Timer::SetInterval( unsigned int interval )
102 // stop existing timer
104 mImpl->mInterval = interval;
109 unsigned int Timer::GetInterval() const
111 return mImpl->mInterval;
116 // Guard against destruction during signal emission
117 Dali::Timer handle( this );
119 bool retVal( false );
121 // Override with new signal if used
122 if( !mTickSignal.Empty() )
124 retVal = mTickSignal.Emit();
126 // Timer stops if return value is false
133 retVal = true; // continue emission
136 else // no callbacks registered
138 // periodic timer is started but nobody listens, continue
145 Dali::Timer::TimerSignalType& Timer::TickSignal()
150 bool Timer::IsRunning() const
152 return 0 <= mImpl->mId;
155 } // namespace Adaptor
157 } // namespace Internal
161 #pragma GCC diagnostic pop