/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// CLASS HEADER
#include <dali/internal/system/common/timer-impl.h>
-// Ecore is littered with C style cast
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wold-style-cast"
-
// INTERNAL INCLUDES
#include <dali/internal/window-system/windows/platform-implement-win.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
// LOCAL STUFF
namespace
{
-void TimerSourceFunc (void *data)
+bool TimerSourceFunc(void* data)
{
Timer* timer = static_cast<Timer*>(data);
-
- bool keepRunning = timer->Tick();
-}
+ return timer->Tick();
}
+} // namespace
/**
- * Struct to hide away Ecore implementation details
+ * Struct to hide away Windows implementation details
*/
struct Timer::Impl
{
- Impl( unsigned int milliSec ) :
- mId(-1),
+ Impl(unsigned int milliSec)
+ : mId(-1),
mInterval(milliSec)
{
}
- int mId;
+ intptr_t mId;
unsigned int mInterval;
};
-TimerPtr Timer::New( unsigned int milliSec )
+TimerPtr Timer::New(unsigned int milliSec)
{
- TimerPtr timer( new Timer( milliSec ) );
+ TimerPtr timer(new Timer(milliSec));
return timer;
}
-Timer::Timer( unsigned int milliSec )
+Timer::Timer(unsigned int milliSec)
: mImpl(new Impl(milliSec))
{
}
void Timer::Start()
{
- if( 0 > mImpl->mId )
+ if(0 > mImpl->mId)
{
- mImpl->mId = WindowsPlatformImplement::SetTimer( mImpl->mInterval, TimerSourceFunc, this );
+ mImpl->mId = WindowsPlatform::SetTimer(mImpl->mInterval, TimerSourceFunc, this);
}
}
void Timer::Stop()
{
- if( 0 <= mImpl->mId )
+ if(0 <= mImpl->mId)
{
- WindowsPlatformImplement::KillTimer( mImpl->mId );
+ WindowsPlatform::KillTimer(mImpl->mId);
mImpl->mId = -1;
}
}
-void Timer::SetInterval( unsigned int interval )
+void Timer::Pause()
+{
+}
+
+void Timer::Resume()
{
- // stop existing timer
- Stop();
- mImpl->mInterval = interval;
- // start new tick
- Start();
+}
+
+void Timer::SetInterval(unsigned int interval, bool restart)
+{
+ if(true == restart)
+ {
+ // stop existing timer
+ Stop();
+ mImpl->mInterval = interval;
+ // start new tick
+ Start();
+ }
+ else
+ {
+ mImpl->mInterval = interval;
+ }
}
unsigned int Timer::GetInterval() const
bool Timer::Tick()
{
// Guard against destruction during signal emission
- Dali::Timer handle( this );
+ Dali::Timer handle(this);
- bool retVal( false );
+ bool retVal(false);
// Override with new signal if used
- if( !mTickSignal.Empty() )
+ if(!mTickSignal.Empty())
{
retVal = mTickSignal.Emit();
// Timer stops if return value is false
- if (retVal == false)
+ if(retVal == false)
{
Stop();
}
else
{
- retVal = true; // continue emission
+ retVal = true; // continue emission
}
}
else // no callbacks registered
} // namespace Internal
} // namespace Dali
-
-#pragma GCC diagnostic pop