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_ARRAY_EQUALS( Property::Array test, Property::Value result )
+{
+ if( result.GetType() == Property::ARRAY )
+ {
+ // Compare arrays
+ Property::Array *resultArray = result.GetArray();
+ DALI_TEST_EQUALS( test.Count(), resultArray->Count(), TEST_LOCATION );
+ for( size_t i=0; i < std::min(test.Count(), resultArray->Count()); ++i )
+ {
+ Property::Value a = test.GetElementAt(i);
+ Property::Value b = resultArray->GetElementAt(i);
+ DALI_TEST_EQUALS( a.GetType(), b.GetType(), TEST_LOCATION );
+ DALI_TEST_EQUALS( a, b, 0.001, TEST_LOCATION );
+ }
+ }
+ else if( result.GetType() == Property::VECTOR4 )
+ {
+ Vector4 value = result.Get<Vector4>();
+ DALI_TEST_CHECK( test.Count() >= 4 );
+ for( size_t i=0; i < 4; ++i )
+ {
+ Property::Value a = test.GetElementAt(i);
+ DALI_TEST_EQUALS( a.GetType(), Property::FLOAT, TEST_LOCATION );
+ DALI_TEST_EQUALS( a.Get<float>(), value[i], 0.001, TEST_LOCATION );
+ }
+ }
+ else
+ {
+ DALI_TEST_CHECK( 0 );
+ }
+}
+
+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 )
+ {
+ if( keyValue.second.GetType() == Property::MAP )
+ {
+ DALI_TEST_EQUALS( keyValue.second.GetType(), value->GetType(), TEST_LOCATION );
+ CHECK_MAP_EQUALS( *(keyValue.second.GetMap()), *(value->GetMap()) );
+ }
+ else if( keyValue.second.GetType() == Property::ARRAY )
+ {
+ CHECK_ARRAY_EQUALS( *(keyValue.second.GetArray()), *value );
+ }
+ else if( keyValue.second.GetType() == Property::STRING )
+ {
+ DALI_TEST_EQUALS( keyValue.second.GetType(), value->GetType(), TEST_LOCATION );
+ std::string str;
+ value->Get(str);
+ DALI_TEST_EQUALS( keyValue.second, str.c_str(), TEST_LOCATION );
+ }
+ else
+ {
+ DALI_TEST_EQUALS( keyValue.second.GetType(), value->GetType(), TEST_LOCATION );
+ 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 UtcDaliTransitionDataMap3P(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 UtcDaliTransitionDataMap4P(void)
+{
+ TestApplication application;
+
+ tet_printf("Testing animation of a visual's placement actor property using bezier curve\n");
+
+ Property::Map map;
+ map["target"] = "Actor1";
+ map["property"] = "position";
+ map["initialValue"] = Vector3(0, 0, 0);
+ map["targetValue"] = Vector3(100, 100, 0);
+ map["animator"] = Property::Map()
+ .Add("alphaFunction", Vector4(0.71, -0.57, 0.42, 1.38) )
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.0f)
+ .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");
+ Stage::GetCurrent().Add(actor);
+
+ 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.GetCurrentPosition(), Vector3(0,0,0), 0.001f, TEST_LOCATION);
+
+ anim.Play();
+
+ application.SendNotification();
+ application.Render(0);
+
+ application.Render(250); // 25%
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(-10,-10,0), 1.0, TEST_LOCATION); // High epsilon as we don't have exact figure for bezier curve at 50%
+
+ application.Render(250); // Halfway thru map1 anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(24,24,0), 1.0, TEST_LOCATION); // High epsilon as we don't have exact figure for bezier curve at 50%
+
+ application.Render(250); // End of map1 anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,100,0), 1.0, TEST_LOCATION); // High epsilon as we don't have exact figure for bezier curve
+
+ application.Render(250); // End of map1 anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,100,0), 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 UtcDaliTransitionDataMapN4(void)
+{
+ TestApplication application;
+
+ tet_printf("Testing visual doesn't animate with duff bezier data \n");
+
+ Property::Map map;
+ map["target"] = "visual1";
+ map["property"] = "mixColor";
+ map["initialValue"] = Color::MAGENTA;
+ map["targetValue"] = Color::RED;
+ map["animator"] = Property::Map()
+ .Add("alphaFunction", Vector3(.1f,1.0f,0.5f))
+ .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);
+ application.SendNotification();
+
+ Renderer renderer = actor.GetRendererAt(0);
+ Property::Index mixColorIdx = renderer.GetPropertyIndex(ColorVisual::Property::MIX_COLOR);
+
+ tet_printf( "Test that the property has been set to target value\n");
+ DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliTransitionDataMapN5(void)
+{
+ TestApplication application;
+
+ tet_printf("Testing visual doesn't animate with duff bezier data \n");
+
+ Property::Map map;
+ map["target"] = "visual1";
+ map["property"] = "mixColor";
+ map["initialValue"] = Color::MAGENTA;
+ map["targetValue"] = Color::RED;
+ map["animator"] = Property::Map()
+ .Add("alphaFunction", Property::Array().Add(.1f).Add(1.0f).Add(0.5f))
+ .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);
+ application.SendNotification();
+
+ Renderer renderer = actor.GetRendererAt(0);
+ Property::Index mixColorIdx = renderer.GetPropertyIndex(ColorVisual::Property::MIX_COLOR);
+
+ tet_printf( "Test that the property has been set to target value\n");
+ DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliTransitionDataMapN6(void)
+{
+ TestApplication application;
+
+ tet_printf("Testing visual doesn't animate with duff bezier data \n");
+
+ Property::Map map;
+ map["target"] = "visual1";
+ map["property"] = "mixColor";
+ map["initialValue"] = Color::MAGENTA;
+ map["targetValue"] = Color::RED;
+ map["animator"] = Property::Map()
+ .Add("alphaFunction", Property::Array().Add("1").Add("Two").Add("3").Add("4"))
+ .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);
+ application.SendNotification();
+
+ Renderer renderer = actor.GetRendererAt(0);
+ Property::Index mixColorIdx = renderer.GetPropertyIndex(ColorVisual::Property::MIX_COLOR);
+
+ tet_printf( "Test that the property has been set to target value\n");
+ DALI_TEST_EQUALS(renderer.GetProperty<Vector4>(mixColorIdx), Color::RED, 0.001, TEST_LOCATION);
+
+ 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"] = "Actor2";
+ map10["property"] = "scale";
+ map10["initialValue"] = Vector3(0,0,0);
+ map10["targetValue"] = Vector3(1,1,1);
+ map10["animator"] = Property::Map()
+ .Add("alphaFunction", Vector4(.23,.4,.8,1.2))
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.0f)
+ .Add("duration", 1.0f));
+
+ Property::Map map11;
+ map11["target"] = "Actor2";
+ map11["property"] = "scale";
+ map11["initialValue"] = Vector3(0,0,0);
+ map11["targetValue"] = Vector3(1,1,1);
+ map11["animator"] = Property::Map()
+ .Add("alphaFunction", Property::Array().Add(.23f).Add(.4f).Add(.8f).Add(.2f))
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.0f)
+ .Add("duration", 1.0f));
+
+ Property::Map map12;
+ map12["target"] = "Actor1";
+ map12["property"] = "orientation";
+ map12["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);
+ array.PushBack(map11);
+ array.PushBack(map12);
+
+ 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-visual.cpp \
$(toolkit_src_dir)/visuals/text/text-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 \
void Controller::Impl::ClampVerticalScroll( const Vector2& layoutSize )
{
+ if( LayoutEngine::SINGLE_LINE_BOX == mLayoutEngine.GetLayout() )
+ {
+ // Nothing to do if the text is single line.
+ return;
+ }
+
// Clamp between -space & 0.
if( layoutSize.height > mVisualModel->mControlSize.height )
{
);
}
+BorderVisualPtr BorderVisual::New( VisualFactoryCache& factoryCache )
+{
+ return new BorderVisual( factoryCache );
+}
+
BorderVisual::BorderVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache ),
mBorderColor( Color::TRANSPARENT ),
{
}
-void BorderVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void BorderVisual::DoSetProperties( const Property::Map& propertyMap )
{
Property::Value* color = propertyMap.Find( Toolkit::BorderVisual::Property::COLOR, COLOR_NAME );
if( !( color && color->Get(mBorderColor) ) )
// EXTERNAL INCLUDES
#include <dali/public-api/rendering/geometry.h>
+#include <dali/public-api/common/intrusive-ptr.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
namespace Internal
{
+class BorderVisual;
+typedef IntrusivePtr< BorderVisual > BorderVisualPtr;
+
/**
* The visual which renders a solid color to the control's quad border fixed to a specified size.
*
* | borderSize | FLOAT |
* | antiAliasing | BOOLEAN |
*/
-
class BorderVisual : public Visual::Base
{
public:
/**
+ * @brief Create a new border visual.
+ *
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @return A smart-pointer to the newly allocated visual.
+ */
+ static BorderVisualPtr New( VisualFactoryCache& factoryCache );
+
+protected:
+
+ /**
* @brief Constructor.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
*/
virtual ~BorderVisual();
-protected:
-
/**
- * @copydoc Visual::Base::DoInitialize
+ * @copydoc Visual::Base::DoSetProperties
*/
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+ virtual void DoSetProperties( const Property::Map& propertyMap );
/**
* @copydoc Visual::Base::DoSetOnStage
);
}
+ColorVisualPtr ColorVisual::New( VisualFactoryCache& factoryCache )
+{
+ return new ColorVisual( factoryCache );
+}
+
ColorVisual::ColorVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache ),
mMixColorIndex( Property::INVALID_INDEX )
{
}
-void ColorVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void ColorVisual::DoSetProperties( const Property::Map& propertyMap )
{
Property::Value* color = propertyMap.Find( Toolkit::ColorVisual::Property::MIX_COLOR, COLOR_NAME );
if( !( color && color->Get(mMixColor) ) )
#define DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * 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.
*
*/
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
+
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
namespace Internal
{
+class ColorVisual;
+typedef IntrusivePtr< ColorVisual > ColorVisualPtr;
+
/**
* The visual which renders a solid color to the control's quad
*
public:
/**
- * @brief Constructor.
+ * @brief Create a new color visual.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @return A smart-pointer to the newly allocated visual.
*/
- ColorVisual( VisualFactoryCache& factoryCache );
-
- /**
- * @brief A reference counted object may only be deleted by calling Unreference().
- */
- virtual ~ColorVisual();
+ static ColorVisualPtr New( VisualFactoryCache& factoryCache );
public: // from Visual
protected:
/**
- * @copydoc Visual::Base::DoInitialize
+ * @brief Constructor.
+ *
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ */
+ ColorVisual( VisualFactoryCache& factoryCache );
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~ColorVisual();
+
+ /**
+ * @copydoc Visual::Base::DoSetProperties
*/
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+ virtual void DoSetProperties( const Property::Map& propertyMap );
/**
* @copydoc Visual::Base::DoSetOnStage
} // unnamed namespace
+GradientVisualPtr GradientVisual::New( VisualFactoryCache& factoryCache )
+{
+ return new GradientVisual( factoryCache );
+}
GradientVisual::GradientVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache ),
{
}
-void GradientVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void GradientVisual::DoSetProperties( const Property::Map& propertyMap )
{
Toolkit::GradientVisual::Units::Type gradientUnits = Toolkit::GradientVisual::Units::OBJECT_BOUNDING_BOX;
#define DALI_TOOLKIT_INTERNAL_GRADIENT_VISUAL_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * 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.
*
*/
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
+
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/visuals/gradient/gradient.h>
{
class Gradient;
+class GradientVisual;
+typedef IntrusivePtr< GradientVisual > GradientVisualPtr;
/**
* The visual which renders smooth transition of colors to the control's quad.
};
/**
- * @brief Constructor.
+ * @brief Create a new gradient visual.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @return A smart-pointer to the newly allocated visual.
*/
- GradientVisual( VisualFactoryCache& factoryCache );
-
- /**
- * @brief A reference counted object may only be deleted by calling Unreference().
- */
- ~GradientVisual();
+ static GradientVisualPtr New( VisualFactoryCache& factoryCache );
public: // from Visual
virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
protected:
+
+ /**
+ * @brief Constructor.
+ *
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ */
+ GradientVisual( VisualFactoryCache& factoryCache );
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~GradientVisual();
+
/**
- * @copydoc Visual::Base::DoInitialize
+ * @copydoc Visual::Base::DoSetProperties
*/
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+ virtual void DoSetProperties( const Property::Map& propertyMap );
/**
* @copydoc Visual::Base::DoSetOnStage
}\n
);
-} //unnamed namespace
+} // unnamed namespace
+
+BatchImageVisualPtr BatchImageVisual::New( VisualFactoryCache& factoryCache )
+{
+ return new BatchImageVisual( factoryCache );
+}
BatchImageVisual::BatchImageVisual( VisualFactoryCache& factoryCache )
- : Visual::Base( factoryCache ),
- mDesiredSize()
+: Visual::Base( factoryCache ),
+ mDesiredSize()
{
}
{
}
-void BatchImageVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void BatchImageVisual::DoSetProperties( const Property::Map& propertyMap )
{
std::string oldImageUrl = mImageUrl;
Property::Value* imageURLValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::URL, Dali::Toolkit::Internal::IMAGE_URL_NAME );
mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
}
-
- // Remove old renderer if exit.
- if( mImpl->mRenderer )
- {
- if( actor ) // Remove old renderer from actor.
- {
- actor.RemoveRenderer( mImpl->mRenderer );
- }
- if( !oldImageUrl.empty() ) // Clean old renderer from cache.
- {
- CleanCache( oldImageUrl );
- }
- }
-
- // If actor is on stage, create new renderer and apply to actor.
- if( actor && actor.OnStage() )
- {
- SetOnStage( actor );
- }
}
void BatchImageVisual::SetSize( const Vector2& size )
*
*/
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
+
// INTERNAL HEADER
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
-// EXTERNAL INCLUDES
-#include <dali/public-api/images/resource-image.h>
-
namespace Dali
{
namespace Toolkit
namespace Internal
{
+class BatchImageVisual;
+typedef IntrusivePtr< BatchImageVisual > BatchImageVisualPtr;
+
class BatchImageVisual: public Visual::Base, public ConnectionTracker
{
public:
/**
- * @brief Constructor.
+ * @brief Create a new batch-image visual.
*
- * @param[in] factoryCache The VisualFactoryCache object
- */
- BatchImageVisual( VisualFactoryCache& factoryCache );
-
- /**
- * @brief A reference counted object may only be deleted by calling Unreference().
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @return A smart-pointer to the newly allocated visual.
*/
- ~BatchImageVisual();
+ static BatchImageVisualPtr New( VisualFactoryCache& factoryCache );
public: // from Visual
protected:
/**
- * @copydoc Visua::Base::DoInitialize
+ * @brief Constructor.
+ *
+ * @param[in] factoryCache The VisualFactoryCache object
+ */
+ BatchImageVisual( VisualFactoryCache& factoryCache );
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ ~BatchImageVisual();
+
+ /**
+ * @copydoc Visua::Base::DoSetProperties
*/
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+ virtual void DoSetProperties( const Property::Map& propertyMap );
/**
* @copydoc Visual::Base::DoSetOnStage
*/
// CLASS HEADER
-#include "image-visual.h"
+#include <dali-toolkit/internal/visuals/image/image-visual.h>
// EXTERNAL HEADER
#include <cstring> // for strncasecmp
return geometry;
}
-} //unnamed namespace
+} // unnamed namespace
+
+ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache )
+{
+ return new ImageVisual( factoryCache );
+}
+
+ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache,
+ const std::string& imageUrl,
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ Dali::SamplingMode::Type samplingMode )
+{
+ return new ImageVisual( factoryCache, imageUrl, size, fittingMode, samplingMode );
+}
+
+ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache, const Image& image )
+{
+ return new ImageVisual( factoryCache, image );
+}
ImageVisual::ImageVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache ),
mFittingMode( FittingMode::DEFAULT ),
mSamplingMode( SamplingMode::DEFAULT ),
mWrapModeU( WrapMode::DEFAULT ),
- mWrapModeV( WrapMode::DEFAULT ),
- mNativeFragmentShaderCode(),
- mNativeImageFlag( false )
+ mWrapModeV( WrapMode::DEFAULT )
{
}
mFittingMode( fittingMode ),
mSamplingMode( samplingMode ),
mWrapModeU( WrapMode::DEFAULT ),
- mWrapModeV( WrapMode::DEFAULT ),
- mNativeFragmentShaderCode(),
- mNativeImageFlag( false )
+ mWrapModeV( WrapMode::DEFAULT )
{
}
mFittingMode( FittingMode::DEFAULT ),
mSamplingMode( SamplingMode::DEFAULT ),
mWrapModeU( WrapMode::DEFAULT ),
- mWrapModeV( WrapMode::DEFAULT ),
- mNativeFragmentShaderCode(),
- mNativeImageFlag( false )
+ mWrapModeV( WrapMode::DEFAULT )
{
- NativeImage newNativeImage = NativeImage::DownCast( image );
- if( newNativeImage )
- {
- SetNativeFragmentShaderCode( newNativeImage );
- mNativeImageFlag = true;
- }
- else
- {
- mNativeImageFlag = false;
- }
}
ImageVisual::~ImageVisual()
{
}
-void ImageVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void ImageVisual::DoSetProperties( const Property::Map& propertyMap )
{
- std::string oldImageUrl = mImageUrl;
-
Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
if( imageURLValue )
{
Property::Value* fittingValue = propertyMap.Find( Toolkit::ImageVisual::Property::FITTING_MODE, IMAGE_FITTING_MODE );
if( fittingValue )
{
- Scripting::GetEnumerationProperty( *fittingValue, FITTING_MODE_TABLE, FITTING_MODE_TABLE_COUNT, mFittingMode );
+ int value;
+ Scripting::GetEnumerationProperty( *fittingValue, FITTING_MODE_TABLE, FITTING_MODE_TABLE_COUNT, value );
+ mFittingMode = Dali::FittingMode::Type( value );
}
Property::Value* samplingValue = propertyMap.Find( Toolkit::ImageVisual::Property::SAMPLING_MODE, IMAGE_SAMPLING_MODE );
if( samplingValue )
{
- Scripting::GetEnumerationProperty( *samplingValue, SAMPLING_MODE_TABLE, SAMPLING_MODE_TABLE_COUNT, mSamplingMode );
+ int value;
+ Scripting::GetEnumerationProperty( *samplingValue, SAMPLING_MODE_TABLE, SAMPLING_MODE_TABLE_COUNT, value );
+ mSamplingMode = Dali::SamplingMode::Type( value );
}
int desiredWidth = 0;
Property::Value* wrapModeValueU = propertyMap.Find( Toolkit::ImageVisual::Property::WRAP_MODE_U, IMAGE_WRAP_MODE_U );
if( wrapModeValueU )
{
- Scripting::GetEnumerationProperty( *wrapModeValueU, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, mWrapModeU );
+ int value;
+ Scripting::GetEnumerationProperty( *wrapModeValueU, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, value );
+ mWrapModeU = Dali::WrapMode::Type( value );
}
Property::Value* wrapModeValueV = propertyMap.Find( Toolkit::ImageVisual::Property::WRAP_MODE_V, IMAGE_WRAP_MODE_V );
if( wrapModeValueV )
{
- Scripting::GetEnumerationProperty( *wrapModeValueV, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, mWrapModeV );
+ int value;
+ Scripting::GetEnumerationProperty( *wrapModeValueV, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, value );
+ mWrapModeV = Dali::WrapMode::Type( value );
}
mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
if( sync )
{
mImpl->mFlags |= Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
+ // if sync loading is required, the loading should start immediately when new image url is set or the actor is off stage
+ // ( for on-stage actor with image url unchanged, resource loading is already finished)
+ if( imageURLValue )
+ {
+ LoadResourceSynchronously();
+ }
}
else
{
mImpl->mFlags &= ~Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
}
}
-
- // if sync loading is required, the loading should start immediately when new image url is set or the actor is off stage
- // ( for on-stage actor with image url unchanged, resource loading is already finished)
- if( imageURLValue && IsSynchronousResourceLoading() )
- {
- LoadResourceSynchronously();
- }
-
- NativeImage nativeImage = NativeImage::DownCast( mImage );
-
- if( nativeImage )
- {
- SetNativeFragmentShaderCode( nativeImage );
- }
-
- // if actor is on stage, create new renderer and apply to actor
- if( actor && actor.OnStage() )
- {
- SetOnStage( actor );
- }
}
void ImageVisual::GetNaturalSize( Vector2& naturalSize ) const
naturalSize = Vector2::ZERO;
}
-Renderer ImageVisual::CreateRenderer() const
+void ImageVisual::CreateRenderer( TextureSet& textures )
{
Geometry geometry;
Shader shader;
- // If mImage is nativeImage with custom sampler or prefix, mNativeFragmentShaderCode will be applied.
- // Renderer can't be shared between NativeImage and other image types.
- if( !mNativeFragmentShaderCode.empty() )
- {
- return CreateNativeImageRenderer();
- }
-
if( !mImpl->mCustomShader )
{
geometry = CreateGeometry( mFactoryCache, ImageDimensions( 1, 1 ) );
geometry = CreateGeometry( mFactoryCache, mImpl->mCustomShader->mGridSize );
if( mImpl->mCustomShader->mVertexShader.empty() && mImpl->mCustomShader->mFragmentShader.empty() )
{
- shader = GetImageShader(mFactoryCache, false, true);
+ shader = GetImageShader( mFactoryCache, false, true );
}
else
{
}
}
- Renderer renderer = Renderer::New( geometry, shader );
-
- return renderer;
+ mImpl->mRenderer = Renderer::New( geometry, shader );
+ DALI_ASSERT_DEBUG( textures );
+ mImpl->mRenderer.SetTextures( textures );
}
-Renderer ImageVisual::CreateNativeImageRenderer() const
+void ImageVisual::CreateNativeImageRenderer( NativeImage& nativeImage )
{
Geometry geometry;
Shader shader;
+ std::string fragmentShader;
+ const char* fragmentPreFix = nativeImage.GetCustomFragmentPreFix();
+ const char* customSamplerTypename = nativeImage.GetCustomSamplerTypename();
+ if( fragmentPreFix )
+ {
+ fragmentShader = fragmentPreFix;
+ fragmentShader += "\n";
+ }
+ if( mImpl->mCustomShader && !mImpl->mCustomShader->mFragmentShader.empty() )
+ {
+ fragmentShader += mImpl->mCustomShader->mFragmentShader;
+ }
+ else
+ {
+ fragmentShader += FRAGMENT_SHADER_NO_ATLAS;
+ }
+ if( customSamplerTypename )
+ {
+ fragmentShader.replace( fragmentShader.find( DEFAULT_SAMPLER_TYPENAME ), strlen( DEFAULT_SAMPLER_TYPENAME ), customSamplerTypename );
+ }
+
if( !mImpl->mCustomShader )
{
geometry = CreateGeometry( mFactoryCache, ImageDimensions( 1, 1 ) );
- shader = Shader::New( VERTEX_SHADER, mNativeFragmentShaderCode );
+ shader = Shader::New( VERTEX_SHADER, fragmentShader );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
}
else
{
geometry = CreateGeometry( mFactoryCache, mImpl->mCustomShader->mGridSize );
shader = Shader::New( mImpl->mCustomShader->mVertexShader.empty() ? VERTEX_SHADER : mImpl->mCustomShader->mVertexShader,
- mNativeFragmentShaderCode,
+ fragmentShader,
mImpl->mCustomShader->mHints );
if( mImpl->mCustomShader->mVertexShader.empty() )
{
}
}
- TextureSet textureSet = TextureSet::New();
- Renderer renderer = Renderer::New( geometry, shader );
- renderer.SetTextures( textureSet );
- return renderer;
+ mImpl->mRenderer = Renderer::New( geometry, shader );
}
}
}
-Image ImageVisual::LoadImage( const std::string& url, bool synchronousLoading )
-{
- if( synchronousLoading )
- {
- if( !mPixels )
- {
- // use broken image
- return VisualFactoryCache::GetBrokenVisualImage();
- }
- Atlas image = Atlas::New( mPixels.GetWidth(), mPixels.GetHeight(), mPixels.GetPixelFormat() );
- image.Upload( mPixels, 0, 0 );
- return image;
- }
- else
- {
- ResourceImage resourceImage = Dali::ResourceImage::New( url, mDesiredSize, mFittingMode, mSamplingMode );
- resourceImage.LoadingFinishedSignal().Connect( this, &ImageVisual::OnImageLoaded );
- return resourceImage;
- }
-}
-
-TextureSet ImageVisual::CreateTextureSet( Vector4& textureRect, const std::string& url, bool synchronousLoading )
+TextureSet ImageVisual::CreateTextureSet( Vector4& textureRect, const std::string& url, bool synchronousLoading, bool attemptAtlasing )
{
TextureSet textureSet;
textureRect = FULL_TEXTURE_RECT;
}
else
{
- textureSet = mFactoryCache.GetAtlasManager()->Add(textureRect, mPixels );
- mImpl->mFlags |= Impl::IS_ATLASING_APPLIED;
- if( !textureSet ) // big image, no atlasing
+ if( attemptAtlasing )
+ {
+ textureSet = mFactoryCache.GetAtlasManager()->Add(textureRect, mPixels );
+ mImpl->mFlags |= Impl::IS_ATLASING_APPLIED;
+ }
+ if( !textureSet ) // big image, no atlasing or atlasing failed
{
mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
- Atlas image = Atlas::New( mPixels.GetWidth(), mPixels.GetHeight(), mPixels.GetPixelFormat() );
- image.Upload( mPixels, 0, 0 );
+ Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, mPixels.GetPixelFormat(),
+ mPixels.GetWidth(), mPixels.GetHeight() );
+ texture.Upload( mPixels );
textureSet = TextureSet::New();
- TextureSetImage( textureSet, 0u, image );
+ textureSet.SetTexture( 0u, texture );
}
}
}
else
{
- textureSet = mFactoryCache.GetAtlasManager()->Add(textureRect, url, mDesiredSize, mFittingMode, true, this );
- mImpl->mFlags |= Impl::IS_ATLASING_APPLIED;
- if( !textureSet ) // big image, no atlasing
+ if( attemptAtlasing )
+ {
+ textureSet = mFactoryCache.GetAtlasManager()->Add(textureRect, url, mDesiredSize, mFittingMode, true, this );
+ mImpl->mFlags |= Impl::IS_ATLASING_APPLIED;
+ }
+ if( !textureSet ) // big image, no atlasing or atlasing failed
{
mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
ResourceImage resourceImage = Dali::ResourceImage::New( url, mDesiredSize, mFittingMode, mSamplingMode );
sampler.SetWrapMode( mWrapModeU, mWrapModeV );
textureSet.SetSampler( 0u, sampler );
}
-
return textureSet;
}
if( !mImpl->mRenderer ) // new renderer is needed
{
Vector4 atlasRect;
- TextureSet textureSet = CreateTextureSet(atlasRect, imageUrl, IsSynchronousResourceLoading() );
- Geometry geometry = CreateGeometry( mFactoryCache, ImageDimensions( 1, 1 ) );
- Shader shader( GetImageShader(mFactoryCache, mImpl->mFlags & Impl::IS_ATLASING_APPLIED, defaultWrapMode) );
- mImpl->mRenderer = Renderer::New( geometry, shader );
- mImpl->mRenderer.SetTextures( textureSet );
+ // texture set has to be created first as we need to know if atlasing succeeded or not
+ // when selecting the shader
+ TextureSet textures = CreateTextureSet( atlasRect, imageUrl, IsSynchronousResourceLoading(), true );
+ CreateRenderer( textures );
if( mImpl->mFlags & Impl::IS_ATLASING_APPLIED ) // the texture is packed inside atlas
{
{
// for custom shader or remote image, renderer is not cached and atlas is not applied
mImpl->mFlags &= ~Impl::IS_FROM_CACHE;
- mImpl->mRenderer = CreateRenderer();
- Image image = LoadImage( imageUrl, IsSynchronousResourceLoading() );
- ApplyImageToSampler( image );
+ Vector4 atlasRect; // ignored in this case
+ TextureSet textures = CreateTextureSet( atlasRect, imageUrl, IsSynchronousResourceLoading(), false );
+ CreateRenderer( textures );
}
}
{
mImpl->mFlags &= ~Impl::IS_FROM_CACHE;
- mImpl->mRenderer = CreateRenderer();
+ // don't reuse CreateTextureSet
+ TextureSet textures = TextureSet::New();
+ // Renderer can't be shared if mImage is NativeImage
+ NativeImage nativeImage = NativeImage::DownCast( image );
+ if( nativeImage )
+ {
+ CreateNativeImageRenderer( nativeImage );
+ DALI_ASSERT_DEBUG( textures );
+ mImpl->mRenderer.SetTextures( textures );
+ }
+ else
+ {
+ // reuse existing code for regular images
+ CreateRenderer( textures );
+ }
if( image )
{
if( image )
{
TextureSet textureSet = mImpl->mRenderer.GetTextures();
- if( !textureSet )
- {
- textureSet = TextureSet::New();
- mImpl->mRenderer.SetTextures( textureSet );
- }
+ DALI_ASSERT_DEBUG( textureSet ); // texture set should always exist by this time
+
TextureSetImage( textureSet, 0u, image );
Sampler sampler = Sampler::New();
sampler.SetWrapMode( mWrapModeU, mWrapModeV );
{
if( IsFromCache() )
{
- TextureSet textureSet = mImpl->mRenderer.GetTextures();
-
Vector4 atlasRect( 0.f, 0.f, 1.f, 1.f );
Property::Index index = mImpl->mRenderer.GetPropertyIndex( ATLAS_RECT_UNIFORM_NAME );
if( index != Property::INVALID_INDEX )
atlasRectValue.Get( atlasRect );
}
+ TextureSet textureSet = mImpl->mRenderer.GetTextures();
mImpl->mRenderer.Reset();
if( mFactoryCache.CleanRendererCache( url ) && index != Property::INVALID_INDEX )
{
}
}
-void ImageVisual::SetNativeFragmentShaderCode( Dali::NativeImage& nativeImage )
-{
- const char* fragmentPreFix = nativeImage.GetCustomFragmentPreFix();
- const char* customSamplerTypename = nativeImage.GetCustomSamplerTypename();
-
- if( fragmentPreFix )
- {
- mNativeFragmentShaderCode = fragmentPreFix;
- mNativeFragmentShaderCode += "\n";
- }
-
- if( mImpl->mCustomShader && !mImpl->mCustomShader->mFragmentShader.empty() )
- {
- mNativeFragmentShaderCode += mImpl->mCustomShader->mFragmentShader;
- }
- else
- {
- mNativeFragmentShaderCode += FRAGMENT_SHADER_NO_ATLAS;
- }
-
- if( customSamplerTypename )
- {
- mNativeFragmentShaderCode.replace( mNativeFragmentShaderCode.find( DEFAULT_SAMPLER_TYPENAME ), strlen( DEFAULT_SAMPLER_TYPENAME ), customSamplerTypename );
- }
-}
-
} // namespace Internal
} // namespace Toolkit
*
*/
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/visuals/visual-base-impl.h>
-#include <dali-toolkit/devel-api/image-loader/atlas-upload-observer.h>
-
// EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/images/image.h>
#include <dali/public-api/images/image-operations.h>
#include <dali/public-api/images/resource-image.h>
#include <dali/devel-api/object/weak-handle.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
+#include <dali-toolkit/devel-api/image-loader/atlas-upload-observer.h>
+
namespace Dali
{
public:
/**
- * @brief Constructor.
+ * @brief Create a new image visual.
*
- * @param[in] factoryCache The VisualFactoryCache object
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @return A smart-pointer to the newly allocated visual.
*/
- ImageVisual( VisualFactoryCache& factoryCache );
+ static ImageVisualPtr New( VisualFactoryCache& factoryCache );
/**
- * @brief Constructor with a URL.
+ * @brief Create a new image visual with a URL.
*
* The visual will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
*
* @param[in] fittingMode The FittingMode of the resource to load
* @param[in] samplingMode The SamplingMode of the resource to load
*/
- ImageVisual( VisualFactoryCache& factoryCache,
- const std::string& imageUrl,
- ImageDimensions size=ImageDimensions(),
- FittingMode::Type fittingMode = FittingMode::DEFAULT,
- Dali::SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR );
+ static ImageVisualPtr New( VisualFactoryCache& factoryCache,
+ const std::string& imageUrl,
+ ImageDimensions size = ImageDimensions(),
+ FittingMode::Type fittingMode = FittingMode::DEFAULT,
+ Dali::SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR );
/**
- * @brief Constructor with an Image type.
+ * @brief Create a new image visual with an Image type.
*
* @param[in] factoryCache The VisualFactoryCache object
* @param[in] image The image to use
*/
- ImageVisual( VisualFactoryCache& factoryCache, const Image& image );
-
- /**
- * @brief A reference counted object may only be deleted by calling Unreference().
- */
- ~ImageVisual();
+ static ImageVisualPtr New( VisualFactoryCache& factoryCache, const Image& image );
public: // from Visual
virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
protected:
+
+ /**
+ * @brief Constructor.
+ *
+ * @param[in] factoryCache The VisualFactoryCache object
+ */
+ ImageVisual( VisualFactoryCache& factoryCache );
+
+ /**
+ * @brief Constructor with a URL.
+ *
+ * The visual will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
+ *
+ * @param[in] factoryCache The VisualFactoryCache object
+ * @param[in] imageUrl The URL of the image resource to use
+ * @param[in] size The width and height to fit the loaded image to.
+ * @param[in] fittingMode The FittingMode of the resource to load
+ * @param[in] samplingMode The SamplingMode of the resource to load
+ */
+ ImageVisual( VisualFactoryCache& factoryCache,
+ const std::string& imageUrl,
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ Dali::SamplingMode::Type samplingMode );
+
+ /**
+ * @brief Constructor with an Image type.
+ *
+ * @param[in] factoryCache The VisualFactoryCache object
+ * @param[in] image The image to use
+ */
+ ImageVisual( VisualFactoryCache& factoryCache, const Image& image );
+
/**
- * @copydoc Visual::Base::DoInitialize
+ * @brief A reference counted object may only be deleted by calling Unreference().
*/
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+ virtual ~ImageVisual();
+
+ /**
+ * @copydoc Visual::Base::DoSetProperties
+ */
+ virtual void DoSetProperties( const Property::Map& propertyMap );
/**
* @copydoc Visual::Base::DoSetOnStage
/**
* @brief Creates the Dali::Renderer (potentially from the renderer cache), initializing it
- *
- * @return Returns the created Dali::Renderer
+ * @param[in] textures to use
*/
- Renderer CreateRenderer() const;
+ void CreateRenderer( TextureSet& textures );
/**
* @brief Creates the Dali::Renderer for NativeImage with custom sampler type and prefix, initializing it
- *
- * @return Returns the created Dali::Renderer
+ * @param NativeImageRenderer
*/
- Renderer CreateNativeImageRenderer() const;
+ void CreateNativeImageRenderer( NativeImage& nativeImage );
/**
* @brief Query whether resources requires to be loaded synchronously.
void LoadResourceSynchronously();
/**
- * Load the image.
+ * Creates the texture set and adds the texture to it
+ * @param[out] textureRect The texture area of the texture in the atlas.
* @param[in] url The URL of the image resource to use.
* @param[in] synchronousLoading If true, the resource is loaded synchronously, otherwise asynchronously.
+ * @param[in] attemptAtlasing If true will attempt atlasing, otherwise create unique texture
+ * @return the texture set to use
*/
- Image LoadImage( const std::string& url, bool synchronousLoading );
-
- /**
- * Load the image and create a texture set to hold the texture, with automatic atlasing applied.
- * @param [out] textureRect The texture area of the resource image in the atlas.
- * @param[in] url The URL of the image resource to use.
- * @param[in] synchronousLoading If true, the resource is loaded synchronously, otherwise asynchronously.
- */
- TextureSet CreateTextureSet( Vector4& textureRect, const std::string& url, bool synchronousLoading );
+ TextureSet CreateTextureSet( Vector4& textureRect, const std::string& url, bool synchronousLoading, bool attemptAtlasing );
/**
* Callback function of image resource loading succeed
*/
void CleanCache(const std::string& url);
- /**
- * Set shader code for nativeimage if it exists
- */
- void SetNativeFragmentShaderCode( Dali::NativeImage& nativeImage );
-
private:
+
Image mImage;
PixelData mPixels;
Vector4 mPixelArea;
WeakHandle<Actor> mPlacementActor;
-
std::string mImageUrl;
+
Dali::ImageDimensions mDesiredSize;
- Dali::FittingMode::Type mFittingMode;
- Dali::SamplingMode::Type mSamplingMode;
- Dali::WrapMode::Type mWrapModeU;
- Dali::WrapMode::Type mWrapModeV;
+ Dali::FittingMode::Type mFittingMode:3;
+ Dali::SamplingMode::Type mSamplingMode:4;
+ Dali::WrapMode::Type mWrapModeU:3;
+ Dali::WrapMode::Type mWrapModeV:3;
- std::string mNativeFragmentShaderCode;
- bool mNativeImageFlag;
};
} // namespace Internal
}\n
);
-} // namespace
+} // unnamed namespace
+
+MeshVisualPtr MeshVisual::New( VisualFactoryCache& factoryCache )
+{
+ return new MeshVisual( factoryCache );
+}
MeshVisual::MeshVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache ),
{
}
-void MeshVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void MeshVisual::DoSetProperties( const Property::Map& propertyMap )
{
Property::Value* objectUrl = propertyMap.Find( Toolkit::MeshVisual::Property::OBJECT_URL, OBJECT_URL_NAME );
if( !objectUrl || !objectUrl->Get( mObjectUrl ) )
// EXTERNAL INCLUDES
#include <fstream>
#include <string.h>
+#include <dali/public-api/common/intrusive-ptr.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/mesh-visual-properties.h>
namespace Internal
{
+class MeshVisual;
+typedef IntrusivePtr< MeshVisual > MeshVisualPtr;
+
/**
* The visual which renders a 3D object to the control's quad
*
public:
/**
- * @brief Constructor.
+ * @brief Create a new mesh visual.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @return A smart-pointer to the newly allocated visual.
*/
- MeshVisual( VisualFactoryCache& factoryCache );
-
- /**
- * @brief A reference counted object may only be deleted by calling Unreference().
- */
- virtual ~MeshVisual();
+ static MeshVisualPtr New( VisualFactoryCache& factoryCache );
public: // from Visual
protected:
/**
- * @copydoc Visual::Base::DoInitialize
+ * @brief Constructor.
+ *
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ */
+ MeshVisual( VisualFactoryCache& factoryCache );
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~MeshVisual();
+
+ /**
+ * @copydoc Visual::Base::DoSetProperties
*/
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+ virtual void DoSetProperties( const Property::Map& propertyMap );
/**
* @copydoc Visual::Base::DoSetOnStage
/////////////////NPatchVisual////////////////
-NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache )
-: Visual::Base( factoryCache ),
- mImage(),
- mCroppedImage(),
- mImageUrl(),
- mStretchPixelsX(),
- mStretchPixelsY(),
- mImageSize(),
- mBorderOnly( false )
+NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache )
{
+ return new NPatchVisual( factoryCache );
}
-NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache, const std::string& imageUrl, bool borderOnly )
-: Visual::Base( factoryCache ),
- mImage(),
- mCroppedImage(),
- mImageUrl( imageUrl ),
- mStretchPixelsX(),
- mStretchPixelsY(),
- mImageSize(),
- mBorderOnly( borderOnly )
+NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, bool borderOnly )
{
- NinePatchImage nPatch = NinePatchImage::New( mImageUrl );
- InitializeFromImage( nPatch );
+ NPatchVisual* nPatchVisual = new NPatchVisual( factoryCache, borderOnly );
+ nPatchVisual->mImageUrl = imageUrl;
+
+ NinePatchImage image = NinePatchImage::New( imageUrl );
+ nPatchVisual->InitializeFromImage( image );
+
+ return nPatchVisual;
}
-NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache, NinePatchImage image, bool borderOnly )
+NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, NinePatchImage image, bool borderOnly )
+{
+ NPatchVisual* nPatchVisual = new NPatchVisual( factoryCache, borderOnly );
+ nPatchVisual->mImage = image;
+
+ nPatchVisual->InitializeFromImage( image );
+
+ return nPatchVisual;
+}
+
+NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache, bool borderOnly )
: Visual::Base( factoryCache ),
- mImage( image ),
+ mImage(),
mCroppedImage(),
mImageUrl(),
mStretchPixelsX(),
mImageSize(),
mBorderOnly( borderOnly )
{
- InitializeFromImage( image );
}
NPatchVisual::~NPatchVisual()
{
}
-void NPatchVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void NPatchVisual::DoSetProperties( const Property::Map& propertyMap )
{
Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
if( imageURLValue )
*
*/
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/visuals/visual-base-impl.h>
-
// EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/images/image.h>
#include <dali/public-api/images/image-operations.h>
#include <dali/devel-api/images/nine-patch-image.h>
#include <dali/public-api/rendering/sampler.h>
#include <dali/public-api/rendering/shader.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
+
namespace Dali
{
namespace Internal
{
+class NPatchVisual;
+typedef IntrusivePtr< NPatchVisual > NPatchVisualPtr;
+
/**
* The visual which renders an 9 patch image to the control's quad
*
public:
/**
- * @brief Constructor.
+ * @brief Create a new n-patch visual.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @return A smart-pointer to the newly allocated visual.
*/
- NPatchVisual( VisualFactoryCache& factoryCache );
+ static NPatchVisualPtr New( VisualFactoryCache& factoryCache );
/**
- * @brief Constructor which creates an N-patch visual using an image URL.
+ * @brief Create an N-patch visual using an image URL.
*
* The visual will load the image synchronously when the associated actor is put on stage, and destroy the image when it is off stage
*
* @param[in] imageUrl The URL to 9 patch image resource to use
* @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
*/
- NPatchVisual( VisualFactoryCache& factoryCache, const std::string& imageUrl, bool borderOnly = false );
+ static NPatchVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl, bool borderOnly = false );
/**
- * @brief Constructor which creates an N-patch viusal with a NinePatchImage resource.
+ * @brief Create an N-patch visual with a NinePatchImage resource.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
* @param[in] image The NinePatchImage to use
* @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
*/
- NPatchVisual( VisualFactoryCache& factoryCache, NinePatchImage image, bool borderOnly = false );
-
- /**
- * @brief A reference counted object may only be deleted by calling Unreference().
- */
- ~NPatchVisual();
+ static NPatchVisualPtr New( VisualFactoryCache& factoryCache, NinePatchImage image, bool borderOnly = false );
public: // from Visual
protected:
/**
- * @copydoc Visual::Base::DoInitialize
+ * @brief Constructor.
+ *
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
+ */
+ NPatchVisual( VisualFactoryCache& factoryCache, bool borderOnly = false );
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~NPatchVisual();
+
+ /**
+ * @copydoc Visual::Base::DoSetProperties
*/
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+ virtual void DoSetProperties( const Property::Map& propertyMap );
/**
* @copydoc Visual::Base::DoSetOnStage
}\n
);
-} // namespace
+} // unnamed namespace
+
+PrimitiveVisualPtr PrimitiveVisual::New( VisualFactoryCache& factoryCache )
+{
+ return new PrimitiveVisual( factoryCache );
+}
PrimitiveVisual::PrimitiveVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache ),
{
}
-void PrimitiveVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void PrimitiveVisual::DoSetProperties( const Property::Map& propertyMap )
{
//Find out which shape to renderer.
Property::Value* primitiveTypeValue = propertyMap.Find( Toolkit::PrimitiveVisual::Property::SHAPE, PRIMITIVE_SHAPE );
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/primitive-visual-properties.h>
namespace Internal
{
+class PrimitiveVisual;
+typedef IntrusivePtr< PrimitiveVisual > PrimitiveVisualPtr;
+
/**
* The visual which renders a simple 3D shape to the control's quad
*
public:
/**
- * @brief Constructor.
+ * @brief Create a new primitive visual.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @return A smart-pointer to the newly allocated visual.
*/
- PrimitiveVisual( VisualFactoryCache& factoryCache );
-
- /**
- * @brief A reference counted object may only be deleted by calling Unreference().
- */
- virtual ~PrimitiveVisual();
+ static PrimitiveVisualPtr New( VisualFactoryCache& factoryCache );
public: // from Visual
protected:
/**
- * @copydoc Visual::Base::DoInitialize
+ * @brief Constructor.
+ *
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ */
+ PrimitiveVisual( VisualFactoryCache& factoryCache );
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~PrimitiveVisual();
+
+ /**
+ * @copydoc Visual::Base::DoSetProperties
*/
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+ virtual void DoSetProperties( const Property::Map& propertyMap );
/**
* @copydoc Visual::Base::DoSetOnStage
namespace Internal
{
-SvgVisual::SvgVisual( VisualFactoryCache& factoryCache )
-: Visual::Base( factoryCache ),
- mAtlasRect( FULL_TEXTURE_RECT ),
- mImageUrl(),
- mParsedImage( NULL ),
- mPlacementActor()
+SvgVisualPtr SvgVisual::New( VisualFactoryCache& factoryCache )
{
- // the rasterized image is with pre-multiplied alpha format
- mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
+ return new SvgVisual( factoryCache );
+}
+
+SvgVisualPtr SvgVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, ImageDimensions size )
+{
+ SvgVisual* svgVisual = new SvgVisual( factoryCache );
+ svgVisual->ParseFromUrl( imageUrl, size );
+ return svgVisual;
}
-SvgVisual::SvgVisual( VisualFactoryCache& factoryCache, const std::string& imageUrl, ImageDimensions size )
+SvgVisual::SvgVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache ),
mAtlasRect( FULL_TEXTURE_RECT ),
mImageUrl(),
{
// the rasterized image is with pre-multiplied alpha format
mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
-
- ParseFromUrl( imageUrl, size );
}
SvgVisual::~SvgVisual()
}
}
-void SvgVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void SvgVisual::DoSetProperties( const Property::Map& propertyMap )
{
Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
if( imageURLValue )
*
*/
-//EXTERNAL INCLUDES
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/devel-api/object/weak-handle.h>
// INTERNAL INCLUDES
namespace Internal
{
+class SvgVisual;
+typedef IntrusivePtr< SvgVisual > SvgVisualPtr;
+
/**
* The visual which renders a svg image
*
public:
/**
- * @brief Constructor.
+ * @brief Create a new SVG visual.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @return A smart-pointer to the newly allocated visual.
*/
- SvgVisual( VisualFactoryCache& factoryCache );
+ static SvgVisualPtr New( VisualFactoryCache& factoryCache );
/**
- * @brief Constructor which creates the SVG Visual using the image URL.
+ * @brief Create the SVG Visual using the image URL.
*
* The visual will parse the SVG image once it is set.
* And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
* @param[in] imageUrl The URL to svg resource to use
+ * @param[in] size The required size for the SVG
*/
- SvgVisual( VisualFactoryCache& factoryCache, const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
-
- /**
- * @brief A reference counted object may only be deleted by calling Unreference().
- */
- ~SvgVisual();
+ static SvgVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
public: // from Visual
protected:
/**
- * @copydoc Visual::Base::DoInitialize
+ * @brief Constructor.
+ *
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ */
+ SvgVisual( VisualFactoryCache& factoryCache );
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~SvgVisual();
+
+ /**
+ * @copydoc Visual::Base::DoSetProperties
*/
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+ virtual void DoSetProperties( const Property::Map& propertyMap );
/**
* @copydoc Visual::Base::DoSetOnStage
return geometry;
}
-} // namespace
+} // unnamed namespace
-TextVisual::TextVisual( VisualFactoryCache& factoryCache )
-: Visual::Base( factoryCache ),
- mController( Text::Controller::New() ),
- mRenderingBackend( Toolkit::Text::DEFAULT_RENDERING_BACKEND ),
- mHasBeenStaged( false )
-{
-}
-
-TextVisual::~TextVisual()
+TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache )
{
+ return new TextVisual( factoryCache );
}
void TextVisual::SetTextControlInterface( Text::ControlInterface* controlInterface )
map.Insert( Toolkit::TextVisual::Property::BATCHING_ENABLED, false ); // TODO
}
-void TextVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+TextVisual::TextVisual( VisualFactoryCache& factoryCache )
+: Visual::Base( factoryCache ),
+ mController( Text::Controller::New() ),
+ mRenderingBackend( Toolkit::Text::DEFAULT_RENDERING_BACKEND ),
+ mHasBeenStaged( false )
{
- mSelf = actor;
+}
+TextVisual::~TextVisual()
+{
+}
+
+void TextVisual::DoSetProperties( const Property::Map& propertyMap )
+{
for( Property::Map::SizeType index = 0u, count = propertyMap.Count(); index < count; ++index )
{
const KeyValuePair& keyValue = propertyMap.GetKeyValue( index );
void TextVisual::RenderText()
{
+ Actor self = mSelf.GetHandle();
+ if( !self )
+ {
+ // Nothing to do if the handle is not initialized.
+ return;
+ }
+
Actor renderableActor;
if( mRenderer )
const Vector2& scrollOffset = mController->GetScrollPosition();
renderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
- mSelf.Add( renderableActor );
+ self.Add( renderableActor );
}
mRenderableActor = renderableActor;
void TextVisual::SetUpAutoScrolling()
{
+ Actor self = mSelf.GetHandle();
+ if( !self )
+ {
+ // Nothing to do if the handle is not initialized.
+ return;
+ }
+
const Text::ScrollerData* const data = mController->GetAutoScrollData();
if( NULL != data )
mTextScroller->StartScrolling( mRenderableActor,
*data );
- mSelf.Add( mTextScroller->GetScrollingText() );
- mSelf.Add( mTextScroller->GetSourceCamera() );
+ self.Add( mTextScroller->GetScrollingText() );
+ self.Add( mTextScroller->GetSourceCamera() );
}
}
*
*/
+// EXTERNAL INCLUDES
+#include <dali/devel-api/object/weak-handle.h>
+#include <dali/public-api/common/intrusive-ptr.h>
+
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/text/rendering/text-renderer.h>
public:
/**
- * @brief Constructor.
+ * @brief Create a new text visual.
*
- * @param[in] factoryCache The VisualFactoryCache object
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @return A smart-pointer to the newly allocated visual.
*/
- TextVisual( VisualFactoryCache& factoryCache );
+ static TextVisualPtr New( VisualFactoryCache& factoryCache );
/**
- * @brief A reference counted object may only be deleted by calling Unreference().
- */
- ~TextVisual();
-
- /**
- *
+ * @brief Sets the text control interface which is needed to communicate with a control.
+ * @param[in] controlInterface Pointer to the control-interface.
*/
void SetTextControlInterface( Text::ControlInterface* controlInterface );
*/
virtual void DoCreatePropertyMap( Property::Map& map ) const;
-protected: // from Visual::Base
+protected:
+
+ /**
+ * @brief Constructor.
+ *
+ * @param[in] factoryCache The VisualFactoryCache object
+ */
+ TextVisual( VisualFactoryCache& factoryCache );
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~TextVisual();
+
+ // from Visual::Base
+
/**
- * @copydoc Visual::Base::DoInitialize()
+ * @copydoc Visual::Base::DoSetProperties()
*/
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
+ virtual void DoSetProperties( const Property::Map& propertyMap );
/**
* @copydoc Visual::Base::DoSetOnStage()
private:
Text::ControllerPtr mController; ///< The text's controller.
- Actor mSelf;
+ WeakHandle<Actor> mSelf;
Text::RendererPtr mRenderer;
Text::TextScrollerPtr mTextScroller;
--- /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 )
+ {
+ if( value.GetType() == Property::ARRAY )
+ {
+ bool valid = true;
+ Vector4 controlPoints;
+ Property::Array *array = value.GetArray();
+ if( array->Count() >= 4 )
+ {
+ for( size_t vecIdx = 0; vecIdx < 4; ++vecIdx )
+ {
+ Property::Value& v = array->GetElementAt(vecIdx);
+ if( v.GetType() == Property::FLOAT )
+ {
+ controlPoints[vecIdx] = v.Get<float>();
+ }
+ else
+ {
+ valid = false;
+ break;
+ }
+ }
+ }
+ else
+ {
+ valid = false;
+ }
+
+ if( valid )
+ {
+ Vector2 controlPoint1( controlPoints.x, controlPoints.y );
+ Vector2 controlPoint2( controlPoints.z, controlPoints.w );
+ animator->alphaFunction = AlphaFunction( controlPoint1, controlPoint2 );
+ }
+ else
+ {
+ animator->animate = false;
+ }
+ }
+ else if( value.GetType() == Property::VECTOR4 )
+ {
+ Vector4 controlPoints = value.Get<Vector4>();
+ Vector2 controlPoint1( controlPoints.x, controlPoints.y );
+ Vector2 controlPoint2( controlPoints.z, controlPoints.w );
+ animator->alphaFunction = AlphaFunction( controlPoint1, controlPoint2 );
+ }
+ else if( value.GetType() == Property::STRING )
+ {
+ std::string alphaFunctionValue = value.Get< std::string >();
+
+ if( alphaFunctionValue == "LINEAR" )
+ {
+ animator->alphaFunction = AlphaFunction(AlphaFunction::LINEAR);
+ }
+ else if( ! alphaFunctionValue.compare(0, 5, "EASE_" ) )
+ {
+ if( alphaFunctionValue == "EASE_IN" )
+ {
+ animator->alphaFunction = AlphaFunction(AlphaFunction::EASE_IN);
+ }
+ else if( alphaFunctionValue == "EASE_OUT" )
+ {
+ animator->alphaFunction = AlphaFunction(AlphaFunction::EASE_OUT);
+ }
+ else if( ! alphaFunctionValue.compare( 5, 3, "IN_" ) )
+ {
+ if( ! alphaFunctionValue.compare(8, -1, "SQUARE" ))
+ {
+ animator->alphaFunction = AlphaFunction(AlphaFunction::EASE_IN_SQUARE);
+ }
+ else if( ! alphaFunctionValue.compare(8, -1, "OUT" ))
+ {
+ animator->alphaFunction = AlphaFunction(AlphaFunction::EASE_IN_OUT);
+ }
+ else if( ! alphaFunctionValue.compare(8, -1, "OUT_SINE" ))
+ {
+ animator->alphaFunction = AlphaFunction(AlphaFunction::EASE_IN_OUT_SINE);
+ }
+ else if( ! alphaFunctionValue.compare(8, -1, "SINE" ))
+ {
+ animator->alphaFunction = AlphaFunction(AlphaFunction::EASE_IN_SINE);
+ }
+ }
+ else if( ! alphaFunctionValue.compare( 5, 4, "OUT_" ) )
+ {
+ if( ! alphaFunctionValue.compare(9, -1, "SQUARE" ) )
+ {
+ animator->alphaFunction = AlphaFunction(AlphaFunction::EASE_OUT_SQUARE);
+ }
+ else if( ! alphaFunctionValue.compare(9, -1, "SINE" ) )
+ {
+ animator->alphaFunction = AlphaFunction(AlphaFunction::EASE_OUT_SINE);
+ }
+ else if( ! alphaFunctionValue.compare(9, -1, "BACK" ) )
+ {
+ animator->alphaFunction = AlphaFunction(AlphaFunction::EASE_OUT_BACK);
+ }
+ }
+ }
+ else if( alphaFunctionValue == "REVERSE" )
+ {
+ animator->alphaFunction = AlphaFunction(AlphaFunction::REVERSE);
+ }
+ else if( alphaFunctionValue == "BOUNCE" )
+ {
+ animator->alphaFunction = AlphaFunction(AlphaFunction::BOUNCE);
+ }
+ else if( alphaFunctionValue == "SIN" )
+ {
+ animator->alphaFunction = AlphaFunction(AlphaFunction::SIN);
+ }
+ }
+ else
+ {
+ animator->animate = false;
+ }
+ }
+ 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 )
+ {
+ Property::Map animateMap;
+
+ if( animator->alphaFunction.GetMode() == AlphaFunction::BUILTIN_FUNCTION )
+ {
+ animateMap.Add(TOKEN_ALPHA_FUNCTION, GetEnumerationName( animator->alphaFunction.GetBuiltinFunction(),
+ ALPHA_FUNCTION_BUILTIN_TABLE,
+ ALPHA_FUNCTION_BUILTIN_TABLE_COUNT ));
+ }
+ else if( animator->alphaFunction.GetMode() == AlphaFunction::BEZIER )
+ {
+ Vector4 controlPoints = animator->alphaFunction.GetBezierControlPoints();
+ animateMap.Add( TOKEN_ALPHA_FUNCTION, controlPoints );
+ }
+ animateMap.Add(TOKEN_TIME_PERIOD, Property::Map()
+ .Add( TOKEN_DELAY, animator->timePeriodDelay )
+ .Add( TOKEN_DURATION, animator->timePeriodDuration ));
+
+ map[TOKEN_ANIMATOR] = animateMap;
+ }
+
+ 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 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 );
}
}
-void Visual::Base::Initialize( Actor& actor, const Property::Map& propertyMap )
+void Visual::Base::SetProperties( const Property::Map& propertyMap )
{
Property::Value* customShaderValue = propertyMap.Find( Toolkit::Visual::Property::SHADER, CUSTOM_SHADER );
if( customShaderValue )
}
}
- DoInitialize( actor, propertyMap );
+ DoSetProperties( 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 )
*/
// EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/images/image-operations.h>
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/rendering/shader.h>
public:
/**
- * Initialisation of the visual, this API should only called by the VisualFactory:
- * request the geometry and shader from the cache, if not available, create and save to the cache for sharing;
- * record the property values.
- *
- * @param[in] actor The Actor the visual is applied to if, empty if the visual has not been applied to any Actor
+ * Setting the properties of the visual, this API should only called by the VisualFactory
* @param[in] propertyMap The properties for the requested Visual object.
*/
- void Initialize( Actor& actor, const Property::Map& propertyMap );
+ void SetProperties( 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 DoCreatePropertyMap( Property::Map& map ) const = 0;
/**
- * @brief Called by Initialize() allowing sub classes to respond to the Initialize event
+ * @brief Called by SetProperties() allowing sub classes to set their properties
*
- * @param[in] actor The Actor the visual is applied to if, empty if the visual has not been applied to any Actor
* @param[in] propertyMap The properties for the requested Visual object.
*/
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap ) {}
+ virtual void DoSetProperties( const Property::Map& propertyMap ) = 0;
protected:
VisualFactoryCache& mFactoryCache;
};
+typedef IntrusivePtr<Base> BasePtr;
+
} // namspace Visual
} // namespace Internal
// Return a new WireframeVisual if we have debug enabled
if( mDebugEnabled )
{
- return Toolkit::Visual::Base( new WireframeVisual( *( mFactoryCache.Get() ) ) );
+ return Toolkit::Visual::Base( WireframeVisual::New( *( mFactoryCache.Get() ) ).Get() );
}
- Visual::Base* visualPtr = NULL;
+ Visual::BasePtr visualPtr;
Property::Value* typeValue = propertyMap.Find( Toolkit::Visual::Property::TYPE, VISUAL_TYPE );
Toolkit::Visual::Type visualType = Toolkit::Visual::IMAGE; // Default to IMAGE type.
{
case Toolkit::Visual::BORDER:
{
- visualPtr = new BorderVisual( *( mFactoryCache.Get() ) );
+ visualPtr = BorderVisual::New( *( mFactoryCache.Get() ) );
break;
}
case Toolkit::Visual::COLOR:
{
- visualPtr = new ColorVisual( *( mFactoryCache.Get() ) );
+ visualPtr = ColorVisual::New( *( mFactoryCache.Get() ) );
break;
}
case Toolkit::Visual::GRADIENT:
{
- visualPtr = new GradientVisual( *( mFactoryCache.Get() ) );
+ visualPtr = GradientVisual::New( *( mFactoryCache.Get() ) );
break;
}
UrlType::Type type = ResolveUrlType( imageUrl );
if( UrlType::N_PATCH == type )
{
- visualPtr = new NPatchVisual( *( mFactoryCache.Get() ) );
+ visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ) );
}
else if( UrlType::SVG == type )
{
- visualPtr = new SvgVisual( *( mFactoryCache.Get() ) );
+ visualPtr = SvgVisual::New( *( mFactoryCache.Get() ) );
}
else // Regular image
{
if( batchingEnabled )
{
- visualPtr = new BatchImageVisual( *( mFactoryCache.Get() ) );
+ visualPtr = BatchImageVisual::New( *( mFactoryCache.Get() ) );
break;
}
else
{
- visualPtr = new ImageVisual( *( mFactoryCache.Get() ) );
+ visualPtr = ImageVisual::New( *( mFactoryCache.Get() ) );
}
}
}
case Toolkit::Visual::MESH:
{
- visualPtr = new MeshVisual( *( mFactoryCache.Get() ) );
+ visualPtr = MeshVisual::New( *( mFactoryCache.Get() ) );
break;
}
case Toolkit::Visual::PRIMITIVE:
{
- visualPtr = new PrimitiveVisual( *( mFactoryCache.Get() ) );
+ visualPtr = PrimitiveVisual::New( *( mFactoryCache.Get() ) );
break;
}
case Toolkit::Visual::WIREFRAME:
{
- visualPtr = new WireframeVisual( *( mFactoryCache.Get() ) );
+ visualPtr = WireframeVisual::New( *( mFactoryCache.Get() ) );
break;
}
case Toolkit::Visual::TEXT:
{
- visualPtr = new TextVisual( *( mFactoryCache.Get() ) );
+ visualPtr = TextVisual::New( *( mFactoryCache.Get() ) );
break;
}
-
}
if( visualPtr )
{
- Actor actor;
- visualPtr->Initialize( actor, propertyMap );
+ visualPtr->SetProperties( propertyMap );
}
else
{
DALI_LOG_ERROR( "Renderer type unknown\n" );
}
- return Toolkit::Visual::Base( visualPtr );
+ return Toolkit::Visual::Base( visualPtr.Get() );
}
Toolkit::Visual::Base VisualFactory::CreateVisual( const Image& image )
if( mDebugEnabled )
{
- return Toolkit::Visual::Base( new WireframeVisual( *( mFactoryCache.Get() ) ) );
+ return Toolkit::Visual::Base( WireframeVisual::New( *( mFactoryCache.Get() ) ).Get() );
}
+ Visual::BasePtr visualPtr;
+
NinePatchImage npatchImage = NinePatchImage::DownCast( image );
if( npatchImage )
{
- NPatchVisual* visualPtr = new NPatchVisual( *( mFactoryCache.Get() ), npatchImage );
- return Toolkit::Visual::Base( visualPtr );
+ visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), npatchImage );
}
else
{
- ImageVisual* visualPtr = new ImageVisual( *( mFactoryCache.Get() ), image );
- return Toolkit::Visual::Base( visualPtr );
+ visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), image );
}
+
+ return Toolkit::Visual::Base( visualPtr.Get() );
}
Toolkit::Visual::Base VisualFactory::CreateVisual( const std::string& url, ImageDimensions size )
if( mDebugEnabled )
{
- return Toolkit::Visual::Base( new WireframeVisual( *( mFactoryCache.Get() ) ) );
+ return Toolkit::Visual::Base( WireframeVisual::New( *( mFactoryCache.Get() ) ).Get() );
}
+ Visual::BasePtr visualPtr;
+
// first resolve url type to know which visual to create
UrlType::Type type = ResolveUrlType( url );
if( UrlType::N_PATCH == type )
{
- NPatchVisual* visualPtr = new NPatchVisual( *( mFactoryCache.Get() ), url );
- return Toolkit::Visual::Base( visualPtr );
+ visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), url );
}
else if( UrlType::SVG == type )
{
- SvgVisual* visualPtr = new SvgVisual( *( mFactoryCache.Get() ), url, size );
- return Toolkit::Visual::Base( visualPtr );
+ visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), url, size );
}
else // Regular image
{
- ImageVisual* visualPtr = new ImageVisual( *( mFactoryCache.Get() ), url, size );
- return Toolkit::Visual::Base( visualPtr );
+ visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), url, size );
}
+
+ return Toolkit::Visual::Base( visualPtr.Get() );
}
} // namespace Internal
}
+WireframeVisualPtr WireframeVisual::New( VisualFactoryCache& factoryCache )
+{
+ return new WireframeVisual( factoryCache );
+}
WireframeVisual::WireframeVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache )
}
WireframeVisual::~WireframeVisual()
-{}
+{
+}
+
+void WireframeVisual::DoSetProperties( const Property::Map& propertyMap )
+{
+ // no properties supported at the moment
+}
void WireframeVisual::DoSetOnStage( Actor& actor )
{
*
*/
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
+
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
namespace Internal
{
+class WireframeVisual;
+typedef IntrusivePtr< WireframeVisual > WireframeVisualPtr;
+
/**
- * The visual which renders a wireframe outline to the control's quad.
- *
+ * @brief Renders a wireframe outline to the control's quad.
*/
class WireframeVisual: public Visual::Base
{
public:
/**
+ * @brief Create a new wireframe visual.
+ *
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @return A smart-pointer to the newly allocated visual.
+ */
+ static WireframeVisualPtr New( VisualFactoryCache& factoryCache );
+
+protected:
+
+ /**
* @brief Constructor.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
*/
virtual ~WireframeVisual();
-protected:
+ /**
+ * @copydoc Visual::Base::DoSetProperties()
+ */
+ virtual void DoSetProperties( const Property::Map& propertyMap );
/**
* @copydoc Visual::Base::DoSetOnStage
#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
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 10;
+const unsigned int TOOLKIT_MICRO_VERSION = 11;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
$(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
Name: dali-addon
Summary: DALi module for Node.JS
-Version: 1.2.10
+Version: 1.2.11
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
Name: NDalic
Summary: dali wrapper
-Version: 1.0.0
+Version: 1.2.11
Release: 1
Group: uifw/graphic
License: TO_BE_FILLED_IN
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.2.10
+Version: 1.2.11
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-2-Clause and MIT
--- /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.
+ *
+ */
+
+%typemap(cscode) Dali::AlphaFunction %{
+ public AlphaFunction(Dali.Constants.AlphaFunction.BuiltinFunction function) : this(NDalicPINVOKE.new_AlphaFunction__SWIG_1((int)function), true){
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+%}
+
+
+
* This is because from C# we can't wrap the operator BooleanType() function
*/
%extend Dali::BaseHandle {
- bool IsHandleEmpty() const {
+ bool HasBody() const {
+
+ // C++ code. DALi uses Handle <-> Body design pattern.
+ // This function checks the Handle to see if it has a body attached ( possible to have empty handles).
+ // Handles in DALi can be converted into a boolean type
+ // to check if the handle has a valid body attached to it.
+ // Internally checking *$self will checks IntrusivePtr<Dali::RefObject> mObjectHandle in BaseHandle;
if( *$self )
{
return true;
return false;
}
}
+
+ // Check if two handles point to the same body / ref-object.
+ bool IsEqual( const BaseHandle& rhs ) const {
+
+ // C++ code. Check if two handles reference the same implemtion
+ if( *$self == rhs)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
};
/**
*/
%typemap(cscode) Dali::BaseHandle %{
- public static bool operator true(BaseHandle handle)
- {
- if( handle!= null )
- {
- return handle.IsHandleEmpty();
- }
- else
- {
- return false;
- }
- }
- public static bool operator false(BaseHandle handle)
- {
- return handle.IsHandleEmpty();
- }
-%}
+ // Returns the bool value true to indicate that an operand is true and returns false otherwise.
+ public static bool operator true(BaseHandle handle)
+ {
+ // if the C# object is null, return false
+ if( BaseHandle.ReferenceEquals( handle, null ) )
+ {
+ return false;
+ }
+ // returns true if the handle has a body, false otherwise
+ return handle.HasBody();
+ }
+
+ // Returns the bool false to indicate that an operand is false and returns true otherwise.
+ public static bool operator false(BaseHandle handle)
+ {
+ // if the C# object is null, return true
+ if( BaseHandle.ReferenceEquals( handle, null ) )
+ {
+ return true;
+ }
+ return !handle.HasBody();
+ }
+
+ // Explicit conversion from Handle to bool.
+ public static explicit operator bool(BaseHandle handle)
+ {
+ // if the C# object is null, return false
+ if( BaseHandle.ReferenceEquals( handle, null ) )
+ {
+ return false;
+ }
+ // returns true if the handle has a body, false otherwise
+ return handle.HasBody();
+ }
+ // Equality operator
+ public static bool operator == (BaseHandle x, BaseHandle y)
+ {
+ // if the C# objects are the same return true
+ if( BaseHandle.ReferenceEquals( x, y ) )
+ {
+ return true;
+ }
+ if ( !BaseHandle.ReferenceEquals( x, null ) && !BaseHandle.ReferenceEquals( y, null ) )
+ {
+ // drop into native code to see if both handles point to the same body
+ return x.IsEqual( y) ;
+ }
+ return false;
+
+ }
+
+ // Inequality operator. Returns Null if either operand is Null
+ public static bool operator !=(BaseHandle x, BaseHandle y)
+ {
+ return !(x==y);
+ }
+
+ // Logical AND operator for &&
+ // It's possible when doing a && this function (opBitwiseAnd) is never called due
+ // to short circuiting. E.g.
+ // If you perform x && y What actually is called is
+ // BaseHandle.op_False( x ) ? BaseHandle.op_True( x ) : BaseHandle.opTrue( BaseHandle.opBitwiseAnd(x,y) )
+ //
+ public static BaseHandle operator &(BaseHandle x, BaseHandle y)
+ {
+ if( x == y )
+ {
+ return x;
+ }
+ return null;
+ }
+
+ // Logical OR operator for ||
+ // It's possible when doing a || this function (opBitwiseOr) is never called due
+ // to short circuiting. E.g.
+ // If you perform x || y What actually is called is
+ // BaseHandle.op_True( x ) ? BaseHandle.op_True( x ) : BaseHandle.opTrue( BaseHandle.opBitwiseOr(x,y) )
+ public static BaseHandle operator |(BaseHandle x, BaseHandle y)
+ {
+ if ( !BaseHandle.ReferenceEquals( x, null ) || !BaseHandle.ReferenceEquals( y, null ) )
+ {
+ if( x.HasBody() )
+ {
+ return x;
+ }
+ if( y.HasBody() )
+ {
+ return y;
+ }
+ return null;
+ }
+ return null;
+ }
+
+ // Logical ! operator
+ public static bool operator !(BaseHandle x)
+ {
+ // if the C# object is null, return true
+ if( BaseHandle.ReferenceEquals( x, null ) )
+ {
+ return true;
+ }
+ if( x.HasBody() )
+ {
+ return false;
+ }
+ return true;
+ }
+%}
\ No newline at end of file
%include events/pangesture-event.i
%include events/propertynotification-event.i
%include events/longpressgesture-event.i
+%include events/rectinteger.i
%include events/resourceimage-event.i
%include events/scrollable-event.i
%include events/scrollbar-event.i
%include events/timer-event.i
%include events/videoview-event.i
+%include alphafunction.i
+
%include dali-operator.i
%include dali-core.i
%include dali-adaptor.i
%define ACTOR_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
%typemap(cscode) NameSpace::ClassName %{
-
- /**
- * @brief Event arguments that passed via Touch signal
- *
- */
- public class TouchEventArgs : EventArgs
- {
- private Actor _actor;
- private TouchData _touchData;
-
- /**
- * @brief Actor - is the actor that is being touched
- *
- */
- public Actor Actor
- {
- get
- {
- return _actor;
- }
- set
- {
- _actor = value;
- }
- }
-
- /**
- * @brief TouchData - contains the information of touch points
- *
- */
- public TouchData TouchData
- {
- get
- {
- return _touchData;
- }
- set
- {
- _touchData = value;
- }
- }
- }
-
- /**
- * @brief Event arguments that passed via Hover signal
- *
- */
- public class HoverEventArgs : EventArgs
- {
- private Actor _actor;
- private HoverEvent _hoverEvent;
-
- /**
- * @brief Actor - is the actor that is being hovered
- *
- */
- public Actor Actor
- {
- get
- {
- return _actor;
- }
- set
- {
- _actor = value;
- }
- }
-
- /**
- * @brief HoverEvent - contains touch points that represent the points
- * that are currently being hovered or the points where a hover has stopped
- *
- */
- public HoverEvent HoverEvent
- {
- get
- {
- return _hoverEvent;
- }
- set
- {
- _hoverEvent = value;
- }
- }
- }
-
- /**
- * @brief Event arguments that passed via Wheel signal
- *
- */
- public class WheelEventArgs : EventArgs
- {
- private Actor _actor;
- private WheelEvent _wheelEvent;
-
- /**
- * @brief Actor - is the actor that is being wheeled
- *
- */
- public Actor Actor
- {
- get
- {
- return _actor;
- }
- set
- {
- _actor = value;
- }
- }
-
- /**
- * @brief WheelEvent - store a wheel rolling type : MOUSE_WHEEL or CUSTOM_WHEEL
- *
- */
- public WheelEvent WheelEvent
- {
- get
- {
- return _wheelEvent;
- }
- set
- {
- _wheelEvent = value;
- }
- }
- }
-
- /**
- * @brief Event arguments that passed via OnStage signal
- *
- */
- public class OnStageEventArgs : EventArgs
- {
- private Actor _actor;
-
- /**
- * @brief Actor - is the actor that is being connected to the stage
- *
- */
- public Actor Actor
- {
- get
- {
- return _actor;
- }
- set
- {
- _actor = value;
- }
- }
- }
-
- /**
- * @brief Event arguments that passed via OffStage signal
- *
- */
- public class OffStageEventArgs : EventArgs
- {
- private Actor _actor;
-
- /**
- * @brief Actor - is the actor that is being disconnected from the stage
- *
- */
- public Actor Actor
- {
- get
- {
- return _actor;
- }
- set
- {
- _actor = value;
- }
- }
- }
-
- /**
- * @brief Event arguments that passed via OnRelayout signal
- *
- */
- public class OnRelayoutEventArgs : EventArgs
- {
- private Actor _actor;
-
- /**
- * @brief Actor - is the actor that is being resized upon relayout
- *
- */
- public Actor Actor
- {
- get
- {
- return _actor;
- }
- set
- {
- _actor = value;
- }
- }
- }
-
-
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
- private delegate bool TouchCallbackDelegate(IntPtr actor, IntPtr touchData);
- private DaliEventHandlerWithReturnType<object,TouchEventArgs,bool> _actorTouchDataEventHandler;
- private TouchCallbackDelegate _actorTouchDataCallbackDelegate;
-
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
- private delegate bool HoverEventCallbackDelegate(IntPtr actor, IntPtr hoverEvent);
- private DaliEventHandlerWithReturnType<object,HoverEventArgs,bool> _actorHoverEventHandler;
- private HoverEventCallbackDelegate _actorHoverEventCallbackDelegate;
-
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
- private delegate bool WheelEventCallbackDelegate(IntPtr actor, IntPtr wheelEvent);
- private DaliEventHandlerWithReturnType<object,WheelEventArgs,bool> _actorWheelEventHandler;
- private WheelEventCallbackDelegate _actorWheelEventCallbackDelegate;
-
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
- private delegate void OnStageEventCallbackDelegate(IntPtr actor);
- private DaliEventHandler<object,OnStageEventArgs> _actorOnStageEventHandler;
- private OnStageEventCallbackDelegate _actorOnStageEventCallbackDelegate;
-
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
- private delegate void OffStageEventCallbackDelegate(IntPtr actor);
- private DaliEventHandler<object,OffStageEventArgs> _actorOffStageEventHandler;
- private OffStageEventCallbackDelegate _actorOffStageEventCallbackDelegate;
-
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
- private delegate void OnRelayoutEventCallbackDelegate(IntPtr actor);
- private DaliEventHandler<object,OnRelayoutEventArgs> _actorOnRelayoutEventHandler;
- private OnRelayoutEventCallbackDelegate _actorOnRelayoutEventCallbackDelegate;
-
- /**
- * @brief Event for Touched signal which can be used to subscribe/unsubscribe the event handler
- * (in the type of TouchEventHandler-DaliEventHandlerWithReturnType<object,TouchEventArgs,bool>)
- * provided by the user. Touched signal is emitted when touch input is received.
- */
- public event DaliEventHandlerWithReturnType<object,TouchEventArgs,bool> Touched
- {
- add
- {
- lock(this)
- {
- // Restricted to only one listener
- if (_actorTouchDataEventHandler == null)
- {
- _actorTouchDataEventHandler += value;
-
- _actorTouchDataCallbackDelegate = new TouchCallbackDelegate(OnTouch);
- this.TouchSignal().Connect(_actorTouchDataCallbackDelegate);
- }
- }
- }
-
- remove
- {
- lock(this)
- {
- if (_actorTouchDataEventHandler != null)
- {
- this.TouchSignal().Disconnect(_actorTouchDataCallbackDelegate);
- }
-
- _actorTouchDataEventHandler -= value;
- }
- }
- }
-
- // Callback for Actor TouchSignal
- private bool OnTouch(IntPtr actor, IntPtr touchData)
- {
- TouchEventArgs e = new TouchEventArgs();
-
- // Populate all members of "e" (TouchEventArgs) with real data
- e.Actor = Actor.GetActorFromPtr(actor);
- e.TouchData = Dali.TouchData.GetTouchDataFromPtr(touchData);
-
- if (_actorTouchDataEventHandler != null)
- {
- //here we send all data to user event handlers
- return _actorTouchDataEventHandler(this, e);
- }
-
- return false;
- }
-
- /**
- * @brief Event for Hovered signal which can be used to subscribe/unsubscribe the event handler
- * (in the type of HoverEventHandler-DaliEventHandlerWithReturnType<object,HoverEventArgs,bool>)
- * provided by the user. Hovered signal is emitted when hover input is received.
- */
- public event DaliEventHandlerWithReturnType<object,HoverEventArgs,bool> Hovered
- {
- add
- {
- lock(this)
- {
- // Restricted to only one listener
- if (_actorHoverEventHandler == null)
- {
- _actorHoverEventHandler += value;
-
- _actorHoverEventCallbackDelegate = new HoverEventCallbackDelegate(OnHoverEvent);
- this.HoveredSignal().Connect(_actorHoverEventCallbackDelegate);
- }
- }
- }
-
- remove
- {
- lock(this)
- {
- if (_actorHoverEventHandler != null)
- {
- this.HoveredSignal().Disconnect(_actorHoverEventCallbackDelegate);
- }
-
- _actorHoverEventHandler -= value;
- }
- }
- }
-
- // Callback for Actor Hover signal
- private bool OnHoverEvent(IntPtr actor, IntPtr hoverEvent)
- {
- HoverEventArgs e = new HoverEventArgs();
-
- // Populate all members of "e" (HoverEventArgs) with real data
- e.Actor = Actor.GetActorFromPtr(actor);
- e.HoverEvent = Dali.HoverEvent.GetHoverEventFromPtr(hoverEvent);
-
- if (_actorHoverEventHandler != null)
- {
- //here we send all data to user event handlers
- return _actorHoverEventHandler(this, e);
- }
-
- return false;
- }
-
- /**
- * @brief Event for WheelMoved signal which can be used to subscribe/unsubscribe the event handler
- * (in the type of WheelEventHandler-DaliEventHandlerWithReturnType<object,WheelEventArgs,bool>)
- * provided by the user. WheelMoved signal is emitted when wheel event is received.
- */
- public event DaliEventHandlerWithReturnType<object,WheelEventArgs,bool> WheelMoved
- {
- add
- {
- lock(this)
- {
- // Restricted to only one listener
- if (_actorWheelEventHandler == null)
- {
- _actorWheelEventHandler += value;
-
- _actorWheelEventCallbackDelegate = new WheelEventCallbackDelegate(OnWheelEvent);
- this.WheelEventSignal().Connect(_actorWheelEventCallbackDelegate);
- }
- }
- }
-
- remove
- {
- lock(this)
- {
- if (_actorWheelEventHandler != null)
- {
- this.WheelEventSignal().Disconnect(_actorWheelEventCallbackDelegate);
- }
-
- _actorWheelEventHandler -= value;
- }
- }
- }
-
- // Callback for Actor Wheel signal
- private bool OnWheelEvent(IntPtr actor, IntPtr wheelEvent)
- {
- WheelEventArgs e = new WheelEventArgs();
-
- // Populate all members of "e" (WheelEventArgs) with real data
- e.Actor = Actor.GetActorFromPtr(actor);
- e.WheelEvent = Dali.WheelEvent.GetWheelEventFromPtr(wheelEvent);
-
- if (_actorWheelEventHandler != null)
- {
- //here we send all data to user event handlers
- return _actorWheelEventHandler(this, e);
- }
-
- return false;
- }
-
- /**
- * @brief Event for OnStage signal which can be used to subscribe/unsubscribe the event handler
- * (in the type of OnStageEventHandler) provided by the user.
- * OnStage signal is emitted after the actor has been connected to the stage.
- */
- public event DaliEventHandler<object,OnStageEventArgs> OnStageEvent
- {
- add
- {
- lock(this)
- {
- // Restricted to only one listener
- if (_actorOnStageEventHandler == null)
- {
- _actorOnStageEventHandler += value;
-
- _actorOnStageEventCallbackDelegate = new OnStageEventCallbackDelegate(OnStage);
- this.OnStageSignal().Connect(_actorOnStageEventCallbackDelegate);
- }
- }
- }
-
- remove
- {
- lock(this)
- {
- if (_actorOnStageEventHandler != null)
- {
- this.OnStageSignal().Disconnect(_actorOnStageEventCallbackDelegate);
- }
-
- _actorOnStageEventHandler -= value;
- }
- }
- }
-
- // Callback for Actor OnStage signal
- private void OnStage(IntPtr data)
- {
- OnStageEventArgs e = new OnStageEventArgs();
-
- // Populate all members of "e" (OnStageEventArgs) with real data
- e.Actor = Actor.GetActorFromPtr(data);
-
- if (_actorOnStageEventHandler != null)
- {
- //here we send all data to user event handlers
- _actorOnStageEventHandler(this, e);
- }
- }
-
- /**
- * @brief Event for OffStage signal which can be used to subscribe/unsubscribe the event handler
- * (in the type of OffStageEventHandler) provided by the user.
- * OffStage signal is emitted after the actor has been disconnected from the stage.
- */
- public event DaliEventHandler<object,OffStageEventArgs> OffStageEvent
- {
- add
- {
- lock(this)
- {
- // Restricted to only one listener
- if (_actorOffStageEventHandler == null)
- {
- _actorOffStageEventHandler += value;
-
- _actorOffStageEventCallbackDelegate = new OffStageEventCallbackDelegate(OffStage);
- this.OnStageSignal().Connect(_actorOffStageEventCallbackDelegate);
- }
- }
- }
-
- remove
- {
- lock(this)
- {
- if (_actorOffStageEventHandler != null)
- {
- this.OnStageSignal().Disconnect(_actorOffStageEventCallbackDelegate);
- }
-
- _actorOffStageEventHandler -= value;
- }
- }
- }
-
- // Callback for Actor OffStage signal
- private void OffStage(IntPtr data)
- {
- OffStageEventArgs e = new OffStageEventArgs();
-
- // Populate all members of "e" (OffStageEventArgs) with real data
- e.Actor = Actor.GetActorFromPtr(data);
-
- if (_actorOffStageEventHandler != null)
- {
- //here we send all data to user event handlers
- _actorOffStageEventHandler(this, e);
- }
- }
-
- /**
- * @brief Event for OnRelayout signal which can be used to subscribe/unsubscribe the event handler
- * (in the type of OnRelayoutEventHandler) provided by the user.
- * OnRelayout signal is emitted after the size has been set on the actor during relayout.
- */
- public event DaliEventHandler<object,OnRelayoutEventArgs> OnRelayoutEvent
- {
- add
- {
- lock(this)
- {
- // Restricted to only one listener
- if (_actorOnRelayoutEventHandler == null)
- {
- _actorOnRelayoutEventHandler += value;
-
- _actorOnRelayoutEventCallbackDelegate = new OnRelayoutEventCallbackDelegate(OnRelayout);
- this.OnRelayoutSignal().Connect(_actorOnRelayoutEventCallbackDelegate);
- }
- }
- }
-
- remove
- {
- lock(this)
- {
- if (_actorOnRelayoutEventHandler != null)
- {
- this.OnRelayoutSignal().Disconnect(_actorOnRelayoutEventCallbackDelegate);
- }
-
- _actorOnRelayoutEventHandler -= value;
- }
- }
- }
-
- // Callback for Actor OnRelayout signal
- private void OnRelayout(IntPtr data)
- {
- OnRelayoutEventArgs e = new OnRelayoutEventArgs();
-
- // Populate all members of "e" (OnRelayoutEventArgs) with real data
- e.Actor = Actor.GetActorFromPtr(data);
-
- if (_actorOnRelayoutEventHandler != null)
- {
- //here we send all data to user event handlers
- _actorOnRelayoutEventHandler(this, e);
- }
- }
-
public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
ClassName ret = new ClassName(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
- public bool Vibility
+ public bool Visibility
{
get
{
{
SetOpacity(value);
}
- }
-
- public float CurrentOpacity
- {
get
{
float ret = GetCurrentOpacity();
return ret;
}
- }
+ }
public bool StateFocusEnable
{
}
}
+ public void Show()
+ {
+ SetVisible(true);
+ }
+
+ public void Hide()
+ {
+ SetVisible(false);
+ }
+
%}
%enddef
%define Animation_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
%typemap(cscode) NameSpace::ClassName %{
+ public static readonly int PARENT_ORIGIN = NDalicPINVOKE.Actor_Property_PARENT_ORIGIN_get();
+ public static readonly int PARENT_ORIGIN_X = NDalicPINVOKE.Actor_Property_PARENT_ORIGIN_X_get();
+ public static readonly int PARENT_ORIGIN_Y = NDalicPINVOKE.Actor_Property_PARENT_ORIGIN_Y_get();
+ public static readonly int PARENT_ORIGIN_Z = NDalicPINVOKE.Actor_Property_PARENT_ORIGIN_Z_get();
+ public static readonly int ANCHOR_POINT = NDalicPINVOKE.Actor_Property_ANCHOR_POINT_get();
+ public static readonly int ANCHOR_POINT_X = NDalicPINVOKE.Actor_Property_ANCHOR_POINT_X_get();
+ public static readonly int ANCHOR_POINT_Y = NDalicPINVOKE.Actor_Property_ANCHOR_POINT_Y_get();
+ public static readonly int ANCHOR_POINT_Z = NDalicPINVOKE.Actor_Property_ANCHOR_POINT_Z_get();
+ public static readonly int SIZE = NDalicPINVOKE.Actor_Property_SIZE_get();
+ public static readonly int SIZE_WIDTH = NDalicPINVOKE.Actor_Property_SIZE_WIDTH_get();
+ public static readonly int SIZE_HEIGHT = NDalicPINVOKE.Actor_Property_SIZE_HEIGHT_get();
+ public static readonly int SIZE_DEPTH = NDalicPINVOKE.Actor_Property_SIZE_DEPTH_get();
+ public static readonly int POSITION = NDalicPINVOKE.Actor_Property_POSITION_get();
+ public static readonly int POSITION_X = NDalicPINVOKE.Actor_Property_POSITION_X_get();
+ public static readonly int POSITION_Y = NDalicPINVOKE.Actor_Property_POSITION_Y_get();
+ public static readonly int POSITION_Z = NDalicPINVOKE.Actor_Property_POSITION_Z_get();
+ public static readonly int WORLD_POSITION = NDalicPINVOKE.Actor_Property_WORLD_POSITION_get();
+ public static readonly int WORLD_POSITION_X = NDalicPINVOKE.Actor_Property_WORLD_POSITION_X_get();
+ public static readonly int WORLD_POSITION_Y = NDalicPINVOKE.Actor_Property_WORLD_POSITION_Y_get();
+ public static readonly int WORLD_POSITION_Z = NDalicPINVOKE.Actor_Property_WORLD_POSITION_Z_get();
+ public static readonly int ORIENTATION = NDalicPINVOKE.Actor_Property_ORIENTATION_get();
+ public static readonly int WORLD_ORIENTATION = NDalicPINVOKE.Actor_Property_WORLD_ORIENTATION_get();
+ public static readonly int SCALE = NDalicPINVOKE.Actor_Property_SCALE_get();
+ public static readonly int SCALE_X = NDalicPINVOKE.Actor_Property_SCALE_X_get();
+ public static readonly int SCALE_Y = NDalicPINVOKE.Actor_Property_SCALE_Y_get();
+ public static readonly int SCALE_Z = NDalicPINVOKE.Actor_Property_SCALE_Z_get();
+ public static readonly int WORLD_SCALE = NDalicPINVOKE.Actor_Property_WORLD_SCALE_get();
+ public static readonly int VISIBLE = NDalicPINVOKE.Actor_Property_VISIBLE_get();
+ public static readonly int COLOR = NDalicPINVOKE.Actor_Property_COLOR_get();
+ public static readonly int COLOR_RED = NDalicPINVOKE.Actor_Property_COLOR_RED_get();
+ public static readonly int COLOR_GREEN = NDalicPINVOKE.Actor_Property_COLOR_GREEN_get();
+ public static readonly int COLOR_BLUE = NDalicPINVOKE.Actor_Property_COLOR_BLUE_get();
+ public static readonly int COLOR_ALPHA = NDalicPINVOKE.Actor_Property_COLOR_ALPHA_get();
+ public static readonly int WORLD_COLOR = NDalicPINVOKE.Actor_Property_WORLD_COLOR_get();
+ public static readonly int WORLD_MATRIX = NDalicPINVOKE.Actor_Property_WORLD_MATRIX_get();
+ public static readonly int NAME = NDalicPINVOKE.Actor_Property_NAME_get();
+ public static readonly int SENSITIVE = NDalicPINVOKE.Actor_Property_SENSITIVE_get();
+ public static readonly int LEAVE_REQUIRED = NDalicPINVOKE.Actor_Property_LEAVE_REQUIRED_get();
+ public static readonly int INHERIT_ORIENTATION = NDalicPINVOKE.Actor_Property_INHERIT_ORIENTATION_get();
+ public static readonly int INHERIT_SCALE = NDalicPINVOKE.Actor_Property_INHERIT_SCALE_get();
+ public static readonly int COLOR_MODE = NDalicPINVOKE.Actor_Property_COLOR_MODE_get();
+ public static readonly int POSITION_INHERITANCE = NDalicPINVOKE.Actor_Property_POSITION_INHERITANCE_get();
+ public static readonly int DRAW_MODE = NDalicPINVOKE.Actor_Property_DRAW_MODE_get();
+ public static readonly int SIZE_MODE_FACTOR = NDalicPINVOKE.Actor_Property_SIZE_MODE_FACTOR_get();
+ public static readonly int WIDTH_RESIZE_POLICY = NDalicPINVOKE.Actor_Property_WIDTH_RESIZE_POLICY_get();
+ public static readonly int HEIGHT_RESIZE_POLICY = NDalicPINVOKE.Actor_Property_HEIGHT_RESIZE_POLICY_get();
+ public static readonly int SIZE_SCALE_POLICY = NDalicPINVOKE.Actor_Property_SIZE_SCALE_POLICY_get();
+ public static readonly int WIDTH_FOR_HEIGHT = NDalicPINVOKE.Actor_Property_WIDTH_FOR_HEIGHT_get();
+ public static readonly int HEIGHT_FOR_WIDTH = NDalicPINVOKE.Actor_Property_HEIGHT_FOR_WIDTH_get();
+ public static readonly int PADDING = NDalicPINVOKE.Actor_Property_PADDING_get();
+ public static readonly int MINIMUM_SIZE = NDalicPINVOKE.Actor_Property_MINIMUM_SIZE_get();
+ public static readonly int MAXIMUM_SIZE = NDalicPINVOKE.Actor_Property_MAXIMUM_SIZE_get();
+ public static readonly int INHERIT_POSITION = NDalicPINVOKE.Actor_Property_INHERIT_POSITION_get();
+ public static readonly int CLIPPING_MODE = NDalicPINVOKE.Actor_Property_CLIPPING_MODE_get();
+ public static readonly int BATCH_PARENT = NDalicPINVOKE.Actor_Property_BATCH_PARENT_get();
+
+
/**
* @brief Event arguments that passed via Finished signal
*
}
}
+ public int LoopCount
+ {
+ set
+ {
+ SetLoopCount(value);
+ }
+ get
+ {
+ int ret = GetLoopCount();
+ return ret;
+ }
+ }
+
+ public void AnimateBy<T,U>(Actor target, T propertyIndex, U relativeValue)
+ {
+ dynamic var = (object)(propertyIndex);
+ dynamic obj = (object)(relativeValue);
+ AnimateBy(new Property(target, var), new Property.Value(obj));
+ }
+
+ public void AnimateBy<T,U>(Actor target, T propertyIndex, U relativeValue, AlphaFunction alpha)
+ {
+ dynamic var = (object)(propertyIndex);
+ dynamic obj = (object)(relativeValue);
+ AnimateBy(new Property(target, var), new Property.Value(obj), alpha);
+ }
+
+ public void AnimateBy<T,U>(Actor target, T propertyIndex, U relativeValue, TimePeriod period)
+ {
+ dynamic var = (object)(propertyIndex);
+ dynamic obj = (object)(relativeValue);
+ AnimateBy(new Property(target, var), new Property.Value(obj), period);
+ }
+
+ public void AnimateBy<T,U>(Actor target, T propertyIndex, U relativeValue, AlphaFunction alpha, TimePeriod period)
+ {
+ dynamic var = (object)(propertyIndex);
+ dynamic obj = (object)(relativeValue);
+ AnimateBy(new Property(target, var), new Property.Value(obj), alpha, period);
+ }
+
+ public void AnimateTo<T,U>(Actor target, T propertyIndex, U destinationValue)
+ {
+ dynamic var = (object)(propertyIndex);
+ dynamic obj = (object)(destinationValue);
+ AnimateTo(new Property(target, var), new Property.Value(obj));
+ }
+
+ public void AnimateTo<T,U>(Actor target, T propertyIndex, U destinationValue, AlphaFunction alpha)
+ {
+ dynamic var = (object)(propertyIndex);
+ dynamic obj = (object)(destinationValue);
+ AnimateTo(new Property(target, var), new Property.Value(obj), alpha);
+ }
+
+ public void AnimateTo<T,U>(Actor target, T propertyIndex, U destinationValue, TimePeriod period)
+ {
+ dynamic var = (object)(propertyIndex);
+ dynamic obj = (object)(destinationValue);
+ AnimateTo(new Property(target, var), new Property.Value(obj), period);
+ }
+
+ public void AnimateTo<T,U>(Actor target, T propertyIndex, U destinationValue, AlphaFunction alpha, TimePeriod period)
+ {
+ dynamic var = (object)(propertyIndex);
+ dynamic obj = (object)(destinationValue);
+ AnimateTo(new Property(target, var), new Property.Value(obj), alpha, period);
+ }
+
+ public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames)
+ {
+ dynamic var = (object)(propertyIndex);
+ AnimateBetween(new Property(target, var), keyFrames);
+ }
+
+ public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, Animation.Interpolation interpolation)
+ {
+ dynamic var = (object)(propertyIndex);
+ AnimateBetween(new Property(target, var), keyFrames, interpolation);
+ }
+
+ public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, AlphaFunction alpha)
+ {
+ dynamic var = (object)(propertyIndex);
+ AnimateBetween(new Property(target, var), keyFrames, alpha);
+ }
+
+ public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, AlphaFunction alpha, Animation.Interpolation interpolation)
+ {
+ dynamic var = (object)(propertyIndex);
+ AnimateBetween(new Property(target, var), keyFrames, alpha, interpolation);
+ }
+
+ public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, TimePeriod period)
+ {
+ dynamic var = (object)(propertyIndex);
+ AnimateBetween(new Property(target, var), keyFrames, period);
+ }
+
+ public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, TimePeriod period, Animation.Interpolation interpolation)
+ {
+ dynamic var = (object)(propertyIndex);
+ AnimateBetween(new Property(target, var), keyFrames, period, interpolation);
+ }
+
+ public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period)
+ {
+ dynamic var = (object)(propertyIndex);
+ AnimateBetween(new Property(target, var), keyFrames, alpha, period);
+ }
+
+ public void AnimateBetween<U>(Actor target, U propertyIndex, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period, Animation.Interpolation interpolation)
+ {
+ dynamic var = (object)(propertyIndex);
+ AnimateBetween(new Property(target, var), keyFrames, alpha, period, interpolation);
+ }
+
%}
%enddef
*/
%define CONTROL_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
-%typemap(csimports) NameSpace::ClassName %{
-using System;
-using System.Runtime.InteropServices;
+ %typemap(csimports) NameSpace::ClassName %{
+ using System;
+ using System.Runtime.InteropServices;
-%}
+ %}
-%enddef
+ %enddef
%define CONTROL_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
-%typemap(cscode) NameSpace::ClassName %{
+ %typemap(cscode) NameSpace::ClassName %{
-/**
- * @brief Event arguments that passed via KeyInputFocusGained signal
- *
- */
-public class KeyInputFocusGainedEventArgs : EventArgs
-{
- private View _view;
-
- /**
- * @brief View - is the view that gets Key Input Focus
+ /**
+ * @brief Event arguments that passed via KeyInputFocusGained signal
*
*/
- public View View
- {
- get
+ public class KeyInputFocusGainedEventArgs : EventArgs
+ {
+ private View _view;
+
+ /**
+ * @brief View - is the view that gets Key Input Focus
+ *
+ */
+ public View View
{
- return _view;
+ get
+ {
+ return _view;
+ }
+ set
+ {
+ _view = value;
+ }
}
- set
+ }
+
+ /**
+ * @brief Event arguments that passed via KeyInputFocusLost signal
+ *
+ */
+ public class KeyInputFocusLostEventArgs : EventArgs
+ {
+ private View _view;
+
+ /**
+ * @brief View - is the view that loses Key Input Focus
+ *
+ */
+ public View View
{
- _view = value;
+ get
+ {
+ return _view;
+ }
+ set
+ {
+ _view = value;
+ }
}
- }
-}
-
-/**
- * @brief Event arguments that passed via KeyInputFocusLost signal
- *
- */
-public class KeyInputFocusLostEventArgs : EventArgs
-{
- private View _view;
+ }
- /**
- * @brief View - is the view that loses Key Input Focus
+ /**
+ * @brief Event arguments that passed via KeyEvent signal
*
*/
- public View View
- {
- get
+ public class KeyEventArgs : EventArgs
+ {
+ private View _view;
+ private KeyEvent _keyEvent;
+
+ /**
+ * @brief View - is the view that recieves the keyevent.
+ *
+ */
+ public View View
{
- return _view;
+ get
+ {
+ return _view;
+ }
+ set
+ {
+ _view = value;
+ }
}
- set
+
+ /**
+ * @brief KeyEvent - is the keyevent sent to the View.
+ *
+ */
+ public KeyEvent KeyEvent
{
- _view = value;
+ get
+ {
+ return _keyEvent;
+ }
+ set
+ {
+ _keyEvent = value;
+ }
+ }
+ }
+
+ /**
+ * @brief Event arguments that passed via OnRelayout signal
+ *
+ */
+ public class OnRelayoutEventArgs : EventArgs
+ {
+ private View _view;
+
+ /**
+ * @brief View - is the view that is being resized upon relayout
+ *
+ */
+ public View View
+ {
+ get
+ {
+ return _view;
+ }
+ set
+ {
+ _view = value;
+ }
+ }
+ }
+
+
+ /**
+ * @brief Event arguments that passed via Touch signal
+ *
+ */
+ public class TouchEventArgs : EventArgs
+ {
+ private View _view;
+ private TouchData _touchData;
+
+ /**
+ * @brief View - is the view that is being touched
+ *
+ */
+ public View View
+ {
+ get
+ {
+ return _view;
+ }
+ set
+ {
+ _view = value;
+ }
}
- }
-}
-/**
- * @brief Event arguments that passed via KeyEvent signal
- *
- */
-public class KeyEventArgs : EventArgs
-{
- private View _view;
- private KeyEvent _keyEvent;
+ /**
+ * @brief TouchData - contains the information of touch points
+ *
+ */
+ public TouchData TouchData
+ {
+ get
+ {
+ return _touchData;
+ }
+ set
+ {
+ _touchData = value;
+ }
+ }
+ }
+
+ /**
+ * @brief Event arguments that passed via Hover signal
+ *
+ */
+ public class HoverEventArgs : EventArgs
+ {
+ private View _view;
+ private HoverEvent _hoverEvent;
+
+ /**
+ * @brief View - is the view that is being hovered
+ *
+ */
+ public View View
+ {
+ get
+ {
+ return _view;
+ }
+ set
+ {
+ _view = value;
+ }
+ }
- /**
- * @brief View - is the view that recieves the keyevent.
- *
+ /**
+ * @brief HoverEvent - contains touch points that represent the points
+ * that are currently being hovered or the points where a hover has stopped
+ *
+ */
+ public HoverEvent HoverEvent
+ {
+ get
+ {
+ return _hoverEvent;
+ }
+ set
+ {
+ _hoverEvent = value;
+ }
+ }
+ }
+
+ /**
+ * @brief Event arguments that passed via Wheel signal
+ *
+ */
+ public class WheelEventArgs : EventArgs
+ {
+ private View _view;
+ private WheelEvent _wheelEvent;
+
+ /**
+ * @brief View - is the view that is being wheeled
+ *
+ */
+ public View View
+ {
+ get
+ {
+ return _view;
+ }
+ set
+ {
+ _view = value;
+ }
+ }
+
+ /**
+ * @brief WheelEvent - store a wheel rolling type : MOUSE_WHEEL or CUSTOM_WHEEL
+ *
+ */
+ public WheelEvent WheelEvent
+ {
+ get
+ {
+ return _wheelEvent;
+ }
+ set
+ {
+ _wheelEvent = value;
+ }
+ }
+ }
+
+ /**
+ * @brief Event arguments that passed via OnStage signal
+ *
+ */
+ public class OnStageEventArgs : EventArgs
+ {
+ private View _view;
+
+ /**
+ * @brief View - is the view that is being connected to the stage
+ *
+ */
+ public View View
+ {
+ get
+ {
+ return _view;
+ }
+ set
+ {
+ _view = value;
+ }
+ }
+ }
+
+ /**
+ * @brief Event arguments that passed via OffStage signal
+ *
+ */
+ public class OffStageEventArgs : EventArgs
+ {
+ private View _view;
+
+ /**
+ * @brief View - is the view that is being disconnected from the stage
+ *
+ */
+ public View View
+ {
+ get
+ {
+ return _view;
+ }
+ set
+ {
+ _view = value;
+ }
+ }
+ }
+
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate void KeyInputFocusGainedCallbackDelegate(IntPtr control);
+ private DaliEventHandler<object,KeyInputFocusGainedEventArgs> _KeyInputFocusGainedEventHandler;
+ private KeyInputFocusGainedCallbackDelegate _KeyInputFocusGainedCallbackDelegate;
+
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate void KeyInputFocusLostCallbackDelegate(IntPtr control);
+ private DaliEventHandler<object,KeyInputFocusLostEventArgs> _KeyInputFocusLostEventHandler;
+ private KeyInputFocusLostCallbackDelegate _KeyInputFocusLostCallbackDelegate;
+
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate bool KeyCallbackDelegate(IntPtr control, IntPtr keyEvent);
+ private DaliEventHandlerWithReturnType<object,KeyEventArgs,bool> _KeyEventHandler;
+ private KeyCallbackDelegate _KeyCallbackDelegate;
+
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate void OnRelayoutEventCallbackDelegate(IntPtr control);
+ private DaliEventHandler<object,OnRelayoutEventArgs> _viewOnRelayoutEventHandler;
+ private OnRelayoutEventCallbackDelegate _viewOnRelayoutEventCallbackDelegate;
+
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate bool TouchCallbackDelegate(IntPtr view, IntPtr touchData);
+ private DaliEventHandlerWithReturnType<object,TouchEventArgs,bool> _viewTouchDataEventHandler;
+ private TouchCallbackDelegate _viewTouchDataCallbackDelegate;
+
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate bool HoverEventCallbackDelegate(IntPtr view, IntPtr hoverEvent);
+ private DaliEventHandlerWithReturnType<object,HoverEventArgs,bool> _viewHoverEventHandler;
+ private HoverEventCallbackDelegate _viewHoverEventCallbackDelegate;
+
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate bool WheelEventCallbackDelegate(IntPtr view, IntPtr wheelEvent);
+ private DaliEventHandlerWithReturnType<object,WheelEventArgs,bool> _viewWheelEventHandler;
+ private WheelEventCallbackDelegate _viewWheelEventCallbackDelegate;
+
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate void OnStageEventCallbackDelegate(IntPtr control);
+ private DaliEventHandler<object,OnStageEventArgs> _viewOnStageEventHandler;
+ private OnStageEventCallbackDelegate _viewOnStageEventCallbackDelegate;
+
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate void OffStageEventCallbackDelegate(IntPtr control);
+ private DaliEventHandler<object,OffStageEventArgs> _viewOffStageEventHandler;
+ private OffStageEventCallbackDelegate _viewOffStageEventCallbackDelegate;
+
+ /**
+ * @brief Event for KeyInputFocusGained signal which can be used to subscribe/unsubscribe the event handler
+ * (in the type of KeyInputFocusGainedEventHandler-DaliEventHandler<object,KeyInputFocusGainedEventArgs>)
+ * provided by the user. KeyInputFocusGained signal is emitted when the control gets Key Input Focus.
*/
- public View View
- {
- get
+ public event DaliEventHandler<object,KeyInputFocusGainedEventArgs> KeyInputFocusGained
+ {
+ add
+ {
+ lock(this)
+ {
+ // Restricted to only one listener
+ if (_KeyInputFocusGainedEventHandler == null)
+ {
+ _KeyInputFocusGainedEventHandler += value;
+ Console.WriteLine("View Keyevent EVENT Locked....");
+ _KeyInputFocusGainedCallbackDelegate = new KeyInputFocusGainedCallbackDelegate(OnKeyInputFocusGained);
+ this.KeyInputFocusGainedSignal().Connect(_KeyInputFocusGainedCallbackDelegate);
+ }
+ }
+ }
+
+ remove
{
- return _view;
+ lock(this)
+ {
+ if (_KeyInputFocusGainedEventHandler != null)
+ {
+ this.KeyInputFocusGainedSignal().Disconnect(_KeyInputFocusGainedCallbackDelegate);
+ }
+
+ _KeyInputFocusGainedEventHandler -= value;
+ }
}
- set
+ }
+
+ private void OnKeyInputFocusGained(IntPtr view)
+ {
+ KeyInputFocusGainedEventArgs e = new KeyInputFocusGainedEventArgs();
+ Console.WriteLine("View Keyevent ....");
+ // Populate all members of "e" (KeyInputFocusGainedEventArgs) with real data
+ e.View = Dali.View.GetViewFromPtr(view);
+
+ if (_KeyInputFocusGainedEventHandler != null)
{
- _view = value;
+ //here we send all data to user event handlers
+ _KeyInputFocusGainedEventHandler(this, e);
}
- }
- /**
- * @brief KeyEvent - is the keyevent sent to the View.
- *
+ }
+
+ /**
+ * @brief Event for KeyInputFocusLost signal which can be used to subscribe/unsubscribe the event handler
+ * (in the type of KeyInputFocusLostEventHandler-DaliEventHandler<object,KeyInputFocusLostEventArgs>)
+ * provided by the user. KeyInputFocusLost signal is emitted when the control loses Key Input Focus.
*/
- public KeyEvent KeyEvent
- {
- get
+ public event DaliEventHandler<object,KeyInputFocusLostEventArgs> KeyInputFocusLost
+ {
+ add
{
- return _keyEvent;
+ lock(this)
+ {
+ // Restricted to only one listener
+ if (_KeyInputFocusLostEventHandler == null)
+ {
+ _KeyInputFocusLostEventHandler += value;
+
+ _KeyInputFocusLostCallbackDelegate = new KeyInputFocusLostCallbackDelegate(OnKeyInputFocusLost);
+ this.KeyInputFocusLostSignal().Connect(_KeyInputFocusLostCallbackDelegate);
+ }
+ }
}
- set
+
+ remove
{
- _keyEvent = value;
+ lock(this)
+ {
+ if (_KeyInputFocusLostEventHandler != null)
+ {
+ this.KeyInputFocusLostSignal().Disconnect(_KeyInputFocusLostCallbackDelegate);
+ }
+
+ _KeyInputFocusLostEventHandler -= value;
+ }
+ }
+ }
+
+ private void OnKeyInputFocusLost(IntPtr view)
+ {
+ KeyInputFocusLostEventArgs e = new KeyInputFocusLostEventArgs();
+
+ // Populate all members of "e" (KeyInputFocusLostEventArgs) with real data
+ e.View = Dali.View.GetViewFromPtr(view);
+
+ if (_KeyInputFocusLostEventHandler != null)
+ {
+ //here we send all data to user event handlers
+ _KeyInputFocusLostEventHandler(this, e);
+ }
+ }
+
+ /**
+ * @brief Event for KeyPressed signal which can be used to subscribe/unsubscribe the event handler
+ * (in the type of KeyEventEventHandler-DaliEventHandlerWithReturnType<object,KeyEventArgs,bool>)
+ * provided by the user. KeyPressed signal is emitted when key event is received.
+ */
+ public event DaliEventHandlerWithReturnType<object,KeyEventArgs,bool> KeyPressed
+ {
+ add
+ {
+ lock(this)
+ {
+ // Restricted to only one listener
+ if (_KeyEventHandler == null)
+ {
+ _KeyEventHandler += value;
+
+ _KeyCallbackDelegate = new KeyCallbackDelegate(OnKeyEvent);
+ this.KeyEventSignal().Connect(_KeyCallbackDelegate);
+ }
+ }
}
- }
-}
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
- private delegate void KeyInputFocusGainedCallbackDelegate(IntPtr control);
- private DaliEventHandler<object,KeyInputFocusGainedEventArgs> _KeyInputFocusGainedEventHandler;
- private KeyInputFocusGainedCallbackDelegate _KeyInputFocusGainedCallbackDelegate;
-
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
- private delegate void KeyInputFocusLostCallbackDelegate(IntPtr control);
- private DaliEventHandler<object,KeyInputFocusLostEventArgs> _KeyInputFocusLostEventHandler;
- private KeyInputFocusLostCallbackDelegate _KeyInputFocusLostCallbackDelegate;
-
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
- private delegate bool KeyCallbackDelegate(IntPtr control, IntPtr keyEvent);
- private DaliEventHandlerWithReturnType<object,KeyEventArgs,bool> _KeyEventHandler;
- private KeyCallbackDelegate _KeyCallbackDelegate;
-
- /**
- * @brief Event for KeyInputFocusGained signal which can be used to subscribe/unsubscribe the event handler
- * (in the type of KeyInputFocusGainedEventHandler-DaliEventHandler<object,KeyInputFocusGainedEventArgs>)
- * provided by the user. KeyInputFocusGained signal is emitted when the control gets Key Input Focus.
- */
- public event DaliEventHandler<object,KeyInputFocusGainedEventArgs> KeyInputFocusGained
- {
- add
- {
+ remove
+ {
lock(this)
{
- // Restricted to only one listener
- if (_KeyInputFocusGainedEventHandler == null)
- {
- _KeyInputFocusGainedEventHandler += value;
+ if (_KeyEventHandler != null)
+ {
+ this.KeyEventSignal().Disconnect(_KeyCallbackDelegate);
+ }
+
+ _KeyEventHandler -= value;
+ }
+ }
+ }
+
+ private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
+ {
+ KeyEventArgs e = new KeyEventArgs();
+
+ // Populate all members of "e" (KeyEventArgs) with real data
+ e.View = Dali.View.GetViewFromPtr(view);
+ e.KeyEvent = Dali.KeyEvent.GetKeyEventFromPtr(keyEvent);
- _KeyInputFocusGainedCallbackDelegate = new KeyInputFocusGainedCallbackDelegate(OnKeyInputFocusGained);
- this.KeyInputFocusGainedSignal().Connect(_KeyInputFocusGainedCallbackDelegate);
- }
+ if (_KeyEventHandler != null)
+ {
+ //here we send all data to user event handlers
+ return _KeyEventHandler(this, e);
+ }
+ return false;
+
+ }
+
+ /**
+ * @brief Event for OnRelayout signal which can be used to subscribe/unsubscribe the event handler
+ * (in the type of OnRelayoutEventHandler) provided by the user.
+ * OnRelayout signal is emitted after the size has been set on the view during relayout.
+ */
+ public event DaliEventHandler<object,OnRelayoutEventArgs> OnRelayoutEvent
+ {
+ add
+ {
+ lock(this)
+ {
+ // Restricted to only one listener
+ if (_viewOnRelayoutEventHandler == null)
+ {
+ _viewOnRelayoutEventHandler += value;
+ Console.WriteLine("View OnRelayoutEventArgs Locked....");
+ _viewOnRelayoutEventCallbackDelegate = new OnRelayoutEventCallbackDelegate(OnRelayout);
+ this.OnRelayoutSignal().Connect(_viewOnRelayoutEventCallbackDelegate);
+ }
}
- }
+ }
- remove
- {
+ remove
+ {
lock(this)
{
- if (_KeyInputFocusGainedEventHandler != null)
- {
- this.KeyInputFocusGainedSignal().Disconnect(_KeyInputFocusGainedCallbackDelegate);
- }
+ if (_viewOnRelayoutEventHandler != null)
+ {
+ this.OnRelayoutSignal().Disconnect(_viewOnRelayoutEventCallbackDelegate);
+ }
- _KeyInputFocusGainedEventHandler -= value;
+ _viewOnRelayoutEventHandler -= value;
}
- }
- }
+ }
+ }
+
+ // Callback for View OnRelayout signal
+ private void OnRelayout(IntPtr data)
+ {
+ OnRelayoutEventArgs e = new OnRelayoutEventArgs();
+ Console.WriteLine("View OnRelayoutEventArgs....");
+ // Populate all members of "e" (OnRelayoutEventArgs) with real data
+ e.View = View.GetViewFromPtr(data);
- private void OnKeyInputFocusGained(IntPtr view)
- {
- KeyInputFocusGainedEventArgs e = new KeyInputFocusGainedEventArgs();
+ if (_viewOnRelayoutEventHandler != null)
+ {
+ //here we send all data to user event handlers
+ _viewOnRelayoutEventHandler(this, e);
+ }
+ }
+
+ /**
+ * @brief Event for Touched signal which can be used to subscribe/unsubscribe the event handler
+ * (in the type of TouchEventHandler-DaliEventHandlerWithReturnType<object,TouchEventArgs,bool>)
+ * provided by the user. Touched signal is emitted when touch input is received.
+ */
+ public event DaliEventHandlerWithReturnType<object,TouchEventArgs,bool> Touched
+ {
+ add
+ {
+ lock(this)
+ {
+ // Restricted to only one listener
+ if (_viewTouchDataEventHandler == null)
+ {
+ _viewTouchDataEventHandler += value;
+ Console.WriteLine("View Touch EVENT LOCKED....");
+ _viewTouchDataCallbackDelegate = new TouchCallbackDelegate(OnTouch);
+ this.TouchSignal().Connect(_viewTouchDataCallbackDelegate);
+ }
+ }
+ }
- // Populate all members of "e" (KeyInputFocusGainedEventArgs) with real data
- e.View = Dali.View.GetViewFromPtr(view);
+ remove
+ {
+ lock(this)
+ {
+ if (_viewTouchDataEventHandler != null)
+ {
+ this.TouchSignal().Disconnect(_viewTouchDataCallbackDelegate);
+ }
- if (_KeyInputFocusGainedEventHandler != null)
- {
- //here we send all data to user event handlers
- _KeyInputFocusGainedEventHandler(this, e);
- }
+ _viewTouchDataEventHandler -= value;
+ }
+ }
+ }
+
+ // Callback for View TouchSignal
+ private bool OnTouch(IntPtr view, IntPtr touchData)
+ {
+ TouchEventArgs e = new TouchEventArgs();
+ Console.WriteLine("View Touch EVENT....");
+ // Populate all members of "e" (TouchEventArgs) with real data
+ e.View = View.GetViewFromPtr(view);
+ e.TouchData = Dali.TouchData.GetTouchDataFromPtr(touchData);
+
+ if (_viewTouchDataEventHandler != null)
+ {
+ //here we send all data to user event handlers
+ return _viewTouchDataEventHandler(this, e);
+ }
- }
+ return false;
+ }
+
+ /**
+ * @brief Event for Hovered signal which can be used to subscribe/unsubscribe the event handler
+ * (in the type of HoverEventHandler-DaliEventHandlerWithReturnType<object,HoverEventArgs,bool>)
+ * provided by the user. Hovered signal is emitted when hover input is received.
+ */
+ public event DaliEventHandlerWithReturnType<object,HoverEventArgs,bool> Hovered
+ {
+ add
+ {
+ lock(this)
+ {
+ // Restricted to only one listener
+ if (_viewHoverEventHandler == null)
+ {
+ _viewHoverEventHandler += value;
+
+ _viewHoverEventCallbackDelegate = new HoverEventCallbackDelegate(OnHoverEvent);
+ this.HoveredSignal().Connect(_viewHoverEventCallbackDelegate);
+ }
+ }
+ }
- /**
- * @brief Event for KeyInputFocusLost signal which can be used to subscribe/unsubscribe the event handler
- * (in the type of KeyInputFocusLostEventHandler-DaliEventHandler<object,KeyInputFocusLostEventArgs>)
- * provided by the user. KeyInputFocusLost signal is emitted when the control loses Key Input Focus.
- */
- public event DaliEventHandler<object,KeyInputFocusLostEventArgs> KeyInputFocusLost
- {
- add
- {
+ remove
+ {
lock(this)
{
- // Restricted to only one listener
- if (_KeyInputFocusLostEventHandler == null)
- {
- _KeyInputFocusLostEventHandler += value;
+ if (_viewHoverEventHandler != null)
+ {
+ this.HoveredSignal().Disconnect(_viewHoverEventCallbackDelegate);
+ }
- _KeyInputFocusLostCallbackDelegate = new KeyInputFocusLostCallbackDelegate(OnKeyInputFocusLost);
- this.KeyInputFocusLostSignal().Connect(_KeyInputFocusLostCallbackDelegate);
- }
+ _viewHoverEventHandler -= value;
}
- }
+ }
+ }
+
+ // Callback for View Hover signal
+ private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
+ {
+ HoverEventArgs e = new HoverEventArgs();
+
+ // Populate all members of "e" (HoverEventArgs) with real data
+ e.View = View.GetViewFromPtr(view);
+ e.HoverEvent = Dali.HoverEvent.GetHoverEventFromPtr(hoverEvent);
+
+ if (_viewHoverEventHandler != null)
+ {
+ //here we send all data to user event handlers
+ return _viewHoverEventHandler(this, e);
+ }
- remove
- {
+ return false;
+ }
+
+ /**
+ * @brief Event for WheelMoved signal which can be used to subscribe/unsubscribe the event handler
+ * (in the type of WheelEventHandler-DaliEventHandlerWithReturnType<object,WheelEventArgs,bool>)
+ * provided by the user. WheelMoved signal is emitted when wheel event is received.
+ */
+ public event DaliEventHandlerWithReturnType<object,WheelEventArgs,bool> WheelMoved
+ {
+ add
+ {
lock(this)
{
- if (_KeyInputFocusLostEventHandler != null)
- {
- this.KeyInputFocusLostSignal().Disconnect(_KeyInputFocusLostCallbackDelegate);
- }
-
- _KeyInputFocusLostEventHandler -= value;
- }
- }
- }
-
- private void OnKeyInputFocusLost(IntPtr view)
- {
- KeyInputFocusLostEventArgs e = new KeyInputFocusLostEventArgs();
-
- // Populate all members of "e" (KeyInputFocusLostEventArgs) with real data
- e.View = Dali.View.GetViewFromPtr(view);
-
- if (_KeyInputFocusLostEventHandler != null)
- {
- //here we send all data to user event handlers
- _KeyInputFocusLostEventHandler(this, e);
- }
- }
-
- /**
- * @brief Event for KeyPressed signal which can be used to subscribe/unsubscribe the event handler
- * (in the type of KeyEventEventHandler-DaliEventHandlerWithReturnType<object,KeyEventArgs,bool>)
- * provided by the user. KeyPressed signal is emitted when key event is received.
- */
- public event DaliEventHandlerWithReturnType<object,KeyEventArgs,bool> KeyPressed
- {
- add
- {
+ // Restricted to only one listener
+ if (_viewWheelEventHandler == null)
+ {
+ _viewWheelEventHandler += value;
+ Console.WriteLine("View Wheel EVENT LOCKED....");
+ _viewWheelEventCallbackDelegate = new WheelEventCallbackDelegate(OnWheelEvent);
+ this.WheelEventSignal().Connect(_viewWheelEventCallbackDelegate);
+ }
+ }
+ }
+
+ remove
+ {
lock(this)
{
- // Restricted to only one listener
- if (_KeyEventHandler == null)
- {
- _KeyEventHandler += value;
+ if (_viewWheelEventHandler != null)
+ {
+ this.WheelEventSignal().Disconnect(_viewWheelEventCallbackDelegate);
+ }
+
+ _viewWheelEventHandler -= value;
+ }
+ }
+ }
+
+ // Callback for View Wheel signal
+ private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
+ {
+ WheelEventArgs e = new WheelEventArgs();
+ Console.WriteLine("View Wheel EVENT ....");
+ // Populate all members of "e" (WheelEventArgs) with real data
+ e.View = View.GetViewFromPtr(view);
+ e.WheelEvent = Dali.WheelEvent.GetWheelEventFromPtr(wheelEvent);
+
+ if (_viewWheelEventHandler != null)
+ {
+ //here we send all data to user event handlers
+ return _viewWheelEventHandler(this, e);
+ }
- _KeyCallbackDelegate = new KeyCallbackDelegate(OnKeyEvent);
- this.KeyEventSignal().Connect(_KeyCallbackDelegate);
- }
+ return false;
+ }
+
+ /**
+ * @brief Event for OnStage signal which can be used to subscribe/unsubscribe the event handler
+ * (in the type of OnStageEventHandler) provided by the user.
+ * OnStage signal is emitted after the view has been connected to the stage.
+ */
+ public event DaliEventHandler<object,OnStageEventArgs> OnStageEvent
+ {
+ add
+ {
+ lock(this)
+ {
+ // Restricted to only one listener
+ if (_viewOnStageEventHandler == null)
+ {
+ _viewOnStageEventHandler += value;
+
+ _viewOnStageEventCallbackDelegate = new OnStageEventCallbackDelegate(OnStage);
+ this.OnStageSignal().Connect(_viewOnStageEventCallbackDelegate);
+ }
}
- }
+ }
- remove
- {
+ remove
+ {
lock(this)
{
- if (_KeyEventHandler != null)
- {
- this.KeyEventSignal().Disconnect(_KeyCallbackDelegate);
- }
+ if (_viewOnStageEventHandler != null)
+ {
+ this.OnStageSignal().Disconnect(_viewOnStageEventCallbackDelegate);
+ }
+
+ _viewOnStageEventHandler -= value;
+ }
+ }
+ }
+
+ // Callback for View OnStage signal
+ private void OnStage(IntPtr data)
+ {
+ OnStageEventArgs e = new OnStageEventArgs();
- _KeyEventHandler -= value;
+ // Populate all members of "e" (OnStageEventArgs) with real data
+ e.View = View.GetViewFromPtr(data);
+
+ if (_viewOnStageEventHandler != null)
+ {
+ //here we send all data to user event handlers
+ _viewOnStageEventHandler(this, e);
+ }
+ }
+
+ /**
+ * @brief Event for OffStage signal which can be used to subscribe/unsubscribe the event handler
+ * (in the type of OffStageEventHandler) provided by the user.
+ * OffStage signal is emitted after the view has been disconnected from the stage.
+ */
+ public event DaliEventHandler<object,OffStageEventArgs> OffStageEvent
+ {
+ add
+ {
+ lock(this)
+ {
+ // Restricted to only one listener
+ if (_viewOffStageEventHandler == null)
+ {
+ _viewOffStageEventHandler += value;
+
+ _viewOffStageEventCallbackDelegate = new OffStageEventCallbackDelegate(OffStage);
+ this.OnStageSignal().Connect(_viewOffStageEventCallbackDelegate);
+ }
}
- }
- }
+ }
+
+ remove
+ {
+ lock(this)
+ {
+ if (_viewOffStageEventHandler != null)
+ {
+ this.OnStageSignal().Disconnect(_viewOffStageEventCallbackDelegate);
+ }
- private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
- {
- KeyEventArgs e = new KeyEventArgs();
+ _viewOffStageEventHandler -= value;
+ }
+ }
+ }
- // Populate all members of "e" (KeyEventArgs) with real data
- e.View = Dali.View.GetViewFromPtr(view);
- e.KeyEvent = Dali.KeyEvent.GetKeyEventFromPtr(keyEvent);
+ // Callback for View OffStage signal
+ private void OffStage(IntPtr data)
+ {
+ OffStageEventArgs e = new OffStageEventArgs();
- if (_KeyEventHandler != null)
- {
- //here we send all data to user event handlers
- return _KeyEventHandler(this, e);
- }
- return false;
+ // Populate all members of "e" (OffStageEventArgs) with real data
+ e.View = View.GetViewFromPtr(data);
- }
+ if (_viewOffStageEventHandler != null)
+ {
+ //here we send all data to user event handlers
+ _viewOffStageEventHandler(this, e);
+ }
+ }
- public static View GetViewFromPtr(global::System.IntPtr cPtr) {
- View ret = new View(cPtr, false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
+ public static View GetViewFromPtr(global::System.IntPtr cPtr) {
+ View ret = new View(cPtr, false);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
-%}
+ %}
-%enddef
+ %enddef
%define DALI_CONTROL_EVENTHANDLER_PARAM( NameSpace, ClassName)
CONTROL_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
CONTROL_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
-%enddef
+ %enddef
-namespace Dali
+ namespace Dali
{
DALI_CONTROL_EVENTHANDLER_PARAM( Dali::Toolkit, Control);
}
--- /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.
+ *
+ */
+
+%define DALI_RECTINTEGER_PROPERTY_PARAM(NameSpace,ClassName)
+ %typemap(cscode) NameSpace::ClassName %{
+
+ public int X {
+ set {
+ NDalicPINVOKE.RectInteger_x_set(swigCPtr, value);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ get {
+ int ret = NDalicPINVOKE.RectInteger_x_get(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+ }
+
+ public int Y {
+ set {
+ NDalicPINVOKE.RectInteger_y_set(swigCPtr, value);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ get {
+ int ret = NDalicPINVOKE.RectInteger_y_get(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+ }
+
+ public int W {
+ set {
+ NDalicPINVOKE.RectInteger_width_set(swigCPtr, value);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ get {
+ int ret = NDalicPINVOKE.RectInteger_width_get(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+ }
+
+ public int H {
+ set {
+ NDalicPINVOKE.RectInteger_height_set(swigCPtr, value);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ get {
+ int ret = NDalicPINVOKE.RectInteger_height_get(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+ }
+
+%}
+
+%enddef
+
+namespace Dali
+{
+ DALI_RECTINTEGER_PROPERTY_PARAM( Dali, Rect<int>);
+}
public void Initialize(object source, AUIApplicationInitEventArgs e)
{
+
+ OperatorTests();
+
Handle handle = new Handle();
int myPropertyIndex = handle.RegisterProperty("myProperty", new Property.Value(10.0f), Property.AccessMode.READ_WRITE);
float myProperty = 0.0f;
Console.WriteLine( " Vector4 r = " + vector4.r + ", g = " + vector4.g + ", b = " + vector4.b + ", a = " + vector4.a );
}
+
+ public void OperatorTests()
+ {
+ Actor actor = new Actor();
+ Actor differentActor = new Actor();
+ Actor actorSame = actor;
+ Actor nullActor = null;
+
+ // test the true operator
+ if ( actor )
+ {
+ Console.WriteLine ("BaseHandle Operator true (actor) : test passed ");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator true (actor): test failed ");
+ }
+
+ Actor parent = actor.GetParent ();
+
+ if ( parent )
+ {
+ Console.WriteLine ("Handle with Empty body :failed ");
+ }
+ else
+ {
+ Console.WriteLine ("Valid with Empty body :passed ");
+ }
+
+ actor.Add( differentActor );
+ // here we test two different C# objects, which on the native side have the same body/ ref-object
+ if ( actor == differentActor.GetParent() )
+ {
+ Console.WriteLine ("actor == differentActor.GetParent() :passed ");
+ }
+ else
+ {
+ Console.WriteLine ("actor == differentActor.GetParent() :failed ");
+ }
+
+ if ( differentActor == differentActor.GetParent() )
+ {
+ Console.WriteLine ("differentActor == differentActor.GetParent() :failed ");
+ }
+ else
+ {
+ Console.WriteLine ("differentActor == differentActor.GetParent() :passed ");
+ }
+
+
+ if ( nullActor )
+ {
+ Console.WriteLine ("BaseHandle Operator true (nullActor) : test failed ");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator true (nullActor): test passed ");
+ }
+
+ // ! operator
+ if ( !actor )
+ {
+ Console.WriteLine ("BaseHandle Operator !(actor) : test failed ");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator !(actor): test passed ");
+ }
+
+ if ( !nullActor )
+ {
+ Console.WriteLine ("BaseHandle Operator !(nullActor) : test passed ");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator !(nullActor): test failed ");
+ }
+
+ // Note: operator false only used inside & operator
+ // test equality operator ==
+ if ( actor == actorSame )
+ {
+ Console.WriteLine ("BaseHandle Operator (actor == actorSame) : test passed");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator (actor == actorSame) : test failed");
+ }
+
+ if ( actor == differentActor )
+ {
+ Console.WriteLine ("BaseHandle Operator (actor == differentActor) : test failed");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator (actor == differentActor) : test passed");
+ }
+
+ if ( actor == nullActor )
+ {
+ Console.WriteLine ("BaseHandle Operator (actor == nullActor) : test failed");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator (actor == nullActor) : test passed");
+ }
+
+ if ( nullActor == nullActor )
+ {
+ Console.WriteLine ("BaseHandle Operator (nullActor == nullActor) : test passed");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator (nullActor == nullActor) : test failed");
+ }
+
+ // test || operator
+ if ( actor || actorSame )
+ {
+ Console.WriteLine ("BaseHandle Operator (actor || actorSame) : test passed");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator (actor || actorSame) : test failed");
+ }
+
+ if ( actor || nullActor )
+ {
+ Console.WriteLine ("BaseHandle Operator (actor || nullActor) : test passed");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator (actor || nullActor) : test failed");
+ }
+
+ if ( nullActor || nullActor )
+ {
+ Console.WriteLine ("BaseHandle Operator (nullActor || nullActor) : test failed");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator (nullActor || nullActor) : test passed");
+ }
+
+
+ // test && operator
+ if ( actor && actorSame )
+ {
+ Console.WriteLine ("BaseHandle Operator (actor && actorSame) : test passed");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator (actor && actorSame) : test failed");
+ }
+
+ if ( actor && nullActor )
+ {
+ Console.WriteLine ("BaseHandle Operator (actor && nullActor) : test failed");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator (actor && nullActor) : test passed");
+ }
+
+ if ( nullActor && nullActor )
+ {
+ Console.WriteLine ("BaseHandle Operator (nullActor && nullActor) : test failed");
+ }
+ else
+ {
+ Console.WriteLine ("BaseHandle Operator (nullActor && nullActor) : test passed");
+ }
+
+ }
+
public void MainLoop()
{
_application.MainLoop ();
--- /dev/null
+using Dali;
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+
+namespace FirstScreen
+{
+ public class FirstScreenApp
+ {
+ private int _currentPostersContainerID;
+ private int _totalPostersContainers;
+
+ private Application _application;
+ private Stage _stage;
+ private Vector2 _stageSize;
+
+ private List<ScrollContainer> _postersContainer;
+
+ private ScrollContainer _menuContainer;
+ private Vector3 _menuItemSize;
+
+ private Layer _bottomClipLayer;
+ private Layer _topClipLayer;
+ private View _topContainer;
+ private View _bottomContainer;
+
+ private FocusEffect _focusEffect;
+ private string _imagePath;
+
+ private ImageView _keyboardFocusIndicator;
+ private ImageView _launcherSeparator;
+ private ImageView[] launcherIcon;
+ private Animation _showBottomContainerAnimation;
+ private Animation _hideBottomContainerAnimation;
+
+ public FirstScreenApp(Application application)
+ {
+ _application = application;
+ _application.Initialized += OnInitialize;
+ }
+
+ public static void Run()
+ {
+ FirstScreenApp tVApp = new FirstScreenApp(Application.NewApplication());
+ tVApp.MainLoop();
+ }
+
+ public void MainLoop()
+ {
+ _application.MainLoop();
+ }
+
+ // Create Items for Poster ScrollContainer
+ private void CreatePosters()
+ {
+ for (int j = 0; j < _totalPostersContainers; j++)
+ {
+ View posterContainer = _postersContainer[j].Container;
+ for (int i = 0; i < Constants.PostersItemsCount; i++)
+ {
+ if (j % _totalPostersContainers == 0)
+ {
+ View item = new ImageView(_imagePath + "/poster"+j+"/"+ (i % 6)+ ".jpg");
+ item.SetName ("poster-item-" + _postersContainer[j].ItemCount);
+ _postersContainer[j].AddItem(item);
+ }
+ else
+ {
+ View item = new ImageView(_imagePath + "/poster"+j+"/"+ (i % 6)+ ".jpg");
+ item.SetName ("poster-item-" + _postersContainer[j].ItemCount);
+ _postersContainer[j].AddItem(item);
+ }
+ }
+
+ if (j == 0)
+ {
+ _postersContainer[j].Show();
+ }
+ else
+ {
+ _postersContainer[j].Hide();
+ }
+
+ _postersContainer[j].SetFocused(false);
+ }
+
+ _currentPostersContainerID = 0;
+ }
+
+ // Create Items for Menu ScrollContainer
+ private void CreateMenu()
+ {
+ View menuContainer = _menuContainer.Container;
+ menuContainer.Position = new Vector3(Constants.LauncherWidth, 0.0f, 0.0f);
+
+ for(int i = 0; i < Constants.MenuItemsCount; i++)
+ {
+ View menuItem = new ImageView(_imagePath + "/menu/" + i % 7 + ".png");
+ menuItem.SetName("menu-item-" + _menuContainer.ItemCount);
+ _menuContainer.AddItem(menuItem);
+ }
+ }
+
+ private Actor OnKeyboardPreFocusChangeSignal(object source, KeyboardFocusManager.PreFocusChangeEventArgs e)
+ {
+ Actor actor = _menuContainer.ItemRoot;
+
+ if (e.Direction == View.KeyboardFocus.Direction.UP)
+ {
+ // Move the Focus to Poster ScrollContainer and hide Bottom Container (Menu ScrollContainer)
+ if (_menuContainer.IsFocused)
+ {
+ actor = _postersContainer[_currentPostersContainerID].GetCurrentFocusedActor();
+ _menuContainer.SetFocused(false);
+ _postersContainer[_currentPostersContainerID].SetFocused(true);
+ HideBottomContainer();
+
+ // Also apply Focus animation on Focused item on Poster ScrollContainer
+ _postersContainer[_currentPostersContainerID].FocusAnimation(_focusEffect, FocusEffectDirection.BottomToTop);
+ }
+ }
+ else if (e.Direction == View.KeyboardFocus.Direction.DOWN)
+ {
+ // Show Bottom Container (Menu ScrollContainer) and move the Focus to it
+ if (!_menuContainer.IsFocused)
+ {
+ ShowBottomContainer();
+ actor = _menuContainer.GetCurrentFocusedActor();
+ _postersContainer[_currentPostersContainerID].SetFocused(false);
+ _menuContainer.SetFocused(true);
+
+ // Also apply Focus animation on Focused item on Menu ScrollContainer
+ _menuContainer.FocusAnimation(_focusEffect, FocusEffectDirection.TopToBottom);
+ }
+ }
+ else if (e.Direction == View.KeyboardFocus.Direction.LEFT)
+ {
+ if (_menuContainer.IsFocused)
+ {
+ // Move the Focus to the left item/image of currently focused item on Menu ScrollContainer
+ actor = _menuContainer.FocusPrevious();
+
+ int id = _menuContainer.FocusedItemID % _totalPostersContainers;
+ if (id != _currentPostersContainerID)
+ {
+ _postersContainer[_currentPostersContainerID].Hide();
+ _currentPostersContainerID = id;
+
+ _postersContainer[_currentPostersContainerID].Show();
+ }
+ }
+ else
+ {
+ // Move the Focus to the left item/image of currently focused item on Poster ScrollContainer
+ actor = _postersContainer[_currentPostersContainerID].FocusPrevious();
+ }
+ }
+ else if (e.Direction == View.KeyboardFocus.Direction.RIGHT)
+ {
+ if (_menuContainer.IsFocused)
+ {
+ // Move the Focus to the right item/image of currently focused item on Menu ScrollContainer
+ actor = _menuContainer.FocusNext();
+
+ int id = _menuContainer.FocusedItemID % _totalPostersContainers;
+ if (id != _currentPostersContainerID)
+ {
+ _postersContainer[_currentPostersContainerID].Hide();
+ _currentPostersContainerID = id;
+ _postersContainer[_currentPostersContainerID].Show();
+ }
+ }
+ else
+ {
+ // Move the Focus to the right item/image of currently focused item on Poster ScrollContainer
+ actor = _postersContainer[_currentPostersContainerID].FocusNext();
+ }
+ }
+
+ return actor;
+ }
+
+ // Hide Bottom Container (Menu ScrollContainer) when it is not focused
+ private void HideBottomContainer()
+ {
+ _topClipLayer.ClippingBox = new RectInteger(0,
+ Convert.ToInt32(_stageSize.height * Constants.TopContainerPositionFactor),
+ Convert.ToInt32((_stageSize.width)),
+ Convert.ToInt32((_stageSize.height * Constants.TopClipLayerExpandHeightFactor))); // X, Y, Width, Height
+
+ _hideBottomContainerAnimation.AnimateTo(new Property(_bottomContainer, Actor.Property.POSITION),
+ new Property.Value(new Vector3(0.0f, _stageSize.height * Constants.BottomContainerHidePositionFactor, 0.0f)),
+ new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE));
+ _hideBottomContainerAnimation.Play();
+ }
+
+ // Show (unhide) Bottom Container (Menu ScrollContainer) when it is focused
+ private void ShowBottomContainer()
+ {
+ _topClipLayer.ClippingBox = new RectInteger(0,
+ Convert.ToInt32(_stageSize.height * Constants.TopContainerPositionFactor),
+ Convert.ToInt32((_stageSize.width)),
+ Convert.ToInt32((_stageSize.height * Constants.TopClipLayerHeightFactor))); // X, Y, Width, Height
+
+ _showBottomContainerAnimation.AnimateTo(new Property(_bottomContainer, Actor.Property.POSITION),
+ new Property.Value(new Vector3(0.0f, _stageSize.height * Constants.BottomContainerShowPositionFactor, 0.0f)),
+ new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE));
+ _showBottomContainerAnimation.Play();
+ }
+
+ // First screen demo Application initialisation
+ private void OnInitialize(object source, AUIApplicationInitEventArgs e)
+ {
+ _stage = Stage.GetCurrent();
+ _stageSize = _stage.GetSize();
+// _stage.SetBackgroundColor(NDalic.TRANSPARENT);
+
+ _totalPostersContainers = Constants.TotalPostersContainers;
+ _imagePath = "./images/"; // Desktop
+// _imagePath = "/home/owner/apps_rw/org.tizen.firstscreen/res/images/"; // Target
+
+ _postersContainer = new List<ScrollContainer> ();
+ _menuContainer = new ScrollContainer ();
+
+ _hideBottomContainerAnimation = new Animation(0.25f);
+ _showBottomContainerAnimation = new Animation(0.25f);
+
+ // Create a Top Container for poster items
+ _topContainer = new View();
+ _topContainer.Size = new Vector3(_stageSize.width, _stageSize.height * Constants.TopContainerHeightFactor, 0.0f);
+ _topContainer.Position = new Vector3(0.0f, _stageSize.y * Constants.TopContainerPositionFactor, 0.0f);
+ _topContainer.ParentOrigin = NDalic.ParentOriginTopLeft;
+ _topContainer.AnchorPoint = NDalic.AnchorPointTopLeft;
+
+ // Add a background to Top container
+ Property.Map visual = new Property.Map();
+ visual.Insert(NDalic.VISUAL_PROPERTY_TYPE, new Property.Value((int)VisualType.IMAGE));
+ visual.Insert(NDalic.IMAGE_VISUAL_URL, new Property.Value(_imagePath + "/background.png"));
+ _topContainer.Background = visual;
+ _topContainer.Name = "TopControl";
+
+ // Create a Bottom Container
+ _bottomContainer = new View();
+ _bottomContainer.Size = new Vector3(_stageSize.width, _stageSize.height * Constants.BottomContainerHeightFactor, 0.0f);
+ _bottomContainer.Position = new Vector3(0.0f, _stageSize.height * Constants.BottomContainerHidePositionFactor, 0.0f);
+ _bottomContainer.ParentOrigin = NDalic.ParentOriginTopLeft;
+ _bottomContainer.AnchorPoint = NDalic.AnchorPointTopLeft;
+
+ // Add a background to Bottom Container
+ visual = new Property.Map();
+ visual.Insert(NDalic.VISUAL_PROPERTY_TYPE, new Property.Value((int)VisualType.IMAGE));
+ visual.Insert(NDalic.IMAGE_VISUAL_URL, new Property.Value(_imagePath + "/background.png"));
+ _bottomContainer.Background = visual;
+ _bottomContainer.Name = "BottomControl";
+
+ // Add both Top and Bottom Containers to Stage
+ _stage.Add(_topContainer);
+ _stage.Add(_bottomContainer);
+
+ // Add a clip layer to Top Container
+ _topClipLayer = new Layer();
+ _topClipLayer.AnchorPoint = NDalic.AnchorPointBottomCenter;
+ _topClipLayer.ParentOrigin = NDalic.ParentOriginBottomCenter;
+ _topClipLayer.ClippingEnable = true;
+ _topClipLayer.ClippingBox = new RectInteger(0,
+ Convert.ToInt32(_stageSize.height * Constants.TopContainerPositionFactor),
+ Convert.ToInt32((_stageSize.width)),
+ Convert.ToInt32((_stageSize.height * Constants.TopClipLayerHeightFactor))); // X, Y, Width, Height
+ _topContainer.Add(_topClipLayer);
+
+ // Create a SpotLight for items / images of both Poster and Menu ScrollContainers
+ ImageView spotLight = new ImageView(_imagePath + "/highlight_spot.png");
+ spotLight.WidthResizePolicy = "USE_NATURAL_SIZE";
+ spotLight.HeightResizePolicy = "USE_NATURAL_SIZE";
+ spotLight.ParentOrigin = NDalic.ParentOriginCenter;
+ spotLight.AnchorPoint = NDalic.AnchorPointCenter;
+ spotLight.Name = "spotLight";
+
+ // Create a shadowBorder for items / images of Poster ScrollContainers
+ ImageView shadowBorder = new ImageView(_imagePath + "/thumbnail_shadow.9.png");
+ shadowBorder.ParentOrigin = NDalic.ParentOriginCenter;
+ shadowBorder.AnchorPoint = NDalic.AnchorPointCenter;
+ shadowBorder.WidthResizePolicy = "SIZE_FIXED_OFFSET_FROM_PARENT";
+ shadowBorder.HeightResizePolicy = "SIZE_FIXED_OFFSET_FROM_PARENT";
+ shadowBorder.SetSizeModeFactor(new Vector3(32.0f, 41.0f, 0.0f));
+ shadowBorder.Name = "poster shadowBorder";
+
+ // Create Poster Containers and add them to Top Clip layer
+ for (int i = 0; i < _totalPostersContainers; i++)
+ {
+ _postersContainer.Add(new ScrollContainer());
+ _postersContainer[i].Container.Name = "poster" + i;
+ if (i == 0)
+ {
+ _postersContainer[i].ItemSize = new Vector3((_stageSize.width * Constants.Poster0ItemWidthFactor) - Constants.PostersContainerPadding,
+ _stageSize.height * Constants.PostersItemHeightFactor, 0.0f);
+ }
+ else
+ {
+ _postersContainer[i].ItemSize = new Vector3(_stageSize.width * Constants.Poster1ItemWidthFactor,
+ _stageSize.height * Constants.PostersItemHeightFactor, 0.0f);
+ }
+ _postersContainer[i].Padding = Constants.PostersContainerPadding;
+ _postersContainer[i].MarginX = Constants.PostersContainerMargin;
+ _postersContainer[i].OffsetY = Constants.PostersContainerOffsetYFactor;
+ _postersContainer[i].Width = _stageSize.width;
+ _postersContainer[i].Height = _stageSize.height * Constants.PostersContainerHeightFactor;
+ _postersContainer[i].ShadowBorder = shadowBorder;
+ _postersContainer[i].ShadowBorder.Position = new Vector3(0.0f, 4.0f, 0.0f);
+ _postersContainer[i].SpotLight = spotLight;
+ _topClipLayer.Add(_postersContainer[i].Container);
+ }
+
+ // Add a clip layer to Bottom Container
+ _bottomClipLayer = new Layer();
+ _bottomClipLayer.AnchorPoint = NDalic.AnchorPointBottomCenter;
+ _bottomClipLayer.ParentOrigin = NDalic.ParentOriginBottomCenter;
+ _bottomClipLayer.ClippingEnable = true;
+ _bottomClipLayer.ClippingBox = new RectInteger(Convert.ToInt32(Constants.LauncherWidth),
+ Convert.ToInt32(_stageSize.height * Constants.BottomContainerShowPositionFactor),
+ Convert.ToInt32((_stageSize.width)),
+ Convert.ToInt32((_stageSize.height - (_stageSize.height * Constants.BottomClipLayerHeightFactor)))); // X, Y, Width, Height
+ _bottomContainer.Add(_bottomClipLayer);
+
+ // Add Launcher items to Bottom Container. Launcher is used to display three images on left of Menu ScrollContainer
+ launcherIcon = new ImageView[Convert.ToInt32(Constants.LauncherItemsCount)];
+ for (int launcherIndex = 0; launcherIndex < Constants.LauncherItemsCount; launcherIndex++)
+ {
+ launcherIcon[launcherIndex] = new ImageView(_imagePath + "/" + launcherIndex + "-normal.png");
+ launcherIcon[launcherIndex].Name = "launcherIcon" + launcherIndex;
+ launcherIcon[launcherIndex].WidthResizePolicy = "USE_NATURAL_SIZE";
+ launcherIcon[launcherIndex].HeightResizePolicy = "USE_NATURAL_SIZE";
+ launcherIcon[launcherIndex].ParentOrigin = NDalic.ParentOriginCenterLeft;
+ launcherIcon[launcherIndex].AnchorPoint = NDalic.AnchorPointCenterLeft;
+ launcherIcon[launcherIndex].Position = new Vector3(Constants.LauncherIconWidth * launcherIndex + Constants.LauncherLeftMargin, 0.0f, 0.0f);
+ _bottomContainer.Add(launcherIcon[launcherIndex]);
+ }
+
+ // Add a shadow seperator image between last Launcher icon and Menu ScrollContainer
+ _launcherSeparator = new ImageView(_imagePath + "/focus_launcher_shadow_n.png");
+ _launcherSeparator.Name = "launcherSeparator";
+ _launcherSeparator.WidthResizePolicy = "USE_NATURAL_SIZE";
+ _launcherSeparator.HeightResizePolicy = "FILL_TO_PARENT";
+ _launcherSeparator.ParentOrigin = NDalic.ParentOriginCenterLeft;
+ _launcherSeparator.AnchorPoint = NDalic.AnchorPointCenterLeft;
+ _launcherSeparator.Position = new Vector3(Constants.LauncherIconWidth * Constants.LauncherItemsCount + Constants.LauncherLeftMargin, 0.0f, 0.0f);
+ _bottomContainer.Add(_launcherSeparator);
+
+ // Create Menu Container and add it to Bottom Clip Layer
+ _menuItemSize = new Vector3((_stageSize.width * Constants.MenuItemWidthFactor) - Constants.MenuContainerPadding,
+ _stageSize.height * Constants.MenuItemHeightFactor, 0.0f);
+ _menuContainer.Container.Name = "menu";
+ _menuContainer.ItemSize = _menuItemSize;
+ _menuContainer.Padding = Constants.MenuContainerPadding;
+ _menuContainer.MarginX = Constants.MenuContainerMargin;
+ _menuContainer.OffsetY = Constants.MenuContainerOffsetYFactor;
+ _menuContainer.OffsetX = Constants.LauncherWidth;
+ _menuContainer.Width = _stageSize.width - Constants.LauncherWidth;
+ _menuContainer.Height = _stageSize.height * Constants.MenuContainerHeightFactor;
+ _menuContainer.ShadowBorder = new ImageView(_imagePath + "/focus_launcher_shadow.9.png");
+ _menuContainer.ShadowBorder.Name = "_menuContainer.ShadowBorder";
+ _menuContainer.ShadowBorder.Size = new Vector3(_menuContainer.ItemSize.width + 40.0f, _menuContainer.ItemSize.height + 50.0f, 0.0f);
+ _menuContainer.ShadowBorder.Position = new Vector3(0.0f, 5.0f, 0.0f);
+ _menuContainer.ShadowBorder.ParentOrigin = NDalic.ParentOriginCenter;
+ _menuContainer.ShadowBorder.AnchorPoint = NDalic.AnchorPointCenter;
+ _menuContainer.SpotLight = spotLight;
+ _bottomClipLayer.Add(_menuContainer.Container);
+
+ CreatePosters(); // Create Items for Poster ScrollContainer
+ CreateMenu(); // Create Items for Menu ScrollContainer
+
+ // Initialize PreFocusChange event of KeyboardFocusManager
+ KeyboardFocusManager keyboardFocusManager = KeyboardFocusManager.Get();
+ keyboardFocusManager.PreFocusChange += OnKeyboardPreFocusChangeSignal;
+
+ _keyboardFocusIndicator = new ImageView(_imagePath + "/highlight_stroke.9.png");
+ _keyboardFocusIndicator.ParentOrigin = NDalic.ParentOriginCenter;
+ _keyboardFocusIndicator.AnchorPoint = NDalic.AnchorPointCenter;
+ _keyboardFocusIndicator.WidthResizePolicy = "FILL_TO_PARENT";
+ _keyboardFocusIndicator.HeightResizePolicy = "FILL_TO_PARENT";
+
+ keyboardFocusManager.SetFocusIndicatorActor(_keyboardFocusIndicator);
+
+ _focusEffect = new FocusEffect();
+
+ // Move Fcous to Bottom Container (Menu ScrollContainer)
+ ShowBottomContainer();
+ _menuContainer.SetFocused(true);
+ }
+ }
+}
+
--- /dev/null
+using System;
+
+namespace FirstScreen
+{
+ public class Constants
+ {
+ public const int TotalPostersContainers = 2; // Number of Poster ScrollContainers to be added on Top Container
+
+ public const float TopContainerHeightFactor = 0.38f; // Height Factor of stage height used for Top Container total height
+ public const float TopContainerPositionFactor = 0.50f; // Position Factor of stage height used for Top Container position
+ public const float TopClipLayerHeightFactor = 0.34f; // Height Factor of stage height used for Top Clip layer height
+ public const float TopClipLayerExpandHeightFactor = 0.36f; // Expanded Height Factor of stage height used for Top Clip layer height (used when Bottom container is hidden)
+ public const float PostersContainerHeightFactor = 0.32f; // Height Factor of stage height used for Poster ScrollContainers
+ public const float PostersContainerPadding = 2.0f; // Padding size used between items / images in Poster ScrollContainer
+ public const float PostersContainerMargin = 60.0f; // Extra margin Padding size used between items / images in Poster ScrollContainer when item / image is focused
+ public const float PostersContainerOffsetYFactor = 0.17f; // Position Factor of Poster item height used for Poster items / images position
+
+ public const float BottomContainerHeightFactor = 0.16f; // Height Factor of stage height used for Bottom Container total height
+ public const float BottomContainerHidePositionFactor = 0.88f; // Position Factor of stage height used for Bottom Container position when bottom container is hidden (not focused)
+ public const float BottomContainerShowPositionFactor = 0.84f; // Position Factor of stage height used for Bottom Container position when bottom container is not hidden (focused)
+ public const float MenuContainerHeightFactor = 0.16f; // Height Factor of stage height used for Bottom ScrollContainers
+ public const float BottomClipLayerHeightFactor = 0.84f; // Height Factor of stage height used for Bottom Clip layer height
+ public const float MenuContainerPadding = 10.0f; // Padding size used between items / images in Menu ScrollContainer
+ public const float MenuContainerMargin = 25.0f; // Extra margin Padding size used between items / images in Menu ScrollContainer when item / image is focused
+ public const float MenuContainerOffsetYFactor = 0.35f; // Position Factor of Poster item height used for Menu items / images position
+
+ public const float MenuItemWidthFactor = 0.125f; // Width Factor (1/8) of stage Width used for Menu items / images Width
+ public const float MenuItemHeightFactor = 0.10f; // Height Factor of stage height used for Menu items / images Height
+ public const float MenuItemsCount = 14; // Number of Menu items / images used in a Menu ScrollContainer
+
+ public const float Poster0ItemWidthFactor = 0.25f; // Width Factor (1/4) of stage Width used for Poster items / images Width in a Poster ScrollContainer 0
+ public const float Poster1ItemWidthFactor = 0.24f; // Width Factor of stage Width used for Poster items / images Width in a Poster ScrollContainer 1
+ public const float PostersItemHeightFactor = 0.24f; // Height Factor of stage height used for Poster items / images Height
+ public const float PostersItemsCount = 24; // Number of Menu items / images used in a Poster ScrollContainer
+
+ public const float LauncherWidth = 280.0f; // Width of Launcher. Launcher is used to display three images on left of Menu ScrollContainer
+ public const float LauncherLeftMargin = 40.0f; // Extra Spaces to the left of first Launcher item / image
+ public const float LauncherSeparatorWidth = 20.0f; // Extra area / space to the left of Menu ScrollContainer used for a speration shadow image
+ public const float LauncherItemsCount = 3.0f; // Total number of Launcher items / images
+ public const float LauncherIconWidth = (LauncherWidth - LauncherLeftMargin - LauncherSeparatorWidth) / LauncherItemsCount; // Width of each Launcher item / image
+ }
+}
+
--- /dev/null
+using Dali;
+using System;
+
+namespace FirstScreen
+{
+ public class FocusData
+ {
+ private string _name; // Name used for FocusData object (mainly to differentiate key frame animation )
+ private string _imageName; // Image File Name (to be loaded from disk) used for ImageView used in key frame animation
+ private Vector3 _parentOrigin; // ParentOrigin applied to ImageView
+ private Vector3 _initSize; // InitSize used for key frame animation
+ private Vector3 _targetSize; // TargetSize used for key frame animation
+ private float _keyFrameStart; // KeyFrameStart used for key frame animation
+ private float _keyFrameEnd; // KeyFrameEnd used for key frame animation
+ private Direction _direction; // Direction used for key frame animation
+ private ImageView _imageFocus; // ImageView used in key frame animation
+
+ // Initialize FocusData used for key frame animation
+ public FocusData(string name, string imageName, Direction direction, Vector3 parentOrigin, Vector3 initSize,
+ Vector3 targetSize, float keyFrameStart, float keyFrameEnd)
+ {
+ _name = name;
+ _imageName = imageName;
+ _parentOrigin = parentOrigin;
+ _initSize = initSize;
+ _targetSize = targetSize;
+ _keyFrameStart = keyFrameStart;
+ _keyFrameEnd = keyFrameEnd;
+ _direction = direction;
+
+ _imageFocus = new ImageView("./images/focuseffect/" + _imageName); // Desktop
+// _imageFocus = new ImageView("/home/owner/apps_rw/org.tizen.firstscreen/res/images/focuseffect/" + _imageName); // Target
+
+ _imageFocus.ParentOrigin = _parentOrigin;
+ _imageFocus.AnchorPoint = NDalic.AnchorPointCenter;
+ _imageFocus.Name = _name;
+ }
+
+ public enum Direction
+ {
+ Horizontal,
+ Vertical
+ };
+
+ public Direction FocusDirection
+ {
+ get {return _direction;}
+ set {_direction = value;}
+ }
+
+ public string Name
+ {
+ get {return _name;}
+ set {_name = value;}
+ }
+
+ public string ImageName
+ {
+ get {return _imageName;}
+ set {_imageName = value;}
+ }
+
+ public Vector3 ParentOrigin
+ {
+ get
+ {
+ return _parentOrigin;
+ }
+ set
+ {
+ _parentOrigin = value;
+ _imageFocus.ParentOrigin = _parentOrigin;
+ }
+ }
+
+ public Vector3 InitSize
+ {
+ get {return _initSize;}
+ set {_initSize = value;}
+ }
+
+ public Vector3 TargetSize
+ {
+ get {return _targetSize;}
+ set {_targetSize = value;}
+ }
+
+ public float KeyFrameStart
+ {
+ get {return _keyFrameStart;}
+ set {_keyFrameStart = value;}
+ }
+
+ public float KeyFrameEnd
+ {
+ get {return _keyFrameEnd;}
+ set {_keyFrameEnd = value;}
+ }
+
+ public ImageView ImageItem
+ {
+ get {return _imageFocus;}
+ }
+ }
+}
+
--- /dev/null
+using Dali;
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+
+namespace FirstScreen
+{
+ public class FocusEffect : IFocusEffect
+ {
+ private float _frameThickness;
+ private FocusData[] _focusData; // Each FocusData is used for one key frame animation (total 6 key frame animations needed for EddenEffect)
+ private Animation _animation; // Animation used to apply all six key frame animations
+
+ public FocusEffect()
+ {
+ _frameThickness = 10.0f;
+ float _bottomFrameTime = 0.6f; // complete the halo/bottom animation 60% of the way through
+ float _sideFrameTime = 0.8f; // Start the side frame animation after the bottom animation and complete at 80% of the way through
+ float _topFrameTime = 1.0f; // start the top frame animation after the side frame animation and complete at 100% way through
+
+ // Six key frame animations (FocusData objects) needed for EddenEffect
+ // Two key frame animations for top horizontal effect
+ // Two key frame animations for bottom horizontal effect
+ // Two key frame animations for vertical horizontal effect
+ _focusData = new FocusData[6];
+
+ FocusData focusData = new FocusData("halo", "halo.png", FocusData.Direction.Horizontal, NDalic.ParentOriginTopCenter,
+ new Vector3(50,20,0), new Vector3(0.0f, 100.0f , 0.0f), 0.0f, _bottomFrameTime);
+ _focusData[0] = focusData;
+
+ focusData = new FocusData("bottom", "horizontalFrame.png", FocusData.Direction.Horizontal, NDalic.ParentOriginTopCenter,
+ new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, _frameThickness, 0.0f), 0.0f, _bottomFrameTime);
+ _focusData[1] = focusData;
+
+ focusData = new FocusData("left", "verticalFrame.png", FocusData.Direction.Vertical, NDalic.ParentOriginBottomLeft,
+ new Vector3(0.0f, 0.0f, 0.0f), new Vector3(_frameThickness, 0.0f, 0.0f), _bottomFrameTime, _sideFrameTime);
+ _focusData[2] = focusData;
+
+ focusData = new FocusData("right", "verticalFrame.png", FocusData.Direction.Vertical, NDalic.ParentOriginBottomRight,
+ new Vector3(0.0f, 0.0f, 0.0f), new Vector3(_frameThickness, 0.0f, 0.0f), _bottomFrameTime, _sideFrameTime);
+ _focusData[3] = focusData;
+
+ focusData = new FocusData("top-left", "horizontalFrame.png", FocusData.Direction.Horizontal, NDalic.ParentOriginBottomLeft,
+ new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f ,_frameThickness, 0.0f), _sideFrameTime, _topFrameTime);
+ _focusData[4] = focusData;
+
+ focusData = new FocusData("top-right", "horizontalFrame.png", FocusData.Direction.Horizontal, NDalic.ParentOriginBottomRight,
+ new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, _frameThickness, 0.0f), _sideFrameTime, _topFrameTime);
+ _focusData[5] = focusData;
+ }
+
+ public void FocusAnimation(View parentItem, Vector3 itemSize, float duration, FocusEffectDirection direction)
+ {
+ var itemWidth = itemSize.x + _frameThickness / 2;
+ var itemHeight = itemSize.y + _frameThickness / 3;
+
+ if (_animation)
+ {
+ _animation.Clear();
+ _animation.Reset();
+ }
+ _animation = new Animation(duration);
+
+ if (direction == FocusEffectDirection.BottomToTop)
+ {
+ _focusData[0].ParentOrigin = NDalic.ParentOriginBottomCenter;
+ _focusData[1].ParentOrigin = NDalic.ParentOriginBottomCenter;
+ _focusData[2].ParentOrigin = NDalic.ParentOriginBottomLeft;
+ _focusData[3].ParentOrigin = NDalic.ParentOriginBottomRight;
+ _focusData[4].ParentOrigin = NDalic.ParentOriginTopLeft;
+ _focusData[5].ParentOrigin = NDalic.ParentOriginTopRight;
+ }
+ else
+ {
+ _focusData[0].ParentOrigin = NDalic.ParentOriginTopCenter;
+ _focusData[1].ParentOrigin = NDalic.ParentOriginTopCenter;
+ _focusData[2].ParentOrigin = NDalic.ParentOriginBottomLeft;
+ _focusData[3].ParentOrigin = NDalic.ParentOriginBottomRight;
+ _focusData[4].ParentOrigin = NDalic.ParentOriginBottomLeft;
+ _focusData[5].ParentOrigin = NDalic.ParentOriginBottomRight;
+ }
+
+ foreach (FocusData focusData in _focusData)
+ {
+ var currentParent = focusData.ImageItem.GetParent();
+
+ // first parent the controls
+ if (parentItem != currentParent)
+ {
+ parentItem.Add(focusData.ImageItem);
+ }
+
+ focusData.ImageItem.Size = new Vector3(100.0f,100.0f, 0.0f);
+ parentItem.Add(focusData.ImageItem);
+
+ Vector3 targetSize = focusData.TargetSize;
+ Vector3 initSize = focusData.InitSize;
+
+ if (focusData.FocusDirection == FocusData.Direction.Horizontal)
+ {
+ // adjust the width to match the parent
+ targetSize.x = itemWidth;
+ }
+ else // vertical frame
+ {
+ // adjust the height to match the parent
+ targetSize.y = itemHeight;
+ }
+
+ // half the size for the top frame as we come out from both left / right sides
+ if (focusData.Name == "top-right" || focusData.Name == "top-left")
+ {
+ targetSize.x = itemWidth - _frameThickness;
+ }
+
+ KeyFrames keyFrames = new KeyFrames();
+
+ keyFrames.Add(0.0f, new Property.Value(initSize));
+ keyFrames.Add(focusData.KeyFrameStart, new Property.Value(initSize));
+ keyFrames.Add(focusData.KeyFrameEnd, new Property.Value(targetSize));
+
+ // for halo add an extra keyframe to shrink it ( in 20% of time after it has finished)
+ if (focusData.Name =="halo")
+ {
+ keyFrames.Add(focusData.KeyFrameEnd + 0.2f, new Property.Value(initSize));
+ }
+
+ _animation.AnimateBetween(new Property(focusData.ImageItem, Actor.Property.SIZE), keyFrames,
+ new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE));
+
+ // Simulate the vertical frame growing from the top.
+ // Vertical items are anchored to the bottom of the parent... so when they grow
+ // we need to move them to the middle of the parent ( otherwise they stick out the bottom)
+ if (focusData.FocusDirection == FocusData.Direction.Vertical)
+ {
+ //animate position as well so it looks like animation is coming from bottom
+ KeyFrames keyFramesV = new KeyFrames();
+
+ if (direction == FocusEffectDirection.BottomToTop)
+ {
+ keyFramesV.Add(0.0f, new Property.Value(0.0f));
+ keyFramesV.Add(focusData.KeyFrameStart, new Property.Value(0.0f));
+ }
+ else
+ {
+ keyFramesV.Add(0.0f, new Property.Value(-itemHeight));
+ keyFramesV.Add(focusData.KeyFrameStart, new Property.Value(-itemHeight));
+ }
+
+ keyFramesV.Add(focusData.KeyFrameEnd, new Property.Value(-itemHeight / 2)); // animate to halfway up the control
+
+ _animation.AnimateBetween(new Property(focusData.ImageItem, Actor.Property.POSITION_Y), keyFramesV,
+ new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE));
+ }
+
+ // Simulate the top frame growing from the sides.
+ if (focusData.Name == "top-left")
+ {
+ KeyFrames keyFramesTL = new KeyFrames();
+
+ keyFramesTL.Add(0.0f, new Property.Value(0.0f));
+ keyFramesTL.Add(focusData.KeyFrameStart, new Property.Value(0.0f));
+ keyFramesTL.Add(focusData.KeyFrameEnd, new Property.Value(itemWidth / 2)); // animate to halfway up the control
+
+ // grow these from the left or right
+ _animation.AnimateBetween(new Property(focusData.ImageItem, Actor.Property.POSITION_X), keyFramesTL,
+ new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE));
+ }
+
+ if (focusData.Name == "top-right")
+ {
+ KeyFrames keyFramesTR = new KeyFrames();
+
+ keyFramesTR.Add(0.0f, new Property.Value(0.0f));
+ keyFramesTR.Add(focusData.KeyFrameStart, new Property.Value(0.0f));
+ keyFramesTR.Add(focusData.KeyFrameEnd, new Property.Value(-itemWidth / 2)); // animate to halfway up the control
+
+ // grow these from the left or right
+ _animation.AnimateBetween(new Property(focusData.ImageItem, Actor.Property.POSITION_X), keyFramesTR,
+ new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE));
+ }
+
+ _animation.Finished += OnAnimationFinished;
+
+ _animation.Play();
+ }
+ }
+
+ private void OnAnimationFinished(object source, Animation.FinishedEventArgs e)
+ {
+ foreach (FocusData focusData in _focusData)
+ {
+ var currentParent = focusData.ImageItem.GetParent();
+
+ if (currentParent)
+ {
+ currentParent.Remove(focusData.ImageItem);
+ }
+ }
+ }
+ }
+}
+
--- /dev/null
+using Dali;
+using System;
+
+namespace FirstScreen
+{
+ public enum FocusEffectDirection
+ {
+ TopToBottom,
+ BottomToTop
+ };
+
+ public interface IFocusEffect
+ {
+ void FocusAnimation(View parentItem, Vector3 itemSize, float duration, FocusEffectDirection direction);
+ }
+}
+
--- /dev/null
+using System;
+
+namespace FirstScreen
+{
+ public class MainClass
+ {
+ [STAThread]
+ static void Main(string[] args)
+ {
+ FirstScreenApp.Run();
+ }
+ }
+}
+
--- /dev/null
+using Dali;
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+
+
+namespace FirstScreen
+{
+ public class ScrollContainer
+ {
+ private View _container;
+ private Actor _itemRoot;
+ private Vector3 _itemSize;
+ private List<View> _itemList;
+ private int _itemCount;
+ private int _focusedItem;
+ private PanGestureDetector _panGestureDetector;
+ private float _scrollDisplacement;
+ private float _currentScrollPosition;
+ private float _padding;
+ private float _width;
+ private float _height;
+ private bool _isFocused;
+ private float _marginX;
+ private float _marginY;
+ private float _offsetY;
+ private float _offsetX;
+ private Stage _stage;
+ private Vector2 _stageSize;
+ private ImageView _shadowBorder;
+ private ImageView _spotLight;
+ private Animation _spotLightAnimation;
+ private Animation _showAnimation;
+ private Animation _hideAnimation;
+ private Animation _focusAnimation;
+ private Animation _scrollAnimation;
+ private Animation _focusTransitionAnimation;
+ private Path _circularPath;
+ private bool _shouldHide;
+
+ public ScrollContainer()
+ {
+ _itemSize = new Vector3(0.0f, 0.0f, 0.0f);
+ _padding = 0.0f;
+ _width = 0.0f;
+ _height = 0.0f;
+ _currentScrollPosition = 0.0f;
+ _itemCount = 0;
+ _focusedItem = -1;
+ _isFocused = false;
+ _marginX = 50.0f;
+ _marginY = 0.0f;
+ _offsetY = 0.0f;
+ _offsetX = 0.0f;
+
+ _shouldHide = true;
+
+ _container = new View();
+ _itemRoot = new Actor();
+ _container.Add(_itemRoot);
+
+ _itemList = new List<View>();
+
+ if (_panGestureDetector == null)
+ {
+ _panGestureDetector = new PanGestureDetector();
+ _panGestureDetector.Attach(_container);
+
+ _panGestureDetector.Detected += OnPan;
+ }
+
+ _container.ParentOrigin = NDalic.ParentOriginTopLeft;
+ _container.AnchorPoint = NDalic.AnchorPointTopLeft;
+ _itemRoot.ParentOrigin = NDalic.ParentOriginTopLeft;
+ _itemRoot.AnchorPoint = NDalic.AnchorPointTopLeft;
+
+ _container.WidthResizePolicy = "FILL_TO_PARENT";
+ _container.HeightResizePolicy = "FILL_TO_PARENT";
+ _itemRoot.WidthResizePolicy = "FILL_TO_PARENT";
+ _itemRoot.HeightResizePolicy = "FILL_TO_PARENT";
+
+ _stage = Stage.GetCurrent();
+ _stageSize = _stage.GetSize();
+
+ _spotLightAnimation = new Animation(5.0f);
+ _focusTransitionAnimation = new Animation (0.35f);
+ _focusAnimation = new Animation (0.35f);
+ _focusAnimation.SetEndAction(Animation.EndAction.BakeFinal);
+ _scrollAnimation = new Animation (0.35f);
+ _scrollAnimation.SetEndAction(Animation.EndAction.BakeFinal);
+ }
+
+ public bool IsFocused
+ {
+ get
+ {
+ return _isFocused;
+ }
+ }
+
+ public Dali.View Container
+ {
+ get
+ {
+ return _container;
+ }
+ }
+
+ public int ItemCount
+ {
+ get
+ {
+ return _itemCount;
+ }
+ }
+
+ public Actor ItemRoot
+ {
+ get
+ {
+ return _itemRoot;
+ }
+ }
+
+ public Vector3 ItemSize
+ {
+ get
+ {
+ return _itemSize;
+ }
+
+ set
+ {
+ _itemSize = value;
+
+ Vector3 topLeft = new Vector3(-0.25f * _itemSize.width, -0.25f * _itemSize.height, 0.0f);
+ Vector3 topRight = new Vector3(0.25f * _itemSize.width, -0.25f * _itemSize.height, 0.0f);
+ Vector3 bottomRight = new Vector3(0.25f * _itemSize.width, 0.25f * _itemSize.height, 0.0f);
+ Vector3 bottomLeft = new Vector3(-0.25f * _itemSize.width, 0.25f * _itemSize.height, 0.0f);
+
+ _circularPath = new Path();
+ _circularPath.AddPoint(topLeft);
+ _circularPath.AddPoint(topRight);
+ _circularPath.AddPoint(bottomRight);
+ _circularPath.AddPoint(bottomLeft);
+ _circularPath.AddPoint(topLeft);
+ _circularPath.GenerateControlPoints(0.5f);
+ }
+ }
+
+ public float Padding
+ {
+ get
+ {
+ return _padding;
+ }
+
+ set
+ {
+ _padding = value;
+ }
+ }
+
+ public float MarginX
+ {
+ get
+ {
+ return _marginX;
+ }
+
+ set
+ {
+ _marginX = value;
+ }
+ }
+
+ public float OffsetY
+ {
+ get
+ {
+ return _offsetY;
+ }
+
+ set
+ {
+ _offsetY = value;
+ }
+ }
+
+ public float OffsetX
+ {
+ get
+ {
+ return _offsetX;
+ }
+
+ set
+ {
+ _offsetX = value;
+ }
+ }
+
+ public float MarginY
+ {
+ get
+ {
+ return _marginY;
+ }
+
+ set
+ {
+ _marginY = value;
+ }
+ }
+
+ public float Width
+ {
+ get
+ {
+ return _width;
+ }
+
+ set
+ {
+ _width = value;
+ }
+ }
+
+ public float Height
+ {
+ get
+ {
+ return _height;
+ }
+
+ set
+ {
+ _height = value;
+ }
+ }
+
+ public ImageView ShadowBorder
+ {
+ get
+ {
+ return _shadowBorder;
+ }
+
+ set
+ {
+ _shadowBorder = value;
+ }
+ }
+
+ public ImageView SpotLight
+ {
+ get
+ {
+ return _spotLight;
+ }
+
+ set
+ {
+ _spotLight = value;
+ }
+ }
+
+ public int FocusedItemID
+ {
+ get
+ {
+ if (_focusedItem < 0)
+ {
+ _focusedItem = 0;
+ }
+
+ return _focusedItem;
+ }
+ }
+
+ public Actor GetCurrentFocusedActor()
+ {
+ if (_focusedItem < 0)
+ {
+ _focusedItem = 0;
+ }
+
+ return _itemList[_focusedItem];
+ }
+
+ public void AddItem(View item)
+ {
+ item.AnchorPoint = NDalic.AnchorPointBottomCenter;
+ item.ParentOrigin = NDalic.ParentOriginBottomCenter;
+
+ item.Size = _itemSize;
+ item.SetKeyboardFocusable(true);
+ item.Position = GetItemPosition(_itemCount, _currentScrollPosition);
+
+ item.Name = _itemCount.ToString();
+
+// item.ClippingMode = "CLIP_CHILDREN";
+
+ _itemRoot.Add(item);
+ _itemList.Add(item);
+ _panGestureDetector.Attach(item);
+ _itemCount++;
+ }
+
+ // Perform Show animation on ScrollContainer (used only for Poster Container)
+ public void Show()
+ {
+ Container.Add(ItemRoot);
+
+ _shouldHide = false;
+ _showAnimation = new Animation (0.35f);
+
+ _showAnimation.AnimateTo(new Property(_container, Actor.Property.COLOR_ALPHA), new Property.Value(1.0f));
+
+ _container.PositionY = _container.Position.y + 200.0f;
+ float targetPositionY = _container.Position.y - 200.0f;
+ _showAnimation.AnimateTo(new Property(_container, Actor.Property.POSITION_Y), new Property.Value(targetPositionY),
+ new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR));
+
+ _showAnimation.Play();
+ }
+
+ // Perform Hide animation on ScrollContainer (used only for Poster Container)
+ public void Hide()
+ {
+ if (_hideAnimation)
+ {
+ _hideAnimation.Clear();
+ _hideAnimation.Reset();
+ }
+
+ float duration = 0.35f;
+ _hideAnimation = new Animation(duration);
+
+ _hideAnimation.AnimateTo(new Property(_container, Actor.Property.COLOR_ALPHA), new Property.Value(0.0f),
+ new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.0f, duration * 0.75f));
+
+ _hideAnimation.Finished += OnHideAnimationFinished;
+
+ _shouldHide = true;
+ _hideAnimation.Play();
+ }
+
+ public View Focus(int itemId)
+ {
+ if (itemId < 0)
+ {
+ itemId = 0;
+ }
+ else if (itemId >= _itemList.Count)
+ {
+ itemId = _itemList.Count - 1;
+ }
+
+ _itemList[itemId].Add(_shadowBorder);
+ _itemList[itemId].Add(_spotLight);
+
+ // Perform Spot Light animation
+ if(_focusedItem != itemId && _spotLight != null)
+ {
+ _spotLightAnimation.Clear();
+ _spotLightAnimation.Animate( _spotLight, _circularPath, new Vector3(0.0f, 0.0f, 0.0f) );
+ _spotLightAnimation.SetLooping(true);
+ _spotLightAnimation.Play();
+ }
+
+ _focusedItem = itemId;
+
+ Vector3 itemPosition = GetItemPosition(_focusedItem, _currentScrollPosition);
+
+ _focusAnimation.Clear();
+
+ float relativeItemPositionX = itemPosition.x - _itemSize.width * 0.5f + (_stageSize.width * 0.5f) + _offsetX;
+ if (relativeItemPositionX < _marginX + _offsetX + _padding)
+ {
+ float amount = _marginX + _offsetX + _padding - relativeItemPositionX;
+ Scroll(amount, itemId + 1); // Perform Scroll animation
+ }
+ else if (relativeItemPositionX + _itemSize.width + _padding + _marginX > _stageSize.width)
+ {
+ float amount = relativeItemPositionX + _marginX + _padding + _itemSize.width - _stageSize.width;
+ Scroll(-amount, itemId - 1); // Perform Scroll animation
+ }
+ else
+ {
+ for (int i = 0; i < _itemList.Count; ++i)
+ {
+ Vector3 targetPosition = GetItemPosition(i, _currentScrollPosition);
+ _focusAnimation.AnimateTo(new Property(_itemList[i], Actor.Property.POSITION),
+ new Property.Value(targetPosition),
+ new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE));
+ }
+ }
+
+ for (int i = 0; i < _itemList.Count; ++i)
+ {
+ SetupItemRenderer(_itemList[i], false);
+
+ // Perform Focus animation
+ if (i == _focusedItem)
+ {
+ _focusAnimation.AnimateTo(new Property(_itemList[i], Actor.Property.SCALE),
+ new Property.Value(new Vector3(1.2f, 1.2f, 1.2f)),
+ new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE));
+ }
+ else
+ {
+ _focusAnimation.AnimateTo(new Property(_itemList[i], Actor.Property.SCALE),
+ new Property.Value(new Vector3(1.0f, 1.0f, 1.0f)),
+ new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE));
+ }
+ }
+
+ _focusAnimation.Play();
+
+ if (_isFocused && _focusedItem >= 0)
+ {
+ SetupItemRenderer(_itemList[_focusedItem], true);
+ SetupSpotLightRenderer();
+ }
+
+ return _itemList[_focusedItem];
+ }
+
+ // Perform EddenEffect animation on Focused Item specified
+ public void FocusAnimation(FocusEffect focusEffect, FocusEffectDirection direction)
+ {
+ focusEffect.FocusAnimation(_itemList[_focusedItem], _itemSize, 1.0f, direction);
+ }
+
+ public void SetFocused(bool focused)
+ {
+ _isFocused = focused;
+
+ // Perform Focus animation if the ScrollContainer is not focused already
+ if (!_isFocused)
+ {
+ Actor parent = _shadowBorder.GetParent();
+ if (parent)
+ {
+ parent.Remove(_shadowBorder);
+ }
+
+ parent = _spotLight.GetParent();
+ if (parent)
+ {
+ parent.Remove(_spotLight);
+ }
+
+ _focusTransitionAnimation.Clear();
+
+ for (int i = 0; i < _itemList.Count; ++i)
+ {
+ SetupItemRenderer(_itemList[i], false);
+
+ Vector3 targetPosition = GetItemPosition(i, _currentScrollPosition);
+ _focusTransitionAnimation.AnimateTo(new Property(_itemList[i], Actor.Property.POSITION),
+ new Property.Value(targetPosition),
+ new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE));
+
+ _focusTransitionAnimation.AnimateTo(new Property(_itemList[i], Actor.Property.SCALE),
+ new Property.Value(new Vector3(1.0f, 1.0f, 1.0f)),
+ new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE));
+ }
+
+ _focusTransitionAnimation.Play();
+ }
+ else
+ {
+ Focus(_focusedItem);
+ }
+ }
+
+ // Obtain ID of first visible item/image on the screen of the ScrollContainer
+ public int GetFirstVisibleItemId()
+ {
+ int firstItemId = -1;
+
+ if (_isFocused)
+ {
+ firstItemId = (int)Math.Floor((-1.0 * _currentScrollPosition + _marginX * 2.0f) / (_itemSize.x + _padding));
+ }
+ else
+ {
+ firstItemId = (int)Math.Floor(-1.0 * _currentScrollPosition / (_itemSize.x + _padding));
+ }
+
+ if (firstItemId < 0)
+ {
+ firstItemId = 0;
+ }
+
+ return firstItemId;
+ }
+
+ // Obtain ID of last visible item/image on the screen of the ScrollContainer
+ public int GetLastVisibleItemId()
+ {
+ int lastItemId = -1;
+
+ if (_isFocused)
+ {
+ lastItemId = (int)Math.Ceiling(((_width - _currentScrollPosition - _marginX * 2.0f) / _itemSize.x) - 1);
+ }
+ else
+ {
+ lastItemId = (int)Math.Ceiling(((_width - _currentScrollPosition) / _itemSize.x) - 1);
+ }
+
+ if (lastItemId >= _itemList.Count)
+ {
+
+ lastItemId = _itemList.Count - 1;
+ }
+
+ return lastItemId;
+ }
+
+ // Obtain Next item/image (Right of the currently focused item) of the ScrollContainer
+ public Actor FocusNext()
+ {
+ int nextItem = -1;
+
+ if (_focusedItem < GetFirstVisibleItemId() || _focusedItem > GetLastVisibleItemId())
+ {
+ nextItem = GetFirstVisibleItemId();
+ }
+ else
+ {
+ nextItem = _focusedItem + 1;
+ }
+
+ return Focus(nextItem);
+ }
+
+ // Obtain Previous item/image (left of the currently focused item) of the ScrollContainer
+ public Actor FocusPrevious()
+ {
+ int previousItem = -1;
+
+ if (_focusedItem < GetFirstVisibleItemId() || _focusedItem > GetLastVisibleItemId())
+ {
+ previousItem = GetFirstVisibleItemId();
+ }
+ else
+ {
+ previousItem = _focusedItem - 1;
+ }
+
+ return Focus(previousItem);
+ }
+
+ private void OnHideAnimationFinished(object source, Animation.FinishedEventArgs e)
+ {
+ var currentParent = ItemRoot.GetParent();
+ if (_shouldHide && currentParent != null)
+ {
+ Container.Remove(ItemRoot);
+ }
+ }
+
+ private void OnPan(object source, PanGestureDetector.DetectedEventArgs e)
+ {
+ switch (e.PanGesture.state)
+ {
+ case Gesture.State.Started:
+ _scrollDisplacement = 0.0f;
+ break;
+
+ case Gesture.State.Continuing:
+ _scrollDisplacement = e.PanGesture.displacement.x;
+ break;
+
+ case Gesture.State.Finished:
+ case Gesture.State.Cancelled:
+ float absScrollDistance = _scrollDisplacement;
+ if (absScrollDistance < 0.0f)
+ absScrollDistance = 0.0f - absScrollDistance;
+
+ float scrollSpeed = e.PanGesture.velocity.x * e.PanGesture.velocity.x + e.PanGesture.velocity.y * e.PanGesture.velocity.y;
+ float maxScrollSpeed = 40.0f; // TBD
+ if (scrollSpeed > maxScrollSpeed)
+ scrollSpeed = maxScrollSpeed;
+
+ if (absScrollDistance > 1.0f && scrollSpeed > 0.05f) // Threshold TBD
+ {
+ if (_scrollDisplacement > 0.0f) // scroll constant distance in constant speed.
+ {
+ Scroll((_itemSize.x + _padding) * 2, GetFirstVisibleItemId());
+ }
+ else
+ {
+ Scroll(-(_itemSize.x + _padding) * 2, GetFirstVisibleItemId());
+ }
+ }
+ break;
+ }
+ }
+
+ // Perform ScrollAnimation on each item
+ private void Scroll(float amount, int baseItem)
+ {
+ float tagetScrollPosition = _currentScrollPosition + amount;
+ float totalItemSize = _itemList.Count * (_itemSize.width + _padding) + _padding + (_marginX * 2.0f);
+
+ float maxScrollPosition = _width - totalItemSize;
+
+ if (tagetScrollPosition < maxScrollPosition)
+ {
+ tagetScrollPosition = maxScrollPosition;
+ }
+ if (tagetScrollPosition > 0.0f)
+ {
+ tagetScrollPosition = 0.0f;
+ }
+
+ _scrollAnimation.Clear();
+
+ for (int i = 0; i < _itemList.Count; ++i)
+ {
+ Vector3 targetPosition = GetItemPosition(i, tagetScrollPosition);
+ _scrollAnimation.AnimateTo(new Property(_itemList[i], Actor.Property.POSITION),
+ new Property.Value(targetPosition),
+ new AlphaFunction(AlphaFunction.BuiltinFunction.EASE_OUT_SINE));
+ }
+
+ _currentScrollPosition = tagetScrollPosition;
+ _scrollAnimation.Play();
+ }
+
+ // Calculate Position of any item/image of ScrollContainer
+ private Vector3 GetItemPosition(int itemId, float scrollPosition)
+ {
+ if (_isFocused)
+ {
+ // used (_itemSize.width * 0.5f) because of AnchorPointCenter
+ // used (_stageSize.width * 0.5f) because of ParentOriginCenter
+ if (_focusedItem > itemId)
+ {
+ float positionX = (_itemSize.width * itemId) + (_padding * (itemId + 1)) + scrollPosition + (_itemSize.width * 0.5f) - (_stageSize.width * 0.5f);
+ return new Vector3(positionX, -_itemSize.height * _offsetY, 0.0f);
+ }
+ else if (_focusedItem == itemId)
+ {
+ float positionX = (_itemSize.width * itemId) + (_padding * (itemId + 1)) + scrollPosition + _marginX + (_itemSize.width * 0.5f) - (_stageSize.width * 0.5f);
+ return new Vector3(positionX, -_itemSize.height * _offsetY, 0.0f);
+ }
+ else
+ {
+ float positionX = (_itemSize.width * itemId) + (_padding * (itemId + 1)) + scrollPosition + _marginX * 2.0f + (_itemSize.width * 0.5f) - (_stageSize.width * 0.5f);
+ return new Vector3(positionX, -_itemSize.height * _offsetY, 0.0f);
+ }
+ }
+ else
+ {
+ float positionX = (_itemSize.width * itemId) + (_padding * (itemId + 1)) + scrollPosition + (_itemSize.width * 0.5f) - (_stageSize.width * 0.5f);
+ return new Vector3(positionX, -_itemSize.height * _offsetY, 0.0f);
+ }
+ }
+
+ // Used for SpotLight animation with clipping
+ private void SetupItemRenderer(Actor actor, bool stencilOn)
+ {
+ if (actor)
+ {
+ Renderer renderer = actor.GetRendererAt(0);
+
+ if (renderer)
+ {
+ // Setup the renderer properties:
+ // The stencil plane is only for stencilling, so disable writing to color buffer.
+
+ // Enable stencil. Draw to the stencil buffer (only).
+ if (stencilOn)
+ {
+ renderer.RenderMode = (int)RenderModeType.COLOR_STENCIL;
+ }
+ else
+ {
+ renderer.RenderMode = (int)RenderModeType.COLOR;
+ }
+ renderer.StencilFunction = (int)StencilFunctionType.ALWAYS;
+ renderer.StencilFunctionReference = 1;
+ renderer.StencilFunctionMask = 0xFF;
+ renderer.StencilOperationOnFail = (int)StencilOperationType.KEEP;
+ renderer.StencilOperationOnZFail = (int)StencilOperationType.KEEP;
+ renderer.StencilOperationOnZPass = (int)StencilOperationType.REPLACE;
+ renderer.StencilMask = 0xFF;
+
+ // We don't want to write to the depth buffer.
+ renderer.DepthWriteMode = (int)DepthWriteModeType.OFF;
+ // We don't beed to test the depth buffer.
+ renderer.DepthTestMode = (int)DepthTestModeType.OFF;
+
+ // This object must be rendered 1st.
+ renderer.DepthIndex = 10;
+ }
+ }
+ }
+
+ // Used for SpotLight animation with clipping
+ private void SetupSpotLightRenderer()
+ {
+ if (_spotLight)
+ {
+ Renderer renderer = _spotLight.GetRendererAt(0);
+
+ if (renderer)
+ {
+ // Setup the renderer properties:
+ // Write to color buffer so soptlight is visible
+
+ // We use blending to blend the spotlight with the poster image.
+ renderer.BlendMode = (int)BlendModeType.ON;
+ renderer.BlendEquationRgb = (int)BlendEquationType.ADD;
+ renderer.BlendEquationAlpha = (int)BlendEquationType.ADD;
+ renderer.BlendFactorDestRgb = (int)BlendFactorType.ONE;
+
+ // Enable stencil. Here we only draw to areas within the stencil.
+ renderer.RenderMode = (int)RenderModeType.COLOR_STENCIL;
+ renderer.StencilFunction = (int)StencilFunctionType.EQUAL;
+ renderer.StencilFunctionReference = 1;
+ renderer.StencilFunctionMask = 0xFF;
+ // Don't write to the stencil.
+ renderer.StencilMask = 0x00;
+
+ // We don't need to write to the depth buffer.
+ renderer.DepthWriteMode = (int)DepthWriteModeType.OFF;
+ // We don't need to test the depth buffer.
+ renderer.DepthTestMode = (int)DepthTestModeType.OFF;
+
+ // This object must be rendered last.
+ renderer.DepthIndex = 20;
+ }
+ }
+ }
+ }
+}
+
{
}
+ public Example(string stylesheet):base(stylesheet)
+ {
+ }
+
+ public Example(string stylesheet, Dali.Application.WINDOW_MODE windowMode):base(stylesheet, windowMode)
+ {
+ }
+
private void Initialize()
{
// Connect the signal callback for stage touched signal
static void Main(string[] args)
{
Console.WriteLine("Hello mono world.");
- Example example = new Example();
+ //Example example = new Example();
+ //Example example = new Example("stylesheet");
+ Example example = new Example("stylesheet", Dali.Application.WINDOW_MODE.TRANSPARENT);
example.Run(args);
}
}
_animation = new Animation(1.0f); // 1 second of duration
- _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 180.0f ) ), Vector3.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.0f, 0.5f));
- _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 0.0f ) ), Vector3.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.5f, 0.5f));
+ _animation.AnimateTo(_text, Animation.ORIENTATION, new Quaternion( new Radian( new Degree( 180.0f ) ), Vector3.XAXIS ), new AlphaFunction(Dali.Constants.AlphaFunction.BuiltinFunction.Linear), new TimePeriod(0.0f, 0.5f));
+
+ _animation.AnimateTo(_text, Animation.ORIENTATION, new Quaternion( new Radian( new Degree( 0.0f ) ), Vector3.XAXIS ), new AlphaFunction(Dali.Constants.AlphaFunction.BuiltinFunction.Linear), new TimePeriod(0.5f, 0.5f));
// Connect the signal callback for animaiton finished signal
_animation.Finished += AnimationFinished;
namespace MyCSharpExample
{
- class Example
- {
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
- delegate void CallbackDelegate(IntPtr data);
+ class Example
+ {
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ delegate void CallbackDelegate(IntPtr data);
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
- delegate void ActorCallbackDelegate(IntPtr data);
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ delegate void ActorCallbackDelegate(IntPtr data);
- private Dali.Application _application;
- private ScrollView _scrollView;
- private ScrollBar _scrollBar;
+ private Dali.Application _application;
+ private ScrollView _scrollView;
+ private ScrollBar _scrollBar;
+ private Animation _animation;
+ private TextLabel _text;
- public Example(Dali.Application application)
- {
- _application = application;
- _application.Initialized += Initialize;
- }
+ public Example(Dali.Application application)
+ {
+ _application = application;
+ _application.Initialized += Initialize;
+ }
- public void Initialize(object source, AUIApplicationInitEventArgs e)
- {
- CreateScrollView();
- }
+ public void Initialize(object source, AUIApplicationInitEventArgs e)
+ {
+ CreateScrollView();
+ }
- private void CreateScrollView()
+ private void CreateScrollView()
+ {
+ Stage stage = Stage.GetCurrent();
+ stage.BackgroundColor = NDalic.WHITE;
+
+ // Create a scroll view
+ _scrollView = new ScrollView();
+ Vector2 stageSize = stage.Size;
+ _scrollView.Size = new Vector3(stageSize.x, stageSize.y, 0.0f);
+ _scrollView.ParentOrigin = NDalic.ParentOriginCenter;
+ _scrollView.AnchorPoint = NDalic.AnchorPointCenter;
+ stage.Add(_scrollView);
+
+ // Add actors to a scroll view with 3 pages
+ int pageRows = 1;
+ int pageColumns = 3;
+ for(int pageRow = 0; pageRow < pageRows; pageRow++)
+ {
+ for(int pageColumn = 0; pageColumn < pageColumns; pageColumn++)
{
- Stage stage = Stage.GetCurrent();
- stage.BackgroundColor = NDalic.WHITE;
-
- // Create a scroll view
- _scrollView = new ScrollView();
- Vector2 stageSize = stage.Size;
- _scrollView.Size = new Vector3(stageSize.x, stageSize.y, 0.0f);
- _scrollView.ParentOrigin = NDalic.ParentOriginCenter;
- _scrollView.AnchorPoint = NDalic.AnchorPointCenter;
- stage.Add(_scrollView);
-
- // Add actors to a scroll view with 3 pages
- int pageRows = 1;
- int pageColumns = 3;
- for(int pageRow = 0; pageRow < pageRows; pageRow++)
+ View pageActor = new View();
+ pageActor.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.ALL_DIMENSIONS);
+ pageActor.ParentOrigin = NDalic.ParentOriginCenter;
+ pageActor.AnchorPoint = NDalic.AnchorPointCenter;
+ pageActor.Position = new Vector3(pageColumn * stageSize.x, pageRow * stageSize.y, 0.0f);
+
+ // Add images in a 3x4 grid layout for each page
+ int imageRows = 4;
+ int imageColumns = 3;
+ float margin = 10.0f;
+ Vector3 imageSize = new Vector3((stageSize.x / imageColumns) - margin, (stageSize.y / imageRows) - margin, 0.0f);
+
+ for(int row = 0; row < imageRows; row++)
+ {
+ for(int column = 0; column < imageColumns;column++)
{
- for(int pageColumn = 0; pageColumn < pageColumns; pageColumn++)
- {
- View pageActor = new View();
- pageActor.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.ALL_DIMENSIONS);
- pageActor.ParentOrigin = NDalic.ParentOriginCenter;
- pageActor.AnchorPoint = NDalic.AnchorPointCenter;
- pageActor.Position = new Vector3(pageColumn * stageSize.x, pageRow * stageSize.y, 0.0f);
-
- // Add images in a 3x4 grid layout for each page
- int imageRows = 4;
- int imageColumns = 3;
- float margin = 10.0f;
- Vector3 imageSize = new Vector3((stageSize.x / imageColumns) - margin, (stageSize.y / imageRows) - margin, 0.0f);
-
- for(int row = 0; row < imageRows; row++)
- {
- for(int column = 0; column < imageColumns;column++)
- {
- int imageId = (row * imageColumns + column) % 2 + 1;
- ImageView imageView = new ImageView("images/image-" + imageId + ".jpg");
- imageView.ParentOrigin = NDalic.ParentOriginCenter;
- imageView.AnchorPoint = NDalic.AnchorPointCenter;
- imageView.Size = imageSize;
- imageView.Position = new Vector3( margin * 0.5f + (imageSize.x + margin) * column - stageSize.x * 0.5f + imageSize.x * 0.5f,
- margin * 0.5f + (imageSize.y + margin) * row - stageSize.y * 0.5f + imageSize.y * 0.5f, 0.0f );
- pageActor.Add(imageView);
- }
- }
-
- _scrollView.Add(pageActor);
- }
+ int imageId = (row * imageColumns + column) % 2 + 1;
+ ImageView imageView = new ImageView("images/image-" + imageId + ".jpg");
+ imageView.ParentOrigin = NDalic.ParentOriginCenter;
+ imageView.AnchorPoint = NDalic.AnchorPointCenter;
+ imageView.Size = imageSize;
+ imageView.Position = new Vector3( margin * 0.5f + (imageSize.x + margin) * column - stageSize.x * 0.5f + imageSize.x * 0.5f,
+ margin * 0.5f + (imageSize.y + margin) * row - stageSize.y * 0.5f + imageSize.y * 0.5f, 0.0f );
+ pageActor.Add(imageView);
}
+ }
- _scrollView.SetAxisAutoLock(true);
-
- // Set scroll view to have 3 pages in X axis and allow page snapping,
- // and also disable scrolling in Y axis.
- RulerPtr scrollRulerX = new RulerPtr(new FixedRuler(stageSize.width));
- RulerPtr scrollRulerY = new RulerPtr(new DefaultRuler());
- scrollRulerX.SetDomain(new RulerDomain(0.0f, stageSize.width * pageColumns, true));
- scrollRulerY.Disable();
- _scrollView.SetRulerX(scrollRulerX);
- _scrollView.SetRulerY(scrollRulerY);
-
- // Create a horizontal scroll bar in the bottom of scroll view (which is optional)
- _scrollBar = new ScrollBar();
- _scrollBar.ParentOrigin = NDalic.ParentOriginBottomLeft;
- _scrollBar.AnchorPoint = NDalic.AnchorPointTopLeft;
- _scrollBar.SetResizePolicy(ResizePolicyType.FIT_TO_CHILDREN, DimensionType.WIDTH);
- _scrollBar.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.HEIGHT);
- _scrollBar.Orientation = new Quaternion( new Radian( new Degree( 270.0f ) ), Vector3.ZAXIS );
- _scrollBar.SetScrollDirection(ScrollBar.Direction.Horizontal);
- _scrollView.Add(_scrollBar);
-
- // Connect to the OnRelayout signal
- _scrollView.OnRelayoutEvent += OnScrollViewRelayout;
+ _scrollView.Add(pageActor);
}
+ }
+
+ _scrollView.SetAxisAutoLock(true);
+
+ // Set scroll view to have 3 pages in X axis and allow page snapping,
+ // and also disable scrolling in Y axis.
+ RulerPtr scrollRulerX = new RulerPtr(new FixedRuler(stageSize.width));
+ RulerPtr scrollRulerY = new RulerPtr(new DefaultRuler());
+ scrollRulerX.SetDomain(new RulerDomain(0.0f, stageSize.width * pageColumns, true));
+ scrollRulerY.Disable();
+ _scrollView.SetRulerX(scrollRulerX);
+ _scrollView.SetRulerY(scrollRulerY);
+
+ // Create a horizontal scroll bar in the bottom of scroll view (which is optional)
+ _scrollBar = new ScrollBar();
+ _scrollBar.ParentOrigin = NDalic.ParentOriginBottomLeft;
+ _scrollBar.AnchorPoint = NDalic.AnchorPointTopLeft;
+ _scrollBar.SetResizePolicy(ResizePolicyType.FIT_TO_CHILDREN, DimensionType.WIDTH);
+ _scrollBar.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.HEIGHT);
+ _scrollBar.Orientation = new Quaternion( new Radian( new Degree( 270.0f ) ), Vector3.ZAXIS );
+ _scrollBar.SetScrollDirection(ScrollBar.Direction.Horizontal);
+ _scrollView.Add(_scrollBar);
+
+ // Connect to the OnRelayout signal
+ _scrollView.OnRelayoutEvent += OnScrollViewRelayout;
+ _scrollView.Touched += OnTouch;
+ _scrollView.WheelMoved += Onwheel;
+ _scrollView.KeyInputFocusGained += OnKey;
+ _text = new TextLabel("View Touch Event Handler Test");
+ _text.ParentOrigin = NDalic.ParentOriginCenter;
+ _text.AnchorPoint = NDalic.AnchorPointCenter;
+ _text.HorizontalAlignment = "CENTER";
+ _text.PointSize = 48.0f;
+
+ _scrollView.Add(_text);
+ }
- private void OnScrollViewRelayout(object source, View.OnRelayoutEventArgs e)
- {
- // Set the correct scroll bar size after size negotiation of scroll view is done
- _scrollBar.Size = new Vector3(0.0f, _scrollView.GetRelayoutSize(DimensionType.WIDTH), 0.0f);
- }
+ // Callback for _animation finished signal handling
+ public void AnimationFinished(object source, Animation.FinishedEventArgs e)
+ {
+ Console.WriteLine("Customized Animation Finished Event handler");
+ Console.WriteLine("Animation finished: duration = " + e.Animation.Duration);
+ }
+ private void OnKey(object source, View.KeyInputFocusGainedEventArgs e)
+ {
+ Console.WriteLine("View Keyevent EVENT callback....");
+ }
- public void MainLoop()
- {
- _application.MainLoop ();
- }
+ private bool Onwheel(object source, View.WheelEventArgs e)
+ {
+ Console.WriteLine("View Wheel EVENT callback....");
+ return true;
+ }
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main(string[] args)
+ private bool OnTouch(object source, View.TouchEventArgs e)
+ {
+ Console.WriteLine("View TOUCH EVENT callback....");
+
+ // Only animate the _text label when touch down happens
+ if( e.TouchData.GetState(0) == PointStateType.DOWN )
+ {
+ Console.WriteLine("Customized Stage Touch event handler");
+ // Create a new _animation
+ if( _animation )
{
- Example example = new Example(Application.NewApplication());
- example.MainLoop ();
+ _animation.Reset();
}
+
+ _animation = new Animation(1.0f); // 1 second of duration
+
+ _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 180.0f ) ), Vector3.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.0f, 0.5f));
+ _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 0.0f ) ), Vector3.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.5f, 0.5f));
+
+ // Connect the signal callback for animaiton finished signal
+ _animation.Finished += AnimationFinished;
+
+ // Play the _animation
+ _animation.Play();
+ }
+ return true;
}
+
+ private void OnScrollViewRelayout(object source, View.OnRelayoutEventArgs e)
+ {
+ Console.WriteLine("View OnRelayoutEventArgs EVENT callback....");
+
+ // Set the correct scroll bar size after size negotiation of scroll view is done
+ _scrollBar.Size = new Vector3(0.0f, _scrollView.GetRelayoutSize(DimensionType.WIDTH), 0.0f);
+ }
+
+ public void MainLoop()
+ {
+ _application.MainLoop ();
+ }
+
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main(string[] args)
+ {
+ Example example = new Example(Application.NewApplication());
+ example.MainLoop ();
+ }
+ }
}
--- /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.
+ *
+ */
+using System;
+
+namespace Dali {
+ namespace Constants{
+ namespace AlphaFunction {
+ public enum BuiltinFunction {
+ Default = Dali.AlphaFunction.BuiltinFunction.DEFAULT,
+ Linear = Dali.AlphaFunction.BuiltinFunction.LINEAR,
+ Reverse = Dali.AlphaFunction.BuiltinFunction.REVERSE,
+ EaseInSquare = Dali.AlphaFunction.BuiltinFunction.EASE_IN_SQUARE,
+ EaseOutSquare = Dali.AlphaFunction.BuiltinFunction.EASE_OUT_SQUARE,
+ EaseIn = Dali.AlphaFunction.BuiltinFunction.EASE_IN,
+ EaseOut = Dali.AlphaFunction.BuiltinFunction.EASE_OUT,
+ EaseInOut = Dali.AlphaFunction.BuiltinFunction.EASE_IN_OUT,
+ EaseInSine = Dali.AlphaFunction.BuiltinFunction.EASE_IN_SINE,
+ EaseOutSine = Dali.AlphaFunction.BuiltinFunction.EASE_OUT_SINE,
+ EaseInOutSine = Dali.AlphaFunction.BuiltinFunction.EASE_IN_OUT_SINE,
+ Bounce = Dali.AlphaFunction.BuiltinFunction.BOUNCE,
+ Sin = Dali.AlphaFunction.BuiltinFunction.SIN,
+ EaseOutBack = Dali.AlphaFunction.BuiltinFunction.EASE_OUT_BACK,
+ Count = Dali.AlphaFunction.BuiltinFunction.COUNT
+ }
+
+
+ public enum Mode {
+ BuiltinFunction = Dali.AlphaFunction.Mode.BUILTIN_FUNCTION,
+ CustomFunction = Dali.AlphaFunction.Mode.CUSTOM_FUNCTION,
+ Bezier = Dali.AlphaFunction.Mode.BEZIER
+ }
+
+ } // namespace AlphaFunction
+
+ namespace FrameBuffer {
+ namespace Attachment {
+ public enum Mask {
+ None = Dali.FrameBuffer.Attachment.Mask.NONE, ///< No attachments are created initially @SINCE_1_1.45
+ Depth = Dali.FrameBuffer.Attachment.Mask.DEPTH, ///< Depth buffer bit-mask value @SINCE_1_1.45
+ Stencil = Dali.FrameBuffer.Attachment.Mask.STENCIL , ///< Stencil buffer bit-mask value @SINCE_1_1.45
+ // Preset bit-mask combinations:
+ DepthStencil = Dali.FrameBuffer.Attachment.Mask.DEPTH_STENCIL ///< The Framebuffer will be created with depth and stencil buffer @SINCE_1_1.45
+ }
+ } //namespace FrameBuffer
+ } // namespace Attachment
+
+
+ public enum TextureType {
+ Texture2D = Dali.TextureType.TEXTURE_2D, ///< One 2D image @SINCE_1_1.43
+ TextureCube = Dali.TextureType.TEXTURE_CUBE ///< Six 2D images arranged in a cube-shape @SINCE_1_1.43
+ }
+
+ /**
+ * @brief Stereoscopic view modes
+ * @SINCE_1_0.0
+ */
+ public enum ViewMode {
+ Mono = Dali.ViewMode.MONO, ///< Monoscopic (single camera). This is the default @SINCE_1_0.0
+ StereoHorizontal = Dali.ViewMode.STEREO_HORIZONTAL, ///< Stereoscopic. Frame buffer is split horizontally with the left and right camera views in their respective sides. @SINCE_1_0.0
+ StereoVertical = Dali.ViewMode.STEREO_VERTICAL, ///< Stereoscopic. Frame buffer is split vertically with the left camera view at the top and the right camera view at the bottom. @SINCE_1_0.0
+ StereoInterlaced = Dali.ViewMode.STEREO_INTERLACED ///< @DEPRECATED_1_1.19 @brief Stereoscopic. Left/Right camera views are rendered into the framebuffer on alternate frames. @SINCE_1_0.0
+ }
+
+ public enum MeshVisualShadingModeValue {
+ TexturelessWithDiffuseLighting = Dali.MeshVisualShadingModeValue.TEXTURELESS_WITH_DIFFUSE_LIGHTING, ///< *Simplest*. One color that is lit by ambient and diffuse lighting. @SINCE_1_1.45
+ TexturedWithSpecularLigting = Dali.MeshVisualShadingModeValue.TEXTURED_WITH_SPECULAR_LIGHTING, ///< Uses only the visual image textures provided with specular lighting in addition to ambient and diffuse lighting. @SINCE_1_1.45
+ TexturedWithDetailedSpecularLighting = Dali.MeshVisualShadingModeValue.TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING ///< Uses all textures provided including a gloss, normal and texture map along with specular, ambient and diffuse lighting. @SINCE_1_1.45
+ }
+
+ /**
+ * @brief Projection modes.
+ * @SINCE_1_0.0
+ */
+ public enum ProjectionMode {
+ PerspectiveProjection = Dali.ProjectionMode.PERSPECTIVE_PROJECTION, ///< Distance causes foreshortening; objects further from the camera appear smaller @SINCE_1_0.0
+ OrthographicProjection = Dali.ProjectionMode.ORTHOGRAPHIC_PROJECTION ///< Relative distance from the camera does not affect the size of objects @SINCE_1_0.0
+ }
+
+
+ } // namespace Constants
+} // namesapce Dali
/// This application is created before OnCreate() or created event. And the DaliApplication will be terminated when this application is closed.
/// </remarks>
protected Dali.Application application;
+
+ /// <summary>
+ /// The instance of the Dali Application extension.
+ /// </summary>
protected Dali.ApplicationExtensions applicationExt;
/// <summary>
+ /// Store the stylesheet value.
+ /// </summary>
+ protected string m_stylesheet;
+
+ /// <summary>
+ /// Store the window mode value.
+ /// </summary>
+ protected Dali.Application.WINDOW_MODE m_windowMode;
+
+ /// <summary>
+ /// Store the app mode value.
+ /// </summary>
+ protected APP_MODE appMode;
+
+ /// <summary>
/// The instance of the Dali Stage.
/// </summary>
public Stage stage { get; private set; }
+ /// <summary>
+ /// The default constructor.
+ /// </summary>
+ public DaliApplication():base()
+ {
+ appMode = APP_MODE.DEFAULT;
+ }
+
+ /// <summary>
+ /// The constructor with stylesheet.
+ /// </summary>
+ public DaliApplication(string stylesheet):base()
+ {
+ //handle the stylesheet
+ appMode = APP_MODE.STYLESHEETONLY;
+ m_stylesheet = stylesheet;
+ }
+
+ /// <summary>
+ /// The constructor with stylesheet and window mode.
+ /// </summary>
+ public DaliApplication(string stylesheet, Dali.Application.WINDOW_MODE windowMode)
+ : base()
+ {
+ //handle the stylesheet and windowMode
+ appMode = APP_MODE.STYLESHEETWITHWINDOWMODE;
+ m_stylesheet = stylesheet;
+ m_windowMode = windowMode;
+ }
/// <summary>
/// Overrides this method if want to handle behavior before calling OnCreate().
/// </summary>
protected override void OnPreCreate()
{
- application = Dali.Application.NewApplication();
- applicationExt = new Dali::ApplicationExtensions(application);
+ switch(appMode)
+ {
+ case APP_MODE.DEFAULT:
+ application = Dali.Application.NewApplication();
+ break;
+ case APP_MODE.STYLESHEETONLY:
+ application = Dali.Application.NewApplication(m_stylesheet);
+ break;
+ case APP_MODE.STYLESHEETWITHWINDOWMODE:
+ application = Dali.Application.NewApplication(m_stylesheet, m_windowMode);
+ break;
+ default:
+ break;
+ }
+
+ applicationExt = new Dali.ApplicationExtensions(application);
applicationExt.Init();
stage = Stage.GetCurrent();
base.OnLocaleChanged(e);
applicationExt.LanguageChange();
}
+
+ /// <summary>
+ /// The mode of creating Dali application.
+ /// </summary>
+ protected enum APP_MODE
+ {
+ DEFAULT = 0,
+ STYLESHEETONLY = 1,
+ STYLESHEETWITHWINDOWMODE = 2
+ }
}
}