utc-Dali-TextLabel.cpp
utc-Dali-TextSelectionPopup.cpp
utc-Dali-ToolBar.cpp
+ utc-Dali-TransitionData.cpp
utc-Dali-Button.cpp
utc-Dali-Control.cpp
utc-Dali-ControlImpl.cpp
{
}
-
DummyControlImpl::~DummyControlImpl()
{
}
return Control::GetPlacementActor( index );
}
+Animation DummyControlImpl::CreateTransition( const Toolkit::TransitionData& transition )
+{
+ return Control::CreateTransition( transition );
+}
+
DummyControl DummyControlImplOverride::New()
{
IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
Toolkit::Visual::Base GetVisual( Property::Index index );
Actor GetPlacementActor( Property::Index index );
+ Animation CreateTransition( const Toolkit::TransitionData& transition );
// Used to test signal connections
void CustomSlot1( Actor actor );
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include "dummy-control.h"
+
+using namespace Dali;
+using namespace Toolkit;
+
+
+void utc_dali_toolkit_transition_data_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_toolkit_transition_data_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+Property::Map CreateMap()
+{
+ Property::Map map;
+
+ map["target"] = "Actor1";
+ map["property"] = "color";
+ map["initialValue"] = Color::MAGENTA;
+ map["targetValue"] = Color::RED;
+ map["animator"] = Property::Map()
+ .Add("alphaFunction", "EASE_IN_OUT_BACK")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.5f)
+ .Add("duration", 1.0f));
+ return map;
+}
+
+void CHECK_MAP_EQUALS( Property::Map test, Property::Map result )
+{
+ DALI_TEST_EQUALS(test.Count(), result.Count(), TEST_LOCATION);
+
+ for( unsigned int i=0; i< test.Count(); ++i )
+ {
+ KeyValuePair keyValue = test.GetKeyValue(i);
+ Property::Value* value;
+
+ if( keyValue.first.type == Property::Key::STRING )
+ {
+ value = result.Find(keyValue.first.stringKey);
+ }
+ else
+ {
+ value = result.Find(keyValue.first.indexKey);
+ }
+
+ DALI_TEST_CHECK( value != NULL );
+ if( value != NULL )
+ {
+ DALI_TEST_EQUALS( keyValue.second.GetType(), value->GetType(), TEST_LOCATION );
+ if( keyValue.second.GetType() == Property::MAP )
+ {
+ CHECK_MAP_EQUALS( *(keyValue.second.GetMap()), *(value->GetMap()) );
+ }
+ else if( keyValue.second.GetType() == Property::ARRAY )
+ {
+ }
+ else if( keyValue.second.GetType() == Property::STRING )
+ {
+ std::string str;
+ value->Get(str);
+ DALI_TEST_EQUALS( keyValue.second, str.c_str(), TEST_LOCATION );
+ }
+ else
+ {
+ DALI_TEST_EQUALS( keyValue.second, *value, 0.001f, TEST_LOCATION );
+ }
+ }
+ }
+}
+
+
+int UtcDaliTransitionDataNew(void)
+{
+ TestApplication application;
+
+ Property::Map map = CreateMap();
+ Dali::Toolkit::TransitionData transition = TransitionData::New( map );
+ DALI_TEST_CHECK( transition );
+
+ END_TEST;
+}
+
+int UtcDaliTransitionDataDownCast(void)
+{
+ TestApplication application;
+
+ Property::Map map = CreateMap();
+
+ BaseHandle handle = TransitionData::New( map );
+ DALI_TEST_CHECK( handle );
+
+ TransitionData transitionData = TransitionData::DownCast( handle );
+ DALI_TEST_CHECK( transitionData );
+ END_TEST;
+}
+
+int UtcDaliTransitionDataCopyConstructor(void)
+{
+ TestApplication application;
+
+ Property::Map map = CreateMap();
+
+ TransitionData transitionData = TransitionData::New( map );
+ DALI_TEST_CHECK( transitionData );
+
+ TransitionData td2( transitionData );
+ DALI_TEST_CHECK( td2 );
+ DALI_TEST_EQUALS( td2.Count(), 1, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliTransitionDataAssignmentOperator(void)
+{
+ TestApplication application;
+
+ Property::Map map = CreateMap();
+
+ TransitionData transitionData = TransitionData::New( map );
+ DALI_TEST_CHECK( transitionData );
+
+ TransitionData td2;
+ DALI_TEST_CHECK( !td2 );
+
+ td2 = transitionData;
+ DALI_TEST_CHECK( td2 );
+
+ DALI_TEST_EQUALS( td2.Count(), 1, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliTransitionDataCount(void)
+{
+ TestApplication application;
+
+ Property::Map map = CreateMap();
+ TransitionData transitionData = TransitionData::New( map );
+ DALI_TEST_CHECK( transitionData );
+ DALI_TEST_EQUALS( transitionData.Count(), 1, TEST_LOCATION );
+
+ Property::Array array;
+ array.PushBack( map );
+ array.PushBack( map );
+ array.PushBack( map );
+
+ TransitionData transitionData2 = TransitionData::New( array );
+ DALI_TEST_CHECK( transitionData2 );
+ DALI_TEST_EQUALS( transitionData2.Count(), 3, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTransitionDataMap1P(void)
+{
+ TestApplication application;
+
+ tet_printf("Testing animation of a visual property using stylesheet equivalent maps\n");
+
+ Property::Map map;
+ map["target"] = "visual1";
+ map["property"] = "mixColor";
+ map["initialValue"] = Color::MAGENTA;
+ map["targetValue"] = Color::RED;
+ map["animator"] = Property::Map()
+ .Add("alphaFunction", "EASE_IN_OUT")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.5f)
+ .Add("duration", 1.0f));
+
+ Dali::Toolkit::TransitionData transition = TransitionData::New( map );
+
+ DummyControl actor = DummyControl::New();
+ actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ actor.SetName("Actor1");
+ actor.SetColor(Color::CYAN);
+ Stage::GetCurrent().Add(actor);
+
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+
+ Property::Map visualMap;
+ visualMap[Visual::Property::TYPE] = Visual::COLOR;
+ visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
+ Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
+ visual.SetName( "visual1" );
+
+ Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
+ dummyImpl.RegisterVisual( visualIndex, actor, visual );
+
+ Animation anim = dummyImpl.CreateTransition( transition );
+ DALI_TEST_CHECK( anim );
+
+ Renderer renderer = actor.GetRendererAt(0);
+ Property::Index mixColorIndex = renderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR );
+ application.SendNotification();
+ application.Render(0);
+
+ DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), Color::MAGENTA, TEST_LOCATION);
+
+ anim.Play();
+
+ application.SendNotification();
+ application.Render(0);
+ application.Render(500); // Start animation
+ application.Render(500); // Halfway thru anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
+
+ application.Render(500); // End of anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), Color::RED, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTransitionDataMap2P(void)
+{
+ TestApplication application;
+
+ tet_printf("Testing animation of a visual property using programmatic maps\n");
+
+ Property::Map map;
+ map["target"] = "visual1";
+ //Control::CONTROL_PROPERTY_END_INDEX + 1
+ map["property"] = ColorVisual::Property::MIX_COLOR;
+ map["initialValue"] = Color::MAGENTA;
+ map["targetValue"] = Color::RED;
+ map["animator"] = Property::Map()
+ .Add("alphaFunction", "LINEAR")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.5f)
+ .Add("duration", 1.0f));
+
+ Dali::Toolkit::TransitionData transition = TransitionData::New( map );
+
+ DummyControl actor = DummyControl::New();
+ actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ actor.SetName("Actor1");
+ actor.SetColor(Color::CYAN);
+ Stage::GetCurrent().Add(actor);
+
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+
+ Property::Map visualMap;
+ visualMap[Visual::Property::TYPE] = Visual::COLOR;
+ visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
+ Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
+ visual.SetName( "visual1" );
+
+ Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
+ dummyImpl.RegisterVisual( visualIndex, actor, visual );
+
+ Animation anim = dummyImpl.CreateTransition( transition );
+ DALI_TEST_CHECK( anim );
+
+ Renderer renderer = actor.GetRendererAt(0);
+ Property::Index mixColorIndex = renderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR );
+ application.SendNotification();
+ application.Render(0);
+
+ DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), Color::MAGENTA, TEST_LOCATION);
+
+ anim.Play();
+
+ application.SendNotification();
+ application.Render(0);
+ application.Render(500); // Start animation
+ application.Render(500); // Halfway thru anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
+
+ application.Render(500); // End of anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(mixColorIndex), Color::RED, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliTransitionDataMapP3(void)
+{
+ TestApplication application;
+
+ tet_printf("Testing animation of a visual's placement actor property\n");
+
+ Property::Map map;
+ map["target"] = "visual1";
+ map["property"] = "color";
+ map["initialValue"] = Color::MAGENTA;
+ map["targetValue"] = Color::RED;
+ map["animator"] = Property::Map()
+ .Add("alphaFunction", "EASE_IN_OUT")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.5f)
+ .Add("duration", 1.0f));
+
+ Dali::Toolkit::TransitionData transition = TransitionData::New( map );
+
+ DummyControl actor = DummyControl::New();
+ actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ actor.SetName("Actor1");
+ actor.SetColor(Color::CYAN);
+ Stage::GetCurrent().Add(actor);
+
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+
+ Property::Map visualMap;
+ visualMap[Visual::Property::TYPE] = Visual::COLOR;
+ visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
+ Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
+ visual.SetName( "visual1" );
+
+ Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
+ dummyImpl.RegisterVisual( visualIndex, actor, visual );
+
+ Animation anim = dummyImpl.CreateTransition( transition );
+ DALI_TEST_CHECK( anim );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION);
+
+ anim.Play();
+
+ application.SendNotification();
+ application.Render(0);
+ application.Render(500);
+ application.Render(500); // Halfway thru map1 anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetCurrentColor(), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
+
+ application.Render(500); // End of map1 anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::RED, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliTransitionDataMap1N(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ map["target"] = "Actor1";
+ map["property"] = "randomProperty";
+ map["initialValue"] = Color::MAGENTA;
+ map["targetValue"] = Color::RED;
+ map["animator"] = Property::Map()
+ .Add("alphaFunction", "EASE_OUT")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.5f)
+ .Add("duration", 1.0f));
+
+ Dali::Toolkit::TransitionData transition = TransitionData::New( map );
+
+ DummyControl actor = DummyControl::New();
+ actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ actor.SetName("Actor1");
+ actor.SetColor(Color::CYAN);
+ Stage::GetCurrent().Add(actor);
+
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ Animation anim = dummyImpl.CreateTransition( transition );
+ DALI_TEST_CHECK( ! anim );
+
+ CHECK_MAP_EQUALS( map, transition.GetAnimatorAt(0) );
+ END_TEST;
+}
+
+
+int UtcDaliTransitionDataMapN3(void)
+{
+ TestApplication application;
+
+ tet_printf("Testing visual lookup with no renderers\n");
+
+ Property::Map map;
+ map["target"] = "visual1";
+ map["property"] = "mixColor";
+ map["initialValue"] = Color::MAGENTA;
+ map["targetValue"] = Color::RED;
+ map["animator"] = Property::Map()
+ .Add("alphaFunction", "EASE_OUT_BACK")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.5f)
+ .Add("duration", 1.0f));
+
+ Dali::Toolkit::TransitionData transition = TransitionData::New( map );
+ CHECK_MAP_EQUALS( map, transition.GetAnimatorAt(0) );
+
+ DummyControl actor = DummyControl::New();
+ actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ actor.SetName("Actor1");
+ actor.SetColor(Color::CYAN);
+ // Don't stage actor
+
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ Property::Map visualMap;
+ visualMap[Visual::Property::TYPE] = Visual::COLOR;
+ visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
+ Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
+ visual.SetName( "visual1" );
+
+ Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
+ dummyImpl.RegisterVisual( visualIndex, actor, visual );
+
+ Animation anim = dummyImpl.CreateTransition( transition );
+ DALI_TEST_CHECK( !anim );
+ END_TEST;
+}
+
+int UtcDaliTransitionDataArrayP(void)
+{
+ TestApplication application;
+
+ Property::Map map1;
+ map1["target"] = "Actor1";
+ map1["property"] = "color";
+ map1["initialValue"] = Color::MAGENTA;
+ map1["targetValue"] = Color::RED;
+ map1["animator"] = Property::Map()
+ .Add("alphaFunction", "EASE_IN_OUT")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.5f)
+ .Add("duration", 1.0f));
+
+ Property::Map map2;
+ map2["target"] = "Actor1";
+ map2["property"] = "position";
+ map2["initialValue"] = Vector3(100,0,0);
+ map2["targetValue"] = Vector3(0,100,0);
+ map2["animator"] = Property::Map()
+ .Add("alphaFunction", "EASE_IN_OUT")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.0f)
+ .Add("duration", 1.0f));
+
+ Property::Map map3;
+ map3["target"] = "Actor1";
+ map3["property"] = "orientation";
+ map3["targetValue"] = Quaternion( Radian(Math::PI_2), Vector3::ZAXIS );
+
+ Property::Array array;
+ array.PushBack(map1);
+ array.PushBack(map2);
+ array.PushBack(map3);
+
+ Dali::Toolkit::TransitionData transition = TransitionData::New( array );
+
+ DummyControl actor = DummyControl::New();
+ actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+ actor.SetName("Actor1");
+ actor.SetColor(Color::CYAN);
+ Stage::GetCurrent().Add(actor);
+ DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0), Vector3::ZAXIS), TEST_LOCATION);
+
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ Animation anim = dummyImpl.CreateTransition( transition );
+ DALI_TEST_CHECK( anim );
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION);
+ DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(Math::PI_2), Vector3::ZAXIS), TEST_LOCATION);
+ anim.Play();
+
+ application.SendNotification();
+ application.Render(0); // start map2 anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,0,0), TEST_LOCATION);
+
+ application.Render(500); // Start map1 animation, halfway thru map2 anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(50,50,0), TEST_LOCATION);
+
+ application.Render(500); // Halfway thru map1 anim, end of map2 anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0,100,0), TEST_LOCATION);
+ DALI_TEST_EQUALS( actor.GetCurrentColor(), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
+
+ application.Render(500); // End of map1 anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::RED, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliTransitionDataGetAnimatorP(void)
+{
+ TestApplication application;
+
+ Property::Map map1;
+ map1["target"] = "Actor1";
+ map1["property"] = "color";
+ map1["initialValue"] = Color::MAGENTA;
+ map1["targetValue"] = Color::RED;
+ map1["animator"] = Property::Map()
+ .Add("alphaFunction", "EASE_IN_SQUARE")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.5f)
+ .Add("duration", 0.5f));
+
+ Property::Map map2;
+ map2["target"] = "Actor1";
+ map2["property"] = "position";
+ map2["initialValue"] = Vector3(100,0,0);
+ map2["targetValue"] = Vector3(0,100,0);
+ map2["animator"] = Property::Map()
+ .Add("alphaFunction", "EASE_OUT_SQUARE")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.2f)
+ .Add("duration", 2.0f));
+
+ Property::Map map3;
+ map3["target"] = "Actor1";
+ map3["property"] = "size";
+ map3["initialValue"] = Vector2(10,10);
+ map3["targetValue"] = Vector2(100,100);
+ map3["animator"] = Property::Map()
+ .Add("alphaFunction", "EASE_OUT_SINE")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.4f)
+ .Add("duration", 3.0f));
+
+ Property::Map map4;
+ map4["target"] = "Actor2";
+ map4["property"] = "color";
+ map4["initialValue"] = Color::BLACK;
+ map4["targetValue"] = Color::GREEN;
+ map4["animator"] = Property::Map()
+ .Add("alphaFunction", "EASE_IN_OUT_SINE")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.5f)
+ .Add("duration", 0.5f));
+
+ Property::Map map5;
+ map5["target"] = "Actor2";
+ map5["property"] = "position";
+ map5["initialValue"] = Vector3(100,0,0);
+ map5["targetValue"] = Vector3(0,100,0);
+ map5["animator"] = Property::Map()
+ .Add("alphaFunction", "BOUNCE")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.2f)
+ .Add("duration", 2.0f));
+
+ Property::Map map6;
+ map6["target"] = "Actor2";
+ map6["property"] = "size";
+ map6["initialValue"] = Vector2(10,10);
+ map6["targetValue"] = Vector2(100,100);
+ map6["animator"] = Property::Map()
+ .Add("alphaFunction", "SIN")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.4f)
+ .Add("duration", 3.0f));
+
+ Property::Map map7;
+ map7["target"] = "Actor4";
+ map7["property"] = "sizeModeFactor";
+ map7["initialValue"] = Vector3(1,1,1);
+ map7["targetValue"] = Vector3(2,2,2);
+ map7["animator"] = Property::Map()
+ .Add("alphaFunction", "EASE_IN_SINE")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.0f)
+ .Add("duration", 1.0f));
+
+ Property::Map map8;
+ map8["target"] = "Visual1";
+ map8["property"] = "colorAlpha";
+ map8["targetValue"] = 1.0f;
+ map8["animator"] = Property::Map()
+ .Add("alphaFunction", "EASE_IN")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.3f)
+ .Add("duration", 9.0f));
+
+ Property::Map map9;
+ map9["target"] = "Actor2";
+ map9["property"] = "scale";
+ map9["initialValue"] = Vector3(0,0,0);
+ map9["targetValue"] = Vector3(1,1,1);
+ map9["animator"] = Property::Map()
+ .Add("alphaFunction", "REVERSE")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.0f)
+ .Add("duration", 1.0f));
+
+ Property::Map map10;
+ map10["target"] = "Actor1";
+ map10["property"] = "orientation";
+ map10["targetValue"] = Quaternion( Radian(Math::PI_2), Vector3::ZAXIS );
+
+ Property::Array array;
+ array.PushBack(map1);
+ array.PushBack(map2);
+ array.PushBack(map3);
+ array.PushBack(map4);
+ array.PushBack(map5);
+ array.PushBack(map6);
+ array.PushBack(map7);
+ array.PushBack(map8);
+ array.PushBack(map9);
+ array.PushBack(map10);
+
+ Dali::Toolkit::TransitionData transition = TransitionData::New( array );
+
+ DALI_TEST_EQUALS( transition.Count(), array.Count(), TEST_LOCATION );
+
+ for( unsigned int i=0; i < array.Count(); ++i )
+ {
+ Property::Map animatorMap = transition.GetAnimatorAt(i);
+ Property::Value& value = array.GetElementAt(i);
+ Property::Map* inputMap = value.GetMap();
+ DALI_TEST_CHECK( inputMap );
+ CHECK_MAP_EQUALS( *inputMap, animatorMap );
+ }
+
+ END_TEST;
+}
#include <dali/public-api/rendering/shader.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/dali-toolkit.h>
+#include "dummy-control.h"
using namespace Dali;
using namespace Dali::Toolkit;
END_TEST;
}
+int UtcDaliVisualSetName01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualSetName" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+
+ const char* visualName = "backgroundVisual";
+ visual.SetName( visualName );
+
+ DALI_TEST_EQUALS( visual.GetName(), visualName, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliVisualSetGetDepthIndex(void)
{
ToolkitTestApplication application;
$(devel_api_src_dir)/transition-effects/cube-transition-effect.cpp \
$(devel_api_src_dir)/transition-effects/cube-transition-fold-effect.cpp \
$(devel_api_src_dir)/transition-effects/cube-transition-wave-effect.cpp \
+ $(devel_api_src_dir)/visual-factory/transition-data.cpp \
$(devel_api_src_dir)/visual-factory/visual-factory.cpp \
$(devel_api_src_dir)/visual-factory/visual-base.cpp \
$(devel_api_src_dir)/controls/gaussian-blur-view/gaussian-blur-view.cpp
$(devel_api_src_dir)/controls/progress-bar/progress-bar.h
devel_api_visual_factory_header_files = \
+ $(devel_api_src_dir)/visual-factory/transition-data.h \
$(devel_api_src_dir)/visual-factory/visual-factory.h \
$(devel_api_src_dir)/visual-factory/visual-base.h
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
+#include <dali-toolkit/internal/visuals/transition-data-impl.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+TransitionData::TransitionData()
+{
+}
+
+TransitionData::~TransitionData()
+{
+}
+
+TransitionData TransitionData::New( const Property::Array& transition )
+{
+ Internal::TransitionDataPtr transitionData = Internal::TransitionData::New( transition );
+ return TransitionData( transitionData.Get() );
+}
+
+TransitionData TransitionData::New( const Property::Map& transition )
+{
+ Internal::TransitionDataPtr transitionData = Internal::TransitionData::New( transition );
+ return TransitionData( transitionData.Get() );
+}
+
+TransitionData TransitionData::DownCast( BaseHandle handle )
+{
+ return TransitionData( dynamic_cast<Dali::Toolkit::Internal::TransitionData*>(handle.GetObjectPtr()));
+}
+
+TransitionData::TransitionData( const TransitionData& handle )
+: BaseHandle( handle )
+{
+}
+
+TransitionData& TransitionData::operator=( const TransitionData& handle )
+{
+ BaseHandle::operator=( handle );
+ return *this;
+}
+
+size_t TransitionData::Count() const
+{
+ return GetImplementation( *this ).Count();
+}
+
+Property::Map TransitionData::GetAnimatorAt( size_t index )
+{
+ return GetImplementation( *this ).GetAnimatorAt( index );
+}
+
+TransitionData::TransitionData( Internal::TransitionData* pointer )
+: BaseHandle( pointer )
+{
+}
+
+} // namespace Toolkit
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_TOOLKIT_TRANSITION_DATA_H__
+#define __DALI_TOOLKIT_TRANSITION_DATA_H__
+
+/*
+ * Copyright (c) 2016 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 <dali/public-api/object/base-handle.h>
+#include <dali/public-api/animation/alpha-function.h>
+#include <dali/public-api/object/property-array.h>
+#include <dali/public-api/object/property-map.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+class TransitionData;
+}
+
+/**
+ * @brief This object translates data from a property array of maps
+ * into an array of animators.
+ *
+ * Each animator describes a named object and a named property of that object
+ * to be animated. Internally, these are translated into object instances and
+ * property indices to be animated.
+ * @see Dali::Toolkit::Internal::Control::CreateTransition()
+ *
+ * The animators can each be retrieved as a Property::Map by using Count() and
+ * GetAnimatorAt().
+ *
+ * In psuedo-JSON, the property array can be represented as follows:
+ *
+ * [
+ * {
+ * "target": "objectName",
+ * "property": "propertyKey",
+ * "initialValue": <value>, # The property value can be one of several types
+ * "targetValue": <value>,
+ * "animator": {
+ * "alphaFunction":<easing-function>",
+ * "timePeriod":{
+ * "duration": 1.0,
+ * "delay": 0.0
+ * }
+ * }
+ * },
+ * # more animators
+ * ]
+ *
+ */
+class DALI_IMPORT_API TransitionData : public BaseHandle
+{
+public:
+ /**
+ * Create an uninitialized handle
+ *
+ * @SINCE_1_2.12
+ */
+ TransitionData();
+
+ /**
+ * Destructor - non virtual
+ *
+ * @SINCE_1_2.12
+ */
+ ~TransitionData();
+
+ /**
+ * @brief Creates a TransitionData object
+ *
+ * @SINCE_1_2.12
+ * @param[in] transition The transition data to store (a single animator)
+ * @return A handle to an initialized data.
+ */
+ static TransitionData New( const Property::Map& transition );
+
+ /**
+ * @brief Creates a TransitionData object
+ *
+ * @SINCE_1_2.12
+ * @param[in] transition The transition data to store (an array of maps of animators)
+ * @return A handle to an initialized data.
+ */
+ static TransitionData New( const Property::Array& transition );
+
+ /**
+ * @brief Downcast to a TransitionData handle
+ *
+ * @SINCE_1_2.12
+ * If handle is not a TransitionData, the returned handle is left uninitialized.
+ * @param[in] handle Handle to an object
+ * @return TransitionData handle or an uninitialized handle.
+ */
+ static TransitionData DownCast( BaseHandle handle );
+
+ /**
+ * @brief Copy constructor
+ *
+ * @SINCE_1_2.12
+ * @param[in] handle Handle to an object
+ */
+ TransitionData( const TransitionData& handle );
+
+ /**
+ * @brief Assignment Operator
+ *
+ * @SINCE_1_2.12
+ * @param[in] handle Handle to an object
+ * @return A reference to this object.
+ */
+ TransitionData& operator=( const TransitionData& handle );
+
+ /**
+ * @brief returns the count of the individual property transitions
+ * stored within this handle.
+ *
+ * @SINCE_1_2.12
+ * @return The count of individual transitions
+ */
+ size_t Count() const;
+
+ /**
+ * @brief Return the animator at the given index as a property map.
+ * @param[in] index The index of the animator ( Must be less than Count() )
+ * @return A property map representing the animator
+ */
+ Property::Map GetAnimatorAt( size_t index );
+
+public: // Not intended for application developers
+
+ explicit DALI_INTERNAL TransitionData( Internal::TransitionData *impl );
+};
+
+} // namespace Toolkit
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_TRANSITION_DATA_H__
{
}
+void Visual::Base::SetName( const std::string& name )
+{
+ GetImplementation( *this ).SetName( name );
+}
+
+const std::string& Visual::Base::GetName()
+{
+ return GetImplementation( *this ).GetName();
+}
+
void Visual::Base::SetSize( const Vector2& size )
{
GetImplementation( *this ).SetSize( size );
Base& operator=( const Base& handle );
/**
+ * @brief Set the name of the visual
+ *
+ * Used by the styling system to animate properties
+ * @param[in] name The name to give the visual
+ */
+ void SetName( const std::string& name );
+
+ /**
+ * @brief Get the name of the visual
+ *
+ * Used by the styling system to animate properties
+ * @return The name of the visual
+ */
+ const std::string& GetName();
+
+ /**
* @brief Set the size of the painting area.
*
* @param[in] size The size of the painting area.
} // namespace Toolkit
} // namespace Dali
-
$(toolkit_src_dir)/visuals/svg/svg-rasterize-thread.cpp \
$(toolkit_src_dir)/visuals/svg/svg-visual.cpp \
$(toolkit_src_dir)/visuals/wireframe/wireframe-visual.cpp \
+ $(toolkit_src_dir)/visuals/transition-data-impl.cpp \
$(toolkit_src_dir)/controls/alignment/alignment-impl.cpp \
$(toolkit_src_dir)/controls/bloom-view/bloom-view-impl.cpp \
$(toolkit_src_dir)/controls/bubble-effect/bubble-emitter-impl.cpp \
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/visuals/transition-data-impl.h>
+
+// EXTERNAL HEADERS
+#include <dali/dali.h>
+#include <dali/devel-api/scripting/enum-helper.h>
+#include <dali/integration-api/debug.h>
+#include <dali-toolkit/public-api/controls/control.h>
+#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <sstream>
+
+using namespace Dali;
+
+namespace
+{
+const char* TOKEN_TARGET("target");
+const char* TOKEN_PROPERTY("property");
+const char* TOKEN_INITIAL_VALUE("initialValue");
+const char* TOKEN_TARGET_VALUE("targetValue");
+const char* TOKEN_ANIMATOR("animator");
+const char* TOKEN_TIME_PERIOD("timePeriod");
+const char* TOKEN_DURATION("duration");
+const char* TOKEN_DELAY("delay");
+const char* TOKEN_ALPHA_FUNCTION("alphaFunction");
+
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN( ALPHA_FUNCTION_BUILTIN )
+DALI_ENUM_TO_STRING_WITH_SCOPE(AlphaFunction, LINEAR)
+DALI_ENUM_TO_STRING_WITH_SCOPE(AlphaFunction, REVERSE)
+DALI_ENUM_TO_STRING_WITH_SCOPE(AlphaFunction, EASE_IN)
+DALI_ENUM_TO_STRING_WITH_SCOPE(AlphaFunction, EASE_OUT)
+DALI_ENUM_TO_STRING_WITH_SCOPE(AlphaFunction, EASE_IN_OUT)
+DALI_ENUM_TO_STRING_WITH_SCOPE(AlphaFunction, EASE_IN_SQUARE)
+DALI_ENUM_TO_STRING_WITH_SCOPE(AlphaFunction, EASE_OUT_SQUARE)
+DALI_ENUM_TO_STRING_WITH_SCOPE(AlphaFunction, EASE_IN_SINE)
+DALI_ENUM_TO_STRING_WITH_SCOPE(AlphaFunction, EASE_OUT_SINE)
+DALI_ENUM_TO_STRING_WITH_SCOPE(AlphaFunction, EASE_IN_OUT_SINE)
+DALI_ENUM_TO_STRING_WITH_SCOPE(AlphaFunction, EASE_OUT_BACK)
+DALI_ENUM_TO_STRING_WITH_SCOPE(AlphaFunction, BOUNCE)
+DALI_ENUM_TO_STRING_WITH_SCOPE(AlphaFunction, SIN)
+DALI_ENUM_TO_STRING_TABLE_END( ALPHA_FUNCTION_BUILTIN )
+}
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+
+TransitionData::TransitionData()
+{
+}
+
+TransitionData::~TransitionData()
+{
+}
+
+TransitionDataPtr TransitionData::New( const Property::Array& value )
+{
+ TransitionDataPtr transitionData( new TransitionData() );
+ transitionData->Initialize(value);
+ return transitionData;
+}
+
+TransitionDataPtr TransitionData::New( const Property::Map& value )
+{
+ TransitionDataPtr transitionData( new TransitionData() );
+ transitionData->Initialize(value);
+ return transitionData;
+}
+
+
+void TransitionData::Initialize( const Property::Map& map )
+{
+ TransitionData::Animator* animator = ConvertMap( map );
+ Add( animator );
+}
+
+void TransitionData::Initialize( const Property::Array& array )
+{
+ for( unsigned int arrayIdx = 0, transitionArrayCount = array.Count(); arrayIdx < transitionArrayCount; ++arrayIdx )
+ {
+ const Property::Value& element = array.GetElementAt( arrayIdx );
+ // Expect each child to be an object representing an animator:
+
+ Property::Map* map = element.GetMap();
+ if( map != NULL )
+ {
+ TransitionData::Animator* animator = ConvertMap( *map );
+ Add( animator );
+ }
+ }
+}
+
+TransitionData::Animator* TransitionData::ConvertMap( const Property::Map& map)
+{
+ TransitionData::Animator* animator = new TransitionData::Animator();
+ animator->alphaFunction = AlphaFunction::LINEAR;
+ animator->timePeriodDelay = 0.0f;
+ animator->timePeriodDuration = 1.0f;
+
+ for( unsigned int mapIdx = 0; mapIdx < map.Count(); ++mapIdx )
+ {
+ const KeyValuePair pair( map.GetKeyValue( mapIdx ) );
+ if( pair.first.type == Property::Key::INDEX )
+ {
+ continue; // We don't consider index keys.
+ }
+
+ const std::string& key( pair.first.stringKey );
+ const Property::Value& value( pair.second );
+
+ if( key == TOKEN_TARGET )
+ {
+ animator->objectName = value.Get< std::string >();
+ }
+ else if( key == TOKEN_PROPERTY )
+ {
+ if( value.GetType() == Property::STRING )
+ {
+ animator->propertyKey = Property::Key( value.Get<std::string>() );
+ }
+ else
+ {
+ animator->propertyKey = Property::Key( value.Get<int>() );
+ }
+ }
+ else if( key == TOKEN_INITIAL_VALUE )
+ {
+ animator->initialValue = value;
+ }
+ else if( key == TOKEN_TARGET_VALUE )
+ {
+ animator->targetValue = value;
+ }
+ else if( key == TOKEN_ANIMATOR )
+ {
+ animator->animate = true;
+ Property::Map animatorMap = value.Get< Property::Map >();
+ for( size_t animatorMapIdx = 0; animatorMapIdx < animatorMap.Count(); ++animatorMapIdx )
+ {
+ const KeyValuePair pair( animatorMap.GetKeyValue( animatorMapIdx ) );
+
+ if( pair.first.type == Property::Key::INDEX )
+ {
+ continue; // We don't consider index keys.
+ }
+
+ const std::string& key( pair.first.stringKey );
+ const Property::Value& value( pair.second );
+
+ if( key == TOKEN_ALPHA_FUNCTION )
+ {
+ std::string alphaFunctionValue = value.Get< std::string >();
+
+ if( alphaFunctionValue == "LINEAR" )
+ {
+ animator->alphaFunction = AlphaFunction::LINEAR;
+ }
+ else if( ! alphaFunctionValue.compare(0, 5, "EASE_" ) )
+ {
+ if( alphaFunctionValue == "EASE_IN" )
+ {
+ animator->alphaFunction = AlphaFunction::EASE_IN;
+ }
+ else if( alphaFunctionValue == "EASE_OUT" )
+ {
+ animator->alphaFunction = AlphaFunction::EASE_OUT;
+ }
+ else if( ! alphaFunctionValue.compare( 5, 3, "IN_" ) )
+ {
+ if( ! alphaFunctionValue.compare(8, -1, "SQUARE" ))
+ {
+ animator->alphaFunction = AlphaFunction::EASE_IN_SQUARE;
+ }
+ else if( ! alphaFunctionValue.compare(8, -1, "OUT" ))
+ {
+ animator->alphaFunction = AlphaFunction::EASE_IN_OUT;
+ }
+ else if( ! alphaFunctionValue.compare(8, -1, "OUT_SINE" ))
+ {
+ animator->alphaFunction = AlphaFunction::EASE_IN_OUT_SINE;
+ }
+ else if( ! alphaFunctionValue.compare(8, -1, "SINE" ))
+ {
+ animator->alphaFunction = AlphaFunction::EASE_IN_SINE;
+ }
+ }
+ else if( ! alphaFunctionValue.compare( 5, 4, "OUT_" ) )
+ {
+ if( ! alphaFunctionValue.compare(9, -1, "SQUARE" ) )
+ {
+ animator->alphaFunction = AlphaFunction::EASE_OUT_SQUARE;
+ }
+ else if( ! alphaFunctionValue.compare(9, -1, "SINE" ) )
+ {
+ animator->alphaFunction = AlphaFunction::EASE_OUT_SINE;
+ }
+ else if( ! alphaFunctionValue.compare(9, -1, "BACK" ) )
+ {
+ animator->alphaFunction = AlphaFunction::EASE_OUT_BACK;
+ }
+ }
+ }
+ else if( alphaFunctionValue == "REVERSE" )
+ {
+ animator->alphaFunction = AlphaFunction::REVERSE;
+ }
+ else if( alphaFunctionValue == "BOUNCE" )
+ {
+ animator->alphaFunction = AlphaFunction::BOUNCE;
+ }
+ else if( alphaFunctionValue == "SIN" )
+ {
+ animator->alphaFunction = AlphaFunction::SIN;
+ }
+ }
+ else if( key == TOKEN_TIME_PERIOD )
+ {
+ Property::Map timeMap = value.Get< Property::Map >();
+ for( size_t timeMapIdx = 0; timeMapIdx < timeMap.Count(); ++timeMapIdx )
+ {
+ const KeyValuePair pair( timeMap.GetKeyValue( timeMapIdx ) );
+ if( pair.first.type == Property::Key::INDEX )
+ {
+ continue;
+ }
+ const std::string& key( pair.first.stringKey );
+
+ if( key == TOKEN_DELAY )
+ {
+ animator->timePeriodDelay = pair.second.Get< float >();
+ }
+ else if( key == TOKEN_DURATION )
+ {
+ animator->timePeriodDuration = pair.second.Get< float >();
+ }
+ }
+ }
+ }
+ }
+ }
+ return animator;
+}
+
+void TransitionData::Add( Animator* animator )
+{
+ mAnimators.PushBack( animator );
+}
+
+TransitionData::Iterator TransitionData::Begin() const
+{
+ return mAnimators.Begin();
+}
+
+TransitionData::Iterator TransitionData::End() const
+{
+ return mAnimators.End();
+}
+
+size_t TransitionData::Count() const
+{
+ return mAnimators.Count();
+}
+
+Property::Map TransitionData::GetAnimatorAt( size_t index )
+{
+ DALI_ASSERT_ALWAYS( index < Count() && "index exceeds bounds" );
+
+ Animator* animator = mAnimators[index];
+ Property::Map map;
+ map[TOKEN_TARGET] = animator->objectName;
+ if( animator->propertyKey.type == Property::Key::INDEX )
+ {
+ map[TOKEN_PROPERTY] = animator->propertyKey.indexKey;
+ }
+ else
+ {
+ map[TOKEN_PROPERTY] = animator->propertyKey.stringKey;
+ }
+ if( animator->initialValue.GetType() != Property::NONE )
+ {
+ map[TOKEN_INITIAL_VALUE] = animator->initialValue;
+ }
+ if( animator->targetValue.GetType() != Property::NONE )
+ {
+ map[TOKEN_TARGET_VALUE] = animator->targetValue;
+ }
+ if( animator->animate )
+ {
+ map[TOKEN_ANIMATOR] = Property::Map()
+ .Add(TOKEN_ALPHA_FUNCTION, GetEnumerationName( animator->alphaFunction,
+ ALPHA_FUNCTION_BUILTIN_TABLE,
+ ALPHA_FUNCTION_BUILTIN_TABLE_COUNT ))
+ .Add(TOKEN_TIME_PERIOD, Property::Map()
+ .Add( TOKEN_DELAY, animator->timePeriodDelay )
+ .Add( TOKEN_DURATION, animator->timePeriodDuration ));
+ }
+
+ return map;
+}
+
+} // namespace Internal
+} // namespace Toolkit
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_INTERNAL_TRANSITION_DATA_H
+#define DALI_TOOLKIT_INTERNAL_TRANSITION_DATA_H
+
+/*
+ * Copyright (c) 2016 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 <dali/public-api/object/base-object.h>
+#include <dali/public-api/animation/alpha-function.h>
+#include <dali/public-api/object/property-key.h>
+#include <dali/devel-api/common/owner-container.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+
+class TransitionData;
+typedef IntrusivePtr<TransitionData> TransitionDataPtr;
+
+/**
+ * TransitionData is an object that holds animator data.
+ */
+class TransitionData : public BaseObject
+{
+public:
+
+ /**
+ * @brief TransitionDataElement Describes one animator of an transition.
+ */
+ struct Animator
+ {
+ Animator()
+ : propertyKey( Property::INVALID_INDEX ),
+ alphaFunction( AlphaFunction::DEFAULT ),
+ timePeriodDelay( 0.0f ),
+ timePeriodDuration( 1.0f ),
+ animate(false)
+ {
+ }
+
+ std::string objectName; ///< An identifier of the actor or visual
+ Property::Key propertyKey; ///< A property key of the property owner
+ Property::Value initialValue; ///< The value to set at the start of the transition
+ Property::Value targetValue; ///< The value to set or animate to
+ Dali::AlphaFunction::BuiltinFunction alphaFunction;
+ float timePeriodDelay;
+ float timePeriodDuration;
+ bool animate;
+ };
+
+ /**
+ * @brief TransitionData holds the required data required to define an
+ * transition to be performed on a property owner
+ */
+ typedef Dali::OwnerContainer< Animator* > AnimatorList;
+ typedef AnimatorList::Iterator Iterator;
+
+public:
+ /**
+ * @copydoc Dali::Transition::New()
+ */
+ static TransitionDataPtr New( const Property::Array& value );
+
+ /**
+ * @copydoc Dali::Transition::New()
+ */
+ static TransitionDataPtr New( const Property::Map& value );
+
+ /**
+ * @brief Iterator to the beginning of the data
+ */
+ Iterator Begin() const;
+
+ /**
+ * @brief Iterator to the end of the data (one past last element)
+ */
+ Iterator End() const;
+
+ /**
+ * @copydoc Dali::Transition::Count()
+ */
+ size_t Count() const;
+
+ /**
+ * @copydoc Dali::Transition::GetAnimatorAt()
+ */
+ Property::Map GetAnimatorAt( size_t index );
+
+private: // Implementation
+ /**
+ * Ref counted object - Only allow construction via New().
+ */
+ TransitionData();
+
+ /**
+ * Second stage initialiazation
+ */
+ void Initialize( const Property::Map& value );
+
+ /**
+ * Second stage initialiazation
+ */
+ void Initialize( const Property::Array& value );
+
+ /**
+ * @brief Adds one Animator to the list to describe a transition.
+ * @param[in] animator An animator data structure
+ */
+ void Add( Animator* animator );
+
+ /**
+ * Convert a Property map into Animator data
+ */
+ Animator* ConvertMap( const Property::Map& map );
+
+protected:
+ /**
+ * A ref counted object may only be deleted by calling Unreference
+ */
+ virtual ~TransitionData();
+
+private: // Unimplemented methods
+ TransitionData( const TransitionData& );
+ TransitionData& operator=( const TransitionData& );
+
+private: // Data members
+ AnimatorList mAnimators; ///< A vector of individual property transitions from which to generate a Dali::Animation.
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+inline Internal::TransitionData& GetImplementation( Dali::Toolkit::TransitionData& handle )
+{
+ DALI_ASSERT_ALWAYS(handle && "TransitionData handle is empty");
+ BaseObject& object = handle.GetBaseObject();
+ return static_cast<Internal::TransitionData&>(object);
+}
+
+inline const Internal::TransitionData& GetImplementation( const Dali::Toolkit::TransitionData& handle )
+{
+ DALI_ASSERT_ALWAYS(handle && "TransitionData handle is empty");
+ const BaseObject& object = handle.GetBaseObject();
+ return static_cast<const Internal::TransitionData&>(object);
+}
+
+} // namespace Toolkit
+} // namespace Dali
+
+
+#endif // DALI_TOOLKIT_INTERNAL_TRANSITION_DATA_H
void CreatePropertyMap( Property::Map& map ) const;
};
- Renderer mRenderer;
-
+ Renderer mRenderer;
CustomShader* mCustomShader;
-
- Vector2 mSize;
- float mDepthIndex;
- int mFlags;
+ std::string mName;
+ Vector2 mSize;
+ float mDepthIndex;
+ int mFlags;
Impl();
~Impl();
}
else
{
- mImpl->mCustomShader = new Impl::CustomShader( shaderMap );
+ mImpl->mCustomShader = new Impl::CustomShader( shaderMap );
}
}
DoInitialize( actor, propertyMap );
}
+void Visual::Base::SetName( const std::string& name )
+{
+ mImpl->mName = name;
+}
+
+const std::string& Visual::Base::GetName()
+{
+ return mImpl->mName;
+}
+
void Visual::Base::SetSize( const Vector2& size )
{
mImpl->mSize = size;
void Initialize( Actor& actor, const Property::Map& propertyMap );
/**
+ * @copydoc Toolkit::Visual::Base::SetName
+ */
+ void SetName( const std::string& name );
+
+ /**
+ * @copydoc Toolkit::Visual::Base::GetName
+ */
+ const std::string& GetName();
+
+ /**
* @copydoc Toolkit::Visual::Base::SetSize
*/
virtual void SetSize( const Vector2& size );
#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#include <dali-toolkit/internal/visuals/color/color-visual.h>
+#include <dali-toolkit/internal/visuals/transition-data-impl.h>
namespace Dali
{
namespace
{
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gLogFilter = Debug::Filter::New( Debug::General, false, "LOG_CONTROL_VISUALS");
+#endif
+
/**
* Struct used to store Visual within the control, index is a unique key for each visual.
*/
index(aIndex), visual(aVisual), placementActor(aPlacementActor), enabled(aEnabled) {}
};
+struct VisualProperty
+{
+ Handle handle; ///< a handle to the target object
+ Property::Index index; ///< The index of a property provided by the referenced object
+
+ VisualProperty( )
+ : handle(),
+ index( Property::INVALID_INDEX )
+ {
+ }
+
+ VisualProperty( Handle& handle, Property::Index index )
+ : handle( handle ),
+ index( index )
+ {
+ }
+};
+
+
typedef Dali::OwnerContainer< RegisteredVisual* > RegisteredVisualContainer;
/**
return false;
}
+VisualProperty GetVisualProperty(
+ Internal::Control& controlImpl,
+ RegisteredVisualContainer& visuals,
+ const std::string& visualName,
+ Property::Key propertyKey )
+{
+#if defined(DEBUG_ENABLED)
+ std::ostringstream oss;
+ oss << "Control::GetVisualProperty(" << visualName << ", " << propertyKey << ")" << std::endl;
+ DALI_LOG_INFO( gLogFilter, Debug::General, oss.str().c_str() );
+#endif
+
+ // Find visualName in the control
+ RegisteredVisualContainer::Iterator iter;
+ for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
+ {
+ if ( (*iter)->visual.GetName() == visualName )
+ {
+ break;
+ }
+ }
+
+ // Does either it's renderer or placement actor have an associated property?
+ if( iter != visuals.End() )
+ {
+ Actor placementActor = (*iter)->placementActor;
+ if( !placementActor )
+ {
+ placementActor = controlImpl.Self();
+ }
+
+ Property::Index index = placementActor.GetPropertyIndex( propertyKey );
+ if( index != Property::INVALID_INDEX )
+ {
+ // It's a placement actor property:
+ return VisualProperty( placementActor, index );
+ }
+ else
+ {
+ // Check if it is a renderer property:
+ if( placementActor.GetRendererCount() > 0 )
+ {
+ // @todo Need to use correct renderer index when placement actors
+ // are removed
+ Renderer renderer = placementActor.GetRendererAt(0);
+ Property::Index index = renderer.GetPropertyIndex( propertyKey );
+ if( index != Property::INVALID_INDEX )
+ {
+ // It's a renderer property:
+ return VisualProperty( renderer, index );
+ }
+ }
+ else
+ {
+ std::ostringstream oss;
+ oss << propertyKey;
+ DALI_LOG_WARNING( "Control::GetVisualProperty(%s, %s) No renderers\n", visualName.c_str(), oss.str().c_str() );
+ }
+ }
+ }
+ Handle handle;
+ return VisualProperty( handle, Property::INVALID_INDEX );
+}
+
+
/**
* Creates control through type registry
*/
// Construction & Destruction
Impl(Control& controlImpl)
-: mControlImpl( controlImpl ),
- mStyleName(""),
- mBackgroundVisual(),
- mBackgroundColor(Color::TRANSPARENT),
- mStartingPinchScale( NULL ),
- mKeyEventSignal(),
- mPinchGestureDetector(),
- mPanGestureDetector(),
- mTapGestureDetector(),
- mLongPressGestureDetector(),
- mFlags( Control::ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
- mIsKeyboardNavigationSupported( false ),
- mIsKeyboardFocusGroup( false )
-{
-}
+ : mControlImpl( controlImpl ),
+ mStyleName(""),
+ mBackgroundVisual(),
+ mBackgroundColor(Color::TRANSPARENT),
+ mStartingPinchScale( NULL ),
+ mKeyEventSignal(),
+ mPinchGestureDetector(),
+ mPanGestureDetector(),
+ mTapGestureDetector(),
+ mLongPressGestureDetector(),
+ mFlags( Control::ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
+ mIsKeyboardNavigationSupported( false ),
+ mIsKeyboardFocusGroup( false )
+ {
+ }
~Impl()
{
return Actor();
}
+Dali::Animation Control::CreateTransition( const Toolkit::TransitionData& handle )
+{
+ Dali::Animation transition;
+ const Internal::TransitionData& transitionData = Toolkit::GetImplementation( handle );
+
+ if( transitionData.Count() > 0 )
+ {
+ // Setup a Transition from TransitionData.
+ TransitionData::Iterator end = transitionData.End();
+ for( TransitionData::Iterator iter = transitionData.Begin() ;
+ iter != end; ++iter )
+ {
+ TransitionData::Animator* animator = (*iter);
+ VisualProperty visualProperty;
+
+ // Attempt to find the object name as a child actor
+ Actor child = Self().FindChildByName( animator->objectName );
+ if( child )
+ {
+ Property::Index propertyIndex = child.GetPropertyIndex( animator->propertyKey );
+ visualProperty = VisualProperty( child, propertyIndex );
+ }
+ else
+ {
+ // Is it a placement actor/visual pair?;
+ visualProperty = GetVisualProperty( *this, mImpl->mVisuals,
+ animator->objectName,
+ animator->propertyKey );
+ }
+
+ if( visualProperty.handle && visualProperty.index != Property::INVALID_INDEX )
+ {
+ if( animator->animate == false )
+ {
+ if( animator->targetValue.GetType() != Property::NONE )
+ {
+ visualProperty.handle.SetProperty( visualProperty.index, animator->targetValue );
+ }
+ }
+ else
+ {
+ if( animator->initialValue.GetType() != Property::NONE )
+ {
+ visualProperty.handle.SetProperty( visualProperty.index, animator->initialValue );
+ }
+
+ if( ! transition )
+ {
+ // Create an animation with a default .1 second duration - the animators
+ // will automatically force it to the 'right' duration.
+ transition = Dali::Animation::New( 0.1f );
+ }
+
+ transition.AnimateTo( Property( visualProperty.handle, visualProperty.index ),
+ animator->targetValue,
+ animator->alphaFunction,
+ TimePeriod( animator->timePeriodDelay,
+ animator->timePeriodDuration ) );
+ }
+ }
+ }
+ }
+
+ return transition;
+}
+
+
bool Control::OnAccessibilityActivated()
{
return false; // Accessibility activation is not handled by default
namespace Dali
{
-
namespace Toolkit
{
+
/**
* @addtogroup dali_toolkit_controls
* @{
*/
class StyleManager;
+class TransitionData;
namespace Visual
{
class Base;
}
+
namespace Internal
{
+
/**
* @brief This is the internal base class for all controls.
*
* @note Derived class should not call visual.SetOnStage(placementActor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
* Use below API with enabled set to false if derived class wishes to control when visual is staged.
*/
- void RegisterVisual( Property::Index index, Actor& placementActor, Toolkit::Visual::Base& visual );
-
- /**
- * @brief Register a visual by Property Index, linking an Actor to visual when required.
- * In the case of the visual being an actor or control deeming visual not required then visual should be an empty handle.
- * If enabled is false then the visual is not set on stage until enabled by the derived class.
- * @see EnableVisual
- *
- * @SINCE_1_2.11
- *
- * @param[in] index The Property index of the visual, used to reference visual
- * @param[in] placementActor The actor used to by the visual.
- * @param[in] visual The visual to register
- * @param[in] enabled false if derived class wants to control when visual is set on stage.
- *
- */
- void RegisterVisual( Property::Index index, Actor& placementActor, Toolkit::Visual::Base& visual, bool enabled );
-
- /**
- * @brief Erase the entry matching the given index from the list of registered visuals
- * @param[in] index The Property index of the visual, used to reference visual
- *
- * @SINCE_1_2.0
- */
- void UnregisterVisual( Property::Index index );
-
- /**
- * @brief Retrieve the visual associated with the given property index.
- *
- * @SINCE_1_2.2
- *
- * @param[in] index The Property index of the visual.
- * @return The registered visual if exist, otherwise empty handle.
- * @note For managing object life-cycle, do not store the returned visual as a member which increments its reference count.
- */
- Toolkit::Visual::Base GetVisual( Property::Index index ) const;
-
- /**
- * @brief Sets the given visual to be displayed or not when parent staged.
- *
- * @SINCE_1_2.11
- *
- * @param[in] index The Property index of the visual
- * @param[in] enable flag to set enabled or disabled.
- */
- void EnableVisual( Property::Index index, bool enable );
-
- /**
- * @brief Queries if the given visual is to be displayed when parent staged.
- *
- * @SINCE_1_2.11
- *
- * @param[in] index The Property index of the visual
- * @return bool whether visual is enabled or not
- */
- bool IsVisualEnabled( Property::Index index ) const;
-
- /**
- * @brief Retrieve the placement actor associated with the given index.
- *
- * @SINCE_1_2.2
- *
- * @@param[in] index The Property index of the visual.
- * @return Then placement actor if exist, otherwise empty handle.
- * @note For managing object life-cycle, do not store the returned placement actor as a member which increments its reference count.
- */
- Actor GetPlacementActor( Property::Index index ) const;
+ void RegisterVisual( Property::Index index, Actor& placementActor, Toolkit::Visual::Base& visual );
+
+ /**
+ * @brief Register a visual by Property Index, linking an Actor to visual when required.
+ * In the case of the visual being an actor or control deeming visual not required then visual should be an empty handle.
+ * If enabled is false then the visual is not set on stage until enabled by the derived class.
+ * @see EnableVisual
+ *
+ * @SINCE_1_2.11
+ *
+ * @param[in] index The Property index of the visual, used to reference visual
+ * @param[in] placementActor The actor used to by the visual.
+ * @param[in] visual The visual to register
+ * @param[in] enabled false if derived class wants to control when visual is set on stage.
+ *
+ */
+ void RegisterVisual( Property::Index index, Actor& placementActor, Toolkit::Visual::Base& visual, bool enabled );
+
+ /**
+ * @brief Erase the entry matching the given index from the list of registered visuals
+ * @param[in] index The Property index of the visual, used to reference visual
+ *
+ * @SINCE_1_2.0
+ */
+ void UnregisterVisual( Property::Index index );
+
+ /**
+ * @brief Retrieve the visual associated with the given property index.
+ *
+ * @SINCE_1_2.2
+ *
+ * @param[in] index The Property index of the visual.
+ * @return The registered visual if exist, otherwise empty handle.
+ * @note For managing object life-cycle, do not store the returned visual as a member which increments its reference count.
+ */
+ Toolkit::Visual::Base GetVisual( Property::Index index ) const;
+
+ /**
+ * @brief Sets the given visual to be displayed or not when parent staged.
+ *
+ * @SINCE_1_2.11
+ *
+ * @param[in] index The Property index of the visual
+ * @param[in] enable flag to set enabled or disabled.
+ */
+ void EnableVisual( Property::Index index, bool enable );
+
+ /**
+ * @brief Queries if the given visual is to be displayed when parent staged.
+ *
+ * @SINCE_1_2.11
+ *
+ * @param[in] index The Property index of the visual
+ * @return bool whether visual is enabled or not
+ */
+ bool IsVisualEnabled( Property::Index index ) const;
+
+ /**
+ * @brief Retrieve the placement actor associated with the given index.
+ *
+ * @SINCE_1_2.2
+ *
+ * @@param[in] index The Property index of the visual.
+ * @return Then placement actor if exist, otherwise empty handle.
+ * @note For managing object life-cycle, do not store the returned placement actor as a member which increments its reference count.
+ */
+ Actor GetPlacementActor( Property::Index index ) const;
+
+ /**
+ * @brief Create a transition effect on the control.
+ *
+ * @SINCE_1_2.12
+ *
+ * @param[in] transitionData The transition data describing the effect to create
+ * @return A handle to an animation defined with the given effect, or an empty
+ * handle if no properties match.
+ */
+ Dali::Animation CreateTransition( const Toolkit::TransitionData& transitionData );
/**
* @brief Emits KeyInputFocusGained signal if true else emits KeyInputFocusLost signal
$(public_api_src_dir)/controls/text-controls/text-editor.cpp \
$(public_api_src_dir)/controls/text-controls/text-label.cpp \
$(public_api_src_dir)/controls/text-controls/text-field.cpp \
+ $(public_api_src_dir)/controls/video-view/video-view.cpp \
$(public_api_src_dir)/styling/style-manager.cpp \
$(public_api_src_dir)/accessibility-manager/accessibility-manager.cpp \
$(public_api_src_dir)/focus-manager/keyboard-focus-manager.cpp \
- $(public_api_src_dir)/controls/video-view/video-view.cpp \
$(public_api_src_dir)/dali-toolkit-version.cpp \
$(public_api_src_dir)/enums.cpp