2 * Copyright (c) 2015 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-toolkit/internal/controls/scrollable/scroll-view/scroll-view-page-path-effect-impl.h>
22 #include <dali/public-api/object/property-array.h>
25 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
33 ScrollViewPagePathEffect::ScrollViewPagePathEffect(Path path, const Vector3& forward, Dali::Property::Index inputPropertyIndex, const Vector3& viewPageSize, unsigned int pageCount)
34 : mPageSize(viewPageSize),
35 mInputPropertyIndex(inputPropertyIndex),
38 //Create path constrainer
39 mPathConstrainer = Dali::PathConstrainer::New();
40 mPathConstrainer.SetProperty(PathConstrainer::Property::FORWARD, forward);
42 Dali::Property::Value pointsProperty = path.GetProperty(Path::Property::POINTS);
43 mPathConstrainer.SetProperty(PathConstrainer::Property::POINTS, pointsProperty);
45 pointsProperty = path.GetProperty(Path::Property::CONTROL_POINTS);
46 mPathConstrainer.SetProperty(PathConstrainer::Property::CONTROL_POINTS, pointsProperty);
48 //Create linear constrainer
49 pointsProperty = Property::Value(Property::ARRAY);
50 Property::Array* array = pointsProperty.GetArray();
54 array->PushBack(0.0f);
55 array->PushBack(1.0f);
56 array->PushBack(0.0f);
58 mLinearConstrainer = Dali::LinearConstrainer::New();
59 mLinearConstrainer.SetProperty(LinearConstrainer::Property::VALUE, pointsProperty);
62 ScrollViewPagePathEffect::~ScrollViewPagePathEffect()
66 void ScrollViewPagePathEffect::ApplyToPage(Actor page, unsigned int pageOrder)
68 float pageHalfSize = mPageSize.x * 0.5f;
69 Vector2 range = Vector2(pageHalfSize - (pageHalfSize * pageOrder), -pageHalfSize - (pageHalfSize * pageOrder));
70 Vector2 wrap = Vector2(range.x, -pageHalfSize * (mPageCount - 2) + range.y);
72 Toolkit::ScrollView scrollView = GetScrollView();
75 mPathConstrainer.Apply(Dali::Property(page, Dali::Actor::Property::POSITION),
76 Dali::Property(scrollView, mInputPropertyIndex),
81 mPathConstrainer.Apply(Dali::Property(page, Dali::Actor::Property::ORIENTATION),
82 Dali::Property(scrollView, mInputPropertyIndex),
87 mLinearConstrainer.Apply(Dali::Property(page, Dali::Actor::Property::COLOR_ALPHA),
88 Dali::Property(scrollView, mInputPropertyIndex),
93 void ScrollViewPagePathEffect::OnAttach(Toolkit::ScrollView& scrollView)
97 void ScrollViewPagePathEffect::OnDetach(Toolkit::ScrollView& scrollView)
101 } // namespace Internal
103 } // namespace Toolkit