-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
-#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h>
using namespace Dali;
FixedRuler::FixedRuler(float spacing)
: mSpacing(spacing)
{
+ if(fabsf(mSpacing) <= Math::MACHINE_EPSILON_1)
+ {
+ DALI_LOG_ERROR( "Page spacing too small (%f).\n", double(spacing) );
+ mSpacing = spacing >= 0.0f ? Math::MACHINE_EPSILON_1 : -Math::MACHINE_EPSILON_1;
+ }
mType = Fixed;
}
volume = 0;
// spacing must be present.
- if(mEnabled && fabsf(mSpacing) > Math::MACHINE_EPSILON_1)
+ if( mEnabled )
{
unsigned int column = page;
unsigned int page = 0;
// spacing must be present.
- if(mEnabled && fabsf(mSpacing) > Math::MACHINE_EPSILON_1)
+ if( mEnabled )
{
- page = floor((position - mDomain.min) / mSpacing + 0.5f);
+ if( wrap )
+ {
+ position = WrapInDomain(position, mDomain.min, mDomain.max);
+ }
+ page = std::max(static_cast<double>(0.0f), floor((position - mDomain.min) / mSpacing + 0.5f));
if(wrap)
{
unsigned int pagesPerVolume = mDomain.GetSize() / mSpacing;
+ // Defensive check to avoid a divide by zero below when the ruler is in an invalid state (entire domain smaller than spacing between pages of it):
+ if(pagesPerVolume < 1u)
+ {
+ pagesPerVolume = 1u;
+ DALI_LOG_ERROR("Ruler domain(%f) is smaller than its spacing(%f).\n", mDomain.GetSize() * 1.0, mSpacing * 1.0 );
+ }
page %= pagesPerVolume;
}
}
unsigned int pagesPerVolume = 1;
// spacing must be present.
- if(mEnabled && fabsf(mSpacing) > Math::MACHINE_EPSILON_1)
+ if( mEnabled )
{
pagesPerVolume = mDomain.GetSize() / mSpacing;
}
// ScrollView
///////////////////////////////////////////////////////////////////////////////////////////////////
-const std::string ScrollView::SCROLL_PAGE_CURRENT( "scroll-page-current" );
-const std::string ScrollView::SCROLL_TIME_PROPERTY_NAME( "scroll-time" );
-const std::string ScrollView::SCROLL_POSITION_PROPERTY_NAME( "scroll-position" );
-const std::string ScrollView::SCROLL_PRE_POSITION_PROPERTY_NAME( "scroll-pre-position" );
-const std::string ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME( "scroll-overshoot-x" );
-const std::string ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME( "scroll-overshoot-y" );
-const std::string ScrollView::SCROLL_FINAL_PROPERTY_NAME( "scroll-final" );
-const std::string ScrollView::SCROLL_X_PROPERTY_NAME( "scroll-x" );
-const std::string ScrollView::SCROLL_Y_PROPERTY_NAME( "scroll-y" );
-const std::string ScrollView::SCROLL_SCALE_PROPERTY_NAME( "scroll-scale" );
-const std::string ScrollView::SCROLL_WRAP_PROPERTY_NAME( "scroll-wrap" );
-const std::string ScrollView::SCROLL_PANNING_PROPERTY_NAME( "scroll-panning" );
-const std::string ScrollView::SCROLL_SCROLLING_PROPERTY_NAME( "scroll-scrolling" );
-const std::string ScrollView::SCROLL_POSITION_DELTA_PROPERTY_NAME( "scroll-position-delta" );
-const std::string ScrollView::SCROLL_START_PAGE_POSITION_PROPERTY_NAME( "scroll-start-page-position" );
-
-const float ScrollView::DEFAULT_SLOW_SNAP_ANIMATION_DURATION(0.5f);
-const float ScrollView::DEFAULT_FAST_SNAP_ANIMATION_DURATION(0.25f);
-const float ScrollView::DEFAULT_SNAP_OVERSHOOT_DURATION(1.0f);
-const float ScrollView::DEFAULT_MAX_OVERSHOOT(100.0f); // 100 pixels
-
-const float ScrollView::DEFAULT_AXIS_AUTO_LOCK_GRADIENT(0.36f);
-const float ScrollView::DEFAULT_FRICTION_COEFFICIENT(1.0f);
-const float ScrollView::DEFAULT_FLICK_SPEED_COEFFICIENT(1.0f);
-const float ScrollView::DEFAULT_MAX_FLICK_SPEED(3.0f);
-
-const char* const ScrollView::SIGNAL_SNAP_STARTED = "snap-started";
-
ScrollView::ScrollView()
{
}
GetImpl(*this).SetRulerY(ruler);
}
-void ScrollView::SetRulerScaleX(RulerPtr ruler)
-{
- GetImpl(*this).SetRulerScaleX(ruler);
-}
-
-void ScrollView::SetRulerScaleY(RulerPtr ruler)
-{
- GetImpl(*this).SetRulerScaleY(ruler);
-}
-
void ScrollView::SetScrollSensitive(bool sensitive)
{
GetImpl(*this).SetScrollSensitive(sensitive);
GetImpl(*this).SetSnapOvershootDuration(duration);
}
-void ScrollView::SetTouchesRequiredForPanning(unsigned int minTouches, unsigned int maxTouches, bool endOutside)
-{
- GetImpl(*this).SetTouchesRequiredForPanning(minTouches, maxTouches, endOutside);
-}
-
void ScrollView::SetActorAutoSnap(bool enable)
{
GetImpl(*this).SetActorAutoSnap(enable);
GetImpl(*this).SetWrapMode(enable);
}
-int ScrollView::GetRefreshInterval() const
+int ScrollView::GetScrollUpdateDistance() const
{
- return GetImpl(*this).GetRefreshInterval();
+ return GetImpl(*this).GetScrollUpdateDistance();
}
-void ScrollView::SetRefreshInterval(int milliseconds)
+void ScrollView::SetScrollUpdateDistance(int distance)
{
- GetImpl(*this).SetRefreshInterval(milliseconds);
+ GetImpl(*this).SetScrollUpdateDistance(distance);
}
bool ScrollView::GetAxisAutoLock() const
GetImpl(*this).SetFlickSpeedCoefficient(speed);
}
+Vector2 ScrollView::GetMinimumDistanceForFlick() const
+{
+ return GetImpl(*this).GetMinimumDistanceForFlick();
+}
+
+void ScrollView::SetMinimumDistanceForFlick( const Vector2& distance )
+{
+ GetImpl(*this).SetMinimumDistanceForFlick(distance);
+}
+
+float ScrollView::GetMinimumSpeedForFlick() const
+{
+ return GetImpl(*this).GetMinimumSpeedForFlick();
+}
+
+void ScrollView::SetMinimumSpeedForFlick( float speed )
+{
+ GetImpl(*this).SetMinimumSpeedForFlick(speed);
+}
+
float ScrollView::GetMaxFlickSpeed() const
{
return GetImpl(*this).GetMaxFlickSpeed();
GetImpl(*this).SetMaxFlickSpeed(speed);
}
-Vector2 ScrollView::GetMouseWheelScrollDistanceStep() const
+Vector2 ScrollView::GetWheelScrollDistanceStep() const
{
- return GetImpl(*this).GetMouseWheelScrollDistanceStep();
+ return GetImpl(*this).GetWheelScrollDistanceStep();
}
-void ScrollView::SetMouseWheelScrollDistanceStep(Vector2 step)
+void ScrollView::SetWheelScrollDistanceStep(Vector2 step)
{
- GetImpl(*this).SetMouseWheelScrollDistanceStep(step);
+ GetImpl(*this).SetWheelScrollDistanceStep(step);
}
-Vector3 ScrollView::GetCurrentScrollPosition() const
+Vector2 ScrollView::GetCurrentScrollPosition() const
{
return GetImpl(*this).GetCurrentScrollPosition();
}
-Vector3 ScrollView::GetCurrentScrollScale() const
-{
- return GetImpl(*this).GetCurrentScrollScale();
-}
-
unsigned int ScrollView::GetCurrentPage() const
{
return GetImpl(*this).GetCurrentPage();
}
-void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, float rotation)
+void ScrollView::ScrollTo(const Vector2 &position)
{
- GetImpl(*this).TransformTo(position, scale, rotation);
+ GetImpl(*this).ScrollTo(position);
}
-void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, float rotation, float duration)
+void ScrollView::ScrollTo(const Vector2 &position, float duration)
{
- GetImpl(*this).TransformTo(position, scale, rotation, duration);
+ GetImpl(*this).ScrollTo(position, duration);
}
-void ScrollView::ScrollTo(const Vector3 &position)
+void ScrollView::ScrollTo(const Vector2 &position, float duration, AlphaFunction alpha)
{
- GetImpl(*this).ScrollTo(position);
+ GetImpl(*this).ScrollTo(position, duration, alpha);
}
-void ScrollView::ScrollTo(const Vector3 &position, float duration)
+void ScrollView::ScrollTo(const Vector2 &position, float duration,
+ DirectionBias horizontalBias, DirectionBias verticalBias)
{
- GetImpl(*this).ScrollTo(position, duration);
+ GetImpl(*this).ScrollTo(position, duration, horizontalBias, verticalBias);
}
-void ScrollView::ScrollTo(const Vector3 &position, float duration,
+void ScrollView::ScrollTo(const Vector2 &position, float duration, AlphaFunction alpha,
DirectionBias horizontalBias, DirectionBias verticalBias)
{
- GetImpl(*this).ScrollTo(position, duration, horizontalBias, verticalBias);
+ GetImpl(*this).ScrollTo(position, duration, alpha, horizontalBias, verticalBias);
}
void ScrollView::ScrollTo(unsigned int page)
return GetImpl(*this).ScrollToSnapPoint();
}
-void ScrollView::ScaleTo(const Vector3 &scale)
-{
- GetImpl(*this).ScaleTo(scale);
-}
-
-void ScrollView::ScaleTo(const Vector3 &scale, float duration)
-{
- GetImpl(*this).ScaleTo(scale, duration);
-}
-
void ScrollView::ApplyConstraintToChildren(Constraint constraint)
{
GetImpl(*this).ApplyConstraintToChildren(constraint);
GetImpl(*this).ApplyEffect(effect);
}
-ScrollViewEffect ScrollView::ApplyEffect(ScrollView::PageEffect effect)
-{
- return GetImpl(*this).ApplyEffect(effect);
-}
-
void ScrollView::RemoveEffect(ScrollViewEffect effect)
{
GetImpl(*this).RemoveEffect(effect);
GetImpl(*this).UnbindActor(child);
}
-ScrollView::SnapStartedSignalV2& ScrollView::SnapStartedSignal()
+ScrollView::SnapStartedSignalType& ScrollView::SnapStartedSignal()
{
return GetImpl(*this).SnapStartedSignal();
}