utc-Dali-JsonParser.cpp
utc-Dali-KeyInputFocusManager.cpp
utc-Dali-NavigationControl.cpp
- utc-Dali-NavigationLayout.cpp
utc-Dali-OverlayEffect.cpp
utc-Dali-Page.cpp
utc-Dali-PageTurnEffect.cpp
utc-Dali-PageTurnView.cpp
- utc-Dali-RollLayout.cpp
utc-Dali-ScrollView.cpp
utc-Dali-ShadowView.cpp
utc-Dali-ShearEffect.cpp
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <float.h> // for FLT_MAX
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-using namespace Toolkit;
-
-namespace
-{
-const unsigned int TOTAL_ITEM_NUMBER = 200;
-
-
-// Implementation of ItemFactory for providing actors to ItemView
-class TestItemFactory : public ItemFactory
-{
-public:
-
- /**
- * Constructor
- * @param application class, stored as reference
- */
- TestItemFactory()
- {
- }
-
-public: // From ItemFactory
-
- /**
- * Query the number of items available from the factory.
- * The maximum available item has an ID of GetNumberOfItems() - 1.
- */
- virtual unsigned int GetNumberOfItems()
- {
- return TOTAL_ITEM_NUMBER;
- }
-
- /**
- * Create an Actor to represent a visible item.
- * @param itemId
- * @return the created actor.
- */
- virtual Actor NewItem(unsigned int itemId)
- {
- // Create an test actor for this item
- ImageActor actor = CreateSolidColorActor(Color::RED);
- actor.SetSize(64.0f, 64.0f);
-
- return actor;
- }
-};
-} // namespace
-
-
-// Positive test case for a method
-int UtcDaliNavigationLayoutNew(void)
-{
- ToolkitTestApplication application;
-
- // Create a navigation layout
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
- navigationLayout->SetNumberOfColumns(6);
- DALI_TEST_CHECK(navigationLayout);
- END_TEST;
-}
-
-int UtcDaliNavigationLayoutColumns(void)
-{
- ToolkitTestApplication application;
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
-
- navigationLayout->SetNumberOfColumns(6);
- // Check whether we get the correct number of columns
- DALI_TEST_CHECK(navigationLayout->GetNumberOfColumns() == 6);
- END_TEST;
-}
-
-int UtcDaliNavigationLayoutSetGetOrientation(void)
-{
- ToolkitTestApplication application;
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
-
- navigationLayout->SetNumberOfColumns(6);
- navigationLayout->SetOrientation(ControlOrientation::Right);
- DALI_TEST_CHECK(navigationLayout->GetOrientation() == ControlOrientation::Right);
- END_TEST;
-}
-
-int UtcDaliNavigationLayoutTestConstraintLeft(void)
-{
- ToolkitTestApplication application;
-
- // Create the ItemView actor
- TestItemFactory factory;
- ItemView view = ItemView::New(factory);
- Vector3 vec(480.0f, 800.0f, 0.0f);
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
- navigationLayout->SetNumberOfColumns(6);
-
- view.SetName("view actor");
- view.AddLayout(*navigationLayout);
- view.SetSize(vec);
-
- Stage::GetCurrent().Add(view);
- navigationLayout->SetOrientation(ControlOrientation::Left);
- view.ActivateLayout(0, vec, 0.0f);
-
- application.SendNotification();
- application.Render(0);
-
- // render 10 frames
- for(int i = 0; i < 10; ++i)
- {
- application.Render(16); // 60hz frames
- }
-
- // Confirm: we have actors in the view and all of them is positioned at X = 0
- // and the series is monotonely decreasing.
- int nonZeroXCount = 0;
- int elementsFound = 0;
- int wrongDirectionCount = 0;
- float prevY = FLT_MAX;
- for(unsigned int i = 0; i < 10; i++)
- {
- Actor testActor = view.GetItem(i);
- if (testActor)
- {
- elementsFound++;
- Vector3 pos = testActor.GetCurrentPosition();
-
- if (pos.x != 0.0f)
- {
- nonZeroXCount++;
- }
-
- if (pos.y >= prevY)
- {
- wrongDirectionCount++;
- }
-
- prevY = pos.y;
- }
- }
-
- DALI_TEST_CHECK((elementsFound > 0) && (nonZeroXCount == 0) && (wrongDirectionCount == 0));
- Stage::GetCurrent().Remove(view);
- END_TEST;
-}
-
-int UtcDaliNavigationLayoutTestConstraintRight(void)
-{
- ToolkitTestApplication application;
-
- // Create the ItemView actor
- TestItemFactory factory;
- ItemView view = ItemView::New(factory);
- Vector3 vec(480.0f, 800.0f, 0.0f);
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
- navigationLayout->SetNumberOfColumns(6);
-
- view.SetName("view actor");
- view.AddLayout(*navigationLayout);
- view.SetSize(vec);
-
- Stage::GetCurrent().Add(view);
- navigationLayout->SetOrientation(ControlOrientation::Right);
- view.ActivateLayout(0, vec, 0.0f);
-
- application.SendNotification();
- application.Render(0);
-
- // render 10 frames
- for(int i = 0; i < 10; ++i)
- {
- application.Render(16); // 60hz frames
- }
-
- // Confirm: we have actors in the view and all of them is positioned at X = 0
- // and the series is monotonely increasing.
- int nonZeroXCount = 0;
- int elementsFound = 0;
- int wrongDirectionCount = 0;
- float prevY = -FLT_MAX;
- for(unsigned int i = 0; i < 10; i++)
- {
- Actor testActor = view.GetItem(i);
- if (testActor)
- {
- elementsFound++;
- Vector3 pos = testActor.GetCurrentPosition();
-
- if (pos.x != 0.0f)
- {
- nonZeroXCount++;
- }
-
- if (pos.y <= prevY)
- {
- wrongDirectionCount++;
- }
-
- prevY = pos.y;
- }
- }
-
- DALI_TEST_CHECK((elementsFound > 0) && (nonZeroXCount == 0) && (wrongDirectionCount == 0));
- Stage::GetCurrent().Remove(view);
- END_TEST;
-}
-
-int UtcDaliNavigationLayoutTestConstraintUp(void)
-{
- ToolkitTestApplication application;
-
- // Create the ItemView actor
- TestItemFactory factory;
- ItemView view = ItemView::New(factory);
- Vector3 vec(480.0f, 800.0f, 0.0f);
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
- navigationLayout->SetNumberOfColumns(6);
-
- view.SetName("view actor");
- view.AddLayout(*navigationLayout);
- view.SetSize(vec);
-
- Stage::GetCurrent().Add(view);
- navigationLayout->SetOrientation(ControlOrientation::Up);
- view.ActivateLayout(0, vec, 0.0f);
-
- application.SendNotification();
- application.Render(0);
-
- // render 10 frames
- for(int i = 0; i < 10; ++i)
- {
- application.Render(16); // 60hz frames
- }
-
- // Confirm: we have actors in the view and all of them is positioned at X = 0
- // and the series is monotonely decreasing.
- int nonZeroYCount = 0;
- int elementsFound = 0;
- int wrongDirectionCount = 0;
- float prevX = -FLT_MAX;
- for(unsigned int i = 0; i < 10; i++)
- {
- Actor testActor = view.GetItem(i);
- if (testActor)
- {
- elementsFound++;
- Vector3 pos = testActor.GetCurrentPosition();
-
- if (pos.y != 0.0f)
- {
- nonZeroYCount++;
- }
-
- if (pos.x <= prevX)
- {
- wrongDirectionCount++;
- }
-
- prevX = pos.x;
- }
- }
-
- DALI_TEST_CHECK((elementsFound > 0) && (nonZeroYCount == 0) && (wrongDirectionCount == 0));
- Stage::GetCurrent().Remove(view);
- END_TEST;
-}
-
-int UtcDaliNavigationLayoutTestConstraintDown(void)
-{
- ToolkitTestApplication application;
-
- // Create the ItemView actor
- TestItemFactory factory;
- ItemView view = ItemView::New(factory);
- Vector3 vec(480.0f, 800.0f, 0.0f);
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
- navigationLayout->SetNumberOfColumns(6);
-
- view.SetName("view actor");
- view.AddLayout(*navigationLayout);
- view.SetSize(vec);
-
- Stage::GetCurrent().Add(view);
- navigationLayout->SetOrientation(ControlOrientation::Down);
- view.ActivateLayout(0, vec, 0.0f);
-
- application.SendNotification();
- application.Render(0);
-
- // render 10 frames
- for(int i = 0; i < 10; ++i)
- {
- application.Render(16); // 60hz frames
- }
-
- // Confirm: we have actors in the view and all of them is positioned at X = 0
- // and the series is monotonely decreasing.
- int nonZeroYCount = 0;
- int elementsFound = 0;
- int wrongDirectionCount = 0;
- float prevX = FLT_MAX;
- for(unsigned int i = 0; i < 10; i++)
- {
- Actor testActor = view.GetItem(i);
- if (testActor)
- {
- elementsFound++;
- Vector3 pos = testActor.GetCurrentPosition();
-
- if (pos.y != 0.0f)
- {
- nonZeroYCount++;
- }
-
- if (pos.x > prevX)
- {
- wrongDirectionCount++;
- }
-
- prevX = pos.x;
- }
- }
-
- DALI_TEST_CHECK((elementsFound > 0) && (nonZeroYCount == 0) && (wrongDirectionCount == 0));
- Stage::GetCurrent().Remove(view);
- END_TEST;
-}
-
-
-int UtcDaliNavigationLayoutScrollDirection(void)
-{
- ToolkitTestApplication application;
-
- // Create the ItemView actor
- TestItemFactory factory;
- ItemView view = ItemView::New(factory);
- Vector3 vec(480.0f, 800.0f, 0.0f);
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
- navigationLayout->SetNumberOfColumns(6);
-
- view.SetName("view actor");
- view.AddLayout(*navigationLayout);
- view.SetSize(vec);
-
- Stage::GetCurrent().Add(view);
- navigationLayout->SetOrientation(ControlOrientation::Left);
- view.ActivateLayout(0, vec, 0.0f);
-
- application.SendNotification();
- application.Render(0);
-
- ItemLayoutPtr layout = navigationLayout;
-
- // render 10 frames
- for(int i = 0; i < 10; ++i)
- {
- application.Render(16); // 60hz frames
- }
-
- navigationLayout->SetOrientation(ControlOrientation::Up);
- view.ActivateLayout(0, vec, 0.0f);
- application.SendNotification();
- application.Render();
-
- Degree deg = layout->GetScrollDirection();
- DALI_TEST_CHECK(deg == (180.0f - 45.0f));
-
- navigationLayout->SetOrientation(ControlOrientation::Down);
- view.ActivateLayout(0, vec, 0.0f);
- application.SendNotification();
- application.Render();
-
- deg = layout->GetScrollDirection();
- DALI_TEST_CHECK((deg == -45.0f));
-
- layout->SetOrientation(ControlOrientation::Left);
- view.ActivateLayout(0, vec, 0.0f);
- application.SendNotification();
- application.Render();
-
- deg = layout->GetScrollDirection();
- DALI_TEST_CHECK(deg == (270.0f - 45.0f));
-
- navigationLayout->SetOrientation(ControlOrientation::Right);
- view.ActivateLayout(0, vec, 0.0f);
- application.SendNotification();
- application.Render();
-
- deg = layout->GetScrollDirection();
- DALI_TEST_CHECK(deg == (90.0f - 45.0f));
-
- Stage::GetCurrent().Remove(view);
- END_TEST;
-}
-
-int UtcDaliNavigationLayoutSetGetColumnSpacing(void)
-{
- ToolkitTestApplication application;
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
- const float testValue = 11.0f;
-
- navigationLayout->SetNumberOfColumns(6);
- navigationLayout->SetColumnSpacing(testValue);
- DALI_TEST_CHECK(navigationLayout->GetColumnSpacing() == testValue);
- END_TEST;
-}
-
-int UtcDaliNavigationLayoutSetGetTopMargin(void)
-{
- ToolkitTestApplication application;
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
- const float testValue = 11.0f;
-
- navigationLayout->SetNumberOfColumns(6);
- navigationLayout->SetTopMargin(testValue);
- DALI_TEST_CHECK(navigationLayout->GetTopMargin() == testValue);
- END_TEST;
-}
-
-int UtcDaliNavigationLayoutSetGetBottomMargin(void)
-{
- ToolkitTestApplication application;
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
- const float testValue = 12.0f;
-
- navigationLayout->SetNumberOfColumns(6);
- navigationLayout->SetBottomMargin(testValue);
- DALI_TEST_CHECK(navigationLayout->GetBottomMargin() == testValue);
- END_TEST;
-}
-
-int UtcDaliNavigationLayoutSetGetScrollSpeedFactor(void)
-{
- ToolkitTestApplication application;
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
- const float testValue = 15.0f;
-
- navigationLayout->SetNumberOfColumns(6);
- navigationLayout->SetScrollSpeedFactor(testValue);
- DALI_TEST_CHECK(navigationLayout->GetScrollSpeedFactor() == testValue);
- END_TEST;
-}
-
-int UtcDaliNavigationLayoutSetGetMaximumSwipeSpeed(void)
-{
- ToolkitTestApplication application;
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
- const float testValue = 10.0f;
-
- navigationLayout->SetNumberOfColumns(6);
- navigationLayout->SetMaximumSwipeSpeed(testValue);
- DALI_TEST_CHECK(navigationLayout->GetMaximumSwipeSpeed() == testValue);
- END_TEST;
-}
-
-int UtcDaliNavigationLayoutSetAndGetItemFlickAnimationDuration(void)
-{
- ToolkitTestApplication application;
-
- // Create a navigation layout
- NavigationLayoutPtr navigationLayout = NavigationLayout::New();
-
- // Set the flick animaiton duration
- navigationLayout->SetItemFlickAnimationDuration(0.35f);
-
- // Check whether we get the correct flick animaiton duration
- DALI_TEST_EQUALS( navigationLayout->GetItemFlickAnimationDuration(), 0.35f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliNavigationLayoutGetScrollToPosition(void)
-{
- ToolkitTestApplication application;
-
- // Create the ItemView actor
- TestItemFactory factory;
- ItemView view = ItemView::New(factory);
- Vector3 vec(480.0f, 800.0f, 0.0f);
- NavigationLayoutPtr layout = NavigationLayout::New();
-
- view.SetName("view actor");
- view.AddLayout(*layout);
- view.SetSize(vec);
-
- Stage::GetCurrent().Add(view);
- layout->SetOrientation(ControlOrientation::Up);
- view.ActivateLayout(0, vec, 0.0f);
-
- application.SendNotification();
- application.Render(0);
-
- // render 10 frames
- for(int i = 0; i < 10; ++i)
- {
- application.Render(16); // 60hz frames
- }
-
- // Confirm: we have actors in the view.
- std::vector<unsigned int> indices;
- for(unsigned int i = 0; i < 10; i++)
- {
- Actor testActor = view.GetItem(i);
- if (testActor)
- {
- indices.push_back(i);
- }
- }
-
- try
- {
- if (!indices.empty())
- {
- const unsigned int firstTargetIndex = indices[indices.size()-1];
- // scroll to last item
- view.ScrollToItem(firstTargetIndex, 0.00f);
- application.Render(16); // 60hz frames
-
- std::size_t moveCount = 0;
- for(std::size_t i = 0; i < indices.size(); i++)
- {
- float layoutPosBefore = view.GetCurrentLayoutPosition(i);
- view.ScrollToItem(indices[i], 0.0f);
-
- application.Render(16); // 60hz frame
-
- float layoutPosAfter = view.GetCurrentLayoutPosition(i);
-
- if (fabs(layoutPosBefore-layoutPosAfter) <= FLT_EPSILON)
- {
- ++moveCount;
- }
- }
-
- DALI_TEST_CHECK((moveCount == indices.size()));
- }
- }
- catch(...)
- {
- tet_result(TET_FAIL);
- }
-
- Stage::GetCurrent().Remove(view);
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-namespace
-{
-const unsigned int TOTAL_ITEM_NUMBER = 200;
-
-Vector3 RollLayoutItemSizeFunction(float layoutWidth, float layoutHeight, float rowSpacing)
-{
- float height = (layoutHeight - rowSpacing) * 0.5f;
- return Vector3(layoutWidth, height, height);
-}
-
-} // namespace
-
-
-// Implementation of ItemFactory for providing actors to ItemView
-class TestItemFactory : public ItemFactory
-{
-public:
-
- /**
- * Constructor
- */
- TestItemFactory()
- {
- }
-
-public: // From ItemFactory
-
- /**
- * Query the number of items available from the factory.
- * The maximum available item has an ID of GetNumberOfItems() - 1.
- */
- virtual unsigned int GetNumberOfItems()
- {
- return TOTAL_ITEM_NUMBER;
- }
-
- /**
- * Create an Actor to represent a visible item.
- * @param itemId
- * @return the created actor.
- */
- virtual Actor NewItem(unsigned int itemId)
- {
- // Create an test actor for this item
- ImageActor actor = CreateSolidColorActor(Color::RED);
- actor.SetSize(64.0f, 64.0f);
- return actor;
- }
-};
-
-void dali_roll_layout_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_roll_layout_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-
-int UtcDaliRollLayoutNew(void)
-{
- ToolkitTestApplication application;
-
- // Create a roll layout
- RollLayoutPtr rollLayout = RollLayout::New();
-
- DALI_TEST_CHECK(rollLayout);
- END_TEST;
-}
-
-int UtcDaliRollLayoutSetAndGetRowSpacing(void)
-{
- ToolkitTestApplication application;
-
- // Create a roll layout
- RollLayoutPtr rollLayout = RollLayout::New();
-
- // Set the row spacing
- rollLayout->SetRowSpacing(10.0f);
-
- // Check whether we get the correct row spacing
- DALI_TEST_EQUALS(rollLayout->GetRowSpacing(), 10.0f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliRollLayoutSetAndGetItemSizeFunction(void)
-{
- ToolkitTestApplication application;
-
- // Create a roll layout
- RollLayoutPtr rollLayout = RollLayout::New();
-
- // Set the item size function
- rollLayout->SetItemSizeFunction(RollLayoutItemSizeFunction);
-
- // Check whether we get the correct item size function
- DALI_TEST_CHECK(rollLayout->GetItemSizeFunction() == RollLayoutItemSizeFunction);
- END_TEST;
-}
-
-int UtcDaliRollLayoutSetAndGetScrollSpeedFactor(void)
-{
- ToolkitTestApplication application;
-
- // Create a roll layout
- RollLayoutPtr rollLayout = RollLayout::New();
-
- // Set the scroll speed factor
- rollLayout->SetScrollSpeedFactor(0.05f);
-
- // Check whether we get the correct scroll speed factor
- DALI_TEST_EQUALS(rollLayout->GetScrollSpeedFactor(), 0.05f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliRollLayoutSetAndGetMaximumSwipeSpeed(void)
-{
- ToolkitTestApplication application;
-
- // Create a roll layout
- RollLayoutPtr rollLayout = RollLayout::New();
-
- // Set the maximum swipe speed
- rollLayout->SetMaximumSwipeSpeed(50.0f);
-
- // Check whether we get the correct maximum swipe speed
- DALI_TEST_EQUALS(rollLayout->GetMaximumSwipeSpeed(), 50.0f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliRollLayoutSetAndGetItemFlickAnimationDuration(void)
-{
- ToolkitTestApplication application;
-
- // Create a roll layout
- RollLayoutPtr rollLayout = RollLayout::New();
-
- // Set the flick animaiton duration
- rollLayout->SetItemFlickAnimationDuration(0.35f);
-
- // Check whether we get the correct flick animaiton duration
- DALI_TEST_EQUALS( rollLayout->GetItemFlickAnimationDuration(), 0.35f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliRollLayoutConstraintLeft(void)
-{
- ToolkitTestApplication application;
-
- // Create the ItemView actor
- TestItemFactory factory;
- ItemView view = ItemView::New(factory);
- Vector3 vec(480.0f, 800.0f, 0.0f);
- RollLayoutPtr rollLayout = RollLayout::New();
-
- view.SetName("view actor");
- view.AddLayout(*rollLayout);
- view.SetSize(vec);
-
- Stage::GetCurrent().Add(view);
- rollLayout->SetOrientation(ControlOrientation::Left);
- view.ActivateLayout(0, vec, 0.0f);
-
- application.SendNotification();
- application.Render(0);
-
- // render 10 frames
- for(int i = 0; i < 10; ++i)
- {
- application.Render(16); // 60hz frames
- }
-
- // Confirm: we have actors in the view and they are positioned some distance from the origin.
- int nonZeroCount = 0;
- int elementsFound = 0;
- for(unsigned int i = 0; i < 10; i++)
- {
- Actor testActor = view.GetItem(i);
- if (testActor)
- {
- elementsFound++;
- Vector3 pos = testActor.GetCurrentPosition();
-
- if (pos.LengthSquared() > 0.0f)
- {
- nonZeroCount++;
- }
- }
- }
-
- DALI_TEST_CHECK((elementsFound > 0) && (nonZeroCount == elementsFound));
- Stage::GetCurrent().Remove(view);
- END_TEST;
-}
-
-int UtcDaliRollLayoutConstraintRight(void)
-{
- ToolkitTestApplication application;
-
- // Create the ItemView actor
- TestItemFactory factory;
- ItemView view = ItemView::New(factory);
- Vector3 vec(480.0f, 800.0f, 0.0f);
- RollLayoutPtr rollLayout = RollLayout::New();
-
- view.SetName("view actor");
- view.AddLayout(*rollLayout);
- view.SetSize(vec);
-
- Stage::GetCurrent().Add(view);
- rollLayout->SetOrientation(ControlOrientation::Right);
- view.ActivateLayout(0, vec, 0.0f);
-
- application.SendNotification();
- application.Render(0);
-
- // render 10 frames
- for(int i = 0; i < 10; ++i)
- {
- application.Render(16); // 60hz frames
- }
-
- // Confirm: we have actors in the view and they are positioned some distance from the origin.
- int nonZeroCount = 0;
- int elementsFound = 0;
- for(unsigned int i = 0; i < 10; i++)
- {
- Actor testActor = view.GetItem(i);
- if (testActor)
- {
- elementsFound++;
- Vector3 pos = testActor.GetCurrentPosition();
-
- if (pos.LengthSquared() > 0.0f)
- {
- nonZeroCount++;
- }
- }
- }
-
- DALI_TEST_CHECK((elementsFound > 0) && (nonZeroCount == elementsFound));
- Stage::GetCurrent().Remove(view);
- END_TEST;
-}
-
-int UtcDaliRollLayoutConstraintUp(void)
-{
- ToolkitTestApplication application;
-
- // Create the ItemView actor
- TestItemFactory factory;
- ItemView view = ItemView::New(factory);
- Vector3 vec(480.0f, 800.0f, 0.0f);
- RollLayoutPtr rollLayout = RollLayout::New();
-
- view.SetName("view actor");
- view.AddLayout(*rollLayout);
- view.SetSize(vec);
-
- Stage::GetCurrent().Add(view);
- rollLayout->SetOrientation(ControlOrientation::Up);
- view.ActivateLayout(0, vec, 0.0f);
-
- application.SendNotification();
- application.Render(0);
-
- // render 10 frames
- for(int i = 0; i < 10; ++i)
- {
- application.Render(16); // 60hz frames
- }
-
- // Confirm: we have actors in the view and they are positioned some distance from the origin.
- int nonZeroCount = 0;
- int elementsFound = 0;
- for(unsigned int i = 0; i < 10; i++)
- {
- Actor testActor = view.GetItem(i);
- if (testActor)
- {
- elementsFound++;
- Vector3 pos = testActor.GetCurrentPosition();
-
- if (pos.LengthSquared() > 0.0f)
- {
- nonZeroCount++;
- }
- }
- }
-
- DALI_TEST_CHECK((elementsFound > 0) && (nonZeroCount == elementsFound));
- Stage::GetCurrent().Remove(view);
- END_TEST;
-}
-
-int UtcDaliRollLayoutConstraintDown(void)
-{
- ToolkitTestApplication application;
-
- // Create the ItemView actor
- TestItemFactory factory;
- ItemView view = ItemView::New(factory);
- Vector3 vec(480.0f, 800.0f, 0.0f);
- RollLayoutPtr rollLayout = RollLayout::New();
-
- view.SetName("view actor");
- view.AddLayout(*rollLayout);
- view.SetSize(vec);
-
- Stage::GetCurrent().Add(view);
- rollLayout->SetOrientation(ControlOrientation::Down);
- view.ActivateLayout(0, vec, 0.0f);
-
- application.SendNotification();
- application.Render(0);
-
- // render 10 frames
- for(int i = 0; i < 10; ++i)
- {
- application.Render(16); // 60hz frames
- }
-
- // Confirm: we have actors in the view and they are positioned some distance from the origin.
- int nonZeroCount = 0;
- int elementsFound = 0;
- for(unsigned int i = 0; i < 10; i++)
- {
- Actor testActor = view.GetItem(i);
- if (testActor)
- {
- elementsFound++;
- Vector3 pos = testActor.GetCurrentPosition();
-
- if (pos.LengthSquared() > 0.0f)
- {
- nonZeroCount++;
- }
- }
- }
-
- DALI_TEST_CHECK((elementsFound > 0) && (nonZeroCount == elementsFound));
- Stage::GetCurrent().Remove(view);
- END_TEST;
-}
-
-int UtcDaliRollLayoutScrollDirection(void)
-{
- ToolkitTestApplication application;
-
- // Create the ItemView actor
- TestItemFactory factory;
- ItemView view = ItemView::New(factory);
- Vector3 vec(480.0f, 800.0f, 0.0f);
- RollLayoutPtr rollLayout = RollLayout::New();
-
- view.SetName("view actor");
- view.AddLayout(*rollLayout);
- view.SetSize(vec);
-
- Stage::GetCurrent().Add(view);
- rollLayout->SetOrientation(ControlOrientation::Left);
- view.ActivateLayout(0, vec, 0.0f);
-
- application.SendNotification();
- application.Render(0);
-
- ItemLayoutPtr layout = rollLayout;
-
- // render 10 frames
- for(int i = 0; i < 10; ++i)
- {
- application.Render(16); // 60hz frames
- }
-
- rollLayout->SetOrientation(ControlOrientation::Up);
- view.ActivateLayout(0, vec, 0.0f);
- application.SendNotification();
- application.Render();
-
- Degree deg = layout->GetScrollDirection();
- DALI_TEST_CHECK(deg == 0.0f);
-
- rollLayout->SetOrientation(ControlOrientation::Down);
- view.ActivateLayout(0, vec, 0.0f);
- application.SendNotification();
- application.Render();
-
- deg = layout->GetScrollDirection();
- DALI_TEST_CHECK((deg == 180.0f));
-
- layout->SetOrientation(ControlOrientation::Left);
- view.ActivateLayout(0, vec, 0.0f);
- application.SendNotification();
- application.Render();
-
- deg = layout->GetScrollDirection();
- DALI_TEST_CHECK(deg == 90.f);
-
- rollLayout->SetOrientation(ControlOrientation::Right);
- view.ActivateLayout(0, vec, 0.0f);
- application.SendNotification();
- application.Render();
-
- deg = layout->GetScrollDirection();
- DALI_TEST_CHECK(deg == 270.0f);
-
- Stage::GetCurrent().Remove(view);
- END_TEST;
-}
#include <dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h>
#include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
#include <dali-toolkit/public-api/controls/scrollable/item-view/item-view.h>
-#include <dali-toolkit/public-api/controls/scrollable/item-view/navigation-layout.h>
-#include <dali-toolkit/public-api/controls/scrollable/item-view/roll-layout.h>
#include <dali-toolkit/public-api/controls/scrollable/item-view/spiral-layout.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-carousel-effect.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-constraints.h>
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-#include <algorithm>
-
-#include <dali-toolkit/public-api/controls/scrollable/item-view/navigation-layout.h>
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-namespace // unnamed namespace
-{
-const unsigned int DEFAULT_NUMBER_OF_COLUMNS = 3;
-const float DEFAULT_TOP_MARGIN = 0.3f;
-const float DEFAULT_BOTTOM_MARGIN = 0.3f;
-const float DEFAULT_SIDE_MARGIN = 0.2f;
-const float DEFAULT_COLUMN_SPACING = 20.0f;
-const float DEFAULT_ROW_SPACING = 20.0f;
-const float DEFAULT_SCROLL_SPEED_FACTOR = 0.01f;
-const float DEFAULT_MAXIMUM_SWIPE_SPEED = 3.0f;
-const float DEFAULT_ITEM_FLICK_ANIMATION_DURATION = 0.05f;
-const float DEFAULT_SIZE_EXTEND = 1.4f;
-const float DEFAULT_HEIGHT_FACTOR = 0.6f;
-
-// 4 orientations are supported
-struct NavigationPositionConstraintUp
-{
- NavigationPositionConstraintUp(const unsigned int columnIndex,
- const unsigned int numberOfColumns,
- const float columnSpacing,
- const float sizeExtend,
- const float bottomMargin,
- const float topMargin)
- : mColumnIndex(columnIndex),
- mNumberOfColumns(numberOfColumns),
- mColumnSpacing(columnSpacing),
- mSizeExtend(sizeExtend),
- mBottomMargin(bottomMargin),
- mTopMargin(topMargin)
- {
- }
-
- Vector3 operator()(const Vector3& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- float itemWidth = (layoutSize.width * mSizeExtend- mColumnSpacing * (mNumberOfColumns - 1))/( mNumberOfColumns );
-
- Vector3 itemPosition;
-
- float z = (sinf((layoutPosition + 1.0f) * Math::PI *0.5f) - 1.0f) * itemWidth * 2.0f;
-
- itemPosition = Vector3( (layoutPosition + 1.0f) * (itemWidth + mColumnSpacing) + itemWidth * 0.5f - layoutSize.width * mSizeExtend * 0.5f,
- (- mBottomMargin + mTopMargin) * layoutSize.width * 0.5f ,
- z);
- return itemPosition;
- }
-
-public:
- unsigned int mColumnIndex;
- unsigned int mNumberOfColumns;
- float mColumnSpacing;
- float mSizeExtend;
- float mBottomMargin;
- float mTopMargin;
-};
-
-struct NavigationPositionConstraintLeft
-{
- NavigationPositionConstraintLeft(const unsigned int columnIndex,
- const unsigned int numberOfColumns,
- const float columnSpacing,
- const float sizeExtend,
- const float bottomMargin,
- const float topMargin)
- : mColumnIndex(columnIndex),
- mNumberOfColumns(numberOfColumns),
- mColumnSpacing(columnSpacing),
- mSizeExtend(sizeExtend),
- mBottomMargin(bottomMargin),
- mTopMargin(topMargin)
- {
- }
-
- Vector3 operator()(const Vector3& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- float itemWidth = (DEFAULT_HEIGHT_FACTOR * layoutSize.height * mSizeExtend- mColumnSpacing * (mNumberOfColumns - 1))/( mNumberOfColumns );
- Vector3 itemPosition;
- float z = (sinf((layoutPosition + 1.0f) * Math::PI *0.5f) - 1.0f) * itemWidth * 1.5f;
- itemPosition = Vector3( (- mBottomMargin + mTopMargin) * 0.5f * layoutSize.width ,
- -((layoutPosition+ 1.0) * (itemWidth + mColumnSpacing) + itemWidth * 0.5f - DEFAULT_HEIGHT_FACTOR * layoutSize.height * mSizeExtend * 0.5f ),
- z);
- return itemPosition;
- }
-
-public:
- unsigned int mColumnIndex;
- unsigned int mNumberOfColumns;
- float mColumnSpacing;
- float mSizeExtend;
- float mBottomMargin;
- float mTopMargin;
-};
-
-struct NavigationPositionConstraintDown
-{
- NavigationPositionConstraintDown(const unsigned int columnIndex,
- const unsigned int numberOfColumns,
- const float columnSpacing,
- const float sizeExtend,
- const float bottomMargin,
- const float topMargin)
- : mColumnIndex(columnIndex),
- mNumberOfColumns(numberOfColumns),
- mColumnSpacing(columnSpacing),
- mSizeExtend(sizeExtend),
- mBottomMargin(bottomMargin),
- mTopMargin(topMargin)
- {
- }
-
- Vector3 operator()(const Vector3& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- float itemWidth = (layoutSize.width * mSizeExtend- mColumnSpacing * (mNumberOfColumns - 1))/( mNumberOfColumns );
- Vector3 itemPosition;
-
- float z = (sinf((layoutPosition + 1.0f ) * Math::PI *0.5f) - 1.0f) * itemWidth * 2.0f;
- itemPosition = Vector3( -((layoutPosition + 1.0f) * (itemWidth + mColumnSpacing) + itemWidth * 0.5f - layoutSize.width * mSizeExtend * 0.5f),
- (- mBottomMargin + mTopMargin)* layoutSize.width * 0.5f,
- z);
- return itemPosition;
- }
-
- public:
- unsigned int mColumnIndex;
- unsigned int mNumberOfColumns;
- float mColumnSpacing;
- float mSizeExtend;
- float mBottomMargin;
- float mTopMargin;
-};
-
-struct NavigationPositionConstraintRight
-{
- NavigationPositionConstraintRight(const unsigned int columnIndex,
- const unsigned int numberOfColumns,
- const float columnSpacing,
- const float sizeExtend,
- const float bottomMargin,
- const float topMargin)
- : mColumnIndex(columnIndex),
- mNumberOfColumns(numberOfColumns),
- mColumnSpacing(columnSpacing),
- mSizeExtend(sizeExtend),
- mBottomMargin(bottomMargin),
- mTopMargin(topMargin)
- {
- }
-
- Vector3 operator()(const Vector3& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- float itemWidth = (DEFAULT_HEIGHT_FACTOR * layoutSize.height * mSizeExtend- mColumnSpacing * (mNumberOfColumns - 1))/( mNumberOfColumns );
- Vector3 itemPosition;
- float z = (sinf((layoutPosition + 1.0f) * Math::PI *0.5f) - 1.0f) * itemWidth * 1.5f;
- itemPosition = Vector3( (- mBottomMargin + mTopMargin) * layoutSize.width * 0.5f,
- ((layoutPosition + 1.0f) * (itemWidth + mColumnSpacing) + itemWidth * 0.5f - DEFAULT_HEIGHT_FACTOR * layoutSize.height * mSizeExtend *0.5f ),
- z);
- return itemPosition;
- }
-
-public:
- unsigned int mColumnIndex;
- unsigned int mNumberOfColumns;
- float mColumnSpacing;
- float mSizeExtend;
- float mBottomMargin;
- float mTopMargin;
-};
-
-struct NavigationRotationConstraintUp
-{
- Quaternion operator()(const Quaternion& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- float angle = 0.0f;
- float _layoutPosition = layoutPosition + 1.0f;
- if(_layoutPosition >= 1.0f)
- {
- angle = - sinf(Math::PI * _layoutPosition) * Math::PI * 0.2f;
- }
- else
- {
- angle = sinf(Math::PI * _layoutPosition) * Math::PI * 0.2f;
- }
- return Quaternion(angle, Vector3::YAXIS);
- }
-
-};
-
-struct NavigationRotationConstraintLeft
-{
- Quaternion operator()(const Quaternion& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- float angle = 0.0f;
- float _layoutPosition = layoutPosition + 1.0f;
- if(_layoutPosition >= 1.0f)
- {
- angle = - sinf(Math::PI * _layoutPosition) * Math::PI * 0.2f;
- }
- else
- {
- angle = sinf(Math::PI * _layoutPosition) * Math::PI * 0.2f;
- }
- return Quaternion(Math::PI * 0.5f, Vector3::ZAXIS) * Quaternion(angle, Vector3::YAXIS);
- }
-};
-
-struct NavigationRotationConstraintDown
-{
- Quaternion operator()(const Quaternion& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- float angle = 0.0f;
- float _layoutPosition = layoutPosition + 1.0f;
- if(_layoutPosition >= 1.0f)//right side
- {
- //rotation angle by z axis
- angle = - sinf(Math::PI * _layoutPosition) * Math::PI * 0.2f;
- }
- else // left side
- {
- angle = sinf(Math::PI * _layoutPosition) * Math::PI * 0.2f;
- }
- return Quaternion(Math::PI, Vector3::ZAXIS) * Quaternion(angle, Vector3::YAXIS);
- }
-};
-
-struct NavigationRotationConstraintRight
-{
- Quaternion operator()(const Quaternion& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- float angle = 0.0f;
- float _layoutPosition = layoutPosition + 1.0f;
- if(_layoutPosition >= 1.0f)
- {
- angle = - sinf(Math::PI * _layoutPosition) * Math::PI * 0.2f;
- }
- else
- {
- angle = sinf(Math::PI * _layoutPosition) * Math::PI * 0.2f;
- }
- return Quaternion(Math::PI * 1.5f, Vector3::ZAXIS) * Quaternion(angle, Vector3::YAXIS);
- }
-};
-
-struct NavigationColorConstraint
-{
- NavigationColorConstraint(unsigned int numberOfColumns)
- : mNumberOfColumns(numberOfColumns)
- {
-
- }
- Vector4 operator()(const Vector4& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- float darkness = 1.0f;
- float alpha = 1.0f;
-
- float pos = ( layoutPosition + 1.0f);
- darkness = (-0.25f) * (pos + 1.0f) * (pos + 1.0f) + 1.0f * (pos + 1.0f) + 0.2f;
-
- darkness = fabs(darkness);
- darkness /= 1.2f;
-
- return Vector4(darkness, darkness, darkness, current.a * alpha);
- }
- unsigned int mNumberOfColumns;
-
-};
-
-struct NavigationVisibilityConstraint
-{
- NavigationVisibilityConstraint(const unsigned int columnIndex,
- const unsigned int numberOfColumns,
- const float columnSpacing )
- : mColumnIndex(columnIndex),
- mNumberOfColumns(numberOfColumns),
- mColumnSpacing(columnSpacing)
- {
- }
-
- bool operator()(const bool& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- float index = layoutPosition + 1.0f;
- return (index >= -1.0f) && (index <= mNumberOfColumns );
- }
-
-public:
- unsigned int mColumnIndex;
- unsigned int mNumberOfColumns;
- float mColumnSpacing;
-};
-}//end namespace
-
-namespace Dali
-{
-namespace Toolkit
-{
-struct NavigationLayout::Impl
-{
- Impl()
- : mNumberOfColumns(DEFAULT_NUMBER_OF_COLUMNS),
- mColumnSpacing(DEFAULT_COLUMN_SPACING),
- mTopMargin(DEFAULT_TOP_MARGIN),
- mBottomMargin(DEFAULT_BOTTOM_MARGIN),
- mSideMargin(DEFAULT_SIDE_MARGIN),
- mScrollSpeedFactor(DEFAULT_SCROLL_SPEED_FACTOR),
- mMaximumSwipeSpeed(DEFAULT_MAXIMUM_SWIPE_SPEED),
- mItemFlickAnimationDuration(DEFAULT_ITEM_FLICK_ANIMATION_DURATION),
- mSizeExtend(DEFAULT_SIZE_EXTEND)
- {
- mColorConstraint = NavigationColorConstraint(mNumberOfColumns);
- mRotationConstraint[0] = NavigationRotationConstraintUp();
- mRotationConstraint[1] = NavigationRotationConstraintLeft();
- mRotationConstraint[2] = NavigationRotationConstraintDown();
- mRotationConstraint[3] = NavigationRotationConstraintRight();
- }
-
- unsigned int mNumberOfColumns;
- float mColumnSpacing;
- float mTopMargin;
- float mBottomMargin;
- float mSideMargin;
- float mScrollSpeedFactor;
- float mMaximumSwipeSpeed;
- float mItemFlickAnimationDuration;
- float mSizeExtend;
-
- ItemLayout::QuaternionFunction mRotationConstraint[4];
-
- ItemLayout::Vector4Function mColorConstraint;
-};
-
-NavigationLayoutPtr NavigationLayout::New()
-{
- return NavigationLayoutPtr(new NavigationLayout());
-}
-
-NavigationLayout::~NavigationLayout()
-{
- delete mImpl;
-}
-
-void NavigationLayout::SetNumberOfColumns(unsigned int columns)
-{
- mImpl->mNumberOfColumns = columns;
-}
-
-unsigned int NavigationLayout::GetNumberOfColumns() const
-{
- return mImpl->mNumberOfColumns;
-}
-
-void NavigationLayout::SetColumnSpacing(float spacing)
-{
- mImpl->mColumnSpacing = spacing;
-}
-
-float NavigationLayout::GetColumnSpacing() const
-{
- return mImpl->mColumnSpacing;
-}
-
-void NavigationLayout::SetTopMargin(float margin)
-{
- mImpl->mTopMargin = margin;
-}
-
-float NavigationLayout::GetTopMargin() const
-{
- return mImpl->mTopMargin;
-}
-
-void NavigationLayout::SetBottomMargin(float margin)
-{
- mImpl->mBottomMargin = margin;
-}
-
-float NavigationLayout::GetBottomMargin() const
-{
- return mImpl->mBottomMargin;
-}
-
-void NavigationLayout::SetSideMargin(float margin)
-{
- mImpl->mSideMargin = margin;
- mImpl->mSizeExtend = (1.0f - margin) * 3.0f;
-}
-
-void NavigationLayout::SetScrollSpeedFactor(float scrollSpeed)
-{
- mImpl->mScrollSpeedFactor = scrollSpeed;
-}
-
-void NavigationLayout::SetMaximumSwipeSpeed(float speed)
-{
- mImpl->mMaximumSwipeSpeed = speed;
-}
-
-void NavigationLayout::SetItemFlickAnimationDuration(float durationSeconds)
-{
- mImpl->mItemFlickAnimationDuration = durationSeconds;
-}
-
-float NavigationLayout::GetScrollSpeedFactor() const
-{
- return mImpl->mScrollSpeedFactor;
-}
-
-float NavigationLayout::GetMaximumSwipeSpeed() const
-{
- return mImpl->mMaximumSwipeSpeed;
-}
-
-float NavigationLayout::GetItemFlickAnimationDuration() const
-{
- return mImpl->mItemFlickAnimationDuration;
-}
-
-float NavigationLayout::GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const
-{
- unsigned int itemsLastRow = numberOfItems % mImpl->mNumberOfColumns;
- if (itemsLastRow == 0)
- {
- itemsLastRow = mImpl->mNumberOfColumns;
- }
-
- float itemsLastPage = static_cast<float>(itemsLastRow);
- return itemsLastPage - static_cast<float>(numberOfItems) - 2.0f;
-
-}
-
-float NavigationLayout::GetClosestAnchorPosition(float layoutPosition) const
-{
- return round(layoutPosition);
-}
-
-float NavigationLayout::GetItemScrollToPosition(unsigned int itemId) const
-{
- return - static_cast<float>(itemId);
-}
-
-ItemRange NavigationLayout::GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const
-{
- int itemsPerPage = mImpl->mNumberOfColumns;
-
- int firstItemIndex = std::max(0.0f, -firstItemPosition -1.0f );
- int lastItemIndex = std::max(0.0f, -(firstItemPosition) + itemsPerPage );
-
- return ItemRange(firstItemIndex , lastItemIndex );
-}
-
-unsigned int NavigationLayout::GetReserveItemCount(Vector3 layoutSize) const
-{
- float layoutWidth = IsHorizontal(mOrientation) ? layoutSize.height : layoutSize.width;
- float itemWidth = (layoutWidth * mImpl->mSizeExtend - mImpl->mColumnSpacing * (mImpl->mNumberOfColumns - 1))/( mImpl->mNumberOfColumns );
- return static_cast<unsigned int>(layoutWidth / itemWidth);
-}
-
-bool NavigationLayout::GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const
-{
- float layoutWidth = IsHorizontal(mOrientation) ? (DEFAULT_HEIGHT_FACTOR * layoutSize.height) : layoutSize.width;
- layoutWidth = layoutWidth * mImpl->mSizeExtend;
-
- float itemWidth = (layoutWidth - mImpl->mColumnSpacing*(mImpl->mNumberOfColumns-1)) / mImpl->mNumberOfColumns;
- float itemHeight = layoutWidth * (1.0f - mImpl->mBottomMargin - mImpl->mTopMargin);
- itemSize = Vector3(itemWidth, itemHeight, (itemWidth/4)*3);
-
- return true;
-}
-
-void NavigationLayout::GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const
-{
-}
-
-bool NavigationLayout::GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const
-{
- unsigned int columnIndex = itemId % mImpl->mNumberOfColumns;
- if (mOrientation == ControlOrientation::Left)
- {
- constraint = NavigationPositionConstraintLeft(columnIndex, mImpl->mNumberOfColumns, mImpl->mColumnSpacing, mImpl->mSizeExtend, mImpl->mBottomMargin, mImpl->mTopMargin);
- }
- else if (mOrientation == ControlOrientation::Up)
- {
- constraint = NavigationPositionConstraintUp(columnIndex, mImpl->mNumberOfColumns, mImpl->mColumnSpacing, mImpl->mSizeExtend, mImpl->mBottomMargin, mImpl->mTopMargin);
- }
- else if (mOrientation == ControlOrientation::Down)
- {
- constraint = NavigationPositionConstraintDown(columnIndex, mImpl->mNumberOfColumns, mImpl->mColumnSpacing, mImpl->mSizeExtend, mImpl->mBottomMargin, mImpl->mTopMargin);
- }
- else if (mOrientation == ControlOrientation::Right)
- {
- constraint = NavigationPositionConstraintRight(columnIndex, mImpl->mNumberOfColumns, mImpl->mColumnSpacing, mImpl->mSizeExtend, mImpl->mBottomMargin, mImpl->mTopMargin);
- }
-
- return true;
-}
-
-bool NavigationLayout::GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const
-{
- return false; // No scaling
-}
-
-bool NavigationLayout::GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const
-{
- constraint = mImpl->mRotationConstraint[mOrientation];
- return true;
-}
-
-bool NavigationLayout::GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const
-{
- constraint = mImpl->mColorConstraint;
- return true;
-}
-
-bool NavigationLayout::GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const
-{
- unsigned int columnIndex = itemId % mImpl->mNumberOfColumns;
- constraint = NavigationVisibilityConstraint(columnIndex, mImpl->mNumberOfColumns, mImpl->mColumnSpacing);
- return true;
-}
-
-Degree NavigationLayout::GetScrollDirection() const
-{
- Degree scrollDirection(0);
- if (mOrientation == ControlOrientation::Down)
- {
- scrollDirection = 0.0f - 45.0f;
- }
- else if (mOrientation == ControlOrientation::Right)
- {
- scrollDirection = 90.0f - 45.0f;
- }
- else if (mOrientation == ControlOrientation::Up)
- {
- scrollDirection = 180.0f - 45.0f;
- }
- else // mOrientation == ControlOrientation::Left
- {
- scrollDirection = 270.0f - 45.0f;
- }
-
- return scrollDirection;
-}
-
-NavigationLayout::NavigationLayout()
- :mImpl(NULL)
-{
- mImpl = new Impl();
-}
-
-}
-}
+++ /dev/null
-#ifndef __DALI_TOOLKIT_NAVIGATION_LAYOUT_H__
-#define __DALI_TOOLKIT_NAVIGATION_LAYOUT_H__
-
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
-
-namespace Dali
-{
-namespace Toolkit
-{
-class NavigationLayout;
-
-typedef IntrusivePtr<NavigationLayout> NavigationLayoutPtr;
-
-/**
- * An ItemView layout which arranges items in navigation mode.
- */
-class DALI_IMPORT_API NavigationLayout: public ItemLayout
-{
-public:
-
- typedef boost::function<Vector3 (const Vector3& layoutSize,
- const unsigned int orientation,
- const unsigned int numberOfColumns,
- const float columnSpacing,
- const float sideMargin)> ResizeFunction;
-
- /**
- * Create a new navigation layout
- */
- static NavigationLayoutPtr New();
-
- /**
- * Virtual destructor.
- */
- virtual ~NavigationLayout();
-
- /**
- * Set the number of columns in the layout.
- * @param[in] columns The number of columns.
- */
- void SetNumberOfColumns(unsigned int columns);
-
- /**
- * Get the number of columns in the layout.
- * @return The number of columns.
- */
- unsigned int GetNumberOfColumns() const;
-
- /**
- * Set the spacing between columns.
- * @param[in] spacing The spacing.
- */
- void SetColumnSpacing(float spacing);
-
- /**
- * Get the spacing between columns.
- * @return The spacing.
- */
- float GetColumnSpacing() const;
-
- /**
- * Set the margin in the top of the layout
- * @param[in] margin The layout top margin.
- */
- void SetTopMargin(float margin);
-
- /**
- * Get the margin in the top of the layout
- * @return The layout top margin.
- */
- float GetTopMargin() const;
-
- /**
- * Set the margin in the bottom of the layout
- * @param[in] margin The layout bottom margin.
- */
- void SetBottomMargin(float margin);
-
- /**
- * Get the margin in the bottom of the layout
- * @return The layout bottom margin.
- */
- float GetBottomMargin() const;
-
- /**
- * Set the margin in the left and right of the layout
- * @param[in] margin The layout side margin.
- */
- void SetSideMargin(float margin);
-
- /**
- * Get the margin in the left and right of the layout
- * @return The layout side margin.
- */
- float GetSideMargin() const;
-
- /**
- * Set the factor used to customise the scroll speed while dragging and swiping the layout.
- * @param[in] scrollSpeed The scroll speed factor.
- */
- void SetScrollSpeedFactor(float scrollSpeed);
-
- /**
- * Set the maximum swipe speed in pixels per second.
- * @param[in] speed The maximum swipe speed.
- */
- void SetMaximumSwipeSpeed(float speed);
-
- /**
- * Set the duration of the flick animation in second. This is the time taken to animate each
- * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
- * by a swipe gesture.
- * @pre durationSeconds must be greater than zero.
- * @param[in] durationSeconds The duration of flick animation in seconds.
- */
- void SetItemFlickAnimationDuration(float durationSeconds);
-
- /**
- * @copydoc ItemLayout::GetScrollSpeedFactor()
- */
- virtual float GetScrollSpeedFactor() const;
-
- /**
- * @copydoc ItemLayout::GetMaximumSwipeSpeed()
- */
- virtual float GetMaximumSwipeSpeed() const;
-
- /**
- * @copydoc ItemLayout::GetItemFlickAnimationDuration()
- */
- virtual float GetItemFlickAnimationDuration() const;
-
-private:
-
- /**
- * @copydoc ItemLayout::GetMinimumLayoutPosition()
- */
- virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
-
- /**
- * @copydoc ItemLayout::GetClosestAnchorPosition()
- */
- virtual float GetClosestAnchorPosition(float layoutPosition) const;
-
- /**
- * @copydoc ItemLayout::GetItemScrollToPosition()
- */
- virtual float GetItemScrollToPosition(unsigned int itemId) const;
-
- /**
- * @copydoc ItemLayout::GetItemsWithinArea()
- */
- virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
-
- /**
- * @copydoc ItemLayout::GetReserveItemCount()
- */
- virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
-
- /**
- * @copydoc ItemLayout::GetItemSize()
- */
- virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
-
- /**
- * @copydoc ItemLayout::GetResizeAnimation()
- */
- virtual void GetResizeAnimation(Animation& animation,
- Actor actor,
- Vector3 size,
- float durationSeconds) const;
-
- /**
- * @copydoc ItemLayout::GetPositionConstraint()
- */
- virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
-
- /**
- * @copydoc ItemLayout::GetRotationConstraint()
- */
- virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
-
- /**
- * @copydoc ItemLayout::GetScaleConstraint()
- */
- virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
-
- /**
- * @copydoc ItemLayout::GetColorConstraint()
- */
- virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
-
- /**
- * @copydoc ItemLayout::GetVisibilityConstraint()
- */
- virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
-
- /**
- * @copydoc ItemLayout::GetScrollDirection()
- */
- virtual Degree GetScrollDirection() const;
-
-protected:
-
- /**
- * Protected constructor; see also GridLayout::New()
- */
- NavigationLayout();
-
-private:
-
- struct Impl;
- Impl* mImpl;
-};
-
-}
-}
-#endif //__DALI_TOOLKIT_NAVIGATION_LAYOUT_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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/item-view/roll-layout.h>
-
-// EXTERNAL INCLUDES
-#include <algorithm>
-#include <dali/public-api/animation/animation.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-namespace // unnamed namespace
-{
-
-const float DEFAULT_ROW_SPACING = 20.0f;
-const float DEFAULT_SCROLL_SPEED_FACTOR = 0.0015f;
-const float DEFAULT_MAXIMUM_SWIPE_SPEED = 8.0f;
-const float DEFAULT_ITEM_FLICK_ANIMATION_DURATION = 0.4f;
-
-// 4 orientations are supported
-static const unsigned int ORIENTATION_COUNT = 4;
-
-static Vector3 GetItemSizeDefaultFunction(float layoutWidth, float layoutHeight, float rowSpacing)
-{
- float height = (layoutHeight - rowSpacing) * 0.5f;
- return Vector3(layoutWidth, height, height);
-}
-
-struct RollPositionConstraint0
-{
- RollPositionConstraint0(const float rowSpacing, RollLayout::ItemSizeFunction itemSizeFunction)
- : mRowSpacing(rowSpacing),
- mItemSizeFunction(itemSizeFunction)
- {
- }
-
- Vector3 operator()(const Vector3& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- Vector3 itemSize = mItemSizeFunction(layoutSize.width, layoutSize.height, mRowSpacing);
-
- float adjustedLayoutPosition = layoutPosition;
- float scrollSpeedFactor = scrollSpeed * scrollSpeed * scrollSpeed * scrollSpeed;
- float y = 0.0f;
-
- float adjustedRowSpacing = mRowSpacing + scrollSpeedFactor;
-
- if(adjustedLayoutPosition > Math::MACHINE_EPSILON_0 && adjustedLayoutPosition -2.0f < Math::MACHINE_EPSILON_0)
- {
- float adjustment = 1.0f - Dali::AlphaFunctions::EaseInOutSine60((2.0f - adjustedLayoutPosition) * 0.5f);
- adjustedLayoutPosition = adjustment * 2.0f;
- y = ((itemSize.y + adjustedRowSpacing ) * adjustedLayoutPosition) - layoutSize.height * 0.5f + itemSize.y * 0.5f;
- }
- else
- {
- float yStep = std::max(50.0f, std::min(itemSize.y, scrollSpeedFactor));
- y = adjustedLayoutPosition < Math::MACHINE_EPSILON_0 ? adjustedLayoutPosition * yStep : (layoutSize.height * 0.5f + adjustedRowSpacing) + (adjustedLayoutPosition - 1.0f) * yStep;
- y += itemSize.y * 0.5f - layoutSize.height * 0.5f;
- }
-
- float z = adjustedLayoutPosition * (10.0f + scrollSpeedFactor);
- z -= std::min(3000.0f, scrollSpeedFactor * 2.0f);
-
- return Vector3(itemSize.x * 0.5f - layoutSize.x * 0.5f, y, z);
- }
-
-public:
-
- float mRowSpacing;
- RollLayout::ItemSizeFunction mItemSizeFunction;
-};
-
-struct RollPositionConstraint90
-{
- RollPositionConstraint90(const float rowSpacing, RollLayout::ItemSizeFunction itemSizeFunction)
- : mRowSpacing(rowSpacing),
- mItemSizeFunction(itemSizeFunction)
- {
- }
-
- Vector3 operator()(const Vector3& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- Vector3 itemSize = mItemSizeFunction(layoutSize.height, layoutSize.width, mRowSpacing);
-
- float adjustedLayoutPosition = layoutPosition;
- float scrollSpeedFactor = scrollSpeed * scrollSpeed * scrollSpeed;
- float x = 0.0f;
-
- float adjustedRowSpacing = mRowSpacing + scrollSpeedFactor;
-
- if(adjustedLayoutPosition > Math::MACHINE_EPSILON_0 && adjustedLayoutPosition -2.0f < Math::MACHINE_EPSILON_0)
- {
- float adjustment = 1.0f - Dali::AlphaFunctions::EaseInOutSine60((2.0f - adjustedLayoutPosition) * 0.5f);
- adjustedLayoutPosition = adjustment * 2.0f;
- x = ((itemSize.y + adjustedRowSpacing ) * adjustedLayoutPosition) - layoutSize.width * 0.5f + itemSize.y * 0.5f;
- }
- else
- {
- float xStep = std::max(50.0f, std::min(itemSize.y, scrollSpeedFactor));
- x = adjustedLayoutPosition < Math::MACHINE_EPSILON_0 ? adjustedLayoutPosition * xStep : (layoutSize.width * 0.5f + adjustedRowSpacing) + (adjustedLayoutPosition - 1.0f) * xStep;
- x += itemSize.y * 0.5f - layoutSize.width * 0.5f;
- }
-
- float z = adjustedLayoutPosition * (10.0f + scrollSpeedFactor);
- z -= std::min(3000.0f, scrollSpeedFactor * 2.0f);
-
- return Vector3(x, itemSize.x * 0.5f - layoutSize.y * 0.5f, z);
- }
-
-public:
-
- float mRowSpacing;
- RollLayout::ItemSizeFunction mItemSizeFunction;
-};
-
-struct RollPositionConstraint180
-{
- RollPositionConstraint180(const float rowSpacing, RollLayout::ItemSizeFunction itemSizeFunction)
- : mRowSpacing(rowSpacing),
- mItemSizeFunction(itemSizeFunction)
- {
- }
-
- Vector3 operator()(const Vector3& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- Vector3 itemSize = mItemSizeFunction(layoutSize.width, layoutSize.height, mRowSpacing);
-
- float adjustedLayoutPosition = layoutPosition;
- float scrollSpeedFactor = scrollSpeed * scrollSpeed * scrollSpeed;
- float y = 0.0f;
-
- float adjustedRowSpacing = mRowSpacing + scrollSpeedFactor;
-
- if(adjustedLayoutPosition > Math::MACHINE_EPSILON_0 && adjustedLayoutPosition -2.0f < Math::MACHINE_EPSILON_0)
- {
- float adjustment = 1.0f - Dali::AlphaFunctions::EaseInOutSine60((2.0f - adjustedLayoutPosition) * 0.5f);
- adjustedLayoutPosition = adjustment * 2.0f;
- y = ((itemSize.y + adjustedRowSpacing ) * adjustedLayoutPosition) - layoutSize.height * 0.5f + itemSize.y * 0.5f;
- }
- else
- {
- float yStep = std::max(50.0f, std::min(itemSize.y, scrollSpeedFactor));
- y = adjustedLayoutPosition < Math::MACHINE_EPSILON_0 ? adjustedLayoutPosition * yStep : (layoutSize.height * 0.5f + adjustedRowSpacing) + (adjustedLayoutPosition - 1.0f) * yStep;
- y += itemSize.y * 0.5f - layoutSize.height * 0.5f;
- }
-
- float z = adjustedLayoutPosition * (10.0f + scrollSpeedFactor);
- z -= std::min(3000.0f, scrollSpeedFactor * 2.0f);
-
-
- return Vector3(-(itemSize.x * 0.5f - layoutSize.x * 0.5f),
- -y,
- z);
- }
-
-public:
-
- float mRowSpacing;
- RollLayout::ItemSizeFunction mItemSizeFunction;
-};
-
-struct RollPositionConstraint270
-{
- RollPositionConstraint270(const float rowSpacing, RollLayout::ItemSizeFunction itemSizeFunction)
- : mRowSpacing(rowSpacing),
- mItemSizeFunction(itemSizeFunction)
- {
- }
-
- Vector3 operator()(const Vector3& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- Vector3 itemSize = mItemSizeFunction(layoutSize.height, layoutSize.width, mRowSpacing);
-
- float adjustedLayoutPosition = layoutPosition;
- float scrollSpeedFactor = scrollSpeed * scrollSpeed * scrollSpeed;
- float x = 0.0f;
-
- float adjustedRowSpacing = mRowSpacing + scrollSpeedFactor;
-
- if(adjustedLayoutPosition > Math::MACHINE_EPSILON_0 && adjustedLayoutPosition -2.0f < Math::MACHINE_EPSILON_0)
- {
- float adjustment = 1.0f - Dali::AlphaFunctions::EaseInOutSine60((2.0f - adjustedLayoutPosition) * 0.5f);
- adjustedLayoutPosition = adjustment * 2.0f;
- x = ((itemSize.y + adjustedRowSpacing ) * adjustedLayoutPosition) - layoutSize.width * 0.5f + itemSize.y * 0.5f;
- }
- else
- {
- float xStep = std::max(50.0f, std::min(itemSize.y, scrollSpeedFactor));
- x = adjustedLayoutPosition < Math::MACHINE_EPSILON_0 ? adjustedLayoutPosition * xStep : (layoutSize.width * 0.5f + adjustedRowSpacing) + (adjustedLayoutPosition - 1.0f) * xStep;
- x += itemSize.y * 0.5f - layoutSize.width * 0.5f;
- }
-
- float z = adjustedLayoutPosition * (10.0f + scrollSpeedFactor);
- z -= std::min(3000.0f, scrollSpeedFactor * 2.0f);
-
- return Vector3(-x,
- itemSize.x * 0.5f - layoutSize.y * 0.5f,
- z);
- }
-
-public:
-
- float mRowSpacing;
- RollLayout::ItemSizeFunction mItemSizeFunction;
-};
-
-struct RollRotationConstraint0
-{
- Quaternion operator()(const Quaternion& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- return Quaternion(0.0f, Vector3::ZAXIS);
- }
-};
-
-struct RollRotationConstraint90
-{
- Quaternion operator()(const Quaternion& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- return Quaternion(1.5f * Math::PI, Vector3::ZAXIS);
- }
-};
-
-struct RollRotationConstraint180
-{
- Quaternion operator()(const Quaternion& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- return Quaternion(Math::PI, Vector3::ZAXIS);
- }
-};
-
-struct RollRotationConstraint270
-{
- Quaternion operator()(const Quaternion& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- return Quaternion(0.5f * Math::PI, Vector3::ZAXIS);
- }
-};
-
-struct RollScaleConstraint
-{
- Vector3 operator()(const Vector3& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- float adjustedLayoutPosition = layoutPosition;
- float factor = 0.0f;
- if(adjustedLayoutPosition < Math::MACHINE_EPSILON_0)
- {
- factor = fabsf(adjustedLayoutPosition);
- }
- if(adjustedLayoutPosition - 1.0f > Math::MACHINE_EPSILON_0)
- {
- factor = adjustedLayoutPosition - 1.0f;
- }
-
- float scale = std::min(1.0f, std::max(0.1f, 1.0f - 0.1f * factor));
- if(scrollSpeed > 0.0f)
- {
- scale *= std::min(1.0f, std::max(0.1f, 1.0f / (scrollSpeed * 0.05f)));
- }
-
- return Vector3(scale, scale, scale);
- }
-};
-
-struct RollColorConstraint
-{
- Vector4 operator()(const Vector4& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- float adjustedLayoutPosition = layoutPosition;
-
- float factor = 0.0f;
- if(adjustedLayoutPosition < Math::MACHINE_EPSILON_0)
- {
- factor = fabsf(adjustedLayoutPosition);
- }
- if(adjustedLayoutPosition - 1.0f > Math::MACHINE_EPSILON_0)
- {
- factor = adjustedLayoutPosition - 1.0f;
- }
-
- float darkness = std::min(1.0f, std::max(0.5f, 1.0f - 0.5f * factor));
- float alpha = std::min(1.0f, std::max(0.0f, 1.0f - 0.9f * factor));
- return Vector4(darkness, darkness, darkness, alpha);
- }
-};
-
-struct RollVisibilityConstraintPortrait
-{
- RollVisibilityConstraintPortrait(const float rowSpacing, RollLayout::ItemSizeFunction itemSizeFunction)
- : mRowSpacing(rowSpacing),
- mItemSizeFunction(itemSizeFunction)
- {
- }
-
- bool operator()(const bool& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- Vector3 itemSize = mItemSizeFunction(layoutSize.width, layoutSize.height, mRowSpacing);
- int rowsPerPage = ceil(layoutSize.height / (itemSize.y + mRowSpacing));
- return (layoutPosition > -rowsPerPage) && (layoutPosition < rowsPerPage);
- }
-
-public:
-
- float mRowSpacing;
- RollLayout::ItemSizeFunction mItemSizeFunction;
-};
-
-struct RollVisibilityConstraintLandscape
-{
- RollVisibilityConstraintLandscape(const float rowSpacing, RollLayout::ItemSizeFunction itemSizeFunction)
- : mRowSpacing(rowSpacing),
- mItemSizeFunction(itemSizeFunction)
- {
- }
-
- bool operator()(const bool& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
- {
- Vector3 itemSize = mItemSizeFunction(layoutSize.height, layoutSize.width, mRowSpacing);
- int rowsPerPage = ceil(layoutSize.width / (itemSize.y + mRowSpacing));
- return (layoutPosition + 2.0f > Math::MACHINE_EPSILON_0) && (layoutPosition < rowsPerPage);
- }
-
-public:
-
- float mRowSpacing;
- RollLayout::ItemSizeFunction mItemSizeFunction;
-};
-
-} // unnamed namespace
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-struct RollLayout::Impl
-{
- Impl()
- : mRowSpacing(DEFAULT_ROW_SPACING),
- mScrollSpeedFactor(DEFAULT_SCROLL_SPEED_FACTOR),
- mMaximumSwipeSpeed(DEFAULT_MAXIMUM_SWIPE_SPEED),
- mItemFlickAnimationDuration(DEFAULT_ITEM_FLICK_ANIMATION_DURATION),
- mItemSizeFunction(GetItemSizeDefaultFunction)
- {
- mScaleConstraint = RollScaleConstraint();
- mColorConstraint = RollColorConstraint();
-
- mRotationConstraint[0] = RollRotationConstraint0();
- mRotationConstraint[1] = RollRotationConstraint90();
- mRotationConstraint[2] = RollRotationConstraint180();
- mRotationConstraint[3] = RollRotationConstraint270();
- }
-
- float mRowSpacing;
-
- float mScrollSpeedFactor;
- float mMaximumSwipeSpeed;
- float mItemFlickAnimationDuration;
-
- ItemLayout::QuaternionFunction mRotationConstraint[ORIENTATION_COUNT];
- ItemLayout::Vector3Function mScaleConstraint;
- ItemLayout::Vector4Function mColorConstraint;
-
- ItemSizeFunction mItemSizeFunction;
-};
-
-RollLayoutPtr RollLayout::New()
-{
- return RollLayoutPtr(new RollLayout());
-}
-
-RollLayout::~RollLayout()
-{
- delete mImpl;
-}
-
-void RollLayout::SetRowSpacing(float spacing)
-{
- mImpl->mRowSpacing = spacing;
-}
-
-float RollLayout::GetRowSpacing() const
-{
- return mImpl->mRowSpacing;
-}
-
-void RollLayout::SetItemSizeFunction(ItemSizeFunction function)
-{
- mImpl->mItemSizeFunction = function;
-}
-
-RollLayout::ItemSizeFunction RollLayout::GetItemSizeFunction() const
-{
- return mImpl->mItemSizeFunction;
-}
-
-void RollLayout::SetScrollSpeedFactor(float scrollSpeed)
-{
- mImpl->mScrollSpeedFactor = scrollSpeed;
-}
-
-void RollLayout::SetMaximumSwipeSpeed(float speed)
-{
- mImpl->mMaximumSwipeSpeed = speed;
-}
-
-void RollLayout::SetItemFlickAnimationDuration(float durationSeconds)
-{
- mImpl->mItemFlickAnimationDuration = durationSeconds;
-}
-
-float RollLayout::GetScrollSpeedFactor() const
-{
- return mImpl->mScrollSpeedFactor;
-}
-
-float RollLayout::GetMaximumSwipeSpeed() const
-{
- return mImpl->mMaximumSwipeSpeed;
-}
-
-float RollLayout::GetItemFlickAnimationDuration() const
-{
- return mImpl->mItemFlickAnimationDuration;
-}
-
-float RollLayout::GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const
-{
- return 2.0f - static_cast<float>(numberOfItems);
-}
-
-float RollLayout::GetClosestAnchorPosition(float layoutPosition) const
-{
- return static_cast<float>(round(layoutPosition));
-}
-
-float RollLayout::GetItemScrollToPosition(unsigned int itemId) const
-{
- return 0.0f - static_cast<float>(itemId);
-}
-
-ItemRange RollLayout::GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const
-{
- float layoutWidth = IsHorizontal(mOrientation) ? layoutSize.height : layoutSize.width;
- float layoutHeight = IsHorizontal(mOrientation) ? layoutSize.width : layoutSize.height;
-
- Vector3 itemSize = mImpl->mItemSizeFunction( layoutWidth,layoutHeight, mImpl->mRowSpacing);
-
- float itemsPerPage = (layoutHeight / (itemSize.y + mImpl->mRowSpacing));
- if(firstItemPosition + 0.001f >= Math::MACHINE_EPSILON_0)
- {
- itemsPerPage = std::max(0.0f, itemsPerPage - 1.0f);
- }
- int firstVisibleItem = -(static_cast<int>(firstItemPosition));
-
- int firstItemIndex = std::max(0, firstVisibleItem);
- int lastItemIndex = std::max(0, static_cast<int>(ceil(firstVisibleItem + itemsPerPage - 1)));
- return ItemRange(firstItemIndex, lastItemIndex);
-}
-
-unsigned int RollLayout::GetReserveItemCount(Vector3 layoutSize) const
-{
- float layoutWidth = IsHorizontal(mOrientation) ? layoutSize.height : layoutSize.width;
- float layoutHeight = IsHorizontal(mOrientation) ? layoutSize.width : layoutSize.height;
-
- Vector3 itemSize = mImpl->mItemSizeFunction(layoutWidth, layoutHeight, mImpl->mRowSpacing);
- int itemsPerPage = ceil(layoutHeight / (itemSize.y + mImpl->mRowSpacing));
- return itemsPerPage * 5;
-}
-
-bool RollLayout::GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const
-{
- // Note: itemId is not checked, since every item has the same size
- float layoutWidth = IsHorizontal(mOrientation) ? layoutSize.height : layoutSize.width;
- float layoutHeight = IsHorizontal(mOrientation) ? layoutSize.width : layoutSize.height;
-
- itemSize = mImpl->mItemSizeFunction(layoutWidth, layoutHeight, mImpl->mRowSpacing);
-
- return true;
-}
-
-void RollLayout::GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const
-{
- if(animation)
- {
- animation.Resize(actor, size);
- }
-}
-
-bool RollLayout::GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const
-{
- if (mOrientation == ControlOrientation::Up)
- {
- constraint = RollPositionConstraint0(mImpl->mRowSpacing, mImpl->mItemSizeFunction);
- }
- else if (mOrientation == ControlOrientation::Left)
- {
- constraint = RollPositionConstraint90(mImpl->mRowSpacing, mImpl->mItemSizeFunction);
- }
- else if (mOrientation == ControlOrientation::Down)
- {
- constraint = RollPositionConstraint180(mImpl->mRowSpacing, mImpl->mItemSizeFunction);
- }
- else // mOrientation == ControlOrientation::Right
- {
- constraint = RollPositionConstraint270(mImpl->mRowSpacing, mImpl->mItemSizeFunction);
- }
-
- return true;
-}
-
-bool RollLayout::GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const
-{
- constraint = mImpl->mRotationConstraint[mOrientation];
- return true;
-}
-
-bool RollLayout::GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const
-{
- constraint = mImpl->mScaleConstraint;
- return true;
-}
-
-bool RollLayout::GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const
-{
- constraint = mImpl->mColorConstraint;
- return true;
-}
-
-bool RollLayout::GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const
-{
- if (IsVertical(mOrientation))
- {
- constraint = RollVisibilityConstraintPortrait(mImpl->mRowSpacing, mImpl->mItemSizeFunction);
- }
- else // horizontal
- {
- constraint = RollVisibilityConstraintLandscape(mImpl->mRowSpacing, mImpl->mItemSizeFunction);
- }
-
- return true;
-}
-
-Degree RollLayout::GetScrollDirection() const
-{
- Degree scrollDirection(0.0f);
-
- if (mOrientation == ControlOrientation::Up)
- {
- scrollDirection = 0.0f;
- }
- else if (mOrientation == ControlOrientation::Left)
- {
- scrollDirection = 90.0f;
- }
- else if (mOrientation == ControlOrientation::Down)
- {
- scrollDirection = 180.0f;
- }
- else // mOrientation == ControlOrientation::Right
- {
- scrollDirection = 270.0f;
- }
-
- return scrollDirection;
-}
-
-RollLayout::RollLayout()
-: mImpl(NULL)
-{
- mImpl = new Impl();
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_ROLL_LAYOUT_H__
-#define __DALI_TOOLKIT_ROLL_LAYOUT_H__
-
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// INTERNAL INCLUDES
-
-#include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-class RollLayout;
-
-typedef IntrusivePtr<RollLayout> RollLayoutPtr;
-
-/**
- * An ItemView layout which arranges items in a roll.
- */
-class DALI_IMPORT_API RollLayout : public ItemLayout
-{
-public:
-
- typedef boost::function<Vector3 (float layoutWidth, float layoutHeight, float rowSpacing)> ItemSizeFunction;
-
- /**
- * Create a new roll layout
- */
- static RollLayoutPtr New();
-
- /**
- * Virtual destructor.
- */
- virtual ~RollLayout();
-
- /**
- * Set the spacing between rows.
- * @param[in] spacing The row spacing.
- */
- void SetRowSpacing(float spacing);
-
- /**
- * Get the spacing between rows.
- * @return The row spacing.
- */
- float GetRowSpacing() const;
-
- /**
- * Set the function used to calculate the item-size, for a given layout-size.
- * @param[in] function The item-size function.
- */
- void SetItemSizeFunction(ItemSizeFunction function);
-
- /**
- * Get the function used to calculate the item-size.
- * @return The item-size function.
- */
- ItemSizeFunction GetItemSizeFunction() const;
-
- /**
- * Set the factor used to customise the scroll speed while dragging and swiping the layout.
- * @param[in] scrollSpeed The scroll speed factor.
- */
- void SetScrollSpeedFactor(float scrollSpeed);
-
- /**
- * Set the maximum swipe speed in pixels per second.
- * @param[in] speed The maximum swipe speed.
- */
- void SetMaximumSwipeSpeed(float speed);
-
- /**
- * Set the duration of the flick animation in second. This is the time taken to animate each
- * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
- * by a swipe gesture.
- * @pre durationSeconds must be greater than zero.
- * @param[in] durationSeconds The duration of flick animation in seconds.
- */
- void SetItemFlickAnimationDuration(float durationSeconds);
-
- /**
- * @copydoc ItemLayout::GetScrollSpeedFactor()
- */
- virtual float GetScrollSpeedFactor() const;
-
- /**
- * @copydoc ItemLayout::GetMaximumSwipeSpeed()
- */
- virtual float GetMaximumSwipeSpeed() const;
-
- /**
- * @copydoc ItemLayout::GetItemFlickAnimationDuration()
- */
- virtual float GetItemFlickAnimationDuration() const;
-
-private:
-
- /**
- * @copydoc ItemLayout::GetMinimumLayoutPosition()
- */
- virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
-
- /**
- * @copydoc ItemLayout::GetClosestAnchorPosition()
- */
- virtual float GetClosestAnchorPosition(float layoutPosition) const;
-
- /**
- * @copydoc ItemLayout::GetItemScrollToPosition()
- */
- virtual float GetItemScrollToPosition(unsigned int itemId) const;
-
- /**
- * @copydoc ItemLayout::GetItemsWithinArea()
- */
- virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
-
- /**
- * @copydoc ItemLayout::GetReserveItemCount()
- */
- virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
-
- /**
- * @copydoc ItemLayout::GetItemSize()
- */
- virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
-
- /**
- * @copydoc ItemLayout::GetResizeAnimation()
- */
- virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
-
- /**
- * @copydoc ItemLayout::GetPositionConstraint()
- */
- virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
-
- /**
- * @copydoc ItemLayout::GetRotationConstraint()
- */
- virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
-
- /**
- * @copydoc ItemLayout::GetScaleConstraint()
- */
- virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
-
- /**
- * @copydoc ItemLayout::GetColorConstraint()
- */
- virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
-
- /**
- * @copydoc ItemLayout::GetVisibilityConstraint()
- */
- virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
-
- /**
- * @copydoc ItemLayout::GetScrollDirection()
- */
- virtual Degree GetScrollDirection() const;
-
-protected:
-
- /**
- * Protected constructor; see also RollLayout::New()
- */
- RollLayout();
-
-private:
-
- struct Impl;
- Impl* mImpl;
-};
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_ROLL_LAYOUT_H__
$(public_api_src_dir)/controls/scrollable/item-view/item-factory.cpp \
$(public_api_src_dir)/controls/scrollable/item-view/item-layout.cpp \
$(public_api_src_dir)/controls/scrollable/item-view/item-view.cpp \
- $(public_api_src_dir)/controls/scrollable/item-view/navigation-layout.cpp \
- $(public_api_src_dir)/controls/scrollable/item-view/roll-layout.cpp \
$(public_api_src_dir)/controls/scrollable/item-view/spiral-layout.cpp \
$(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-carousel-effect.cpp \
$(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-constraints.cpp \
$(public_api_src_dir)/controls/scrollable/item-view/item-layout.h \
$(public_api_src_dir)/controls/scrollable/item-view/item-view-declarations.h \
$(public_api_src_dir)/controls/scrollable/item-view/item-view.h \
- $(public_api_src_dir)/controls/scrollable/item-view/navigation-layout.h \
- $(public_api_src_dir)/controls/scrollable/item-view/roll-layout.h \
$(public_api_src_dir)/controls/scrollable/item-view/spiral-layout.h
public_api_magnifier_header_files = \