mTrace.PushCall("GetClosestImageSize", "");
}
-
/**
* @copydoc PlatformAbstraction::LoadResource()
*/
void TestPlatformAbstraction::LoadResource(const Integration::ResourceRequest& request)
{
std::ostringstream out;
- out << "Type:";
- if( request.GetType()->id == Integration::ResourceText )
- {
- out << "Text";
- }
- else
- {
- out << request.GetType()->id;
- }
- out << ", 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::GetDefaultFontFamily()
- */
-const std::string& TestPlatformAbstraction::GetDefaultFontFamily() const
-{
- mTrace.PushCall("GetDefaultFontFamily", "");
- return mGetDefaultFontFamilyResult;
-}
-
-/**
- * @copydoc PlatformAbstraction::GetDefaultFontSize()
- */
-float TestPlatformAbstraction::GetDefaultFontSize() const
-{
- mTrace.PushCall("GetDefaultFontSize", "");
- return mGetDefaultFontSizeResult;
-}
-
-PixelSize TestPlatformAbstraction::GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, CapsHeight capsHeight) const
-{
- mTrace.PushCall("GetFontLineHeightFromCapsHeight", "");
- // LineHeight will be bigger than CapsHeight, so return capsHeight + 1
- return PixelSize(capsHeight + 1);
-}
-
-/**
- * @copydoc PlatformAbstraction::GetGlyphData()
- */
-
-Integration::GlyphSet* TestPlatformAbstraction::GetGlyphData ( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily,
- bool getBitmap) const
-{
- if( getBitmap )
- {
- mTrace.PushCall("GetGlyphData", "getBitmap:true");
- }
- else
- {
- mTrace.PushCall("GetGlyphData", "getBitmap:false");
- }
-
- // It creates fake metrics for the received characters.
-
- Integration::GlyphSet* set = new Dali::Integration::GlyphSet();
- Integration::BitmapPtr bitmapData;
-
- std::set<uint32_t> characters;
-
- for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it )
- {
- if( characters.find( it->character ) == characters.end() )
- {
- characters.insert( it->character );
- Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::LOW_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition };
-
- if( getBitmap )
- {
- bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD);
- bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64);
- PixelBuffer* pixelBuffer = bitmapData->GetBuffer();
- memset( pixelBuffer, it->character, 64*64 );
- }
-
- set->AddCharacter(bitmapData, character);
- }
- }
-
- set->mLineHeight = 10.0f;
- set->mAscender = 9.0f;
- set->mUnitsPerEM = 2048.0f/64.0f;
- set->SetAtlasResourceId( textRequest.mTextureAtlasId );
- set->mFontHash = textRequest.mFontHash;
-
- return set;
-}
-
-/**
- * @copydoc PlatformAbstraction::GetCachedGlyphData()
- */
-
-Integration::GlyphSet* TestPlatformAbstraction::GetCachedGlyphData( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily ) const
-{
- mTrace.PushCall("GetCachedGlyphData", "");
-
- // It creates fake metrics and bitmap for received numeric characters '0' through '9'.
- Integration::GlyphSet* set = new Dali::Integration::GlyphSet();
- Integration::BitmapPtr bitmapData;
-
- std::set<uint32_t> characters;
-
- for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it )
- {
- if( it->character >= '0' && it->character <= '9' && characters.find( it->character ) == characters.end() )
- {
- characters.insert( it->character );
- Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::HIGH_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition };
-
- bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD);
- bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64);
- PixelBuffer* pixelBuffer = bitmapData->GetBuffer();
- memset( pixelBuffer, it->character, 64*64 );
- set->AddCharacter(bitmapData, character);
- }
- }
-
- set->mLineHeight = 10.0f;
- set->mAscender = 9.0f;
- set->mUnitsPerEM = 2048.0f/64.0f;
- set->SetAtlasResourceId( textRequest.mTextureAtlasId );
- set->mFontHash = textRequest.mFontHash;
-
- return set;
-}
-
-
-/**
- * @copydoc PlatformAbstraction::GetGlobalMetrics()
- */
-void TestPlatformAbstraction::GetGlobalMetrics( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics ) const
-{
- globalMetrics.lineHeight = 10.0f;
- globalMetrics.ascender = 9.0f;
- globalMetrics.unitsPerEM = 2048.0f/64.0f;
- globalMetrics.underlineThickness = 2.f;
- globalMetrics.underlinePosition = 1.f;
-}
-
-/**
- * @copydoc PlatformAbstraction::GetFontPath()
- */
-std::string TestPlatformAbstraction::GetFontPath(const std::string& family, bool bold, bool italic) const
-{
- mTrace.PushCall("GetFontPath", "");
- return mGetFontPathResult;
-
- // Do nothing with arguments
-}
-
-/**
* @copydoc PlatformAbstraction::SetDpi()
*/
void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical)
}
/**
- * @copydoc PlatformAbstraction::GetFontFamilyForChars()
- */
-const std::string& TestPlatformAbstraction::GetFontFamilyForChars(const Integration::TextArray& charsRequested) const
-{
- mTrace.PushCall("GetFontFamilyForChars", "");
- return mGetDefaultFontFamilyResult;
-}
-
-/**
- * @copydoc PlatformAbstraction::AllGlyphsSupported()
- */
-bool TestPlatformAbstraction::AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const
-{
- mTrace.PushCall("AllGlyphsSupported", "");
- return true;
-}
-
-/**
- * @copydoc PlatformAbstraction::ValidateFontFamilyName()
- */
-bool TestPlatformAbstraction::ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const
-{
- mTrace.PushCall("ValidateFontFamilyName", "");
- return true;
-}
-
-/**
- * @copydoc PlatformAbstraction::GetFontList()
- */
-void TestPlatformAbstraction::GetFontList( PlatformAbstraction::FontListMode mode, std::vector<std::string>& fonstList ) const
-{
- mFontListMode = mode;
- mTrace.PushCall("ValidateGetFontList", "");
-}
-
-/**
* @copydoc PlatformAbstraction::LoadFile()
*/
bool TestPlatformAbstraction::LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const
}
/**
+ * @copydoc PlatformAbstraction::LoadShaderBinFile()
+ */
+ bool TestPlatformAbstraction::LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer ) const
+ {
+ mTrace.PushCall("LoadShaderBinFile", "");
+ if( mLoadFileResult.loadResult )
+ {
+ buffer = mLoadFileResult.buffer;
+ }
+
+ return mLoadFileResult.loadResult;
+ }
+
+ /**
* @copydoc PlatformAbstraction::SaveFile()
*/
bool TestPlatformAbstraction::SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const
mTrace.PushCall("JoinLoaderThreads", "");
}
-void TestPlatformAbstraction::UpdateDefaultsFromDevice()
-{
- mTrace.PushCall("UpdateDefaultsFromDevice", "");
- mGetDefaultFontFamilyResult+=1.0f;
-}
-
Integration::DynamicsFactory* TestPlatformAbstraction::GetDynamicsFactory()
{
mTrace.PushCall("GetDynamicsFactory", "");
return NULL;
}
-bool TestPlatformAbstraction::ReadGlobalMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics )
-{
- mTrace.PushCall("ReadGlobalMetricsFromCacheFile", "");
- globalMetrics = mReadGlobalMetrics; // Want to copy contents...
- return mReadGlobalMetricsResult; // Default false (will be set to true on subsequent write)
-}
-
-void TestPlatformAbstraction::WriteGlobalMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlobalMetrics& globalMetrics )
-{
- // Copy so next read uses written values. TODO: Could add method
- // to turn this behaviour off for more extensive testing.
- mReadGlobalMetrics = globalMetrics;
- mReadGlobalMetricsResult = true;
-
- mTrace.PushCall("WriteGlobalMetricsToCacheFile", "");
-}
-
-bool TestPlatformAbstraction::ReadMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- std::vector<Integration::GlyphMetrics>& glyphMetricsContainer )
-{
- mTrace.PushCall("ReadMetricsFromCacheFile", "");
- glyphMetricsContainer = mReadMetrics;
- return mReadMetricsResult; // Default false (will be set to true on subsequent write)
-}
-
-void TestPlatformAbstraction::WriteMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlyphSet& glyphSet )
-{
- // Copy so next read uses written values. TODO: Could add method
- // to turn this behaviour off for more extensive testing.
- const Integration::GlyphSet::CharacterList& charList = glyphSet.GetCharacterList();
- mReadMetrics.clear();
- for(std::size_t i=0, end=charList.size(); i<end; ++i)
- {
- mReadMetrics.push_back(charList[i].second);
- }
- mReadMetricsResult = true;
-
- mTrace.PushCall("WriteMetricsToCacheFile", "");
-}
-
-
-void TestPlatformAbstraction::GetFileNamesFromDirectory( const std::string& directoryName,
- std::vector<std::string>& fileNames )
-{
- fileNames.push_back( std::string( "u1f004.png" ) );
- fileNames.push_back( std::string( "u1f0cf.png" ) );
- fileNames.push_back( std::string( "u1f170.png" ) );
- fileNames.push_back( std::string( "u1f601.png" ) );
-}
-
-
-Integration::BitmapPtr TestPlatformAbstraction::GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const
-{
- Integration::BitmapPtr image = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
- image->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 1, 1 );
-
- mTrace.PushCall("GetGlyphImage", "");
-
- return image;
-}
-
-
/** Call this every test */
void TestPlatformAbstraction::Initialize()
{
mTrace.Reset();
mTrace.Enable(true);
memset(&mResources, 0, sizeof(Resources));
- memset(&mReadGlobalMetrics, 0, sizeof(Integration::GlobalMetrics));
mSeconds=0;
mMicroSeconds=0;
mIsLoadingResult=false;
- mGetDefaultFontFamilyResult = "HelveticaNeue";
- mGetDefaultFontSizeResult=12.0f;
- mGetFontPathResult="helvetica-12";
- mReadMetricsResult=false;
- mReadGlobalMetricsResult=false;
if(mRequest)
{
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 SaveFileFunc: return mTrace.FindMethod("SaveFile");
case CancelLoadFunc: return mTrace.FindMethod("CancelLoad");
case GetResourcesFunc: return mTrace.FindMethod("GetResources");
case IsLoadingFunc: return mTrace.FindMethod("IsLoading");
- case GetDefaultFontFamilyFunc: return mTrace.FindMethod("GetDefaultFontFamily");
- case GetDefaultFontSizeFunc: return mTrace.FindMethod("GetDefaultFontSize");
- case GetFontLineHeightFromCapsHeightFunc: return mTrace.FindMethod("GetFontLineHeightFromCapsHeight");
- case GetGlyphDataFunc: return mTrace.FindMethod("GetGlyphData");
- case GetCachedGlyphDataFunc: return mTrace.FindMethod("GetCachedGlyphData");
- case GetFontPathFunc: return mTrace.FindMethod("GetFontPath");
case SetDpiFunc: return mTrace.FindMethod("SetDpi");
case JoinLoaderThreadsFunc: return mTrace.FindMethod("JoinLoaderThreads");
- case GetFontFamilyForCharsFunc: return mTrace.FindMethod("GetFontFamilyForChars");
- case AllGlyphsSupportedFunc: return mTrace.FindMethod("AllGlyphsSupported");
- case ValidateFontFamilyNameFunc: return mTrace.FindMethod("ValidateFontFamilyName");
- case UpdateDefaultsFromDeviceFunc: return mTrace.FindMethod("UpdateDefaultsFromDevice");
case GetDynamicsFactoryFunc: return mTrace.FindMethod("GetDynamicsFactory");
- case ValidateGetFontListFunc: return mTrace.FindMethod("ValidateGetFontList");
- case ReadGlobalMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadGlobalMetricsFromCacheFile");
- case WriteGlobalMetricsToCacheFileFunc: return mTrace.FindMethod("WriteGlobalMetricsToCacheFile");
- case ReadMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadMetricsFromCacheFile");
- case WriteMetricsToCacheFileFunc: return mTrace.FindMethod("WriteMetricsToCacheFile");
}
return false;
}
mIsLoadingResult = result;
}
-void TestPlatformAbstraction::SetGetDefaultFontFamilyResult(std::string result)
-{
- mGetDefaultFontFamilyResult = result;
-}
-
-void TestPlatformAbstraction::SetGetDefaultFontSizeResult(float result)
-{
- mGetDefaultFontSizeResult = result;
-}
-
-void TestPlatformAbstraction::SetGetFontPathResult(std::string& result)
-{
- mGetFontPathResult = result;
-}
-
void TestPlatformAbstraction::ClearReadyResources()
{
memset(&mResources, 0, sizeof(Resources));
mSaveFileResult = result;
}
-Integration::PlatformAbstraction::FontListMode TestPlatformAbstraction::GetLastFontListMode( )
-{
- return mFontListMode;
-}
-
-void TestPlatformAbstraction::SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics )
-{
- mReadGlobalMetricsResult = success;
- mReadGlobalMetrics = globalMetrics;
-}
-
-void TestPlatformAbstraction::SetReadMetricsResult( bool success, std::vector<Integration::GlyphMetrics>& glyphMetricsContainer )
-{
- mReadMetricsResult = success;
- mReadMetrics = glyphMetricsContainer; // copy
-}
-
} // namespace Dali
#include <dali/public-api/common/set-wrapper.h>
#include <dali/integration-api/platform-abstraction.h>
-#include <dali/integration-api/glyph-set.h>
#include "test-trace-call-stack.h"
virtual bool IsLoading();
/**
- * @copydoc PlatformAbstraction::GetDefaultFontFamily()
- */
- virtual const std::string& GetDefaultFontFamily() const;
-
- /**
- * @copydoc PlatformAbstraction::GetDefaultFontSize()
- */
- virtual float GetDefaultFontSize() const;
-
- /**
- * @copydoc PlatformAbstraction::GetFontLineHeightFromCapsHeight()
- */
- virtual Dali::PixelSize GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, CapsHeight capsHeight) const;
-
- /**
- * @copydoc PlatformAbstraction::GetGlyphData()
- */
- virtual Integration::GlyphSet* GetGlyphData ( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily,
- bool getBitmap) const;
-
- /**
- * @copydoc PlatformAbstraction::GetCachedGlyphData()
- */
- virtual Integration::GlyphSet* GetCachedGlyphData( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily ) const;
-
-
- /**
- * @copydoc PlatformAbstraction::GetGlobalMetrics()
- */
- virtual void GetGlobalMetrics( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics ) const;
-
- /**
- * @copydoc PlatformAbstraction::GetFontPath()
- */
- virtual std::string GetFontPath(const std::string& family, bool bold, bool italic) const;
-
- /**
* @copydoc PlatformAbstraction::SetDpi()
*/
virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
-
- /**
- * @copydoc PlatformAbstraction::GetFontFamilyForChars()
- */
- virtual const std::string& GetFontFamilyForChars(const Integration::TextArray& charsRequested) const;
-
- /**
- * @copydoc PlatformAbstraction::AllGlyphsSupported()
- */
- virtual bool AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const;
-
- /**
- * @copydoc PlatformAbstraction::ValidateFontFamilyName()
- */
- virtual bool ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const;
-
- /**
- * @copydoc PlatformAbstraction::GetFontList()
- */
- virtual void GetFontList( PlatformAbstraction::FontListMode mode, std::vector<std::string>& fontList ) const;
-
/**
* @copydoc PlatformAbstraction::LoadFile()
*/
virtual bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const;
/**
+ * @copydoc PlatformAbstraction::LoadShaderBinFile()
+ */
+ virtual bool LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer ) const;
+
+ /**
* @copydoc PlatformAbstraction::SaveFile()
*/
virtual bool SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const;
virtual void JoinLoaderThreads();
- virtual void UpdateDefaultsFromDevice();
-
virtual Integration::DynamicsFactory* GetDynamicsFactory();
- virtual bool ReadGlobalMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics );
-
- virtual void WriteGlobalMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlobalMetrics& globalMetrics );
-
- virtual bool ReadMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- std::vector<Integration::GlyphMetrics>& glyphMetricsContainer );
- virtual void WriteMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlyphSet& glyphSet );
-
-
- virtual void GetFileNamesFromDirectory( const std::string& directoryName,
- std::vector<std::string>& fileNames );
-
- virtual Integration::BitmapPtr GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const;
-
public: // TEST FUNCTIONS
// Enumeration of Platform Abstraction methods
SaveResourceFunc,
SaveFileFunc,
LoadFileFunc,
+ LoadShaderBinFileFunc,
CancelLoadFunc,
GetResourcesFunc,
IsLoadingFunc,
- GetDefaultFontFamilyFunc,
- GetDefaultFontSizeFunc,
- GetFontLineHeightFromCapsHeightFunc,
- GetGlyphDataFunc,
- GetCachedGlyphDataFunc,
SetDpiFunc,
- GetFontPathFunc,
JoinLoaderThreadsFunc,
- GetFontFamilyForCharsFunc,
- AllGlyphsSupportedFunc,
- ValidateFontFamilyNameFunc,
- UpdateDefaultsFromDeviceFunc,
GetDynamicsFactoryFunc,
- ValidateGetFontListFunc,
- ReadGlobalMetricsFromCacheFileFunc,
- WriteGlobalMetricsToCacheFileFunc,
- ReadMetricsFromCacheFileFunc,
- WriteMetricsToCacheFileFunc,
} TestFuncEnum;
/** Call this every test */
void SetSaveFileResult( bool result );
- PlatformAbstraction::FontListMode GetLastFontListMode( );
-
- void SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics );
-
- void SetReadMetricsResult( bool success, std::vector<Integration::GlyphMetrics>& glyphMetricsContainer );
-
-
private:
mutable TraceCallStack mTrace;
size_t mSeconds;
size_t mMicroSeconds;
bool mIsLoadingResult;
- std::string mGetDefaultFontFamilyResult;
- float mGetDefaultFontSizeResult;
- std::string mGetFontPathResult;
Resources mResources;
Integration::ResourceRequest* mRequest;
Vector2 mSize;
Vector2 mClosestSize;
- bool mReadGlobalMetricsResult;
- bool mReadMetricsResult;
- Integration::GlobalMetrics mReadGlobalMetrics;
- std::vector<Integration::GlyphMetrics> mReadMetrics;
LoadFileResult mLoadFileResult;
bool mSaveFileResult;
- mutable FontListMode mFontListMode;
};
} // Dali
int UtcDaliRadioButtonLabelActor(void)
{
- ToolkitTestApplication application;
-
- TextView actor1 = TextView::New( "test actor 1" );
-
- RadioButton radioButton = RadioButton::New( actor1 );
- DALI_TEST_CHECK( actor1 == radioButton.GetLabel() );
-
- TextView actor2 = TextView::New( "test actor 2" );
- radioButton.SetLabel( actor2 );
- DALI_TEST_CHECK( actor2 == radioButton.GetLabel() );
-
+ // TODO
END_TEST;
}
radioButton.SetPosition( 0.0f, 0.0f );
// Default selected
- DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
+ DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::Property::SELECTED ) == false );
// Setting false selected
- radioButton.SetProperty( Button::PROPERTY_SELECTED, false );
- DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
+ radioButton.SetProperty( Button::Property::SELECTED, false );
+ DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::Property::SELECTED ) == false );
// Setting true selected
- radioButton.SetProperty( Button::PROPERTY_SELECTED, true );
- DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
+ radioButton.SetProperty( Button::Property::SELECTED, true );
+ DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::Property::SELECTED ) == true );
// Setting false again
- radioButton.SetProperty( Button::PROPERTY_SELECTED, false );
- DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
+ radioButton.SetProperty( Button::Property::SELECTED, false );
+ DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::Property::SELECTED ) == false );
// Test selecting radio buttons
RadioButton radioButton2 = RadioButton::New( "label" );
application.Render();
// Simulate touch events
- DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
- DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
+ DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::Property::SELECTED ) == false );
+ DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::Property::SELECTED ) == false );
// Select first radio
{
application.SendNotification();
application.Render();
- DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
- DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
+ DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::Property::SELECTED ) == true );
+ DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::Property::SELECTED ) == false );
}
// Select an already selected radio
application.SendNotification();
application.Render();
- DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
- DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
+ DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::Property::SELECTED ) == true );
+ DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::Property::SELECTED ) == false );
}
// Select second radio
application.SendNotification();
application.Render();
- DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
- DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
+ DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::Property::SELECTED ) == false );
+ DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::Property::SELECTED ) == true );
}
// Select outside radio group
application.SendNotification();
application.Render();
- DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
- DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
+ DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::Property::SELECTED ) == false );
+ DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::Property::SELECTED ) == true );
}
END_TEST;
// EXTERNAL INCLUDES
#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/object/type-registry.h>
+ #include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/scripting/scripting.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
namespace Dali
{
namespace Toolkit
{
- const Property::Index Button::PROPERTY_DISABLED = Internal::Button::BUTTON_PROPERTY_START_INDEX;
- const Property::Index Button::PROPERTY_AUTO_REPEATING = Internal::Button::BUTTON_PROPERTY_START_INDEX + 1;
- const Property::Index Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY = Internal::Button::BUTTON_PROPERTY_START_INDEX + 2;
- const Property::Index Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY = Internal::Button::BUTTON_PROPERTY_START_INDEX + 3;
- const Property::Index Button::PROPERTY_TOGGLABLE = Internal::Button::BUTTON_PROPERTY_START_INDEX + 4;
- const Property::Index Button::PROPERTY_SELECTED = Internal::Button::BUTTON_PROPERTY_START_INDEX + 5;
- const Property::Index Button::PROPERTY_NORMAL_STATE_ACTOR = Internal::Button::BUTTON_PROPERTY_START_INDEX + 6;
- const Property::Index Button::PROPERTY_SELECTED_STATE_ACTOR = Internal::Button::BUTTON_PROPERTY_START_INDEX + 7;
- const Property::Index Button::PROPERTY_DISABLED_STATE_ACTOR = Internal::Button::BUTTON_PROPERTY_START_INDEX + 8;
- const Property::Index Button::PROPERTY_LABEL_ACTOR = Internal::Button::BUTTON_PROPERTY_START_INDEX + 9;
-
namespace Internal
{
namespace
{
- const unsigned int INITIAL_AUTOREPEATING_DELAY( 0.15f );
- const unsigned int NEXT_AUTOREPEATING_DELAY( 0.05f );
-
- // Signals
-
- const char* const SIGNAL_PRESSED = "pressed";
- const char* const SIGNAL_RELEASED = "released";
- const char* const SIGNAL_CLICKED = "clicked";
- const char* const SIGNAL_STATE_CHANGED = "state-changed";
-
- // Actions
-
- const char* const ACTION_BUTTON_CLICK = "button-click";
-
BaseHandle Create()
{
// empty handle as we cannot create button (but type registered for clicked signal)
return BaseHandle();
}
- TypeRegistration typeRegistration( typeid( Toolkit::Button ), typeid( Toolkit::Control ), Create );
+ // Setup properties, signals and actions using the type-registry.
+ DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Button, Toolkit::Control, Create );
+
+ DALI_PROPERTY_REGISTRATION( Button, "disabled", BOOLEAN, DISABLED )
+ DALI_PROPERTY_REGISTRATION( Button, "auto-repeating", BOOLEAN, AUTO_REPEATING )
+ DALI_PROPERTY_REGISTRATION( Button, "initial-auto-repeating-delay", FLOAT, INITIAL_AUTO_REPEATING_DELAY )
+ DALI_PROPERTY_REGISTRATION( Button, "next-auto-repeating-delay", FLOAT, NEXT_AUTO_REPEATING_DELAY )
+ DALI_PROPERTY_REGISTRATION( Button, "togglable", BOOLEAN, TOGGLABLE )
+ DALI_PROPERTY_REGISTRATION( Button, "selected", BOOLEAN, SELECTED )
+ DALI_PROPERTY_REGISTRATION( Button, "normal-state-actor", MAP, NORMAL_STATE_ACTOR )
+ DALI_PROPERTY_REGISTRATION( Button, "selected-state-actor", MAP, SELECTED_STATE_ACTOR )
+ DALI_PROPERTY_REGISTRATION( Button, "disabled-state-actor", MAP, DISABLED_STATE_ACTOR )
+ DALI_PROPERTY_REGISTRATION( Button, "label-actor", MAP, LABEL_ACTOR )
- SignalConnectorType signalConnector1( typeRegistration, SIGNAL_PRESSED , &Button::DoConnectSignal );
- SignalConnectorType signalConnector2( typeRegistration, SIGNAL_RELEASED, &Button::DoConnectSignal );
- SignalConnectorType signalConnector3( typeRegistration, SIGNAL_CLICKED, &Button::DoConnectSignal );
- SignalConnectorType signalConnector4( typeRegistration, SIGNAL_STATE_CHANGED, &Button::DoConnectSignal );
+ DALI_SIGNAL_REGISTRATION( Button, "pressed", SIGNAL_PRESSED )
+ DALI_SIGNAL_REGISTRATION( Button, "released", SIGNAL_RELEASED )
+ DALI_SIGNAL_REGISTRATION( Button, "clicked", SIGNAL_CLICKED )
+ DALI_SIGNAL_REGISTRATION( Button, "state-changed", SIGNAL_STATE_CHANGED )
- TypeAction action1( typeRegistration, ACTION_BUTTON_CLICK, &Button::DoAction );
+ DALI_ACTION_REGISTRATION( Button, "button-click", ACTION_BUTTON_CLICK )
- PropertyRegistration property1( typeRegistration, "disabled", Toolkit::Button::PROPERTY_DISABLED, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
- PropertyRegistration property2( typeRegistration, "auto-repeating", Toolkit::Button::PROPERTY_AUTO_REPEATING, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
- PropertyRegistration property3( typeRegistration, "initial-auto-repeating-delay", Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY, Property::FLOAT, &Button::SetProperty, &Button::GetProperty );
- PropertyRegistration property4( typeRegistration, "next-auto-repeating-delay", Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY, Property::FLOAT, &Button::SetProperty, &Button::GetProperty );
- PropertyRegistration property5( typeRegistration, "togglable", Toolkit::Button::PROPERTY_TOGGLABLE, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
- PropertyRegistration property6( typeRegistration, "selected", Toolkit::Button::PROPERTY_SELECTED, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
- PropertyRegistration property7( typeRegistration, "normal-state-actor", Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR, Property::MAP, &Button::SetProperty, &Button::GetProperty );
- PropertyRegistration property8( typeRegistration, "selected-state-actor", Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR, Property::MAP, &Button::SetProperty, &Button::GetProperty );
- PropertyRegistration property9( typeRegistration, "disabled-state-actor", Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR, Property::MAP, &Button::SetProperty, &Button::GetProperty );
- PropertyRegistration property10( typeRegistration, "label-actor", Toolkit::Button::PROPERTY_LABEL_ACTOR, Property::MAP, &Button::SetProperty, &Button::GetProperty );
+ DALI_TYPE_REGISTRATION_END()
+
+ const unsigned int INITIAL_AUTOREPEATING_DELAY( 0.15f );
+ const unsigned int NEXT_AUTOREPEATING_DELAY( 0.05f );
} // unnamed namespace
void Button::SetLabel( const std::string& label )
{
- Toolkit::TextView textView = Toolkit::TextView::New( label );
- textView.SetWidthExceedPolicy( Toolkit::TextView::ShrinkToFit ); // Make sure our text always fits inside the button
- SetLabel( textView );
}
void Button::SetLabel( Actor label )
{
switch ( index )
{
- case Toolkit::Button::PROPERTY_DISABLED:
+ case Toolkit::Button::Property::DISABLED:
{
GetImplementation( button ).SetDisabled( value.Get<bool>() );
break;
}
- case Toolkit::Button::PROPERTY_AUTO_REPEATING:
+ case Toolkit::Button::Property::AUTO_REPEATING:
{
GetImplementation( button ).SetAutoRepeating( value.Get< bool >() );
break;
}
- case Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY:
+ case Toolkit::Button::Property::INITIAL_AUTO_REPEATING_DELAY:
{
GetImplementation( button ).SetInitialAutoRepeatingDelay( value.Get< float >() );
break;
}
- case Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY:
+ case Toolkit::Button::Property::NEXT_AUTO_REPEATING_DELAY:
{
GetImplementation( button ).SetNextAutoRepeatingDelay( value.Get< float >() );
break;
}
- case Toolkit::Button::PROPERTY_TOGGLABLE:
+ case Toolkit::Button::Property::TOGGLABLE:
{
GetImplementation( button ).SetTogglableButton( value.Get< bool >() );
break;
}
- case Toolkit::Button::PROPERTY_SELECTED:
+ case Toolkit::Button::Property::SELECTED:
{
GetImplementation( button ).SetSelected( value.Get< bool >() );
break;
}
- case Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR:
+ case Toolkit::Button::Property::NORMAL_STATE_ACTOR:
{
GetImplementation( button ).SetButtonImage( Scripting::NewActor( value.Get< Property::Map >() ) );
break;
}
- case Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR:
+ case Toolkit::Button::Property::SELECTED_STATE_ACTOR:
{
GetImplementation( button ).SetSelectedImage( Scripting::NewActor( value.Get< Property::Map >() ) );
break;
}
- case Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR:
+ case Toolkit::Button::Property::DISABLED_STATE_ACTOR:
{
GetImplementation( button ).SetDisabledImage( Scripting::NewActor( value.Get< Property::Map >() ) );
break;
}
- case Toolkit::Button::PROPERTY_LABEL_ACTOR:
+ case Toolkit::Button::Property::LABEL_ACTOR:
{
GetImplementation( button ).SetLabel( Scripting::NewActor( value.Get< Property::Map >() ) );
break;
{
switch ( propertyIndex )
{
- case Toolkit::Button::PROPERTY_DISABLED:
+ case Toolkit::Button::Property::DISABLED:
{
value = GetImplementation( button ).mDisabled;
break;
}
- case Toolkit::Button::PROPERTY_AUTO_REPEATING:
+ case Toolkit::Button::Property::AUTO_REPEATING:
{
value = GetImplementation( button ).mAutoRepeating;
break;
}
- case Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY:
+ case Toolkit::Button::Property::INITIAL_AUTO_REPEATING_DELAY:
{
value = GetImplementation( button ).mInitialAutoRepeatingDelay;
break;
}
- case Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY:
+ case Toolkit::Button::Property::NEXT_AUTO_REPEATING_DELAY:
{
value = GetImplementation( button ).mNextAutoRepeatingDelay;
break;
}
- case Toolkit::Button::PROPERTY_TOGGLABLE:
+ case Toolkit::Button::Property::TOGGLABLE:
{
value = GetImplementation( button ).mTogglableButton;
break;
}
- case Toolkit::Button::PROPERTY_SELECTED:
+ case Toolkit::Button::Property::SELECTED:
{
value = GetImplementation( button ).mSelected;
break;
}
- case Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR:
+ case Toolkit::Button::Property::NORMAL_STATE_ACTOR:
{
Property::Map map;
Scripting::CreatePropertyMap( GetImplementation( button ).mButtonContent, map );
break;
}
- case Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR:
+ case Toolkit::Button::Property::SELECTED_STATE_ACTOR:
{
Property::Map map;
Scripting::CreatePropertyMap( GetImplementation( button ).mSelectedContent, map );
break;
}
- case Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR:
+ case Toolkit::Button::Property::DISABLED_STATE_ACTOR:
{
Property::Map map;
Scripting::CreatePropertyMap( GetImplementation( button ).mDisabledContent, map );
break;
}
- case Toolkit::Button::PROPERTY_LABEL_ACTOR:
+ case Toolkit::Button::Property::LABEL_ACTOR:
{
Property::Map map;
Scripting::CreatePropertyMap( GetImplementation( button ).mLabel, map );
#include <dali/public-api/common/stage.h>
#include <dali/public-api/events/key-event.h>
#include <dali/public-api/events/touch-event.h>
+ #include <dali/public-api/images/resource-image.h>
#include <dali/public-api/object/type-registry.h>
+ #include <dali/public-api/object/type-registry-helper.h>
#include <dali/integration-api/debug.h>
- #include <dali/public-api/images/resource-image.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/buttons/button.h>
- #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
+ #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
+ #include <dali-toolkit/public-api/focus-manager/focus-manager.h>
#include <dali-toolkit/internal/controls/relayout-helper.h>
#include <dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h>
- #include <dali-toolkit/public-api/focus-manager/focus-manager.h>
using namespace Dali;
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace Internal
+ {
+
namespace
{
+
+ BaseHandle Create()
+ {
+ return Toolkit::Popup::New();
+ }
+
+ // Setup properties, signals and actions using the type-registry.
+ DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Popup, Toolkit::Control, Create )
+
+ DALI_SIGNAL_REGISTRATION( Popup, "touched-outside", SIGNAL_TOUCHED_OUTSIDE )
+ DALI_SIGNAL_REGISTRATION( Popup, "hidden", SIGNAL_HIDDEN )
+
+ DALI_TYPE_REGISTRATION_END()
+
+ // Properties
+ const char* const PROPERTY_TITLE = "title";
+ const char* const PROPERTY_STATE = "state";
+
const float CONTENT_DEPTH = 1.0f; ///< 3D Effect of buttons/title etc. appearing off the popup.
const float POPUP_ANIMATION_DURATION = 0.5f; ///< Duration of hide/show animations
const float BACKING_DEPTH = -1.0f; ///< Depth of backing (positioned just behind dialog, so dialog catches hit events first)
const Vector3 DEFAULT_DIALOG_SIZE = Vector3(POPUP_TITLE_WIDTH/POPUP_WIDTH, 0.5f, 0.0f);
const Vector3 DEFAULT_BOTTOM_SIZE = Vector3(1.0f, 0.2f, 0.0f);
- // Signals
-
- const char* const SIGNAL_TOUCHED_OUTSIDE = "touched-outside";
- const char* const SIGNAL_HIDDEN = "hidden";
-
- // Properties
-
- const char* const PROPERTY_TITLE = "title";
- const char* const PROPERTY_STATE = "state";
-
/**
* The background size should be at least as big as the Dialog.
* In some cases a background may have graphics which are visible
} // unnamed namespace
- namespace Dali
- {
-
- namespace Toolkit
- {
-
- namespace Internal
- {
-
- namespace
- {
-
- BaseHandle Create()
- {
- return Toolkit::Popup::New();
- }
-
- TypeRegistration typeRegistration( typeid( Toolkit::Popup ), typeid( Toolkit::Control ), Create );
-
- SignalConnectorType signalConnector1( typeRegistration, SIGNAL_TOUCHED_OUTSIDE, &Popup::DoConnectSignal );
- SignalConnectorType signalConnector2( typeRegistration, SIGNAL_HIDDEN, &Popup::DoConnectSignal );
-
-
- }
-
-
///////////////////////////////////////////////////////////////////////////////////////////////////
// Popup
///////////////////////////////////////////////////////////////////////////////////////////////////
void Popup::SetTitle( const std::string& text )
{
- Toolkit::TextView titleActor = Toolkit::TextView::New();
- titleActor.SetText( text );
- titleActor.SetColor( Color::BLACK );
- titleActor.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
- titleActor.SetWidthExceedPolicy( Toolkit::TextView::Split );
- titleActor.SetLineJustification( Toolkit::TextView::Center );
-
- SetTitle( titleActor );
-}
-
-void Popup::SetTitle( Toolkit::TextView titleActor )
-{
- // Replaces the current title actor.
- if( mTitle && mPopupBg )
- {
- mPopupBg.Remove( mTitle );
- }
- mTitle = titleActor;
-
- mPopupBg.Add( mTitle );
-
- RelayoutRequest();
}
-Toolkit::TextView Popup::GetTitle() const
+const std::string& Popup::GetTitle() const
{
- return mTitle;
+ static std::string temp("");
+ return temp;
}
void Popup::AddButton( Toolkit::Button button )
if(mShowing)
{
- mAnimation.AnimateTo( Property(mBacking, Actor::Property::ColorAlpha), targetBackingAlpha, AlphaFunctions::EaseInOut, TimePeriod(0.0f, duration * 0.5f) );
- mAnimation.AnimateTo( Property(mPopupBg, Actor::Property::Scale), targetSize, AlphaFunctions::EaseInOut, TimePeriod(duration * 0.5f, duration * 0.5f) );
+ mAnimation.AnimateTo( Property(mBacking, Actor::Property::COLOR_ALPHA), targetBackingAlpha, AlphaFunctions::EaseInOut, TimePeriod(0.0f, duration * 0.5f) );
+ mAnimation.AnimateTo( Property(mPopupBg, Actor::Property::SCALE), targetSize, AlphaFunctions::EaseInOut, TimePeriod(duration * 0.5f, duration * 0.5f) );
}
else
{
- mAnimation.AnimateTo( Property(mBacking, Actor::Property::ColorAlpha), targetBackingAlpha, AlphaFunctions::EaseInOut, TimePeriod(0.0f, duration * 0.5f) );
- mAnimation.AnimateTo( Property(mPopupBg, Actor::Property::Scale), targetSize, AlphaFunctions::EaseInOut, TimePeriod(0.0f, duration * 0.5f) );
+ mAnimation.AnimateTo( Property(mBacking, Actor::Property::COLOR_ALPHA), targetBackingAlpha, AlphaFunctions::EaseInOut, TimePeriod(0.0f, duration * 0.5f) );
+ mAnimation.AnimateTo( Property(mPopupBg, Actor::Property::SCALE), targetSize, AlphaFunctions::EaseInOut, TimePeriod(0.0f, duration * 0.5f) );
}
mAnimation.Play();
mAnimation.FinishedSignal().Connect(this, &Popup::OnStateAnimationFinished);
// Relayout title
Vector3 positionOffset( 0.0f, mPopupStyle->margin + POPUP_OUT_MARGIN_WIDTH, CONTENT_DEPTH );
- if( mTitle )
- {
- Vector2 titleSize;
- titleSize.width = popupSize.width;
- titleSize.height = mTitle.GetHeightForWidth( titleSize.width );
-
- // As the default size policy for text-view is Fixed & Fixed, a size needs to be set.
- // Otherwise size-negotiation algorithm uses the GetNaturalSize() with doesn't take
- // into account the multiline and exceed policies, giving as result a wrong size.
- mTitle.SetSize( titleSize );
- Relayout( mTitle, titleSize, container );
-
- mTitle.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- mTitle.SetParentOrigin( ParentOrigin::TOP_CENTER );
- mTitle.SetPosition( positionOffset );
-
- positionOffset.y += titleSize.height + mPopupStyle->margin;
- }
+ // TODO
// Relayout content
if( mContent )
Vector3 naturalSize( 0.0f, 0.0f, 0.0f );
- if ( mTitle )
- {
- Vector3 titleNaturalSize = mTitle.GetImplementation().GetNaturalSize();
- // Buffer to avoid errors. The width of the popup could potentially be the width of the title text.
- // It was observed in this case that text wrapping was then inconsistent when seen on device
- const float titleBuffer = 0.5f;
- titleNaturalSize.width += titleBuffer;
-
- // As TextView GetNaturalSize does not take wrapping into account, limit the width
- // to that of the stage
- if( titleNaturalSize.width >= maxWidth)
- {
- naturalSize.width = maxWidth;
- naturalSize.height = mTitle.GetImplementation().GetHeightForWidth( naturalSize.width );
- }
- else
- {
- naturalSize += titleNaturalSize;
- }
-
- naturalSize.height += mPopupStyle->margin;
- }
-
if( mContent )
{
Vector3 contentSize = RelayoutHelper::GetNaturalSize( mContent );
float height( 0.0f );
float popupWidth( width - 2.f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin ) );
- if ( mTitle )
- {
- height += mTitle.GetImplementation().GetHeightForWidth( popupWidth );
- height += mPopupStyle->margin;
- }
-
if( mContent )
{
height += RelayoutHelper::GetHeightForWidth( mContent, popupWidth ) + mPopupStyle->margin;
#include <sstream>
#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/object/type-registry.h>
+ #include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/images/resource-image.h>
// INTERNAL INCLUDES
namespace Toolkit
{
- // Properties
- const Property::Index Slider::LOWER_BOUND_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX;
- const Property::Index Slider::UPPER_BOUND_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 1;
-
- const Property::Index Slider::VALUE_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 2;
- const Property::Index Slider::HIT_REGION_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 3;
- const Property::Index Slider::BACKING_REGION_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 4;
- const Property::Index Slider::HANDLE_REGION_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 5;
-
- const Property::Index Slider::BACKING_IMAGE_NAME_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 6;
- const Property::Index Slider::HANDLE_IMAGE_NAME_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 7;
- const Property::Index Slider::PROGRESS_IMAGE_NAME_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 8;
- const Property::Index Slider::POPUP_IMAGE_NAME_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 9;
- const Property::Index Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 10;
-
- const Property::Index Slider::DISABLE_COLOR_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 11;
- const Property::Index Slider::POPUP_TEXT_COLOR_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 12;
-
- const Property::Index Slider::VALUE_PRECISION_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 13;
-
- const Property::Index Slider::SHOW_POPUP_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 14;
- const Property::Index Slider::SHOW_VALUE_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 15;
-
- const Property::Index Slider::ENABLED_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 16;
-
- const Property::Index Slider::MARKS_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 17;
- const Property::Index Slider::SNAP_TO_MARKS_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 18;
- const Property::Index Slider::MARK_TOLERANCE_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 19;
-
namespace Internal
{
- namespace
+ namespace // Unnamed namespace
+ {
+
+ BaseHandle Create()
{
+ return Dali::Toolkit::Slider::New();
+ }
+
+ // Setup properties, signals and actions using the type-registry.
+ DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Slider, Toolkit::Control, Create )
+
+ DALI_PROPERTY_REGISTRATION( Slider, "lower-bound", FLOAT, LOWER_BOUND )
+ DALI_PROPERTY_REGISTRATION( Slider, "upper-bound", FLOAT, UPPER_BOUND )
+ DALI_PROPERTY_REGISTRATION( Slider, "value", FLOAT, VALUE )
+ DALI_PROPERTY_REGISTRATION( Slider, "hit-region", VECTOR2, HIT_REGION )
+ DALI_PROPERTY_REGISTRATION( Slider, "backing-region", VECTOR2, BACKING_REGION )
+ DALI_PROPERTY_REGISTRATION( Slider, "handle-region", VECTOR2, HANDLE_REGION )
+ DALI_PROPERTY_REGISTRATION( Slider, "backing-image-name", STRING, BACKING_IMAGE_NAME )
+ DALI_PROPERTY_REGISTRATION( Slider, "handle-image-name", STRING, HANDLE_IMAGE_NAME )
+ DALI_PROPERTY_REGISTRATION( Slider, "progress-image-name", STRING, PROGRESS_IMAGE_NAME )
+ DALI_PROPERTY_REGISTRATION( Slider, "popup-image-name", STRING, POPUP_IMAGE_NAME )
+ DALI_PROPERTY_REGISTRATION( Slider, "popup-arrow-image-name", STRING, POPUP_ARROW_IMAGE_NAME )
+ DALI_PROPERTY_REGISTRATION( Slider, "disable-color", VECTOR4, DISABLE_COLOR )
+ DALI_PROPERTY_REGISTRATION( Slider, "popup-text-color", VECTOR4, POPUP_TEXT_COLOR )
+ DALI_PROPERTY_REGISTRATION( Slider, "value-precision", INTEGER, VALUE_PRECISION )
+ DALI_PROPERTY_REGISTRATION( Slider, "show-popup", BOOLEAN, SHOW_POPUP )
+ DALI_PROPERTY_REGISTRATION( Slider, "show-value", BOOLEAN, SHOW_VALUE )
+ DALI_PROPERTY_REGISTRATION( Slider, "enabled", BOOLEAN, ENABLED )
+ DALI_PROPERTY_REGISTRATION( Slider, "marks", ARRAY, MARKS )
+ DALI_PROPERTY_REGISTRATION( Slider, "snap-to-marks", BOOLEAN, SNAP_TO_MARKS )
+ DALI_PROPERTY_REGISTRATION( Slider, "mark-tolerance", FLOAT, MARK_TOLERANCE )
+
+ DALI_SIGNAL_REGISTRATION( Slider, "value-changed", SIGNAL_VALUE_CHANGED )
+ DALI_SIGNAL_REGISTRATION( Slider, "mark", SIGNAL_MARK )
+
+ DALI_TYPE_REGISTRATION_END()
+
const float BACKING_Z = -0.1f;
const float PROGRESS_Z = 0.1f;
const float HANDLE_Z = 1.0f;
const bool DEFAULT_ENABLED = true;
const bool DEFAULT_SNAP_TO_MARKS = false;
- // Signals
-
- const char* const SIGNAL_VALUE_CHANGED = "value-changed";
- const char* const SIGNAL_MARK = "mark";
-
- BaseHandle Create()
- {
- return Dali::Toolkit::Slider::New();
- }
-
- TypeRegistration typeRegistration( typeid( Dali::Toolkit::Slider ), typeid( Dali::Toolkit::Control ), Create );
-
- SignalConnectorType signalConnector1( typeRegistration, SIGNAL_VALUE_CHANGED, &Toolkit::Internal::Slider::DoConnectSignal );
- SignalConnectorType signalConnector2( typeRegistration, SIGNAL_MARK, &Toolkit::Internal::Slider::DoConnectSignal );
-
- PropertyRegistration property1( typeRegistration, "lower-bound", Toolkit::Slider::LOWER_BOUND_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty );
- PropertyRegistration property2( typeRegistration, "upper-bound", Toolkit::Slider::UPPER_BOUND_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty );
- PropertyRegistration property3( typeRegistration, "value", Toolkit::Slider::VALUE_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty );
-
- PropertyRegistration property4( typeRegistration, "hit-region", Toolkit::Slider::HIT_REGION_PROPERTY, Property::VECTOR2, &Slider::SetProperty, &Slider::GetProperty );
- PropertyRegistration property5( typeRegistration, "backing-region", Toolkit::Slider::BACKING_REGION_PROPERTY, Property::VECTOR2, &Slider::SetProperty, &Slider::GetProperty );
- PropertyRegistration property6( typeRegistration, "handle-region", Toolkit::Slider::HANDLE_REGION_PROPERTY, Property::VECTOR2, &Slider::SetProperty, &Slider::GetProperty );
-
- PropertyRegistration property7( typeRegistration, "backing-image-name", Toolkit::Slider::BACKING_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty );
- PropertyRegistration property8( typeRegistration, "handle-image-name", Toolkit::Slider::HANDLE_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty );
- PropertyRegistration property9( typeRegistration, "progress-image-name", Toolkit::Slider::PROGRESS_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty );
- PropertyRegistration property10( typeRegistration, "popup-image-name", Toolkit::Slider::POPUP_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty );
- PropertyRegistration property11( typeRegistration, "popup-arrow-image-name", Toolkit::Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty );
-
- PropertyRegistration property12( typeRegistration, "disable-color", Toolkit::Slider::DISABLE_COLOR_PROPERTY, Property::VECTOR4, &Slider::SetProperty, &Slider::GetProperty );
- PropertyRegistration property13( typeRegistration, "popup-text-color", Toolkit::Slider::POPUP_TEXT_COLOR_PROPERTY, Property::VECTOR4, &Slider::SetProperty, &Slider::GetProperty );
-
- PropertyRegistration property14( typeRegistration, "value-precision", Toolkit::Slider::VALUE_PRECISION_PROPERTY, Property::INTEGER, &Slider::SetProperty, &Slider::GetProperty );
-
- PropertyRegistration property15( typeRegistration, "show-popup", Toolkit::Slider::SHOW_POPUP_PROPERTY, Property::BOOLEAN, &Slider::SetProperty, &Slider::GetProperty );
- PropertyRegistration property16( typeRegistration, "show-value", Toolkit::Slider::SHOW_VALUE_PROPERTY, Property::BOOLEAN, &Slider::SetProperty, &Slider::GetProperty );
-
- PropertyRegistration property17( typeRegistration, "enabled", Toolkit::Slider::ENABLED_PROPERTY, Property::BOOLEAN, &Slider::SetProperty, &Slider::GetProperty );
-
- PropertyRegistration property18( typeRegistration, "marks", Toolkit::Slider::MARKS_PROPERTY, Property::ARRAY, &Slider::SetProperty, &Slider::GetProperty );
- PropertyRegistration property19( typeRegistration, "snap-to-marks", Toolkit::Slider::SNAP_TO_MARKS_PROPERTY, Property::BOOLEAN, &Slider::SetProperty, &Slider::GetProperty );
- PropertyRegistration property20( typeRegistration, "mark-tolerance", Toolkit::Slider::MARK_TOLERANCE_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty );
-
- } // namespace
+ } // Unnamed namespace
///////////////////////////////////////////////////////////////////////////////////////////////////
// Slider
mMarkSignal.Emit( self, markIndex );
}
}
-
- if( mHandleValueTextView )
- {
- std::stringstream ss;
- ss.precision( GetValuePrecision() );
- ss << std::fixed << clampledValue;
- mHandleValueTextView.SetText( ss.str() );
- }
}
void Slider::SetMarks( const MarkList& marks )
return arrow;
}
-Toolkit::TextView Slider::CreatePopupText()
-{
- Toolkit::TextView textView = Toolkit::TextView::New();
- textView.SetParentOrigin( ParentOrigin::CENTER );
- textView.SetAnchorPoint( AnchorPoint::CENTER );
- textView.SetSizePolicy( Toolkit::Control::Flexible, Toolkit::Control::Flexible );
- textView.SetZ( VALUE_DISPLAY_TEXT_Z );
- return textView;
-}
+//Toolkit::TextView Slider::CreatePopupText()
+//{
+//}
ImageActor Slider::CreatePopup()
{
popup.SetParentOrigin( ParentOrigin::TOP_CENTER );
popup.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
- mValueTextView = CreatePopupText();
- popup.Add( mValueTextView );
-
return popup;
}
void Slider::CreateHandleValueDisplay()
{
- if( mHandle && !mHandleValueTextView )
- {
- mHandleValueTextView = Toolkit::TextView::New();
- mHandleValueTextView.SetParentOrigin( ParentOrigin::CENTER );
- mHandleValueTextView.SetAnchorPoint( AnchorPoint::CENTER );
- mHandleValueTextView.SetSize( GetHandleRegion() );
- mHandleValueTextView.SetZ( HANDLE_VALUE_DISPLAY_TEXT_Z );
- mHandle.Add( mHandleValueTextView );
- }
}
void Slider::DestroyHandleValueDisplay()
{
- if(mHandleValueTextView)
- {
- mHandleValueTextView.Unparent();
- mHandleValueTextView.Reset();
- }
}
void Slider::SetPopupTextColor( const Vector4& color )
outIndex = current;
return true;
}
+
+ if( value < mark )
+ {
+ tail = current - 1;
+ }
else
{
- if( value < mark )
- {
- tail = current - 1;
- }
- else
- {
- head = current + 1;
- }
+ head = current + 1;
}
}
void Slider::DisplayPopup( float value )
{
- // Value displayDoConnectSignal
- if( mValueTextView )
- {
- std::stringstream ss;
- ss.precision( GetValuePrecision() );
- ss << std::fixed << value;
- mValueTextView.SetText( ss.str() );
- TextStyle style;
- style.SetTextColor( GetPopupTextColor() );
- mValueTextView.SetStyleToCurrentText( style, TextStyle::COLOR);
-
- if( mValueDisplay )
- {
- Font font = Font::New();
- float popupWidth = font.MeasureText( ss.str() ).x + VALUE_POPUP_MARGIN * 2.0f;
- if( popupWidth < VALUE_POPUP_MIN_WIDTH )
- {
- popupWidth = VALUE_POPUP_MIN_WIDTH;
- }
-
- mPopup.SetSize( popupWidth, VALUE_POPUP_HEIGHT );
- mValueDisplay.SetVisible( true );
-
- mValueTimer.SetInterval( VALUE_VIEW_SHOW_DURATION );
- }
- }
}
void Slider::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
switch ( propertyIndex )
{
- case Toolkit::Slider::LOWER_BOUND_PROPERTY:
+ case Toolkit::Slider::Property::LOWER_BOUND:
{
sliderImpl.SetLowerBound( value.Get< float >() );
break;
}
- case Toolkit::Slider::UPPER_BOUND_PROPERTY:
+ case Toolkit::Slider::Property::UPPER_BOUND:
{
sliderImpl.SetUpperBound( value.Get< float >() );
break;
}
- case Toolkit::Slider::VALUE_PROPERTY:
+ case Toolkit::Slider::Property::VALUE:
{
sliderImpl.SetValue( value.Get< float >() );
break;
}
- case Toolkit::Slider::HIT_REGION_PROPERTY:
+ case Toolkit::Slider::Property::HIT_REGION:
{
sliderImpl.SetHitRegion( value.Get< Vector2 >() );
break;
}
- case Toolkit::Slider::BACKING_REGION_PROPERTY:
+ case Toolkit::Slider::Property::BACKING_REGION:
{
sliderImpl.SetBackingRegion( value.Get< Vector2 >() );
break;
}
- case Toolkit::Slider::HANDLE_REGION_PROPERTY:
+ case Toolkit::Slider::Property::HANDLE_REGION:
{
sliderImpl.SetHandleRegion( value.Get< Vector2 >() );
break;
}
- case Toolkit::Slider::BACKING_IMAGE_NAME_PROPERTY:
+ case Toolkit::Slider::Property::BACKING_IMAGE_NAME:
{
sliderImpl.SetBackingImageName( value.Get< std::string >() );
break;
}
- case Toolkit::Slider::HANDLE_IMAGE_NAME_PROPERTY:
+ case Toolkit::Slider::Property::HANDLE_IMAGE_NAME:
{
sliderImpl.SetHandleImageName( value.Get< std::string >() );
break;
}
- case Toolkit::Slider::PROGRESS_IMAGE_NAME_PROPERTY:
+ case Toolkit::Slider::Property::PROGRESS_IMAGE_NAME:
{
sliderImpl.SetProgressImageName( value.Get< std::string >() );
break;
}
- case Toolkit::Slider::POPUP_IMAGE_NAME_PROPERTY:
+ case Toolkit::Slider::Property::POPUP_IMAGE_NAME:
{
sliderImpl.SetPopupImageName( value.Get< std::string >() );
break;
}
- case Toolkit::Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY:
+ case Toolkit::Slider::Property::POPUP_ARROW_IMAGE_NAME:
{
sliderImpl.SetPopupArrowImageName( value.Get< std::string >() );
break;
}
- case Toolkit::Slider::DISABLE_COLOR_PROPERTY:
+ case Toolkit::Slider::Property::DISABLE_COLOR:
{
sliderImpl.SetDisableColor( value.Get< Vector4 >() );
break;
}
- case Toolkit::Slider::POPUP_TEXT_COLOR_PROPERTY:
+ case Toolkit::Slider::Property::POPUP_TEXT_COLOR:
{
sliderImpl.SetPopupTextColor( value.Get< Vector4 >() );
break;
}
- case Toolkit::Slider::VALUE_PRECISION_PROPERTY:
+ case Toolkit::Slider::Property::VALUE_PRECISION:
{
sliderImpl.SetValuePrecision( value.Get< int >() );
break;
}
- case Toolkit::Slider::SHOW_POPUP_PROPERTY:
+ case Toolkit::Slider::Property::SHOW_POPUP:
{
sliderImpl.SetShowPopup( value.Get< bool >() );
break;
}
- case Toolkit::Slider::SHOW_VALUE_PROPERTY:
+ case Toolkit::Slider::Property::SHOW_VALUE:
{
sliderImpl.SetShowValue( value.Get< bool >() );
break;
}
- case Toolkit::Slider::ENABLED_PROPERTY:
+ case Toolkit::Slider::Property::ENABLED:
{
sliderImpl.SetEnabled( value.Get< bool >() );
break;
}
- case Toolkit::Slider::MARKS_PROPERTY:
+ case Toolkit::Slider::Property::MARKS:
{
sliderImpl.SetMarks( value.Get< Property::Array >() );
break;
}
- case Toolkit::Slider::SNAP_TO_MARKS_PROPERTY:
+ case Toolkit::Slider::Property::SNAP_TO_MARKS:
{
sliderImpl.SetSnapToMarks( value.Get< bool >() );
break;
}
- case Toolkit::Slider::MARK_TOLERANCE_PROPERTY:
+ case Toolkit::Slider::Property::MARK_TOLERANCE:
{
sliderImpl.SetMarkTolerance( value.Get< float >() );
break;
switch ( propertyIndex )
{
- case Toolkit::Slider::LOWER_BOUND_PROPERTY:
+ case Toolkit::Slider::Property::LOWER_BOUND:
{
value = sliderImpl.GetLowerBound();
break;
}
- case Toolkit::Slider::UPPER_BOUND_PROPERTY:
+ case Toolkit::Slider::Property::UPPER_BOUND:
{
value = sliderImpl.GetUpperBound();
break;
}
- case Toolkit::Slider::VALUE_PROPERTY:
+ case Toolkit::Slider::Property::VALUE:
{
value = sliderImpl.GetValue();
break;
}
- case Toolkit::Slider::HIT_REGION_PROPERTY:
+ case Toolkit::Slider::Property::HIT_REGION:
{
value = sliderImpl.GetHitRegion();
break;
}
- case Toolkit::Slider::BACKING_REGION_PROPERTY:
+ case Toolkit::Slider::Property::BACKING_REGION:
{
value = sliderImpl.GetBackingRegion();
break;
}
- case Toolkit::Slider::HANDLE_REGION_PROPERTY:
+ case Toolkit::Slider::Property::HANDLE_REGION:
{
value = sliderImpl.GetHandleRegion();
break;
}
- case Toolkit::Slider::BACKING_IMAGE_NAME_PROPERTY:
+ case Toolkit::Slider::Property::BACKING_IMAGE_NAME:
{
value = sliderImpl.GetBackingImageName();
break;
}
- case Toolkit::Slider::HANDLE_IMAGE_NAME_PROPERTY:
+ case Toolkit::Slider::Property::HANDLE_IMAGE_NAME:
{
value = sliderImpl.GetHandleImageName();
break;
}
- case Toolkit::Slider::PROGRESS_IMAGE_NAME_PROPERTY:
+ case Toolkit::Slider::Property::PROGRESS_IMAGE_NAME:
{
value = sliderImpl.GetProgressImageName();
break;
}
- case Toolkit::Slider::POPUP_IMAGE_NAME_PROPERTY:
+ case Toolkit::Slider::Property::POPUP_IMAGE_NAME:
{
value = sliderImpl.GetPopupImageName();
break;
}
- case Toolkit::Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY:
+ case Toolkit::Slider::Property::POPUP_ARROW_IMAGE_NAME:
{
value = sliderImpl.GetPopupArrowImageName();
break;
}
- case Toolkit::Slider::DISABLE_COLOR_PROPERTY:
+ case Toolkit::Slider::Property::DISABLE_COLOR:
{
value = sliderImpl.GetDisableColor();
break;
}
- case Toolkit::Slider::POPUP_TEXT_COLOR_PROPERTY:
+ case Toolkit::Slider::Property::POPUP_TEXT_COLOR:
{
value = sliderImpl.GetPopupTextColor();
break;
}
- case Toolkit::Slider::VALUE_PRECISION_PROPERTY:
+ case Toolkit::Slider::Property::VALUE_PRECISION:
{
value = sliderImpl.GetValuePrecision();
break;
}
- case Toolkit::Slider::SHOW_POPUP_PROPERTY:
+ case Toolkit::Slider::Property::SHOW_POPUP:
{
value = sliderImpl.GetShowPopup();
break;
}
- case Toolkit::Slider::SHOW_VALUE_PROPERTY:
+ case Toolkit::Slider::Property::SHOW_VALUE:
{
value = sliderImpl.GetShowValue();
break;
}
- case Toolkit::Slider::ENABLED_PROPERTY:
+ case Toolkit::Slider::Property::ENABLED:
{
value = sliderImpl.IsEnabled();
break;
}
- case Toolkit::Slider::MARKS_PROPERTY:
+ case Toolkit::Slider::Property::MARKS:
{
// TODO: Need to be able to return a PropertyArray
// value = sliderImpl.GetMarks();
break;
}
- case Toolkit::Slider::SNAP_TO_MARKS_PROPERTY:
+ case Toolkit::Slider::Property::SNAP_TO_MARKS:
{
value = sliderImpl.GetSnapToMarks();
break;
}
- case Toolkit::Slider::MARK_TOLERANCE_PROPERTY:
+ case Toolkit::Slider::Property::MARK_TOLERANCE:
{
value = sliderImpl.GetMarkTolerance();
break;
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/slider/slider.h>
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
namespace Dali
{
{
public:
- // Properties
- enum
- {
- SLIDER_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
- SLIDER_PROPERTY_END_INDEX = SLIDER_PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
- };
-
typedef Property::Array MarkList;
/**
*
* @return The textview created for the popup
*/
- Toolkit::TextView CreatePopupText();
+ //Toolkit::TextView CreatePopupText();
/**
* Create the value display for the slider
ImageActor mPopup; ///< Popup backing
ImageActor mPopupArrow; ///< Popup arrow backing
- Toolkit::TextView mValueTextView; //< The text value in popup
- Toolkit::TextView mHandleValueTextView; ///< The text value on handle
Vector2 mHandleLastTouchPoint; ///< The last touch point for the handle
Timer mValueTimer; ///< Timer used to hide value view
--- /dev/null
- TypeRegistration mType( typeid(Toolkit::TextField), typeid(Toolkit::Control), Create );
-
+/*
+ * Copyright (c) 2015 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/controls/text-controls/text-field-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/images/resource-image.h>
+#include <dali/public-api/object/type-registry.h>
++#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/layouts/layout-engine.h>
+#include <dali-toolkit/internal/text/rendering/text-backend.h>
+
+using namespace Dali::Toolkit::Text;
+
+namespace
+{
+
+const unsigned int DEFAULT_RENDERING_BACKEND = 0;
+
+} // namespace
+
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+
+// Type registration
+BaseHandle Create()
+{
+ return Toolkit::TextField::New();
+}
+
- DALI_PROPERTY_REGISTRATION( TextField, "rendering-backend", INT, RENDERING_BACKEND )
+// Setup properties, signals and actions using the type-registry.
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextField, Toolkit::Control, Create );
+
- case Toolkit::TextField::PROPERTY_RENDERING_BACKEND:
++DALI_PROPERTY_REGISTRATION( TextField, "rendering-backend", INTEGER, RENDERING_BACKEND )
+DALI_PROPERTY_REGISTRATION( TextField, "placeholder-text", STRING, PLACEHOLDER_TEXT )
+DALI_PROPERTY_REGISTRATION( TextField, "text", STRING, TEXT )
+DALI_PROPERTY_REGISTRATION( TextField, "font-family", STRING, FONT_FAMILY )
+DALI_PROPERTY_REGISTRATION( TextField, "font-style", STRING, FONT_STYLE )
+DALI_PROPERTY_REGISTRATION( TextField, "point-size", FLOAT, POINT_SIZE )
+DALI_PROPERTY_REGISTRATION( TextField, "cursor-image", STRING, CURSOR_IMAGE )
+DALI_PROPERTY_REGISTRATION( TextField, "primary-cursor-color", VECTOR4, PRIMARY_CURSOR_COLOR )
+DALI_PROPERTY_REGISTRATION( TextField, "secondary-cursor-color", VECTOR4, SECONDARY_CURSOR_COLOR )
+DALI_PROPERTY_REGISTRATION( TextField, "enable-cursor-blink", BOOLEAN, ENABLE_CURSOR_BLINK )
+DALI_PROPERTY_REGISTRATION( TextField, "cursor-blink-interval", FLOAT, CURSOR_BLINK_INTERVAL )
+DALI_PROPERTY_REGISTRATION( TextField, "cursor-blink-duration", FLOAT, CURSOR_BLINK_DURATION )
+DALI_PROPERTY_REGISTRATION( TextField, "grab-handle-image", STRING, GRAB_HANDLE_IMAGE )
+DALI_PROPERTY_REGISTRATION( TextField, "decoration bounding-box", RECTANGLE, DECORATION_BOUNDING_BOX )
+
+DALI_TYPE_REGISTRATION_END()
+
+} // namespace
+
+Toolkit::TextField TextField::New()
+{
+ // Create the implementation, temporarily owned by this handle on stack
+ IntrusivePtr< TextField > impl = new TextField();
+
+ // Pass ownership to CustomActor handle
+ Toolkit::TextField handle( *impl );
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ impl->Initialize();
+
+ return handle;
+}
+
+void TextField::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+ Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
+
+ if( textField )
+ {
+ TextField& impl( GetImpl( textField ) );
+
+ switch( index )
+ {
- case Toolkit::TextField::PROPERTY_PLACEHOLDER_TEXT:
++ case Toolkit::TextField::Property::RENDERING_BACKEND:
+ {
+ unsigned int backend = value.Get< unsigned int >();
+
+ if( impl.mRenderingBackend != backend )
+ {
+ impl.mRenderingBackend = backend;
+ impl.mRenderer.Reset();
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_TEXT:
++ case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
+ {
+ if( impl.mController )
+ {
+ //impl.mController->SetPlaceholderText( value.Get< std::string >() ); TODO
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_CURSOR_IMAGE:
++ case Toolkit::TextField::Property::TEXT:
+ {
+ if( impl.mController )
+ {
+ impl.mController->SetText( value.Get< std::string >() );
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_PRIMARY_CURSOR_COLOR:
++ case Toolkit::TextField::Property::CURSOR_IMAGE:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetCursorImage( image );
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_SECONDARY_CURSOR_COLOR:
++ case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetColor( PRIMARY_CURSOR, value.Get< Vector4 >() );
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_ENABLE_CURSOR_BLINK:
++ case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetColor( SECONDARY_CURSOR, value.Get< Vector4 >() );
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_CURSOR_BLINK_INTERVAL:
++ case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
+ {
+ if( impl.mController )
+ {
+ //impl.mController->SetEnableCursorBlink( value.Get< bool >() ); TODO
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_CURSOR_BLINK_DURATION:
++ case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetCursorBlinkInterval( value.Get< float >() );
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_GRAB_HANDLE_IMAGE:
++ case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetCursorBlinkDuration( value.Get< float >() );
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_DECORATION_BOUNDING_BOX:
++ case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
+ {
+ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetGrabHandleImage( image );
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_RENDERING_BACKEND:
++ case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetBoundingBox( value.Get< Rect<int> >() );
+ }
+ break;
+ }
+ }
+ }
+}
+
+Property::Value TextField::GetProperty( BaseObject* object, Property::Index index )
+{
+ Property::Value value;
+
+ Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
+
+ if( textField )
+ {
+ TextField& impl( GetImpl( textField ) );
+
+ switch( index )
+ {
- case Toolkit::TextField::PROPERTY_PLACEHOLDER_TEXT:
++ case Toolkit::TextField::Property::RENDERING_BACKEND:
+ {
+ value = impl.mRenderingBackend;
+ break;
+ }
- case Toolkit::TextField::PROPERTY_TEXT:
++ case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
+ {
+ DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" );
+ break;
+ }
- case Toolkit::TextField::PROPERTY_CURSOR_IMAGE:
++ case Toolkit::TextField::Property::TEXT:
+ {
+ DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" );
+ break;
+ }
- case Toolkit::TextField::PROPERTY_PRIMARY_CURSOR_COLOR:
++ case Toolkit::TextField::Property::CURSOR_IMAGE:
+ {
+ if( impl.mDecorator )
+ {
+ ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetCursorImage() );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_SECONDARY_CURSOR_COLOR:
++ case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetColor( PRIMARY_CURSOR );
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_ENABLE_CURSOR_BLINK:
++ case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetColor( SECONDARY_CURSOR );
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_CURSOR_BLINK_INTERVAL:
++ case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
+ {
+ //value = impl.mController->GetEnableCursorBlink(); TODO
+ break;
+ }
- case Toolkit::TextField::PROPERTY_CURSOR_BLINK_DURATION:
++ case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetCursorBlinkInterval();
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_GRAB_HANDLE_IMAGE:
++ case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetCursorBlinkDuration();
+ }
+ break;
+ }
- case Toolkit::TextField::PROPERTY_DECORATION_BOUNDING_BOX:
++ case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
+ {
+ if( impl.mDecorator )
+ {
+ ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetCursorImage() );
+ if( image )
+ {
+ value = image.GetUrl();
+ }
+ }
+ break;
+ }
++ case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetBoundingBox();
+ }
+ break;
+ }
+ }
+ }
+
+ return value;
+}
+
+void TextField::OnInitialize()
+{
+ mController = Text::Controller::New( *this );
+
+ mDecorator = Text::Decorator::New( *this, *mController );
+
+ mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
+
+ mController->EnableTextInput( mDecorator );
+
+ // Forward input events to controller
+ mDoubleTapDetector = TapGestureDetector::New();
+ mDoubleTapDetector.SetMaximumTapsRequired( 2 );
+ mDoubleTapDetector.DetectedSignal().Connect( this, &TextField::OnTap );
+ mDoubleTapDetector.Attach(Self());
+
+ // Set BoundingBox to stage size if not already set.
+ if ( mDecorator->GetBoundingBox().IsEmpty() )
+ {
+ Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
+ mDecorator->SetBoundingBox( Rect<int>( 0.0f, 0.0f, stageSize.width, stageSize.height ) );
+ }
+}
+
+Vector3 TextField::GetNaturalSize()
+{
+ return mController->GetNaturalSize();
+}
+
+float TextField::GetHeightForWidth( float width )
+{
+ return mController->GetHeightForWidth( width );
+}
+
+void TextField::OnRelayout( const Vector2& size, ActorSizeContainer& container )
+{
+ if( mController->Relayout( size ) )
+ {
+ if( mDecorator )
+ {
+ mDecorator->Relayout( size );
+ }
+
+ if( !mRenderer )
+ {
+ mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
+ }
+
+ if( mRenderer )
+ {
+ Actor renderableActor = mRenderer->Render( mController->GetView() );
+
+ if( renderableActor )
+ {
+ Self().Add( renderableActor );
+ }
+ }
+ }
+}
+
+void TextField::OnTap( Actor actor, const TapGesture& gesture )
+{
+ mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y );
+}
+
+void TextField::RequestTextRelayout()
+{
+ RelayoutRequest();
+}
+
+TextField::TextField()
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) ),
+ mRenderingBackend( DEFAULT_RENDERING_BACKEND )
+{
+}
+
+TextField::~TextField()
+{
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
- // Properties
- enum
- {
- TEXTFIELD_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
- TEXTFIELD_PROPERTY_END_INDEX = TEXTFIELD_PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
- };
-
+#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
+#define __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/public-api/controls/text-controls/text-field.h>
+#include <dali-toolkit/internal/text/decorator/text-decorator.h>
+#include <dali-toolkit/internal/text/text-control-interface.h>
+#include <dali-toolkit/internal/text/text-controller.h>
+#include <dali-toolkit/internal/text/rendering/text-renderer.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * @brief A control which renders a short text string.
+ */
+class TextField : public Control, public Text::ControlInterface
+{
+public:
+
+ /**
+ * @copydoc Dali::Toollkit::TextField::New()
+ */
+ static Toolkit::TextField New();
+
+ // Properties
+
+ /**
+ * Called when a property of an object of this type is set.
+ * @param[in] object The object whose property is set.
+ * @param[in] index The property index.
+ * @param[in] value The new property value.
+ */
+ static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
+
+ /**
+ * Called to retrieve a property of an object of this type.
+ * @param[in] object The object whose property is to be retrieved.
+ * @param[in] index The property index.
+ * @return The current value of the property.
+ */
+ static Property::Value GetProperty( BaseObject* object, Property::Index index );
+
+private: // From Control
+
+ /**
+ * @copydoc Control::OnInitialize()
+ */
+ virtual void OnInitialize();
+
+ /**
+ * @copydoc Control::GetNaturalSize()
+ */
+ virtual Vector3 GetNaturalSize();
+
+ /**
+ * @copydoc Control::GetHeightForWidth()
+ */
+ virtual float GetHeightForWidth( float width );
+
+ /**
+ * @copydoc Control::OnInitialize()
+ */
+ virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
+
+ /**
+ * Received for single & double taps
+ */
+ void OnTap( Actor actor, const TapGesture& tap );
+
+ /**
+ * @copydoc Text::ControlInterface::RequestTextRelayout()
+ */
+ virtual void RequestTextRelayout();
+
+private: // Implementation
+
+ /**
+ * Construct a new TextField.
+ */
+ TextField();
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~TextField();
+
+private:
+
+ // Undefined copy constructor and assignment operators
+ TextField(const TextField&);
+ TextField& operator=(const TextField& rhs);
+
+private: // Data
+
+ Text::ControllerPtr mController;
+ Text::RendererPtr mRenderer;
+ Text::DecoratorPtr mDecorator;
+
+ TapGestureDetector mDoubleTapDetector;
+
+ unsigned int mRenderingBackend;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Toolkit::Internal::TextField& GetImpl( Toolkit::TextField& textField )
+{
+ DALI_ASSERT_ALWAYS(textField);
+
+ Dali::RefObject& handle = textField.GetImplementation();
+
+ return static_cast<Toolkit::Internal::TextField&>(handle);
+}
+
+inline const Toolkit::Internal::TextField& GetImpl( const Toolkit::TextField& textField )
+{
+ DALI_ASSERT_ALWAYS(textField);
+
+ const Dali::RefObject& handle = textField.GetImplementation();
+
+ return static_cast<const Toolkit::Internal::TextField&>(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H__
--- /dev/null
- DALI_PROPERTY_REGISTRATION( TextLabel, "rendering-backend", INT, RENDERING_BACKEND )
+/*
+ * Copyright (c) 2015 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/controls/text-controls/text-label-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
++#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/layouts/layout-engine.h>
+#include <dali-toolkit/internal/text/rendering/text-backend.h>
+
+using Dali::Toolkit::Text::LayoutEngine;
+using Dali::Toolkit::Text::Backend;
+
+namespace
+{
+
+const unsigned int DEFAULT_RENDERING_BACKEND = 0;
+
+} // namespace
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+
+// Type registration
+BaseHandle Create()
+{
+ return Toolkit::TextLabel::New();
+}
+
+// Setup properties, signals and actions using the type-registry.
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextLabel, Toolkit::Control, Create );
+
- case Toolkit::TextLabel::PROPERTY_RENDERING_BACKEND:
++DALI_PROPERTY_REGISTRATION( TextLabel, "rendering-backend", INTEGER, RENDERING_BACKEND )
+DALI_PROPERTY_REGISTRATION( TextLabel, "text", STRING, TEXT )
+DALI_PROPERTY_REGISTRATION( TextLabel, "font-family", STRING, FONT_FAMILY )
+DALI_PROPERTY_REGISTRATION( TextLabel, "font-style", STRING, FONT_STYLE )
+DALI_PROPERTY_REGISTRATION( TextLabel, "point-size", FLOAT, POINT_SIZE )
+DALI_PROPERTY_REGISTRATION( TextLabel, "multi-line", BOOLEAN, MULTI_LINE )
+
+DALI_TYPE_REGISTRATION_END()
+
+} // namespace
+
+Toolkit::TextLabel TextLabel::New()
+{
+ // Create the implementation, temporarily owned by this handle on stack
+ IntrusivePtr< TextLabel > impl = new TextLabel();
+
+ // Pass ownership to CustomActor handle
+ Toolkit::TextLabel handle( *impl );
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ impl->Initialize();
+
+ return handle;
+}
+
+void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+ Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( Dali::BaseHandle( object ) );
+
+ if( label )
+ {
+ TextLabel& impl( GetImpl( label ) );
+ switch( index )
+ {
- case Toolkit::TextLabel::PROPERTY_TEXT:
++ case Toolkit::TextLabel::Property::RENDERING_BACKEND:
+ {
+ unsigned int backend = value.Get< int >();
+
+ if( impl.mRenderingBackend != backend )
+ {
+ impl.mRenderingBackend = static_cast< unsigned int >( backend );
+ impl.mRenderer.Reset();
+ impl.RequestTextRelayout();
+ }
+ break;
+ }
- case Toolkit::TextLabel::PROPERTY_FONT_FAMILY:
++ case Toolkit::TextLabel::Property::TEXT:
+ {
+ if( impl.mController )
+ {
+ impl.mController->SetText( value.Get< std::string >() );
+ impl.RequestTextRelayout();
+ }
+ break;
+ }
- case Toolkit::TextLabel::PROPERTY_FONT_STYLE:
++ case Toolkit::TextLabel::Property::FONT_FAMILY:
+ {
+ if( impl.mController )
+ {
+ std::string fontFamily = value.Get< std::string >();
+
+ if( impl.mController->GetDefaultFontFamily() != fontFamily )
+ {
+ impl.mController->SetDefaultFontFamily( fontFamily );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
- case Toolkit::TextLabel::PROPERTY_POINT_SIZE:
++ case Toolkit::TextLabel::Property::FONT_STYLE:
+ {
+ if( impl.mController )
+ {
+ std::string fontStyle = value.Get< std::string >();
+
+ if( impl.mController->GetDefaultFontStyle() != fontStyle )
+ {
+ impl.mController->SetDefaultFontStyle( fontStyle );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
- case Toolkit::TextLabel::PROPERTY_MULTI_LINE:
++ case Toolkit::TextLabel::Property::POINT_SIZE:
+ {
+ if( impl.mController )
+ {
+ float pointSize = value.Get< float >();
+
+ if( impl.mController->GetDefaultPointSize() != pointSize /*TODO - epsilon*/ )
+ {
+ impl.mController->SetDefaultPointSize( pointSize );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
- case Toolkit::TextLabel::PROPERTY_RENDERING_BACKEND:
++ case Toolkit::TextLabel::Property::MULTI_LINE:
+ {
+ if( impl.mController )
+ {
+ LayoutEngine& engine = impl.mController->GetLayoutEngine();
+ LayoutEngine::Layout layout = value.Get< bool >() ? LayoutEngine::MULTI_LINE_BOX : LayoutEngine::SINGLE_LINE_BOX;
+
+ if( engine.GetLayout() != layout )
+ {
+ impl.mController->GetLayoutEngine().SetLayout( layout );
+ impl.RequestTextRelayout();
+ }
+ }
+ break;
+ }
+ }
+ }
+}
+
+Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index index )
+{
+ Property::Value value;
+
+ Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( Dali::BaseHandle( object ) );
+
+ if( label )
+ {
+ TextLabel& impl( GetImpl( label ) );
+ switch( index )
+ {
- case Toolkit::TextLabel::PROPERTY_TEXT:
++ case Toolkit::TextLabel::Property::RENDERING_BACKEND:
+ {
+ value = impl.mRenderingBackend;
+ break;
+ }
- case Toolkit::TextLabel::PROPERTY_MULTI_LINE:
++ case Toolkit::TextLabel::Property::TEXT:
+ {
+ if( impl.mController )
+ {
+ std::string text;
+ impl.mController->GetText( text );
+ value = text;
+ }
+
+ DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" );
+ break;
+ }
++ case Toolkit::TextLabel::Property::MULTI_LINE:
+ {
+ if( impl.mController )
+ {
+ value = static_cast<bool>( LayoutEngine::MULTI_LINE_BOX == impl.mController->GetLayoutEngine().GetLayout() );
+ }
+ break;
+ }
+ }
+ }
+
+ return value;
+}
+
+void TextLabel::OnInitialize()
+{
+ mController = Text::Controller::New( *this );
+}
+
+Vector3 TextLabel::GetNaturalSize()
+{
+ return mController->GetNaturalSize();
+}
+
+float TextLabel::GetHeightForWidth( float width )
+{
+ return mController->GetHeightForWidth( width );
+}
+
+void TextLabel::OnRelayout( const Vector2& size, ActorSizeContainer& container )
+{
+ if( mController->Relayout( size ) ||
+ !mRenderer )
+ {
+ if( !mRenderer )
+ {
+ mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
+ }
+
+ RenderableActor renderableActor;
+ if( mRenderer )
+ {
+ renderableActor = mRenderer->Render( mController->GetView() );
+ }
+
+ if( renderableActor != mRenderableActor )
+ {
+ UnparentAndReset( mRenderableActor );
+
+ if( renderableActor )
+ {
+ Self().Add( renderableActor );
+ }
+
+ mRenderableActor = renderableActor;
+ }
+ }
+}
+
+void TextLabel::RequestTextRelayout()
+{
+ RelayoutRequest();
+}
+
+TextLabel::TextLabel()
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) ),
+ mRenderingBackend( DEFAULT_RENDERING_BACKEND )
+{
+}
+
+TextLabel::~TextLabel()
+{
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
- // Properties
- enum
- {
- TEXTLABEL_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
- TEXTLABEL_PROPERTY_END_INDEX = TEXTLABEL_PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
- };
-
+#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
+#define __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
+#include <dali-toolkit/internal/text/text-controller.h>
+#include <dali-toolkit/internal/text/rendering/text-renderer.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * @brief A control which renders a short text string.
+ */
+class TextLabel : public Control, public Text::ControlInterface
+{
+public:
+
+ /**
+ * @copydoc Dali::Toollkit::TextLabel::New()
+ */
+ static Toolkit::TextLabel New();
+
+ // Properties
+
+ /**
+ * Called when a property of an object of this type is set.
+ * @param[in] object The object whose property is set.
+ * @param[in] index The property index.
+ * @param[in] value The new property value.
+ */
+ static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
+
+ /**
+ * Called to retrieve a property of an object of this type.
+ * @param[in] object The object whose property is to be retrieved.
+ * @param[in] index The property index.
+ * @return The current value of the property.
+ */
+ static Property::Value GetProperty( BaseObject* object, Property::Index index );
+
+private: // From Control
+
+ /**
+ * @copydoc Control::OnInitialize()
+ */
+ virtual void OnInitialize();
+
+ /**
+ * @copydoc Control::OnInitialize()
+ */
+ virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
+
+ /**
+ * @copydoc Control::GetNaturalSize()
+ */
+ virtual Vector3 GetNaturalSize();
+
+ /**
+ * @copydoc Control::GetHeightForWidth()
+ */
+ virtual float GetHeightForWidth( float width );
+
+ /**
+ * @copydoc Text::ControlInterface::RequestTextRelayout()
+ */
+ virtual void RequestTextRelayout();
+
+private: // Implementation
+
+ /**
+ * Construct a new TextLabel.
+ */
+ TextLabel();
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~TextLabel();
+
+private:
+
+ // Undefined copy constructor and assignment operators
+ TextLabel(const TextLabel&);
+ TextLabel& operator=(const TextLabel& rhs);
+
+private: // Data
+
+ Text::ControllerPtr mController;
+ Text::RendererPtr mRenderer;
+ RenderableActor mRenderableActor;
+
+ unsigned int mRenderingBackend;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Toolkit::Internal::TextLabel& GetImpl( Toolkit::TextLabel& textLabel )
+{
+ DALI_ASSERT_ALWAYS(textLabel);
+
+ Dali::RefObject& handle = textLabel.GetImplementation();
+
+ return static_cast<Toolkit::Internal::TextLabel&>(handle);
+}
+
+inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& textLabel )
+{
+ DALI_ASSERT_ALWAYS(textLabel);
+
+ const Dali::RefObject& handle = textLabel.GetImplementation();
+
+ return static_cast<const Toolkit::Internal::TextLabel&>(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
--- /dev/null
- PROPERTY_RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "rendering-backend", The type or rendering e.g. bitmap-based, type INT
- PROPERTY_PLACEHOLDER_TEXT, ///< name "placeholder-text", The text to display when the TextField is empty, type STRING
- PROPERTY_TEXT, ///< name "text", The text to display in UTF-8 format, type STRING
- PROPERTY_FONT_FAMILY, ///< name "font-family", The requested font family, type STRING
- PROPERTY_FONT_STYLE, ///< name "font-style", The requested font style e.g. Regular/Italic, type STRING
- PROPERTY_POINT_SIZE, ///< name "point-size", The size of font in points, type FLOAT
- PROPERTY_CURSOR_IMAGE, ///< name "cursor-image", The image to display for cursors, type STRING
- PROPERTY_PRIMARY_CURSOR_COLOR, ///< name "primary-cursor-color", The color to apply to the primary cursor, type VECTOR4
- PROPERTY_SECONDARY_CURSOR_COLOR, ///< name "secondary-cursor-color", The color to apply to the secondary cursor, type VECTOR4
- PROPERTY_ENABLE_CURSOR_BLINK, ///< name "enable-cursor-blink", Whether the cursor should blink or not, type BOOLEAN
- PROPERTY_CURSOR_BLINK_INTERVAL, ///< name "cursor-blink-interval", The time interval between cursor on/off states, type FLOAT
- PROPERTY_CURSOR_BLINK_DURATION, ///< name "cursor-blink-duration", The cursor will stop blinking after this duration (if non-zero), type FLOAT
- PROPERTY_GRAB_HANDLE_IMAGE, ///< name "grab-handle-image", The image to display for grab handle, type STRING
- PROPERTY_DECORATION_BOUNDING_BOX ///< name "decoration-bounding-box", The decorations (handles etc) will positioned within this area on-screen, type RECTANGLE
+#ifndef __DALI_TOOLKIT_TEXT_FIELD_H__
+#define __DALI_TOOLKIT_TEXT_FIELD_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+class TextField;
+}
+
+/**
+ * @brief A control which provides a single-line editable text field.
+ */
+class DALI_IMPORT_API TextField : public Control
+{
+public:
+
+ /**
+ * @brief The start and end property ranges for this control.
+ */
+ enum PropertyRange
+ {
+ PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
+ PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices
+ };
+
+ /**
+ * @brief An enumeration of properties belonging to the TextLabel class.
+ */
+ struct Property
+ {
+ enum
+ {
++ RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "rendering-backend", The type or rendering e.g. bitmap-based, type INT
++ PLACEHOLDER_TEXT, ///< name "placeholder-text", The text to display when the TextField is empty, type STRING
++ TEXT, ///< name "text", The text to display in UTF-8 format, type STRING
++ FONT_FAMILY, ///< name "font-family", The requested font family, type STRING
++ FONT_STYLE, ///< name "font-style", The requested font style e.g. Regular/Italic, type STRING
++ POINT_SIZE, ///< name "point-size", The size of font in points, type FLOAT
++ CURSOR_IMAGE, ///< name "cursor-image", The image to display for cursors, type STRING
++ PRIMARY_CURSOR_COLOR, ///< name "primary-cursor-color", The color to apply to the primary cursor, type VECTOR4
++ SECONDARY_CURSOR_COLOR, ///< name "secondary-cursor-color", The color to apply to the secondary cursor, type VECTOR4
++ ENABLE_CURSOR_BLINK, ///< name "enable-cursor-blink", Whether the cursor should blink or not, type BOOLEAN
++ CURSOR_BLINK_INTERVAL, ///< name "cursor-blink-interval", The time interval between cursor on/off states, type FLOAT
++ CURSOR_BLINK_DURATION, ///< name "cursor-blink-duration", The cursor will stop blinking after this duration (if non-zero), type FLOAT
++ GRAB_HANDLE_IMAGE, ///< name "grab-handle-image", The image to display for grab handle, type STRING
++ DECORATION_BOUNDING_BOX ///< name "decoration-bounding-box", The decorations (handles etc) will positioned within this area on-screen, type RECTANGLE
+ };
+ };
+
+ /**
+ * Create the TextField control.
+ * @return A handle to the TextField control.
+ */
+ static TextField New();
+
+ /**
+ * @brief Creates an empty handle.
+ */
+ TextField();
+
+ /**
+ * @brief Copy constructor.
+ *
+ * @param[in] handle The handle to copy from.
+ */
+ TextField( const TextField& handle );
+
+ /**
+ * @brief Assignment operator.
+ *
+ * @param[in] handle The handle to copy from.
+ * @return A reference to this.
+ */
+ TextField& operator=( const TextField& handle );
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~TextField();
+
+ /**
+ * @brief Downcast a handle to TextField.
+ *
+ * If the BaseHandle points is a TextField the downcast returns a valid handle.
+ * If not the returned handle is left empty.
+ *
+ * @param[in] handle Handle to an object
+ * @return handle to a TextField or an empty handle
+ */
+ static TextField DownCast( BaseHandle handle );
+
+public: // Not intended for application developers
+
+ /**
+ * @brief Creates a handle using the Toolkit::Internal implementation.
+ *
+ * @param[in] implementation The Control implementation.
+ */
+ DALI_INTERNAL TextField( Internal::TextField& implementation );
+
+ /**
+ * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
+ *
+ * @param[in] internal A pointer to the internal CustomActor.
+ */
+ explicit DALI_INTERNAL TextField( Dali::Internal::CustomActor* internal );
+};
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_TEXT_FIELD_H__
--- /dev/null
- PROPERTY_RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "rendering-backend", The type or rendering e.g. bitmap-based, type INT
- PROPERTY_TEXT, ///< name "text", The text to display in UTF-8 format, type STRING
- PROPERTY_FONT_FAMILY, ///< name "font-family", The requested font family, type STRING
- PROPERTY_FONT_STYLE, ///< name "font-style", The requested font style e.g. Regular/Italic, type STRING
- PROPERTY_POINT_SIZE, ///< name "point-size", The size of font in points, type FLOAT
- PROPERTY_MULTI_LINE, ///< name "multi-line", The single-line or multi-line layout option, type BOOLEAN
+#ifndef __DALI_TOOLKIT_TEXT_LABEL_H__
+#define __DALI_TOOLKIT_TEXT_LABEL_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+class TextLabel;
+}
+
+/**
+ * @brief A control which renders a short text string.
+ *
+ * Text labels are lightweight, non-editable and do not respond to user input.
+ */
+class DALI_IMPORT_API TextLabel : public Control
+{
+public:
+
+ /**
+ * @brief The start and end property ranges for this control.
+ */
+ enum PropertyRange
+ {
+ PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
+ PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices
+ };
+
+ /**
+ * @brief An enumeration of properties belonging to the TextLabel class.
+ */
+ struct Property
+ {
+ enum
+ {
++ RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "rendering-backend", The type or rendering e.g. bitmap-based, type INT
++ TEXT, ///< name "text", The text to display in UTF-8 format, type STRING
++ FONT_FAMILY, ///< name "font-family", The requested font family, type STRING
++ FONT_STYLE, ///< name "font-style", The requested font style e.g. Regular/Italic, type STRING
++ POINT_SIZE, ///< name "point-size", The size of font in points, type FLOAT
++ MULTI_LINE, ///< name "multi-line", The single-line or multi-line layout option, type BOOLEAN
+ };
+ };
+
+ /**
+ * Create the TextLabel control.
+ * @return A handle to the TextLabel control.
+ */
+ static TextLabel New();
+
+ /**
+ * @brief Creates an empty handle.
+ */
+ TextLabel();
+
+ /**
+ * @brief Copy constructor.
+ *
+ * @param[in] handle The handle to copy from.
+ */
+ TextLabel( const TextLabel& handle );
+
+ /**
+ * @brief Assignment operator.
+ *
+ * @param[in] handle The handle to copy from.
+ * @return A reference to this.
+ */
+ TextLabel& operator=( const TextLabel& handle );
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~TextLabel();
+
+ /**
+ * @brief Downcast a handle to TextLabel.
+ *
+ * If the BaseHandle points is a TextLabel the downcast returns a valid handle.
+ * If not the returned handle is left empty.
+ *
+ * @param[in] handle Handle to an object
+ * @return handle to a TextLabel or an empty handle
+ */
+ static TextLabel DownCast( BaseHandle handle );
+
+public: // Not intended for application developers
+
+ /**
+ * @brief Creates a handle using the Toolkit::Internal implementation.
+ *
+ * @param[in] implementation The Control implementation.
+ */
+ DALI_INTERNAL TextLabel( Internal::TextLabel& implementation );
+
+ /**
+ * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
+ *
+ * @param[in] internal A pointer to the internal CustomActor.
+ */
+ explicit DALI_INTERNAL TextLabel( Dali::Internal::CustomActor* internal );
+};
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_TEXT_LABEL_H__