imageVisual.GetNaturalSize(naturalSize);
DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 200.f), TEST_LOCATION );
- // n patch visual
- TestPlatformAbstraction& platform = application.GetPlatform();
- Vector2 testSize(80.f, 160.f);
- platform.SetClosestImageSize(testSize);
- image = ResourceImage::New(TEST_NPATCH_FILE_NAME);
- Visual::Base nPatchVisual = factory.CreateVisual( image );
- nPatchVisual.SetSize( visualSize );
- DALI_TEST_EQUALS( nPatchVisual.GetSize(), visualSize, TEST_LOCATION );
- nPatchVisual.GetNaturalSize(naturalSize);
- DALI_TEST_EQUALS( naturalSize, testSize, TEST_LOCATION );
+ // n patch visual is tested in the utc-Dali-VisualFactory.cpp
// border visual
float borderSize = 5.f;
DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION ); // Natural size should still be 100, 100
// Batch Image visual
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ Vector2 testSize(80.f, 160.f);
+ platform.SetClosestImageSize(testSize);
propertyMap.Clear();
propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<bool>() == true );
- // Test the properties..
- Property::Value imageValue = imageVisual.GetProperty( ImageVisual::Property::URL );
- DALI_TEST_CHECK( imageValue.Get<std::string>() == TEST_IMAGE_FILE_NAME );
-
- // Other Properties for Image Visual can be tested here once implemented in the Visual
-
- tet_infoline( "UtcDaliVisualGetPropertyMap5 Ensuring Property without a Getter is not problematic" );
- imageValue = imageVisual.GetProperty( ImageVisual::Property::DESIRED_HEIGHT );
- DALI_TEST_CHECK( imageValue.Get<int>() != 30 );
-
-
- // Rest of test uses Image not an url ( legacy )
-
// Get an image visual with an image handle, and test the default property values
Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
imageVisual = factory.CreateVisual(image);
ToolkitTestApplication application;
tet_infoline( "UtcDaliVisualGetPropertyMap6: NPatchVisual" );
- bool BORDER_ONLY_SETTING = true;
-
VisualFactory factory = VisualFactory::Get();
Property::Map propertyMap;
propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
- propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, BORDER_ONLY_SETTING );
+ propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
Visual::Base nPatchVisual = factory.CreateVisual( propertyMap );
Property::Map resultMap;
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<bool>() );
- // Test the properties via Index.
- nPatchVisual.SetProperty( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME ); // May not able to change URL in future using SetProperty
- Property::Value nPatchValue = nPatchVisual.GetProperty( ImageVisual::Property::URL );
- DALI_TEST_CHECK( nPatchValue.Get<std::string>() == TEST_NPATCH_FILE_NAME );
-
- nPatchValue = nPatchVisual.GetProperty( ImageVisual::Property::BORDER_ONLY );
- DALI_TEST_CHECK( nPatchValue.Get<bool>() == BORDER_ONLY_SETTING );
-
- // Other Properties for N-Patch Visual can be tested here once implemented in the Visual
-
- tet_infoline( "UtcDaliVisualGetPropertyMap6 Ensuring Property without a Getter is not problematic" );
- nPatchValue = nPatchVisual.GetProperty( ImageVisual::Property::DESIRED_HEIGHT );
- DALI_TEST_CHECK( nPatchValue.Get<int>() != 30 );
END_TEST;
}
DALI_TEST_CHECK( !value->Get<bool>() );
value = resultMap.Find( TextVisual::Property::ENABLE_AUTO_SCROLL, Property::BOOLEAN );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( !value->Get<bool>() );
+ DALI_TEST_CHECK( !value );
value = resultMap.Find( TextVisual::Property::LINE_SPACING, Property::FLOAT );
DALI_TEST_CHECK( value );
END_TEST;
}
+int UtcDaliNPatchVisualCustomShader(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "NPatchVisual with custom shader" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map properties;
+ Property::Map shader;
+ const std::string fragmentShader = "Foobar";
+ shader[Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
+ properties[Dali::Toolkit::Visual::Property::TYPE] = Dali::Toolkit::Visual::IMAGE;
+ properties[Dali::Toolkit::Visual::Property::SHADER]=shader;
+ properties[Dali::Toolkit::ImageVisual::Property::URL] = TEST_NPATCH_FILE_NAME;
+
+ Visual::Base visual = factory.CreateVisual( properties );
+ Actor dummy = Actor::New();
+ // trigger creation through setting on stage
+ visual.SetOnStage( dummy );
+
+ Renderer renderer = dummy.GetRendererAt( 0 );
+ Shader shader2 = renderer.GetShader();
+ Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
+ Property::Map* map = value.GetMap();
+ DALI_TEST_CHECK( map );
+
+ Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
+ // *map["vertex"]; is default here so not verifying it
+
+ DALI_TEST_EQUALS( fragmentShader, fragment->Get<std::string>(), TEST_LOCATION );
+
+ END_TEST;
+}
+
$(toolkit_src_dir)/visuals/visual-base-impl.cpp \
$(toolkit_src_dir)/visuals/visual-base-data-impl.cpp \
$(toolkit_src_dir)/visuals/image-atlas-manager.cpp \
+ $(toolkit_src_dir)/visuals/npatch-loader.cpp \
$(toolkit_src_dir)/visuals/visual-factory-cache.cpp \
$(toolkit_src_dir)/visuals/visual-factory-impl.cpp \
$(toolkit_src_dir)/visuals/visual-string-constants.cpp \
$(toolkit_src_dir)/text/text-font-style.cpp \
$(toolkit_src_dir)/text/text-io.cpp \
$(toolkit_src_dir)/text/text-scroller.cpp \
- $(toolkit_src_dir)/text/text-scroller-data.cpp \
$(toolkit_src_dir)/text/text-scroller-interface.cpp \
$(toolkit_src_dir)/text/text-view.cpp \
$(toolkit_src_dir)/text/text-view-interface.cpp \
return new TextVisual( factoryCache );
}
- void TextVisual::SetTextControlInterface( Text::ControlInterface* controlInterface )
- {
- if( mController )
- {
- mController->SetTextControlInterface( controlInterface );
- }
- }
-
void TextVisual::SetSize( const Vector2& size )
{
const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size );
return mController->GetHeightForWidth( width );
}
-void TextVisual::GetNaturalSize( Vector2& naturalSize ) const
+void TextVisual::GetNaturalSize( Vector2& naturalSize )
{
naturalSize = mController->GetNaturalSize().GetVectorXY();
}
map.Insert( Toolkit::TextVisual::Property::ENABLE_MARKUP, mController->IsMarkupProcessorEnabled() );
- map.Insert( Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL, mController->IsAutoScrollEnabled() );
-
- map.Insert( Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED, mController->GetAutoScrollSpeed() );
-
- map.Insert( Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT, mController->GetAutoScrollLoopCount() );
-
- map.Insert( Toolkit::TextVisual::Property::AUTO_SCROLL_GAP, mController->GetAutoScrollWrapGap() );
-
map.Insert( Toolkit::TextVisual::Property::LINE_SPACING, mController->GetDefaultLineSpacing() );
GetUnderlineProperties( mController, value, Text::EffectStyle::DEFAULT );
}
case Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL:
{
- const bool enableAutoScroll = propertyValue.Get<bool>();
-
- // If request to auto scroll is the same as current state then do nothing.
- if( enableAutoScroll != mController->IsAutoScrollEnabled() )
- {
- // If request is disable (false) and auto scrolling is enabled then need to stop it
- if( !enableAutoScroll )
- {
- StopTextAutoScrolling(); // Causes the current animation to finish playing.
- }
- // If request is enable (true) then start autoscroll as not already running
- else
- {
- mController->GetLayoutEngine().SetTextEllipsisEnabled( false );
- mController->SetAutoScrollEnabled( enableAutoScroll );
- mController->RequestRelayout();
- }
- }
+ // nothing to do.
break;
}
case Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED:
{
- mController->SetAutoscrollSpeed( propertyValue.Get<int>() );
+ // nothing to do.
break;
}
case Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT:
{
- const int loopCount = propertyValue.Get<int>();
- if( loopCount > 0 )
- {
- mController->SetAutoScrollLoopCount( loopCount );
- }
- else
- {
- StopTextAutoScrolling(); // Causes the current animation to finish playing.
- }
+ // nothing to do.
break;
}
case Toolkit::TextVisual::Property::AUTO_SCROLL_GAP:
{
- mController->SetAutoScrollWrapGap( propertyValue.Get<float>() );
+ // nothing to do.
break;
}
case Toolkit::TextVisual::Property::LINE_SPACING:
}
case Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL:
{
- value = mController->IsAutoScrollEnabled();
+ // nothing to do.
break;
}
case Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED:
{
- value = mController->GetAutoScrollSpeed();
+ // nothing to do.
break;
}
case Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT:
{
- value = mController->GetAutoScrollLoopCount();
+ // nothing to do.
break;
}
case Toolkit::TextVisual::Property::AUTO_SCROLL_GAP:
{
- value = mController->GetAutoScrollWrapGap();
+ // nothing to do.
break;
}
case Toolkit::TextVisual::Property::LINE_SPACING:
self.Add( renderableActor );
}
mRenderableActor = renderableActor;
-
- if( mController->IsAutoScrollEnabled() )
- {
- SetUpAutoScrolling();
- }
- }
- }
-
- void TextVisual::StopTextAutoScrolling()
- {
- if( mTextScroller )
- {
- mTextScroller->StopScrolling();
- }
- }
-
- 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 )
- {
- if( !mTextScroller )
- {
- // If speed, loopCount or gap not set via property system then will need to create a TextScroller with defaults
- mTextScroller = Text::TextScroller::New( *mController );
- }
-
- mTextScroller->StartScrolling( mRenderableActor,
- *data );
-
- self.Add( mTextScroller->GetScrollingText() );
- self.Add( mTextScroller->GetSourceCamera() );
}
}
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/text/rendering/text-renderer.h>
#include <dali-toolkit/internal/text/text-controller.h>
- #include <dali-toolkit/internal/text/text-scroller.h>
namespace Dali
{
*/
static TextVisualPtr New( VisualFactoryCache& factoryCache );
- /**
- * @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 );
-
public: // from Visual::Base
/**
/**
* @copydoc Visual::Base::GetNaturalSize()
*/
- virtual void GetNaturalSize( Vector2& naturalSize ) const;
+ virtual void GetNaturalSize( Vector2& naturalSize );
/**
* @copydoc Visual::Base::CreatePropertyMap()
*/
void RenderText();
- /**
- * @brief Stops the text auto scroll.
- */
- void StopTextAutoScrolling();
-
- /**
- * @brief Set up Autoscrolling.
- */
- void SetUpAutoScrolling();
-
private:
Text::ControllerPtr mController; ///< The text's controller.
WeakHandle<Actor> mSelf;
Text::RendererPtr mRenderer;
- Text::TextScrollerPtr mTextScroller;
Actor mRenderableActor;
int mRenderingBackend;