2 * Copyright (c) 2023 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/windows/timer-impl-win.h>
22 #include <dali/internal/window-system/windows/platform-implement-win.h>
33 bool TimerSourceFunc(void* data)
35 TimerWin* timer = static_cast<TimerWin*>(data);
41 * Struct to hide away Windows implementation details
45 Impl(uint32_t milliSec)
56 TimerWinPtr TimerWin::New(uint32_t milliSec)
58 TimerWinPtr timer(new TimerWin(milliSec));
62 TimerWin::TimerWin(uint32_t milliSec)
63 : mImpl(new Impl(milliSec))
76 void TimerWin::Start()
80 mImpl->mId = WindowsPlatform::SetTimer(mImpl->mInterval, TimerSourceFunc, this);
88 WindowsPlatform::KillTimer(mImpl->mId);
93 void TimerWin::Pause()
97 void TimerWin::Resume()
101 void TimerWin::SetInterval(uint32_t interval, bool restart)
105 // stop existing timer
107 mImpl->mInterval = interval;
113 mImpl->mInterval = interval;
117 uint32_t TimerWin::GetInterval() const
119 return mImpl->mInterval;
122 bool TimerWin::Tick()
124 // Guard against destruction during signal emission
125 Dali::Timer handle(this);
129 // Override with new signal if used
130 if(!mTickSignal.Empty())
132 retVal = mTickSignal.Emit();
134 // Timer stops if return value is false
141 retVal = true; // continue emission
144 else // no callbacks registered
146 // periodic timer is started but nobody listens, continue
153 bool TimerWin::IsRunning() const
155 return 0 <= mImpl->mId;
158 } // namespace Adaptor
160 } // namespace Internal