using namespace Tizen::Base;
using namespace Tizen::Ui::Animations;
using namespace Tizen::Graphics::_Text;
+using namespace Tizen::Base::Runtime;
namespace Tizen { namespace Ui { namespace Controls
{
: __pSlider(null)
, __pSliderModel(null)
, __pSliderOverlay(null)
+ , __pSlideTimer(null)
, __pResourceBgTopBitmap(null)
, __pResourceBgMiddleBitmap(null)
, __pResourceBgBottomBitmap(null)
, __handleX(0)
, __isSliderPressed(false)
, __isNeedToBeUpdated(true)
- , __isBubblingBlocked(false)
, __isResourceLoaded(false)
, __isCustomHandle(false)
, __isCustomPressedTextColor(false)
, __groupStyle(GROUP_STYLE_NONE)
, __fontSize(0.0f)
, __barOffset(0.0f)
+ , __isTimerRunning(false)
+ , __currentPosition(0.0f, 0.0f)
{
}
delete __pSliderOverlay;
__pSliderOverlay = null;
+ if (__pSlideTimer != null)
+ {
+ __pSlideTimer->Cancel();
+ delete __pSlideTimer;
+ __pSlideTimer = null;
+ }
+
delete __pResourceBgTopBitmap;
__pResourceBgTopBitmap = null;
}
int
-_SliderPresenter::CalculateSliderValue(int positionX, int offsetX)
+_SliderPresenter::CalculateSliderValue(float positionX, float offsetX)
{
int minValue = __pSliderModel->GetMinValue();
int maxValue = __pSliderModel->GetMaxValue();
return false;
}
- Point point = _CoordinateSystemUtils::ConvertToInteger(touchinfo.GetCurrentPosition());
+ if (__pSlideTimer == null)
+ {
+ __pSlideTimer = new (std::nothrow) Timer;
+ SysTryReturn(NID_UI_CTRL, __pSlideTimer != null, true, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ result r = __pSlideTimer->Construct(*this);
+ if (r != E_SUCCESS)
+ {
+ delete __pSlideTimer;
+ __pSlideTimer = null;
- __isBubblingBlocked = false;
+ return true;
+ }
+ }
- if (__pSlider->IsEnabled() == true && __handleRect.Contains(FloatPoint(point.x, point.y)) == true)
+ FloatPoint point = touchinfo.GetCurrentPosition();
+
+ if (__handleRect.Contains(point) == true)
{
+ __isSliderPressed = true;
+
int candidateValue = CalculateSliderValue(point.x, point.x - __handleRect.x);
__pSliderModel->SetValue(candidateValue);
__pSlider->SetAccessibilityElementValue();
- __isSliderPressed = true;
- __isBubblingBlocked = true;
-
if (__pSlider->GetStyle() & _SLIDER_STYLE_OVERLAY)
{
__pSliderOverlay->Open(false);
__pSlider->Invalidate();
}
- return __isBubblingBlocked;
+ return __isSliderPressed;
}
bool
return false;
}
- Point point = _CoordinateSystemUtils::ConvertToInteger(touchinfo.GetCurrentPosition());
- bool isBubblingBlocked = __isBubblingBlocked;
+ if (__pSlideTimer != null)
+ {
+ __isTimerRunning = false;
+ __pSlideTimer->Cancel();
+ }
+
+ FloatPoint point = touchinfo.GetCurrentPosition();
Canvas* pCanvas = __pSlider->GetCanvasN();
SysTryReturn(NID_UI_CTRL, pCanvas != null, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the canvas.");
- if (point.x >= (pCanvas->GetBounds().x + pCanvas->GetBounds().width))
+ if (point.x >= (pCanvas->GetBoundsF().x + pCanvas->GetBoundsF().width))
{
- point.x = pCanvas->GetBounds().x + pCanvas->GetBounds().width;
+ point.x = pCanvas->GetBoundsF().x + pCanvas->GetBoundsF().width;
}
if (__isSliderPressed == true)
pAdjustmentEvent->Fire(*pEventArg);
}
+ return true;
}
- return isBubblingBlocked;
+ return false;
}
bool
return false;
}
- Point point = _CoordinateSystemUtils::ConvertToInteger(touchinfo.GetCurrentPosition());
- bool isBubblingBlocked = __isBubblingBlocked;
+ if (__isSliderPressed == false)
+ {
+ return false;
+ }
+
+ FloatPoint point = touchinfo.GetCurrentPosition();
Canvas* pCanvas = __pSlider->GetCanvasN();
- SysTryReturn(NID_UI_CTRL, pCanvas != null, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the canvas.");
+ SysTryReturn(NID_UI_CTRL, pCanvas != null, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the canvas.");
- if (point.x >= (pCanvas->GetBounds().x + pCanvas->GetBounds().width))
+ if (point.x >= (pCanvas->GetBoundsF().x + pCanvas->GetBoundsF().width))
{
- point.x = pCanvas->GetBounds().x + pCanvas->GetBounds().width;
+ point.x = pCanvas->GetBoundsF().x + pCanvas->GetBoundsF().width;
}
+ __currentPosition.x = point.x;
+ __currentPosition.y = point.y;
- if (__isSliderPressed == false)
+ if ( __isTimerRunning == false )
{
- return false;
+ __isTimerRunning = true;
+ __pSlideTimer->Start(__timerValue);
}
- if (__pSlider->IsEnabled() == false)
- {
- __isSliderPressed = false;
- return false;
- }
+ return true;
+}
- float handleHalfWidth = __handleRect.width / 2.0f;
- int oldValue = __pSliderModel->GetValue();
- int candidateValue = CalculateSliderValue(point.x, handleHalfWidth);
+void
+_SliderPresenter::OnTimerExpired(Timer& timer)
+{
+ __isTimerRunning = false;
+
+ float handleHalfWidth = __handleRect.width / 2;
+ int candidateValue = CalculateSliderValue(__currentPosition.x, handleHalfWidth);
__pSliderModel->SetValue(candidateValue);
__pSlider->SetAccessibilityElementValue();
__pSlider->Draw();
__pSlider->Show();
- if (oldValue != candidateValue)
+ // Slider Event Fire
+ _SliderEvent* pSliderEvent = dynamic_cast <_SliderEvent*>(__pSlider->GetSliderEvent());
+ if (pSliderEvent != null)
{
- // Slider Event Fire
- _SliderEvent* pSliderEvent = dynamic_cast <_SliderEvent*>(__pSlider->GetSliderEvent());
- if (pSliderEvent != null)
- {
- Tizen::Base::Runtime::IEventArg* pEventArg = _SliderEvent::CreateSliderEventArgN(candidateValue);
- result r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, pEventArg != null, true, r, "[%s] Propagating.", GetErrorMessage(r));
+ Tizen::Base::Runtime::IEventArg* pEventArg = _SliderEvent::CreateSliderEventArgN(candidateValue);
- pSliderEvent->Fire(*pEventArg);
+ if( pEventArg == null)
+ {
+ return;
}
+
+ pSliderEvent->Fire(*pEventArg);
}
- return isBubblingBlocked;
+ return;
}
bool