/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
#include <cstring> // for strcmp
#include <dali/public-api/animation/animation.h>
#include <dali/public-api/animation/constraint.h>
-#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h>
-#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
using namespace Dali;
namespace //Unnamed namespace
{
-// broken image is loaded if there is no valid image provided for the page
-const char * const BROKEN_IMAGE_URL( DALI_IMAGE_DIR "broken.png");
-
-// names of shader property map
-const char * const CUSTOM_SHADER( "shader" );
-const char * const CUSTOM_VERTEX_SHADER( "vertexShader" );
-const char * const CUSTOM_FRAGMENT_SHADER( "fragmentShader" );
-
// properties set on shader, these properties have the constant value in regardless of the page status
const char * const PROPERTY_SPINE_SHADOW ( "uSpineShadowParameter" ); // uniform for both spine and turn effect
propertyTurnDirection = actor.RegisterProperty(PROPERTY_TURN_DIRECTION, -1.f);
}
-void PageTurnView::Page::SetImage( Image image )
+void PageTurnView::Page::SetTexture( Texture texture )
{
if( !textureSet )
{
textureSet = TextureSet::New();
}
-
- textureSet.SetImage( 0u, image );
+ textureSet.SetTexture( 0u, texture );
}
void PageTurnView::Page::UseEffect(Shader newShader)
}
PageTurnView::PageTurnView( PageFactory& pageFactory, const Vector2& pageSize )
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ),
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
mPageFactory( &pageFactory ),
mPageSize( pageSize ),
mSpineShadowParameter( DEFAULT_SPINE_SHADOW_PARAMETER ),
// create the grid geometry for pages
uint16_t width = static_cast<uint16_t>(mPageSize.width / DEFAULT_GRID_DENSITY + 0.5f);
uint16_t height = static_cast<uint16_t>(mPageSize.height / DEFAULT_GRID_DENSITY + 0.5f);
- mGeometry = RendererFactoryCache::CreateGridGeometry( Uint16Pair( width, height ) );
+ mGeometry = VisualFactoryCache::CreateGridGeometry( Uint16Pair( width, height ) );
mPages.reserve( NUMBER_OF_CACHED_PAGES );
for( int i = 0; i < NUMBER_OF_CACHED_PAGES; i++ )
Self().Add( mPages[i].actor );
}
- // create the layer for turning images
+ // create the layer for turning pages
mTurningPageLayer = Layer::New();
mTurningPageLayer.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
mTurningPageLayer.SetBehavior(Layer::LAYER_3D);
Shader PageTurnView::CreateShader( const Property::Map& shaderMap )
{
Shader shader;
- Property::Value* shaderValue = shaderMap.Find( CUSTOM_SHADER );
+ Property::Value* shaderValue = shaderMap.Find( Toolkit::Visual::Property::SHADER, CUSTOM_SHADER );
Property::Map shaderSource;
if( shaderValue && shaderValue->Get( shaderSource ) )
{
std::string vertexShader;
- Property::Value* vertexShaderValue = shaderSource.Find( CUSTOM_VERTEX_SHADER );
+ Property::Value* vertexShaderValue = shaderSource.Find( Toolkit::Visual::Shader::Property::VERTEX_SHADER, CUSTOM_VERTEX_SHADER );
if( !vertexShaderValue || !vertexShaderValue->Get( vertexShader ) )
{
DALI_LOG_ERROR("PageTurnView::CreateShader failed: vertex shader source is not available.\n");
}
std::string fragmentShader;
- Property::Value* fragmentShaderValue = shaderSource.Find( CUSTOM_FRAGMENT_SHADER );
+ Property::Value* fragmentShaderValue = shaderSource.Find( Toolkit::Visual::Shader::Property::FRAGMENT_SHADER, CUSTOM_FRAGMENT_SHADER );
if( !fragmentShaderValue || !fragmentShaderValue->Get( fragmentShader ) )
{
DALI_LOG_ERROR("PageTurnView::CreateShader failed: fragment shader source is not available.\n");
void PageTurnView::OnStageConnection( int depth )
{
- Control::OnStageConnection( depth );
-
SetupShadowView();
+
+ Control::OnStageConnection( depth );
}
void PageTurnView::OnStageDisconnection()
{
int index = pageIndex % NUMBER_OF_CACHED_PAGES;
- Image newPageImage;
- newPageImage = mPageFactory->NewPage( pageIndex );
-
- if( !newPageImage ) // load the broken image
- {
- newPageImage = ResourceImage::New( BROKEN_IMAGE_URL );
- }
+ Texture newPage;
+ newPage = mPageFactory->NewPage( pageIndex );
+ DALI_ASSERT_ALWAYS( newPage && "must pass in valid texture" );
bool isLeftSide = ( pageIndex < mCurrentPageIndex );
if( mPages[index].isTurnBack != isLeftSide )
mPages[index].actor.SetOrientation( Degree( degree ), Vector3::YAXIS );
mPages[index].actor.SetVisible( false );
mPages[index].UseEffect( mSpineEffectShader, mGeometry );
- mPages[index].SetImage( newPageImage );
+ mPages[index].SetTexture( newPage );
// For Portrait, nothing to do
// For Landscape, set the parent origin to CENTER
- OnAddPage( mPages[index].actor, isLeftSide );
+ OnAddPage( mPages[index].actor, isLeftSide );
}
}