X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscrollable%2Fitem-view%2Fitem-view-impl.cpp;h=23fcd36a6e0cf9c826a6f5ef696101a221739888;hp=ca658b9d6145d8b55c331ba1e50e9c986627fcea;hb=06f734a391814a2972e31351604e0a34ef712ed9;hpb=fcecf5a523b19dd101ec2dcc651f42e1b6232d77 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 old mode 100644 new mode 100755 index ca658b9..23fcd36 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -21,6 +21,8 @@ // EXTERNAL INCLUDES #include // for strcmp #include +#include + #include #include #include @@ -29,10 +31,17 @@ #include #include #include +#include // INTERNAL INCLUDES #include #include +#include +#include +#include +#include +#include +#include #include using std::string; @@ -250,6 +259,8 @@ DALI_PROPERTY_REGISTRATION( Toolkit, ItemView, "minimumSwipeDistance", FLO 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 ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, ItemView, "layout", ARRAY, LAYOUT ) + DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "layoutPosition", FLOAT, LAYOUT_POSITION) DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "scrollSpeed", FLOAT, SCROLL_SPEED) @@ -407,11 +418,11 @@ void ItemView::ActivateLayout(unsigned int layoutIndex, const Vector3& targetSiz // Remove constraints from previous layout actor.RemoveConstraints(); + mActiveLayout->ApplyConstraints(actor, itemId, targetSize, Self() ); + Vector3 size; mActiveLayout->GetItemSize( itemId, targetSize, size ); actor.SetSize( size.GetVectorXY() ); - - mActiveLayout->ApplyConstraints(actor, itemId, targetSize, Self() ); } // Refresh the new layout @@ -1732,6 +1743,89 @@ void ItemView::SetProperty( BaseObject* object, Property::Index index, const Pro itemViewImpl.SetRefreshInterval( value.Get() ); break; } + case Toolkit::DevelItemView::Property::LAYOUT: + { + // Get a Property::Array from the property if possible. + Property::Array layoutArray; + if( value.Get( layoutArray ) ) + { + itemViewImpl.SetLayoutArray( layoutArray ); + } + break; + } + } + } +} + +Property::Array ItemView::GetLayoutArray() +{ + return mlayoutArray; +} + +void ItemView::SetLayoutArray( const Property::Array& layouts ) +{ + mlayoutArray = layouts; + if(GetLayoutCount() > 0) + { + for(unsigned int index = GetLayoutCount() - 1; index >= 0; --index) + { + RemoveLayout(index); + if(index == 0) break; + } + } + + for( unsigned int arrayIdx = 0, arrayCount = layouts.Count(); arrayIdx < arrayCount; ++arrayIdx ) + { + const Property::Value& element = layouts.GetElementAt( arrayIdx ); + + Property::Map* layout = element.GetMap(); + if( layout != NULL ) + { + for( unsigned int mapIdx = 0, mapCount = (*layout).Count(); mapIdx < mapCount; ++mapIdx ) + { + KeyValuePair propertyPair( (*layout).GetKeyValue( mapIdx ) ); + + if(propertyPair.first == DefaultItemLayoutProperty::TYPE) + { + int layoutType = propertyPair.second.Get(); + if(layoutType <= DefaultItemLayout::SPIRAL && layoutType >= DefaultItemLayout::DEPTH) + { + //DEPTH, GRID, LIST, SPIRAL + switch(DefaultItemLayout::Type(layoutType)) + { + case DefaultItemLayout::DEPTH: + { + Internal::DepthLayoutPtr depthLayout = Internal::DepthLayout::New(); + (*depthLayout).SetLayoutProperties(*layout); + AddLayout(*depthLayout); + break; + } + case DefaultItemLayout::GRID: + { + Internal::GridLayoutPtr gridLayout = Internal::GridLayout::New(); + (*gridLayout).SetLayoutProperties(*layout); + AddLayout(*gridLayout); + break; + } + case DefaultItemLayout::LIST: + { + Internal::GridLayoutPtr listLayout = Internal::GridLayout::New(); + listLayout->SetNumberOfColumns( 1 ); + (*listLayout).SetLayoutProperties(*layout); + AddLayout(*listLayout); + break; + } + case DefaultItemLayout::SPIRAL: + { + Internal::SpiralLayoutPtr spiralLayout = Internal::SpiralLayout::New(); + (*spiralLayout).SetLayoutProperties(*layout); + AddLayout(*spiralLayout); + break; + } + } + } + } + } } } } @@ -1772,6 +1866,13 @@ Property::Value ItemView::GetProperty( BaseObject* object, Property::Index index value = itemViewImpl.GetRefreshInterval(); break; } + case Toolkit::DevelItemView::Property::LAYOUT: + { + Property::Array layouts= itemViewImpl.GetLayoutArray(); + value = layouts; + break; + } + } }