mVertexAttribArrayChanged = false;
mCheckFramebufferStatusResult = 0;
- mNumBinaryFormats = 1;
- mBinaryFormats = 1;
+ mFramebufferStatus = 0;
+ mFramebufferColorAttached = 0;
+ mFramebufferDepthAttached = 0;
+ mFramebufferStencilAttached = 0;
+
+ mNumBinaryFormats = 0;
+ mBinaryFormats = 0;
mProgramBinaryLength = 0;
+ mGetProgramBinaryCalled = false;
mLastAutoTextureIdUsed = 0;
mLastProgramIdUsed = 0;
mLastUniformIdUsed = 0;
mLastShaderCompiled = 0;
+ mLastClearBitMask = 0;
+ mClearCount = 0;
mLastBlendEquationRgb = 0;
mLastBlendEquationAlpha = 0;
*/
// EXTERNAL INCLUDES
-#include <cstdio> // fprintf
#include <sstream>
#include <string>
-#include <cstring> // for strcpy, strncpy
#include <map>
+#include <cstdio>
+#include <cstring> // for strcmp
// INTERNAL INCLUDES
#include <dali/public-api/dali-core.h>
inline void BindFramebuffer( GLenum target, GLuint framebuffer )
{
+ //Add 010 bit;
+ mFramebufferStatus |= 2;
}
inline void BindRenderbuffer( GLenum target, GLuint renderbuffer )
inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
{
+ mBufferDataCalls.push_back(size);
}
inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
{
+ mBufferSubDataCalls.push_back(size);
}
inline GLenum CheckFramebufferStatus(GLenum target)
{
+ //If it has the three last bits set to 1 - 111, then the three minimum functions to create a
+ //Framebuffer texture have been called
+ if( mFramebufferStatus == 7 )
+ {
+ return GL_FRAMEBUFFER_COMPLETE;
+ }
+
return mCheckFramebufferStatusResult;
}
+ inline GLenum CheckFramebufferColorAttachment()
+ {
+ return mFramebufferColorAttached;
+ }
+
+ inline GLenum CheckFramebufferDepthAttachment()
+ {
+ return mFramebufferDepthAttached;
+ }
+
+ inline GLenum CheckFramebufferStencilAttachment()
+ {
+ return mFramebufferStencilAttached;
+ }
+
inline void Clear(GLbitfield mask)
{
+ mClearCount++;
+ mLastClearBitMask = mask;
}
inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
{
+ if (attachment == GL_DEPTH_ATTACHMENT)
+ {
+ mFramebufferDepthAttached = true;
+ }
+ else if (attachment == GL_STENCIL_ATTACHMENT)
+ {
+ mFramebufferStencilAttached = true;
+ }
}
inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
{
+ //Add 100 bit;
+ mFramebufferStatus |= 4;
+
+ //We check 4 attachment colors
+ if ((attachment == GL_COLOR_ATTACHMENT0) || (attachment == GL_COLOR_ATTACHMENT1) || (attachment == GL_COLOR_ATTACHMENT2) || (attachment == GL_COLOR_ATTACHMENT4))
+ {
+ mFramebufferColorAttached = true;
+ }
}
inline void FrontFace(GLenum mode)
inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
{
+ for( int i = 0; i < n; i++ )
+ {
+ framebuffers[i] = i + 1;
+ }
+
+ //Add 001 bit, this function needs to be called the first one in the chain
+ mFramebufferStatus = 1;
}
inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
{
+ for( int i = 0; i < n; i++ )
+ {
+ renderbuffers[i] = i + 1;
+ }
}
/**
out << ", ";
}
}
- mTextureTrace.PushCall("GenTexture", out.str());
+ mTextureTrace.PushCall("GenTextures", out.str());
}
inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
{
+ mGetProgramBinaryCalled = true;
}
inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
}
}
- fprintf(stderr, "Not found, printing possible values:" );
+ fprintf(stderr, "Not found, printing possible values:\n" );
for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
program_it != mUniforms.end();
++program_it )
{
std::stringstream out;
out << uniform_it->first << ": " << origValue;
- fprintf(stderr, "%s", out.str().c_str() );
+ fprintf(stderr, "%s\n", out.str().c_str() );
}
}
}
return mLastProgramIdUsed;
}
+ inline GLbitfield GetLastClearMask() const
+ {
+ return mLastClearBitMask;
+ }
+
enum AttribType
{
ATTRIB_UNKNOWN = -1,
// Methods to check scissor tests
inline const ScissorParams& GetScissorParams() const { return mScissorParams; }
+ inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; }
+
+ inline unsigned int GetClearCountCalled() const { return mClearCount; }
+
+ typedef std::vector<size_t> BufferDataCalls;
+ inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; }
+ inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); }
+
+ typedef std::vector<size_t> BufferSubDataCalls;
+ inline const BufferSubDataCalls& GetBufferSubDataCalls() const { return mBufferSubDataCalls; }
+ inline void ResetBufferSubDataCalls() { mBufferSubDataCalls.clear(); }
+
private:
GLuint mCurrentProgram;
GLuint mCompileStatus;
+ BufferDataCalls mBufferDataCalls;
+ BufferSubDataCalls mBufferSubDataCalls;
GLuint mLinkStatus;
GLint mGetAttribLocationResult;
GLenum mGetErrorResult;
GLboolean mIsTextureResult;
GLenum mActiveTextureUnit;
GLenum mCheckFramebufferStatusResult;
+ GLint mFramebufferStatus;
+ GLenum mFramebufferColorAttached;
+ GLenum mFramebufferDepthAttached;
+ GLenum mFramebufferStencilAttached;
GLint mNumBinaryFormats;
GLint mBinaryFormats;
GLint mProgramBinaryLength;
bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
+ bool mGetProgramBinaryCalled;
typedef std::map< GLuint, std::string> ShaderSourceMap;
ShaderSourceMap mShaderSources;
GLuint mLastShaderCompiled;
+ GLbitfield mLastClearBitMask;
+ unsigned int mClearCount;
Vector4 mLastBlendColor;
GLenum mLastBlendEquationRgb;
ImageDimensions TestPlatformAbstraction::GetClosestImageSize( const std::string& filename,
ImageDimensions size,
- FittingMode::Type scalingMode,
+ FittingMode::Type fittingMode,
SamplingMode::Type samplingMode,
bool orientationCorrection )
{
ImageDimensions TestPlatformAbstraction::GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
ImageDimensions size,
- FittingMode::Type scalingMode,
+ FittingMode::Type fittingMode,
SamplingMode::Type samplingMode,
bool orientationCorrection )
{
void TestPlatformAbstraction::LoadResource(const Integration::ResourceRequest& request)
{
std::ostringstream out;
- out << "Type:" << request.GetType()->id << ", Path: " << request.GetPath() << std::endl;
+ out << "Type:" << request.GetType()->id << ", Path: " << request.GetPath() << std::endl ;
mTrace.PushCall("LoadResource", out.str());
if(mRequest != NULL)
}
/**
- * @copydoc PlatformAbstraction::SaveResource()
- */
-void TestPlatformAbstraction::SaveResource(const Integration::ResourceRequest& request)
-{
- mTrace.PushCall("SaveResource", "");
- if(mRequest != NULL)
- {
- delete mRequest;
- tet_infoline ("Warning: multiple resource requests not handled by Test Suite. You may see unexpected errors");
- }
- mRequest = new Integration::ResourceRequest(request);
-}
-
-/**
* @copydoc PlatformAbstraction::CancelLoad()
*/
void TestPlatformAbstraction::CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId)
{
cache.LoadFailed( mResources.loadFailedId, mResources.loadFailure );
}
- if(mResources.saved)
- {
- cache.SaveComplete( mResources.savedId, mResources.savedType );
- }
- if(mResources.saveFailed)
- {
- cache.SaveFailed( mResources.saveFailedId, mResources.saveFailure );
- }
}
/**
/**
* @copydoc PlatformAbstraction::LoadFile()
*/
-bool TestPlatformAbstraction::LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const
+bool TestPlatformAbstraction::LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const
{
mTrace.PushCall("LoadFile", "");
if( mLoadFileResult.loadResult )
}
/**
- * @copydoc PlatformAbstraction::LoadShaderBinFile()
+ * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
*/
-bool TestPlatformAbstraction::LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer ) const
+bool TestPlatformAbstraction::LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const
{
- mTrace.PushCall("LoadShaderBinFile", "");
+ mTrace.PushCall("LoadShaderBinaryFile", "");
if( mLoadFileResult.loadResult )
{
buffer = mLoadFileResult.buffer;
/**
* @copydoc PlatformAbstraction::SaveFile()
*/
-bool TestPlatformAbstraction::SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const
+bool TestPlatformAbstraction::SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes) const
{
mTrace.PushCall("SaveFile", "");
return false;
mTrace.PushCall("JoinLoaderThreads", "");
}
-Integration::DynamicsFactory* TestPlatformAbstraction::GetDynamicsFactory()
-{
- mTrace.PushCall("GetDynamicsFactory", "");
- return NULL;
-}
-
/** Call this every test */
void TestPlatformAbstraction::Initialize()
{
case SuspendFunc: return mTrace.FindMethod("Suspend");
case ResumeFunc: return mTrace.FindMethod("Resume");
case LoadResourceFunc: return mTrace.FindMethod("LoadResource");
- case SaveResourceFunc: return mTrace.FindMethod("SaveResource");
case LoadFileFunc: return mTrace.FindMethod("LoadFile");
- case LoadShaderBinFileFunc: return mTrace.FindMethod("LoadShaderBinFile");
+ case LoadShaderBinaryFileFunc: return mTrace.FindMethod("LoadShaderBinaryFile");
+ case SaveShaderBinaryFileFunc: return mTrace.FindMethod("SaveShaderBinaryFile");
case SaveFileFunc: return mTrace.FindMethod("SaveFile");
case CancelLoadFunc: return mTrace.FindMethod("CancelLoad");
case GetResourcesFunc: return mTrace.FindMethod("GetResources");
case IsLoadingFunc: return mTrace.FindMethod("IsLoading");
case SetDpiFunc: return mTrace.FindMethod("SetDpi");
case JoinLoaderThreadsFunc: return mTrace.FindMethod("JoinLoaderThreads");
- case GetDynamicsFactoryFunc: return mTrace.FindMethod("GetDynamicsFactory");
}
return false;
}
mResources.loadFailure = failure;
}
-void TestPlatformAbstraction::SetResourceSaved(Integration::ResourceId savedId,
- Integration::ResourceTypeId savedType)
-{
- mResources.saved = true;
- mResources.savedId = savedId;
- mResources.savedType = savedType;
-}
-
-void TestPlatformAbstraction::SetResourceSaveFailed(Integration::ResourceId id,
- Integration::ResourceFailure failure)
-{
- mResources.saveFailed = true;
- mResources.saveFailedId = id;
- mResources.saveFailure = failure;
-}
-
Integration::ResourceRequest* TestPlatformAbstraction::GetRequest()
{
return mRequest;
mClosestSize = size;
}
-void TestPlatformAbstraction::SetLoadFileResult( bool result, std::vector< unsigned char >& buffer )
+void TestPlatformAbstraction::SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer )
{
mLoadFileResult.loadResult = result;
if( result )
bool loadFailed;
Integration::ResourceId loadFailedId;
Integration::ResourceFailure loadFailure;
-
- bool saved;
- Integration::ResourceId savedId;
- Integration::ResourceTypeId savedType;
-
- bool saveFailed;
- Integration::ResourceId saveFailedId;
- Integration::ResourceFailure saveFailure;
};
struct LoadFileResult
}
bool loadResult;
- std::vector< unsigned char> buffer;
+ Dali::Vector< unsigned char> buffer;
};
/**
*/
virtual ImageDimensions GetClosestImageSize( const std::string& filename,
ImageDimensions size,
- FittingMode::Type scalingMode,
+ FittingMode::Type fittingMode,
SamplingMode::Type samplingMode,
bool orientationCorrection );
*/
virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
ImageDimensions size,
- FittingMode::Type scalingMode,
+ FittingMode::Type fittingMode,
SamplingMode::Type samplingMode,
bool orientationCorrection );
virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
/**
- * @copydoc PlatformAbstraction::SaveResource()
- */
- virtual void SaveResource(const Integration::ResourceRequest& request);
-
- /**
* @copydoc PlatformAbstraction::CancelLoad()
*/
virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
* @copydoc PlatformAbstraction::SetDpi()
*/
virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
+
/**
* @copydoc PlatformAbstraction::LoadFile()
*/
- virtual bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const;
+ virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
/**
- * @copydoc PlatformAbstraction::LoadShaderBinFile()
+ * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
*/
- virtual bool LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer ) const;
+ virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer
+) const;
+
+ virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; }
/**
* @copydoc PlatformAbstraction::SaveFile()
*/
- virtual bool SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const;
+ virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes) const;
virtual void JoinLoaderThreads();
- virtual Integration::DynamicsFactory* GetDynamicsFactory();
-
public: // TEST FUNCTIONS
// Enumeration of Platform Abstraction methods
SuspendFunc,
ResumeFunc,
LoadResourceFunc,
- SaveResourceFunc,
SaveFileFunc,
LoadFileFunc,
- LoadShaderBinFileFunc,
+ LoadShaderBinaryFileFunc,
+ SaveShaderBinaryFileFunc,
CancelLoadFunc,
GetResourcesFunc,
IsLoadingFunc,
SetDpiFunc,
- JoinLoaderThreadsFunc,
- GetDynamicsFactoryFunc,
+ JoinLoaderThreadsFunc
} TestFuncEnum;
/** Call this every test */
void SetResourceLoadFailed(Integration::ResourceId id,
Integration::ResourceFailure failure);
- void SetResourceSaved(Integration::ResourceId savedId,
- Integration::ResourceTypeId savedType);
-
- void SetResourceSaveFailed(Integration::ResourceId id,
- Integration::ResourceFailure failure);
-
Integration::ResourceRequest* GetRequest();
void DiscardRequest();
void SetClosestImageSize(const Vector2& size);
- void SetLoadFileResult( bool result, std::vector< unsigned char >& buffer );
+ void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer );
void SetSaveFileResult( bool result );
// Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
// HorizontalLeft, VerticalCenter
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
// HorizontalRight, VerticalCenter
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
// HorizontalLeft, VerticalTop
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
// HorizontalCenter, VerticalTop
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
// HorizontalRight, VerticalTop
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
// HorizontalLeft, VerticalBottom
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
// HorizontalCenter, VerticalBottom
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
// HorizontalRight, VerticalBottom
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
{
Alignment alignment = Alignment::New();
DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
{
Alignment alignment = Alignment::New(Alignment::HorizontalLeft);
DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
{
Alignment alignment = Alignment::New(Alignment::HorizontalRight);
DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
{
Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalTop);
DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
{
Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalTop);
DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
{
Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalTop);
DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
{
Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalBottom);
DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
{
Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalBottom);
DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
{
Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalBottom);
DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
// ScaleToFill
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
// ScaleToFitKeepAspect
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
// ScaleToFillKeepAspect
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
// ShrinkToFit
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
// ShrinkToFitKeepAspect
{
Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
+ alignment.Add(Actor::New());
Stage::GetCurrent().Add(alignment);
application.Render();
application.SendNotification();
application.Render();
application.SendNotification();
- Actor actor = RenderableActor::New();
+ Actor actor = Actor::New();
alignment.Add(actor);
DALI_TEST_EQUALS(alignment.GetChildCount(), 1u, TEST_LOCATION);
return false;
}
+Image CreateSolidColorImage( const Vector4& color, unsigned int width, unsigned int height )
+{
+ BufferImage imageData = BufferImage::New( width, height, Pixel::RGBA8888 );
+
+ // Create the image
+ PixelBuffer* pixbuf = imageData.GetBuffer();
+ unsigned int size = width * height;
+
+ for( size_t i = 0; i < size; i++ )
+ {
+ pixbuf[i*4+0] = 0xFF * color.r;
+ pixbuf[i*4+1] = 0xFF * color.g;
+ pixbuf[i*4+2] = 0xFF * color.b;
+ pixbuf[i*4+3] = 0xFF * color.a;
+ }
+
+ imageData.Update();
+
+ return imageData;
+}
+
const Dali::TouchPoint pointDownInside( 0, TouchPoint::Down, 240, 400 );
const Dali::TouchPoint pointUpInside( 0, TouchPoint::Up, 240, 400 );
const Dali::TouchPoint pointLeave( 0, TouchPoint::Leave, 240, 400 );
END_TEST;
}
+int UtcDaliButtonSetButtonImage(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonSetButtonImage");
+
+ Image image = CreateSolidColorImage( Color::RED, 10, 10 );
+
+ PushButton pushButton = PushButton::New();
+ Stage::GetCurrent().Add( pushButton );
+
+ application.SendNotification();
+ application.Render();
+
+ pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
+ pushButton.SetButtonImage( image );
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 size = pushButton.GetCurrentSize();
+
+ DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION );
+ DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetSelectedImageP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonSetButtonImage");
+
+ Image image = CreateSolidColorImage( Color::RED, 10, 10 );
+
+ PushButton pushButton = PushButton::New();
+ Stage::GetCurrent().Add( pushButton );
+
+ application.SendNotification();
+ application.Render();
+
+ pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
+ pushButton.SetSelectedImage( image );
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 size = pushButton.GetCurrentSize();
+
+ DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION );
+ DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliButtonPressedSignalP(void)
{
ToolkitTestApplication application;
return true;
}
-Image CreateSolidColorImage( const Vector4& color, unsigned int width, unsigned int height )
-{
- BufferImage imageData = BufferImage::New( width, height, Pixel::RGBA8888 );
-
- // Create the image
- PixelBuffer* pixbuf = imageData.GetBuffer();
- unsigned int size = width * height;
-
- for( size_t i = 0; i < size; i++ )
- {
- pixbuf[i*4+0] = 0xFF * color.r;
- pixbuf[i*4+1] = 0xFF * color.g;
- pixbuf[i*4+2] = 0xFF * color.b;
- pixbuf[i*4+3] = 0xFF * color.a;
- }
-
- imageData.Update();
-
- return imageData;
-}
-
} // namespace
void checkbox_button_startup(void)
END_TEST;
}
-int UtcDaliCheckBoxButtonSetBackgroundImageP(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliCheckBoxButtonSetBackgroundImageP");
-
- Image image = CreateSolidColorImage( Color::RED, 10, 10 );
- ImageActor imageActor = CreateSolidColorActor( Color::RED );
- imageActor.SetSize( 20, 20 );
-
- CheckBoxButton checkBoxButton = CheckBoxButton::New();
-
- checkBoxButton.SetBackgroundImage( image );
-
- DALI_TEST_CHECK( checkBoxButton.GetBackgroundImage() );
-
- checkBoxButton.SetBackgroundImage( imageActor );
-
- DALI_TEST_CHECK( checkBoxButton.GetBackgroundImage() );
-
- END_TEST;
-}
-
-int UtcDaliCheckBoxButtonSetSelectedImageP(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliCheckBoxButtonSetSelectedImageP");
-
- Image image = CreateSolidColorImage( Color::RED, 10, 10 );
- ImageActor imageActor = CreateSolidColorActor( Color::RED );
- imageActor.SetSize( 20, 20 );
-
- CheckBoxButton checkBoxButton = CheckBoxButton::New();
-
- checkBoxButton.SetSelectedImage( image );
-
- DALI_TEST_CHECK( checkBoxButton.GetSelectedImage() );
-
- checkBoxButton.SetSelectedImage( imageActor );
-
- DALI_TEST_CHECK( checkBoxButton.GetSelectedImage() );
-
- END_TEST;
-}
-
-int UtcDaliCheckBoxButtonSetDisabledBackgroundImageP(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliCheckBoxButtonSetDisabledBackgroundImageP");
-
- Image image = CreateSolidColorImage( Color::RED, 10, 10 );
- ImageActor imageActor = CreateSolidColorActor( Color::RED );
- imageActor.SetSize( 20, 20 );
-
- CheckBoxButton checkBoxButton = CheckBoxButton::New();
-
- checkBoxButton.SetDisabledBackgroundImage( image );
-
- DALI_TEST_CHECK( checkBoxButton.GetDisabledBackgroundImage() );
-
- checkBoxButton.SetDisabledBackgroundImage( imageActor );
-
- DALI_TEST_CHECK( checkBoxButton.GetDisabledBackgroundImage() );
-
- END_TEST;
-}
-
-int UtcDaliCheckBoxButtonSetDisabledSelectedImageP(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliCheckBoxButtonSetDisabledSelectedImageP");
-
- Image image = CreateSolidColorImage( Color::RED, 10, 10 );
- ImageActor imageActor = CreateSolidColorActor( Color::RED );
- imageActor.SetSize( 20, 20 );
-
- CheckBoxButton checkBoxButton = CheckBoxButton::New();
-
- checkBoxButton.SetDisabledSelectedImage( image );
-
- DALI_TEST_CHECK( checkBoxButton.GetDisabledSelectedImage() );
-
- checkBoxButton.SetDisabledSelectedImage( imageActor );
-
- DALI_TEST_CHECK( checkBoxButton.GetDisabledSelectedImage() );
-
- END_TEST;
-}
-
int UtcDaliCheckBoxButtonSetGetSelected(void)
{
ToolkitTestApplication application;
DALI_TEST_CHECK( gCheckBoxButtonState );
END_TEST;
}
-
-int UtcDaliCheckBoxButtonSetImages(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliCheckBoxButtonSetImages");
-
- Actor imageActor;
-
- Image image01 = CreateSolidColorImage( Color::RED, 10, 10 );
- ImageActor imageActor01 = CreateSolidColorActor( Color::RED );
- imageActor01.SetSize( 20, 20 );
-
- Image image02 = CreateSolidColorImage( Color::RED, 30, 30 );
- ImageActor imageActor02 = CreateSolidColorActor( Color::RED );
- imageActor02.SetSize( 40, 40 );
- imageActor02.SetName( "imageActor02" );
-
- Image image03 = CreateSolidColorImage( Color::RED, 50, 50 );
- ImageActor imageActor03 = CreateSolidColorActor( Color::RED );
- imageActor03.SetSize( 60, 60 );
-
- Image image04 = CreateSolidColorImage( Color::RED, 70, 70 );
- ImageActor imageActor04 = CreateSolidColorActor( Color::RED );
- imageActor04.SetSize( 80, 80 );
-
- Vector3 size;
- CheckBoxButton checkBoxButton = CheckBoxButton::New();
- checkBoxButton.SetName( "UtcDaliCheckBoxButtonSetImages" );
- Stage::GetCurrent().Add( checkBoxButton );
-
- application.SendNotification();
- application.Render();
-
- // Just check if check box button size changes when a bigger image is set.
-
- checkBoxButton.SetBackgroundImage( image01 );
-
- application.SendNotification();
- application.Render();
-
- size = checkBoxButton.GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 10.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 10.f, TEST_LOCATION );
-
- checkBoxButton.SetBackgroundImage( imageActor01 );
-
- END_TEST;
-}
DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
- Actor actor = RenderableActor::New();
+ Actor actor = Actor::New();
dummy.Add(actor);
DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
application.SendNotification();
DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
- Actor actor = RenderableActor::New();
+ Actor actor = Actor::New();
dummy.Add(actor);
DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
Control dummy = Control::New();
Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
- // test that style manager is being used, passing an empty handle throws exception
- try
- {
- Dali::Toolkit::StyleManager styleManager;
- controlImpl.OnStyleChange( styleManager, StyleChange::THEME_CHANGE );
- tet_result(TET_FAIL);
- }
- catch (DaliException &exception)
- {
- tet_result(TET_PASS);
- }
+ // test that style manager is being used, passing an empty handle does nothing but does not crash either
+ Dali::Toolkit::StyleManager styleManager;
+ controlImpl.OnStyleChange( styleManager, StyleChange::THEME_CHANGE );
+ // no crash so test passes
+ tet_result(TET_PASS);
END_TEST;
}
END_TEST;
}
-int UtcDaliPushButtonSetButtonImage(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonSetButtonImage");
-
- Image image = CreateSolidColorImage( Color::RED, 10, 10 );
- ImageActor imageActor = CreateSolidColorActor( Color::RED );
- imageActor.SetSize( 20, 20 );
-
- PushButton pushButton = PushButton::New();
- Stage::GetCurrent().Add( pushButton );
-
- application.SendNotification();
- application.Render();
-
- pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
- pushButton.SetButtonImage( image );
-
- DALI_TEST_CHECK( pushButton.GetButtonImage() );
-
- application.SendNotification();
- application.Render();
-
- Vector3 size = pushButton.GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION );
-
- pushButton.SetButtonImage( imageActor );
-
- DALI_TEST_CHECK( pushButton.GetButtonImage() );
- END_TEST;
-}
-
-int UtcDaliPushButtonSetBackgroundImageP(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonSetBackgroundImageP");
-
- Image image = CreateSolidColorImage( Color::RED, 10, 10 );
- ImageActor imageActor = CreateSolidColorActor( Color::RED );
- imageActor.SetSize( 20, 20 );
-
- PushButton pushButton = PushButton::New();
-
- pushButton.SetBackgroundImage( image );
-
- DALI_TEST_CHECK( pushButton.GetBackgroundImage() );
-
- pushButton.SetBackgroundImage( imageActor );
-
- DALI_TEST_CHECK( pushButton.GetBackgroundImage() );
-
- END_TEST;
-}
-
-int UtcDaliPushButtonSetSelectedImageP(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonSetSelectedImageP");
-
- Image image = CreateSolidColorImage( Color::RED, 10, 10 );
- ImageActor imageActor = CreateSolidColorActor( Color::RED );
- imageActor.SetSize( 20, 20 );
-
- PushButton pushButton = PushButton::New();
-
- pushButton.SetSelectedImage( image );
-
- DALI_TEST_CHECK( pushButton.GetSelectedImage() );
-
- pushButton.SetSelectedImage( imageActor );
-
- DALI_TEST_CHECK( pushButton.GetSelectedImage() );
-
- END_TEST;
-}
-
-int UtcDaliPushButtonSetSelectedBackgroundImageP(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonSetSelectedBackgroundImageP");
-
- Image image = CreateSolidColorImage( Color::RED, 10, 10 );
- ImageActor imageActor = CreateSolidColorActor( Color::RED );
- imageActor.SetSize( 20, 20 );
-
- PushButton pushButton = PushButton::New();
-
- pushButton.SetSelectedBackgroundImage( image );
-
- DALI_TEST_CHECK( pushButton.GetSelectedBackgroundImage() );
-
- pushButton.SetSelectedBackgroundImage( imageActor );
-
- DALI_TEST_CHECK( pushButton.GetSelectedBackgroundImage() );
-
- END_TEST;
-}
-
-int UtcDaliPushButtonSetDisabledBackgroundImageP(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonSetDisabledBackgroundImageP");
-
- Image image = CreateSolidColorImage( Color::RED, 10, 10 );
- ImageActor imageActor = CreateSolidColorActor( Color::RED );
- imageActor.SetSize( 20, 20 );
-
- PushButton pushButton = PushButton::New();
-
- pushButton.SetDisabledBackgroundImage( image );
-
- DALI_TEST_CHECK( pushButton.GetDisabledBackgroundImage() );
-
- pushButton.SetDisabledBackgroundImage( imageActor );
-
- DALI_TEST_CHECK( pushButton.GetDisabledBackgroundImage() );
-
- END_TEST;
-}
-
-int UtcDaliPushButtonSetDisabledImageP(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonSetDisabledImageP");
-
- Image image = CreateSolidColorImage( Color::RED, 10, 10 );
- ImageActor imageActor = CreateSolidColorActor( Color::RED );
- imageActor.SetSize( 20, 20 );
-
- PushButton pushButton = PushButton::New();
-
- pushButton.SetDisabledImage( image );
-
- DALI_TEST_CHECK( pushButton.GetDisabledImage() );
-
- pushButton.SetDisabledImage( imageActor );
-
- DALI_TEST_CHECK( pushButton.GetDisabledImage() );
-
- END_TEST;
-}
-
int UtcDaliPushButtonSetGetAutoRepeating(void)
{
ToolkitTestApplication application;
// Test "rows" property
DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_ROWS ) == TableView::Property::ROWS );
- tableView.SetProperty( TableView::Property::ROWS, 4u );
+ tableView.SetProperty( TableView::Property::ROWS, 4 );
DALI_TEST_CHECK( tableView.GetRows() == 4u );
- DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::ROWS).Get<unsigned int>() == 4u );
+ DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::ROWS).Get<int>() == 4 );
// Test "columns" property
DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_COLUMNS ) == TableView::Property::COLUMNS );
- tableView.SetProperty( TableView::Property::COLUMNS, 5u );
+ tableView.SetProperty( TableView::Property::COLUMNS, 5 );
DALI_TEST_CHECK( tableView.GetColumns() == 5u );
- DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::COLUMNS).Get<unsigned int>() == 5u );
+ DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::COLUMNS).Get<int>() == 5 );
// Test "cell-padding" property
DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_CELL_PADDING ) == TableView::Property::CELL_PADDING );
const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decoration-bounding-box";
const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "input-method-settings";
-const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
+const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
TextField field = TextField::New();
DALI_TEST_CHECK( field );
- // Check defaults.
- DALI_TEST_EQUALS( field.GetProperty<unsigned int>( TextField::Property::RENDERING_BACKEND ), DEFAULT_RENDERING_BACKEND, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string(""), TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string(""), TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string(""), TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), std::string(""), TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), 50u, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), TextField::EXCEED_POLICY_CLIP, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "BEGIN", TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "TOP", TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::BLACK, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2::ZERO, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), PLACEHOLDER_TEXT_COLOR, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::BLACK, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::BLACK, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLACK, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), true, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), CURSOR_BLINK_INTERVAL * TO_SECONDS, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 0.f, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), SCROLL_THRESHOLD, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), SCROLL_SPEED, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), LIGHT_BLUE, TEST_LOCATION );
+ // Note - we can't check the defaults since the stylesheets are platform-specific
// Check the render backend property.
field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
- DALI_TEST_EQUALS( field.GetProperty<unsigned int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
+ DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
// Check text property.
field.SetProperty( TextField::Property::TEXT, "Setting Text" );
// Checks if the right number of actors are created.
TextField field = TextField::New();
+ field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
DALI_TEST_CHECK( field );
Stage::GetCurrent().Add( field );
DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
- // Try to tap at the end.
+ // Tap away from the start position.
application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 13.f, 25.0f ) ) );
application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 13.0f, 25.0f ) ) );
application.SendNotification();
application.Render();
- // Cursor position should be the same than position1.
Vector3 position5 = cursor.GetCurrentPosition();
- DALI_TEST_EQUALS( position1, position5, TEST_LOCATION ); // Should be in the same position1.
+ DALI_TEST_CHECK( position5.x > position4.x );
- // Remove some text.
+ // Remove all the text.
application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
+ field.SetProperty( TextField::Property::TEXT, "" );
// Render and notify
application.SendNotification();
Stage::GetCurrent().Add( field );
field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
+ field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
field.SetSize( 30.f, 50.f );
field.SetParentOrigin( ParentOrigin::TOP_LEFT );
field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
const char* const PROPERTY_NAME_UNDERLINE_COLOR = "underline-color";
const char* const PROPERTY_NAME_UNDERLINE_HEIGHT = "underline-height";
-const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
+const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
} // namespace
TextLabel label = TextLabel::New();
DALI_TEST_CHECK( label );
- // Check defaults
- DALI_TEST_EQUALS( label.GetProperty<unsigned int>( TextLabel::Property::RENDERING_BACKEND ), DEFAULT_RENDERING_BACKEND, TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string(""), TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string(""), TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE ), std::string(""), TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), false, TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "BEGIN", TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "TOP", TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLACK, TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2::ZERO, TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLACK, TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), false, TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLACK, TEST_LOCATION );
- DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 0.0f, TEST_LOCATION );
-
+ // Note - we can't check the defaults since the stylesheets are platform-specific
label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
- DALI_TEST_EQUALS( label.GetProperty<unsigned int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
+ DALI_TEST_EQUALS( label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
// Check that text can be correctly reset
label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
develapisuperblurview_HEADERS = $(devel_api_super_blur_view_header_files)
develapitoolbar_HEADERS = $(devel_api_tool_bar_header_files)
develapitransitioneffects_HEADERS = $(devel_api_transition_effects_header_files)
-develapitextselectionpopup_HEADERS = $(devel_api_text_selection_popup_header_files)
+develapitextselectionpopup_HEADERS = $(devel_api_text_controls_header_files)
# public api source
publicapidir = $(topleveldir)/public-api
return JsonParser( dynamic_cast<Internal::JsonParser*>(handle.GetObjectPtr()) );
}
-int JsonParser::Parse(const std::string& source)
+bool JsonParser::Parse(const std::string& source)
{
return GetImplementation(*this).Parse(source);
}
* Parse the source and construct a node tree.
* Subsequent calls to this function will merge the trees.
* @param source The json source to parse
- * @return zero if parsed okay, otherwise an error.
+ * @return true if parsed okay, otherwise an error.
*/
- int Parse(const std::string& source);
+ bool Parse(const std::string& source);
/*
* Optimize memory usage by packing strings
/**
* @brief Enable different blending mode for rendering.
*
- * @param[in] enable If false, the default blending function for RenderableActor is used.
+ * @param[in] enable If false, the default blending function if ImageActor is used.
*/
void SetBlendMode( bool enable );
GetImpl(*this).RaiseAbove( target );
}
+void TextSelectionPopup::ShowPopup()
+{
+ GetImpl(*this).ShowPopup();
+}
+
TextSelectionPopup::TextSelectionPopup( Internal::TextSelectionPopup& implementation )
: Control(implementation)
{
POPUP_PASTE_BUTTON_ICON_IMAGE, ///< name "popup-paste-button-image", The image to use as the popup paste icon, type STRING
POPUP_SELECT_BUTTON_ICON_IMAGE, ///< name "popup-select-button-image", The image to use as the popup select icon, type STRING
POPUP_SELECT_ALL_BUTTON_ICON_IMAGE, ///< name "popup-select-all-button-image", The image to use as the popup select all icon, type STRING
+ DIVIDER_COLOR, ///< name "popup-divider-color", VECTOR4, The color of the divider between options, type VECTOR4
+ ICON_COLOR, ///< name "popup-icon-color", VECTOR4, The color of the icons (if supplied), type VECTOR4
+ PRESSED_COLOR ///< name "popup-pressed-color", VECTOR4, The color of the option when pressed, type VECTOR4
};
};
*/
void RaiseAbove( Layer target );
+ /**
+ * @brief Show the Popup
+ */
+ void ShowPopup();
+
public: // Not intended for application developers
/**
struct AtlasSize
{
- SizeType mWidth; // width of the atlas in pixels
- SizeType mHeight; // height of the atlas in pixels
- SizeType mBlockWidth; // width of a block in pixels
- SizeType mBlockHeight; // height of a block in pixels
+ SizeType mWidth; ///< width of the atlas in pixels
+ SizeType mHeight; ///< height of the atlas in pixels
+ SizeType mBlockWidth; ///< width of a block in pixels
+ SizeType mBlockHeight; ///< height of a block in pixels
};
/**
*/
struct AtlasMetricsEntry
{
- AtlasSize mSize; // size of atlas and blocks
- SizeType mBlocksUsed; // number of blocks used in the atlas
- SizeType mTotalBlocks; // total blocks used by atlas
- Pixel::Format mPixelFormat; // pixel format of the atlas
+ AtlasSize mSize; ///< size of atlas and blocks
+ SizeType mBlocksUsed; ///< number of blocks used in the atlas
+ SizeType mTotalBlocks; ///< total blocks used by atlas
+ Pixel::Format mPixelFormat; ///< pixel format of the atlas
};
struct Metrics
{
- SizeType mAtlasCount; // number of atlases
- SizeType mTextureMemoryUsed; // texture memory used by atlases
- Dali::Vector< AtlasMetricsEntry > mAtlasMetrics; // container of atlas information
+ Metrics()
+ : mAtlasCount( 0u ),
+ mTextureMemoryUsed( 0u )
+ {}
+
+ ~Metrics()
+ {}
+
+ SizeType mAtlasCount; ///< number of atlases
+ SizeType mTextureMemoryUsed; ///< texture memory used by atlases
+ Dali::Vector< AtlasMetricsEntry > mAtlasMetrics; ///< container of atlas information
};
struct Vertex2D
*/
struct AtlasSlot
{
- ImageId mImageId; // Id of stored Image
- AtlasId mAtlasId; // Id of Atlas containing this slot
+ ImageId mImageId; ///< Id of stored Image
+ AtlasId mAtlasId; ///< Id of Atlas containing this slot
};
typedef Dali::Vector< AtlasManager::AtlasSlot > slotContainer;
ret = ToString( value.Get<int>() );
break;
}
- case Property::UNSIGNED_INTEGER:
- {
- ret = ToString( value.Get<unsigned int>() );
- break;
- }
case Property::VECTOR2:
{
ret = ToString( value.Get<Vector2>() );
}
break;
}
- case Property::UNSIGNED_INTEGER:
- {
- if( OptionalUnsignedInt v = replacer.IsUnsignedInteger( node) )
- {
- value = *v;
- done = true;
- }
- break;
- }
case Property::VECTOR2:
{
if( OptionalVector2 v = replacer.IsVector2(node) )
}
}
-int JsonParser::Parse(const std::string& source)
+bool JsonParser::Parse(const std::string& source)
{
mSources.push_back( VectorChar(source.begin(), source.end()) );
/*
* @copydoc Toolkit::JsonParser::Parse()
*/
- int Parse(const std::string& source);
+ bool Parse(const std::string& source);
/*
* @copydoc Toolkit::JsonParser::Pack()
return ret;
}
-OptionalUnsignedInt Replacement::IsUnsignedInteger( const TreeNode & node ) const
-{
- OptionalUnsignedInt ret;
- if( OptionalString replace = HasFullReplacement( node ) )
- {
- Property::Value value = GetFullReplacement( *replace );
- if( Property::UNSIGNED_INTEGER == value.GetType() )
- {
- ret = value.Get<unsigned int>();
- }
- }
- else
- {
- if ( OptionalInteger i = ::IsInteger( node ) )
- {
- ret = OptionalUnsignedInt(static_cast<unsigned int>(*i) );
- }
- }
- return ret;
-}
-
OptionalVector2 Replacement::IsVector2( const TreeNode & node ) const
{
OptionalVector2 ret;
* @param node The TreeNode to check
* @return Optional value
*/
- OptionalUnsignedInt IsUnsignedInteger( const TreeNode & node ) const;
-
- /* @brief Check node for a type
- *
- * @param node The TreeNode to check
- * @return Optional value
- */
OptionalVector2 IsVector2( const TreeNode & node ) const;
/* @brief Check node for a type
vertices.SetData( &vertexData[0] );
Property::Map indexFormat;
- indexFormat["indices"] = Property::UNSIGNED_INTEGER;
+ indexFormat["indices"] = Property::INTEGER;
PropertyBuffer indices = PropertyBuffer::New( indexFormat, numIndex );
indices.SetData( &indexData[0] );
//(2) mDisabledBackgroundContent (Inserted)
//(1) mBackgroundContent
- TransitionInBetween( mUnselectedContent, mLabel, mDisabledContent );
- TransitionInAbove( mBackgroundContent, mDisabledBackgroundContent );
+ AddButtonImage( mBackgroundContent );
+ TransitionButtonImage( mDisabledBackgroundContent );
+ AddButtonImage( mUnselectedContent );
+ TransitionButtonImage( mDisabledContent );
+ ReAddLabel();
TransitionOut( mUnselectedContent );
TransitionOut( mSelectedContent );
//(2) mSelectedBackgroundContent
//(1) mBackgroundContent
- TransitionInBetween( mSelectedContent, mLabel, mDisabledSelectedContent );
- TransitionInAbove( mSelectedBackgroundContent, mDisabledBackgroundContent );
+ AddButtonImage( mBackgroundContent );
+ AddButtonImage( mSelectedBackgroundContent );
+ TransitionButtonImage( mDisabledBackgroundContent );
+ AddButtonImage( mSelectedContent );
+ TransitionButtonImage( mDisabledSelectedContent );
+ ReAddLabel();
TransitionOut( mUnselectedContent );
TransitionOut( mSelectedContent );
//(2) mBackgroundContent (Inserted)
//(1) mDisabledBackgroundContent
- TransitionInBetween( mDisabledContent, mLabel, mUnselectedContent );
- TransitionInAbove( mDisabledBackgroundContent, mBackgroundContent );
+ AddButtonImage( mDisabledBackgroundContent );
+ TransitionButtonImage( mBackgroundContent );
+ AddButtonImage( mDisabledContent );
+ TransitionButtonImage( mUnselectedContent );
+ ReAddLabel();
TransitionOut( mSelectedContent );
TransitionOut( mSelectedBackgroundContent );
//(2) mBackgroundContent (Inserted)
//(1) mDisabledBackgroundContent
- TransitionInBetween( mDisabledSelectedContent, mLabel, mSelectedContent );
- TransitionInAbove( mDisabledBackgroundContent, mSelectedBackgroundContent );
- TransitionInAbove( mDisabledBackgroundContent, mBackgroundContent );
+ AddButtonImage( mDisabledBackgroundContent );
+ TransitionButtonImage( mBackgroundContent );
+ TransitionButtonImage( mSelectedBackgroundContent );
+ AddButtonImage( mDisabledSelectedContent );
+ TransitionButtonImage( mSelectedContent );
+ ReAddLabel();
TransitionOut( mUnselectedContent );
TransitionOut( mDisabledContent );
//(2) mSelectedBackgroundContent (Inserted)
//(1) mBackgroundContent
- TransitionInBetween( mUnselectedContent, mLabel, mSelectedContent );
- TransitionInAbove( mBackgroundContent, mSelectedBackgroundContent );
- TransitionInAtIndex( 0, mBackgroundContent );
+ AddButtonImage( mBackgroundContent );
+ TransitionButtonImage( mSelectedBackgroundContent );
+ AddButtonImage( mUnselectedContent );
+ TransitionButtonImage( mSelectedContent );
+ ReAddLabel();
TransitionOut( mUnselectedContent );
TransitionOut( mDisabledContent );
//(2) mSelectedContent
//(1) mBackgroundContent
- TransitionInBetween( mSelectedContent, mLabel, mUnselectedContent );
- TransitionInAtIndex( 0, mBackgroundContent );
+ AddButtonImage( mBackgroundContent );
+ AddButtonImage( mSelectedContent );
+ TransitionButtonImage( mUnselectedContent );
+ ReAddLabel();
TransitionOut( mSelectedContent );
TransitionOut( mSelectedBackgroundContent );
{
if( !mTogglableButton )
{
- Toolkit::Button handle( GetOwner() );
-
Pressed();
if( mAutoRepeating )
{
SetUpTimer( mInitialAutoRepeatingDelay );
}
-
- //Emit signal.
- mPressedSignal.Emit( handle );
}
+
+ // The pressed signal should be emitted regardless of toggle mode.
+ Toolkit::Button handle( GetOwner() );
+ mPressedSignal.Emit( handle );
}
void Button::OnButtonUp()
{
mAutoRepeatingTimer.Reset();
}
-
- Toolkit::Button handle( GetOwner() );
-
- //Emit signal.
- mReleasedSignal.Emit( handle );
- mClickedSignal.Emit( handle );
}
+
+ // The clicked and released signals should be emitted regardless of toggle mode.
+ Toolkit::Button handle( GetOwner() );
+ mReleasedSignal.Emit( handle );
+ mClickedSignal.Emit( handle );
}
}
{
if( !mTogglableButton )
{
- Toolkit::Button handle( GetOwner() );
-
Released();
if( mAutoRepeating )
{
mAutoRepeatingTimer.Reset();
}
-
- //Emit signal.
- mReleasedSignal.Emit( handle );
}
+
+ // The released signal should be emitted regardless of toggle mode.
+ Toolkit::Button handle( GetOwner() );
+ mReleasedSignal.Emit( handle );
}
}
//(2) mSelectedBackgroundContent (Inserted)
//(1) mBackgroundContent
- TransitionInBetween( mUnselectedContent, mLabel, mSelectedContent );
- TransitionInAbove( mBackgroundContent, mSelectedBackgroundContent );
- TransitionInAtIndex( 0, mBackgroundContent );
+ AddButtonImage( mBackgroundContent );
+ TransitionButtonImage( mSelectedBackgroundContent );
+ AddButtonImage( mUnselectedContent );
+ TransitionButtonImage( mSelectedContent );
+ ReAddLabel();
TransitionOut( mUnselectedContent );
TransitionOut( mDisabledContent );
//(2) mSelectedContent
//(1) mBackgroundContent
- TransitionInBetween( mSelectedContent, mLabel, mUnselectedContent );
- TransitionInAtIndex( 0, mBackgroundContent );
+ AddButtonImage( mBackgroundContent );
+ AddButtonImage( mSelectedContent );
+ TransitionButtonImage( mUnselectedContent );
+ ReAddLabel();
TransitionOut( mSelectedContent );
TransitionOut( mSelectedBackgroundContent );
return mPaintState;
}
-bool Button::InsertButtonImage( unsigned int index, Actor& actor )
+void Button::PrepareAddButtonImage( Actor& actor )
{
if( actor )
{
- Self().Insert( index, actor );
+ actor.Unparent();
+ Self().Add( actor );
PrepareForTranstionOut( actor );
- return true;
}
+}
- return false;
+void Button::TransitionButtonImage( Actor& actor )
+{
+ if( actor )
+ {
+ if( !actor.GetParent() )
+ {
+ Self().Add( actor );
+ }
+
+ OnTransitionIn( actor );
+ }
+}
+
+void Button::AddButtonImage( Actor& actor )
+{
+ if( actor )
+ {
+ Self().Add( actor );
+ }
+}
+
+void Button::ReAddLabel()
+{
+ if( mLabel )
+ {
+ mLabel.Unparent();
+ Self().Add( mLabel );
+ }
}
void Button::RemoveButtonImage( Actor& actor )
return childrenNum;
}
-void Button::TransitionInBetween( Actor childLower, Actor childUpper, Actor actor )
-{
- unsigned int index = childLower ? FindChildIndex( childLower ) + 1 : FindChildIndex( childUpper );
- TransitionInAtIndex( index, actor );
-}
-
-void Button::TransitionInAbove( Actor child, Actor actor )
-{
- unsigned int index = child ? FindChildIndex( child ) + 1 : 0;
- TransitionInAtIndex( index, actor );
-}
-
-void Button::TransitionInAtIndex( unsigned int index, Actor actor )
-{
- if( actor )
- {
- if( !actor.GetParent() )
- {
- Self().Insert( index, actor );
- }
-
- OnTransitionIn( actor );
- }
-}
-
void Button::TransitionOut( Actor actor )
{
OnTransitionOut( actor );
void Button::ResetImageLayers()
{
- //ensure that all layers are in the correct order and state according to the paint state
+ // Ensure that all layers are in the correct order and state according to the paint state
- int index = 0;
switch( mPaintState )
{
case UnselectedState:
RemoveButtonImage( mDisabledSelectedContent );
RemoveButtonImage( mDisabledBackgroundContent );
- if( InsertButtonImage( index, mBackgroundContent ) )
- {
- ++index;
- }
- if( InsertButtonImage( index, mUnselectedContent ) )
- {
- ++index;
- }
+ PrepareAddButtonImage( mBackgroundContent );
+ PrepareAddButtonImage( mUnselectedContent );
break;
}
case SelectedState:
RemoveButtonImage( mDisabledSelectedContent );
RemoveButtonImage( mDisabledBackgroundContent );
- if( InsertButtonImage( index, mBackgroundContent ) )
- {
- ++index;
- }
- if( InsertButtonImage( index, mSelectedBackgroundContent ) )
- {
- ++index;
- }
- if( InsertButtonImage( index, mSelectedContent ) )
- {
- ++index;
- }
+ PrepareAddButtonImage( mBackgroundContent );
+ PrepareAddButtonImage( mSelectedBackgroundContent );
+ PrepareAddButtonImage( mSelectedContent );
+ ReAddLabel();
break;
}
case DisabledUnselectedState:
RemoveButtonImage( mDisabledSelectedContent );
RemoveButtonImage( mSelectedBackgroundContent );
- if( InsertButtonImage( index, mDisabledBackgroundContent ? mDisabledBackgroundContent : mBackgroundContent ) )
- {
- ++index;
- }
- if( InsertButtonImage( index, mDisabledContent ? mDisabledContent : mUnselectedContent ) )
- {
- ++index;
- }
+ PrepareAddButtonImage( mDisabledBackgroundContent ? mDisabledBackgroundContent : mBackgroundContent );
+ PrepareAddButtonImage( mDisabledContent ? mDisabledContent : mUnselectedContent );
+ ReAddLabel();
break;
}
case DisabledSelectedState:
if( mDisabledBackgroundContent )
{
- if( InsertButtonImage( index, mDisabledBackgroundContent) )
- {
- ++index;
- }
+ PrepareAddButtonImage( mDisabledBackgroundContent );
}
else
{
- if( InsertButtonImage( index, mBackgroundContent ) )
- {
- ++index;
- }
- if( InsertButtonImage( index, mSelectedBackgroundContent ) )
- {
- ++index;
- }
+ PrepareAddButtonImage( mBackgroundContent );
+ PrepareAddButtonImage( mSelectedBackgroundContent );
}
- if( InsertButtonImage( index, mDisabledSelectedContent ? mDisabledSelectedContent : mSelectedContent) )
- {
- ++index;
- }
+ PrepareAddButtonImage( mDisabledSelectedContent ? mDisabledSelectedContent : mSelectedContent );
+ ReAddLabel();
break;
}
}
void ResetImageLayers();
/**
- * Transitions in the actor, inserting the actor above childLower below the childUpper.
- * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor)
+ * Transitions out the actor
*/
- void TransitionInBetween( Actor childLower, Actor childUpper, Actor actor );
+ void TransitionOut( Actor actor );
/**
- * Transitions in the actor, inserting the actor above the child if the child exists or at the bottom otherwise
- * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor)
+ * Removes the actor from the button and prepares it to be transitioned out
*/
- void TransitionInAbove( Actor child, Actor actor );
+ void RemoveButtonImage( Actor& actor );
/**
- * Transitions in the actor, inserting the actor at the index
- * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor)
+ * Finds the index of the actor.
+ * If the actor doesn't exist, return the last index + 1.
*/
- void TransitionInAtIndex( unsigned int index, Actor actor );
+ unsigned int FindChildIndex( Actor& actor );
/**
- * Transitions out the actor
+ * Adds an actor to the hierarchy and prepares it to be transitioned.
+ * @param[in] actor The actor to add
*/
- void TransitionOut( Actor actor );
+ void PrepareAddButtonImage( Actor& actor );
/**
- * Inserts the actor to the button and prepares it to be transitioned out
- * @return true if the child was inserted, false otherwise
+ * Adds an actor to the hierarchy and marks it to be transitioned.
+ * @param[in] actor The actor to add
*/
- bool InsertButtonImage( unsigned int index, Actor& actor );
+ void TransitionButtonImage( Actor& actor );
/**
- * Removes the actor from the button and prepares it to be transitioned out
+ * Adds an actor to the hierarchy.
+ * @param[in] actor The actor to add
*/
- void RemoveButtonImage( Actor& actor );
+ void AddButtonImage( Actor& actor );
/**
- * Finds the index of the actor.
- * If the actor doesn't exist, return the last index + 1.
+ * (Re)Adds the label (if exists) to the hierarchy (so it is always on top).
*/
- unsigned int FindChildIndex( Actor& actor );
-
+ void ReAddLabel();
// Undefined
Button( const Button& );
Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( GetLabel() );
if( label )
{
- size.width = std::max( size.width, label.GetRelayoutSize( Dimension::WIDTH ) );
- size.height = std::max( size.height, label.GetRelayoutSize( Dimension::HEIGHT ) );
+ Padding padding( 0.0f, 0.0f, 0.0f, 0.0f );
+ label.GetPadding( padding );
+ size = label.GetNaturalSize();
+ size.width += padding.x + padding.width;
+ size.height += padding.y + padding.height;
}
else
{
// EXTERNAL INCLUDES
#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/object/type-registry-helper.h>
+#include <dali/devel-api/rendering/cull-face.h>
namespace Dali
{
void PageTurnLandscapeView::OnAddPage( ImageActor newPage, bool isLeftSide )
{
newPage.SetParentOrigin( ParentOrigin::CENTER );
- newPage.SetCullFace( CullBack );
+ SetCullFace( newPage, CullBack );
if( 0 < newPage.GetChildCount() )
{
ImageActor backImage = ImageActor::DownCast( newPage.GetChildAt( 0 ) );
backImage.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
backImage.SetSize( mPageSize );
- backImage.SetCullFace( CullFront );
+ SetCullFace( backImage, CullFront );
backImage.SetZ( 0.25f * STATIC_PAGE_INTERVAL_DISTANCE );
}
if( isLeftSide )
#include <dali/public-api/animation/animation.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/object/type-registry-helper.h>
+#include <dali/devel-api/rendering/cull-face.h>
//INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
AlphaFunction::EASE_OUT, TimePeriod(PAGE_TURN_OVER_ANIMATION_DURATION*0.75f) );
animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), AngleAxis( Degree( 180.0f ), Vector3::YAXIS ) ,AlphaFunction::EASE_OUT );
animation.Play();
- ImageActor::DownCast(actor).SetCullFace( CullBack );
+
+ ImageActor imageActor = ImageActor::DownCast(actor);
+ if( imageActor )
+ {
+ SetCullFace( imageActor, CullBack );
+ }
animation.FinishedSignal().Connect( this, &PageTurnPortraitView::OnTurnedOver );
}
}
void PageTurnPortraitView::OnTurnedOver( Animation& animation )
{
- ImageActor::DownCast(mAnimationActorPair[animation]).SetCullFace( CullNone );
+ ImageActor imageActor = ImageActor::DownCast( mAnimationActorPair[ animation ] );
+ if( imageActor )
+ {
+ SetCullFace( imageActor, CullNone );
+ }
TurnedOver( animation );
}
void ScrollBar::OnInitialize()
{
CreateDefaultIndicatorActor();
+ Self().SetDrawMode(DrawMode::OVERLAY_2D);
}
void ScrollBar::SetScrollPropertySource( Handle handle, Property::Index propertyScrollPosition, Property::Index propertyMinScrollPosition, Property::Index propertyMaxScrollPosition, Property::Index propertyScrollContentSize )
if( indicator )
{
mIndicator = indicator;
+ Self().Add(mIndicator);
- Actor self = Self();
- self.Add(mIndicator);
+ EnableGestureDetection(Gesture::Type(Gesture::Pan));
- if( !mPanGestureDetector )
- {
- mPanGestureDetector = PanGestureDetector::New();
- mPanGestureDetector.DetectedSignal().Connect(this, &ScrollBar::OnPan);
- }
-
- mPanGestureDetector.DetachAll();
- mPanGestureDetector.Attach( mIndicator );
+ PanGestureDetector detector( GetPanGestureDetector() );
+ detector.DetachAll();
+ detector.Attach( mIndicator );
unsigned int childCount = mIndicator.GetChildCount();
for ( unsigned int index = 0; index < childCount; index++ )
Actor child = mIndicator.GetChildAt( index );
if ( child )
{
- mPanGestureDetector.Attach( child );
+ detector.Attach( child );
}
}
}
return true;
}
-void ScrollBar::OnPan( Actor source, const PanGesture& gesture )
+void ScrollBar::OnPan( const PanGesture& gesture )
{
if(mScrollableObject)
{
if(itemView)
{
// Disable automatic refresh in ItemView during fast scrolling
- GetImpl(itemView).SetRefreshEnabled(true);//!mIsPanning);
+ GetImpl(itemView).SetRefreshEnabled(!mIsPanning);
}
}
}
virtual void OnInitialize();
/**
+ * @copydoc Toolkit::Control::OnPan
+ */
+ virtual void OnPan( const PanGesture& gesture );
+
+ /**
* @copydoc CustomActorImpl::OnSizeSet( const Vector3& size )
*/
virtual void OnSizeSet( const Vector3& size );
*/
void OnIndicatorHeightPolicyPropertySet(Property::Value propertyValue);
- /**
- * Pan gesture callback
- *
- * @param[in] actor The actor the event is raised for
- * @param[in] gesture The pan event info
- */
- void OnPan(Actor source, const PanGesture& gesture);
-
private:
/**
Toolkit::ScrollBar::IndicatorHeightPolicy mIndicatorHeightPolicy; ///< The height policy of scroll indicator (variable or fixed)
float mIndicatorFixedHeight; ///< The fixed height of scroll indicator
- PanGestureDetector mPanGestureDetector; ///< The pan gesture detector for scroll indicator
-
Timer mContractDelayTimer; ///< Timer guarantee contract delay time.
Timer mPanProcessTimer; ///< The timer to process the pan gesture after the gesture is started.
unsigned int indexData[18] = { 0,3,1,0,2,3,4,7,5,4,6,7,8,11,9,8,10,11 };
Property::Map indexFormat;
- indexFormat["indices"] = Property::UNSIGNED_INTEGER;
+ indexFormat["indices"] = Property::INTEGER;
PropertyBuffer indices = PropertyBuffer::New( indexFormat, 18u );
indices.SetData( indexData );
void ItemView::OnScrollPositionChanged( float position )
{
// Cancel scroll animation to prevent any fighting of setting the scroll position property.
- RemoveAnimation(mScrollAnimation);
+ if(!mRefreshEnabled)
+ {
+ RemoveAnimation(mScrollAnimation);
+ }
// Refresh the cache immediately when the scroll position is changed.
DoRefresh(position, false); // No need to cache extra items.
// Setup properties, signals and actions using the type-registry.
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TableView, Toolkit::Control, Create );
-DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "rows", UNSIGNED_INTEGER, ROWS )
-DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "columns", UNSIGNED_INTEGER, COLUMNS )
-DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "cell-padding", VECTOR2, CELL_PADDING )
-DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "layout-rows", MAP, LAYOUT_ROWS )
-DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "layout-columns", MAP, LAYOUT_COLUMNS )
+DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "rows", INTEGER, ROWS )
+DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "columns", INTEGER, COLUMNS )
+DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "cell-padding", VECTOR2, CELL_PADDING )
+DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "layout-rows", MAP, LAYOUT_ROWS )
+DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "layout-columns", MAP, LAYOUT_COLUMNS )
DALI_TYPE_REGISTRATION_END()
{
case Toolkit::TableView::Property::ROWS:
{
- if( value.Get<unsigned int>() != tableViewImpl.GetRows() )
+ int rows = 0;
+ if( value.Get( rows ) && rows >= 0 )
{
- tableViewImpl.Resize( value.Get<unsigned int>(), tableViewImpl.GetColumns() );
+ if( static_cast<unsigned int>(rows) != tableViewImpl.GetRows() )
+ {
+ tableViewImpl.Resize( rows, tableViewImpl.GetColumns() );
+ }
}
break;
}
case Toolkit::TableView::Property::COLUMNS:
{
- if( value.Get<unsigned int>() != tableViewImpl.GetColumns() )
+ int columns = 0;
+ if( value.Get( columns ) && columns >= 0 )
{
- tableViewImpl.Resize( tableViewImpl.GetRows(), value.Get<unsigned int>() );
+ if( static_cast<unsigned int>( columns ) != tableViewImpl.GetColumns() )
+ {
+ tableViewImpl.Resize( tableViewImpl.GetRows(), value.Get<int>() );
+ }
}
break;
}
{
case Toolkit::TableView::Property::ROWS:
{
- value = tableViewImpl.GetRows();
+ value = static_cast<int>( tableViewImpl.GetRows() );
break;
}
case Toolkit::TableView::Property::COLUMNS:
{
- value = tableViewImpl.GetColumns();
+ value = static_cast<int>( tableViewImpl.GetColumns() );
break;
}
case Toolkit::TableView::Property::CELL_PADDING:
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-image-right", STRING, SELECTION_HANDLE_IMAGE_RIGHT )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-pressed-image-left", STRING, SELECTION_HANDLE_PRESSED_IMAGE_LEFT )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-pressed-image-right", STRING, SELECTION_HANDLE_PRESSED_IMAGE_RIGHT )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-highlight-color", STRING, SELECTION_HIGHLIGHT_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-highlight-color", VECTOR4, SELECTION_HIGHLIGHT_COLOR )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "decoration-bounding-box", RECTANGLE, DECORATION_BOUNDING_BOX )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "input-method-settings", MAP, INPUT_METHOD_SETTINGS )
const std::string TEXT_SELECTION_POPUP_LABEL = "textselectionpopuplabel";
-const Dali::Vector4 DEFAULT_POPUP_DIVIDER_COLOR( Dali::Vector4( 0.23f, 0.72f, 0.8f, 0.11f ) );
-const Dali::Vector4 DEFAULT_OPTION_ICON( Dali::Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
-const Dali::Vector4 DEFAULT_OPTION_PRESSED_COLOR( Dali::Vector4( 0.24f, 0.72f, 0.8f, 0.11f ) );
-
-const float DEFAULT_CAPTION_POINT_SIZE = 8.0f; // todo This should be from the style sheet not fixed.
-
-const std::string DEFAULT_POPUP_BACKGROUND_IMAGE( DALI_IMAGE_DIR "selection-popup-bg#.png" );
-const std::string OPTION_ICON_CLIPBOARD( DALI_IMAGE_DIR "copy_paste_icon_clipboard.png" );
-const std::string OPTION_ICON_COPY( DALI_IMAGE_DIR "copy_paste_icon_copy.png" );
-const std::string OPTION_ICON_CUT( DALI_IMAGE_DIR "copy_paste_icon_cut.png" );
-const std::string OPTION_ICON_PASTE( DALI_IMAGE_DIR "copy_paste_icon_paste.png" );
-const std::string OPTION_ICON_SELECT( DALI_IMAGE_DIR "copy_paste_icon_select.png" );
-const std::string OPTION_ICON_SELECT_ALL( DALI_IMAGE_DIR "copy_paste_icon_select_all.png" );
-
-const float OPTION_MARGIN_WIDTH( 10.f ); ///< The margin between the right or lefts edge and the text or icon.
-
#ifdef DGETTEXT_ENABLED
#define POPUP_CUT_STRING GET_LOCALE_TEXT("IDS_COM_BODY_CUT")
DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-paste-button-image", STRING, POPUP_PASTE_BUTTON_ICON_IMAGE )
DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-select-button-image", STRING, POPUP_SELECT_BUTTON_ICON_IMAGE )
DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-select-all-button-image", STRING, POPUP_SELECT_ALL_BUTTON_ICON_IMAGE )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-divider-color", VECTOR4, DIVIDER_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-icon-color", VECTOR4, ICON_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-pressed-color", VECTOR4, PRESSED_COLOR )
DALI_TYPE_REGISTRATION_END()
impl.SetDimensionToCustomise( POPUP_MAXIMUM_SIZE, value.Get< Vector2 >() );
break;
}
- case Toolkit::TextSelectionPopup::Property::POPUP_MIN_SIZE:
- {
- impl.SetDimensionToCustomise( POPUP_MINIMUM_SIZE, value.Get< Vector2 >() );
- break;
- }
case Toolkit::TextSelectionPopup::Property::OPTION_MAX_SIZE:
{
impl.SetDimensionToCustomise( OPTION_MAXIMUM_SIZE, value.Get< Vector2 >() );
impl.SetButtonImage( Toolkit::TextSelectionPopup::SELECT_ALL, image );
break;
}
+ case Toolkit::TextSelectionPopup::Property::DIVIDER_COLOR:
+ {
+ impl.mDividerColor = value.Get< Vector4 >();
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::ICON_COLOR:
+ {
+ impl.mIconColor = value.Get< Vector4 >();
+ break;
+ }
+ case Toolkit::TextSelectionPopup::Property::PRESSED_COLOR:
+ {
+ impl.mPressedColor = value.Get< Vector4 >();
+ break;
+ }
} // switch
} // TextSelectionPopup
}
}
}
+void TextSelectionPopup::ShowPopup()
+{
+ AddPopupOptionsToToolbar( mShowIcons, mShowCaptions );
+}
+
void TextSelectionPopup::OnInitialize()
{
CreatePopup();
{
case POPUP_MAXIMUM_SIZE :
{
- Actor self = Self();
- mMaxSize = dimension;
if ( mToolbar )
{
- mToolbar.SetProperty( Toolkit::TextSelectionToolbar::Property::MAX_SIZE, mMaxSize );
+ mToolbar.SetProperty( Toolkit::TextSelectionToolbar::Property::MAX_SIZE, dimension );
}
break;
}
- case POPUP_MINIMUM_SIZE :
- {
- Actor self = Self();
- mMinSize = dimension;
- // Option can not be smaller than this if only one.
- break;
- }
case OPTION_MAXIMUM_SIZE :
{
mOptionMaxSize = dimension;
// Option max size not currently currently supported
-
break;
}
case OPTION_MINIMUM_SIZE :
{
case POPUP_MAXIMUM_SIZE :
{
- return mMaxSize;
- }
- case POPUP_MINIMUM_SIZE :
- {
- return mMinSize;
+ return mToolbar.GetProperty( Toolkit::TextSelectionToolbar::Property::MAX_SIZE ).Get< Vector2 >();
}
case OPTION_MAXIMUM_SIZE :
{
mOrderListOfButtons.reserve( 8u );
// Create button for each possible option using Option priority
- if ( !mCutIconImage )
- {
- mCutIconImage = ResourceImage::New( OPTION_ICON_CUT );
- }
mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::CUT, mCutOptionPriority, OPTION_CUT, POPUP_CUT_STRING , mCutIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::CUT) ) );
-
- if ( !mCopyIconImage )
- {
- mCopyIconImage = ResourceImage::New( OPTION_ICON_COPY );
- }
mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::COPY, mCopyOptionPriority, OPTION_COPY, POPUP_COPY_STRING, mCopyIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::COPY) ) );
-
- if ( !mPasteIconImage )
- {
- mPasteIconImage = ResourceImage::New( OPTION_ICON_PASTE );
- }
mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::PASTE, mPasteOptionPriority, OPTION_PASTE, POPUP_PASTE_STRING, mPasteIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::PASTE) ) );
-
- if ( !mSelectIconImage )
- mSelectIconImage = ResourceImage::New( OPTION_ICON_SELECT );
mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::SELECT, mSelectOptionPriority, OPTION_SELECT_WORD, POPUP_SELECT_STRING, mSelectIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::SELECT) ) );
-
- if ( !mSelectAllIconImage )
- {
- mSelectAllIconImage = ResourceImage::New( OPTION_ICON_SELECT_ALL );
- }
mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::SELECT_ALL, mSelectAllOptionPriority, OPTION_SELECT_ALL, POPUP_SELECT_ALL_STRING, mSelectAllIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::SELECT_ALL) ) );
-
- if ( !mClipboardIconImage )
- {
- mClipboardIconImage = ResourceImage::New( OPTION_ICON_CLIPBOARD );
- }
mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::CLIPBOARD, mClipboardOptionPriority, OPTION_CLIPBOARD, POPUP_CLIPBOARD_STRING, mClipboardIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::CLIPBOARD) ) );
// Sort the buttons according their priorities.
Toolkit::TextLabel captionTextLabel = Toolkit::TextLabel::New();
captionTextLabel.SetStyleName( TEXT_SELECTION_POPUP_LABEL );
captionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
- captionTextLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, DEFAULT_CAPTION_POINT_SIZE );
captionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
Toolkit::TextLabel pressedCaptionTextLabel = Toolkit::TextLabel::New();
pressedCaptionTextLabel.SetStyleName( TEXT_SELECTION_POPUP_LABEL );
pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
- pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, DEFAULT_CAPTION_POINT_SIZE );
pressedCaptionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
Padding padding;
int depth = Self().GetHierarchyDepth();
// 3. Create the icons
- if ( showIcons )
+ if ( showIcons && iconImage )
{
ImageActor pressedIcon = ImageActor::New( iconImage );
ImageActor icon = ImageActor::New( iconImage );
void TextSelectionPopup::CreatePopup()
{
Actor self = Self();
- CreateOrderedListOfPopupOptions(); //todo Currently causes all options to be shown
+ CreateOrderedListOfPopupOptions();
self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
- SetBackgroundImage( NinePatchImage::New( DEFAULT_POPUP_BACKGROUND_IMAGE ) );
if( !mToolbar )
{
mToolbar = Toolkit::TextSelectionToolbar::New();
mToolbar.SetParentOrigin( ParentOrigin::CENTER );
- mToolbar.SetProperty( Toolkit::TextSelectionToolbar::Property::MAX_SIZE, mMaxSize );
self.Add( mToolbar );
- AddPopupOptionsToToolbar( mShowIcons, mShowCaptions );
}
}
TextSelectionPopup::TextSelectionPopup( TextSelectionPopupCallbackInterface* callbackInterface )
: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
mToolbar(),
- mMaxSize(),
- mMinSize(),
- mOptionDividerSize( Size( 2.0f, 0.0f) ),
+ mOptionDividerSize(),
mEnabledButtons( Toolkit::TextSelectionPopup::NONE ),
mCallbackInterface( callbackInterface ),
- mDividerColor( DEFAULT_POPUP_DIVIDER_COLOR ),
- mIconColor( DEFAULT_OPTION_ICON ),
- mPressedColor( DEFAULT_OPTION_PRESSED_COLOR ),
+ mDividerColor( Color::WHITE ),
+ mIconColor( Color::WHITE ),
+ mPressedColor( Color::WHITE ),
mSelectOptionPriority( 1 ),
mSelectAllOptionPriority ( 2 ),
mCutOptionPriority ( 4 ),
enum PopupCustomisations
{
POPUP_MAXIMUM_SIZE,
- POPUP_MINIMUM_SIZE,
OPTION_MAXIMUM_SIZE,
OPTION_MINIMUM_SIZE,
OPTION_DIVIDER_SIZE
*/
void RaiseAbove( Layer target );
+ /**
+ * @copydoc Toolkit::TextSelectionPopup::ShowPopup()
+ */
+ void ShowPopup();
+
private: // From Control
/**
Image mSelectIconImage;
Image mSelectAllIconImage;
- Size mMaxSize; // Maximum size of the Popup
- Size mMinSize; // Minimum size of the Popup
-
Size mOptionMaxSize; // Maximum size of an Option button
Size mOptionMinSize; // Minimum size of an Option button
Size mOptionDividerSize; // Size of divider line
void TextSelectionToolbar::SetPopupMaxSize( const Size& maxSize )
{
mMaxSize = maxSize;
+ if (mScrollView && mStencilLayer )
+ {
+ mScrollView.SetMaximumSize( mMaxSize );
+ mStencilLayer.SetMaximumSize( mMaxSize );
+ }
}
const Dali::Vector2& TextSelectionToolbar::GetPopupMaxSize() const
scrollView.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
scrollView.SetParentOrigin( ParentOrigin::CENTER_LEFT );
scrollView.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
- scrollView.SetMaximumSize( mMaxSize );
scrollView.SetScrollingDirection( PanGestureDetector::DIRECTION_HORIZONTAL, Degree( 40.0f ) );
scrollView.SetAxisAutoLock( true );
mStencilLayer = Layer::New();
mStencilLayer.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
mStencilLayer.SetParentOrigin( ParentOrigin::CENTER );
- mStencilLayer.SetMaximumSize( mMaxSize );
ImageActor stencil = CreateSolidColorActor( Color::RED );
stencil.SetDrawMode( DrawMode::STENCIL );
TextSelectionToolbar::TextSelectionToolbar()
: Control( ControlBehaviour( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ) ),
- mMaxSize ( DEFAULT_MAX_SIZE ),
+ mMaxSize (),
mIndexInTable( 0 ),
mDividerIndexes()
{
--- /dev/null
+#ifndef __DALI_FEEDBACK_IDS_H__
+#define __DALI_FEEDBACK_IDS_H__
+
+/*
+ * Copyright (c) 2014 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.
+ *
+ */
+
+namespace Dali
+{
+
+/**
+ * Enumerations for the types of feedback
+ * Note: These are based on feedback_type_e in libsvi
+ */
+enum FeedbackType
+{
+ FEEDBACK_TYPE_NONE,
+
+ FEEDBACK_TYPE_SOUND,
+ FEEDBACK_TYPE_VIBRATION,
+ FEEDBACK_TYPE_LED,
+
+ FEEDBACK_TYPE_END
+};
+
+/**
+ * The pattern list for feedback effects.
+ * Note: These are based on feedback_pattern_e in libsvi
+ */
+enum FeedbackPattern
+{
+ FEEDBACK_PATTERN_NONE = -1,
+
+ FEEDBACK_PATTERN_TAP = 0, /**< feedback pattern when general touch */
+ FEEDBACK_PATTERN_SIP, /**< feedback pattern when touch text key */
+ FEEDBACK_PATTERN_SIP_BACKSPACE, /**< feedback pattern when touch backspace key */
+ FEEDBACK_PATTERN_MAX_CHARACTER, /**< feedback pattern when max character */
+ FEEDBACK_PATTERN_KEY0, /**< feedback pattern when touch numeric 0 key */
+ FEEDBACK_PATTERN_KEY1, /**< feedback pattern when touch numeric 1 key */
+ FEEDBACK_PATTERN_KEY2, /**< feedback pattern when touch numeric 2 key */
+ FEEDBACK_PATTERN_KEY3, /**< feedback pattern when touch numeric 3 key */
+ FEEDBACK_PATTERN_KEY4, /**< feedback pattern when touch numeric 4 key */
+ FEEDBACK_PATTERN_KEY5, /**< feedback pattern when touch numeric 5 key */
+ FEEDBACK_PATTERN_KEY6, /**< feedback pattern when touch numeric 6 key */
+ FEEDBACK_PATTERN_KEY7, /**< feedback pattern when touch numeric 7 key */
+ FEEDBACK_PATTERN_KEY8, /**< feedback pattern when touch numeric 8 key */
+ FEEDBACK_PATTERN_KEY9, /**< feedback pattern when touch numeric 9 key */
+ FEEDBACK_PATTERN_KEY_STAR, /**< feedback pattern when touch star key */
+ FEEDBACK_PATTERN_KEY_SHARP, /**< feedback pattern when touch sharp key */
+ FEEDBACK_PATTERN_HOLD, /**< feedback pattern when touch hold */
+ FEEDBACK_PATTERN_MULTI_TAP, /**< feedback pattern when multi touch */
+ FEEDBACK_PATTERN_HW_TAP, /**< feedback pattern when press hardware key */
+ FEEDBACK_PATTERN_HW_HOLD, /**< feedback pattern when holding press hardware key */
+
+ FEEDBACK_PATTERN_MESSAGE, /**< feedback pattern when incoming a message */
+ FEEDBACK_PATTERN_MESSAGE_ON_CALL, /**< feedback pattern when incoming a message on call */
+ FEEDBACK_PATTERN_EMAIL, /**< feedback pattern when incoming an email */
+ FEEDBACK_PATTERN_EMAIL_ON_CALL, /**< feedback pattern when incoming an email on call */
+ FEEDBACK_PATTERN_WAKEUP, /**< feedback pattern when alert wake up call */
+ FEEDBACK_PATTERN_WAKEUP_ON_CALL, /**< feedback pattern when alert wake up call on call */
+ FEEDBACK_PATTERN_SCHEDULE, /**< feedback pattern when alert schedule alarm */
+ FEEDBACK_PATTERN_SCHEDULE_ON_CALL, /**< feedback pattern when alert schedule alarm on call */
+ FEEDBACK_PATTERN_TIMER, /**< feedback pattern when alert timer */
+ FEEDBACK_PATTERN_TIMER_ON_CALL, /**< feedback pattern when alert timer on call */
+ FEEDBACK_PATTERN_GENERAL, /**< feedback pattern when alert general event */
+ FEEDBACK_PATTERN_GENERAL_ON_CALL, /**< feedback pattern when alert general event on call */
+
+ FEEDBACK_PATTERN_POWER_ON, /**< feedback pattern when power on */
+ FEEDBACK_PATTERN_POWER_OFF, /**< feedback pattern when power off */
+ FEEDBACK_PATTERN_CHARGERCONN, /**< feedback pattern when connecting charger */
+ FEEDBACK_PATTERN_CHARGERCONN_ON_CALL, /**< feedback pattern when connecting charger on call */
+ FEEDBACK_PATTERN_FULLCHARGED, /**< feedback pattern when full charged */
+ FEEDBACK_PATTERN_FULLCHARGED_ON_CALL, /**< feedback pattern when full charged on call */
+ FEEDBACK_PATTERN_LOWBATT, /**< feedback pattern when low battery */
+ FEEDBACK_PATTERN_LOWBATT_ON_CALL, /**< feedback pattern when low battery on call */
+ FEEDBACK_PATTERN_LOCK, /**< feedback pattern when lock */
+ FEEDBACK_PATTERN_UNLOCK, /**< feedback pattern when unlock */
+ FEEDBACK_PATTERN_CALLCONNECT, /**< feedback pattern when connecting call */
+ FEEDBACK_PATTERN_DISCALLCONNECT, /**< feedback pattern when disconnecting call */
+ FEEDBACK_PATTERN_MINUTEMINDER, /**< feedback pattern when minute minder */
+ FEEDBACK_PATTERN_VIBRATION, /**< feedback pattern when vibration */
+ FEEDBACK_PATTERN_SHUTTER, /**< feedback pattern when screen capture or camera shutter */
+ FEEDBACK_PATTERN_LIST_REORDER, /**< feedback pattern when list reorder */
+ FEEDBACK_PATTERN_SLIDER_SWEEP, /**< feedback pattern when slider sweep */
+
+ FEEDBACK_PATTERN_END,
+};
+
+
+} // namespace Dali
+
+#endif // __DALI_FEEDBACK_IDS_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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/feedback/feedback-style.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/object/object-registry.h>
+#include <dali/devel-api/adaptor-framework/style-monitor.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/builder/json-parser.h>
+#include <dali-toolkit/internal/feedback/feedback-ids.h>
+
+using std::string;
+
+namespace // unnamed namespace
+{
+
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::General, false, "LOG_FEEDBACK");
+#endif
+
+const char* DEFAULT_FEEDBACK_THEME_PATH = DALI_STYLE_DIR"default-feedback-theme.json";
+
+// Sets bool and string if the node has a child "name"
+void GetIfString(const Dali::Toolkit::TreeNode& node, const std::string& name, bool& exists, std::string& str)
+{
+ const Dali::Toolkit::TreeNode* child = node.GetChild(name);
+ if( child &&
+ Dali::Toolkit::TreeNode::STRING == child->GetType() )
+ {
+ exists = true;
+ str = child->GetString();
+ }
+}
+
+} // unnamed namespace
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+struct SignalFeedbackInfo
+{
+ /**
+ * Default constructor.
+ */
+ SignalFeedbackInfo()
+ :mHasHapticFeedbackInfo(false),
+ mHasSoundFeedbackInfo(false)
+ {
+ }
+
+ bool mHasHapticFeedbackInfo;
+ bool mHasSoundFeedbackInfo;
+ string mSignalName;
+ string mHapticFeedbackPattern;
+ string mSoundFeedbackPattern;
+ string mHapticFeedbackFile;
+ string mSoundFeedbackFile;
+};
+
+typedef std::vector<SignalFeedbackInfo> SignalFeedbackInfoContainer;
+typedef SignalFeedbackInfoContainer::const_iterator SignalFeedbackInfoConstIter;
+
+struct FeedbackStyleInfo
+{
+ /**
+ * Default constructor.
+ */
+ FeedbackStyleInfo()
+ {
+ }
+
+ string mTypeName;
+
+ SignalFeedbackInfoContainer mSignalFeedbackInfoList;
+};
+
+static const FeedbackStyleInfo DEFAULT_FEEDBACK_STYLE_INFO;
+
+FeedbackStyle::FeedbackStyle()
+: mConnections( this )
+{
+ mFeedback = Dali::FeedbackPlayer::Get();
+
+ string defaultTheme;
+
+ if( mFeedback && mFeedback.LoadFile( DEFAULT_FEEDBACK_THEME_PATH, defaultTheme ) )
+ {
+ LoadTheme( defaultTheme );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceLoader::LoadTheme(%s) - loaded %d bytes\n",
+ DEFAULT_FEEDBACK_THEME_PATH, defaultTheme.size() );
+ }
+ else
+ {
+ DALI_LOG_ERROR("ResourceLoader::LoadTheme(%s) - failed to load\n", DEFAULT_FEEDBACK_THEME_PATH);
+ }
+
+}
+
+FeedbackStyle::~FeedbackStyle()
+{
+}
+
+struct PlayFeedbackFromSignal
+{
+ PlayFeedbackFromSignal( FeedbackStyle& controller, const string& typeName, const string& signalName )
+ : mController( controller ),
+ mTypeName( typeName ),
+ mSignalName( signalName )
+ {
+ }
+
+ void operator()()
+ {
+ mController.PlayFeedback( mTypeName, mSignalName );
+ }
+
+ FeedbackStyle& mController;
+ string mTypeName;
+ string mSignalName;
+};
+
+
+void FeedbackStyle::ObjectCreated( BaseHandle handle )
+{
+ std::string typeName = handle.GetTypeName();
+
+ if( handle )
+ {
+ string type = handle.GetTypeName();
+
+ const FeedbackStyleInfo styleInfo = GetStyleInfo( type );
+
+ for( SignalFeedbackInfoConstIter iter = styleInfo.mSignalFeedbackInfoList.begin(); iter != styleInfo.mSignalFeedbackInfoList.end(); ++iter )
+ {
+ const SignalFeedbackInfo& info = *iter;
+
+ if( info.mHasHapticFeedbackInfo || info.mHasSoundFeedbackInfo )
+ {
+ if( !info.mHapticFeedbackPattern.empty() || !info.mHapticFeedbackFile.empty() ||
+ !info.mSoundFeedbackPattern.empty() || !info.mSoundFeedbackFile.empty() )
+ {
+ handle.ConnectSignal( this,
+ info.mSignalName,
+ PlayFeedbackFromSignal( *this, type, info.mSignalName ) );
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FeedbackStyle::Set found Haptic pattern %s for Object type: %s, Signal Type: %s\n",
+ info.mHapticFeedbackPattern.c_str(), type.c_str(), info.mSignalName.c_str() );
+ }
+ else
+ {
+ DALI_LOG_ERROR("FeedbackStyle::Set() Warning Inconsistent data in theme file!\n");
+ }
+ }
+ }
+ }
+}
+
+const FeedbackStyleInfo& FeedbackStyle::GetStyleInfo( const string& type ) const
+{
+ std::map<const string, FeedbackStyleInfo>::const_iterator iter( mStyleInfoLut.find( type ) );
+ if( iter != mStyleInfoLut.end() )
+ {
+ return iter->second;
+ }
+ else
+ {
+ return DEFAULT_FEEDBACK_STYLE_INFO;
+ }
+}
+
+void FeedbackStyle::StyleChanged( const std::string& userDefinedThemePath, Dali::StyleChange::Type styleChange )
+{
+ if( StyleChange::THEME_CHANGE )
+ {
+ string userDefinedTheme;
+
+ if( mFeedback && mFeedback.LoadFile( userDefinedThemePath, userDefinedTheme ) )
+ {
+ if( !LoadTheme( userDefinedTheme ) )
+ {
+ DALI_LOG_ERROR("FeedbackStyle::StyleChanged() User defined theme failed to load! \n");
+
+ //If there is any problem is using the user defined theme, then fall back to default theme
+ if( !LoadTheme( DEFAULT_FEEDBACK_THEME_PATH ) )
+ {
+ //If the default theme fails, Then No luck!
+ DALI_LOG_ERROR("FeedbackStyle::StyleChanged() Default theme failed to load! \n");
+ }
+ }
+ else
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceLoader::LoadTheme(%s) - loaded %d bytes\n",
+ userDefinedThemePath.c_str(), userDefinedTheme.size() );
+ }
+ }
+ else
+ {
+ DALI_LOG_ERROR("ResourceLoader::LoadTheme(%s) - failed to load\n", userDefinedThemePath.c_str());
+ }
+ }
+}
+
+bool FeedbackStyle::LoadTheme( const string& data )
+{
+ bool result = false;
+
+ try
+ {
+ LoadFromString( data );
+
+ result = true;
+ }
+ catch(...)
+ {
+ //Problem in user set theme, So fallback to use default theme.
+ DALI_LOG_ERROR( "FeedbackStyle::LoadTheme() Failed to load theme\n" );
+ }
+
+ return result;
+}
+
+void FeedbackStyle::LoadFromString( const string& data )
+{
+ Toolkit::JsonParser parser = Toolkit::JsonParser::New();
+ const Toolkit::TreeNode* root = NULL;
+
+ if( !parser.Parse( data ) )
+ {
+ DALI_LOG_WARNING( "JSON Parse Error:'%s'\n", parser.GetErrorDescription().c_str() );
+ DALI_LOG_WARNING( "JSON Parse Line :'%d (%d)'\n",
+ parser.GetErrorLineNumber(),
+ parser.GetErrorColumn() );
+ }
+ else
+ {
+ root = parser.GetRoot();
+ }
+
+ if(root)
+ {
+ // Clear previously loaded style
+ mStyleInfoLut.clear();
+
+ // Parse style
+ if( const TreeNode* node = root->GetChild("style") )
+ {
+ Toolkit::TreeNode::ConstIterator iter = node->CBegin();
+ Toolkit::TreeNode::ConstIterator end = node->CEnd();
+ for( ; iter != end; ++iter )
+ {
+ const char* key = (*iter).first;
+ FeedbackStyleInfo themeInfo;
+ themeInfo.mTypeName = key;
+
+ if( const TreeNode* signals = (*iter).second.GetChild("signals") )
+ {
+ TreeNode::ConstIterator signalIter = signals->CBegin();
+ TreeNode::ConstIterator signalEnd = signals->CEnd();
+ for( ; signalIter != signalEnd; ++signalIter )
+ {
+ SignalFeedbackInfo signalFeedbackInfo;
+
+ const TreeNode* type = (*signalIter).second.GetChild("type");
+ DALI_ASSERT_ALWAYS(type && TreeNode::STRING == type->GetType() && "Signal must have a type");
+ signalFeedbackInfo.mSignalName = type->GetString();
+
+ GetIfString( (*signalIter).second, "haptic-feedback-pattern",
+ signalFeedbackInfo.mHasHapticFeedbackInfo,
+ signalFeedbackInfo.mHapticFeedbackPattern );
+
+ GetIfString( (*signalIter).second, "haptic-feedback-file",
+ signalFeedbackInfo.mHasHapticFeedbackInfo,
+ signalFeedbackInfo.mHapticFeedbackFile );
+
+ GetIfString( (*signalIter).second, "sound-feedback-pattern",
+ signalFeedbackInfo.mHasSoundFeedbackInfo,
+ signalFeedbackInfo.mSoundFeedbackPattern );
+
+ GetIfString( (*signalIter).second, "haptic-feedback-file",
+ signalFeedbackInfo.mHasSoundFeedbackInfo,
+ signalFeedbackInfo.mSoundFeedbackFile );
+
+ if( signalFeedbackInfo.mHasHapticFeedbackInfo || signalFeedbackInfo.mHasSoundFeedbackInfo )
+ {
+ AddSignalInfo( themeInfo, signalFeedbackInfo );
+ }
+ }
+ }
+
+ mStyleInfoLut[key] = themeInfo;
+
+ } // for styles
+ } // if(style)
+ } // if(root)
+
+} // LoadFromString()
+
+void FeedbackStyle::AddSignalInfo( FeedbackStyleInfo& styleInfo, SignalFeedbackInfo signalInfo )
+{
+ bool updated = false;
+ std::vector<SignalFeedbackInfo>::iterator iter;
+
+ // If info exists for the signal then update it, else add new
+ for( iter = styleInfo.mSignalFeedbackInfoList.begin(); iter != styleInfo.mSignalFeedbackInfoList.end(); ++iter )
+ {
+ if( (*iter).mSignalName == signalInfo.mSignalName )
+ {
+ (*iter).mHasHapticFeedbackInfo = signalInfo.mHasHapticFeedbackInfo;
+ (*iter).mHapticFeedbackPattern = signalInfo.mHapticFeedbackPattern;
+ (*iter).mHapticFeedbackFile = signalInfo.mHapticFeedbackFile;
+ (*iter).mHasSoundFeedbackInfo = signalInfo.mHasSoundFeedbackInfo;
+ (*iter).mSoundFeedbackPattern = signalInfo.mSoundFeedbackPattern;
+ (*iter).mSoundFeedbackFile = signalInfo.mSoundFeedbackFile;
+
+ updated = true;
+ break;
+ }
+ }
+
+ if( !updated )
+ {
+ styleInfo.mSignalFeedbackInfoList.push_back( signalInfo );
+ }
+}
+
+void FeedbackStyle::PlayFeedback(const string& type, const string& signalName)
+{
+ const FeedbackStyleInfo styleInfo = GetStyleInfo(type);
+ SignalFeedbackInfoConstIter iter;
+
+ for(iter = styleInfo.mSignalFeedbackInfoList.begin(); iter != styleInfo.mSignalFeedbackInfoList.end(); ++iter)
+ {
+ const SignalFeedbackInfo& info = *iter;
+
+ if(info.mSignalName == signalName)
+ {
+ if(info.mHasHapticFeedbackInfo)
+ {
+ if(!info.mHapticFeedbackPattern.empty())
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FeedbackStyle::PlayFeedback Playing Haptic effect: Object type: %s, Signal type: %s, pattern type: %s\n",
+ type.c_str(), signalName.c_str(), info.mHapticFeedbackPattern.c_str());
+
+ mFeedback.PlayFeedbackPattern( FEEDBACK_TYPE_VIBRATION, GetFeedbackPattern(info.mHapticFeedbackPattern) );
+ }
+ else if(!info.mHapticFeedbackFile.empty())
+ {
+ mFeedback.PlayFile( info.mHapticFeedbackFile );
+ }
+ }
+
+ if(info.mHasSoundFeedbackInfo)
+ {
+ if(!info.mSoundFeedbackPattern.empty())
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FeedbackStyle::PlayFeedback Playing Sound effect: Object type: %s, Signal type: %s, pattern type: %s\n",
+ type.c_str(), signalName.c_str(), info.mHapticFeedbackPattern.c_str());
+
+ mFeedback.PlayFeedbackPattern( FEEDBACK_TYPE_SOUND, GetFeedbackPattern(info.mSoundFeedbackPattern) );
+ }
+ else if(!info.mSoundFeedbackFile.empty())
+ {
+ mFeedback.PlaySound( info.mSoundFeedbackFile );
+ }
+ }
+
+ break;
+ }
+ }
+}
+
+FeedbackPattern FeedbackStyle::GetFeedbackPattern( const string &pattern )
+{
+ if( 0 == mFeedbackPatternLut.size() )
+ {
+ mFeedbackPatternLut["FEEDBACK_PATTERN_NONE"] = Dali::FEEDBACK_PATTERN_NONE;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_TAP"] = Dali::FEEDBACK_PATTERN_TAP;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_SIP"] = Dali::FEEDBACK_PATTERN_SIP;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_SIP_BACKSPACE"] = Dali::FEEDBACK_PATTERN_SIP_BACKSPACE;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_MAX_CHARACTER"] = Dali::FEEDBACK_PATTERN_MAX_CHARACTER;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY0"] = Dali::FEEDBACK_PATTERN_KEY0;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY1"] = Dali::FEEDBACK_PATTERN_KEY1;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY2"] = Dali::FEEDBACK_PATTERN_KEY2;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY3"] = Dali::FEEDBACK_PATTERN_KEY3;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY4"] = Dali::FEEDBACK_PATTERN_KEY4;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY5"] = Dali::FEEDBACK_PATTERN_KEY5;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY6"] = Dali::FEEDBACK_PATTERN_KEY6;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY7"] = Dali::FEEDBACK_PATTERN_KEY7;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY8"] = Dali::FEEDBACK_PATTERN_KEY8;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY9"] = Dali::FEEDBACK_PATTERN_KEY9;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY_STAR"] = Dali::FEEDBACK_PATTERN_KEY_STAR;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY_SHARP"] = Dali::FEEDBACK_PATTERN_KEY_SHARP;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_HOLD"] = Dali::FEEDBACK_PATTERN_HOLD;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_MULTI_TAP"] = Dali::FEEDBACK_PATTERN_MULTI_TAP;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_HW_TAP"] = Dali::FEEDBACK_PATTERN_HW_TAP;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_HW_HOLD"] = Dali::FEEDBACK_PATTERN_HW_HOLD;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_MESSAGE"] = Dali::FEEDBACK_PATTERN_MESSAGE;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_MESSAGE_ON_CALL"] = Dali::FEEDBACK_PATTERN_MESSAGE_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_EMAIL"] = Dali::FEEDBACK_PATTERN_EMAIL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_EMAIL_ON_CALL"] = Dali::FEEDBACK_PATTERN_EMAIL_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_WAKEUP"] = Dali::FEEDBACK_PATTERN_WAKEUP;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_WAKEUP_ON_CALL"] = Dali::FEEDBACK_PATTERN_WAKEUP_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_SCHEDULE"] = Dali::FEEDBACK_PATTERN_SCHEDULE;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_SCHEDULE_ON_CALL"] = Dali::FEEDBACK_PATTERN_SCHEDULE_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_TIMER"] = Dali::FEEDBACK_PATTERN_TIMER;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_TIMER_ON_CALL"] = Dali::FEEDBACK_PATTERN_TIMER_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_GENERAL"] = Dali::FEEDBACK_PATTERN_GENERAL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_GENERAL_ON_CALL"] = Dali::FEEDBACK_PATTERN_GENERAL_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_POWER_ON"] = Dali::FEEDBACK_PATTERN_POWER_ON;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_POWER_OFF"] = Dali::FEEDBACK_PATTERN_POWER_OFF;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_CHARGERCONN"] = Dali::FEEDBACK_PATTERN_CHARGERCONN;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_CHARGERCONN_ON_CALL"] = Dali::FEEDBACK_PATTERN_CHARGERCONN_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_FULLCHARGED"] = Dali::FEEDBACK_PATTERN_FULLCHARGED;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_FULLCHARGED_ON_CALL"] = Dali::FEEDBACK_PATTERN_FULLCHARGED_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_LOWBATT"] = Dali::FEEDBACK_PATTERN_LOWBATT;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_LOWBATT_ON_CALL"] = Dali::FEEDBACK_PATTERN_LOWBATT_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_LOCK"] = Dali::FEEDBACK_PATTERN_LOCK;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_UNLOCK"] = Dali::FEEDBACK_PATTERN_UNLOCK;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_CALLCONNECT"] = Dali::FEEDBACK_PATTERN_CALLCONNECT;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_DISCALLCONNECT"] = Dali::FEEDBACK_PATTERN_DISCALLCONNECT;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_MINUTEMINDER"] = Dali::FEEDBACK_PATTERN_MINUTEMINDER;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_VIBRATION"] = Dali::FEEDBACK_PATTERN_VIBRATION;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_SHUTTER"] = Dali::FEEDBACK_PATTERN_SHUTTER;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_LIST_REORDER"] = Dali::FEEDBACK_PATTERN_LIST_REORDER;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_SLIDER_SWEEP"] = Dali::FEEDBACK_PATTERN_SLIDER_SWEEP;
+ }
+
+ std::map<const string, FeedbackPattern>::const_iterator iter( mFeedbackPatternLut.find( pattern ) );
+
+ if( iter != mFeedbackPatternLut.end() )
+ {
+ return iter->second;
+ }
+ else
+ {
+ DALI_LOG_ERROR( "Unknown feedback pattern type: %s, So Defaulting to FEEDBACK_PATTERN_NONE!\n" );
+ return Dali::FEEDBACK_PATTERN_NONE;
+ }
+}
+
+} // namespace Toolkit
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_FEEDBACK_STYLE_H__
+#define __DALI_INTERNAL_FEEDBACK_STYLE_H__
+
+/*
+ * Copyright (c) 2014 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 <map>
+#include <dali/public-api/object/base-handle.h>
+#include <dali/devel-api/adaptor-framework/feedback-player.h>
+#include <dali/public-api/signals/connection-tracker.h>
+#include <dali/public-api/adaptor-framework/style-change.h>
+#include <dali/public-api/signals/slot-delegate.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/feedback/feedback-ids.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+struct FeedbackStyleInfo;
+struct SignalFeedbackInfo;
+
+/**
+ * Plays feedback effects for Dali-Toolkit UI Controls.
+ *
+ * This functionality relies on an adaptor plugin.
+ * (And will have no effect if this is not loaded)
+ *
+ */
+class FeedbackStyle : public ConnectionTracker
+{
+public:
+
+ /**
+ * Constructor.
+ */
+ FeedbackStyle();
+
+ /**
+ * The destructor
+ */
+ ~FeedbackStyle();
+
+ /**
+ * Called to start playing feedback effects.
+ */
+ void Start();
+
+ /**
+ * Called to stop playing feedback effects.
+ */
+ void Stop();
+
+ /**
+ * Callback function to play a feedback effect when a signal is emitted for an object
+ * Plays feedback effect.
+ * @param [in] type The Object type
+ * @param [in] signalName The name of the signal
+ */
+ void PlayFeedback(const std::string& type, const std::string& signalName);
+
+ /**
+ * Connects feedback to signals for the newly created object
+ * @param [in] object Handle to the newly created object
+ */
+ void ObjectCreated( BaseHandle object );
+
+ /**
+ * Style changed so reload the theme file
+ * @param [in] userDefinedThemePath Theme filename path
+ * @param [in] styleChange The type of style change
+ */
+ void StyleChanged(const std::string& userDefinedThemePath, StyleChange::Type styleChange);
+
+private:
+
+ /**
+ * Helper to retrieve styleInfo from mStyleInfoLut
+ * @param type A string described a type of object
+ * @return The style information for the given object
+ */
+ const FeedbackStyleInfo& GetStyleInfo( const std::string& type) const;
+
+ /**
+ * Callback function for Dali::Toolkit::PushButton::SignalPressed signal
+ * Plays feedback effect.
+ * @param [in] effect The feedback effect to play
+ */
+ bool LoadTheme(const std::string& data);
+
+ /**
+ * Loads a string representation the theme.
+ * @param [in] data A string represenation of the theme.
+ * @param [in] format The string representation format ie JSON.
+ */
+ void LoadFromString( const std::string& data );
+
+ /**
+ * Helper to store signal information.
+ * @param [in] styleInfo The information will be stored here.
+ * @param [in] signalInfo The information to add.
+ */
+ void AddSignalInfo( FeedbackStyleInfo& styleInfo, SignalFeedbackInfo signalInfo );
+
+ /**
+ * Map a pattern string to feedback pattern ID.
+ * @param [in] pattern The pattern string.
+ * @return A feedback pattern ID.
+ */
+ FeedbackPattern GetFeedbackPattern( const std::string& pattern );
+
+ /**
+ * Plays a feedback effect
+ * @param [in] type The feedback type haptic or sound
+ * @param [in] effect The feedback effect to play
+ */
+ void PlayEffect(FeedbackType type, FeedbackPattern effect);
+
+ /**
+ * Plays a haptic or sound effect file
+ * @param [in] type The feedback type haptic or sound
+ * @param [in] file The path to the file containing the effect
+ */
+ void PlayFile(FeedbackType type, const std::string& file);
+
+private:
+ Dali::FeedbackPlayer mFeedback;
+
+ std::map<const std::string, FeedbackPattern> mFeedbackPatternLut; ///< Used to convert feedback pattern strings into enumerated values
+ std::map<const std::string, FeedbackStyleInfo> mStyleInfoLut; ///< Converts key strings into style information
+
+ SlotDelegate< FeedbackStyle > mConnections; ///< Maintains the connections to the Object registry.
+};
+
+} // namespace Toolkit
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_FEEDBACK_STYLE_H__
$(toolkit_src_dir)/controls/text-controls/text-selection-toolbar-impl.cpp \
$(toolkit_src_dir)/controls/tool-bar/tool-bar-impl.cpp \
$(toolkit_src_dir)/accessibility-manager/accessibility-manager-impl.cpp \
+ \
+ $(toolkit_src_dir)/feedback/feedback-style.cpp \
+ \
$(toolkit_src_dir)/focus-manager/keyboard-focus-manager-impl.cpp \
$(toolkit_src_dir)/focus-manager/keyinput-focus-manager-impl.cpp \
$(toolkit_src_dir)/filters/blur-two-pass-filter.cpp \
#include <dali-toolkit/public-api/controls/control.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/devel-api/styling/style-manager.h>
+#include <dali-toolkit/internal/feedback/feedback-style.h>
namespace
{
StyleManager::StyleManager()
: mOrientationDegrees( 0 ), // Portrait
mDefaultFontSize( -1 ),
- mThemeFile( DEFAULT_THEME )
+ mThemeFile( DEFAULT_THEME ),
+ mFeedbackStyle( NULL )
{
// Add theme builder constants
mThemeBuilderConstants[ PACKAGE_PATH_KEY ] = DEFAULT_PACKAGE_PATH;
mDefaultFontSize = mStyleMonitor.GetDefaultFontSize();
}
+
+ // Sound & haptic style
+ mFeedbackStyle = new FeedbackStyle();
+
}
StyleManager::~StyleManager()
{
+ delete mFeedbackStyle;
}
void StyleManager::SetOrientationValue( int orientation )
void StyleManager::ApplyStyle( Toolkit::Builder builder, Toolkit::Control control )
{
std::string styleName = control.GetStyleName();
+
if( styleName.empty() )
{
// Convert control name to lower case
void StyleManager::ApplyThemeStyle( Toolkit::Control control )
{
+ if( !mThemeBuilder )
+ {
+ RequestDefaultTheme();
+ }
+
+ if( mThemeBuilder )
+ {
+ ApplyStyle( mThemeBuilder, control );
+ }
+}
+
+void StyleManager::ApplyThemeStyleAtInit( Toolkit::Control control )
+{
if( mThemeBuilder )
{
ApplyStyle( mThemeBuilder, control );
}
+
+ if(mFeedbackStyle)
+ {
+ mFeedbackStyle->ObjectCreated( control );
+ }
}
void StyleManager::ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName )
void StyleManager::SetTheme()
{
mThemeBuilder = CreateBuilder( mThemeBuilderConstants );
- if ( LoadJSON( mThemeBuilder, mThemeFile ) )
+
+ if( LoadJSON( mThemeBuilder, mThemeFile ) )
{
+ if(mFeedbackStyle)
+ {
+ mFeedbackStyle->StyleChanged( mThemeFile, StyleChange::THEME_CHANGE );
+ }
+
mStyleChangeSignal.Emit( Toolkit::StyleManager::Get(), StyleChange::THEME_CHANGE );
}
else
namespace Internal
{
+
+class FeedbackStyle;
+
/**
* @copydoc Toolkit::StyleManager
*/
void ApplyThemeStyle( Toolkit::Control control );
/**
+ * @brief Apply the theme style to a control at initialization.
+ *
+ * @param[in] control The control to apply style.
+ */
+ void ApplyThemeStyleAtInit( Toolkit::Control control );
+
+ /**
* @copydoc Toolkit::StyleManager::ApplyStyle
*/
void ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName );
BuilderMap mBuilderCache; ///< Cache of builders keyed by JSON file name
+ Toolkit::Internal::FeedbackStyle* mFeedbackStyle; ///< Feedback style
+
// Signals
Toolkit::StyleManager::StyleChangeSignalType mStyleChangeSignal; ///< Emitted when the style( theme/font ) changes
};
mScrollThreshold( SCROLL_THRESHOLD ),
mScrollSpeed( SCROLL_SPEED ),
mScrollDistance( SCROLL_DISTANCE ),
+ mTextDepth( 0u ),
mActiveCopyPastePopup( false ),
mCursorBlinkStatus( true ),
mPrimaryCursorVisible( false ),
mNotifyEndOfScroll( false )
{
mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
- mQuadIndexFormat[ "indices" ] = Property::UNSIGNED_INTEGER;
+ mQuadIndexFormat[ "indices" ] = Property::INTEGER;
mHighlightMaterial = Material::New( Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ) );
}
// Show or hide the cursors
CreateCursors();
+
if( mPrimaryCursor )
{
const CursorImpl& cursor = mCursor[PRIMARY_CURSOR];
CreateGrabHandle();
grabHandle.actor.SetPosition( position.x,
- position.y + grabHandle.lineHeight );
+ grabHandle.lineHeight ); // TODO : Fix for multiline.
}
grabHandle.actor.SetVisible( isVisible );
}
if( isPrimaryVisible )
{
primary.actor.SetPosition( primaryPosition.x,
- primaryPosition.y + primary.lineHeight );
+ primary.lineHeight ); // TODO : Fix for multiline.
}
if( isSecondaryVisible )
{
secondary.actor.SetPosition( secondaryPosition.x,
- secondaryPosition.y + secondary.lineHeight );
+ secondary.lineHeight ); // TODO : Fix for multiline.
}
}
primary.actor.SetVisible( isPrimaryVisible );
mQuadVertices.SetData( &vertices[ 0 ] );
mQuadIndices.SetData( &indices[ 0 ] );
- mQuadGeometry = Geometry::New();
- mQuadGeometry.AddVertexBuffer( mQuadVertices );
- mQuadGeometry.SetIndexBuffer( mQuadIndices );
-
- if( mHighlightRenderer )
+ if( !mQuadGeometry )
{
- mHighlightRenderer.SetGeometry( mQuadGeometry );
+ mQuadGeometry = Geometry::New();
+ mQuadGeometry.AddVertexBuffer( mQuadVertices );
}
- else
+ mQuadGeometry.SetIndexBuffer( mQuadIndices );
+
+ if( !mHighlightRenderer )
{
mHighlightRenderer = Dali::Renderer::New( mQuadGeometry, mHighlightMaterial );
mHighlightActor.AddRenderer( mHighlightRenderer );
}
-
- mHighlightActor.SetPosition( mHighlightPosition.x,
- mHighlightPosition.y );
}
+ mHighlightActor.SetPosition( mHighlightPosition.x,
+ mHighlightPosition.y );
+
+ mHighlightQuadList.clear();
+
mHighlightRenderer.SetDepthIndex( mTextDepth - 2u ); // text is rendered at mTextDepth and text's shadow at mTextDepth -1u.
}
}
if( mImpl->mActiveLayer )
{
mImpl->mActiveLayer.Add( mImpl->mCopyPastePopup.actor );
+ mImpl->mCopyPastePopup.actor.ShowPopup();
}
}
// Get the glyph info.
const GlyphInfo& glyphInfo = *( parameters.glyphsBuffer + glyphIndex );
+ // Check if the font of the current glyph is the same of the previous one.
+ // If it's different the ascender and descender need to be updated.
+ if( lastFontId != glyphInfo.fontId )
+ {
+ UpdateLineHeight( glyphInfo.fontId, tmpLineLayout );
+ lastFontId = glyphInfo.fontId;
+ }
+
// Get the character indices for the current glyph. The last character index is needed
// because there are glyphs formed by more than one character but their break info is
// given only for the last character.
tmpLineLayout.Clear();
}
- // Check if the font of the current glyph is the same of the previous one.
- // If it's different the ascender and descender need to be updated.
- if( lastFontId != glyphInfo.fontId )
- {
- UpdateLineHeight( glyphInfo.fontId, tmpLineLayout );
- lastFontId = glyphInfo.fontId;
- }
-
previousCharacterDirection = characterDirection;
}
// EXTERNAL INCLUDES
#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/common/stage.h>
+#include <dali/integration-api/debug.h>
#define MAKE_SHADER(A)#A
namespace
{
+
+#if defined(DEBUG_ENABLED)
+ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_RENDERING");
+#endif
+
const char* VERTEX_SHADER = MAKE_SHADER(
attribute mediump vec2 aPosition;
attribute mediump vec2 aTexCoord;
gl_FragColor = vec4(uColor.rgb, uColor.a*color.r);
}
);
-}
+
+} // unnamed namespace
namespace Dali
{
mShadowShader = Shader::New( VERTEX_SHADER_SHADOW, FRAGMENT_SHADER_SHADOW, Dali::Shader::HINT_MODIFIES_GEOMETRY );
}
-AtlasGlyphManager::~AtlasGlyphManager()
-{
- // Clear up any remaining references
- for ( std::vector< FontGlyphRecord >::iterator fontGlyphRecordIt = mFontGlyphRecords.begin();
- fontGlyphRecordIt != mFontGlyphRecords.end();
- ++fontGlyphRecordIt )
- {
- for ( Vector< GlyphRecordEntry >::Iterator glyphRecordEntryIt = fontGlyphRecordIt->mGlyphRecords.Begin();
- glyphRecordEntryIt != fontGlyphRecordIt->mGlyphRecords.End();
- ++glyphRecordEntryIt )
- {
- mAtlasManager.Remove( glyphRecordEntryIt->mImageId );
- }
- }
-}
-
-AtlasGlyphManagerPtr AtlasGlyphManager::New()
-{
- AtlasGlyphManagerPtr internal = new AtlasGlyphManager();
- return internal;
-}
-
void AtlasGlyphManager::Add( const Text::GlyphInfo& glyph,
const BufferImage& bitmap,
Dali::Toolkit::AtlasManager::AtlasSlot& slot )
{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Added glyph, font: %d index: %d\n", glyph.fontId, glyph.index );
+
mAtlasManager.Add( bitmap, slot );
GlyphRecordEntry record;
}
bool AtlasGlyphManager::Cached( Text::FontId fontId,
- uint32_t index,
+ Text::GlyphIndex index,
Dali::Toolkit::AtlasManager::AtlasSlot& slot )
{
for ( std::vector< FontGlyphRecord >::iterator fontGlyphRecordIt = mFontGlyphRecords.begin();
const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
{
+ std::ostringstream verboseMetrics;
+
mMetrics.mGlyphCount = 0u;
for ( std::vector< FontGlyphRecord >::iterator fontGlyphRecordIt = mFontGlyphRecords.begin();
fontGlyphRecordIt != mFontGlyphRecords.end();
++fontGlyphRecordIt )
{
mMetrics.mGlyphCount += fontGlyphRecordIt->mGlyphRecords.Size();
+
+ verboseMetrics << "[FontId " << fontGlyphRecordIt->mFontId << " Glyph ";
+ for ( Vector< GlyphRecordEntry >::Iterator glyphRecordEntryIt = fontGlyphRecordIt->mGlyphRecords.Begin();
+ glyphRecordEntryIt != fontGlyphRecordIt->mGlyphRecords.End();
+ ++glyphRecordEntryIt )
+ {
+ verboseMetrics << glyphRecordEntryIt->mIndex << "(" << glyphRecordEntryIt->mCount << ") ";
+ }
+ verboseMetrics << "] ";
}
+ mMetrics.mVerboseGlyphCounts = verboseMetrics.str();
+
mAtlasManager.GetMetrics( mMetrics.mAtlasMetrics );
+
return mMetrics;
}
-void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, uint32_t imageId, int32_t delta )
+void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta )
{
- for ( std::vector< FontGlyphRecord >::iterator fontGlyphRecordIt = mFontGlyphRecords.begin();
- fontGlyphRecordIt != mFontGlyphRecords.end();
- ++fontGlyphRecordIt )
+ if( 0 != delta )
{
- if ( fontGlyphRecordIt->mFontId == fontId )
+ DALI_LOG_INFO( gLogFilter, Debug::General, "AdjustReferenceCount %d, font: %d index: %d\n", delta, fontId, index );
+
+ for ( std::vector< FontGlyphRecord >::iterator fontGlyphRecordIt = mFontGlyphRecords.begin();
+ fontGlyphRecordIt != mFontGlyphRecords.end();
+ ++fontGlyphRecordIt )
{
- for ( Vector< GlyphRecordEntry >::Iterator glyphRecordIt = fontGlyphRecordIt->mGlyphRecords.Begin();
- glyphRecordIt != fontGlyphRecordIt->mGlyphRecords.End();
- ++glyphRecordIt )
+ if ( fontGlyphRecordIt->mFontId == fontId )
{
- if ( glyphRecordIt->mImageId == imageId )
+ for ( Vector< GlyphRecordEntry >::Iterator glyphRecordIt = fontGlyphRecordIt->mGlyphRecords.Begin();
+ glyphRecordIt != fontGlyphRecordIt->mGlyphRecords.End();
+ ++glyphRecordIt )
{
- glyphRecordIt->mCount += delta;
- if ( !glyphRecordIt->mCount )
+ if ( glyphRecordIt->mIndex == index )
{
- mAtlasManager.Remove( glyphRecordIt->mImageId );
- fontGlyphRecordIt->mGlyphRecords.Remove( glyphRecordIt );
+ glyphRecordIt->mCount += delta;
+ DALI_ASSERT_DEBUG( glyphRecordIt->mCount >= 0 && "Glyph ref-count should not be negative" );
+
+ if ( !glyphRecordIt->mCount )
+ {
+ mAtlasManager.Remove( glyphRecordIt->mImageId );
+ fontGlyphRecordIt->mGlyphRecords.Remove( glyphRecordIt );
+ }
+ return;
}
- return;
}
}
}
+
+ // Should not arrive here
+ DALI_ASSERT_DEBUG( false && "Failed to adjust ref-count" );
}
}
return mAtlasManager.GetSampler( atlasId );
}
+AtlasGlyphManager::~AtlasGlyphManager()
+{
+ // mAtlasManager handle is automatically released here
+}
+
} // namespace Internal
} // namespace Toolkit
Vector< GlyphRecordEntry > mGlyphRecords;
};
- AtlasGlyphManager();
-
- virtual ~AtlasGlyphManager();
-
-/**
- * Create a new AtlasGlyphManager
+ /**
+ * @brief Constructor
*/
- static AtlasGlyphManagerPtr New();
+ AtlasGlyphManager();
/**
* @copydoc Toolkit::AtlasGlyphManager::Add
/**
* @copydoc toolkit::AtlasGlyphManager::AdjustReferenceCount
*/
- void AdjustReferenceCount( Text::FontId fontId, uint32_t imageId, int32_t delta );
+ void AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta );
/**
* @copydoc Toolkit::AtlasGlyphManager::GetMaterial
return mShadowShader;
}
+protected:
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~AtlasGlyphManager();
+
private:
Dali::Toolkit::AtlasManager mAtlasManager; ///> Atlas Manager created by GlyphManager
return GetImplementation(*this).GetMetrics();
}
-void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, uint32_t imageId, int32_t delta )
+void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta )
{
- GetImplementation(*this).AdjustReferenceCount( fontId, imageId, delta );
+ GetImplementation(*this).AdjustReferenceCount( fontId, index, delta );
}
Shader AtlasGlyphManager::GetEffectBufferShader() const
~Metrics()
{}
- uint32_t mGlyphCount; // number of glyphs being managed
- AtlasManager::Metrics mAtlasMetrics; // metrics from the Atlas Manager
+ uint32_t mGlyphCount; ///< number of glyphs being managed
+ std::string mVerboseGlyphCounts; ///< a verbose list of the glyphs + ref counts
+ AtlasManager::Metrics mAtlasMetrics; ///< metrics from the Atlas Manager
};
/**
const Metrics& GetMetrics();
/**
- * @brief Adjust the reference count for an imageId and remove cache entry if it becomes free
+ * @brief Adjust the reference count for glyph
*
- * @param[in] fontId the font this image came from
- * @param[in] imageId The imageId
- * @param[in] delta adjustment to make to reference count
+ * @param[in] fontId The font this image came from
+ * @param[in] index The index of the glyph
+ * @param[in] delta The adjustment to make to the reference count
*/
- void AdjustReferenceCount( Text::FontId fontId, uint32_t imageId, int32_t delta );
+ void AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta );
/**
* @brief Get Shader used for rendering glyph effect buffers
mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
mQuadVertexFormat[ "aTexCoord" ] = Property::VECTOR2;
- mQuadIndexFormat[ "indices" ] = Property::UNSIGNED_INTEGER;
+ mQuadIndexFormat[ "indices" ] = Property::INTEGER;
}
void AddGlyphs( const std::vector<Vector2>& positions,
style = STYLE_DROP_SHADOW;
}
- if ( mTextCache.Size() )
- {
- // Update the glyph cache with any changes to current text
- RemoveText( glyphs );
- }
-
CalculateBlocksSize( glyphs );
+ // Avoid emptying mTextCache (& removing references) until after incremented references for the new text
+ Vector< TextCacheEntry > newTextCache;
+
for( uint32_t i = 0, glyphSize = glyphs.Size(); i < glyphSize; ++i )
{
const GlyphInfo& glyph = glyphs[ i ];
mGlyphManager.Add( glyph, bitmap, slot );
}
}
+ else
+ {
+ // We have 2+ copies of the same glyph
+ mGlyphManager.AdjustReferenceCount( glyph.fontId, glyph.index, 1/*increment*/ );
+ }
// Generate mesh data for this quad, plugging in our supplied position
mGlyphManager.GenerateMeshData( slot.mImageId, position, newMesh );
textCacheEntry.mFontId = glyph.fontId;
textCacheEntry.mImageId = slot.mImageId;
textCacheEntry.mIndex = glyph.index;
- mTextCache.PushBack( textCacheEntry );
+ newTextCache.PushBack( textCacheEntry );
// Find an existing mesh data object to attach to ( or create a new one, if we can't find one using the same atlas)
StitchTextMesh( meshContainer,
}
}
+ // Now remove references for the old text
+ RemoveText();
+ mTextCache.Swap( newTextCache );
+
if ( underlineEnabled )
{
// Check to see if any of the text needs an underline
metrics.mGlyphCount,
metrics.mAtlasMetrics.mAtlasCount,
metrics.mAtlasMetrics.mTextureMemoryUsed / 1024 );
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "%s\n", metrics.mVerboseGlyphCounts.c_str() );
+
for ( uint32_t i = 0; i < metrics.mAtlasMetrics.mAtlasCount; ++i )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Atlas [%i] %sPixels: %s Size: %ix%i, BlockSize: %ix%i, BlocksUsed: %i/%i\n",
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, " Atlas [%i] %sPixels: %s Size: %ix%i, BlockSize: %ix%i, BlocksUsed: %i/%i\n",
i + 1, i > 8 ? "" : " ",
metrics.mAtlasMetrics.mAtlasMetrics[ i ].mPixelFormat == Pixel::L8 ? "L8 " : "BGRA",
metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mWidth,
#endif
}
+ void RemoveText()
+ {
+ for ( Vector< TextCacheEntry >::Iterator oldTextIter = mTextCache.Begin(); oldTextIter != mTextCache.End(); ++oldTextIter )
+ {
+ mGlyphManager.AdjustReferenceCount( oldTextIter->mFontId, oldTextIter->mIndex, -1/*decrement*/ );
+ }
+ mTextCache.Resize( 0 );
+ }
+
Actor CreateMeshActor( const MeshRecord& meshRecord )
{
PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat, meshRecord.mMesh.mVertices.Size() );
}
}
- void RemoveText( const Vector<GlyphInfo>& glyphs )
- {
- Vector< CheckEntry > checked;
- CheckEntry checkEntry;
-
- for ( Vector< TextCacheEntry >::Iterator tCit = mTextCache.Begin(); tCit != mTextCache.End(); ++tCit )
- {
- uint32_t index = tCit->mIndex;
- uint32_t fontId = tCit->mFontId;
-
- // Check that this character has not already been checked...
- bool wasChecked = false;
- for ( Vector< CheckEntry >::Iterator cEit = checked.Begin(); cEit != checked.End(); ++cEit )
- {
- if ( fontId == cEit->mFontId && index == cEit->mIndex )
- {
- wasChecked = true;
- }
- }
-
- if ( !wasChecked )
- {
-
- int32_t newCount = 0;
- int32_t oldCount = 0;
-
- // How many times does this character occur in the old text ?
- for ( Vector< TextCacheEntry >::Iterator oTcit = mTextCache.Begin(); oTcit != mTextCache.End(); ++oTcit )
- {
- if ( fontId == oTcit->mFontId && index == oTcit->mIndex )
- {
- oldCount++;
- }
- }
-
- // And how many times in the new ?
- for ( Vector< GlyphInfo >::Iterator cGit = glyphs.Begin(); cGit != glyphs.End(); ++cGit )
- {
- if ( fontId == cGit->fontId && index == cGit->index )
- {
- newCount++;
- }
- }
- mGlyphManager.AdjustReferenceCount( fontId, tCit->mImageId, newCount - oldCount );
- checkEntry.mIndex = index;
- checkEntry.mFontId = fontId;
- checked.PushBack( checkEntry );
- }
- }
- mTextCache.Resize( 0 );
- }
-
void CalculateBlocksSize( const Vector<GlyphInfo>& glyphs )
{
MaxBlockSize maxBlockSize;
AtlasRenderer::~AtlasRenderer()
{
- Vector< GlyphInfo > emptyGlyphs;
- mImpl->RemoveText( emptyGlyphs );
+ mImpl->RemoveText();
delete mImpl;
}
* @brief Abstract base class for Text renderers.
*
* This is reponsible for rendering the glyphs from a ViewInterface in the specified positions.
- * It is implemented by returning a RenderableActor intended as the child of a UI control.
+ * It is implemented by returning an Actor intended as the child of a UI control.
*/
class Renderer : public RefObject
{
* @param[in] glyphIndex The index to the first glyph.
* @param[in] numberOfGlyphs The number of glyphs.
* @param[out] glyphMetrics Some glyph metrics (font height, advance, ascender and x bearing).
- * @param[in]
- * @param[in]
+ * @param[in] visualModel The visual model.
+ * @param[in] fontClient The font client.
*/
void GetGlyphsMetrics( GlyphIndex glyphIndex,
Length numberOfGlyphs,
if( handleStopScrolling )
{
- mEventData->mUpdateLeftSelectionPosition = ( mEventData->mLeftSelectionPosition != handlePosition ) && ( mEventData->mRightSelectionPosition != handlePosition);
+ mEventData->mUpdateLeftSelectionPosition = ( mEventData->mRightSelectionPosition != handlePosition );
mEventData->mScrollAfterUpdatePosition = mEventData->mUpdateLeftSelectionPosition;
if( mEventData->mUpdateLeftSelectionPosition )
if( handleStopScrolling )
{
- mEventData->mUpdateRightSelectionPosition = ( mEventData->mRightSelectionPosition != handlePosition ) && ( mEventData->mLeftSelectionPosition != handlePosition );
+ mEventData->mUpdateRightSelectionPosition = ( mEventData->mLeftSelectionPosition != handlePosition );
mEventData->mScrollAfterUpdatePosition = mEventData->mUpdateRightSelectionPosition;
-
if( mEventData->mUpdateRightSelectionPosition )
{
mEventData->mRightSelectionPosition = handlePosition;
ClampHorizontalScroll( actualSize );
+ bool endOfScroll = false;
if( Vector2::ZERO == ( currentScrollPosition - mEventData->mScrollPosition ) )
{
// Notify the decorator there is no more text to scroll.
// The decorator won't send more scroll events.
mEventData->mDecorator->NotifyEndOfScroll();
+ // Still need to set the position of the handle.
+ endOfScroll = true;
}
- else
- {
- const bool scrollRightDirection = xSpeed > 0.f;
- const bool leftSelectionHandleEvent = Event::LEFT_SELECTION_HANDLE_EVENT == event.type;
- const bool rightSelectionHandleEvent = Event::RIGHT_SELECTION_HANDLE_EVENT == event.type;
- if( Event::GRAB_HANDLE_EVENT == event.type )
- {
- ChangeState( EventData::GRAB_HANDLE_PANNING );
+ // Set the position of the handle.
+ const bool scrollRightDirection = xSpeed > 0.f;
+ const bool leftSelectionHandleEvent = Event::LEFT_SELECTION_HANDLE_EVENT == event.type;
+ const bool rightSelectionHandleEvent = Event::RIGHT_SELECTION_HANDLE_EVENT == event.type;
- Vector2 position = mEventData->mDecorator->GetPosition( GRAB_HANDLE );
+ if( Event::GRAB_HANDLE_EVENT == event.type )
+ {
+ ChangeState( EventData::GRAB_HANDLE_PANNING );
- // Position the grag handle close to either the left or right edge.
- position.x = scrollRightDirection ? 0.f : mControlSize.width;
+ Vector2 position = mEventData->mDecorator->GetPosition( GRAB_HANDLE );
- // Get the new handle position.
- // The grab handle's position is in decorator coords. Need to transforms to text coords.
- const CharacterIndex handlePosition = GetClosestCursorIndex( position.x - mEventData->mScrollPosition.x - mAlignmentOffset.x,
- position.y - mEventData->mScrollPosition.y - mAlignmentOffset.y );
+ // Position the grag handle close to either the left or right edge.
+ position.x = scrollRightDirection ? 0.f : mControlSize.width;
- mEventData->mUpdateCursorPosition = mEventData->mPrimaryCursorPosition != handlePosition;
- mEventData->mScrollAfterUpdatePosition = mEventData->mUpdateCursorPosition;
- mEventData->mPrimaryCursorPosition = handlePosition;
- }
- else if( leftSelectionHandleEvent || rightSelectionHandleEvent )
- {
- // TODO: This is recalculating the selection box every time the text is scrolled with the selection handles.
- // Think if something can be done to save power.
+ // Get the new handle position.
+ // The grab handle's position is in decorator coords. Need to transforms to text coords.
+ const CharacterIndex handlePosition = GetClosestCursorIndex( position.x - mEventData->mScrollPosition.x - mAlignmentOffset.x,
+ position.y - mEventData->mScrollPosition.y - mAlignmentOffset.y );
- ChangeState( EventData::SELECTION_HANDLE_PANNING );
+ mEventData->mUpdateCursorPosition = mEventData->mPrimaryCursorPosition != handlePosition;
+ mEventData->mScrollAfterUpdatePosition = mEventData->mUpdateCursorPosition;
+ mEventData->mPrimaryCursorPosition = handlePosition;
+ }
+ else if( leftSelectionHandleEvent || rightSelectionHandleEvent )
+ {
+ // TODO: This is recalculating the selection box every time the text is scrolled with the selection handles.
+ // Think if something can be done to save power.
- Vector2 position = mEventData->mDecorator->GetPosition( leftSelectionHandleEvent ? Text::LEFT_SELECTION_HANDLE : Text::RIGHT_SELECTION_HANDLE );
+ ChangeState( EventData::SELECTION_HANDLE_PANNING );
- // Position the selection handle close to either the left or right edge.
- position.x = scrollRightDirection ? 0.f : mControlSize.width;
+ Vector2 position = mEventData->mDecorator->GetPosition( leftSelectionHandleEvent ? Text::LEFT_SELECTION_HANDLE : Text::RIGHT_SELECTION_HANDLE );
- // Get the new handle position.
- // The selection handle's position is in decorator coords. Need to transforms to text coords.
- const CharacterIndex handlePosition = GetClosestCursorIndex( position.x - mEventData->mScrollPosition.x - mAlignmentOffset.x,
- position.y - mEventData->mScrollPosition.y - mAlignmentOffset.y );
+ // Position the selection handle close to either the left or right edge.
+ position.x = scrollRightDirection ? 0.f : mControlSize.width;
- if( leftSelectionHandleEvent )
+ // Get the new handle position.
+ // The selection handle's position is in decorator coords. Need to transforms to text coords.
+ const CharacterIndex handlePosition = GetClosestCursorIndex( position.x - mEventData->mScrollPosition.x - mAlignmentOffset.x,
+ position.y - mEventData->mScrollPosition.y - mAlignmentOffset.y );
+
+ if( leftSelectionHandleEvent )
+ {
+ const bool differentHandles = ( mEventData->mLeftSelectionPosition != handlePosition ) && ( mEventData->mRightSelectionPosition != handlePosition );
+ mEventData->mUpdateLeftSelectionPosition = endOfScroll || differentHandles;
+ if( differentHandles )
{
- mEventData->mUpdateLeftSelectionPosition = handlePosition != mEventData->mLeftSelectionPosition;
mEventData->mLeftSelectionPosition = handlePosition;
}
- else
+ }
+ else
+ {
+ const bool differentHandles = ( mEventData->mRightSelectionPosition != handlePosition ) && ( mEventData->mLeftSelectionPosition != handlePosition );
+ mEventData->mUpdateRightSelectionPosition = endOfScroll || differentHandles;
+ if( differentHandles )
{
- mEventData->mUpdateRightSelectionPosition = handlePosition != mEventData->mRightSelectionPosition;
mEventData->mRightSelectionPosition = handlePosition;
}
+ }
- if( mEventData->mUpdateLeftSelectionPosition || mEventData->mUpdateRightSelectionPosition )
- {
- RepositionSelectionHandles( mEventData->mLeftSelectionPosition,
- mEventData->mRightSelectionPosition );
+ if( mEventData->mUpdateLeftSelectionPosition || mEventData->mUpdateRightSelectionPosition )
+ {
+ RepositionSelectionHandles( mEventData->mLeftSelectionPosition,
+ mEventData->mRightSelectionPosition );
- mEventData->mScrollAfterUpdatePosition = true;
- }
+ mEventData->mScrollAfterUpdatePosition = true;
}
- mEventData->mDecoratorUpdated = true;
}
+ mEventData->mDecoratorUpdated = true;
} // end ( HANDLE_SCROLLING == state )
}
std::swap( selectionStart, selectionEnd );
}
- GlyphIndex glyphStart = *( charactersToGlyphBuffer + selectionStart );
- GlyphIndex glyphEnd = *( charactersToGlyphBuffer + ( selectionEnd - 1u ) ) + *( glyphsPerCharacterBuffer + ( selectionEnd - 1u ) ) - 1u;
+ const GlyphIndex glyphStart = *( charactersToGlyphBuffer + selectionStart );
+ const Length numberOfGlyphs = *( glyphsPerCharacterBuffer + ( selectionEnd - 1u ) );
+ const GlyphIndex glyphEnd = *( charactersToGlyphBuffer + ( selectionEnd - 1u ) ) + ( ( numberOfGlyphs > 0 ) ? numberOfGlyphs - 1u : 0u );
mEventData->mDecorator->SwapSelectionHandlesEnabled( firstLine.direction != indicesSwapped );
for( GlyphIndex index = glyphStart; index <= glyphEnd; ++index )
{
+ // TODO: Fix the LATIN ligatures. i.e ff, fi, etc...
const GlyphInfo& glyph = *( glyphsBuffer + index );
const Vector2& position = *( positionsBuffer + index );
return;
}
- // Get the previous logical index.
- const CharacterIndex previousLogical = isFirstPosition ? 0u : logical - 1u;
+ // 'logical' is the logical 'cursor' index.
+ // Get the next and current logical 'character' index.
+ const CharacterIndex nextCharacterIndex = logical;
+ const CharacterIndex characterIndex = isFirstPosition ? logical : logical - 1u;
- // Decrease the logical index if it's the last one.
- if( isLastPosition )
- {
- --logical;
- }
-
- // Get the direction of the character and the previous one.
+ // Get the direction of the character and the next one.
const CharacterDirection* const modelCharacterDirectionsBuffer = ( 0u != mLogicalModel->mCharacterDirections.Count() ) ? mLogicalModel->mCharacterDirections.Begin() : NULL;
CharacterDirection isCurrentRightToLeft = false;
- CharacterDirection isPreviousRightToLeft = false;
+ CharacterDirection isNextRightToLeft = false;
if( NULL != modelCharacterDirectionsBuffer ) // If modelCharacterDirectionsBuffer is NULL, it means the whole text is left to right.
{
- isCurrentRightToLeft = *( modelCharacterDirectionsBuffer + logical );
- isPreviousRightToLeft = *( modelCharacterDirectionsBuffer + previousLogical );
+ isCurrentRightToLeft = *( modelCharacterDirectionsBuffer + characterIndex );
+ isNextRightToLeft = *( modelCharacterDirectionsBuffer + nextCharacterIndex );
}
// Get the line where the character is laid-out.
const LineRun* modelLines = mVisualModel->mLines.Begin();
- const LineIndex lineIndex = mVisualModel->GetLineOfCharacter( logical );
+ const LineIndex lineIndex = mVisualModel->GetLineOfCharacter( characterIndex );
const LineRun& line = *( modelLines + lineIndex );
// Get the paragraph's direction.
// Check whether there is an alternative position:
- cursorInfo.isSecondaryCursor = ( isCurrentRightToLeft != isPreviousRightToLeft ) ||
- ( isLastPosition && ( isRightToLeftParagraph != isCurrentRightToLeft ) );
+ cursorInfo.isSecondaryCursor = ( !isLastPosition && ( isCurrentRightToLeft != isNextRightToLeft ) ) ||
+ ( isLastPosition && ( isRightToLeftParagraph != isCurrentRightToLeft ) );
// Set the line height.
cursorInfo.lineHeight = line.ascender + -line.descender;
- // Convert the cursor position into the glyph position.
- CharacterIndex characterIndex = logical;
- if( cursorInfo.isSecondaryCursor &&
- ( isRightToLeftParagraph != isCurrentRightToLeft ) )
+ // Calculate the primary cursor.
+
+ CharacterIndex index = characterIndex;
+ if( cursorInfo.isSecondaryCursor )
{
- characterIndex = previousLogical;
+ // If there is a secondary position, the primary cursor may be in a different place than the logical index.
+
+ if( isLastPosition )
+ {
+ // The position of the cursor after the last character needs special
+ // care depending on its direction and the direction of the paragraph.
+
+ // Need to find the first character after the last character with the paragraph's direction.
+ // i.e l0 l1 l2 r0 r1 should find r0.
+
+ // TODO: check for more than one line!
+ index = isRightToLeftParagraph ? line.characterRun.characterIndex : line.characterRun.characterIndex + line.characterRun.numberOfCharacters - 1u;
+ index = mLogicalModel->GetLogicalCharacterIndex( index );
+ }
+ else
+ {
+ index = ( isRightToLeftParagraph == isCurrentRightToLeft ) ? characterIndex : nextCharacterIndex;
+ }
}
- const GlyphIndex currentGlyphIndex = *( mVisualModel->mCharactersToGlyph.Begin() + characterIndex );
- const Length numberOfGlyphs = *( mVisualModel->mGlyphsPerCharacter.Begin() + characterIndex );
- const Length numberOfCharacters = *( mVisualModel->mCharactersPerGlyph.Begin() +currentGlyphIndex );
+ // Convert the cursor position into the glyph position.
+ const GlyphIndex primaryGlyphIndex = *( mVisualModel->mCharactersToGlyph.Begin() + index );
+ const Length primaryNumberOfGlyphs = *( mVisualModel->mGlyphsPerCharacter.Begin() + index );
+ const Length primaryNumberOfCharacters = *( mVisualModel->mCharactersPerGlyph.Begin() + primaryGlyphIndex );
// Get the metrics for the group of glyphs.
GlyphMetrics glyphMetrics;
- GetGlyphsMetrics( currentGlyphIndex,
- numberOfGlyphs,
+ GetGlyphsMetrics( primaryGlyphIndex,
+ primaryNumberOfGlyphs,
glyphMetrics,
mVisualModel,
mFontClient );
- float interGlyphAdvance = 0.f;
+ float glyphAdvance = 0.f;
if( !isLastPosition &&
- ( numberOfCharacters > 1u ) )
+ ( primaryNumberOfCharacters > 1u ) )
+ {
+ const CharacterIndex firstIndex = *( mVisualModel->mGlyphsToCharacters.Begin() + primaryGlyphIndex );
+ glyphAdvance = static_cast<float>( 1u + characterIndex - firstIndex ) * glyphMetrics.advance / static_cast<float>( primaryNumberOfCharacters );
+ }
+ else
{
- const CharacterIndex firstIndex = *( mVisualModel->mGlyphsToCharacters.Begin() + currentGlyphIndex );
- interGlyphAdvance = static_cast<float>( characterIndex - firstIndex ) * glyphMetrics.advance / static_cast<float>( numberOfCharacters );
+ glyphAdvance = glyphMetrics.advance;
}
// Get the glyph position and x bearing.
- const Vector2& currentPosition = *( mVisualModel->mGlyphPositions.Begin() + currentGlyphIndex );
+ const Vector2& primaryPosition = *( mVisualModel->mGlyphPositions.Begin() + primaryGlyphIndex );
- // Set the cursor's height.
- cursorInfo.primaryCursorHeight = glyphMetrics.fontHeight;
-
- // Set the position.
- cursorInfo.primaryPosition.x = -glyphMetrics.xBearing + currentPosition.x + ( isCurrentRightToLeft ? glyphMetrics.advance : interGlyphAdvance );
- cursorInfo.primaryPosition.y = line.ascender - glyphMetrics.ascender;
+ // Set the primary cursor's height.
+ cursorInfo.primaryCursorHeight = cursorInfo.isSecondaryCursor ? 0.5f * glyphMetrics.fontHeight : glyphMetrics.fontHeight;
+ // Set the primary cursor's position.
if( isLastPosition )
{
- // The position of the cursor after the last character needs special
- // care depending on its direction and the direction of the paragraph.
-
- if( cursorInfo.isSecondaryCursor )
- {
- // Need to find the first character after the last character with the paragraph's direction.
- // i.e l0 l1 l2 r0 r1 should find r0.
-
- // TODO: check for more than one line!
- characterIndex = isRightToLeftParagraph ? line.characterRun.characterIndex : line.characterRun.characterIndex + line.characterRun.numberOfCharacters - 1u;
- characterIndex = mLogicalModel->GetLogicalCharacterIndex( characterIndex );
-
- const GlyphIndex glyphIndex = *( mVisualModel->mCharactersToGlyph.Begin() + characterIndex );
- const Length numberOfGlyphs = *( mVisualModel->mGlyphsPerCharacter.Begin() + characterIndex );
-
- const Vector2& position = *( mVisualModel->mGlyphPositions.Begin() + glyphIndex );
+ cursorInfo.primaryPosition.x = -glyphMetrics.xBearing + primaryPosition.x + ( isRightToLeftParagraph ? 0.f : glyphMetrics.advance );
+ }
+ else
+ {
+ cursorInfo.primaryPosition.x = -glyphMetrics.xBearing + primaryPosition.x + ( ( ( isFirstPosition && !isCurrentRightToLeft ) || ( !isFirstPosition && isCurrentRightToLeft ) ) ? 0.f : glyphAdvance );
+ }
+ cursorInfo.primaryPosition.y = line.ascender - glyphMetrics.ascender;
- // Get the metrics for the group of glyphs.
- GlyphMetrics glyphMetrics;
- GetGlyphsMetrics( glyphIndex,
- numberOfGlyphs,
- glyphMetrics,
- mVisualModel,
- mFontClient );
+ // Calculate the secondary cursor.
- cursorInfo.primaryPosition.x = -glyphMetrics.xBearing + position.x + ( isRightToLeftParagraph ? 0.f : glyphMetrics.advance );
+ if( cursorInfo.isSecondaryCursor )
+ {
+ // Set the secondary cursor's height.
+ cursorInfo.secondaryCursorHeight = 0.5f * glyphMetrics.fontHeight;
- cursorInfo.primaryPosition.y = line.ascender - glyphMetrics.ascender;
- }
- else
+ CharacterIndex index = characterIndex;
+ if( !isLastPosition )
{
- if( !isCurrentRightToLeft )
- {
- cursorInfo.primaryPosition.x += glyphMetrics.advance;
- }
- else
- {
- cursorInfo.primaryPosition.x -= glyphMetrics.advance;
- }
+ index = ( isRightToLeftParagraph == isCurrentRightToLeft ) ? nextCharacterIndex : characterIndex;
}
- }
- // Set the alternative cursor position.
- if( cursorInfo.isSecondaryCursor )
- {
- // Convert the cursor position into the glyph position.
- const CharacterIndex previousCharacterIndex = ( ( isRightToLeftParagraph != isCurrentRightToLeft ) ? logical : previousLogical );
- const GlyphIndex previousGlyphIndex = *( mVisualModel->mCharactersToGlyph.Begin() + previousCharacterIndex );
- const Length numberOfGlyphs = *( mVisualModel->mGlyphsPerCharacter.Begin() + previousCharacterIndex );
+ const GlyphIndex secondaryGlyphIndex = *( mVisualModel->mCharactersToGlyph.Begin() + index );
+ const Length secondaryNumberOfGlyphs = *( mVisualModel->mGlyphsPerCharacter.Begin() + index );
- // Get the glyph position.
- const Vector2& previousPosition = *( mVisualModel->mGlyphPositions.Begin() + previousGlyphIndex );
+ const Vector2& secondaryPosition = *( mVisualModel->mGlyphPositions.Begin() + index );
- // Get the metrics for the group of glyphs.
- GlyphMetrics glyphMetrics;
- GetGlyphsMetrics( previousGlyphIndex,
- numberOfGlyphs,
+ GetGlyphsMetrics( secondaryGlyphIndex,
+ secondaryNumberOfGlyphs,
glyphMetrics,
mVisualModel,
mFontClient );
- // Set the cursor position and height.
- cursorInfo.secondaryPosition.x = -glyphMetrics.xBearing + previousPosition.x + ( ( ( isLastPosition && !isCurrentRightToLeft ) ||
- ( !isLastPosition && isCurrentRightToLeft ) ) ? glyphMetrics.advance : 0.f );
-
- cursorInfo.secondaryCursorHeight = 0.5f * glyphMetrics.fontHeight;
-
+ // Set the secondary cursor's position.
+ cursorInfo.secondaryPosition.x = -glyphMetrics.xBearing + secondaryPosition.x + ( isCurrentRightToLeft ? 0.f : glyphMetrics.advance );
cursorInfo.secondaryPosition.y = cursorInfo.lineHeight - cursorInfo.secondaryCursorHeight - line.descender - ( glyphMetrics.fontHeight - glyphMetrics.ascender );
-
- // Update the primary cursor height as well.
- cursorInfo.primaryCursorHeight *= 0.5f;
}
}
#include <dali-toolkit/internal/controls/buttons/button-impl.h>
+// EXTERNAL INCLUDES
+#include <dali/public-api/actors/image-actor.h>
+
namespace Dali
{
return Dali::Toolkit::GetImplementation( *this ).GetLabel();
}
+void Button::SetButtonImage( Image image )
+{
+ Actor imageActor = ImageActor::New( image );
+ Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageActor );
+}
+
+void Button::SetBackgroundImage( Image image )
+{
+ Actor imageActor = ImageActor::New( image );
+ Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( imageActor );
+}
+
+void Button::SetSelectedImage( Image image )
+{
+ Actor imageActor = ImageActor::New( image );
+ imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+ Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageActor );
+}
+
+void Button::SetSelectedBackgroundImage( Image image )
+{
+ Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( ImageActor::New( image ) );
+}
+
+void Button::SetDisabledBackgroundImage( Image image )
+{
+ Actor imageActor = ImageActor::New( image );
+ imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+ Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( imageActor );
+}
+
+void Button::SetDisabledImage( Image image )
+{
+ Actor imageActor = ImageActor::New( image );
+ imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+ Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( imageActor );
+}
+
+void Button::SetDisabledSelectedImage( Image image )
+{
+ Actor imageActor = ImageActor::New( image );
+ imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+ Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( imageActor );
+}
+
Button::ButtonSignalType& Button::PressedSignal()
{
return Dali::Toolkit::GetImplementation( *this ).PressedSignal();
*/
Actor GetLabel() const;
+ /**
+ * @brief Sets the button image.
+ *
+ * @param[in] image The button image.
+ */
+ void SetButtonImage( Image image );
+
+ /**
+ * @brief Sets the background image.
+ *
+ * @param[in] image The background image.
+ */
+ void SetBackgroundImage( Image image );
+
+ /**
+ * @brief Sets the selected image.
+ *
+ * @param[in] image The selected image.
+ */
+ void SetSelectedImage( Image image );
+
+ /**
+ * @brief Sets the selected background image.
+ *
+ * @param[in] image The selected background image.
+ */
+ void SetSelectedBackgroundImage( Image image );
+
+ /**
+ * @brief Sets the disabled background image.
+ *
+ * @param[in] image The disabled background image.
+ */
+ void SetDisabledBackgroundImage( Image image );
+
+ /**
+ * @brief Sets the disabled button image.
+ *
+ * @param[in] image The disabled button image.
+ */
+ void SetDisabledImage( Image image );
+
+ /**
+ * @brief Sets the disabled selected button image.
+ *
+ * @param[in] image The disabled selected button image.
+ */
+ void SetDisabledSelectedImage( Image image );
+
public: //Signals
/**
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/buttons/check-box-button-impl.h>
-#include <dali/public-api/actors/image-actor.h>
namespace Dali
{
return Control::DownCast<CheckBoxButton, Internal::CheckBoxButton>(handle);
}
-void CheckBoxButton::SetBackgroundImage( Image image )
-{
- Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( ImageActor::New( image ) );
-}
-
-void CheckBoxButton::SetBackgroundImage( Actor image )
-{
- Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( image );
-}
-
-Actor CheckBoxButton::GetBackgroundImage() const
-{
- return Dali::Toolkit::GetImplementation( *this ).GetBackgroundImage();
-}
-
-void CheckBoxButton::SetSelectedImage( Image image )
-{
- Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( ImageActor::New( image ) );
-}
-
-void CheckBoxButton::SetSelectedImage( Actor image )
-{
- Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( image );
-}
-
-Actor CheckBoxButton::GetSelectedImage() const
-{
- return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
-}
-
-void CheckBoxButton::SetDisabledBackgroundImage( Image image )
-{
- Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( ImageActor::New( image ) );
-}
-
-void CheckBoxButton::SetDisabledBackgroundImage( Actor image )
-{
- Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( image );
-}
-
-Actor CheckBoxButton::GetDisabledBackgroundImage() const
-{
- return Dali::Toolkit::GetImplementation( *this ).GetDisabledBackgroundImage();
-}
-
-void CheckBoxButton::SetDisabledSelectedImage( Image image )
-{
- Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( ImageActor::New( image ) );
-}
-
-void CheckBoxButton::SetDisabledSelectedImage( Actor image )
-{
- Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( image );
-}
-
-Actor CheckBoxButton::GetDisabledSelectedImage() const
-{
- return Dali::Toolkit::GetImplementation( *this ).GetDisabledSelectedImage();
-}
-
CheckBoxButton::CheckBoxButton( Internal::CheckBoxButton& implementation )
: Button( implementation )
{
*/
static CheckBoxButton DownCast( BaseHandle handle );
- /**
- * Sets the background image.
- *
- * @param[in] image The background image.
- */
- void SetBackgroundImage( Image image );
-
- /**
- * @copydoc SetBackgroundImage( Image image )
- */
- void SetBackgroundImage( Actor image );
-
- /**
- * Gets the background image.
- * @return An actor with the background image.
- */
- Actor GetBackgroundImage() const;
-
- /**
- * Sets the selected image.
- *
- * @param[in] image The selected image.
- */
- void SetSelectedImage( Image image );
-
- /**
- * @copydoc SetSelectedImage( Image image )
- */
- void SetSelectedImage( Actor image );
-
- /**
- * Gets the selected image.
- * @return An actor with the selected image.
- */
- Actor GetSelectedImage() const;
-
- /**
- * Sets the disabled background image.
- *
- * @param[in] image The disabled background image.
- */
- void SetDisabledBackgroundImage( Image image );
-
- /**
- * @copydoc SetDisabledBackgroundImage( Image image )
- */
- void SetDisabledBackgroundImage( Actor image );
-
- /**
- * Gets the disabled background image.
- * @return An actor with the disabled background image.
- */
- Actor GetDisabledBackgroundImage() const;
-
- /**
- * Sets the disabled selected image.
- *
- * @param[in] image The disabled selected image.
- */
- void SetDisabledSelectedImage( Image image );
-
- /**
- * @copydoc SetDisabledSelectedImage( Image image )
- */
- void SetDisabledSelectedImage( Actor image );
-
- /**
- * Gets the disabled selected image.
- * @return An actor with the disabled selected image.
- */
- Actor GetDisabledSelectedImage() const;
-
public: // Not intended for application developers
/**
return Control::DownCast<PushButton, Internal::PushButton>(handle);
}
-void PushButton::SetButtonImage( Image image )
-{
- Actor imageActor = ImageActor::New( image );
- Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageActor );
-}
-
void PushButton::SetButtonImage( Actor image )
{
Dali::Toolkit::GetImplementation( *this ).SetButtonImage( image );
return Dali::Toolkit::GetImplementation( *this ).GetButtonImage();
}
-void PushButton::SetBackgroundImage( Image image )
-{
- Actor imageActor = ImageActor::New( image );
- Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( imageActor );
-}
-
void PushButton::SetBackgroundImage( Actor image )
{
Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( image );
return Dali::Toolkit::GetImplementation( *this ).GetBackgroundImage();
}
-void PushButton::SetSelectedImage( Image image )
-{
- Actor imageActor = ImageActor::New( image );
- imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
- Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageActor );
-}
-
void PushButton::SetSelectedImage( Actor image )
{
Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( image );
return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
}
-void PushButton::SetSelectedBackgroundImage( Image image )
-{
- Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( ImageActor::New( image ) );
-}
-
void PushButton::SetSelectedBackgroundImage( Actor image )
{
Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( image );
return Dali::Toolkit::GetImplementation( *this ).GetSelectedBackgroundImage();
}
-void PushButton::SetDisabledBackgroundImage( Image image )
-{
- Actor imageActor = ImageActor::New( image );
- imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
- Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( imageActor );
-}
-
void PushButton::SetDisabledBackgroundImage( Actor image )
{
Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( image );
return Dali::Toolkit::GetImplementation( *this ).GetDisabledBackgroundImage();
}
-void PushButton::SetDisabledImage( Image image )
-{
- Actor imageActor = ImageActor::New( image );
- imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
- Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( imageActor );
-}
-
void PushButton::SetDisabledImage( Actor image )
{
Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( image );
*/
static PushButton DownCast( BaseHandle handle );
- /**
- * @brief Sets the button image.
- *
- * @param[in] image The button image.
- */
- void SetButtonImage( Image image );
+ using Button::SetButtonImage;
/**
* @brief SetButtonImage
*/
Actor GetButtonImage() const;
- /**
- * @brief Sets the background image.
- *
- * @param[in] image The background image.
- */
- void SetBackgroundImage( Image image );
+ using Button::SetBackgroundImage;
/**
* @brief SetBackgroundImage
*/
Actor GetBackgroundImage() const;
- /**
- * @brief Sets the selected image.
- *
- * @param[in] image The selected image.
- */
- void SetSelectedImage( Image image );
+ using Button::SetSelectedImage;
/**
* @copydoc SetSelectedImage( Image image )
*/
Actor GetSelectedImage() const;
- /**
- * @brief Sets the selected background image.
- *
- * @param[in] image The selected background image.
- */
- void SetSelectedBackgroundImage( Image image );
+ using Button::SetSelectedBackgroundImage;
/**
* @copydoc SetSelectedBackgroundImage( Image image )
*/
Actor GetSelectedBackgroundImage() const;
- /**
- * @brief Sets the disabled background image.
- *
- * @param[in] image The disabled background image.
- */
- void SetDisabledBackgroundImage( Image image );
+ using Button::SetDisabledBackgroundImage;
/**
* @copydoc SetDisabledBackgroundImage( Image image )
*/
Actor GetDisabledBackgroundImage() const;
- /**
- * @brief Sets the disabled button image.
- *
- * @param[in] image The disabled button image.
- */
- void SetDisabledImage( Image image );
+ using Button::SetDisabledImage;
/**
* @copydoc SetDisabledImage( Image image )
*
*/
+#include <dali/public-api/actors/layer.h>
namespace Dali
{
namespace Toolkit
{
enum ControlDepthIndexRanges
{
- BACKGROUND_DEPTH_INDEX = -10000000,
- CONTENT_DEPTH_INDEX = 0,
- DECORATION_DEPTH_INDEX = 10000000
+ BACKGROUND_DEPTH_INDEX = static_cast<int>( -Dali::Layer::TREE_DEPTH_MULTIPLIER * 0.1f ),
+ CONTENT_DEPTH_INDEX = 0,
+ DECORATION_DEPTH_INDEX = static_cast<int>( Dali::Layer::TREE_DEPTH_MULTIPLIER * 0.1f )
};
}
//Create the index buffer
Property::Map indexFormat;
- indexFormat["indices"] = Property::UNSIGNED_INTEGER;
+ indexFormat["indices"] = Property::INTEGER;
PropertyBuffer indexBuffer = PropertyBuffer::New( indexFormat, 6u );
indexBuffer.SetData(gQuadIndex);
Actor actor = CreateBackground(Self(), color );
background.actor = actor;
mImpl->mAddRemoveBackgroundChild = true;
- // use insert to guarantee its the first child (so that OVERLAY mode works)
- Self().Insert( 0, actor );
+ // The actor does not need to be inserted to guarantee order.
+ Self().Add( actor );
mImpl->mAddRemoveBackgroundChild = false;
}
// Set the background actor before adding so that we do not inform derived classes
background.actor = actor;
mImpl->mAddRemoveBackgroundChild = true;
- // use insert to guarantee its the first child (so that OVERLAY mode works)
- Self().Insert( 0, actor );
+ // The actor does not need to be inserted to guarantee order.
+ Self().Add( actor );
mImpl->mAddRemoveBackgroundChild = false;
}
styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
// Apply the current style
- GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+ GetImpl( styleManager ).ApplyThemeStyleAtInit( Toolkit::Control( GetOwner() ) );
}
}
void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
{
// By default the control is only interested in theme (not font) changes
- if( change == StyleChange::THEME_CHANGE )
+ if( styleManager && change == StyleChange::THEME_CHANGE )
{
GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
}
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 48;
+const unsigned int TOOLKIT_MICRO_VERSION = 49;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
"textselectionpopup":
{
"popup-max-size":[400,100],
- "popup-min-size":[100,65]
+ "option-divider-size":[2,0],
+ "popup-divider-color":[0.23,0.72,0.8,0.11],
+ "popup-icon-color":[1.0,1.0,1.0,1.0],
+ "popup-pressed-color":[0.24,0.72,0.8,0.11],
+ "background-image": {
+ "filename": "{DALI_IMAGE_DIR}selection-popup-bg.9.png"
+ }
},
"textfield":
{
--- /dev/null
+//******************************************************************************
+//
+// Default feedback theme for dali-toolkit
+//
+//******************************************************************************
+{
+ "style":
+ {
+ "PushButton":
+ {
+ "signals":
+ [
+ {
+ "type": "clicked",
+ "sound-feedback-pattern": "FEEDBACK_PATTERN_TAP"
+ }
+ ]
+ }
+ }
+}
"point-size":25
},
+
"textfield":
{
"font-family":"SamsungSans",
"textselectionpopup":
{
"popup-max-size":[400,100],
- "popup-min-size":[100,65]
+ "option-divider-size":[2,0],
+ "popup-divider-color":[0.23,0.72,0.8,0.11],
+ "popup-icon-color":[1.0,1.0,1.0,1.0],
+ "popup-pressed-color":[0.24,0.72,0.8,0.11],
+ "background-image": {
+ "filename": "{DALI_IMAGE_DIR}selection-popup-bg.9.png"
+ }
},
"scrollview":
{
### Control Base Class
+ [Background Feature](@ref background)
+ Keyboard Focus
- + Accessibility
+ + [Accessibility](@ref accessibility)
### UI Components
+ [Text Label](@ref text-label)
@code
/**
* @brief An enumeration of properties belonging to the ImageActor class.
- * Properties additional to RenderableActor.
+ * Properties additional to Actor.
*/
struct Property
{
--- /dev/null
+<!--
+/**-->
+
+[TOC]
+
+# Accessibility{#accessibility}
+
+
+## Introduction - What is Accessibility? {#accessibilityintroduction}
+
+Accessibility describes functionality designed to aid usage by the visually impaired.
+
+This includes:
+- Reading out selections or other on-screen items via text-to-speach.
+- Item selection being controlled with gestures to aid selecting other small hard to select entities.
+
+
+## Accessibility within DALi {#accessibilitydali}
+
+DALi will pick up the system's current accessibility state (and subsequent changes to it) and enable its internal accessibility mode based on this.
+
+DALi includes an Accessibility Manager which prodives public API control of the order of object selection by gesture, and text to be read out per actor or control.
+
+It further provides many signals that represent accessibility gestures. These gestures can range from a simple actor selection through to a more control-specific concept like "page-up", which an application developer may want to provide an implementation for.
+
+Furthermore, these APIs can be used not only with existing actors and controls, but also when creating a custom control.
+
+The AccessibilityManager lives within DALi Toolkit. Please see accessibility-manager.h for the full API.
+
+
+## Accessibility Focus {#accessibilityfocus}
+
+<!-- Float image to the right of the text -->
+<div style="float: right">
+ ![ ](../assets/img/accessibility/accessibility-focus.png) ![ ](./accessibility-focus.png)
+</div>
+
+Visibily, when enabled, accessibility will typically show an actor (or actors) as focused. This is represented by default with yellow rectangular frame around the actor. See this section for [modifying the appearance of the accessibility focus](#accessibilityfocusappearance).
+
+Once in accessibility mode, normal control is disabled and accessibility gestures must be used to access content.
+DALi actors and controls will no longer receive tap gestures or click events when they are touched once (as they normally would).
+
+Note: The accessibility focus is also refered to as the Focus Indicator.
+
+
+### Moving the focus with gestures {#accessibilitygestures}
+
+Accessibility recognises many gesture types to move the accessibility focus from actor to actor.
+
+Note:
+
+- Some of these gestures have pre-defined, automatic behaviour.
+- Some gestures require an specific implementation to be added to use.
+- All can be caught as signals if extra control is needed.
+
+To test (and understand) this behaviour, you can use the Tizen adaptor which uses the following gestures to perform basic operation:
+
+Note: The gestures that perform these actions are platform specific. These are the gestures implemented in the Tizen adaptor for example only.
+
+- Swiping right and left will move the focus forward and backward one item.
+- Doing a left or right swipe-return (where a direction is swiped forwards and backwards quickly) will move to the previous or next page - DALi cannot know what a page is within your application so these gestures can only work if implemented manually.
+
+
+![ ](../assets/img/accessibility/accessibility-focus-order.png) ![ ](./accessibility-focus-order.png)
+
+### Activation {#accessibilityactivation}
+
+Activation describes an operation performed on a selected actor, typically an on-tap or on-click event.
+
+Activating an actor in accessibility mode will call a virtual function, as well as signal, for that actor.
+Depending on the platform this can br triggered in different ways.
+When activated, the built in actor types (like PushButton) will do the equivalent of a tap.
+
+Custom-built actor types will need to implement activation in order to perform a specific behaviour. See the [Custom Controls](#accessibilitycustomcontrol) section.
+
+Therefore, to tap an actor (EG. Click a button) in accessibility mode, the following must be done:
+
+- The actor needs to be selected first (using gestures specific to the platform).
+- Then activated, by using the activation gesture.
+
+## Scrolling {#accessibilityscrolling}
+
+Scrolling around a view outside of accessibility is normally performed by simply holding one finger and dragging (in the appropriate direction).
+Within accessibility this can be overridden and performed with a different gesture type to achieve the same effect.
+
+Example: For the Tizen platform scrolling is performed with a two-finger drag.
+
+
+## Basic functionality {#accessibilitybasicfunctionality}
+
+### Using the Accessibility Manager functionality {#accessibilityfunctionality}
+
+Accessibility information is stored within the accessibility manager itself rather than within actors.
+This allows the manager to have a global view of focusable actors and their order.
+
+The Accessibility Manager is a singleton (owned by the singleton service) and can be accessed via its static Get() method:
+
+~~~{.cpp}
+// Get the accessibility manager singleton.
+accessibilityManager accessibilityManager = AccessibilityManager::Get();
+~~~
+
+
+### Controlling where the focus will move {#accessibilitymovingfocus}
+
+In order to provide automatic focus movement, the accessibility manager must be told the focus order of any actors to be selected.
+This order is a linear order. It can move forwards or backwards only (there is no concept of "up" or "down").
+
+The order of a particular actor can be set with a call to the accessibility manager like so:
+
+~~~{.cpp}
+// 6 is an int representing this actor's position in the focus chain.
+accessibilityManager.SetFocusOrder( actor, 6 );
+~~~
+
+The focus order of each actor in the focus chain is unique. If there is another actor assigned with the same focus order already, the new actor will be inserted to the focus chain with that focus order, and the focus order of the original actor and all the actors followed in the focus chain will be increased accordingly.
+
+If the focus order assigned to the actor is 0, it means that actor's focus order is undefined (e.g. the actor has a description but with no focus order being set yet) and therefore that actor is not focusable.
+
+Moving focus to a particular actor directly can be done with SetCurrentFocusActor like so:
+
+~~~{.cpp}
+// Move focus to the first item on our applications page.
+AccessibilityManager accessibilityManager = AccessibilityManager::Get();
+
+accessibilityManager.SetCurrentFocusActor( table.GetChildAt( 0 ) );
+~~~
+
+### Modifying the appearance of the accessibility focus {#accessibilityfocusappearance}
+
+The focus graphic itself can be customised.
+It can be an image (EG. A nine-patch border) or any other type of actor.
+
+It can be set using this method within C++:
+
+~~~{.cpp}
+accessibilityManager.SetFocusIndicatorActor( myCustomIndicatorActor );
+~~~
+
+
+### Using activation {#accessibilityusingactivation}
+
+If the application would like to perform specific behaviour when an entity is activated, it can catch the activation by connecting to a signal like this:
+
+~~~{.cpp}
+AccessibilityManager::Get().FocusedActorActivatedSignal().Connect( this, &MyClass::OnFocusedActorActivated );
+~~~
+
+Controlling the activation behaviour within a custom control is covered in the [custom control section](#accessibilitycustomcontrol)
+
+
+## Focus groups {#accessibilityfocusgroups}
+
+<!-- Float image to the right of the text -->
+<div style="float: right">
+ ![ ](../assets/img/accessibility/accessibility-focus-group.png) ![ ](./accessibility-focus-group.png)
+</div>
+
+Group mode allows the limiting of focusable actors.
+
+Example: If a popup appears, you may want the focus to be limited to only the OK and Cancel buttons. You can do this by setting the popup as a focus group and turning on group mode, the focus will be limited.
+
+~~~{.cpp}
+// Create a parent actor and add two children to it.
+Actor groupActor = Actor::New();
+
+Actor child1 = Actor::New();
+groupActor.Add( child1 );
+
+Actor child2 = Actor::New();
+groupActor.Add( child2 );
+
+AccessibilityManager accessibilityManager = AccessibilityManager::Get();
+
+// Mark the parent as a focus group. Now focus movement *can* be limited to the children of this actor.
+// Note: That this is not enabled until specified.
+accessibilityManager.SetFocusGroup( groupActor, true );
+
+// Enable the focus group mode.
+accessibilityManager.SetGroupMode( true );
+~~~
+
+
+### Wrap mode {#accessibilitywrapmode}
+
+Wrap mode allows the focus to wrap back to the beginning once the end is reached.
+
+In group mode this will move to the beggining of the current focus group.
+
+~~~{.cpp}
+AccessibilityManager accessibilityManager = AccessibilityManager::Get();
+
+// Enable wrap mode.
+accessibilityManager.SetWrapMode( true );
+~~~
+
+
+## Using Accessibility {#accessibilityusage}
+
+### Using accessibility with existing actors {#accessibilityactors}
+
+This example sets up a 3 by 3 grid of actors with the following accessibility functionality:
+
+ - They have a focus order that moves from top left to bottom right (when using the accessibility next and previous gestures).
+ - They contain text that will be spoken out loud (via text-to-speach) when the focus changes.
+
+Note that all the above is set via the AccessibilityManager and not as properties within the actors.
+
+The text spoken per tile will be the LABEL, TRAIT and HINT (in that order).
+
+~~~{.cpp}
+Toolkit::TableView table = Toolkit::TableView::New( 3, 3 );
+int tileNumber = 0;
+for( int row = 0; row < 3; ++row )
+{
+ for( int column = 0; column < 3; ++column )
+ {
+ // Create a solid color actor, with some text.
+ Actor tile = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
+ Toolkit::TextLabel text = Toolkit::TextLabel::New( tileNames[tileNumber] );
+ tile.Add( text );
+
+ // Get the accessibility manager singleton.
+ accessibilityManager accessibilityManager = AccessibilityManager::Get();
+
+ // Set the focus order of this actor.
+ accessibilityManager.SetFocusOrder( tile, tileNumber );
+
+ // Set up the accessibility information for this actor (this will be read out with text-to-speach).
+ accessibilityManager.SetAccessibilityAttribute( tile, Dali::Toolkit::AccessibilityManager::ACCESSIBILITY_LABEL, tileNames[tileNumber] );
+ accessibilityManager.SetAccessibilityAttribute( tile, Dali::Toolkit::AccessibilityManager::ACCESSIBILITY_TRAIT, "Tile" );
+ accessibilityManager.SetAccessibilityAttribute( tile, Dali::Toolkit::AccessibilityManager::ACCESSIBILITY_HINT, "You can run this example");
+
+ // Lay out our actor within the table view.
+ table.AddChild( tile, Toolkit::TableView::CellPosition( row, column ) );
+
+ tileNumber++;
+ }
+}
+Stage::GetCurrent().Add( table );
+~~~
+
+### Using accessibility within a custom control (C++) {#accessibilitycustomcontrol}
+
+As well as the Activation signal, if implementing a custom control from C++ you can use the OnAccessibilityActivate() virtual function.
+
+Other virtual accessibility methods are available for overriding within control also:
+
+- virtual bool OnAccessibilityPan( PanGesture gesture );
+- virtual bool OnAccessibilityTouch( const TouchEvent& touchEvent );
+- virtual bool OnAccessibilityValueChange( bool isIncrease ); // (i.e. value change of slider control)
+- virtual bool OnAccessibilityZoom();
+
+
+### Using accessibility signals for extra control {#accessibilitysignals}
+
+For more specific control of functionality when accessibility is enabled, there are several signals within the accessibility manager's public API that can be connected to.
+
+The main catagories of signals are:
+
+- The signal when the accessibility status is detected as being toggled on or off: StatusChangedSignal()
+- Focus changes can cause FocusChangedSignal() and FocusOvershotSignal(). These can be connected to in order to provide custom actions when the focus is moved around the screen.
+- The activated signal when an actor has been activated (typically by a focus, then double tap): ActionActivateSignal()
+- Gesture received signals: There are many of these. They are each linked to the many accessibility gestures that can be received by the system.
+
+Please see accessibility-manager.h within DALi Toolkit for the full API.
+
+
+@class _Guide_Accessibility
+*/
// In this mode depth testing is turned off and order is determined by the hierachy (depth-first search order).
// Not always recommended if there is going to be a lot of overdraw ( if lots of actors are on top of each other)
-Actor::SetDrawMode( DrawMode::OVERLAY ); // C++
+Actor::SetDrawMode( DrawMode::OVERLAY_2D ); // C++
~~~
~~~{.js}
// In this mode depth testing is turned off and order is determined by the hierachy (depth-first search order).
// Not always recommended if there is going to be a lot of overdraw ( if lots of actors are on top of each other)
-actor.drawMode = dali.DRAW_MODE_OVERLAY;
+actor.drawMode = dali.DRAW_MODE_OVERLAY_2D;
~~~
- Use TextureAtlases ( reduces state changes in the GPU)
- Use compressed textures
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.0.48
+Version: 1.0.49
Release: 1
Group: System/Libraries
License: Apache-2.0
* By default a renderable actor will be drawn as a 3D object. It will be depth-tested against
* other objects in the world i.e. it may be obscured if other objects are in front.
*
- * If OVERLAY is used, the actor and its children will be drawn as a 2D overlay.
+ * If OVERLAY_2D is used, the actor and its children will be drawn as a 2D overlay.
* Overlay actors are drawn in a separate pass, after all non-overlay actors within the Layer.
* For overlay actors, the drawing order is determined by the hierachy (depth-first search order),
* and depth-testing will not be used.
*
* @example
*
- * var actor.drawMode = dali.DRAW_MODE_NORMAL; // binary 00. The default draw-mode
- * var actor.drawMode = dali.DRAW_MODE_OVERLAY; // binary 01. Draw the actor and its children as an overlay
- * var actor.drawMode = dali.DRAW_MODE_STENCIL ;// binary 11. Draw the actor and its children into the stencil buffer
+ * var actor.drawMode = dali.DRAW_MODE_NORMAL; // binary 00. The default draw-mode
+ * var actor.drawMode = dali.DRAW_MODE_OVERLAY_2D; // binary 01. Draw the actor and its children as an overlay
+ * var actor.drawMode = dali.DRAW_MODE_STENCIL ; // binary 11. Draw the actor and its children into the stencil buffer
*
*
* @type Number
|**actor.drawMode **| |
|DRAW_MODE_NORMAL | integer value |
-|DRAW_MODE_OVERLAY | integer value |
+|DRAW_MODE_OVERLAY_2D | integer value |
|DRAW_MODE_STENCIL | integer value |
|**Image load policy **| |
// EXTERNAL INCLUDES
#include <dali/public-api/object/type-registry.h>
+#include <dali-toolkit/public-api/controls/control.h>
// INTERNAL INCLUDES
#include <actors/layer-api.h>
// ignore GetNinePatchBorder use imageActor.border
{ "SetSortModifier", ImageActorApi::SetSortModifier, IMAGE_ACTOR_API },
{ "GetSortModifier", ImageActorApi::GetSortModifier, IMAGE_ACTOR_API },
- { "SetCullFace", ImageActorApi::SetCullFace, IMAGE_ACTOR_API },
- { "GetCullFace", ImageActorApi::GetCullFace, IMAGE_ACTOR_API },
{ "SetBlendMode", ImageActorApi::SetBlendMode, IMAGE_ACTOR_API },
{ "GetBlendMode", ImageActorApi::GetBlendMode, IMAGE_ACTOR_API },
{ "SetBlendFunc", ImageActorApi::SetBlendFunc, IMAGE_ACTOR_API },
v8::Handle<v8::Object> ActorWrapper::WrapActor(v8::Isolate* isolate, Actor actor )
{
v8::EscapableHandleScope handleScope( isolate );
- v8::Local<v8::Object> object = WrapActor( isolate, actor, GetActorType( actor.GetTypeName() ) );
+
+ // Check whether the actor is a Control
+ ActorWrapper::ActorType type = Toolkit::Control::DownCast(actor) ? ACTOR : GetActorType( actor.GetTypeName() );
+ v8::Local<v8::Object> object = WrapActor( isolate, actor, type );
return handleScope.Escape( object );
}
}
/**
- * Set the face-culling mode for this actor.
- * @for ImageActor
- * @method setCullFace
- * @param {Number} cullMode
- * @example
- * // cull mode should be one of the following constants
- * dali.CULL_FACE_DISABLE // Face culling disabled
- * dali.CULL_FRONT_FACE // Cull front facing polygons
- * dali.CULL_BACK_FACE // Cull back facing polygons
- * dali.CULL_FRONT_AND_BACK_FACE // Cull front and back facing polygons
- * actor.SetCullFace( dali.CULL_FRONT_FACE );
- */
-void ImageActorApi::SetCullFace( const v8::FunctionCallbackInfo<v8::Value>& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
- ImageActor imageActor = GetImageActor( isolate, args );
-
- bool found( false );
- int cullMode = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "bad parameter" );
- return;
- }
-
- imageActor.SetCullFace( static_cast<Dali::CullFaceMode>( cullMode ) );
-
-}
-
-/**
- * Retrieve the face-culling mode for this actor.
- * @for ImageActor
- * @method getCullFace
- * @return {Number} cullMode
- * @example
- * // cull mode is one of the following
- * dali.CULL_FACE_DISABLE // Face culling disabled
- * dali.CULL_FRONT_FACE // Cull front facing polygons
- * dali.CULL_BACK_FACE // Cull back facing polygons
- * dali.CULL_FRONT_AND_BACK_FACE // Cull front and back facing polygon
- */
-void ImageActorApi::GetCullFace( const v8::FunctionCallbackInfo<v8::Value>& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
- ImageActor imageActor = GetImageActor( isolate, args );
-
- args.GetReturnValue().Set( v8::Integer::New( isolate, imageActor.GetCullFace() ) );
-
-}
-
-/**
* Sets the blending mode.
*
* If blending is disabled (BLENDING_OFF) fade in and fade out animations do not work.
void GetImage( const v8::FunctionCallbackInfo< v8::Value >& args );
void SetSortModifier( const v8::FunctionCallbackInfo< v8::Value >& args );
void GetSortModifier( const v8::FunctionCallbackInfo< v8::Value >& args );
- void SetCullFace( const v8::FunctionCallbackInfo< v8::Value >& args );
- void GetCullFace( const v8::FunctionCallbackInfo< v8::Value >& args );
void SetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args );
void GetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args );
void SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args );
{ "POSITION_INHERITANCE_DONT_INHERIT_POSITION", DONT_INHERIT_POSITION },
{ "DRAW_MODE_NORMAL", DrawMode::NORMAL },
- { "DRAW_MODE_OVERLAY", DrawMode::OVERLAY },
+ { "DRAW_MODE_OVERLAY_2D", DrawMode::OVERLAY_2D },
{ "DRAW_MODE_STENCIL", DrawMode::STENCIL },
{ "IMAGE_LOAD_POLICY_IMMEDIATE", ResourceImage::IMMEDIATE },
{ "BLEND_EQUATION_SUBTRACT", BlendingEquation::SUBTRACT },
{ "BLEND_EQUATION_REVERSE_SUBTRACT", BlendingEquation::REVERSE_SUBTRACT },
-
- { "CULL_FACE_DISABLE", CullNone },
- { "CULL_FRONT_FACE", CullFront },
- { "CULL_BACK_FACE", CullBack },
- { "CULL_FRONT_AND_BACK_FACE", CullFrontAndBack },
-
{ "CAMERA_FREE_LOOK" , Camera::FREE_LOOK },
{ "CAMERA_LOOK_AT_TARGET" , Camera::LOOK_AT_TARGET },
{ "CAMERA_PERSPECTIVE_PROJECTION" , Camera::PERSPECTIVE_PROJECTION },
{ "PathConstrainer", PathConstrainerWrapper::NewPathConstrainer},
{ "LinearConstrainer", LinearConstrainerWrapper::NewLinearConstrainer},
{ "Actor", ActorWrapper::NewActor },
- { "TextActor", ActorWrapper::NewActor },
{ "ImageActor", ActorWrapper::NewActor },
- { "MeshActor", ActorWrapper::NewActor },
{ "CameraActor", ActorWrapper::NewActor },
{ "Layer", ActorWrapper::NewActor },
{ "Control", ActorWrapper::NewControl },
{
case Dali::Property::BOOLEAN:
case Dali::Property::INTEGER:
- case Dali::Property::UNSIGNED_INTEGER:
case Dali::Property::STRING:
case Dali::Property::FLOAT:
{
v8Value = v8::Integer::New( isolate, value.Get<int>());
break;
}
- case Dali::Property::UNSIGNED_INTEGER:
- {
- v8Value = v8::Integer::New( isolate, value.Get<unsigned int>());
- break;
- }
case Dali::Property::STRING:
{
std::string string = value.Get< std::string >();
}
break;
}
- case Dali::Property::UNSIGNED_INTEGER:
- {
- if( v8Value->IsUint32() )
- {
- daliPropertyValue = Dali::Property::Value( v8Value->Uint32Value() );//static_cast<unsigned int>( V8Utils::GetNumberValue( isolate, v8Value) ));
- }
- break;
- }
case Dali::Property::STRING:
{
if( V8Utils::IsStringPrimitiveOrObject( v8Value) )
v8::Local<v8::Number> v = value->ToNumber();
return Dali::Property::Value(static_cast<float>(v->Value()));
}
- else if( value->IsInt32() )
+ else if( value->IsInt32() || value->IsUint32() )
{
found = true;
v8::Local<v8::Int32> v = value->ToInt32();
return Dali::Property::Value(static_cast<int>(v->Value()));
}
- else if ( value->IsUint32() )
- {
- found = true;
- v8::Local<v8::Uint32> v = value->ToUint32();
- return Dali::Property::Value(static_cast<unsigned int>(v->Value()));
- }
return daliPropertyValue;
}
v8Value = v8::Integer::New( isolate, value.Get<int>());
break;
}
- case Dali::Property::UNSIGNED_INTEGER:
- {
- v8Value = v8::Integer::New( isolate, value.Get<unsigned int>());
- break;
- }
case Dali::Property::STRING:
{
std::string string = value.Get< std::string >();