From: Kimmo Hoikka Date: Tue, 26 Jan 2016 15:38:18 +0000 (-0800) Subject: Merge "Updated programming guide for image-scaling-and-fitting" into devel/master X-Git-Tag: dali_1.1.19~6 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=2ecd7e13e0dbe45f59b5150abbf7924bf780f720;hp=62f4bf2995acd0c3a386975f4c38f95cbdd507e3 Merge "Updated programming guide for image-scaling-and-fitting" into devel/master --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp index 2c49895..2cbd51b 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp @@ -837,3 +837,92 @@ int UtcDaliItemViewLayoutActivatedSignalP(void) END_TEST; } + +int UtcDaliItemViewSetGetProperty(void) +{ + ToolkitTestApplication application; + + // Create the ItemView actor + TestItemFactory factory; + ItemView view = ItemView::New(factory); + DALI_TEST_CHECK(view); + + // Event side properties + + // Test "minimumSwipeSpeed" property + DALI_TEST_CHECK( view.GetPropertyIndex("minimumSwipeSpeed") == ItemView::Property::MINIMUM_SWIPE_SPEED ); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED).Get(), view.GetMinimumSwipeSpeed(), TEST_LOCATION ); + view.SetProperty( ItemView::Property::MINIMUM_SWIPE_SPEED, 2.5f ); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED).Get(), 2.5f, TEST_LOCATION ); + + // Test "minimumSwipeDistance" property + DALI_TEST_CHECK( view.GetPropertyIndex("minimumSwipeDistance") == ItemView::Property::MINIMUM_SWIPE_DISTANCE ); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE).Get(), view.GetMinimumSwipeDistance(), TEST_LOCATION ); + view.SetProperty( ItemView::Property::MINIMUM_SWIPE_DISTANCE, 8.725f ); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE).Get(), 8.725f, TEST_LOCATION ); + + // Test "wheelScrollDistanceStep" property + DALI_TEST_CHECK( view.GetPropertyIndex("wheelScrollDistanceStep") == ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP ); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get(), view.GetWheelScrollDistanceStep(), TEST_LOCATION ); + view.SetProperty( ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP, 5.0f ); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get(), 5.0f, TEST_LOCATION ); + + // Test "snapToItemEnabled" property + DALI_TEST_CHECK( view.GetPropertyIndex("snapToItemEnabled") == ItemView::Property::SNAP_TO_ITEM_ENABLED ); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED).Get(), view.GetAnchoring(), TEST_LOCATION ); + view.SetProperty( ItemView::Property::SNAP_TO_ITEM_ENABLED, true ); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED).Get(), true, TEST_LOCATION ); + + // Test "refreshInterval" property + DALI_TEST_CHECK( view.GetPropertyIndex("refreshInterval") == ItemView::Property::REFRESH_INTERVAL ); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get(), view.GetRefreshInterval(), TEST_LOCATION ); + view.SetProperty( ItemView::Property::REFRESH_INTERVAL, 11.0f ); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get(), 11.0f, TEST_LOCATION ); + + // Test "overshootEnabled" property + DALI_TEST_CHECK( view.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED ); + DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), view.IsOvershootEnabled(), TEST_LOCATION ); + view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false ); + DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), false, TEST_LOCATION ); + + // Animatable properties + + // Test "layoutPosition" property + DALI_TEST_CHECK( view.GetPropertyIndex("layoutPosition") == ItemView::Property::LAYOUT_POSITION ); + view.SetProperty( ItemView::Property::LAYOUT_POSITION, 20.5f ); + Wait(application); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::LAYOUT_POSITION).Get(), 20.5f, TEST_LOCATION ); + + // Test "scrollSpeed" property + DALI_TEST_CHECK( view.GetPropertyIndex("scrollSpeed") == ItemView::Property::SCROLL_SPEED ); + view.SetProperty( ItemView::Property::SCROLL_SPEED, 3.35f ); + Wait(application); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SCROLL_SPEED).Get(), 3.35f, TEST_LOCATION ); + + // Test "overshoot" property + DALI_TEST_CHECK( view.GetPropertyIndex("overshoot") == ItemView::Property::OVERSHOOT ); + view.SetProperty( ItemView::Property::OVERSHOOT, 0.15f ); + Wait(application); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::OVERSHOOT).Get(), 0.15f, TEST_LOCATION ); + + // Test "scrollDirection" property + DALI_TEST_CHECK( view.GetPropertyIndex("scrollDirection") == ItemView::Property::SCROLL_DIRECTION ); + view.SetProperty( ItemView::Property::SCROLL_DIRECTION, Vector2(0.85f, 0.5f) ); + Wait(application); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SCROLL_DIRECTION).Get(), Vector2(0.85f, 0.5f), TEST_LOCATION ); + + // Test "layoutOrientation" property + DALI_TEST_CHECK( view.GetPropertyIndex("layoutOrientation") == ItemView::Property::LAYOUT_ORIENTATION ); + view.SetProperty( ItemView::Property::LAYOUT_ORIENTATION, 2 ); + Wait(application); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::LAYOUT_ORIENTATION).Get(), 2, TEST_LOCATION ); + + // Test "scrollContentSize" property + DALI_TEST_CHECK( view.GetPropertyIndex("scrollContentSize") == ItemView::Property::SCROLL_CONTENT_SIZE ); + view.SetProperty( ItemView::Property::SCROLL_CONTENT_SIZE, 250.0f ); + Wait(application); + DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SCROLL_CONTENT_SIZE).Get(), 250.0f, TEST_LOCATION ); + + END_TEST; +} + diff --git a/automated-tests/src/dali-toolkit/utc-Dali-JsonParser.cpp b/automated-tests/src/dali-toolkit/utc-Dali-JsonParser.cpp index 1f2c667..1fafb16 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-JsonParser.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-JsonParser.cpp @@ -722,3 +722,37 @@ int UtcDaliJsonParserMethod11(void) tet_result(TET_PASS); END_TEST; } + + +int UtcDaliJsonParserMerge1(void) +{ + ToolkitTestApplication application; + tet_infoline("JSON tree merge"); + + std::string s1( ReplaceQuotes(" \ +{ \ + 'styles': \ + { \ + 'button': \ + { \ + 'backgroundColor':[0.8, 0.0, 1.0, 1.0], \ + 'foregroundColor':[1, 1, 1, 1] \ + } \ + } \ +} \ +")); + + JsonParser parser = JsonParser::New(); + JsonParser testParser = JsonParser::New(); + + testParser.Parse( s1 ); + + parser.Parse( s1 ); + parser.Parse( s1 ); // Merge the tree into itself. The value array should not grow. + + DALI_TEST_CHECK(parser.GetRoot()); + + CompareTrees( *parser.GetRoot(), *testParser.GetRoot() ); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp index 3f9879e..61fba59 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp @@ -2347,3 +2347,166 @@ int UtcDaliToolkitScrollViewGesturePageLimit(void) END_TEST; } + +int UtcDaliScrollViewSetGetProperty(void) +{ + ToolkitTestApplication application; + + // Create the ScrollView actor + ScrollView scrollView = ScrollView::New(); + DALI_TEST_CHECK(scrollView); + + // Event side properties + + // Test "wrapEnabled" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrapEnabled") == ScrollView::Property::WRAP_ENABLED ); + scrollView.SetProperty( ScrollView::Property::WRAP_ENABLED, true ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP_ENABLED).Get(), true, TEST_LOCATION ); + + // Test "panningEnabled" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED ); + scrollView.SetProperty( ScrollView::Property::PANNING_ENABLED, false ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING_ENABLED).Get(), false, TEST_LOCATION ); + + // Test "axisAutoLockEnabled" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED ); + scrollView.SetProperty( ScrollView::Property::AXIS_AUTO_LOCK_ENABLED, false ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED).Get(), false, TEST_LOCATION ); + + // Test "wheelScrollDistanceStep" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP ); + scrollView.SetProperty( ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP, Vector2(100.0f, 50.0f) ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get(), Vector2(100.0f, 50.0f), TEST_LOCATION ); + + // Test "overshootEnabled" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED ); + DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), scrollView.IsOvershootEnabled(), TEST_LOCATION ); + scrollView.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false ); + DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), false, TEST_LOCATION ); + + // Animatable properties + + // Test "scrollPosition" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION ); + scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION).Get(), Vector2(320.0f, 550.0f), TEST_LOCATION ); + + // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION ); + scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get(), Vector2(300.0f, 500.0f), TEST_LOCATION ); + + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X ); + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get(), 300.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get(), 500.0f, TEST_LOCATION ); + scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_X, 400.0f ); + scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_Y, 600.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get(), 400.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get(), 600.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get(), Vector2(400.0f, 600.0f), TEST_LOCATION ); + + // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX ); + scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get(), Vector2(100.0f, 200.0f), TEST_LOCATION ); + + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X ); + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get(), 100.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get(), 200.0f, TEST_LOCATION ); + scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, 300.0f ); + scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, 400.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get(), 300.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get(), 400.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get(), Vector2(300.0f, 400.0f), TEST_LOCATION ); + + // Test "overshootX" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootX") == ScrollView::Property::OVERSHOOT_X ); + scrollView.SetProperty( ScrollView::Property::OVERSHOOT_X, 0.8f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X).Get(), 0.8f, TEST_LOCATION ); + + // Test "overshootY" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootY") == ScrollView::Property::OVERSHOOT_Y ); + scrollView.SetProperty( ScrollView::Property::OVERSHOOT_Y, 0.8f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y).Get(), 0.8f, TEST_LOCATION ); + + // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinal") == ScrollView::Property::SCROLL_FINAL ); + scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get(), Vector2(200.0f, 300.0f), TEST_LOCATION ); + + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalX") == ScrollView::Property::SCROLL_FINAL_X ); + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalY") == ScrollView::Property::SCROLL_FINAL_Y ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get(), 200.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get(), 300.0f, TEST_LOCATION ); + scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_X, 500.0f ); + scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_Y, 600.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get(), 500.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get(), 600.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get(), Vector2(500.0f, 600.0f), TEST_LOCATION ); + + // Test "wrap" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrap") == ScrollView::Property::WRAP ); + scrollView.SetProperty( ScrollView::Property::WRAP, false ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP).Get(), false, TEST_LOCATION ); + + // Test "panning" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("panning") == ScrollView::Property::PANNING ); + scrollView.SetProperty( ScrollView::Property::PANNING, true ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING).Get(), true, TEST_LOCATION ); + + // Test "scrolling" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrolling") == ScrollView::Property::SCROLLING ); + scrollView.SetProperty( ScrollView::Property::SCROLLING, false ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLLING).Get(), false, TEST_LOCATION ); + + // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE ); + scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get(), Vector2(1200.0f, 1300.0f), TEST_LOCATION ); + + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X ); + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get(), 1200.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get(), 1300.0f, TEST_LOCATION ); + scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_X, 1500.0f ); + scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_Y, 1600.0f ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get(), 1500.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get(), 1600.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get(), Vector2(1500.0f, 1600.0f), TEST_LOCATION ); + + // Test "scrollDomainOffset" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET ); + scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET).Get(), Vector2(500.0f, 200.0f), TEST_LOCATION ); + + // Test "scrollPositionDelta" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA ); + scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION_DELTA, Vector2(10.0f, 30.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION_DELTA).Get(), Vector2(10.0f, 30.0f), TEST_LOCATION ); + + // Test "startPagePosition" property + DALI_TEST_CHECK( scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION ); + scrollView.SetProperty( ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f) ); + Wait(application); + DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::START_PAGE_POSITION).Get(), Vector3(50.0f, 100.0f, 20.0f), TEST_LOCATION ); + + END_TEST; +} diff --git a/dali-toolkit/internal/builder/builder-impl.cpp b/dali-toolkit/internal/builder/builder-impl.cpp index 1535eeb..de40d44 100644 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -1117,7 +1117,6 @@ void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::U parser.GetErrorDescription().c_str() ); DALI_ASSERT_ALWAYS(!"Cannot parse JSON"); - } else { @@ -1155,7 +1154,6 @@ void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::U } DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Cannot parse JSON"); - } void Builder::AddConstants( const Property::Map& map ) @@ -1359,9 +1357,9 @@ Builder::Builder() mParser = Dali::Toolkit::JsonParser::New(); Property::Map defaultDirs; - defaultDirs[ TOKEN_STRING(DALI_IMAGE_DIR) ] = DALI_IMAGE_DIR; - defaultDirs[ TOKEN_STRING(DALI_SOUND_DIR) ] = DALI_SOUND_DIR; - defaultDirs[ TOKEN_STRING(DALI_STYLE_DIR) ] = DALI_STYLE_DIR; + defaultDirs[ TOKEN_STRING(DALI_IMAGE_DIR) ] = DALI_IMAGE_DIR; + defaultDirs[ TOKEN_STRING(DALI_SOUND_DIR) ] = DALI_SOUND_DIR; + defaultDirs[ TOKEN_STRING(DALI_STYLE_DIR) ] = DALI_STYLE_DIR; defaultDirs[ TOKEN_STRING(DALI_STYLE_IMAGE_DIR) ] = DALI_STYLE_IMAGE_DIR; AddConstants( defaultDirs ); diff --git a/dali-toolkit/internal/builder/json-parser-state.cpp b/dali-toolkit/internal/builder/json-parser-state.cpp index afa9e59..3691838 100644 --- a/dali-toolkit/internal/builder/json-parser-state.cpp +++ b/dali-toolkit/internal/builder/json-parser-state.cpp @@ -318,8 +318,13 @@ TreeNode* JsonParserState::NewNode(const char* name, TreeNode::NodeType type) TreeNodeManipulator modify(node); modify.SetName(name); - // Set the type of the existing node, this may remove children where necessary - // (changing from container type to value type) + + // Set the type of the existing node. + // Where the new type is different, then any children of this node will + // be deleted. + // When the type is an array of numbers, then this will also remove any children + // When the type is an object or other array, then the children will not be removed, + // but will instead follow these replace rules. modify.SetType(type); mCurrent = modify; diff --git a/dali-toolkit/internal/builder/tree-node-manipulator.cpp b/dali-toolkit/internal/builder/tree-node-manipulator.cpp index 3e10edd..4357cb8 100644 --- a/dali-toolkit/internal/builder/tree-node-manipulator.cpp +++ b/dali-toolkit/internal/builder/tree-node-manipulator.cpp @@ -36,16 +36,37 @@ namespace Internal namespace { -void Indent(std::ostream& o, int indent) +void Indent(std::ostream& o, int level, int indentWidth) { - for (int i = 0; i < indent; ++i) + for (int i = 0; i < level*indentWidth; ++i) { o << " "; } } +std::string EscapeQuotes( const char* aString) +{ + std::string escapedString; + int length = strlen(aString); + escapedString.reserve(length); + + const char* end = aString+length; + for( const char* iter = aString; iter != end ; ++iter) + { + if(*iter != '\"') + { + escapedString.push_back(*iter); + } + else + { + escapedString.append("\\\""); + } + } + return escapedString; } +} // anonymous namespace + TreeNodeManipulator::TreeNodeManipulator(TreeNode* node) : mNode(node) { @@ -270,6 +291,19 @@ void TreeNodeManipulator::SetType( TreeNode::NodeType type) } } } + else if( TreeNode::ARRAY == mNode->mType ) + { + if( mNode->mFirstChild != NULL ) + { + TreeNode::NodeType type = mNode->mFirstChild->GetType(); + + if( TreeNode::FLOAT == type || TreeNode::INTEGER == type ) + { + // Arrays of numbers should be replaced, not appended to. + RemoveChildren(); + } + } + } } void TreeNodeManipulator::SetName( const char* name ) @@ -327,14 +361,17 @@ void TreeNodeManipulator::SetBoolean( bool b ) void TreeNodeManipulator::Write(std::ostream& output, int indent) const { DALI_ASSERT_DEBUG(mNode && "Operation on NULL JSON node"); - DoWrite(mNode, output, indent); + DoWrite(mNode, output, 0, indent, false); } -void TreeNodeManipulator::DoWrite(const TreeNode *value, std::ostream& output, int indent) const +void TreeNodeManipulator::DoWrite(const TreeNode *value, std::ostream& output, int level, int indentWidth, bool groupChildren) const { DALI_ASSERT_DEBUG(value && "Operation on NULL JSON node"); - Indent(output, indent); + if(!groupChildren) + { + Indent(output, level, indentWidth); + } if (value->GetName()) { @@ -348,9 +385,9 @@ void TreeNodeManipulator::DoWrite(const TreeNode *value, std::ostream& output, i output << "null"; if(NULL != value->mNextSibling) { - output << ","; + output << ", "; } - if(indent) + if( !groupChildren ) { output << std::endl; } @@ -359,58 +396,89 @@ void TreeNodeManipulator::DoWrite(const TreeNode *value, std::ostream& output, i case TreeNode::OBJECT: case TreeNode::ARRAY: { + bool groupMyChildren = false; + + if( TreeNode::ARRAY == value->GetType() && + ( TreeNode::INTEGER == value->mFirstChild->GetType() || + TreeNode::FLOAT == value->mFirstChild->GetType() ) ) + { + groupMyChildren = true; + } + if( value->GetType() == TreeNode::OBJECT) { + output << std::endl; + Indent(output, level, indentWidth); output << "{"; - if(indent) - { - output << std::endl; - } } else { - output << "["; - if(indent) + if( !groupMyChildren ) { output << std::endl; + Indent(output, level, indentWidth); } + output << "["; + } + + if( groupMyChildren ) + { + output << " "; + } + else + { + output << std::endl; } for (TreeNode::ConstIterator it = value->CBegin(); it != value->CEnd(); ++it) { - DoWrite( &((*it).second), output, indent + 1); + DoWrite( &((*it).second), output, level+1, indentWidth, groupMyChildren ); } - Indent(output, indent); + + if( !groupMyChildren ) + { + Indent(output, level, indentWidth); + } + if( value->GetType() == TreeNode::OBJECT ) { output << "}"; - if(indent) - { - output << std::endl; - } } else { output << "]"; - if(indent) - { - output << std::endl; - } } + + if( NULL != value->mNextSibling ) + { + output << ","; + } + + if( !groupChildren ) + { + output << std::endl; + } + + groupChildren = false; break; } case TreeNode::STRING: { - output << "\"" << value->GetString() << "\""; + std::string escapedString = EscapeQuotes(value->GetString()); + output << "\"" << escapedString << "\""; if(NULL != value->mNextSibling) { output << ","; } - if(indent) + + if( groupChildren ) + { + output << " "; + } + else { output << std::endl; } - break; } case TreeNode::INTEGER: @@ -420,11 +488,15 @@ void TreeNodeManipulator::DoWrite(const TreeNode *value, std::ostream& output, i { output << ","; } - if(indent) + + if( groupChildren ) + { + output << " "; + } + else { output << std::endl; } - break; } case TreeNode::FLOAT: @@ -436,7 +508,12 @@ void TreeNodeManipulator::DoWrite(const TreeNode *value, std::ostream& output, i { output << ","; } - if(indent) + + if( groupChildren ) + { + output << " "; + } + else { output << std::endl; } @@ -452,11 +529,17 @@ void TreeNodeManipulator::DoWrite(const TreeNode *value, std::ostream& output, i { output << "false"; } + if(NULL != value->mNextSibling) { output << ","; } - if(indent) + + if( groupChildren ) + { + output << " "; + } + else { output << std::endl; } @@ -520,4 +603,3 @@ char *CopyString( const char *fromString, VectorCharIter& iter, const VectorChar } // namespace Toolkit } // namespace Dali - diff --git a/dali-toolkit/internal/builder/tree-node-manipulator.h b/dali-toolkit/internal/builder/tree-node-manipulator.h index 838c2cb..f900350 100644 --- a/dali-toolkit/internal/builder/tree-node-manipulator.h +++ b/dali-toolkit/internal/builder/tree-node-manipulator.h @@ -191,7 +191,7 @@ private: /* * Do write to string stream */ - void DoWrite(const TreeNode *value, std::ostream& output, int ident) const; + void DoWrite(const TreeNode *value, std::ostream& output, int level, int ident, bool groupChildren) const; }; diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp index 86a869e..9403c8a 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -247,7 +247,7 @@ DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ItemView, Toolkit::Scrollable, NULL) DALI_PROPERTY_REGISTRATION( Toolkit, ItemView, "minimumSwipeSpeed", FLOAT, MINIMUM_SWIPE_SPEED ) DALI_PROPERTY_REGISTRATION( Toolkit, ItemView, "minimumSwipeDistance", FLOAT, MINIMUM_SWIPE_DISTANCE ) -DALI_PROPERTY_REGISTRATION( Toolkit, ItemView, "wheelScrollDistanceStep", FLOAT, WHELL_SCROLL_DISTANCE_SPEED ) +DALI_PROPERTY_REGISTRATION( Toolkit, ItemView, "wheelScrollDistanceStep", FLOAT, WHEEL_SCROLL_DISTANCE_STEP ) DALI_PROPERTY_REGISTRATION( Toolkit, ItemView, "snapToItemEnabled", BOOLEAN, SNAP_TO_ITEM_ENABLED ) DALI_PROPERTY_REGISTRATION( Toolkit, ItemView, "refreshInterval", FLOAT, REFRESH_INTERVAL ) @@ -1717,7 +1717,7 @@ void ItemView::SetProperty( BaseObject* object, Property::Index index, const Pro itemViewImpl.SetMinimumSwipeDistance( value.Get() ); break; } - case Toolkit::ItemView::Property::WHELL_SCROLL_DISTANCE_SPEED: + case Toolkit::ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP: { itemViewImpl.SetWheelScrollDistanceStep( value.Get() ); break; @@ -1757,7 +1757,7 @@ Property::Value ItemView::GetProperty( BaseObject* object, Property::Index index value = itemViewImpl.GetMinimumSwipeDistance(); break; } - case Toolkit::ItemView::Property::WHELL_SCROLL_DISTANCE_SPEED: + case Toolkit::ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP: { value = itemViewImpl.GetWheelScrollDistanceStep(); break; diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp index c19b920..61388ac 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp @@ -355,7 +355,8 @@ void TextSelectionPopup::RaiseAbove( Layer target ) void TextSelectionPopup::ShowPopup() { - if ( !mPopupShowing || mButtonsChanged ) + if( ( !mPopupShowing || mButtonsChanged ) && + ( Toolkit::TextSelectionPopup::NONE != mEnabledButtons ) ) { Actor self = Self(); AddPopupOptionsToToolbar( mShowIcons, mShowCaptions ); diff --git a/dali-toolkit/internal/styling/style-manager-impl.cpp b/dali-toolkit/internal/styling/style-manager-impl.cpp index 2861611..85aa069 100644 --- a/dali-toolkit/internal/styling/style-manager-impl.cpp +++ b/dali-toolkit/internal/styling/style-manager-impl.cpp @@ -101,7 +101,6 @@ StyleManager::StyleManager() : mOrientationDegrees( 0 ), // Portrait mDefaultFontSize( -1 ), mDefaultFontFamily(""), - mThemeFile( DEFAULT_THEME ), mFeedbackStyle( NULL ) { // Add theme builder constants @@ -117,7 +116,6 @@ StyleManager::StyleManager() // Sound & haptic style mFeedbackStyle = new FeedbackStyle(); - } StyleManager::~StyleManager() @@ -132,7 +130,7 @@ void StyleManager::SetOrientationValue( int orientation ) mOrientationDegrees = orientation; // TODO: if orientation changed, apply the new style to all controls // dont want to really do the whole load from file again if the bundle contains both portrait & landscape - SetTheme(); + SetTheme( mThemeFile ); } } @@ -156,14 +154,14 @@ void StyleManager::SetOrientation( Orientation orientation ) } } -std::string StyleManager::GetDefaultFontFamily() const +Orientation StyleManager::GetOrientation() { - return mDefaultFontFamily; + return mOrientation; } -Orientation StyleManager::GetOrientation() +std::string StyleManager::GetDefaultFontFamily() const { - return mOrientation; + return mDefaultFontFamily; } void StyleManager::SetStyleConstant( const std::string& key, const Property::Value& value ) @@ -183,12 +181,120 @@ bool StyleManager::GetStyleConstant( const std::string& key, Property::Value& va return false; } -void StyleManager::OnOrientationChanged( Orientation orientation ) +void StyleManager::RequestThemeChange( const std::string& themeFile ) { - mOrientation = orientation; - // TODO: if orientation changed, apply the new style to all controls - // dont want to really do the whole load from file again if the bundle contains both portrait & landscape - SetTheme(); + SetTheme( themeFile ); +} + +void StyleManager::RequestDefaultTheme() +{ + std::string empty; + SetTheme( empty ); +} + +void StyleManager::ApplyThemeStyle( Toolkit::Control control ) +{ + if( !mThemeBuilder ) + { + RequestDefaultTheme(); + } + + if( mThemeBuilder ) + { + ApplyStyle( mThemeBuilder, control ); + } +} + +void StyleManager::ApplyThemeStyleAtInit( Toolkit::Control control ) +{ + ApplyThemeStyle( control ); + + if(mFeedbackStyle) + { + mFeedbackStyle->ObjectCreated( control ); + } +} + +void StyleManager::ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName ) +{ + bool builderReady = false; + + // First look in the cache + Toolkit::Builder builder = FindCachedBuilder( jsonFileName ); + if( builder ) + { + builderReady = true; + } + else + { + // Merge theme and style constants + Property::Map constants( mThemeBuilderConstants ); + constants.Merge( mStyleBuilderConstants ); + + // Create it + builder = CreateBuilder( constants ); + + if( LoadJSON( builder, jsonFileName ) ) + { + CacheBuilder( builder, jsonFileName ); + builderReady = true; + } + } + + // Apply the style to the control + if( builderReady ) + { + builder.ApplyStyle( styleName, control ); + } +} + +Toolkit::StyleManager::StyleChangeSignalType& StyleManager::StyleChangeSignal() +{ + return mStyleChangeSignal; +} + +void StyleManager::SetTheme( const std::string& themeFile ) +{ + bool themeLoaded = false; + + mThemeBuilder = CreateBuilder( mThemeBuilderConstants ); + + // Always load the default theme first, then merge in the custom theme if present + themeLoaded = LoadJSON( mThemeBuilder, DEFAULT_THEME ); + + if( ! themeFile.empty() ) + { + mThemeFile = themeFile; + themeLoaded = LoadJSON( mThemeBuilder, mThemeFile ); + } + + if( themeLoaded ) + { + if(mFeedbackStyle) + { + mFeedbackStyle->StyleChanged( mThemeFile, StyleChange::THEME_CHANGE ); + } + + mStyleChangeSignal.Emit( Toolkit::StyleManager::Get(), StyleChange::THEME_CHANGE ); + } + else + { + mThemeBuilder.Reset(); + } +} + +bool StyleManager::LoadFile( const std::string& filename, std::string& stringOut ) +{ + DALI_ASSERT_DEBUG( 0 != filename.length()); + + // as toolkit is platform agnostic, it cannot load files from filesystem + // ask style monitor to load the style sheet + if( mStyleMonitor ) + { + return mStyleMonitor.LoadThemeFile( filename, stringOut ); + } + + return false; } Toolkit::Builder StyleManager::CreateBuilder( const Property::Map& constants ) @@ -294,112 +400,14 @@ void StyleManager::ApplyStyle( Toolkit::Builder builder, Toolkit::Control contro } } -void StyleManager::ApplyThemeStyle( Toolkit::Control control ) -{ - if( !mThemeBuilder ) - { - RequestDefaultTheme(); - } - - if( mThemeBuilder ) - { - ApplyStyle( mThemeBuilder, control ); - } -} - -void StyleManager::ApplyThemeStyleAtInit( Toolkit::Control control ) -{ - ApplyThemeStyle( control ); - - if(mFeedbackStyle) - { - mFeedbackStyle->ObjectCreated( control ); - } -} - -void StyleManager::ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName ) -{ - bool builderReady = false; - - // First look in the cache - Toolkit::Builder builder = FindCachedBuilder( jsonFileName ); - if( builder ) - { - builderReady = true; - } - else - { - // Merge theme and style constants - Property::Map constants( mThemeBuilderConstants ); - constants.Merge( mStyleBuilderConstants ); - - // Create it - builder = CreateBuilder( constants ); - - if( LoadJSON( builder, jsonFileName ) ) - { - CacheBuilder( builder, jsonFileName ); - builderReady = true; - } - } - - // Apply the style to the control - if( builderReady ) - { - builder.ApplyStyle( styleName, control ); - } -} - -bool StyleManager::LoadFile( const std::string& filename, std::string& stringOut ) -{ - DALI_ASSERT_DEBUG( 0 != filename.length()); - - // as toolkit is platform agnostic, it cannot load files from filesystem - // ask style monitor to load the style sheet - if( mStyleMonitor ) - { - return mStyleMonitor.LoadThemeFile( filename, stringOut ); - } - - return false; -} - -Toolkit::StyleManager::StyleChangeSignalType& StyleManager::StyleChangeSignal() -{ - return mStyleChangeSignal; -} - -void StyleManager::RequestThemeChange( const std::string& themeFile ) -{ - mThemeFile = themeFile; - - // need to do style change synchronously as app might create a UI control on the next line - SetTheme(); -} - -void StyleManager::RequestDefaultTheme() +void StyleManager::OnOrientationChanged( Orientation orientation ) { - RequestThemeChange( DEFAULT_THEME ); + mOrientation = orientation; + // TODO: if orientation changed, apply the new style to all controls + // dont want to really do the whole load from file again if the bundle contains both portrait & landscape + SetTheme( mThemeFile ); } -void StyleManager::SetTheme() -{ - mThemeBuilder = CreateBuilder( mThemeBuilderConstants ); - - if( LoadJSON( mThemeBuilder, mThemeFile ) ) - { - if(mFeedbackStyle) - { - mFeedbackStyle->StyleChanged( mThemeFile, StyleChange::THEME_CHANGE ); - } - - mStyleChangeSignal.Emit( Toolkit::StyleManager::Get(), StyleChange::THEME_CHANGE ); - } - else - { - mThemeBuilder.Reset(); - } -} Toolkit::Builder StyleManager::FindCachedBuilder( const std::string& key ) { @@ -435,17 +443,7 @@ void StyleManager::StyleMonitorChange( StyleMonitor styleMonitor, StyleChange::T case StyleChange::THEME_CHANGE: { - const std::string& newTheme = styleMonitor.GetTheme(); - if( ! newTheme.empty() ) - { - mThemeFile = newTheme; - } - else - { - mThemeFile = DEFAULT_THEME; - } - - SetTheme(); + SetTheme( styleMonitor.GetTheme() ); break; } } diff --git a/dali-toolkit/internal/styling/style-manager-impl.h b/dali-toolkit/internal/styling/style-manager-impl.h index ab5e24d..294e601 100644 --- a/dali-toolkit/internal/styling/style-manager-impl.h +++ b/dali-toolkit/internal/styling/style-manager-impl.h @@ -47,7 +47,6 @@ class FeedbackStyle; class StyleManager : public Dali::BaseObject, public ConnectionTracker { public: - /** * Singleton access * @@ -60,6 +59,14 @@ public: */ StyleManager(); +protected: + /** + * @brief Destructor + */ + virtual ~StyleManager(); + +public: // Public API + /** * @copydoc Toolkit::StyleManager::SetOrientationValue */ @@ -106,12 +113,6 @@ public: void RequestDefaultTheme(); /** - * Determine if a theme change has been requested - * @return Whether a theme request is pending - */ - bool IsThemeRequestPending(); - - /** * @brief Apply the theme style to a control. * * @param[in] control The control to apply style. @@ -138,24 +139,14 @@ public: */ Toolkit::StyleManager::StyleChangeSignalType& StyleChangeSignal(); -protected: - - /** - * @brief Destructor - */ - virtual ~StyleManager(); - - -public: +private: + typedef std::vector StringList; /** * @brief Set the current theme. Called only once per event processing cycle. + * @param[in] themeFile The name of the theme file to read. */ - void SetTheme(); - -private: - - typedef std::vector StringList; + void SetTheme( const std::string& themeFile ); /** * @brief Internal helper method to read a file from file system. @@ -258,9 +249,7 @@ private: int mOrientationDegrees; ///< Directly set value of orientation int mDefaultFontSize; ///< Logical size, not a point-size - std::string mDefaultFontFamily; - std::string mThemeFile; ///< The full path of the current theme file Property::Map mThemeBuilderConstants; ///< Contants to give the theme builder @@ -299,4 +288,3 @@ inline const Internal::StyleManager& GetImpl( const Dali::Toolkit::StyleManager& } // namespace Dali #endif // __DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H__ - diff --git a/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h b/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h index 5431d25..0bb0d1b 100644 --- a/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h +++ b/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h @@ -80,7 +80,7 @@ public: // Event side properties MINIMUM_SWIPE_SPEED = PROPERTY_START_INDEX, ///< Property, name "minimumSwipeSpeed", @see SetMinimumSwipeSpeed(), type float, @since DALi 1.1.18 MINIMUM_SWIPE_DISTANCE, ///< Property, name "minimumSwipeDistance", @see SetMinimumSwipeDistance(), type float, @since DALi 1.1.18 - WHELL_SCROLL_DISTANCE_SPEED, ///< Property, name "wheelScrollDistanceStep", @see SetWheelScrollDistanceStep(), type float, @since DALi 1.1.18 + WHEEL_SCROLL_DISTANCE_STEP, ///< Property, name "wheelScrollDistanceStep", @see SetWheelScrollDistanceStep(), type float, @since DALi 1.1.18 SNAP_TO_ITEM_ENABLED, ///< Property, name "snapToItemEnabled", @see SetAnchoring(), type bool, @since DALi 1.1.18 REFRESH_INTERVAL, ///< Property, name "refreshInterval", @see SetRefreshInterval(), type float, @since DALi 1.1.18 diff --git a/dali-toolkit/public-api/controls/scrollable/scrollable.h b/dali-toolkit/public-api/controls/scrollable/scrollable.h index 3c22468..c14f203 100644 --- a/dali-toolkit/public-api/controls/scrollable/scrollable.h +++ b/dali-toolkit/public-api/controls/scrollable/scrollable.h @@ -58,8 +58,8 @@ public: */ enum PropertyRange { - PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @since DALi 1.1.18 - PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, ///< Reserve property indices, @since DALi 1.1.18 + PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, + PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, ///< Reserve property indices ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX, ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000 ///< Reserve animatable property indices diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index f8d7918..afebe0a 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -31,7 +31,7 @@ namespace Toolkit const unsigned int TOOLKIT_MAJOR_VERSION = 1; const unsigned int TOOLKIT_MINOR_VERSION = 1; -const unsigned int TOOLKIT_MICRO_VERSION = 17; +const unsigned int TOOLKIT_MICRO_VERSION = 18; const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED @@ -42,7 +42,7 @@ struct PrintVersion { PrintVersion() { - std::cout << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << " (" << TOOLKIT_BUILD_DATE << ")" << std::endl; + std::cerr << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << " (" << TOOLKIT_BUILD_DATE << ")" << std::endl; } }; PrintVersion TOOLKIT_VERSION; diff --git a/dali-toolkit/styles/480x800/dali-toolkit-default-theme.json b/dali-toolkit/styles/480x800/dali-toolkit-default-theme.json index 3717470..ab9c802 100644 --- a/dali-toolkit/styles/480x800/dali-toolkit-default-theme.json +++ b/dali-toolkit/styles/480x800/dali-toolkit-default-theme.json @@ -142,6 +142,14 @@ distributing this software or its derivatives. "grabHandleImage" : "{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png", "selectionHandleImageLeft" : {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png" }, "selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" } + }, + "popup": + { + "popupBackgroundImage":"{DALI_IMAGE_DIR}00_popup_bg.9.png" + }, + "confirmationpopup": + { + "popupBackgroundImage":"{DALI_IMAGE_DIR}00_popup_bg.9.png" } } } diff --git a/docs/content/images/scroll-view/scroll-view.png b/docs/content/images/scroll-view/scroll-view.png new file mode 100755 index 0000000..fe2d409 Binary files /dev/null and b/docs/content/images/scroll-view/scroll-view.png differ diff --git a/node-addon/binding.gyp b/node-addon/binding.gyp index 142cc74..ac3b428 100644 --- a/node-addon/binding.gyp +++ b/node-addon/binding.gyp @@ -21,6 +21,7 @@ '<(DALI_JS_DIR)/controls/control-wrapper.cpp', '<(DALI_JS_DIR)/controls/item-factory-wrapper.cpp', '<(DALI_JS_DIR)/controls/item-view-api.cpp', + '<(DALI_JS_DIR)/controls/scroll-view-api.cpp', '<(DALI_JS_DIR)/animation/animation-api.cpp', '<(DALI_JS_DIR)/animation/animation-wrapper.cpp', '<(DALI_JS_DIR)/animation/constrainer-api.cpp', diff --git a/node-addon/build/tizen/CMakeLists.txt b/node-addon/build/tizen/CMakeLists.txt index f76d25a..d29846dd 100644 --- a/node-addon/build/tizen/CMakeLists.txt +++ b/node-addon/build/tizen/CMakeLists.txt @@ -56,6 +56,10 @@ add_library(dali_addon SHARED ${PLUGING_SRC_DIR}/actors/actor-api.cpp ${PLUGING_SRC_DIR}/actors/layer-api.cpp ${PLUGING_SRC_DIR}/actors/camera-actor-api.cpp + ${PLUGING_SRC_DIR}/controls/control-wrapper.cpp + ${PLUGING_SRC_DIR}/controls/item-factory-wrapper.cpp + ${PLUGING_SRC_DIR}/controls/item-view-api.cpp + ${PLUGING_SRC_DIR}/controls/scroll-view-api.cpp ${PLUGING_SRC_DIR}/constants/constants-wrapper.cpp ${PLUGING_SRC_DIR}/animation/animation-api.cpp ${PLUGING_SRC_DIR}/animation/animation-wrapper.cpp diff --git a/node-addon/examples/scroll-view.js b/node-addon/examples/scroll-view.js new file mode 100644 index 0000000..d0cf3e5 --- /dev/null +++ b/node-addon/examples/scroll-view.js @@ -0,0 +1,130 @@ + var window= { + x:0, + y:0, + width:1920, + height:1080, + transparent: false, + name:'scrollview-example' + }; + + var viewMode={ + 'stereoscopic-mode':'mono', // stereo-horizontal, stereo-vertical, stereo-interlaced, + 'stereoBase': 65 // Distance in millimeters between left/right cameras typically between (50-70mm) + }; + + var options= { + 'window': window, + 'viewMode': viewMode, + } + +//desktop +//var dali = require('../build/Release/dali')( options ); + +//target +var dali = require('dali')( options ); + +var stageSize; +var scrollView; +var scrollBar; + +var imageDir = "./images/"; + +var daliApp = {}; + +daliApp.createScrollView = function() { + + // Create a scroll view + scrollView = new dali.Control("ScrollView"); + stageSize = dali.stage.getSize(); + scrollView.size = [stageSize.x, stageSize.y, 0.0]; + scrollView.parentOrigin = dali.CENTER; + scrollView.anchorPoint = dali.CENTER; + + dali.stage.add( scrollView ); + + // Add actors to a scroll view with 4 pages + var pageRows = 1; + var pageColumns = 3; + for(var pageRow = 0; pageRow < pageRows; pageRow++) + { + for(var pageColumn = 0; pageColumn < pageColumns; pageColumn++) + { + var pageActor = new dali.Control(); + pageActor.widthResizePolicy = "FILL_TO_PARENT"; + pageActor.heightResizePolicy = "FILL_TO_PARENT"; + pageActor.parentOrigin = dali.CENTER; + pageActor.anchorPoint = dali.CENTER; + pageActor.position = [pageColumn * stageSize.x, pageRow * stageSize.y, 0.0]; + pageActor.name = "pageActor" + pageColumn; + + // Add images in a 5x4 grid layout for each page + var imageRows = 4; + var imageColumns = 5; + var margin = 10.0; + var imageSize = [(stageSize.x / imageColumns) - margin, (stageSize.y / imageRows) - margin, 0.0]; + + for(var row = 0; row < imageRows; row++) + { + for(var column = 0; column < imageColumns;column++) + { + var imageView = new dali.Control("ImageView"); + var imageId = (row * imageColumns + column) % 2 + 1; + imageView.image = imageDir + "image-" + imageId + ".jpg"; + imageView.parentOrigin = dali.CENTER; + imageView.anchorPoint = dali.CENTER; + imageView.size = imageSize; + imageView.position = [ margin * 0.5 + (imageSize[0] + margin) * column - stageSize.x * 0.5 + imageSize[0] * 0.5, + margin * 0.5 + (imageSize[1] + margin) * row - stageSize.y * 0.5 + imageSize[1] * 0.5, + 0.0 ]; + pageActor.add(imageView); + var position = imageView.position; + } + } + + scrollView.add( pageActor ); + } + } + + // Set scroll view to have 3 pages in X axis and allow page snapping, + // and also disable scrolling in Y axis. + var scrollMode = { + xAxisScrollEnabled : true, + xAxisSnapToInterval : stageSize.x, // Define the snap points + xAxisScrollBoundary : stageSize.x * pageColumns, // i.e. Define 3 pages + yAxisScrollEnabled : false + } + + scrollView.setScrollMode(scrollMode); + + // Create a horizontal scroll bar in the bottom of scroll view (optional) + scrollBar = new dali.Control("ScrollBar"); + scrollBar.parentOrigin = dali.BOTTOM_LEFT; + scrollBar.anchorPoint = dali.TOP_LEFT; + scrollBar.widthResizePolicy = "FIT_TO_CHILDREN"; + scrollBar.heightResizePolicy = "FILL_TO_PARENT"; + scrollBar.orientation = [0, 0, 270]; + scrollBar.scrollDirection = "Horizontal"; + scrollView.add(scrollBar); + + // Connect to the onRelayout signal + scrollView.on("onRelayout", daliApp.onScrollViewRelayout); +} + +daliApp.onScrollViewRelayout = function( button ) { + + // Set the correct scroll bar size after size negotiation of scroll view is done + scrollBar.size = [0.0, scrollView.getRelayoutSize(dali.DIMENSION_WIDTH), 0.0 ]; +} + +function startup() +{ + daliApp.init(); +} + +daliApp.init = function() +{ + daliApp.createScrollView(); +} + +startup(); + diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index c8057f7..d326e26 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali-toolkit Summary: The OpenGLES Canvas Core Library Toolkit -Version: 1.1.17 +Version: 1.1.18 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-2-Clause and MIT diff --git a/plugins/dali-script-v8/docs/content/actor.js b/plugins/dali-script-v8/docs/content/actor.js index 98b35a4..9b4b4ff 100644 --- a/plugins/dali-script-v8/docs/content/actor.js +++ b/plugins/dali-script-v8/docs/content/actor.js @@ -118,7 +118,7 @@ function OnPressed( actor, touchEvent ) var anim = new dali.Animation( 4 ); var rotation = new dali.Rotation( 90, 0, 0 ); // pitch, yaw, roll - anim.animateBy( actor, "rotation", rotation ); + anim.animateBy( actor, "orientation", rotation ); anim.play(); return true; } @@ -195,8 +195,8 @@ See worldPositionX |FLOAT | ✘ | ✘ worldPositionY |FLOAT | ✘ | ✘ worldPositionZ |FLOAT | ✘ | ✘ - rotation |ROTATION | ✔ | ✔ - worldRotation |ROTATION | ✘ | ✘ + orientation |ROTATION | ✔ | ✔ + worldOrientation |ROTATION | ✘ | ✘ scale |VECTOR3 | ✔ | ✔ scaleX |FLOAT | ✔ | ✔ scaleY |FLOAT | ✔ | ✔ @@ -213,7 +213,7 @@ See name |STRING | ✔ | ✘ sensitive |BOOLEAN | ✔ | ✘ leaveRequired |BOOLEAN | ✔ | ✘ - inheritRotation |BOOLEAN | ✔ | ✘ + inheritOrientation |BOOLEAN | ✔ | ✘ inheritScale |BOOLEAN | ✔ | ✘ colorMode |NUMBER | ✔ | ✘ positionInheritance |NUMBER | ✔ | ✘ @@ -381,19 +381,19 @@ WORLD_POSITION_Z /** - * Actors rotation - * @property rotation + * Actors orientation + * @property orientation * @type dali Rotation object */ -ROTATION +ORIENTATION /** - * Actors world-rotation - * @property worldRotation + * Actors world-orientation + * @property worldOrientation * @type dali Rotation object ( read only) */ -WORLD_ROTATION +WORLD_ORIENTATION /** * Actors scale @@ -521,10 +521,10 @@ LEAVE_REQUIRED /** * Set whether a child actor inherits it's parent's orientation. * @type Boolean - * @property inheritRotation + * @property inheritOrientation * @default true */ -INHERIT_ROTATION, +INHERIT_ORIENTATION, /** diff --git a/plugins/dali-script-v8/docs/content/animation.js b/plugins/dali-script-v8/docs/content/animation.js index 54ba7c3..43d0f02 100644 --- a/plugins/dali-script-v8/docs/content/animation.js +++ b/plugins/dali-script-v8/docs/content/animation.js @@ -78,7 +78,7 @@ function createAnimation() { var anim = new dali.Animation(1); // default duration is increased if length of all animations is greater than it. var animOptions = { - alpha: "linear", + alpha: dali.ALPHA_FUNCTION_LINEAR, delay: 0.5, // used to delay the start of the animation duration: 3, // duration of the animation }; @@ -89,16 +89,16 @@ function createAnimation() { // rotate back to correct orientation var endRotation = new dali.Rotation(0,0,0); - animOptions.alpha = "easeInOutSine"; + animOptions.alpha = dali.ALPHA_FUNCTION_EASE_IN_OUT_SINE; anim.animateTo(myActor1, "orientation", endRotation, animOptions); // Delay the myActor2 by a second animOptions.delay = 0.0; - animOptions.alpha = "linear"; + animOptions.alpha = dali.ALPHA_FUNCTION_LINEAR; anim.animateTo(myActor2, "positionZ", 0, animOptions); // rotate back to correct orientation - animOptions.alpha = "easeInOutSine"; + animOptions.alpha = dali.ALPHA_FUNCTION_EASE_IN_OUT_SINE; anim.animateTo(myActor2, "orientation", endRotation, animOptions); return anim; @@ -171,7 +171,7 @@ createShaderAnimation = function( imageView, color, zoom, duration, delay ) var shaderAnim = new dali.Animation(duration+delay); var animOptions = { - alpha: "doubleEaseInOutSine60", + alpha: dali.ALPHA_FUNCTION_EASE_IN_OUT_SINE, delay: delay, duration: duration, }; @@ -214,7 +214,7 @@ var shaderAnim = createShaderAnimation( imageView, color,zoom, duration, delay); // also rotate the imageView 90 degrees at the same time. var rotation = new dali.Rotation(90,0,0,1); -shaderAnim.animateTo(imageView, "orientation", rotation, { alpha:"linear", duration:duration, delay:delay }); +shaderAnim.animateTo(imageView, "orientation", rotation, { alpha:dali.ALPHA_FUNCTION_LINEAR, duration:duration, delay:delay }); shaderAnim.play(); @@ -224,36 +224,22 @@ shaderAnim.play(); ### Animation alpha functions -| Name | Description | -|--------------------|--------------| -|default |Linear | -|linear |Linear | -|square |Square (x^2) | -|reverse |Reverse linear | -|easeIn |Speeds up and comes to a sudden stop | -|easeOut |Sudden start and slows to a gradual stop| -|easeInOut |Speeds up and slows to a gradual stop| -|easeInSine |Speeds up and comes to a sudden stop| -|easeOutSine |Sudden start and slows to a gradual stop| -|easeInOutSine |Speeds up and slows to a gradual stop | -|easeInSine33 |Speeds up and comes to a sudden stop | -|easeOutSine33 |Sudden start and slows to a gradual stop | -|easeInOutSine33 |Speeds up and slows to a gradual stop | -|easeInOutSine50 |Speeds up and slows to a gradual stop | -|easeInOutSine60 |Speeds up and slows to a gradual stop | -|easeInOutSine70 |Speeds up and slows to a gradual stop | -|easeInOutSine80 |Speeds up and slows to a gradual stop | -|easeInOutSine90 |Speeds up and slows to a gradual stop | -|doubleEaseInOutSine6|Speeds up and slows to a gradual stop, then speeds up again and slows to a gradual stop | -|easeOutQuint50 |Sudden start and slows to a gradual stop | -|easeOutQuint80 |Sudden start and slows to a gradual stop | -|bounce |Sudden start, loses momentum and ** Returns to start position ** | -|bounceBack |Sudden start, loses momentum and returns to exceed start position ** Returns to start position ** | -|easeInBack |Slow start, exceed start position and quickly reach destination | -|easeOutBack |Sudden start, exceed end position and return to a gradual stop| -|easeInOutBack |Slow start, exceed start position, fast middle, exceed end position and return to a gradual stop| -|sin |full 360 revolution ** Returns to start position ** | -|sin2x |full 720 revolution ** Returns to start position ** | +| Name | Description | +|----------------------------------|----------------| +|ALPHA_FUNCTION_DEFAULT |Linear | +|ALPHA_FUNCTION_LINEAR |Linear | +|ALPHA_FUNCTION_REVERSE |Reverse linear | +|ALPHA_FUNCTION_EASE_IN_SQUARE |Speeds up and comes to a sudden stop (Square) | +|ALPHA_FUNCTION_EASE_OUT_SQUARE |Sudden start and slows to a gradual stop (Square) | +|ALPHA_FUNCTION_EASE_IN |Speeds up and comes to a sudden stop | +|ALPHA_FUNCTION_EASE_OUT |Sudden start and slows to a gradual stop| +|ALPHA_FUNCTION_EASE_IN_OUT |Speeds up and slows to a gradual stop| +|ALPHA_FUNCTION_EASE_IN_SINE |Speeds up and comes to a sudden stop| +|ALPHA_FUNCTION_EASE_OUT_SINE |Sudden start and slows to a gradual stop| +|ALPHA_FUNCTION_EASE_IN_OUT_SINE |Speeds up and slows to a gradual stop | +|ALPHA_FUNCTION_BOUNCE |Sudden start, loses momentum and ** Returns to start position ** | +|ALPHA_FUNCTION_SIN |full 360 revolution ** Returns to start position ** | +|ALPHA_FUNCTION_EASE_OUT_BACK |Sudden start, exceed end position and return to a gradual stop| diff --git a/plugins/dali-script-v8/docs/content/constants.js b/plugins/dali-script-v8/docs/content/constants.js index a09ed33..19359bd 100644 --- a/plugins/dali-script-v8/docs/content/constants.js +++ b/plugins/dali-script-v8/docs/content/constants.js @@ -169,28 +169,49 @@ Constants accessible under the dali global object. |GEOMETRY_TRIANGLE_STRIP | integer value | |**Property type ** | | -|PROPERTY_NONE | integer value | +|PROPERTY_NONE | none | |PROPERTY_BOOLEAN | integer value | -|PROPERTY_FLOAT | integer value | +|PROPERTY_FLOAT | float value | |PROPERTY_INTEGER | integer value | -|PROPERTY_VECTOR2 | integer value | -|PROPERTY_VECTOR3 | integer value | -|PROPERTY_VECTOR4 | integer value | -|PROPERTY_MATRIX3 | integer value | -|PROPERTY_MATRIX | integer value | -|PROPERTY_RECTANGLE | integer value | -|PROPERTY_ROTATION | integer value | -|PROPERTY_STRING | integer value | -|PROPERTY_ARRAY | integer value | -|PROPERTY_MAP | integer value | -|PROPERTY_INVALID_INDEX | integer value | -|PROPERTY_READ_ONLY | integer value | -|PROPERTY_READ_WRITE | integer value | -|PROPERTY_ANIMATABLE | integer value | +|PROPERTY_VECTOR2 | Array[ float, float ] | +|PROPERTY_VECTOR3 | Array[ float, float, float ] | +|PROPERTY_VECTOR4 | Array[ float, float, float, float ] | +|PROPERTY_MATRIX3 | Object | +|PROPERTY_MATRIX | Object | +|PROPERTY_RECTANGLE | Object | +|PROPERTY_ORIENTATION | Object | +|PROPERTY_STRING | String | +|PROPERTY_ARRAY | Object | +|PROPERTY_MAP | Object | + +|**Layout dimensions ** | | +|DIMENSION_WIDTH | integer value | +|DIMENSION_HEIGHT | integer value | |**Item layout type ** | | |ITEM_LAYOUT_LIST | integer value | |ITEM_LAYOUT_GRID | integer value | +|**Scroll direction bias ** | | +|DIRECTION_BIAS_NONE | integer value | +|DIRECTION_BIAS_LEFT | integer value | +|DIRECTION_BIAS_RIGHT | integer value | + +|**Animation alpha function ** | | +|ALPHA_FUNCTION_DEFAULT | integer value | +|ALPHA_FUNCTION_LINEAR | integer value | +|ALPHA_FUNCTION_REVERSE | integer value | +|ALPHA_FUNCTION_EASE_IN_SQUARE | integer value | +|ALPHA_FUNCTION_EASE_OUT_SQUARE | integer value | +|ALPHA_FUNCTION_EASE_IN | integer value | +|ALPHA_FUNCTION_EASE_OUT | integer value | +|ALPHA_FUNCTION_EASE_IN_OUT | integer value | +|ALPHA_FUNCTION_EASE_IN_SINE | integer value | +|ALPHA_FUNCTION_EASE_OUT_SINE | integer value | +|ALPHA_FUNCTION_EASE_IN_OUT_SINE | integer value | +|ALPHA_FUNCTION_BOUNCE | integer value | +|ALPHA_FUNCTION_SIN | integer value | +|ALPHA_FUNCTION_EASE_OUT_BACK | integer value | + * @class Constants */ diff --git a/plugins/dali-script-v8/docs/content/item-factory.js b/plugins/dali-script-v8/docs/content/item-factory.js index b7ae5ab..8f01154 100644 --- a/plugins/dali-script-v8/docs/content/item-factory.js +++ b/plugins/dali-script-v8/docs/content/item-factory.js @@ -169,7 +169,7 @@ JSON_TEMPLATE_FILE * "title_text" : "Item 1" } * ]; * - * itemFactory.data = itemViewData; // ItemFactory will look for the template from this JSON file + * itemFactory.data = itemViewData; // ItemFactory will create items from this data * * @type Array * @property data diff --git a/plugins/dali-script-v8/docs/content/path-animation.js b/plugins/dali-script-v8/docs/content/path-animation.js index 7847fc1..45b7fb6 100644 --- a/plugins/dali-script-v8/docs/content/path-animation.js +++ b/plugins/dali-script-v8/docs/content/path-animation.js @@ -30,7 +30,7 @@ function begin() dali.stage.add( imageView ); var animation = new dali.Animation(2.0); - var animOptions = { alpha:"easeInOutSine", delay:0.5, duration:1.5 }; + var animOptions = { alpha:dali.ALPHA_FUNCTION_EASE_IN_OUT_SINE, delay:0.5, duration:1.5 }; var forward = new dali.Vector3(1,0,0); animation.animate( imageView, myPath, forward, animOptions ); diff --git a/plugins/dali-script-v8/docs/content/scroll-view.js b/plugins/dali-script-v8/docs/content/scroll-view.js new file mode 100644 index 0000000..bff2fc3 --- /dev/null +++ b/plugins/dali-script-v8/docs/content/scroll-view.js @@ -0,0 +1,89 @@ +/** + * +## ScrollView API + +ScrollView is a container where the actors inside it can be scrolled manually +(via touch or pan gesture) or automatically. + +By default, ScrollView can scroll to any position both horizontally and +vertically and no snapping is enabled. + +Scroll mode can be specified to define how ScrollView should handle scrolling +in X and Y axes respectively (i.e. whether scrolling is enabled horizontally +or vertically, how scrolling is snapped, and the boundary to prevent ScrollView +to scroll beyond a certain position in the axes). + +![ ](../assets/img/scroll-view/scroll-view.png) + +### Example of creating a ScrollView + +``` + // Create a scroll view + var scrollView = new dali.Control("ScrollView"); + var stageSize = dali.stage.getSize(); + scrollView.size = [stageSize.x, stageSize.y, 0.0]; + scrollView.parentOrigin = dali.CENTER; + scrollView.anchorPoint = dali.CENTER; + + dali.stage.add( scrollView ); + + // Add actors to a scroll view with 3 pages + var pageRows = 1; + var pageColumns = 3; + for(var pageRow = 0; pageRow < pageRows; pageRow++) + { + for(var pageColumn = 0; pageColumn < pageColumns; pageColumn++) + { + var pageActor = new dali.Control(); + pageActor.widthResizePolicy = "FILL_TO_PARENT"; + pageActor.heightResizePolicy = "FILL_TO_PARENT"; + pageActor.parentOrigin = dali.CENTER; + pageActor.anchorPoint = dali.CENTER; + pageActor.position = [pageColumn * stageSize.x, pageRow * stageSize.y, 0.0]; + pageActor.name = "pageActor" + pageColumn; + + // Add images in a 3x4 grid layout for each page + var imageRows = 4; + var imageColumns = 3; + var margin = 10.0; + var imageSize = [(stageSize.x / imageColumns) - margin, (stageSize.y / imageRows) - margin, 0.0]; + + for(var row = 0; row < imageRows; row++) + { + for(var column = 0; column < imageColumns;column++) + { + var imageView = new dali.Control("ImageView"); + var imageId = row * imageColumns + column; + imageView.image = "./image-" + imageId + ".jpg"; + imageView.parentOrigin = dali.CENTER; + imageView.anchorPoint = dali.CENTER; + imageView.size = imageSize; + imageView.position = [ margin * 0.5 + (imageSize[0] + margin) * column - stageSize.x * 0.5 + imageSize[0] * 0.5, + margin * 0.5 + (imageSize[1] + margin) * row - stageSize.y * 0.5 + imageSize[1] * 0.5, + 0.0 ]; + pageActor.add(imageView); + var position = imageView.position; + } + } + + scrollView.add( pageActor ); + } + } + + // Set scroll view to have 3 pages in X axis and allow page snapping, + // and also disable scrolling in Y axis. + var scrollMode = { + xAxisScrollEnabled : true, + xAxisSnapToInterval : stageSize.x, // Define the snap points + xAxisScrollBoundary : stageSize.x * pageColumns, // i.e. Define 3 pages + yAxisScrollEnabled : false + } + + scrollView.setScrollMode(scrollMode); + +``` + + @class ScrollView + @extends Actor + +*/ diff --git a/plugins/dali-script-v8/file.list b/plugins/dali-script-v8/file.list index 598d90e..d648d9b 100644 --- a/plugins/dali-script-v8/file.list +++ b/plugins/dali-script-v8/file.list @@ -16,6 +16,7 @@ script_v8_plugin_src_files = \ $(v8_plugin_dir)/controls/control-wrapper.cpp \ $(v8_plugin_dir)/controls/item-factory-wrapper.cpp \ $(v8_plugin_dir)/controls/item-view-api.cpp \ + $(v8_plugin_dir)/controls/scroll-view-api.cpp \ $(v8_plugin_dir)/constants/constants-wrapper.cpp \ $(v8_plugin_dir)/animation/animation-api.cpp \ $(v8_plugin_dir)/animation/animation-wrapper.cpp \ diff --git a/plugins/dali-script-v8/src/actors/actor-api.cpp b/plugins/dali-script-v8/src/actors/actor-api.cpp index 371639d..e47285b 100644 --- a/plugins/dali-script-v8/src/actors/actor-api.cpp +++ b/plugins/dali-script-v8/src/actors/actor-api.cpp @@ -518,6 +518,31 @@ void ActorApi::GetNaturalSize( const v8::FunctionCallbackInfo& args ) } /** + * Return the value of negotiated dimension for the given dimension + * + * @for Actor + * @method getRelayoutSize + * @param {Integer} dimension The dimension of layout to retrieve (either dali.DIMENSION_WIDTH or dali.DIMENSION_HEIGHT) + * @return {Number} The value of the negotiated dimension + */ +void ActorApi::GetRelayoutSize( const v8::FunctionCallbackInfo& args ) +{ + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope handleScope( isolate ); + Actor actor = GetActor( isolate, args ); + + bool found; + int dimension = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 ); + if( !found ) + { + DALI_SCRIPT_EXCEPTION( isolate, "missing dimension parameter"); + return; + } + + args.GetReturnValue().Set( v8::Number::New( isolate, actor.GetRelayoutSize( static_cast(dimension) ) ) ); +} + +/** * Calculate the width of the actor given a height * * The natural size is used for default calculation. diff --git a/plugins/dali-script-v8/src/actors/actor-api.h b/plugins/dali-script-v8/src/actors/actor-api.h index bcd600e..2963400 100644 --- a/plugins/dali-script-v8/src/actors/actor-api.h +++ b/plugins/dali-script-v8/src/actors/actor-api.h @@ -57,6 +57,7 @@ namespace ActorApi void SetKeyboardFocusable( const v8::FunctionCallbackInfo< v8::Value >& args ); void IsKeyboardFocusable( const v8::FunctionCallbackInfo< v8::Value >& args ); void GetNaturalSize( const v8::FunctionCallbackInfo< v8::Value >& args ); + void GetRelayoutSize( const v8::FunctionCallbackInfo< v8::Value >& args ); void GetWidthForHeight( const v8::FunctionCallbackInfo& args ); void GetHeightForWidth( const v8::FunctionCallbackInfo& args ); void TranslateBy( const v8::FunctionCallbackInfo< v8::Value >& args ); diff --git a/plugins/dali-script-v8/src/actors/actor-wrapper.cpp b/plugins/dali-script-v8/src/actors/actor-wrapper.cpp index a1c0f78..c9d3e1d 100644 --- a/plugins/dali-script-v8/src/actors/actor-wrapper.cpp +++ b/plugins/dali-script-v8/src/actors/actor-wrapper.cpp @@ -179,6 +179,7 @@ const ActorFunctions ActorFunctionTable[]= // ignore. SetSize() use Actor.size // ignore. GetCurrentSize() use Actor.size { "GetNaturalSize", ActorApi::GetNaturalSize, ACTOR_API }, + { "GetRelayoutSize", ActorApi::GetRelayoutSize, ACTOR_API }, { "GetWidthForHeight",ActorApi::GetWidthForHeight, ACTOR_API }, { "GetHeightForWidth",ActorApi::GetHeightForWidth, ACTOR_API }, // ignore. SetPosition(....) use Actor.position diff --git a/plugins/dali-script-v8/src/animation/animation-api.cpp b/plugins/dali-script-v8/src/animation/animation-api.cpp index 0db4482..e20e656 100644 --- a/plugins/dali-script-v8/src/animation/animation-api.cpp +++ b/plugins/dali-script-v8/src/animation/animation-api.cpp @@ -20,7 +20,6 @@ #include "path-wrapper.h" // EXTERNAL INCLUDES -#include // for strcmp #include @@ -38,85 +37,11 @@ namespace V8Plugin namespace // un named namespace { -// @todo think about alternative ways of passing around -struct AlphaFuncStruct -{ - const char* const name; - AlphaFunction alphaFunc; -}; -/** - * Contains a list of alpha functions that can be used. - */ -const AlphaFuncStruct AlphaFunctionTable[]= -{ - - {"default" , AlphaFunction::DEFAULT }, - {"linear" , AlphaFunction::LINEAR }, - {"reverse" , AlphaFunction::REVERSE }, - - {"easeInSquare" , AlphaFunction::EASE_IN_SQUARE }, - {"easeOutSquare" , AlphaFunction::EASE_OUT_SQUARE }, - - {"easeIn" , AlphaFunction::EASE_IN }, - {"easeOut" , AlphaFunction::EASE_OUT }, - {"easeInOut" , AlphaFunction::EASE_IN_OUT }, - - {"easeInSine" , AlphaFunction::EASE_IN_SINE }, - {"easeOutSine" , AlphaFunction::EASE_OUT_SINE }, - {"easeInOutSine" , AlphaFunction::EASE_IN_OUT_SINE }, - - {"bounce" , AlphaFunction::BOUNCE }, - {"sin" , AlphaFunction::SIN }, - {"easeOutBack" , AlphaFunction::EASE_OUT_BACK }, - -}; -const unsigned int AlphaFunctionTableCount = sizeof(AlphaFunctionTable)/sizeof(AlphaFunctionTable[0]); -const char* const DEFAULT_ALPHA_NAME = "default"; -static AlphaFunction DEFAULT_ALPHA_FUNCTION = AlphaFunction::DEFAULT; - - - -AlphaFunction GetAlphaFunction( const std::string& alphaFuncName ) -{ - // This will normally get called just a few times during the application, so no point in doing anything clever - for( unsigned int i = 0; i < AlphaFunctionTableCount; i++) - { - const AlphaFuncStruct& alphaStruct( AlphaFunctionTable[i] ); - - if( std::strcmp( alphaStruct.name , alphaFuncName.c_str() ) == 0 ) - { - return alphaStruct.alphaFunc; - } - } - - DALI_LOG_ERROR("Failed to find alpha func |%s| \n", alphaFuncName.c_str() ); - return DEFAULT_ALPHA_FUNCTION; -} - -const char* const GetAlphaFunctionName( AlphaFunction alphaFunc ) -{ - // This may get called 3 times during the application, so no point - // in doing anything clever - - for( unsigned int i = 0; i < AlphaFunctionTableCount; i++) - { - const AlphaFuncStruct& alphaStruct( AlphaFunctionTable[i] ); - - - if( alphaStruct.alphaFunc.GetBuiltinFunction() == alphaFunc.GetBuiltinFunction() ) - { - return alphaStruct.name; - } - } - return "default"; -} - - struct AnimationParameters { AnimationParameters( const Animation& anim) : propertyIndex( Property::INVALID_INDEX ), - alphaFunction( DEFAULT_ALPHA_FUNCTION), + alphaFunction( AlphaFunction::DEFAULT), delay( 0.f ), duration(anim.GetDuration()), optionsFound( false ) @@ -150,11 +75,10 @@ void GetAnimationOptions( v8::Isolate* isolate, { v8::Local obj = options->ToObject(); v8::Local alphaValue = obj->Get( v8::String::NewFromUtf8( isolate, "alpha" ) ); - if( alphaValue->IsString() ) + if( alphaValue->IsUint32() ) { animParams.optionsFound = true; - std::string alphaName = V8Utils::v8StringToStdString( alphaValue ); - animParams.alphaFunction = GetAlphaFunction( alphaName ); + animParams.alphaFunction = static_cast(alphaValue->ToUint32()->Value()); } v8::Local delayValue = obj->Get( v8::String::NewFromUtf8( isolate, "delay" ) ); @@ -225,10 +149,9 @@ KeyFrames GetKeyFrames( v8::Isolate* isolate, v8::Local keyFrameArra // get keyframe.alpha v8::Handle alphaValue = keyFrameObject->Get(v8::String::NewFromUtf8( isolate, "alpha")); - if( alphaValue->IsString() ) + if( alphaValue->IsUint32() ) { - std::string alphaName = V8Utils::v8StringToStdString( alphaValue ); - AlphaFunction alphaFunction = GetAlphaFunction( alphaName ); + AlphaFunction alphaFunction = static_cast(alphaValue->ToUint32()->Value()); keyframes.Add( progress->NumberValue(), value, alphaFunction ); } else @@ -529,7 +452,7 @@ void AnimationApi::GetDisconnectAction( const v8::FunctionCallbackInfo< v8::Valu * Set the default alpha function for an animation. * @method setDefaultAlphaFunction * @for Animation - * @param {string} alpha function + * @param {Integer} alpha function */ void AnimationApi::SetDefaultAlphaFunction( const v8::FunctionCallbackInfo< v8::Value >& args ) { @@ -539,23 +462,22 @@ void AnimationApi::SetDefaultAlphaFunction( const v8::FunctionCallbackInfo< v8:: Animation anim = GetAnimation( isolate, args ); bool found( false ); - std::string alphaFunc = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args ); + int alphaFunc = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 ); if( !found ) { DALI_SCRIPT_EXCEPTION( isolate, "bad parameter" ); } else { - AlphaFunction func = GetAlphaFunction( alphaFunc ); + AlphaFunction func = static_cast(alphaFunc); anim.SetDefaultAlphaFunction( func ); } - } /** * Get the default alpha function for an animation. * @method getDefaultAlphaFunction * @for Animation - * @return {string} alpha function + * @return {Integer} alpha function */ void AnimationApi::GetDefaultAlphaFunction( const v8::FunctionCallbackInfo& args ) { @@ -564,10 +486,10 @@ void AnimationApi::GetDefaultAlphaFunction( const v8::FunctionCallbackInfo& args, Acto targetPropertyIndex = targetActor.GetPropertyIndex( propertyName ); if( targetPropertyIndex == Property::INVALID_INDEX ) { - targetPropertyIndex = targetActor.GetPropertyIndex( propertyName ); - - if( targetPropertyIndex == Property::INVALID_INDEX ) - { - DALI_SCRIPT_EXCEPTION( isolate, "Target property not found" ); - return false; - } + DALI_SCRIPT_EXCEPTION( isolate, "Target property not found" ); + return false; } } else @@ -139,14 +134,9 @@ bool GetApplyParameters( const v8::FunctionCallbackInfo< v8::Value >& args, Acto sourcePropertyIndex = targetActor.GetPropertyIndex( propertyName ); if( sourcePropertyIndex == Property::INVALID_INDEX ) { - sourcePropertyIndex = targetActor.GetPropertyIndex( propertyName ); - - if( sourcePropertyIndex == Property::INVALID_INDEX ) - { - DALI_SCRIPT_EXCEPTION( isolate, "Source property not found" ); - return false; + DALI_SCRIPT_EXCEPTION( isolate, "Source property not found" ); + return false; } - } } else { diff --git a/plugins/dali-script-v8/src/constants/constants-wrapper.cpp b/plugins/dali-script-v8/src/constants/constants-wrapper.cpp index edbd62b..a3a3dd7 100644 --- a/plugins/dali-script-v8/src/constants/constants-wrapper.cpp +++ b/plugins/dali-script-v8/src/constants/constants-wrapper.cpp @@ -36,6 +36,7 @@ #include #include #include +#include namespace Dali { @@ -248,9 +249,31 @@ const IntegerPair EnumTable[] = { "PROPERTY_READ_WRITE", Property::READ_WRITE }, { "PROPERTY_ANIMATABLE", Property::ANIMATABLE }, + { "DIMENSION_WIDTH", Dimension::WIDTH }, + { "DIMENSION_HEIGHT", Dimension::HEIGHT }, + { "ITEM_LAYOUT_LIST", Toolkit::DefaultItemLayout::LIST }, { "ITEM_LAYOUT_GRID", Toolkit::DefaultItemLayout::GRID }, + { "DIRECTION_BIAS_NONE", Toolkit::DirectionBiasNone }, + { "DIRECTION_BIAS_LEFT", Toolkit::DirectionBiasLeft }, + { "DIRECTION_BIAS_RIGHT", Toolkit::DirectionBiasRight }, + + { "ALPHA_FUNCTION_DEFAULT", AlphaFunction::DEFAULT }, + { "ALPHA_FUNCTION_LINEAR", AlphaFunction::LINEAR }, + { "ALPHA_FUNCTION_REVERSE", AlphaFunction::REVERSE }, + { "ALPHA_FUNCTION_EASE_IN_SQUARE", AlphaFunction::EASE_IN_SQUARE }, + { "ALPHA_FUNCTION_EASE_OUT_SQUARE", AlphaFunction::EASE_OUT_SQUARE }, + { "ALPHA_FUNCTION_EASE_IN", AlphaFunction::EASE_IN }, + { "ALPHA_FUNCTION_EASE_OUT", AlphaFunction::EASE_OUT }, + { "ALPHA_FUNCTION_EASE_IN_OUT", AlphaFunction::EASE_IN_OUT }, + { "ALPHA_FUNCTION_EASE_IN_SINE", AlphaFunction::EASE_IN_SINE }, + { "ALPHA_FUNCTION_EASE_OUT_SINE", AlphaFunction::EASE_OUT_SINE }, + { "ALPHA_FUNCTION_EASE_IN_OUT_SINE", AlphaFunction::EASE_IN_OUT_SINE }, + { "ALPHA_FUNCTION_BOUNCE", AlphaFunction::BOUNCE }, + { "ALPHA_FUNCTION_SIN", AlphaFunction::SIN }, + { "ALPHA_FUNCTION_EASE_OUT_BACK", AlphaFunction::EASE_OUT_BACK }, + }; const unsigned int EnumTableCount = sizeof(EnumTable)/sizeof(EnumTable[0]); diff --git a/plugins/dali-script-v8/src/controls/control-wrapper.cpp b/plugins/dali-script-v8/src/controls/control-wrapper.cpp index 09093a2..b3cc3dc 100644 --- a/plugins/dali-script-v8/src/controls/control-wrapper.cpp +++ b/plugins/dali-script-v8/src/controls/control-wrapper.cpp @@ -24,6 +24,7 @@ // INTERNAL INCLUDES #include +#include #include #include @@ -35,6 +36,7 @@ namespace V8Plugin v8::Persistent ControlWrapper::mControlTemplate; v8::Persistent ControlWrapper::mItemViewTemplate; +v8::Persistent ControlWrapper::mScrollViewTemplate; Vector< void* > ControlWrapper::mControlGarbageContainer; @@ -56,7 +58,8 @@ struct ControlTemplate const ControlTemplate ControlTemplateLookup[]= { { &ControlWrapper::mControlTemplate }, // CONTROL - { &ControlWrapper::mItemViewTemplate } // ITEMVIEW + { &ControlWrapper::mItemViewTemplate }, // ITEMVIEW + { &ControlWrapper::mScrollViewTemplate } // SCROLLVIEW }; /** @@ -65,7 +68,8 @@ const ControlTemplate ControlTemplateLookup[]= enum ControlApiBitMask { CONTROL_API = 1 << 0, - ITEMVIEW_API = 1 << 1 + ITEMVIEW_API = 1 << 1, + SCROLLVIEW_API = 1 << 2 }; /** @@ -87,6 +91,7 @@ const ControlApiStruct ControlApiLookup[]= { {"Control", ControlWrapper::CONTROL, NULL, CONTROL_API }, {"ItemView", ControlWrapper::ITEMVIEW, ItemViewApi::New, CONTROL_API | ITEMVIEW_API }, + {"ScrollView", ControlWrapper::SCROLLVIEW, ScrollViewApi::New, CONTROL_API | SCROLLVIEW_API } }; const unsigned int ControlApiLookupCount = sizeof(ControlApiLookup)/sizeof(ControlApiLookup[0]); @@ -171,6 +176,19 @@ const ControlFunctions ControlFunctionTable[]= { "GetItemId", ItemViewApi::GetItemId, ITEMVIEW_API }, { "GetItemsRange", ItemViewApi::GetItemsRange, ITEMVIEW_API }, + /************************************** + * ScrollView API + **************************************/ + { "SetScrollMode", ScrollViewApi::SetScrollMode, SCROLLVIEW_API }, + { "GetCurrentPage", ScrollViewApi::GetCurrentPage, SCROLLVIEW_API }, + { "ScrollToPosition", ScrollViewApi::ScrollToPosition, SCROLLVIEW_API }, + { "ScrollToPage", ScrollViewApi::ScrollToPage, SCROLLVIEW_API }, + { "ScrollToActor", ScrollViewApi::ScrollToActor, SCROLLVIEW_API }, + { "ScrollToSnapInterval", ScrollViewApi::ScrollToSnapInterval, SCROLLVIEW_API }, + { "SetScrollFlickAlphaFunction", ScrollViewApi::SetScrollFlickAlphaFunction, SCROLLVIEW_API }, + { "SetScrollSnapAlphaFunction", ScrollViewApi::SetScrollSnapAlphaFunction, SCROLLVIEW_API }, + { "SetSnapOvershootAlphaFunction", ScrollViewApi::SetSnapOvershootAlphaFunction, SCROLLVIEW_API }, + }; const unsigned int ControlFunctionTableCount = sizeof(ControlFunctionTable)/sizeof(ControlFunctionTable[0]); diff --git a/plugins/dali-script-v8/src/controls/control-wrapper.h b/plugins/dali-script-v8/src/controls/control-wrapper.h index dc4b636..8147d56 100644 --- a/plugins/dali-script-v8/src/controls/control-wrapper.h +++ b/plugins/dali-script-v8/src/controls/control-wrapper.h @@ -50,7 +50,8 @@ public: { UNKNOWN_CONTROL = -1, CONTROL = 0, - ITEMVIEW = 1 + ITEMVIEW = 1, + SCROLLVIEW = 2 }; /** diff --git a/plugins/dali-script-v8/src/controls/scroll-view-api.cpp b/plugins/dali-script-v8/src/controls/scroll-view-api.cpp new file mode 100644 index 0000000..969fbf7 --- /dev/null +++ b/plugins/dali-script-v8/src/controls/scroll-view-api.cpp @@ -0,0 +1,477 @@ +/* + * 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 "scroll-view-api.h" + +// EXTERNAL INCLUDES + +// INTERNAL INCLUDES +#include +#include +#include + +namespace Dali +{ + +namespace V8Plugin +{ + +namespace // unanmed namespace +{ + +Toolkit::ScrollView GetScrollView( v8::Isolate* isolate, const v8::FunctionCallbackInfo& args ) +{ + HandleWrapper* handleWrapper = HandleWrapper::Unwrap( isolate, args.This() ); + return Toolkit::ScrollView::DownCast( handleWrapper->mHandle ); +} + +} //unanmed namespace + +/*************************************** + * SCROLLVIEW API FUNCTIONS + ***************************************/ + +/** + * Constructor + * + * @for ScrollView + * @constructor + * @method ScrollView + * @return {Object} scrollView + */ +Toolkit::Control ScrollViewApi::New( const v8::FunctionCallbackInfo< v8::Value >& args ) +{ + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope handleScope( isolate ); + + Toolkit::ScrollView scrollView = Toolkit::ScrollView::New(); + return scrollView; +} + +/** + * Set the scroll mode of ScrollView. + * + * This defines whether scrolling is enabled horizontally or vertically, how + * scrolling is snapped, and the boundary in which the scroll view can pan. + * + * When no specific scroll mode is set, scroll view can scroll to any position + * both horizontally and vertically and no snapping is enabled. + * + * Example of setting the scroll boundary of scroll view in the X axis to + * three pages (page size equals to the width of scroll view) and allowing + * snapping between pages, and disabling scrolling in the Y axis. + * + * ``` + * var scrollMode = { + * xAxisScrollEnabled : true, + * xAxisSnapToInterval : scrollView.sizeWidth, + * xAxisScrollBoundary : scrollView.sizeWidth * 3, + * yAxisScrollEnabled : false + * } + * + * scrollView.setScrollMode(scrollMode); + * ``` + * + * @for ScrollView + * @method setScrollMode + * @param {Object} scrollMode + * @param {Boolean} scrollMode.xAxisScrollEnabled True if the content can be scrolled in X axis or false if not. + * @param {Float} [scrollMode.xAxisSnapToInterval] When set, causes scroll view to snap to multiples of the value of the interval in the X axis while flicking. (by default no snapping) + * @param {Float} [scrollMode.xAxisScrollBoundary] When set, causes scroll view unable to scroll beyond the value of the boundary in the X axis (by default no boundary) + * @param {Boolean} scrollMode.yAxisScrollEnabled True if the content can be scrolled in Y axis or false if not. + * @param {Float} [scrollMode.yAxisSnapToInterval] When set, causes scroll view to snap to multiples of the value of the interval in the Y axis while flicking. (by default no snapping) + * @param {Float} [scrollMode.yAxisScrollBoundary] When set, causes scroll view unable to scroll beyond the value of the boundary in the Y axis (by default no boundary) + */ +void ScrollViewApi::SetScrollMode( const v8::FunctionCallbackInfo< v8::Value >& args) +{ + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope handleScope( isolate ); + + Toolkit::ScrollView scrollView = GetScrollView( isolate, args ); + + v8::Local scrollMode( args[0] ); + if( !scrollMode->IsObject() ) + { + DALI_SCRIPT_EXCEPTION( isolate, "invalid scroll mode parameter" ); + return; + } + + v8::Local scrollModeObj = scrollMode->ToObject(); + + Toolkit::RulerPtr rulerX, rulerY; + + // Check the scroll mode in the X axis + bool xAxisScrollEnabled = true; + v8::Local xAxisScrollEnabledValue= scrollModeObj->Get( v8::String::NewFromUtf8( isolate, "xAxisScrollEnabled" ) ); + if( xAxisScrollEnabledValue->IsBoolean() ) + { + xAxisScrollEnabled = xAxisScrollEnabledValue->ToBoolean()->Value(); + } + else + { + DALI_SCRIPT_EXCEPTION( isolate, "Missing xAxisScrollEnabled"); + return; + } + + if(!xAxisScrollEnabled) + { + // Default ruler and disabled + rulerX = new Toolkit::DefaultRuler(); + rulerX->Disable(); + } + else + { + v8::Local xAxisSnapToIntervalValue= scrollModeObj->Get( v8::String::NewFromUtf8( isolate, "xAxisSnapToInterval" ) ); + if( xAxisSnapToIntervalValue->IsNumber() ) + { + // Fixed ruler and enabled + float xAxisSnapToInterval = xAxisSnapToIntervalValue->ToNumber()->Value(); + rulerX = new Toolkit::FixedRuler(xAxisSnapToInterval); + } + else + { + // Default ruler and enabled + rulerX = new Toolkit::DefaultRuler(); + } + + v8::Local xAxisScrollBoundaryValue= scrollModeObj->Get( v8::String::NewFromUtf8( isolate, "xAxisScrollBoundary" ) ); + if( xAxisScrollBoundaryValue->IsNumber() ) + { + // By default ruler domain is disabled unless set + float xAxisScrollBoundary = xAxisScrollBoundaryValue->ToNumber()->Value(); + rulerX->SetDomain( Toolkit::RulerDomain( 0, xAxisScrollBoundary, true ) ); + } + } + + // Check the scroll mode in the Y axis + bool yAxisScrollEnabled = true; + v8::Local yAxisScrollEnabledValue= scrollModeObj->Get( v8::String::NewFromUtf8( isolate, "yAxisScrollEnabled" ) ); + if( yAxisScrollEnabledValue->IsBoolean() ) + { + yAxisScrollEnabled = yAxisScrollEnabledValue->ToBoolean()->Value(); + } + else + { + DALI_SCRIPT_EXCEPTION( isolate, "Missing yAxisScrollEnabled"); + return; + } + + if(!yAxisScrollEnabled) + { + // Default ruler and disabled + rulerY = new Toolkit::DefaultRuler(); + rulerY->Disable(); + } + else + { + v8::Local yAxisSnapToIntervalValue= scrollModeObj->Get( v8::String::NewFromUtf8( isolate, "yAxisSnapToInterval" ) ); + if( yAxisSnapToIntervalValue->IsNumber() ) + { + // Fixed ruler and enabled + float yAxisSnapToInterval = yAxisSnapToIntervalValue->ToNumber()->Value(); + rulerY = new Toolkit::FixedRuler(yAxisSnapToInterval); + } + else + { + // Default ruler and enabled + rulerY = new Toolkit::DefaultRuler(); + } + + v8::Local yAxisScrollBoundaryValue= scrollModeObj->Get( v8::String::NewFromUtf8( isolate, "yAxisScrollBoundary" ) ); + if( yAxisScrollBoundaryValue->IsNumber() ) + { + // By default ruler domain is disabled unless set + float yAxisScrollBoundary = yAxisScrollBoundaryValue->ToNumber()->Value(); + rulerY->SetDomain( Toolkit::RulerDomain( 0, yAxisScrollBoundary, true ) ); + } + } + + scrollView.SetRulerX(rulerX); + scrollView.SetRulerY(rulerY); +} + +/** + * Retrieves current scroll page based on the defined snap interval being the + * size of one page, and all pages laid out in a grid fashion, increasing from + * left to right until the end of the scroll boundary. Pages start from 0 as the + * first page. + * + * If no snap interval is defined, this API will return undefined value. + * + * @for ScrollView + * @method getCurrentPage + * @return {Integer} The index of current page in scroll view + */ +void ScrollViewApi::GetCurrentPage( const v8::FunctionCallbackInfo< v8::Value >& args) +{ + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope handleScope( isolate ); + + Toolkit::ScrollView scrollView = GetScrollView( isolate, args ); + args.GetReturnValue().Set( v8::Integer::New( isolate, scrollView.GetCurrentPage() ) ); +} + +/** + * Scrolls the contents to the given position. + * + * Position 0,0 is the origin. Increasing X scrolls contents left, while + * increasing Y scrolls contents up. If Rulers have been applied to the axes, + * then the contents will scroll until reaching the scroll boundary. + * Contents will not snap. + * + * The biasing parameters are provided such that in scenarios with 2 or 2x2 pages + * in wrap mode, the application developer can decide whether to scroll left or + * right to get to the target page. + * + * @for ScrollView + * @method scrollToPosition + * @param {Array} position The position to scroll to. + * @param {Float} [durationSeconds] The duration of the scroll animation in seconds (default value is scrollView.scrollSnapDuration) + * @param {Integer} [alphaFunction] The alpha function to use. + * @param {Integer} [horizontalBias] Whether to bias scrolling to left or right (by default no bias). + * @param {Integer} [verticalBias] Whether to bias scrolling to top or bottom (by default no bias). + * @example + * // scroll direction bias is one of the following + * dali.DIRECTION_BIAS_NONE // Don't bias scroll snap + * dali.DIRECTION_BIAS_LEFT // Bias scroll snap to Left + * dali.DIRECTION_BIAS_RIGHT // Bias scroll snap to Right + * + * scrollView.scrollToPosition( [150.0, 100.0], 0.5, dali.ALPHA_FUNCTION_EASE_IN_OUT, dali.DIRECTION_BIAS_LEFT, dali.DIRECTION_BIAS_NONE ); + */ +void ScrollViewApi::ScrollToPosition( const v8::FunctionCallbackInfo< v8::Value >& args) +{ + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope handleScope( isolate ); + + Toolkit::ScrollView scrollView = GetScrollView( isolate, args ); + + bool found( false ); + Vector2 position = V8Utils::GetVector2Parameter( PARAMETER_0, found, isolate, args ); + if( !found ) + { + DALI_SCRIPT_EXCEPTION( isolate, "bad position parameter" ); + return; + } + + float durationSeconds = V8Utils::GetFloatParameter( PARAMETER_1, found, isolate, args, scrollView.GetScrollSnapDuration() ); + + AlphaFunction alphaFunction = scrollView.GetScrollSnapAlphaFunction(); + + found = false; + int alpha = V8Utils::GetIntegerParameter( PARAMETER_2, found, isolate, args, 0 ); + if(found) + { + alphaFunction = static_cast(alpha); + } + + Toolkit::DirectionBias horizontalBias = static_cast( V8Utils::GetIntegerParameter( PARAMETER_3, found, isolate, args, Toolkit::DirectionBiasNone ) ); + Toolkit::DirectionBias verticalBias = static_cast( V8Utils::GetIntegerParameter( PARAMETER_4, found, isolate, args, Toolkit::DirectionBiasNone ) ); + + scrollView.ScrollTo( position, durationSeconds, alphaFunction, horizontalBias, verticalBias ); +} + +/** + * Scrolls the contents to the page with the given index. + * + * This is based on assumption that the page index starts from 0 and the + * position of each page is: [pageIndex * snapToInterval, 0]. + * + * If no snap interval is defined, calling this API will cause unexpected + * behaviour. + * + * The biasing parameter is provided such that in scenarios with 2 pages + * in wrap mode, the application developer can decide whether to scroll + * left or right to get to the target page. + * + * @for ScrollView + * @method scrollToPage + * @param {Integer} pageIndex The index of the page to scroll to. + * @param {Float} [durationSeconds] The duration of the scroll animation in seconds (default value is scrollView.scrollSnapDuration) + * @param {Integer} [bias] Whether to bias scrolling to left or right (by default no bias). + * @example + * // scroll direction bias is one of the following + * dali.DIRECTION_BIAS_NONE // Don't bias scroll snap + * dali.DIRECTION_BIAS_LEFT // Bias scroll snap to Left + * dali.DIRECTION_BIAS_RIGHT // Bias scroll snap to Right + * + * scrollView.scrollToPage( 1, 0.5, dali.DIRECTION_BIAS_RIGHT ); + */ +void ScrollViewApi::ScrollToPage( const v8::FunctionCallbackInfo< v8::Value >& args) +{ + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope handleScope( isolate ); + + Toolkit::ScrollView scrollView = GetScrollView( isolate, args ); + + bool found( false ); + int pageIndex = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 ); + if( !found ) + { + DALI_SCRIPT_EXCEPTION( isolate, "bad page index parameter" ); + return; + } + + float durationSeconds = V8Utils::GetFloatParameter( PARAMETER_1, found, isolate, args, scrollView.GetScrollSnapDuration() ); + Toolkit::DirectionBias bias = static_cast( V8Utils::GetIntegerParameter( PARAMETER_2, found, isolate, args, Toolkit::DirectionBiasNone ) ); + + scrollView.ScrollTo( pageIndex, durationSeconds, bias ); +} + +/** + * Scrolls the contents such that the given actor appears in the center of + * the scroll view. + * + * The actor must be a direct child of scroll view. + * + * @for ScrollView + * @method scrollToActor + * @param {Object} actor The actor to scroll to. + * @param {Float} [durationSeconds] The duration of the scroll animation in seconds (default value is scrollView.scrollSnapDuration) + * @example + * scrollView.scrollToActor( childActor, 0.5 ); + */ +void ScrollViewApi::ScrollToActor( const v8::FunctionCallbackInfo< v8::Value >& args) +{ + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope handleScope( isolate ); + + Toolkit::ScrollView scrollView = GetScrollView( isolate, args ); + + bool found( false ); + Actor actor = V8Utils::GetActorParameter( 0, found, isolate, args ); + if( !found ) + { + DALI_SCRIPT_EXCEPTION( isolate, "invalid actor parameter" ); + return; + } + + float durationSeconds = V8Utils::GetFloatParameter( PARAMETER_1, found, isolate, args, scrollView.GetScrollSnapDuration() ); + + scrollView.ScrollTo( actor, durationSeconds ); +} + +/** + * Scrolls the content to the nearest snap point as specified by the snap interval. + * If already at snap points, it will not scroll. + * + * @for ScrollView + * @method scrollToSnapInterval + * @return {Boolean} True if snapping is needed or false if already at snap points + * @example + * var success = scrollView.scrollToSnapInterval(); + */ +void ScrollViewApi::ScrollToSnapInterval( const v8::FunctionCallbackInfo< v8::Value >& args) +{ + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope handleScope( isolate ); + + Toolkit::ScrollView scrollView = GetScrollView( isolate, args ); + + args.GetReturnValue().Set( v8::Boolean::New( isolate, scrollView.ScrollToSnapPoint() ) ); +} + +/** + * Set the alpha function of flick animation. + * + * @for ScrollView + * @method setScrollFlickAlphaFunction + * @param {Integer} alphaFunction The alpha function to use. + * @example + * scrollView.setScrollFlickAlphaFunction( dali.ALPHA_FUNCTION_EASE_IN_OUT ); + */ +void ScrollViewApi::SetScrollFlickAlphaFunction( const v8::FunctionCallbackInfo< v8::Value >& args) +{ + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope handleScope( isolate ); + + Toolkit::ScrollView scrollView = GetScrollView( isolate, args ); + + bool found( false ); + int alphaFunction = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 ); + if( !found ) + { + DALI_SCRIPT_EXCEPTION( isolate, "invalid alpha function parameter" ); + return; + } + else + { + scrollView.SetScrollFlickAlphaFunction( static_cast(alphaFunction) ); + } +} + +/** + * Set the alpha function of snap animation. + * + * @for ScrollView + * @method setScrollSnapAlphaFunction + * @param {String} alphaFunction The alpha function to use. + * @example + * scrollView.setScrollSnapAlphaFunction( dali.ALPHA_FUNCTION_EASE_IN_OUT ); + */ +void ScrollViewApi::SetScrollSnapAlphaFunction( const v8::FunctionCallbackInfo< v8::Value >& args) +{ + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope handleScope( isolate ); + + Toolkit::ScrollView scrollView = GetScrollView( isolate, args ); + + bool found( false ); + int alphaFunction = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 ); + if( !found ) + { + DALI_SCRIPT_EXCEPTION( isolate, "invalid alpha function parameter" ); + return; + } + else + { + scrollView.SetScrollSnapAlphaFunction( static_cast(alphaFunction) ); + } +} + +/** + * Set the alpha function of overshoot snap animation. + * + * @for ScrollView + * @method setSnapOvershootAlphaFunction + * @param {String} alphaFunction The alpha function to use. + * @example + * scrollView.setSnapOvershootAlphaFunction( dali.ALPHA_FUNCTION_EASE_IN_OUT ); + */ +void ScrollViewApi::SetSnapOvershootAlphaFunction( const v8::FunctionCallbackInfo< v8::Value >& args) +{ + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope handleScope( isolate ); + + Toolkit::ScrollView scrollView = GetScrollView( isolate, args ); + + bool found( false ); + int alphaFunction = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 ); + if( !found ) + { + DALI_SCRIPT_EXCEPTION( isolate, "invalid alpha function parameter" ); + return; + } + else + { + scrollView.SetSnapOvershootAlphaFunction( static_cast(alphaFunction) ); + } +} + +} // namespace V8Plugin + +} // namespace Dali diff --git a/plugins/dali-script-v8/src/controls/scroll-view-api.h b/plugins/dali-script-v8/src/controls/scroll-view-api.h new file mode 100644 index 0000000..0ca74db --- /dev/null +++ b/plugins/dali-script-v8/src/controls/scroll-view-api.h @@ -0,0 +1,58 @@ +#ifndef __DALI_V8PLUGIN_SCROLL_VIEW_API_H__ +#define __DALI_V8PLUGIN_SCROLL_VIEW_API_H__ + +/* + * 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. + * + */ + +// EXTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +namespace V8Plugin +{ + +namespace ScrollViewApi +{ + + /** + * constructor + */ + Toolkit::Control New( const v8::FunctionCallbackInfo< v8::Value >& args ); + + /** + * ScrollView API. See scroll-view.h for description of functions + */ + void SetScrollMode( const v8::FunctionCallbackInfo< v8::Value >& args); + void GetCurrentPage( const v8::FunctionCallbackInfo< v8::Value >& args ); + void ScrollToPosition( const v8::FunctionCallbackInfo< v8::Value >& args ); + void ScrollToPage( const v8::FunctionCallbackInfo< v8::Value >& args ); + void ScrollToActor( const v8::FunctionCallbackInfo< v8::Value >& args ); + void ScrollToSnapInterval( const v8::FunctionCallbackInfo< v8::Value >& args ); + void SetScrollFlickAlphaFunction( const v8::FunctionCallbackInfo< v8::Value >& args ); + void SetScrollSnapAlphaFunction( const v8::FunctionCallbackInfo< v8::Value >& args ); + void SetSnapOvershootAlphaFunction( const v8::FunctionCallbackInfo< v8::Value >& args ); + +}; // namespace ScrollViewApi + +} // namespace V8Plugin + +} // namespace Dali + +#endif // header __DALI_V8PLUGIN_SCROLL_VIEW_API_H__ diff --git a/plugins/dali-script-v8/src/shared/base-wrapped-object.h b/plugins/dali-script-v8/src/shared/base-wrapped-object.h index 0bd9840..0efc17e 100644 --- a/plugins/dali-script-v8/src/shared/base-wrapped-object.h +++ b/plugins/dali-script-v8/src/shared/base-wrapped-object.h @@ -82,6 +82,7 @@ public: ACTOR_PROPERTY, ITEMVIEW, ITEMFACTORY, + SCROLLVIEW, RENDER_TASK, RENDER_TASK_LIST, TIMER,