/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
#include <cstring> // for strcmp
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/common/stage.h>
-#include <dali/public-api/events/mouse-wheel-event.h>
+#include <dali/public-api/events/wheel-event.h>
#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/devel-api/object/type-registry-helper.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
const float FREE_FLICK_SPEED_THRESHOLD = 200.0f; ///< Free-Flick threshold in pixels/ms
const float AUTOLOCK_AXIS_MINIMUM_DISTANCE2 = 100.0f; ///< Auto-lock axis after minimum distance squared.
const float FLICK_ORTHO_ANGLE_RANGE = 75.0f; ///< degrees. (if >45, then supports diagonal flicking)
-const Vector2 DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION = Vector2(0.17f, 0.1f); ///< The step of horizontal scroll distance in the proportion of stage size for each mouse wheel event received.
+const Vector2 DEFAULT_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION = Vector2(0.17f, 0.1f); ///< The step of horizontal scroll distance in the proportion of stage size for each wheel event received.
const unsigned long MINIMUM_TIME_BETWEEN_DOWN_AND_UP_FOR_RESET( 150u );
const float TOUCH_DOWN_TIMER_INTERVAL = 100.0f;
const float DEFAULT_SCROLL_UPDATE_DISTANCE( 30.0f ); ///< Default distance to travel in pixels for scroll update signal
}
ScrollView::ScrollView()
-: ScrollBase( ControlBehaviour( REQUIRES_MOUSE_WHEEL_EVENTS ) ), // Enable size negotiation
+: ScrollBase( ControlBehaviour( REQUIRES_WHEEL_EVENTS ) ), // Enable size negotiation
mTouchDownTime(0u),
mGestureStackDepth(0),
mScrollStateFlags(0),
mFrictionCoefficient(DEFAULT_FRICTION_COEFFICIENT),
mFlickSpeedCoefficient(DEFAULT_FLICK_SPEED_COEFFICIENT),
mMaxFlickSpeed(DEFAULT_MAX_FLICK_SPEED),
- mMouseWheelScrollDistanceStep(Vector2::ZERO),
+ mWheelScrollDistanceStep(Vector2::ZERO),
mInAccessibilityPan(false),
mInitialized(false),
mScrolling(false),
// Internal Actor, used to hide actors from enumerations.
// Also actors added to Internal actor appear as overlays e.g. ScrollBar components.
mInternalActor = Actor::New();
- mInternalActor.SetDrawMode(DrawMode::OVERLAY);
self.Add(mInternalActor);
mInternalActor.SetParentOrigin(ParentOrigin::CENTER);
mScrollPostPosition = mScrollPrePosition = Vector2::ZERO;
- mMouseWheelScrollDistanceStep = Stage::GetCurrent().GetSize() * DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION;
+ mWheelScrollDistanceStep = Stage::GetCurrent().GetSize() * DEFAULT_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION;
mInitialized = true;
self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL, mCanScrollVertical);
self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_HORIZONTAL, mCanScrollHorizontal);
- Vector3 size = GetControlSize();
- UpdatePropertyDomain(size);
+ UpdatePropertyDomain();
SetInternalConstraints();
}
-void ScrollView::OnControlStageConnection()
+void ScrollView::OnStageConnection( int depth )
{
DALI_LOG_SCROLL_STATE("[0x%X]", this);
}
}
-void ScrollView::OnControlStageDisconnection()
+void ScrollView::OnStageDisconnection()
{
DALI_LOG_SCROLL_STATE("[0x%X]", this);
{
mRulerX = ruler;
- Vector3 size = GetControlSize();
- UpdatePropertyDomain(size);
+ UpdatePropertyDomain();
UpdateMainInternalConstraint();
}
{
mRulerY = ruler;
- Vector3 size = GetControlSize();
- UpdatePropertyDomain(size);
+ UpdatePropertyDomain();
UpdateMainInternalConstraint();
}
-void ScrollView::UpdatePropertyDomain(const Vector3& size)
+void ScrollView::UpdatePropertyDomain()
{
Actor self = Self();
+ Vector3 size = self.GetTargetSize();
Vector2 min = mMinScroll;
Vector2 max = mMaxScroll;
bool scrollPositionChanged = false;
mMaxFlickSpeed = speed;
}
-void ScrollView::SetMouseWheelScrollDistanceStep(Vector2 step)
+void ScrollView::SetWheelScrollDistanceStep(Vector2 step)
{
- mMouseWheelScrollDistanceStep = step;
+ mWheelScrollDistanceStep = step;
}
-Vector2 ScrollView::GetMouseWheelScrollDistanceStep() const
+Vector2 ScrollView::GetWheelScrollDistanceStep() const
{
- return mMouseWheelScrollDistanceStep;
+ return mWheelScrollDistanceStep;
}
unsigned int ScrollView::GetCurrentPage() const
return -GetPropertyPosition();
}
-void ScrollView::SetScrollPosition(const Vector2& position)
-{
- mScrollPrePosition = position;
-}
-
Vector2 ScrollView::GetDomainSize() const
{
Vector3 size = Self().GetCurrentSize();
void ScrollView::AddOverlay(Actor actor)
{
+ actor.SetDrawMode( DrawMode::OVERLAY_2D );
mInternalActor.Add( actor );
}
void ScrollView::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
{
// need to update domain properties for new size
- UpdatePropertyDomain(targetSize);
+ UpdatePropertyDomain();
}
-void ScrollView::OnControlSizeSet( const Vector3& size )
+void ScrollView::OnSizeSet( const Vector3& size )
{
// need to update domain properties for new size
if( mDefaultMaxOvershoot )
mMaxOvershoot = mUserMaxOvershoot;
}
}
- UpdatePropertyDomain(size);
+ UpdatePropertyDomain();
UpdateMainInternalConstraint();
if( IsOvershootEnabled() )
{
return true;
}
-bool ScrollView::OnMouseWheelEvent(const MouseWheelEvent& event)
+bool ScrollView::OnWheelEvent(const WheelEvent& event)
{
if(!mSensitive)
{
- // Ignore this mouse wheel event, if scrollview is insensitive.
+ // Ignore this wheel event, if scrollview is insensitive.
return false;
}
if(mRulerX->GetType() == Ruler::Free)
{
// Free panning mode
- targetScrollPosition.x += event.z * mMouseWheelScrollDistanceStep.x;
+ targetScrollPosition.x += event.z * mWheelScrollDistanceStep.x;
ClampPosition(targetScrollPosition);
ScrollTo(-targetScrollPosition);
}
if(mRulerY->GetType() == Ruler::Free)
{
// Free panning mode
- targetScrollPosition.y += event.z * mMouseWheelScrollDistanceStep.y;
+ targetScrollPosition.y += event.z * mWheelScrollDistanceStep.y;
ClampPosition(targetScrollPosition);
ScrollTo(-targetScrollPosition);
}
{
mScrollMainInternalPrePositionConstraint.Remove();
}
-
- if( mOvershootIndicator )
- {
- mOvershootIndicator->ClearOvershoot();
- }
}
else
{