# List of test case sources (Only these get parsed for test cases)
SET(TC_SOURCES
+ utc-Dali-BidirectionalSupport.cpp
+ utc-Dali-ColorConversion.cpp
+ utc-Dali-DebugRendering.cpp
+ utc-Dali-ItemView-internal.cpp
+ utc-Dali-LogicalModel.cpp
+ utc-Dali-PropertyHelper.cpp
utc-Dali-Text-CharacterSetConversion.cpp
+ utc-Dali-Text-Controller.cpp
utc-Dali-Text-Cursor.cpp
- utc-Dali-Text-Segmentation.cpp
- utc-Dali-Text-MultiLanguage.cpp
- utc-Dali-LogicalModel.cpp
- utc-Dali-BidirectionalSupport.cpp
- utc-Dali-Text-Shaping.cpp
- utc-Dali-VisualModel.cpp
utc-Dali-Text-Layout.cpp
- utc-Dali-Text-Controller.cpp
- utc-Dali-VisualUrl.cpp
utc-Dali-Text-Markup.cpp
+ utc-Dali-Text-MultiLanguage.cpp
+ utc-Dali-Text-Segmentation.cpp
+ utc-Dali-Text-Shaping.cpp
utc-Dali-Text-Typesetter.cpp
utc-Dali-Text-ViewModel.cpp
- utc-Dali-DebugRendering.cpp
- utc-Dali-ItemView-internal.cpp
- utc-Dali-PropertyHelper.cpp
- utc-Dali-ColorConversion.cpp
+ utc-Dali-TextureManager.cpp
+ utc-Dali-VisualModel.cpp
+ utc-Dali-VisualUrl.cpp
)
# Append list of test harness files (Won't get parsed for test cases)
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/internal/visuals/texture-manager.h>
+#include <dali-toolkit/internal/visuals/texture-upload-observer.h>
+
+using namespace Dali::Toolkit::Internal;
+
+class TestObserver : public Dali::Toolkit::TextureUploadObserver
+{
+public:
+ TestObserver()
+ : mLoaded(false),
+ mObserverCalled(false)
+ {
+ }
+
+ void UploadComplete( bool loadSuccess, TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect )
+ {
+ mLoaded = loadSuccess;
+ mObserverCalled = true;
+ }
+
+ bool mLoaded;
+ bool mObserverCalled;
+};
+
+
+int UtcTextureManagerRequestLoad(void)
+{
+ ToolkitTestApplication application;
+
+ TextureManager textureManager; // Create new texture manager
+
+ TestObserver observer;
+ std::string filename("image.png");
+
+ TextureManager::TextureId textureId = textureManager.RequestLoad(
+ filename,
+ ImageDimensions(),
+ FittingMode::SCALE_TO_FILL,
+ SamplingMode::BOX_THEN_LINEAR,
+ TextureManager::NO_ATLAS,
+ &observer );
+
+ const VisualUrl& url = textureManager.GetVisualUrl( textureId );
+
+ DALI_TEST_EQUALS( url.GetUrl().compare( filename ), 0, TEST_LOCATION );
+
+ END_TEST;
+}
../dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp
- ../dali-toolkit/dali-toolkit-test-utils/toolkit-bitmap-loader.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-color-controller.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.cpp
{
+ "config":
+ {
+ "alwaysShowFocus":false
+ },
"constants":
{
"CONFIG_SCRIPT_LOG_LEVEL":"NoLogging"
dali-toolkit-test-utils/toolkit-adaptor.cpp
dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp
dali-toolkit-test-utils/toolkit-application.cpp
- dali-toolkit-test-utils/toolkit-bitmap-loader.cpp
dali-toolkit-test-utils/toolkit-clipboard.cpp
dali-toolkit-test-utils/toolkit-clipboard-event-notifier.cpp
dali-toolkit-test-utils/toolkit-event-thread-callback.cpp
dali-toolkit-test-utils/toolkit-tts-player.cpp
dali-toolkit-test-utils/toolkit-native-image-source.cpp
dali-toolkit-test-utils/toolkit-video-player.cpp
+ dali-toolkit-test-utils/toolkit-trigger-event-factory.cpp
dali-toolkit-test-utils/dali-test-suite-utils.cpp
dali-toolkit-test-utils/dummy-control.cpp
dali-toolkit-test-utils/mesh-builder.cpp
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// CLASS HEADER
-#include "toolkit-bitmap-loader.h"
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-object.h>
-#include <cstring>
-#include <semaphore.h>
-
-using namespace Dali;
-
-namespace Dali
-{
-namespace
-{
-Dali::BitmapLoader gBitmapLoader;
-}
-
-
-namespace Internal
-{
-
-class BitmapLoader : public BaseObject
-{
-public:
- static IntrusivePtr<BitmapLoader> New( const std::string& url,
- ImageDimensions size,
- FittingMode::Type fittingMode,
- SamplingMode::Type samplingMode,
- bool orientationCorrection)
- {
- IntrusivePtr<BitmapLoader> internal = new BitmapLoader( url, size, fittingMode, samplingMode, orientationCorrection );
- return internal;
- }
-
- BitmapLoader(const std::string& url,
- ImageDimensions size,
- FittingMode::Type fittingMode,
- SamplingMode::Type samplingMode,
- bool orientationCorrection)
- : mSize(size),
- mPixelData(),
- mUrl(url)
- {
- sem_init( &mySemaphore, 0, 0 );
- }
-
- ~BitmapLoader(){}
-
- void Load()
- {
- size_t bufferSize = mSize.GetWidth() * mSize.GetHeight() * 4;
- unsigned char* buffer = static_cast<unsigned char*>(malloc(bufferSize));
- memset(buffer, 0, bufferSize);
-
- mPixelData = Dali::PixelData::New( buffer, bufferSize, mSize.GetWidth(), mSize.GetHeight(), Pixel::RGBA8888, Dali::PixelData::FREE);
-
- sem_post( &mySemaphore );
- }
-
- Dali::PixelData GetPixelData() const
- {
- return mPixelData;
- }
-
- const std::string& GetUrl() const
- {
- return mUrl;
- }
-
- bool IsLoaded()
- {
- return mPixelData ? true : false;
- }
-
- void WaitForLoading()
- {
- if( mPixelData )
- {
- return;
- }
- sem_wait( &mySemaphore );
- }
-
- ImageDimensions mSize;
- Dali::PixelData mPixelData;
- const std::string mUrl;
- sem_t mySemaphore;
-};
-
-} // internal
-
-inline Internal::BitmapLoader& GetImplementation(Dali::BitmapLoader& handle)
-{
- DALI_ASSERT_ALWAYS( handle && "handle is empty" );
- BaseObject& object = handle.GetBaseObject();
- return static_cast<Internal::BitmapLoader&>(object);
-}
-
-inline const Internal::BitmapLoader& GetImplementation(const Dali::BitmapLoader& handle)
-{
- DALI_ASSERT_ALWAYS( handle && "handle is empty" );
- const BaseObject& object = handle.GetBaseObject();
- return static_cast<const Internal::BitmapLoader&>(object);
-}
-
-Dali::BitmapLoader Dali::BitmapLoader::New(std::string const&url, Dali::Uint16Pair size, Dali::FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode, bool orientationCorrection)
-{
- IntrusivePtr<Internal::BitmapLoader> internal = Internal::BitmapLoader::New(url, size, fittingMode, samplingMode, orientationCorrection);
- gBitmapLoader = BitmapLoader(internal.Get());
- return gBitmapLoader;
-}
-
-BitmapLoader::BitmapLoader()
-{
-}
-
-Dali::BitmapLoader::BitmapLoader(Dali::BitmapLoader const& handle)
-:BaseHandle(handle)
-{
-}
-Dali::BitmapLoader::BitmapLoader(Internal::BitmapLoader* internal)
-:BaseHandle(internal)
-{
-}
-Dali::BitmapLoader::~BitmapLoader()
-{
-}
-BitmapLoader& BitmapLoader::operator=(const BitmapLoader& rhs)
-{
- BaseHandle::operator=(rhs);
- return *this;
-}
-void Dali::BitmapLoader::Load()
-{
- GetImplementation(*this).Load();
-}
-PixelData Dali::BitmapLoader::GetPixelData() const
-{
- return GetImplementation(*this).GetPixelData();
-}
-std::string Dali::BitmapLoader::GetUrl() const
-{
- return GetImplementation(*this).GetUrl();
-}
-bool Dali::BitmapLoader::IsLoaded()
-{
- return GetImplementation(*this).IsLoaded();
-}
-void Dali::BitmapLoader::WaitForLoading()
-{
- GetImplementation(*this).WaitForLoading();
-}
-
-BitmapLoader Dali::BitmapLoader::GetLatestCreated()
-{
- return gBitmapLoader;
-}
-
-void Dali::BitmapLoader::ResetLatestCreated()
-{
- gBitmapLoader.Reset();
-}
-
-} // Dali
+++ /dev/null
-#ifndef DALI_TOOLKIT_BITMAP_LOADER_H
-#define DALI_TOOLKIT_BITMAP_LOADER_H
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define DALI_BITMAP_LOADER_H
-
-#include <string>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/images/image-operations.h>
-#include <dali/public-api/images/pixel.h>
-#include <dali/public-api/images/pixel-data.h>
-#include <dali/public-api/object/base-handle.h>
-
-namespace Dali
-{
-namespace Internal
-{
-class BitmapLoader;
-}
-
-class DALI_IMPORT_API BitmapLoader : public BaseHandle
-{
-public:
-
- static BitmapLoader New( const std::string& url,
- ImageDimensions size = ImageDimensions( 0, 0 ),
- FittingMode::Type fittingMode = FittingMode::DEFAULT,
- SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR,
- bool orientationCorrection = true);
- BitmapLoader();
- ~BitmapLoader();
- BitmapLoader(const BitmapLoader& handle);
- BitmapLoader& operator=(const BitmapLoader& rhs);
-
-public:
- void Load();
- bool IsLoaded();
- std::string GetUrl() const;
- PixelData GetPixelData() const;
-
- void WaitForLoading();
- static BitmapLoader GetLatestCreated(); // return the latest created BitmapLoader
- static void ResetLatestCreated();
-
-public: // Not intended for application developers
-
- explicit DALI_INTERNAL BitmapLoader(Internal::BitmapLoader*);
-};
-
-} // Dali
-
-#endif // DALI_TOOLKIT_BITMAP_LOADER_H
--- /dev/null
+
+#include <dali/integration-api/adaptors/trigger-event-interface.h>
+#include <dali/integration-api/adaptors/trigger-event-factory.h>
+#include <dali/public-api/signals/callback.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Toolkit
+{
+
+class TriggerEvent: public Dali::TriggerEventInterface
+{
+public:
+
+ TriggerEvent( Dali::CallbackBase* callback, Dali::TriggerEventInterface::Options Options );
+ ~TriggerEvent(){}
+
+ void Trigger();
+
+private:
+ Dali::CallbackBase* mCallback;
+
+};
+
+TriggerEvent::TriggerEvent( Dali::CallbackBase* callback, Dali::TriggerEventInterface::Options Options )
+ : mCallback( callback )
+{
+}
+
+void TriggerEvent::Trigger()
+{
+ Dali::CallbackBase::Execute( *mCallback );
+}
+
+} // namespace Toolkit
+
+} // namespace Internal
+
+} // namespace Dali
+
+Dali::TriggerEventInterface* Dali::TriggerEventFactory::CreateTriggerEvent( Dali::CallbackBase* callback, Dali::TriggerEventInterface::Options options )
+{
+ return new Dali::Internal::Toolkit::TriggerEvent( callback, options );
+}
+
+void Dali::TriggerEventFactory::DestroyTriggerEvent( Dali::TriggerEventInterface* triggerEventInterface )
+{
+ Dali::Internal::Toolkit::TriggerEvent* triggerEvent( static_cast< Dali::Internal::Toolkit::TriggerEvent *>(triggerEventInterface) );
+ delete triggerEvent;
+}
return 0;
}
+void VideoPlayer::SetDisplayArea( DisplayArea area )
+{
+}
+
void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
{
}
return Internal::Adaptor::GetImplementation( *this ).mFinishedSignal;
}
+void VideoPlayer::Forward( int millisecond )
+{
+}
+
+void VideoPlayer::Backward( int millisecond )
+{
+}
+
} // namespace Dali;
int GetPlayPosition();
+ void SetDisplayArea( DisplayArea area );
+
void SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation );
Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
+ void Forward( int millisecond );
+
+ void Backward( int millisecond );
+
private:
VideoPlayer( Internal::Adaptor::VideoPlayer* internal );
END_TEST;
}
+
+int UtcDaliBuilderConfigurationP(void)
+{
+ ToolkitTestApplication application;
+
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ " \"config\":\n"
+ " {\n"
+ " \"alwaysShowFocus\":true\n"
+ " }\n"
+ "}\n"
+ );
+
+ Builder builder = Builder::New();
+ builder.LoadFromString( json );
+
+ Property::Map map = builder.GetConfigurations();
+
+ Dali::Property::Value* pValue = map.Find( "alwaysShowFocus" );
+
+ DALI_TEST_CHECK( pValue );
+
+ bool value = pValue->Get<bool>();
+
+ DALI_TEST_CHECK( value );
+
+ END_TEST;
+}
#include <dali-toolkit/devel-api/transition-effects/cube-transition-cross-effect.h>
#include <dali-toolkit/devel-api/transition-effects/cube-transition-fold-effect.h>
#include <dali-toolkit/devel-api/transition-effects/cube-transition-wave-effect.h>
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
#include <dali/public-api/images/buffer-image.h>
-
+#include <dali/devel-api/adaptor-framework/image-loading.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
using namespace Dali;
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- BitmapLoader loader = BitmapLoader::New( "Image.jpg" );
- loader.Load();
- PixelData pixelData = loader.GetPixelData();
+ Devel::PixelBuffer pixelBuffer = LoadImageFromFile(TEST_RESOURCE_DIR "/gallery-small-1.jpg");
+ PixelData pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
Texture texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
texture.Upload( pixelData );
application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- BitmapLoader loader = BitmapLoader::New( "Image.jpg" );
- loader.Load();
- PixelData pixelData = loader.GetPixelData();
+ Devel::PixelBuffer pixelBuffer = LoadImageFromFile(TEST_RESOURCE_DIR "/gallery-small-1.jpg");
+ PixelData pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
Texture texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
texture.Upload( pixelData );
// resolution: 128*128, pixel format: RGB888
static const char* gImage_128_RGB = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
-// this is image is not exist, for negative test
-static const char* gImageNonExist = "non-exist.jpg";
+// Empty image, for testing broken image loading
+static const char* gEmptyImage = TEST_RESOURCE_DIR "/empty.bmp";
const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
unsigned int size = 200;
ImageAtlas atlas = ImageAtlas::New( size, size );
- Vector4 textureRect;
- atlas.Upload( textureRect, gImageNonExist );
- DALI_TEST_EQUALS( textureRect, Vector4::ZERO, TEST_LOCATION );
-
// Set broken image
TestPlatformAbstraction& platform = application.GetPlatform();
platform.SetClosestImageSize(Vector2( 34, 34));
atlas.SetBrokenImage( gImage_34_RGBA );
- // the non-exit image will be replaced with the broken image
- platform.SetClosestImageSize(Vector2( 0, 0));
- atlas.Upload( textureRect, gImageNonExist );
+ Vector4 textureRect;
+
+ // the empty image will be replaced with the broken image
+ platform.SetClosestImageSize(Vector2( 20, 20));
+ atlas.Upload( textureRect, gEmptyImage );
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
Rect<int> pixelArea = TextureCoordinateToPixelArea(textureRect, size);
- DALI_TEST_EQUALS( pixelArea.width, 34, TEST_LOCATION );
- DALI_TEST_EQUALS( pixelArea.height, 34, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.width, 20, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.height, 20, TEST_LOCATION );
END_TEST;
}
+
+
int UtcDaliImageAtlasUploadP(void)
{
ToolkitTestApplication application;
// Need to override adaptor classes for toolkit test harness, so include
// test harness headers before dali headers.
#include <dali-toolkit-test-suite-utils.h>
-#include <toolkit-bitmap-loader.h>
#include <toolkit-event-thread-callback.h>
#include <dali-toolkit/dali-toolkit.h>
#include <test-native-image.h>
#include <sstream>
+#include <unistd.h>
using namespace Dali;
using namespace Toolkit;
const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
const char* TEST_IMAGE_FILE_NAME2 = "gallery_image_02.jpg";
+const char* TEST_IMAGE_1 = TEST_RESOURCE_DIR "/TB-gloss.png";
+const char* TEST_IMAGE_2 = TEST_RESOURCE_DIR "/tb-norm.png";
+
// resolution: 34*34, pixel format: RGBA8888
static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
// resolution: 600*600, pixel format: RGB888
int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
{
ToolkitTestApplication application;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ const std::vector<GLuint>& textures = gl.GetBoundTextures();
+ size_t numTextures = textures.size();
// Async loading, no atlasing for big size image
ImageView imageView = ImageView::New( gImage_600_RGB );
// By default, Aysnc loading is used
Stage::GetCurrent().Add( imageView );
+ imageView.SetSize(100, 100);
+ imageView.SetParentOrigin( ParentOrigin::CENTER );
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
application.SendNotification();
application.Render(16);
- application.Render(16);
application.SendNotification();
- // BitmapLoader is not used
- BitmapLoader loader = BitmapLoader::GetLatestCreated();
- DALI_TEST_CHECK( !loader );
+ const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
+ DALI_TEST_GREATER( textures2.size(), numTextures, TEST_LOCATION );
+
+
END_TEST;
}
// Sync loading is used
syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
-
-
- // BitmapLoader is used, and the loading is started immediately even the actor is not on stage.
- BitmapLoader loader = BitmapLoader::GetLatestCreated();
- DALI_TEST_CHECK( loader );
}
// Sync loading, automatic atlasing for small size image
{
- BitmapLoader::ResetLatestCreated();
TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
callStack.Reset();
callStack.Enable(true);
ImageView imageView = ImageView::New( );
+
// Sync loading is used
syncLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
syncLoadingMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
syncLoadingMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
- // loading is started even if the actor is offStage
- BitmapLoader loader = BitmapLoader::GetLatestCreated();
- DALI_TEST_CHECK( loader );
-
- loader.WaitForLoading();
-
- DALI_TEST_CHECK( loader.IsLoaded() );
-
Stage::GetCurrent().Add( imageView );
application.SendNotification();
application.Render(16);
// Sync loading, automatic atlasing for small size image
{
- BitmapLoader::ResetLatestCreated();
TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
callStack.Reset();
callStack.Enable(true);
syncLoadingMap[ "atlasing" ] = true;
imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
- // loading is started even if the actor is offStage
- BitmapLoader loader = BitmapLoader::GetLatestCreated();
- DALI_TEST_CHECK( loader );
-
- loader.WaitForLoading();
-
- DALI_TEST_CHECK( loader.IsLoaded() );
-
Stage::GetCurrent().Add( imageView );
application.SendNotification();
application.Render(16);
END_TEST;
}
+
+
+int UtcDaliImageViewReplaceImage(void)
+{
+ ToolkitTestApplication application;
+
+ gResourceReadySignalFired = false;
+
+ int width = 100;
+ int height = 200;
+ Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
+
+ // Check ImageView with background and main image, to ensure both visuals are marked as loaded
+ ImageView imageView = ImageView::New( TEST_IMAGE_1 );
+
+ DALI_TEST_EQUALS( Toolkit::DevelControl::IsResourceReady( imageView ), false, TEST_LOCATION );
+
+ Toolkit::DevelControl::ResourceReadySignal( imageView ).Connect( &ResourceReadySignal);
+
+ Stage::GetCurrent().Add( imageView );
+
+ application.SendNotification();
+ application.Render(16);
+
+ // loading started, this waits for the loader thread for max 30 seconds
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
+
+ gResourceReadySignalFired = false;
+
+ imageView.SetImage(TEST_IMAGE_2);
+
+ application.SendNotification();
+ application.Render(16);
+
+ // loading started, this waits for the loader thread for max 30 seconds
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( Toolkit::DevelControl::IsResourceReady( imageView ), true, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
+
+ END_TEST;
+}
#include <stdlib.h>
#include <dali-toolkit-test-suite-utils.h>
#include <toolkit-timer.h>
-#include <toolkit-bitmap-loader.h>
#include <toolkit-event-thread-callback.h>
#include <dali/public-api/rendering/renderer.h>
#include <dali/public-api/rendering/texture-set.h>
application.SendNotification();
application.Render();
- BitmapLoader loader = BitmapLoader::GetLatestCreated();
- DALI_TEST_CHECK( loader );
- loader.WaitForLoading();// waiting until the image to be loaded
- DALI_TEST_CHECK( loader.IsLoaded() );
-
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
application.SendNotification();
application.Render();
- BitmapLoader loader = BitmapLoader::GetLatestCreated();
- DALI_TEST_CHECK( loader );
- loader.WaitForLoading();// waiting until the image to be loaded
- DALI_TEST_CHECK( loader.IsLoaded() );
-
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
END_TEST;
}
+int UtcDaliImageVisualTextureCancelAsyncLoad(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "Load image asynchronosly, cancel loading, then load again" );
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable( true );
+ TraceCallStack& drawTrace = gl.GetDrawTrace();
+ drawTrace.Enable( true );
+
+ DummyControl actor = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
+ dummyImpl.RegisterVisual( Control::Property::BACKGROUND, visual );
+
+ Stage::GetCurrent().Add( actor );
+
+ // Cancel loading
+ Stage::GetCurrent().Remove( actor );
+
+ Stage::GetCurrent().Add( actor );
+
+ // Create another visual with the same image
+ visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ dummyImpl.RegisterVisual( Control::Property::BACKGROUND, visual );
+
+ application.SendNotification();
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliImageVisualSetInvalidAsyncImage(void)
{
ToolkitTestApplication application;
const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
+const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
+const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == DevelTextEditor::Property::LINE_COUNT );
DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
+ DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == DevelTextEditor::Property::ENABLE_SELECTION );
+ DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == DevelTextEditor::Property::PLACEHOLDER );
END_TEST;
}
editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
+ // Check the enable selection property
+ editor.SetProperty( DevelTextEditor::Property::ENABLE_SELECTION, false );
+ DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
+
+ // Check the placeholder property with pixel size
+ Property::Map placeholderPixelSizeMapSet;
+ Property::Map placeholderPixelSizeMapGet;
+ Property::Map placeholderFontstyleMap;
+ placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
+ placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
+ placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
+ placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
+
+ placeholderFontstyleMap.Insert( "weight", "bold" );
+ placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
+
+ placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
+
+ // Check the placeholder property with point size
+ Property::Map placeholderMapSet;
+ Property::Map placeholderMapGet;
+ placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
+ placeholderMapSet["placeholderColor"] = Color::RED;
+ placeholderMapSet["placeholderFontFamily"] = "Arial";
+ placeholderMapSet["placeholderPointSize"] = 12.0f;
+
+ // Check the placeholder font style property
+ placeholderFontstyleMap.Clear();
+
+ placeholderFontstyleMap.Insert( "weight", "bold" );
+ placeholderFontstyleMap.Insert( "width", "condensed" );
+ placeholderFontstyleMap.Insert( "slant", "italic" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
+ // Reset font style.
+ placeholderFontstyleMap.Clear();
+ placeholderFontstyleMap.Insert( "weight", "normal" );
+ placeholderFontstyleMap.Insert( "slant", "oblique" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
+ placeholderFontstyleMap.Clear();
+ placeholderFontstyleMap.Insert( "slant", "roman" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
+
+ placeholderFontstyleMap.Clear();
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+
+ editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
+ placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
END_TEST;
}
END_TEST;
}
+int utcDaliTextEditorEvent06(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorEvent06");
+
+ // Checks if the highlight actor is created.
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK( editor );
+
+ Stage::GetCurrent().Add( editor );
+
+ editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
+ editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
+ editor.SetSize( 100.f, 50.f );
+ editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Tap on the text editor
+ application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
+ application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Move to seconds line of the text.
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ float layoutHeight = editor.GetHeightForWidth( 100.f );
+
+
+ // Add another script characters ( glyph height is defferent )
+ application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
+ application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
+
+ // Delete characters
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
+
+ DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
+
+
+
+ END_TEST;
+}
+
int utcDaliTextEditorHandles(void)
{
ToolkitTestApplication application;
const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
+const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
+const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextField::Property::PIXEL_SIZE );
+ DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == DevelTextField::Property::ENABLE_SELECTION );
+ DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == DevelTextField::Property::PLACEHOLDER );
END_TEST;
}
field.SetProperty( DevelTextField::Property::PIXEL_SIZE, 20.f );
DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ // Check the enable selection property
+ field.SetProperty( DevelTextField::Property::ENABLE_SELECTION, false );
+ DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
+
+ // Check the placeholder property with pixel size
+ Property::Map placeholderPixelSizeMapSet;
+ Property::Map placeholderPixelSizeMapGet;
+ Property::Map placeholderFontstyleMap;
+ placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
+ placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
+ placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
+ placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
+
+ placeholderFontstyleMap.Insert( "weight", "bold" );
+ placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
+
+ placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
+
+ // Check the placeholder property with point size
+ Property::Map placeholderMapSet;
+ Property::Map placeholderMapGet;
+ placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
+ placeholderMapSet["placeholderColor"] = Color::RED;
+ placeholderMapSet["placeholderFontFamily"] = "Arial";
+ placeholderMapSet["placeholderPointSize"] = 12.0f;
+
+ // Check the placeholder font style property
+ placeholderFontstyleMap.Clear();
+
+ placeholderFontstyleMap.Insert( "weight", "bold" );
+ placeholderFontstyleMap.Insert( "width", "condensed" );
+ placeholderFontstyleMap.Insert( "slant", "italic" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
+ // Reset font style.
+ placeholderFontstyleMap.Clear();
+ placeholderFontstyleMap.Insert( "weight", "normal" );
+ placeholderFontstyleMap.Insert( "slant", "oblique" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
+ placeholderFontstyleMap.Clear();
+ placeholderFontstyleMap.Insert( "slant", "roman" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+
+ placeholderFontstyleMap.Clear();
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
+ placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
END_TEST;
}
const char* const VOLUME_RIGHT( "volumeRight" );
const char* const RENDERING_TYPE( "renderingTarget" );
+const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
+ attribute mediump vec2 aPosition;\n
+ varying mediump vec2 vTexCoord;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ uniform mediump vec3 uSize;\n
+ \n
+ void main()\n
+ {\n
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
+ vertexPosition.xyz *= uSize;\n
+ vertexPosition = uMvpMatrix * vertexPosition;\n
+ \n
+ vTexCoord = aPosition + vec2(0.5);\n
+ gl_Position = vertexPosition;\n
+ }\n
+);
+
+const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
+ varying mediump vec2 vTexCoord;\n
+ uniform sampler2D sTexture;\n
+ uniform lowp vec4 uColor;\n
+ \n
+ void main()\n
+ {\n
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
+ }\n
+);
+
}
void video_view_startup(void)
END_TEST;
}
+
+int UtcDaliVideoViewCustomShaderForCoverage(void)
+{
+ ToolkitTestApplication application;
+ VideoView videoView = VideoView::New();
+ DALI_TEST_CHECK( videoView );
+
+ Stage::GetCurrent().Add( videoView );
+ videoView.SetProperty( VideoView::Property::VIDEO, "testvideo" );
+
+ Property::Map customShader;
+ customShader.Insert( "vertexShader", VERTEX_SHADER );
+ customShader.Insert( "fragmentShader", FRAGMENT_SHADER );
+
+ Property::Map map;
+ map.Insert( "shader", customShader );
+
+ videoView.SetProperty( VideoView::Property::VIDEO, map );
+
+ Property::Map map2;
+ Property::Value value = videoView.GetProperty( VideoView::Property::VIDEO );
+
+ DALI_TEST_CHECK( !value.Get( map2 ) );
+ END_TEST;
+}
+
+int UtcDaliVideoViewMethodsForCoverage2(void)
+{
+ ToolkitTestApplication application;
+ VideoView videoView = VideoView::New();
+ DALI_TEST_CHECK( videoView );
+
+ Property::Map windowSurfaceTarget;
+
+ windowSurfaceTarget.Insert( RENDERING_TYPE, "windowSurfaceTarget" );
+
+ Stage::GetCurrent().Add( videoView );
+
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map;
+ Property::Value value;
+ videoView.SetProperty( VideoView::Property::VIDEO, windowSurfaceTarget );
+
+ value = videoView.GetProperty( VideoView::Property::VIDEO );
+ DALI_TEST_CHECK( value.Get( map ) );
+
+ Property::Value* type = map.Find( RENDERING_TYPE );
+ DALI_TEST_CHECK( type );
+ DALI_TEST_EQUALS( "windowSurfaceTarget", type->Get<std::string>(), TEST_LOCATION );
+
+ Vector3 vector(100.0f, 100.0f, 0.0f);
+
+ DALI_TEST_CHECK(vector != videoView.GetCurrentSize());
+ videoView.SetSize( vector );
+
+ application.SendNotification();
+ application.Render();
+
+ // Check the size in the new frame
+ DALI_TEST_CHECK(vector == videoView.GetCurrentSize());
+
+ END_TEST;
+}
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
Property::Map shader;
+ const std::string vertexShader = "Foobar";
const std::string fragmentShader = "Foobar";
shader[Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
+ shader[Dali::Toolkit::Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
Property::Map transformMap;
transformMap["size"] = Vector2( 0.5f, 0.5f ) ;
DALI_TEST_EQUALS( renderer.GetProperty( index ), Property::Value(Vector2(0.5, 0.5)), 0.001, TEST_LOCATION );
Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
- // *map["vertex"]; is default here so not verifying it
-
DALI_TEST_EQUALS( fragmentShader, fragment->Get<std::string>(), TEST_LOCATION );
+ Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
+ DALI_TEST_EQUALS( vertexShader, vertex->Get<std::string>(), TEST_LOCATION );
+
END_TEST;
}
#include <stdlib.h>
#include <dali-toolkit-test-suite-utils.h>
#include <toolkit-timer.h>
-#include <toolkit-bitmap-loader.h>
#include <toolkit-event-thread-callback.h>
#include <dali/public-api/rendering/renderer.h>
#include <dali/public-api/rendering/texture-set.h>
develapiimageloaderdir = $(develapidir)/image-loader
develapiscriptingdir = $(develapidir)/scripting
develapishadereffectsdir = $(develapidir)/shader-effects
+develapistylingdir = $(develapidir)/styling
develapitransitioneffectsdir = $(develapidir)/transition-effects
develapitoolbardir = $(develapicontrolsdir)/tool-bar
develapitooltipdir = $(develapicontrolsdir)/tooltip
develapiscripting_HEADERS = $(devel_api_scripting_header_files)
develapishadowview_HEADERS = $(devel_api_shadow_view_header_files)
develapishadereffects_HEADERS = $(devel_api_shader_effects_header_files)
+develapistyling_HEADERS = $(devel_api_styling_header_files)
develapisuperblurview_HEADERS = $(devel_api_super_blur_view_header_files)
develapitoolbar_HEADERS = $(devel_api_tool_bar_header_files)
develapitooltip_HEADERS = $(devel_api_tooltip_header_files)
GetImpl(*this).AddConstant( key, value );
}
+const Property::Map& Builder::GetConfigurations() const
+{
+ return GetImpl(*this).GetConfigurations();
+}
+
const Property::Map& Builder::GetConstants() const
{
return GetImpl(*this).GetConstants();
void AddConstant( const std::string& key, const Property::Value& value );
/**
+ * @brief Gets all currently defined configurations.
+ *
+ * @pre The Builder has been initialized.
+ * @return A reference to the currently defined configurations.
+ */
+ const Property::Map& GetConfigurations() const;
+
+ /**
* @brief Gets all currently defined constants.
*
* e.g.
bool IsResourceReady( const Control& control )
{
const Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control);
- const Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl );
+ const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( internalControl );
- return controlImpl.IsResourceReady();
+ return controlDataImpl.IsResourceReady();
}
void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual )
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- controlImpl.RegisterVisual( index, visual );
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control );
+ controlDataImpl.RegisterVisual( index, visual );
}
void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, int depthIndex )
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- controlImpl.RegisterVisual( index, visual, depthIndex );
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control );
+ controlDataImpl.RegisterVisual( index, visual, depthIndex );
}
void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- controlImpl.RegisterVisual( index, visual, enabled );
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control );
+ controlDataImpl.RegisterVisual( index, visual, enabled );
}
void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex )
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- controlImpl.RegisterVisual( index, visual, enabled, depthIndex );
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control );
+ controlDataImpl.RegisterVisual( index, visual, enabled, depthIndex );
}
void UnregisterVisual( Internal::Control& control, Dali::Property::Index index )
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- controlImpl.UnregisterVisual( index );
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control );
+ controlDataImpl.UnregisterVisual( index );
}
Toolkit::Visual::Base GetVisual( const Internal::Control& control, Dali::Property::Index index )
{
- const Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- return controlImpl.GetVisual( index );
+ const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control );
+ return controlDataImpl.GetVisual( index );
}
void EnableVisual( Internal::Control& control, Dali::Property::Index index, bool enable )
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- controlImpl.EnableVisual( index, enable );
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control );
+ controlDataImpl.EnableVisual( index, enable );
}
bool IsVisualEnabled( const Internal::Control& control, Dali::Property::Index index )
{
- const Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- return controlImpl.IsVisualEnabled( index );
+ const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control );
+ return controlDataImpl.IsVisualEnabled( index );
}
Dali::Animation CreateTransition( Internal::Control& control, const Toolkit::TransitionData& handle )
{
- Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
- return controlImpl.CreateTransition( handle );
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control );
+ return controlDataImpl.CreateTransition( handle );
}
/**
* @brief The size of font in pixels.
+ *
+ * Conversion from Point size to Pixel size :
+ * Pixel size = Point size * DPI / 72
* @details name "pixelSize", type float
*/
PIXEL_SIZE,
* @brief The placeholder-text color.
* @details name "placeholderTextColor", type vector4
*/
- PLACEHOLDER_TEXT_COLOR
+ PLACEHOLDER_TEXT_COLOR,
+
+ /**
+ * @brief Enables Text selection, such as the cursor, handle, clipboard, and highlight color.
+ * @details name "enableSelection", type bool
+ */
+ ENABLE_SELECTION,
+
+ /**
+ * @brief Sets the placeholder : text, color, font family, font style, point size, and pixel size.
+ *
+ * @code
+ * Property::Map propertyMap;
+ * propertyMap["placeholderText"] = "Setting Placeholder Text";
+ * propertyMap["placeholderColor"] = Color::RED;
+ * propertyMap["placeholderFontFamily"] = "Arial";
+ * propertyMap["placeholderPointSize"] = 12.0f;
+ *
+ * Property::Map fontStyleMap;
+ * fontstyleMap.Insert( "weight", "bold" );
+ * fontstyleMap.Insert( "width", "condensed" );
+ * fontstyleMap.Insert( "slant", "italic" );
+ * propertyMap["placeholderFontStyle"] = fontStyleMap;
+ *
+ * editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, propertyMap );
+ * @endcode
+ *
+ * @details name "placeholder", type MAP
+ */
+ PLACEHOLDER
};
} // namespace Property
/**
* @brief The size of font in pixels.
+ *
+ * Conversion from Point size to Pixel size :
+ * Pixel size = Point size * DPI / 72
* @details name "pixelSize", type float
*/
PIXEL_SIZE = INPUT_OUTLINE + 2,
+
+ /**
+ * @brief Enables Text selection, such as the cursor, handle, clipboard, and highlight color.
+ * @details name "enableSelection", type bool
+ */
+ ENABLE_SELECTION = INPUT_OUTLINE + 3,
+
+ /**
+ * @brief Sets the placeholder : text, color, font family, font style, point size, and pixel size.
+ *
+ * @code
+ * Property::Map propertyMap;
+ * propertyMap["placeholderText"] = "Setting Placeholder Text";
+ * propertyMap["placeholderColor"] = Color::RED;
+ * propertyMap["placeholderFontFamily"] = "Arial";
+ * propertyMap["placeholderPointSize"] = 12.0f;
+ *
+ * Property::Map fontStyleMap;
+ * fontstyleMap.Insert( "weight", "bold" );
+ * fontstyleMap.Insert( "width", "condensed" );
+ * fontstyleMap.Insert( "slant", "italic" );
+ * propertyMap["placeholderFontStyle"] = fontStyleMap;
+ *
+ * field.SetProperty( DevelTextField::Property::PLACEHOLDER, propertyMap );
+ * @endcode
+ *
+ * @details name "placeholder", type MAP
+ */
+ PLACEHOLDER = INPUT_OUTLINE + 4
};
} // namespace Property
/**
* @brief The size of font in pixels.
+ *
+ * Conversion from Point size to Pixel size :
+ * Pixel size = Point size * DPI / 72
* @details name "pixelSize", type float
*/
PIXEL_SIZE = OUTLINE + 1,
$(devel_api_src_dir)/controls/tool-bar/tool-bar.cpp \
$(devel_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \
$(devel_api_src_dir)/focus-manager/keyboard-focus-manager-devel.cpp \
+ $(devel_api_src_dir)/image-loader/async-image-loader-devel.cpp \
$(devel_api_src_dir)/image-loader/atlas-upload-observer.cpp \
$(devel_api_src_dir)/image-loader/image-atlas.cpp \
$(devel_api_src_dir)/scripting/script.cpp \
+ $(devel_api_src_dir)/styling/style-manager-devel.cpp \
$(devel_api_src_dir)/transition-effects/cube-transition-cross-effect.cpp \
$(devel_api_src_dir)/transition-effects/cube-transition-effect.cpp \
$(devel_api_src_dir)/transition-effects/cube-transition-fold-effect.cpp \
$(devel_api_src_dir)/focus-manager/keyboard-focus-manager-devel.h
devel_api_image_loader_header_files = \
+ $(devel_api_src_dir)/image-loader/async-image-loader-devel.h \
$(devel_api_src_dir)/image-loader/atlas-upload-observer.h \
$(devel_api_src_dir)/image-loader/image-atlas.h
$(devel_api_src_dir)/shader-effects/motion-blur-effect.h \
$(devel_api_src_dir)/shader-effects/motion-stretch-effect.h
+devel_api_styling_header_files= \
+ $(devel_api_src_dir)/styling/style-manager-devel.h
+
devel_api_super_blur_view_header_files = \
$(devel_api_src_dir)/controls/super-blur-view/super-blur-view.h
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali-toolkit/devel-api/image-loader/async-image-loader-devel.h>
+#include <dali-toolkit/internal/image-loader/async-image-loader-impl.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace DevelAsyncImageLoader
+{
+
+PixelBufferLoadedSignalType& PixelBufferLoadedSignal( AsyncImageLoader asyncImageLoader )
+{
+ return GetImplementation( asyncImageLoader ).PixelBufferLoadedSignal();
+}
+
+} // Devel
+} // Toolkit
+} // Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_DEVEL_API_IMAGE_LOADER_ASYNC_IMAGE_LOADER_DEVEL_H
+#define DALI_TOOLKIT_DEVEL_API_IMAGE_LOADER_ASYNC_IMAGE_LOADER_DEVEL_H
+
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali/public-api/signals/dali-signal.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali-toolkit/public-api/image-loader/async-image-loader.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace DevelAsyncImageLoader
+{
+
+typedef Signal< void ( uint32_t, Devel::PixelBuffer ) > PixelBufferLoadedSignalType;
+
+/**
+ * Connect to this signal if you want to load a PixelBuffer instead of a PixelData.
+ * @note Connecting to this signal prevents the emission of the ImageLoadedSignal.
+ */
+DALI_IMPORT_API PixelBufferLoadedSignalType& PixelBufferLoadedSignal( AsyncImageLoader asyncImageLoader );
+
+}
+} // Toolkit
+} // Dali
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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/devel-api/styling/style-manager-devel.h>
+#include <dali-toolkit/internal/styling/style-manager-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelStyleManager
+{
+
+const Property::Map GetConfigurations( StyleManager styleManager )
+{
+ return GetImpl(styleManager).GetConfigurations();
+}
+
+} // namespace DevelStyleManager
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_STYLE_MANAGER_DEVEL_H
+#define DALI_TOOLKIT_STYLE_MANAGER_DEVEL_H
+
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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/styling/style-manager.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelStyleManager
+{
+
+
+/**
+ * @brief Gets all currently defined configurations.
+ *
+ * @pre The Builder has been initialized.
+ * @param[in] styleManager The instance of StyleManager
+ * @return A property map to the currently defined configurations
+**/
+DALI_IMPORT_API const Property::Map GetConfigurations( StyleManager styleManager );
+
+} // namespace DevelStyleManager
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_STYLE_MANAGER_DEVEL_H
}
else
{
+ // load configuration map
+ LoadConfiguration( *parser.GetRoot(), mConfigurationMap );
// load constant map (allows the user to override the constants in the json after loading)
LoadConstants( *parser.GetRoot(), mReplacementMap );
-
// merge includes
if( OptionalChild includes = IsChild(*parser.GetRoot(), KEYNAME_INCLUDES) )
{
mReplacementMap[key] = value;
}
+const Property::Map& Builder::GetConfigurations() const
+{
+ return mConfigurationMap;
+}
+
const Property::Map& Builder::GetConstants() const
{
return mReplacementMap;
{
}
+void Builder::LoadConfiguration( const TreeNode& root, Property::Map& intoMap )
+{
+ Replacement replacer(intoMap);
+
+ if( OptionalChild constants = IsChild(root, "config") )
+ {
+ for(TreeNode::ConstIterator iter = (*constants).CBegin();
+ iter != (*constants).CEnd(); ++iter)
+ {
+ Dali::Property::Value property;
+ if( (*iter).second.GetName() )
+ {
+ DeterminePropertyFromNode( (*iter).second, property, replacer );
+ intoMap[ (*iter).second.GetName() ] = property;
+ }
+ }
+ }
+}
+
void Builder::LoadConstants( const TreeNode& root, Property::Map& intoMap )
{
Replacement replacer(intoMap);
void AddConstant( const std::string& key, const Property::Value& value );
/**
+ * @copydoc Toolkit::Builder::GetConfigurations
+ */
+ const Property::Map& GetConfigurations() const;
+
+ /**
* @copydoc Toolkit::Builder::GetConstants
*/
const Property::Map& GetConstants() const;
void LoadConstants( const TreeNode& root, Property::Map& intoMap );
+ void LoadConfiguration( const TreeNode& root, Property::Map& intoMap );
+
Animation CreateAnimation( const std::string& animationName,
const Replacement& replacement,
Dali::Actor sourceActor );
LinearConstrainerLut mLinearConstrainerLut;
SlotDelegate<Builder> mSlotDelegate;
Property::Map mReplacementMap;
+ Property::Map mConfigurationMap;
MappingsLut mCompleteMappings;
Dictionary<StylePtr> mStyles; // State based styles
Toolkit::Builder::BuilderSignalType mQuitSignal;
}
/**
+ * Move visual from source to destination container
+ */
+void MoveVisual( RegisteredVisualContainer::Iterator sourceIter, RegisteredVisualContainer& source, RegisteredVisualContainer& destination )
+{
+ Toolkit::Visual::Base visual = (*sourceIter)->visual;
+ if( visual )
+ {
+ RegisteredVisual* rv = source.Release( sourceIter );
+ destination.PushBack( rv );
+ }
+}
+
+/**
* Performs actions as requested using the action name.
* @param[in] object The object on which to perform the action.
* @param[in] actionName The action to perform.
// Called by a Visual when it's resource is ready
void Control::Impl::ResourceReady( Visual::Base& object)
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceReady \n");
+
+ // A resource is ready, check if is in the replacement visual container
+ // Iterate through all visuals in replacement container and store indexes of ready visuals
+ Dali::Vector <Property::Index> readyVisuals;
+ Actor self = mControlImpl.Self();
+
+ for( auto replacementVisualIter = mReplacementVisuals.Begin();
+ replacementVisualIter < mReplacementVisuals.End(); ++replacementVisualIter )
+ {
+ const Toolkit::Visual::Base replacementVisual = (*replacementVisualIter)->visual;
+ const Internal::Visual::Base& replacementVisualImpl = Toolkit::GetImplementation( replacementVisual );
+
+ if( replacementVisualImpl.IsResourceReady() )
+ {
+ // Check if new replacement visual (index) is already queued for replacement and swap old for new.
+ RegisteredVisualContainer::Iterator registeredVisualsIter;
+ if( FindVisual( (*replacementVisualIter)->index, mVisuals, registeredVisualsIter ) )
+ {
+ Property::Index readyVisualIndex = (*replacementVisualIter)->index;
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceReady: %d Ready to replace\n", readyVisualIndex );
+ readyVisuals.PushBack( readyVisualIndex );
+ // Remove current shown visual from stage and from registered visuals container
+ Toolkit::GetImplementation((*registeredVisualsIter)->visual).SetOffStage( self );
+ mVisuals.Erase( registeredVisualsIter );
+ }
+ }
+ }
+
+ for( auto readyVisualsIter = readyVisuals.Begin(); readyVisualsIter != readyVisuals.End(); readyVisualsIter++ )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceReady: %d Matched\n", (*readyVisualsIter) );
+ // Move new visual to be shown from replacement container into the control's registered visuals container
+ // Replacement visual has already been set on stage when it was added to replacement container
+ RegisteredVisualContainer::Iterator readyReplacementVisual;
+ if( FindVisual( (*readyVisualsIter) , mReplacementVisuals, readyReplacementVisual ) )
+ {
+ MoveVisual( readyReplacementVisual, mReplacementVisuals, mVisuals ); // Erases visual from replacement queue
+ }
+ // A visual has been replaced so control will most likely need relayouting
+ mControlImpl.RelayoutRequest();
+ }
// go through and check if all the visuals are ready, if they are emit a signal
- for ( RegisteredVisualContainer::ConstIterator visualIter = mVisuals.Begin();
+ for( auto visualIter = mVisuals.Begin();
visualIter != mVisuals.End(); ++visualIter )
{
const Toolkit::Visual::Base visual = (*visualIter)->visual;
// all the visuals are ready
Dali::Toolkit::Control handle( mControlImpl.GetOwner() );
mResourceReadySignal.Emit( handle );
-
}
bool Control::Impl::IsResourceReady() const
void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, VisualState::Type enabled, DepthIndexValue::Type depthIndexValueSet, int depthIndex )
{
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "RegisterVisual:%d \n", index );
+
bool visualReplaced ( false );
Actor self = mControlImpl.Self();
if( !mVisuals.Empty() )
{
- RegisteredVisualContainer::Iterator iter;
+ RegisteredVisualContainer::Iterator registeredVisualsiter;
// Check if visual (index) is already registered. Replace if so.
- if ( FindVisual( index, mVisuals, iter ) )
+ if( FindVisual( index, mVisuals, registeredVisualsiter ) )
{
- if( (*iter)->visual && self.OnStage() )
+ if( (*registeredVisualsiter)->visual )
{
- Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
- }
+ // Store current visual depth index as may need to set the replacement visual to same depth
+ const int currentDepthIndex = (*registeredVisualsiter)->visual.GetDepthIndex();
- // If we've not set the depth-index value and the new visual does not have a depth index applied to it, then use the previously set depth-index for this index
- if( ( depthIndexValueSet == DepthIndexValue::NOT_SET ) &&
- ( visual.GetDepthIndex() == 0 ) )
- {
- const int currentDepthIndex = (*iter)->visual.GetDepthIndex();
- visual.SetDepthIndex( currentDepthIndex );
- }
+ // Monitor when the visuals resources are ready
+ StopObservingVisual( (*registeredVisualsiter)->visual );
+ StartObservingVisual( visual );
+
+ if( self.OnStage() )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "RegisterVisual Adding visual to replacement Queue: %d \n", index );
+ // Check if visual is currently in the process of being replaced
+ RegisteredVisualContainer::Iterator queuedReplacementVisual;
+ if ( FindVisual( index, mReplacementVisuals, queuedReplacementVisual ) )
+ {
+ // If visual on replacement queue is going to be replaced before it's ready then will be removed from queue (and stage)
+ // Only the the last requested visual will be queued and then displayed.
+ Toolkit::GetImplementation( (*queuedReplacementVisual)->visual ).SetOffStage( self );
+ mReplacementVisuals.Erase(queuedReplacementVisual);
+ }
+ // Add to replacement list
+ mReplacementVisuals.PushBack( new RegisteredVisual( index, visual, ( enabled == VisualState::ENABLED ? true : false ) ) );
+ }
+ else
+ {
+ // Not staged so can just replace registered visual
+ (*registeredVisualsiter)->visual = visual;
+ (*registeredVisualsiter)->enabled = ( enabled == VisualState::ENABLED ) ? true : false;
+ }
- StopObservingVisual( (*iter)->visual );
- StartObservingVisual( visual );
+ // If we've not set the depth-index value and the new visual does not have a depth index applied to it, then use the previously set depth-index for this index
+ if( ( depthIndexValueSet == DepthIndexValue::NOT_SET ) &&
+ ( visual.GetDepthIndex() == 0 ) )
+ {
+ visual.SetDepthIndex( currentDepthIndex );
+ }
+ }
- (*iter)->visual = visual;
- (*iter)->enabled = ( enabled == VisualState::ENABLED ) ? true : false;
visualReplaced = true;
}
}
if( !visualReplaced ) // New registration entry
{
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "New Visual registration %d\n", index);
mVisuals.PushBack( new RegisteredVisual( index, visual, ( enabled == VisualState::ENABLED ? true : false ) ) );
// monitor when the visuals resources are ready
// Put on stage if enabled and the control is already on the stage
if( ( enabled == VisualState::ENABLED ) && self.OnStage() )
{
+ // Visual must be set on stage for the renderer to be created and the ResourceReady triggered.
Toolkit::GetImplementation(visual).SetOnStage( self );
}
}
void Control::Impl::EnableVisual( Property::Index index, bool enable )
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Visual (%d)\n", index);
+
RegisteredVisualContainer::Iterator iter;
if ( FindVisual( index, mVisuals, iter ) )
{
/**
* @brief Adds the visual to the list of registered visuals.
* @param[in] index The Property index of the visual, used to reference visual
- * @param[in] visual The visual to register
+ * @param[in,out] visual The visual to register, which can be altered in this function
* @param[in] enabled false if derived class wants to control when visual is set on stage
* @param[in] depthIndexValueSet Set to true if the depthIndex has actually been set manually
* @param[in] depthIndex The visual's depth-index is set to this
+ *
+ * @note Registering a visual with an index that already has a registered visual will replace it. The replacement will
+ * occur once the replacement visual is ready (loaded).
*/
void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, VisualState::Type enabled, DepthIndexValue::Type depthIndexValueSet, int depthIndex = 0 );
bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
+ RegisteredVisualContainer mReplacementVisuals; ///< List of visuals that will be used for replacing current visuals.
+
// Properties - these need to be members of Internal::Control::Impl as they access private methods/data of Internal::Control and Internal::Control::Impl.
static const PropertyRegistration PROPERTY_1;
static const PropertyRegistration PROPERTY_2;
/////////////////////////////////////////////////////////////
+void ImageView::OnInitialize()
+{
+ // ImageView can relayout in the OnImageReady, alternative to a signal would be to have a upcall from the Control to ImageView
+ Dali::Toolkit::Control handle( GetOwner() );
+ Toolkit::DevelControl::ResourceReadySignal( handle ).Connect( this, &ImageView::OnResourceReady );
+}
+
void ImageView::SetImage( Image image )
{
// Don't bother comparing if we had a visual previously, just drop old visual and create new one
mUrl.clear();
mPropertyMap.Clear();
- mVisual = Toolkit::VisualFactory::Get().CreateVisual( image );
- DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, mVisual );
+ Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( image );
+ if (!mVisual)
+ {
+ mVisual = visual;
+ }
- RelayoutRequest();
+ DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, visual );
}
void ImageView::SetImage( const Property::Map& map )
mPropertyMap = map;
mUrl.clear();
mImage.Reset();
+ Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( mPropertyMap );
+ // Don't set mVisual until it is ready and shown. Getters will still use current visual.
+ if (!mVisual)
+ {
+ mVisual = visual;
+ }
- mVisual = Toolkit::VisualFactory::Get().CreateVisual( mPropertyMap );
- DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, mVisual );
-
- RelayoutRequest();
+ DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, visual );
}
void ImageView::SetImage( const std::string& url, ImageDimensions size )
mImage.Reset();
mPropertyMap.Clear();
- mVisual = Toolkit::VisualFactory::Get().CreateVisual( url, size );
- DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, mVisual );
+ // Don't set mVisual until it is ready and shown. Getters will still use current visual.
+ Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( url, size );
+ if (!mVisual)
+ {
+ mVisual = visual;
+ }
- RelayoutRequest();
+ DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, visual );
}
Image ImageView::GetImage() const
}
}
+void ImageView::OnResourceReady( Toolkit::Control control )
+{
+ mVisual = DevelControl::GetVisual( *this, Toolkit::ImageView::Property::IMAGE );
+}
+
///////////////////////////////////////////////////////////
//
// Properties
private: // From Control
/**
+ * @copydoc Toolkit::Control::OnInitialize
+ */
+ void OnInitialize();
+
+ /**
* @copydoc Toolkit::Control::GetNaturalSize
*/
virtual Vector3 GetNaturalSize();
virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
private:
+
+ /**
+ * @brief Callback for ResourceReadySignal
+ * param[in] control signal prototype
+ */
+ void OnResourceReady( Toolkit::Control control );
+
+private:
// Undefined
ImageView( const ImageView& );
ImageView& operator=( const ImageView& );
#include <dali-toolkit/public-api/controls/model3d-view/model3d-view.h>
#include <dali/public-api/images/resource-image.h>
#include <dali/devel-api/adaptor-framework/file-loader.h>
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
+#include <dali/devel-api/adaptor-framework/image-loading.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/model3d-view/obj-loader.h>
Texture LoadTexture( const char* imageUrl )
{
Texture texture;
- Dali::BitmapLoader loader = Dali::BitmapLoader::New( imageUrl );
- loader.Load();
- PixelData pixelData = loader.GetPixelData();
- if( pixelData )
+ Devel::PixelBuffer pixelBuffer = LoadImageFromFile( imageUrl );
+ if( pixelBuffer )
{
- texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
+ texture = Texture::New( TextureType::TEXTURE_2D, pixelBuffer.GetPixelFormat(), pixelBuffer.GetWidth(), pixelBuffer.GetHeight() );
+ PixelData pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
texture.Upload( pixelData );
texture.GenerateMipmaps();
}
DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextEditor, "lineCount", INTEGER, LINE_COUNT )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderText", STRING, PLACEHOLDER_TEXT )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableSelection", BOOLEAN, ENABLE_SELECTION )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholder", MAP, PLACEHOLDER )
DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED )
}
break;
}
+ case Toolkit::DevelTextEditor::Property::ENABLE_SELECTION:
+ {
+ if( impl.mController )
+ {
+ const bool enableSelection = value.Get< bool >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection );
+ impl.mController->SetSelectionEnabled( enableSelection );
+ }
+ break;
+ }
+ case Toolkit::DevelTextEditor::Property::PLACEHOLDER:
+ {
+ const Property::Map* map = value.GetMap();
+ if( map )
+ {
+ impl.mController->SetPlaceholderProperty( *map );
+ }
+ break;
+ }
} // switch
} // texteditor
}
}
break;
}
+ case Toolkit::DevelTextEditor::Property::ENABLE_SELECTION:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->IsSelectionEnabled();
+ }
+ break;
+ }
+ case Toolkit::DevelTextEditor::Property::PLACEHOLDER:
+ {
+ Property::Map map;
+ impl.mController->GetPlaceholderProperty( map );
+ value = map;
+ break;
+ }
} //switch
}
return;
}
- // If scrolling is not started, start scrolling and emit ScrollStateChangedSignal
- if( !mScrollStarted )
- {
- mScrollStarted = true;
- Dali::Toolkit::TextEditor handle( GetOwner() );
- mScrollStateChangedSignal.Emit( handle, DevelTextEditor::Scroll::STARTED );
- }
-
CustomActor self = Self();
if( !mScrollBar )
{
self.SetProperty( propertyScrollContentSize, layoutSize );
}
+ // If scrolling is not started, start scrolling and emit ScrollStateChangedSignal
+ if( !mScrollStarted )
+ {
+ mScrollStarted = true;
+ Dali::Toolkit::TextEditor handle( GetOwner() );
+ mScrollStateChangedSignal.Emit( handle, DevelTextEditor::Scroll::STARTED );
+ }
+
Actor indicator = mScrollBar.GetScrollIndicator();
if( mAnimation )
{
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputOutline", MAP, INPUT_OUTLINE )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "hiddenInputSettings", MAP, HIDDEN_INPUT_SETTINGS )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "pixelSize", FLOAT, PIXEL_SIZE )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableSelection", BOOLEAN, ENABLE_SELECTION )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholder", MAP, PLACEHOLDER )
DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
}
break;
}
+ case Toolkit::DevelTextField::Property::ENABLE_SELECTION:
+ {
+ if( impl.mController )
+ {
+ const bool enableSelection = value.Get< bool >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection );
+ impl.mController->SetSelectionEnabled( enableSelection );
+ }
+ break;
+ }
+ case Toolkit::DevelTextField::Property::PLACEHOLDER:
+ {
+ const Property::Map* map = value.GetMap();
+ if( map )
+ {
+ impl.mController->SetPlaceholderProperty( *map );
+ }
+ break;
+ }
} // switch
} // textfield
}
}
break;
}
+ case Toolkit::DevelTextField::Property::ENABLE_SELECTION:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->IsSelectionEnabled();
+ }
+ break;
+ }
+ case Toolkit::DevelTextField::Property::PLACEHOLDER:
+ {
+ Property::Map map;
+ impl.mController->GetPlaceholderProperty( map );
+ value = map;
+ break;
+ }
} //switch
}
#include <dali/devel-api/scripting/scripting.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
#include <dali/integration-api/adaptors/adaptor.h>
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/animation/constraint.h>
+#include <dali/devel-api/actors/actor-devel.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/video-view/video-view.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
namespace Dali
{
const char* const WINDOW_SURFACE_TARGET( "windowSurfaceTarget" );
const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" );
+const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
+ attribute mediump vec2 aPosition;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ uniform mediump vec3 uSize;\n
+ \n
+ void main()\n
+ {\n
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
+ vertexPosition.xyz *= uSize;\n
+ gl_Position = uMvpMatrix * vertexPosition;\n
+ }\n
+);
+
+const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
+ uniform lowp vec4 uColor;\n
+ uniform lowp vec3 mixColor;\n
+ uniform lowp float opacity;\n
+ \n
+ void main()\n
+ {\n
+ gl_FragColor = vec4(mixColor, opacity)*uColor;\n
+ }\n
+);
+
+struct TriggerFunctor
+{
+ TriggerFunctor( TriggerEventInterface* notification )
+ : mNotification( notification )
+ {
+ }
+
+ void operator()( bool& current, const PropertyInputContainer& inputs )
+ {
+ if( mNotification != NULL )
+ {
+ mNotification->Trigger();
+ }
+ }
+
+ TriggerEventInterface* mNotification;
+};
+
} // anonymous namepsace
VideoView::VideoView()
: Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
+ mUpdateTriggerPropertyIndex( Property::INVALID_INDEX),
+ mNotification( NULL ),
mCurrentVideoPlayPosition( 0 ),
mIsNativeImageTarget( true ),
mIsPlay( false ),
mIsPause( false )
{
mVideoPlayer = Dali::VideoPlayer::New();
+
+ TriggerEventFactory triggerEventFactory;
+ mNotification = triggerEventFactory.CreateTriggerEvent( MakeCallback(this, &VideoView::UpdateDisplayArea ),
+ TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
}
VideoView::~VideoView()
{
+ if( mNotification != NULL )
+ {
+ delete mNotification;
+ }
}
Toolkit::VideoView VideoView::New()
mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr );
mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
+
+ mUpdateTriggerPropertyIndex = Self().RegisterProperty( "updateTrigger", true );
}
void VideoView::SetUrl( const std::string& url )
}
}
+ Property::Value* target = map.Find( RENDERING_TARGET );
+ std::string targetType;
+
+ if( target && target->Get( targetType ) && targetType == WINDOW_SURFACE_TARGET )
+ {
+ this->SetWindowSurfaceTarget();
+ }
+ else if( target && target->Get( targetType ) && targetType == NATIVE_IMAGE_TARGET )
+ {
+ this->SetNativeImageTarget();
+ }
+
RelayoutRequest();
}
case Toolkit::VideoView::Property::VIDEO:
{
std::string videoUrl;
+ Property::Map map;
+
if( value.Get( videoUrl ) )
{
impl.SetUrl( videoUrl );
}
-
- Property::Map map;
- if( value.Get( map ) )
+ else if( value.Get( map ) )
{
- impl.SetPropertyMap( map );
+ Property::Value* shaderValue = map.Find( Toolkit::Visual::Property::SHADER, CUSTOM_SHADER );
- Property::Value* target = map.Find( RENDERING_TARGET );
- std::string targetType;
- if( target && target->Get( targetType ) && targetType == WINDOW_SURFACE_TARGET )
+ if( map.Count() > 1u || !shaderValue )
{
- impl.SetWindowSurfaceTarget();
+ impl.SetPropertyMap( map );
}
- else if( target && target->Get( targetType ) && targetType == NATIVE_IMAGE_TARGET )
+ else if( impl.mVisual && map.Count() == 1u && shaderValue )
{
- impl.SetNativeImageTarget();
+ Property::Map shaderMap;
+ if( shaderValue->Get( shaderMap ) )
+ {
+ Internal::Visual::Base& visual = Toolkit::GetImplementation( impl.mVisual );
+ visual.SetCustomShader( shaderMap );
+ if( videoView.OnStage() )
+ {
+ visual.SetOffStage( videoView );
+ visual.SetOnStage( videoView );
+ }
+ }
}
}
break;
mVisual.Reset();
}
+ Constraint constraint = Constraint::New<bool>( self, mUpdateTriggerPropertyIndex, TriggerFunctor( mNotification ) );
+ constraint.AddSource( Source( self, Actor::Property::POSITION ) );
+ constraint.AddSource( Source( self, Actor::Property::SIZE ) );
+ constraint.Apply();
+
mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() );
mVideoPlayer.SetUrl( mUrl );
mVideoPlayer.Pause();
}
mVideoPlayer.SetPlayPosition( curPos );
+
+ // For underlay rendering mode, video display area have to be transparent.
+ Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
+ Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ Renderer renderer = Renderer::New( geometry, shader );
+
+ renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
+ renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE );
+ renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ZERO );
+ renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE );
+ renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ZERO );
+ self.AddRenderer( renderer );
}
void VideoView::SetNativeImageTarget()
mVideoPlayer.SetPlayPosition( curPos );
}
+void VideoView::UpdateDisplayArea()
+{
+ Actor self( Self() );
+
+ bool positionUsesAnchorPoint = self.GetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT ).Get< bool >();
+ Vector3 actorSize = self.GetCurrentSize() * self.GetCurrentScale();
+ Vector3 anchorPointOffSet = actorSize * ( positionUsesAnchorPoint ? self.GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT );
+
+ Vector2 screenPosition = self.GetProperty( DevelActor::Property::SCREEN_POSITION ).Get< Vector2 >();
+
+ mDisplayArea.x = screenPosition.x - anchorPointOffSet.x;
+ mDisplayArea.y = screenPosition.y - anchorPointOffSet.y;
+ mDisplayArea.width = actorSize.x;
+ mDisplayArea.height = actorSize.y;
+
+ mVideoPlayer.SetDisplayArea( mDisplayArea );
+}
+
} // namespace Internal
-} // namespace Toolkit
+} // namespace toolkit
} // namespace Dali
#include <dali/public-api/object/property-map.h>
#include <dali/public-api/images/native-image.h>
#include <dali/devel-api/adaptor-framework/video-player.h>
+#include <dali/integration-api/adaptors/trigger-event-factory.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/image/image-visual.h>
*/
static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
+ /**
+ * Connects a callback function with the object's signals.
+ * @param[in] object The object providing the signal.
+ * @param[in] tracker Used to disconnect the signal.
+ * @param[in] signalName The signal to connect to.
+ * @param[in] functor A newly allocated FunctorDelegate.
+ * @return True if the signal was connected.
+ * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the c
+ */
static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ /*
+ * @brief Updates video display area for window rendering target
+ */
+ void UpdateDisplayArea();
+
private: // From Control
/**
Dali::NativeImage mNativeImage; ///< Native image handle for video rendering by texture streaming
Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
std::string mUrl;
+ Dali::DisplayArea mDisplayArea;
+
+ Property::Index mUpdateTriggerPropertyIndex;
+ TriggerEventInterface* mNotification;
+
int mCurrentVideoPlayPosition;
bool mIsNativeImageTarget;
bool mIsPlay;
#include <dali/public-api/events/touch-data.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/object/property-map.h>
#include <dali/public-api/images/resource-image.h>
#include <dali/integration-api/debug.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/public-api/accessibility-manager/accessibility-manager.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
+#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
namespace Dali
{
mFocusedActorEnterKeySignal(),
mCurrentFocusActor(),
mFocusIndicatorActor(),
+ mIsFocusIndicatorEnabled( -1 ),
mFocusGroupLoopEnabled( false ),
- mIsFocusIndicatorEnabled( true ),
mIsWaitingKeyboardFocusChangeCommit( false ),
mFocusHistory(),
mSlotDelegate( this ),
{
}
+void KeyboardFocusManager::GetConfigurationFromStyleManger()
+{
+ Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+ if( styleManager )
+ {
+ Property::Map config = Toolkit::DevelStyleManager::GetConfigurations( styleManager );
+ mIsFocusIndicatorEnabled = static_cast<int>(config["alwaysShowFocus"].Get<bool>());
+ }
+}
+
bool KeyboardFocusManager::SetCurrentFocusActor( Actor actor )
{
DALI_ASSERT_DEBUG( !mIsWaitingKeyboardFocusChangeCommit && "Calling this function in the PreFocusChangeSignal callback?" );
+ if( mIsFocusIndicatorEnabled == -1 )
+ {
+ GetConfigurationFromStyleManger();
+ }
+
return DoSetCurrentFocusActor( actor );
}
}
mCurrentFocusActor.Reset();
- mIsFocusIndicatorEnabled = false;
+ mIsFocusIndicatorEnabled = 0;
}
void KeyboardFocusManager::SetFocusGroupLoop(bool enabled)
std::string keyName = event.keyPressedName;
+ if( mIsFocusIndicatorEnabled == -1 )
+ {
+ GetConfigurationFromStyleManger();
+ }
+
bool isFocusStartableKey = false;
if(event.state == KeyEvent::Down)
if(!mIsFocusIndicatorEnabled)
{
// Show focus indicator
- mIsFocusIndicatorEnabled = true;
+ mIsFocusIndicatorEnabled = 1;
}
else
{
if(!mIsFocusIndicatorEnabled)
{
// Show focus indicator
- mIsFocusIndicatorEnabled = true;
+ mIsFocusIndicatorEnabled = 1;
}
else
{
if(!mIsFocusIndicatorEnabled)
{
// Show focus indicator
- mIsFocusIndicatorEnabled = true;
+ mIsFocusIndicatorEnabled = 1;
}
else
{
if(!mIsFocusIndicatorEnabled)
{
// Show focus indicator
- mIsFocusIndicatorEnabled = true;
+ mIsFocusIndicatorEnabled = 1;
}
else
{
if(!mIsFocusIndicatorEnabled)
{
// Show focus indicator
- mIsFocusIndicatorEnabled = true;
+ mIsFocusIndicatorEnabled = 1;
}
else
{
if(!mIsFocusIndicatorEnabled)
{
// Show focus indicator
- mIsFocusIndicatorEnabled = true;
+ mIsFocusIndicatorEnabled = 1;
}
else
{
if(!mIsFocusIndicatorEnabled)
{
// Show focus indicator
- mIsFocusIndicatorEnabled = true;
+ mIsFocusIndicatorEnabled = 1;
}
else
{
if(!mIsFocusIndicatorEnabled)
{
// Show focus indicator
- mIsFocusIndicatorEnabled = true;
+ mIsFocusIndicatorEnabled = 1;
}
isFocusStartableKey = true;
if(!mIsFocusIndicatorEnabled)
{
// Show focus indicator
- mIsFocusIndicatorEnabled = true;
+ mIsFocusIndicatorEnabled = 1;
}
isFocusStartableKey = true;
if(!mIsFocusIndicatorEnabled && !isAccessibilityEnabled)
{
// Show focus indicator
- mIsFocusIndicatorEnabled = true;
+ mIsFocusIndicatorEnabled = 1;
}
else
{
typedef FocusStack::Iterator FocusStackIterator; ///< Define FocusStack::Iterator as FocusStackIterator to navigate FocusStack
/**
+ * Get configuration from StyleManager.
+ */
+ void GetConfigurationFromStyleManger();
+
+ /**
* Get the focus group of current focused actor.
* @pre The FocusManager has been initialized.
* @return A handle to the parent of the current focused actor which is a focus group,
Actor mFocusIndicatorActor; ///< The focus indicator actor shared by all the keyboard focusable actors for highlight
- bool mFocusGroupLoopEnabled:1; ///< Whether the focus movement is looped within the same focus group
+ int mIsFocusIndicatorEnabled; ///< Whether indicator should be shown / hidden when getting focus. It could be enabled when keyboard focus feature is enabled and navigation keys or 'Tab' key are pressed.
- bool mIsFocusIndicatorEnabled:1; ///< Whether indicator should be shown / hidden. It could be enabled when keyboard focus feature enabled and navigation keys or 'Tab' key pressed.
+ bool mFocusGroupLoopEnabled:1; ///< Whether the focus movement is looped within the same focus group
bool mIsWaitingKeyboardFocusChangeCommit:1; /// A flag to indicate PreFocusChangeSignal emitted but the proposed focus actor is not commited by the application yet.
return mLoadedSignal;
}
+Toolkit::DevelAsyncImageLoader::PixelBufferLoadedSignalType& AsyncImageLoader::PixelBufferLoadedSignal()
+{
+ return mPixelBufferLoadedSignal;
+}
+
bool AsyncImageLoader::Cancel( uint32_t loadingTaskId )
{
return mLoadThread.CancelTask( loadingTaskId );
{
while( LoadingTask *next = mLoadThread.NextCompletedTask() )
{
- mLoadedSignal.Emit( next->id, next->pixelData );
+ if( mPixelBufferLoadedSignal.GetConnectionCount() > 0 )
+ {
+ mPixelBufferLoadedSignal.Emit( next->id, next->pixelBuffer );
+ }
+ else if( mLoadedSignal.GetConnectionCount() > 0 )
+ {
+ PixelData pixelData;
+ if( next->pixelBuffer )
+ {
+ pixelData = Devel::PixelBuffer::Convert( next->pixelBuffer );
+ }
+ mLoadedSignal.Emit( next->id, pixelData );
+ }
+
delete next;
}
}
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/image-loader/async-image-loader.h>
+#include <dali-toolkit/devel-api/image-loader/async-image-loader-devel.h>
#include <dali-toolkit/internal/image-loader/image-load-thread.h>
namespace Dali
Toolkit::AsyncImageLoader::ImageLoadedSignalType& ImageLoadedSignal();
/**
+ * @copydoc Toolkit::AsyncImageLoader::PixelBufferLoadedSignal
+ */
+ Toolkit::DevelAsyncImageLoader::PixelBufferLoadedSignalType& PixelBufferLoadedSignal();
+
+ /**
* @copydoc Toolkit::AsyncImageLoader::Cancel
*/
bool Cancel( uint32_t loadingTaskId );
private:
Toolkit::AsyncImageLoader::ImageLoadedSignalType mLoadedSignal;
+ Toolkit::DevelAsyncImageLoader::PixelBufferLoadedSignalType mPixelBufferLoadedSignal;
ImageLoadThread mLoadThread;
uint32_t mLoadTaskId;
#include <string.h>
#include <dali/public-api/signals/callback.h>
#include <dali/devel-api/adaptor-framework/image-loading.h>
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
#include <dali/integration-api/debug.h>
namespace Dali
void ImageAtlas::UploadBrokenImage( const Rect<unsigned int>& area )
{
- BitmapLoader loader = BitmapLoader::New(mBrokenImageUrl, ImageDimensions( area.width, area.height ) );
- loader.Load();
- SizeType loadedWidth = loader.GetPixelData().GetWidth();
- SizeType loadedHeight = loader.GetPixelData().GetHeight();
+ Devel::PixelBuffer brokenBuffer = LoadImageFromFile( mBrokenImageUrl, ImageDimensions( area.width, area.height ) );
+ SizeType loadedWidth = brokenBuffer.GetWidth();
+ SizeType loadedHeight = brokenBuffer.GetHeight();
bool needBackgroundClear = false;
SizeType packX = area.x;
if( needBackgroundClear )
{
SizeType size = area.width * area.height * Pixel::GetBytesPerPixel( mPixelFormat );
- PixelBuffer* buffer = new PixelBuffer [size];
- PixelData background = PixelData::New( buffer, size, area.width, area.height, mPixelFormat, PixelData::DELETE_ARRAY );
+ Devel::PixelBuffer background = Devel::PixelBuffer::New( area.width, area.height, mPixelFormat );
+ unsigned char* buffer = background.GetBuffer();
for( SizeType idx = 0; idx < size; idx++ )
{
buffer[idx] = 0x00;
}
- mAtlas.Upload( background, 0u, 0u, area.x, area.y, area.width, area.height );
+ PixelData pixelData = Devel::PixelBuffer::Convert( background );
+ mAtlas.Upload( pixelData, 0u, 0u, area.x, area.y, area.width, area.height );
}
- mAtlas.Upload( loader.GetPixelData(), 0u, 0u, packX, packY, loadedWidth, loadedHeight );
+ PixelData brokenPixelData = Devel::PixelBuffer::Convert( brokenBuffer );
+ mAtlas.Upload( brokenPixelData, 0u, 0u, packX, packY, loadedWidth, loadedHeight );
}
} // namespace Internal
LoadingTask::LoadingTask( uint32_t id, const VisualUrl& url, ImageDimensions dimensions,
FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection )
-: pixelData(),
+: pixelBuffer(),
url( url ),
id( id ),
dimensions( dimensions ),
{
if( url.IsLocal() )
{
- pixelData = Dali::LoadImageFromFile( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection );
+ pixelBuffer = Dali::LoadImageFromFile( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection );
}
else
{
- pixelData = Dali::DownloadImageSynchronously ( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection );
+ pixelBuffer = Dali::DownloadImageSynchronously ( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection );
}
}
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/images/image-operations.h>
-#include <dali/public-api/images/pixel-data.h>
#include <dali/devel-api/threading/conditional-wait.h>
#include <dali/devel-api/threading/mutex.h>
#include <dali/devel-api/threading/thread.h>
#include <dali/devel-api/adaptor-framework/event-thread-callback.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali-toolkit/internal/visuals/visual-url.h>
namespace Dali
public:
- PixelData pixelData; ///< pixelData handle after successfull load
+ Devel::PixelBuffer pixelBuffer; ///< pixelBuffer handle after successful load
VisualUrl url; ///< url of the image to load
uint32_t id; ///< The unique id associated with this task.
ImageDimensions dimensions; ///< dimensions to load
{
bool themeLoaded = false;
- mThemeBuilder = CreateBuilder( mThemeBuilderConstants );
-
- // Always load the default theme first, then merge in the custom theme if present
- themeLoaded = LoadJSON( mThemeBuilder, DEFAULT_THEME );
- mThemeFile = themeFile;
+ if( mThemeFile.compare(DEFAULT_THEME) == 0 && mThemeBuilder )
+ {
+ // We have already loaded the default theme into mThemeBuilder
+ }
+ else
+ {
+ // Reload the default theme
+ mThemeBuilder = CreateBuilder( mThemeBuilderConstants );
+ themeLoaded = LoadJSON( mThemeBuilder, DEFAULT_THEME );
+ }
if( themeFile.compare(DEFAULT_THEME) != 0 )
{
- themeLoaded = LoadJSON( mThemeBuilder, mThemeFile );
+ // The theme is different to the default: Merge it
+ themeLoaded = LoadJSON( mThemeBuilder, themeFile );
+ mThemeFile = themeFile;
}
if( themeLoaded )
}
}
+const Property::Map StyleManager::GetConfigurations()
+{
+ Property::Map result;
+ if( mThemeBuilder )
+ {
+ result = mThemeBuilder.GetConfigurations();
+ }
+ else
+ {
+ bool themeLoaded = false;
+
+ mThemeBuilder = CreateBuilder( mThemeBuilderConstants );
+
+ // Load default theme because this is first try to load stylesheet.
+ themeLoaded = LoadJSON( mThemeBuilder, DEFAULT_THEME );
+ mThemeFile = DEFAULT_THEME;
+
+ if( themeLoaded )
+ {
+ result = mThemeBuilder.GetConfigurations();
+ }
+ }
+
+ return result;
+}
+
bool StyleManager::LoadFile( const std::string& filename, std::string& stringOut )
{
DALI_ASSERT_DEBUG( 0 != filename.length());
bool GetStyleConstant( const std::string& key, Property::Value& valueOut );
/**
+ * @copydoc Toolkit::StyleManager::GetConfigurations
+ */
+ const Property::Map GetConfigurations();
+
+ /**
* @brief Apply the theme style to a control.
*
* @param[in] control The control to apply style.
// Set the primary cursor's height.
cursorInfo.primaryCursorHeight = cursorInfo.isSecondaryCursor ? 0.5f * glyphMetrics.fontHeight : glyphMetrics.fontHeight;
+
+ cursorInfo.glyphOffset = line.ascender - glyphMetrics.ascender;
// Set the primary cursor's position.
cursorInfo.primaryPosition.x = -glyphMetrics.xBearing + primaryPosition.x + glyphAdvance;
- cursorInfo.primaryPosition.y = cursorInfo.lineOffset + line.ascender - glyphMetrics.ascender;
+ cursorInfo.primaryPosition.y = cursorInfo.lineOffset + cursorInfo.glyphOffset;
// Transform the cursor info from line's coords to text's coords.
cursorInfo.primaryPosition.x += line.alignmentOffset;
: primaryPosition(),
secondaryPosition(),
lineOffset( 0.f ),
+ glyphOffset( 0.f ),
lineHeight( 0.f ),
primaryCursorHeight( 0.f ),
secondaryCursorHeight( 0.f ),
Vector2 primaryPosition; ///< The primary cursor's position (in text's coords).
Vector2 secondaryPosition; ///< The secondary cursor's position (in text's coords).
float lineOffset; ///< The vertical offset where the line containing the cursor starts.
+ float glyphOffset; ///< The difference of line ascender and glyph ascender.
float lineHeight; ///< The height of the line where the cursor is placed.
float primaryCursorHeight; ///< The primary cursor's height.
float secondaryCursorHeight; ///< The secondary cursor's height.
: color( Dali::Color::BLACK ),
position(),
cursorHeight( 0.0f ),
- lineHeight( 0.0f )
+ lineHeight( 0.0f ),
+ glyphOffset( 0.0f )
{
}
Vector2 position;
float cursorHeight;
float lineHeight;
+ float glyphOffset;
};
struct HandleImpl
return mImpl->mCursor[cursor].position;
}
+void Decorator::SetGlyphOffset( Cursor cursor, float glyphOffset )
+{
+ Impl::CursorImpl& cursorImpl = mImpl->mCursor[cursor];
+
+ cursorImpl.glyphOffset = glyphOffset;
+}
+
+const float Decorator::GetGlyphOffset( Cursor cursor) const
+{
+ return mImpl->mCursor[cursor].glyphOffset;
+}
+
void Decorator::SetCursorColor( Cursor cursor, const Dali::Vector4& color )
{
mImpl->mCursor[cursor].color = color;
*/
const Vector2& GetPosition( Cursor cursor ) const;
+
+ /**
+ * @brief Sets the glyph offset of a cursor.
+ *
+ * @param[in] cursor The cursor to set.
+ * @param[in] glyphoffset The difference of line ascender and glyph ascender.
+ */
+ void SetGlyphOffset( Cursor cursor, float glyphOffset );
+
+ /**
+ * @brief Retrieves the glyph offset of a cursor.
+ *
+ * @param[in] cursor The cursor to get.
+ *
+ * @return The glyph offset. glyph offset means difference of line ascender and glyph ascender.
+ */
+ const float GetGlyphOffset( Cursor cursor ) const;
+
/**
* @brief Sets the color for a cursor.
*
EventData::EventData( DecoratorPtr decorator )
: mDecorator( decorator ),
mImfManager(),
+ mPlaceholderFont( NULL ),
mPlaceholderText(),
mPlaceholderTextActive(),
mPlaceholderTextInactive(),
mScrollAfterDelete( false ),
mAllTextSelected( false ),
mUpdateInputStyle( false ),
- mPasswordInput( false )
+ mPasswordInput( false ),
+ mIsPlaceholderPixelSize( false )
{
mImfManager = ImfManager::Get();
}
// Get the default font's description.
TextAbstraction::FontDescription defaultFontDescription;
TextAbstraction::PointSize26Dot6 defaultPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
- if( NULL != mFontDefaults )
+
+ if( IsShowingPlaceholderText() && ( NULL != mEventData->mPlaceholderFont ) )
{
+ // If the placeholder font is set specifically, only placeholder font is changed.
+ defaultFontDescription = mEventData->mPlaceholderFont->mFontDescription;
+ if( mEventData->mPlaceholderFont->sizeDefined )
+ {
+ defaultPointSize = mEventData->mPlaceholderFont->mDefaultPointSize * 64u;
+ }
+ }
+ else if( NULL != mFontDefaults )
+ {
+ // Set the normal font and the placeholder font.
defaultFontDescription = mFontDefaults->mFontDescription;
defaultPointSize = mFontDefaults->mDefaultPointSize * 64u;
}
const Vector2 cursorPosition = cursorInfo.primaryPosition + mModel->mScrollPosition;
+ mEventData->mDecorator->SetGlyphOffset( PRIMARY_CURSOR, cursorInfo.glyphOffset );
+
// Sets the cursor position.
mEventData->mDecorator->SetPosition( PRIMARY_CURSOR,
cursorPosition.x,
// Get the current cursor position in decorator coords.
const Vector2& currentCursorPosition = mEventData->mDecorator->GetPosition( PRIMARY_CURSOR );
+ const LineIndex lineIndex = mModel->mVisualModel->GetLineOfCharacter( mEventData->mPrimaryCursorPosition );
+
+
+
// Calculate the offset to match the cursor position before the character was deleted.
mModel->mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x;
- mModel->mScrollPosition.y = currentCursorPosition.y - cursorInfo.lineOffset;
+
+ //If text control has more than two lines and current line index is not last, calculate scrollpositionY
+ if( mModel->mVisualModel->mLines.Count() > 1u && lineIndex != mModel->mVisualModel->mLines.Count() -1u )
+ {
+ const float currentCursorGlyphOffset = mEventData->mDecorator->GetGlyphOffset( PRIMARY_CURSOR );
+ mModel->mScrollPosition.y = currentCursorPosition.y - cursorInfo.lineOffset - currentCursorGlyphOffset;
+ }
+
ClampHorizontalScroll( mModel->mVisualModel->GetLayoutSize() );
ClampVerticalScroll( mModel->mVisualModel->GetLayoutSize() );
//Forward declarations
struct CursorInfo;
+struct FontDefaults;
struct Event
{
DecoratorPtr mDecorator; ///< Pointer to the decorator.
ImfManager mImfManager; ///< The Input Method Framework Manager.
+ FontDefaults* mPlaceholderFont; ///< The placeholder default font.
std::string mPlaceholderText; ///< The text to display when the TextField is empty.
std::string mPlaceholderTextActive; ///< The text to display when the TextField is empty with key-input focus.
std::string mPlaceholderTextInactive; ///< The text to display when the TextField is empty and inactive.
bool mUpdateInputStyle : 1; ///< Whether to update the input style after moving the cursor.
bool mPasswordInput : 1; ///< True if password input is enabled.
bool mCheckScrollAmount : 1; ///< Whether to check scrolled amount after updating the position
+ bool mIsPlaceholderPixelSize : 1; ///< True if the placeholder font size is set as pixel size.
};
struct ModifyEvent
#include <dali-toolkit/internal/text/character-set-conversion.h>
#include <dali-toolkit/internal/text/layouts/layout-parameters.h>
#include <dali-toolkit/internal/text/markup-processor.h>
+#include <dali-toolkit/internal/text/multi-language-support.h>
#include <dali-toolkit/internal/text/text-controller-impl.h>
#include <dali-toolkit/internal/text/text-editable-control-interface.h>
+#include <dali-toolkit/internal/text/text-font-style.h>
namespace
{
const std::string EMPTY_STRING("");
+const char * const PLACEHOLDER_TEXT = "placeholderText";
+const char * const PLACEHOLDER_COLOR = "placeholderColor";
+const char * const PLACEHOLDER_FONT_FAMILY = "placeholderFontFamily";
+const char * const PLACEHOLDER_FONT_STYLE = "placeholderFontStyle";
+const char * const PLACEHOLDER_POINT_SIZE = "placeholderPointSize";
+const char * const PLACEHOLDER_PIXEL_SIZE = "placeholderPixelSize";
+
float ConvertToEven( float value )
{
int intValue(static_cast<int>( value ));
return mImpl->mModel->mElideEnabled;
}
+void Controller::SetSelectionEnabled( bool enabled )
+{
+ mImpl->mEventData->mSelectionEnabled = enabled;
+}
+
+bool Controller::IsSelectionEnabled() const
+{
+ return mImpl->mEventData->mSelectionEnabled;
+}
+
// public : Update
void Controller::SetText( const std::string& text )
return EMPTY_STRING;
}
+void Controller::SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ if( NULL == mImpl->mEventData->mPlaceholderFont )
+ {
+ mImpl->mEventData->mPlaceholderFont = new FontDefaults();
+ }
+
+ mImpl->mEventData->mPlaceholderFont->mFontDescription.family = placeholderTextFontFamily;
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetPlaceholderFontFamily %s\n", placeholderTextFontFamily.c_str());
+ mImpl->mEventData->mPlaceholderFont->familyDefined = !placeholderTextFontFamily.empty();
+
+ mImpl->RequestRelayout();
+ }
+}
+
+const std::string& Controller::GetPlaceholderFontFamily() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->mFontDescription.family;
+ }
+
+ return EMPTY_STRING;
+}
+
void Controller::SetDefaultFontWeight( FontWeight weight )
{
if( NULL == mImpl->mFontDefaults )
return TextAbstraction::FontWeight::NORMAL;
}
+void Controller::SetPlaceholderTextFontWeight( FontWeight weight )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ if( NULL == mImpl->mEventData->mPlaceholderFont )
+ {
+ mImpl->mEventData->mPlaceholderFont = new FontDefaults();
+ }
+
+ mImpl->mEventData->mPlaceholderFont->mFontDescription.weight = weight;
+ mImpl->mEventData->mPlaceholderFont->weightDefined = true;
+
+ mImpl->RequestRelayout();
+ }
+}
+
+bool Controller::IsPlaceholderTextFontWeightDefined() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->weightDefined;
+ }
+ return false;
+}
+
+FontWeight Controller::GetPlaceholderTextFontWeight() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->mFontDescription.weight;
+ }
+
+ return TextAbstraction::FontWeight::NORMAL;
+}
+
void Controller::SetDefaultFontWidth( FontWidth width )
{
if( NULL == mImpl->mFontDefaults )
return TextAbstraction::FontWidth::NORMAL;
}
+void Controller::SetPlaceholderTextFontWidth( FontWidth width )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ if( NULL == mImpl->mEventData->mPlaceholderFont )
+ {
+ mImpl->mEventData->mPlaceholderFont = new FontDefaults();
+ }
+
+ mImpl->mEventData->mPlaceholderFont->mFontDescription.width = width;
+ mImpl->mEventData->mPlaceholderFont->widthDefined = true;
+
+ mImpl->RequestRelayout();
+ }
+}
+
+bool Controller::IsPlaceholderTextFontWidthDefined() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->widthDefined;
+ }
+ return false;
+}
+
+FontWidth Controller::GetPlaceholderTextFontWidth() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->mFontDescription.width;
+ }
+
+ return TextAbstraction::FontWidth::NORMAL;
+}
+
void Controller::SetDefaultFontSlant( FontSlant slant )
{
if( NULL == mImpl->mFontDefaults )
return TextAbstraction::FontSlant::NORMAL;
}
+void Controller::SetPlaceholderTextFontSlant( FontSlant slant )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ if( NULL == mImpl->mEventData->mPlaceholderFont )
+ {
+ mImpl->mEventData->mPlaceholderFont = new FontDefaults();
+ }
+
+ mImpl->mEventData->mPlaceholderFont->mFontDescription.slant = slant;
+ mImpl->mEventData->mPlaceholderFont->slantDefined = true;
+
+ mImpl->RequestRelayout();
+ }
+}
+
+bool Controller::IsPlaceholderTextFontSlantDefined() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->slantDefined;
+ }
+ return false;
+}
+
+FontSlant Controller::GetPlaceholderTextFontSlant() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->mFontDescription.slant;
+ }
+
+ return TextAbstraction::FontSlant::NORMAL;
+}
+
void Controller::SetDefaultFontSize( float fontSize, FontSizeType type )
{
if( NULL == mImpl->mFontDefaults )
}
case PIXEL_SIZE:
{
- // Point size = Pixel size * 72 / DPI
+ // Point size = Pixel size * 72.f / DPI
unsigned int horizontalDpi = 0u;
unsigned int verticalDpi = 0u;
TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
fontClient.GetDpi( horizontalDpi, verticalDpi );
- mImpl->mFontDefaults->mDefaultPointSize = ( fontSize * 72 ) / horizontalDpi;
+ mImpl->mFontDefaults->mDefaultPointSize = ( fontSize * 72.f ) / static_cast< float >( horizontalDpi );
mImpl->mFontDefaults->sizeDefined = true;
break;
}
- default:
- {
- DALI_ASSERT_ALWAYS( false );
- }
}
// Clear the font-specific data
}
case PIXEL_SIZE:
{
- // Pixel size = Point size * DPI / 72
+ // Pixel size = Point size * DPI / 72.f
unsigned int horizontalDpi = 0u;
unsigned int verticalDpi = 0u;
TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
fontClient.GetDpi( horizontalDpi, verticalDpi );
- value = mImpl->mFontDefaults->mDefaultPointSize * horizontalDpi / 72;
+ value = mImpl->mFontDefaults->mDefaultPointSize * static_cast< float >( horizontalDpi ) / 72.f;
break;
}
- default:
+ }
+ return value;
+ }
+
+ return value;
+}
+
+void Controller::SetPlaceholderTextFontSize( float fontSize, FontSizeType type )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ if( NULL == mImpl->mEventData->mPlaceholderFont )
+ {
+ mImpl->mEventData->mPlaceholderFont = new FontDefaults();
+ }
+
+ switch( type )
+ {
+ case POINT_SIZE:
{
- DALI_ASSERT_ALWAYS( false );
+ mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = fontSize;
+ mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
+ mImpl->mEventData->mIsPlaceholderPixelSize = false; // Font size flag
+ break;
+ }
+ case PIXEL_SIZE:
+ {
+ // Point size = Pixel size * 72.f / DPI
+ unsigned int horizontalDpi = 0u;
+ unsigned int verticalDpi = 0u;
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.GetDpi( horizontalDpi, verticalDpi );
+
+ mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = ( fontSize * 72.f ) / static_cast< float >( horizontalDpi );
+ mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
+ mImpl->mEventData->mIsPlaceholderPixelSize = true; // Font size flag
+ break;
+ }
+ }
+
+ mImpl->RequestRelayout();
+ }
+}
+
+float Controller::GetPlaceholderTextFontSize( FontSizeType type ) const
+{
+ float value = 0.0f;
+ if( NULL != mImpl->mEventData )
+ {
+ switch( type )
+ {
+ case POINT_SIZE:
+ {
+ if( NULL != mImpl->mEventData->mPlaceholderFont )
+ {
+ value = mImpl->mEventData->mPlaceholderFont->mDefaultPointSize;
+ }
+ else
+ {
+ // If the placeholder text font size is not set, then return the default font size.
+ value = GetDefaultFontSize( POINT_SIZE );
+ }
+ break;
+ }
+ case PIXEL_SIZE:
+ {
+ if( NULL != mImpl->mEventData->mPlaceholderFont )
+ {
+ // Pixel size = Point size * DPI / 72.f
+ unsigned int horizontalDpi = 0u;
+ unsigned int verticalDpi = 0u;
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.GetDpi( horizontalDpi, verticalDpi );
+
+ value = mImpl->mEventData->mPlaceholderFont->mDefaultPointSize * static_cast< float >( horizontalDpi ) / 72.f;
+ }
+ else
+ {
+ // If the placeholder text font size is not set, then return the default font size.
+ value = GetDefaultFontSize( PIXEL_SIZE );
+ }
+ break;
}
}
return value;
}
}
+void Controller::SetPlaceholderProperty( const Property::Map& map )
+{
+ const Property::Map::SizeType count = map.Count();
+
+ for( Property::Map::SizeType position = 0; position < count; ++position )
+ {
+ KeyValuePair keyValue = map.GetKeyValue( position );
+ Property::Key& key = keyValue.first;
+ Property::Value& value = keyValue.second;
+
+ if( key == PLACEHOLDER_TEXT )
+ {
+ std::string text = "";
+ value.Get( text );
+ SetPlaceholderText( text );
+ }
+ else if( key == PLACEHOLDER_COLOR )
+ {
+ Vector4 textColor;
+ value.Get( textColor );
+ if( GetPlaceholderTextColor() != textColor )
+ {
+ SetPlaceholderTextColor( textColor );
+ }
+ }
+ else if( key == PLACEHOLDER_FONT_FAMILY )
+ {
+ std::string fontFamily = "";
+ value.Get( fontFamily );
+ SetPlaceholderFontFamily( fontFamily );
+ }
+ else if( key == PLACEHOLDER_FONT_STYLE )
+ {
+ SetFontStyleProperty( this, value, Text::FontStyle::PLACEHOLDER );
+ }
+ else if( key == PLACEHOLDER_POINT_SIZE )
+ {
+ float pointSize;
+ value.Get( pointSize );
+ if( !Equals( GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE ), pointSize ) )
+ {
+ SetPlaceholderTextFontSize( pointSize, Text::Controller::POINT_SIZE );
+ }
+ }
+ else if( key == PLACEHOLDER_PIXEL_SIZE )
+ {
+ float pixelSize;
+ value.Get( pixelSize );
+ if( !Equals( GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) )
+ {
+ SetPlaceholderTextFontSize( pixelSize, Text::Controller::PIXEL_SIZE );
+ }
+ }
+ }
+}
+
+void Controller::GetPlaceholderProperty( Property::Map& map )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ map[ PLACEHOLDER_TEXT ] = mImpl->mEventData->mPlaceholderText;
+ map[ PLACEHOLDER_COLOR ] = mImpl->mEventData->mPlaceholderTextColor;
+ map[ PLACEHOLDER_FONT_FAMILY ] = GetPlaceholderFontFamily();
+
+ Property::Value fontStyleMapGet;
+ GetFontStyleProperty( this, fontStyleMapGet, Text::FontStyle::PLACEHOLDER );
+ map[ PLACEHOLDER_FONT_STYLE ] = fontStyleMapGet;
+
+ // Choose font size : POINT_SIZE or PIXEL_SIZE
+ if( !mImpl->mEventData->mIsPlaceholderPixelSize )
+ {
+ map[ PLACEHOLDER_POINT_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE );
+ }
+ else
+ {
+ map[ PLACEHOLDER_PIXEL_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE );
+ }
+ }
+}
+
// public : Relayout.
Controller::UpdateTextType Controller::Relayout( const Size& size )
bool IsTextElideEnabled() const;
/**
+ * @brief Enable or disable the text selection.
+ * @param[in] enabled Whether to enable the text selection.
+ */
+ void SetSelectionEnabled( bool enabled );
+
+ /**
+ * @brief Whether the text selection is enabled or not.
+ * @return True if the text selection is enabled
+ */
+ bool IsSelectionEnabled() const;
+
+ /**
* @brief Sets input type to password
*
* @note The string is displayed hidden character
const std::string& GetDefaultFontFamily() const;
/**
+ * @brief Sets the placeholder text font family.
+ * @param[in] placeholderTextFontFamily The placeholder text font family.
+ */
+ void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
+
+ /**
+ * @brief Retrieves the placeholder text font family.
+ *
+ * @return The placeholder text font family
+ */
+ const std::string& GetPlaceholderFontFamily() const;
+
+ /**
* @brief Sets the default font weight.
*
* @param[in] weight The font weight.
FontWeight GetDefaultFontWeight() const;
/**
+ * @brief Sets the placeholder text font weight.
+ *
+ * @param[in] weight The font weight
+ */
+ void SetPlaceholderTextFontWeight( FontWeight weight );
+
+ /**
+ * @brief Whether the font's weight has been defined.
+ *
+ * @return True if the placeholder text font weight is defined
+ */
+ bool IsPlaceholderTextFontWeightDefined() const;
+
+ /**
+ * @brief Retrieves the placeholder text font weight.
+ *
+ * @return The placeholder text font weight
+ */
+ FontWeight GetPlaceholderTextFontWeight() const;
+
+ /**
* @brief Sets the default font width.
*
* @param[in] width The font width.
FontWidth GetDefaultFontWidth() const;
/**
+ * @brief Sets the placeholder text font width.
+ *
+ * @param[in] width The font width
+ */
+ void SetPlaceholderTextFontWidth( FontWidth width );
+
+ /**
+ * @brief Whether the font's width has been defined.
+ *
+ * @return True if the placeholder text font width is defined
+ */
+ bool IsPlaceholderTextFontWidthDefined() const;
+
+ /**
+ * @brief Retrieves the placeholder text font width.
+ *
+ * @return The placeholder text font width
+ */
+ FontWidth GetPlaceholderTextFontWidth() const;
+
+ /**
* @brief Sets the default font slant.
*
* @param[in] slant The font slant.
FontSlant GetDefaultFontSlant() const;
/**
+ * @brief Sets the placeholder text font slant.
+ *
+ * @param[in] slant The font slant
+ */
+ void SetPlaceholderTextFontSlant( FontSlant slant );
+
+ /**
+ * @brief Whether the font's slant has been defined.
+ *
+ * @return True if the placeholder text font slant is defined
+ */
+ bool IsPlaceholderTextFontSlantDefined() const;
+
+ /**
+ * @brief Retrieves the placeholder text font slant.
+ *
+ * @return The placeholder text font slant
+ */
+ FontSlant GetPlaceholderTextFontSlant() const;
+
+ /**
* @brief Set the default font size.
*
- * @param[in] size The default font size.
+ * @param[in] fontSize The default font size
* @param[in] type The font size type is point size or pixel size
*/
void SetDefaultFontSize( float fontSize, FontSizeType type );
float GetDefaultFontSize( FontSizeType type ) const;
/**
+ * @brief Sets the Placeholder text font size.
+ * @param[in] fontSize The placeholder text font size
+ * @param[in] type The font size type is point size or pixel size
+ */
+ void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
+
+ /**
+ * @brief Retrieves the Placeholder text font size.
+ * @param[in] type The font size type
+ * @return The placeholder font size
+ */
+ float GetPlaceholderTextFontSize( FontSizeType type ) const;
+
+ /**
* @brief Sets the text's default color.
*
* @param color The default color.
*/
void GetHiddenInputOption( Property::Map& options );
+ /**
+ * @brief Sets the Placeholder Properties.
+ *
+ * @param[in] map The placeholder property map
+ */
+ void SetPlaceholderProperty( const Property::Map& map );
+
+ /**
+ * @brief Retrieves the Placeholder Property map.
+ *
+ * @param[out] map The property map
+ */
+ void GetPlaceholderProperty( Property::Map& map );
+
public: // Relayout.
/**
}
break;
}
+ case FontStyle::PLACEHOLDER:
+ {
+ // Sets the placeholder text font's style values.
+ if( !weightDefined ||
+ ( weightDefined && ( controller->GetPlaceholderTextFontWeight() != weight ) ) )
+ {
+ controller->SetPlaceholderTextFontWeight( weight );
+ }
+
+ if( !widthDefined ||
+ ( widthDefined && ( controller->GetPlaceholderTextFontWidth() != width ) ) )
+ {
+ controller->SetPlaceholderTextFontWidth( width );
+ }
+
+ if( !slantDefined ||
+ ( slantDefined && ( controller->GetPlaceholderTextFontSlant() != slant ) ) )
+ {
+ controller->SetPlaceholderTextFontSlant( slant );
+ }
+ break;
+ }
} // switch
} // map not empty
else
controller->SetInputFontSlant( TextAbstraction::FontSlant::NONE );
break;
}
+ case FontStyle::PLACEHOLDER:
+ {
+ controller->SetPlaceholderTextFontWeight( TextAbstraction::FontWeight::NONE );
+ controller->SetPlaceholderTextFontWidth( TextAbstraction::FontWidth::NONE );
+ controller->SetPlaceholderTextFontSlant( TextAbstraction::FontSlant::NONE );
+ break;
+ }
} // switch
} // map.Empty()
} // controller
{
if( controller )
{
- const bool isDefaultStyle = FontStyle::DEFAULT == type;
const bool isSetbyString = controller->IsFontStyleSetByString();
bool weightDefined = false;
FontWidth width = TextAbstraction::FontWidth::NONE;
FontSlant slant = TextAbstraction::FontSlant::NONE;
- if( isDefaultStyle )
+ switch( type )
{
- weightDefined = controller->IsDefaultFontWeightDefined();
- widthDefined = controller->IsDefaultFontWidthDefined();
- slantDefined = controller->IsDefaultFontSlantDefined();
-
- if( weightDefined )
+ case FontStyle::DEFAULT:
{
- weight = controller->GetDefaultFontWeight();
- }
+ weightDefined = controller->IsDefaultFontWeightDefined();
+ widthDefined = controller->IsDefaultFontWidthDefined();
+ slantDefined = controller->IsDefaultFontSlantDefined();
- if( widthDefined )
- {
- width = controller->GetDefaultFontWidth();
- }
+ if( weightDefined )
+ {
+ weight = controller->GetDefaultFontWeight();
+ }
- if( slantDefined )
- {
- slant = controller->GetDefaultFontSlant();
- }
- }
- else
- {
- weightDefined = controller->IsInputFontWeightDefined();
- widthDefined = controller->IsInputFontWidthDefined();
- slantDefined = controller->IsInputFontSlantDefined();
+ if( widthDefined )
+ {
+ width = controller->GetDefaultFontWidth();
+ }
- if( weightDefined )
- {
- weight = controller->GetInputFontWeight();
+ if( slantDefined )
+ {
+ slant = controller->GetDefaultFontSlant();
+ }
+ break;
}
-
- if( widthDefined )
+ case FontStyle::INPUT:
{
- width = controller->GetInputFontWidth();
- }
+ weightDefined = controller->IsInputFontWeightDefined();
+ widthDefined = controller->IsInputFontWidthDefined();
+ slantDefined = controller->IsInputFontSlantDefined();
- if( slantDefined )
+ if( weightDefined )
+ {
+ weight = controller->GetInputFontWeight();
+ }
+
+ if( widthDefined )
+ {
+ width = controller->GetInputFontWidth();
+ }
+
+ if( slantDefined )
+ {
+ slant = controller->GetInputFontSlant();
+ }
+ break;
+ }
+ case FontStyle::PLACEHOLDER:
{
- slant = controller->GetInputFontSlant();
+ // The type is FontStyle::PLACEHOLDER
+ weightDefined = controller->IsPlaceholderTextFontWeightDefined();
+ widthDefined = controller->IsPlaceholderTextFontWidthDefined();
+ slantDefined = controller->IsPlaceholderTextFontSlantDefined();
+
+ if( weightDefined )
+ {
+ weight = controller->GetPlaceholderTextFontWeight();
+ }
+
+ if( widthDefined )
+ {
+ width = controller->GetPlaceholderTextFontWidth();
+ }
+
+ if( slantDefined )
+ {
+ slant = controller->GetPlaceholderTextFontSlant();
+ }
+ break;
}
}
{
enum Type
{
- DEFAULT, ///< The default font's style.
- INPUT ///< The input font's style.
+ DEFAULT, ///< The default font's style.
+ INPUT, ///< The input font's style.
+ PLACEHOLDER ///< The placeholder text font's style.
};
};
*
* @param[in] controller The text's controller.
* @param[in] value The value of the font's style.
- * @param[in] type Whether the property is for the default font's style or the input font's style.
+ * @param[in] type Whether the property is for the default font's style, the input font's style or the placeholder font's style.
*
*/
void SetFontStyleProperty( ControllerPtr controller, const Property::Value& value, FontStyle::Type type );
*
* @param[in] controller The text's controller.
* @param[out] value The value of the font's style.
- * @param[in] type Whether the property is for the default font's style or the input font's style.
+ * @param[in] type Whether the property is for the default font's style, the input font's style or the placeholder font's style.
*/
void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, FontStyle::Type type );
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/images/native-image.h>
#include <dali/devel-api/images/texture-set-image.h>
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/devel-api/scripting/scripting.h>
{
bool atlasing = false;
mAttemptAtlasing = value.Get( atlasing );
+ break;
}
case Toolkit::DevelImageVisual::Property::ALPHA_MASK_URL:
{
mAlphaMaskUrl = VisualUrl( alphaUrl );
}
+ break;
}
}
}
{
if( mImageUrl.IsValid() )
{
- BitmapLoader loader = BitmapLoader::New( mImageUrl.GetUrl(), mDesiredSize, mFittingMode, mSamplingMode );
- loader.Load();
- mPixels = loader.GetPixelData();
+ Devel::PixelBuffer pixelBuffer = LoadImageFromFile( mImageUrl.GetUrl(), mDesiredSize, mFittingMode, mSamplingMode );
+
+ if( pixelBuffer )
+ {
+ mPixels = Devel::PixelBuffer::Convert(pixelBuffer); // takes ownership of buffer
+ }
mTextureLoading = false;
}
}
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
#include <dali/public-api/common/stage.h>
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
+#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <dali/devel-api/adaptor-framework/file-loader.h>
#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/devel-api/scripting/scripting.h>
Texture LoadTexture( const char* imageUrl, bool generateMipmaps )
{
Texture texture;
- Dali::BitmapLoader loader = Dali::BitmapLoader::New( imageUrl );
- loader.Load();
- PixelData pixelData = loader.GetPixelData();
- if( pixelData )
+
+ Devel::PixelBuffer pixelBuffer = LoadImageFromFile( imageUrl );
+ if( pixelBuffer )
{
- texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
+ texture = Texture::New( TextureType::TEXTURE_2D, pixelBuffer.GetPixelFormat(), pixelBuffer.GetWidth(), pixelBuffer.GetHeight() );
+ PixelData pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
texture.Upload( pixelData );
if( generateMipmaps )
vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
- mediump vec2 scale = vec2( length( uModelMatrix[ 0 ].xyz ), length( uModelMatrix[ 1 ].xyz ) );\n
mediump vec2 size = visualSize.xy;\n
\n
mediump vec2 fixedFactor = vec2( uFixed[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uFixed[ int( ( aPosition.y + 1.0 ) * 0.5 ) ].y );\n
}
hints = mImpl->mCustomShader->mHints;
+ /* Apply Custom Vertex Shader only if image is 9-patch */
if( ( xStretchCount == 1 && yStretchCount == 1 ) ||
( xStretchCount == 0 && yStretchCount == 0 ) )
{
- shader = Shader::New( VERTEX_SHADER_3X3, fragmentShader, hints );
+ const char* vertexShader = VERTEX_SHADER_3X3;
+
+ if( !mImpl->mCustomShader->mVertexShader.empty() )
+ {
+ vertexShader = mImpl->mCustomShader->mVertexShader.c_str();
+ }
+ shader = Shader::New( vertexShader, fragmentShader, hints );
}
else if( xStretchCount > 0 || yStretchCount > 0)
{
// Hold the weak handle of the placement actor and delay the adding of renderer until the svg rasterization is finished.
mPlacementActor = actor;
+
+ // SVG visual needs it's size set before it can be rasterized hence set ResourceReady once on stage
+ ResourceReady();
}
void SvgVisual::DoSetOffStage( Actor& actor )
}
// Nothing else to do if the relayout size is zero.
+ ResourceReady();
return;
}
// EXTERNAL HEADERS
#include <dali/devel-api/common/hash.h>
-#include <dali/devel-api/images/pixel-data-mask.h>
#include <dali/devel-api/images/texture-set-image.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali/integration-api/debug.h>
// INTERNAL HEADERS
#include <dali/integration-api/debug.h>
-#include <dali-toolkit/internal/image-loader/async-image-loader-impl.h>
+#include <dali-toolkit/devel-api/image-loader/async-image-loader-devel.h>
#include <dali-toolkit/internal/image-loader/image-atlas-impl.h>
+#include <dali-toolkit/internal/image-loader/async-image-loader-impl.h>
#include <dali-toolkit/public-api/image-loader/sync-image-loader.h>
mAsyncRemoteLoader( Toolkit::AsyncImageLoader::New() ),
mCurrentTextureId( 0 )
{
- mAsyncLocalLoader.ImageLoadedSignal().Connect( this, &TextureManager::AsyncLocalLoadComplete );
- mAsyncRemoteLoader.ImageLoadedSignal().Connect( this, &TextureManager::AsyncRemoteLoadComplete );
+ DevelAsyncImageLoader::PixelBufferLoadedSignal(mAsyncLocalLoader).Connect( this, &TextureManager::AsyncLocalLoadComplete );
+ DevelAsyncImageLoader::PixelBufferLoadedSignal(mAsyncRemoteLoader).Connect( this, &TextureManager::AsyncRemoteLoadComplete );
}
TextureManager::TextureId TextureManager::RequestLoad(
const UseAtlas useAtlas,
TextureUploadObserver* observer )
{
- return RequestInternalLoad( url, INVALID_TEXTURE_ID, desiredSize, fittingMode, samplingMode, useAtlas, GPU_UPLOAD, observer );
+ return RequestLoadInternal( url, INVALID_TEXTURE_ID, desiredSize, fittingMode, samplingMode, useAtlas, UPLOAD_TO_TEXTURE, observer );
}
TextureManager::TextureId TextureManager::RequestLoad(
const UseAtlas useAtlas,
TextureUploadObserver* observer )
{
- return RequestInternalLoad( url, maskTextureId, desiredSize, fittingMode, samplingMode, useAtlas, GPU_UPLOAD, observer );
+ return RequestLoadInternal( url, maskTextureId, desiredSize, fittingMode, samplingMode, useAtlas, UPLOAD_TO_TEXTURE, observer );
}
TextureManager::TextureId TextureManager::RequestMaskLoad( const VisualUrl& maskUrl )
{
// Use the normal load procedure to get the alpha mask.
- return RequestInternalLoad( maskUrl, INVALID_TEXTURE_ID, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, NO_ATLAS, CPU, NULL );
+ return RequestLoadInternal( maskUrl, INVALID_TEXTURE_ID, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, NO_ATLAS, KEEP_PIXEL_BUFFER, NULL );
}
-TextureManager::TextureId TextureManager::RequestInternalLoad(
+TextureManager::TextureId TextureManager::RequestLoadInternal(
const VisualUrl& url,
TextureId maskTextureId,
const ImageDimensions desiredSize,
}
}
+const VisualUrl& TextureManager::GetVisualUrl( TextureId textureId )
+{
+ int cacheIndex = GetCacheIndexFromId( textureId );
+ DALI_ASSERT_DEBUG( cacheIndex != INVALID_CACHE_INDEX && "TextureId out of range");
+
+ TextureInfo& cachedTextureInfo( mTextureInfoContainer[ cacheIndex ] );
+ return cachedTextureInfo.url;
+}
+
TextureManager::LoadState TextureManager::GetTextureState( TextureId textureId )
{
LoadState loadState = TextureManager::NOT_STARTED;
}
}
-void TextureManager::AsyncLocalLoadComplete( uint32_t id, PixelData pixelData )
+void TextureManager::AsyncLocalLoadComplete( uint32_t id, Devel::PixelBuffer pixelBuffer )
{
- AsyncLoadComplete( mAsyncLocalLoadingInfoContainer, id, pixelData );
+ AsyncLoadComplete( mAsyncLocalLoadingInfoContainer, id, pixelBuffer );
}
-void TextureManager::AsyncRemoteLoadComplete( uint32_t id, PixelData pixelData )
+void TextureManager::AsyncRemoteLoadComplete( uint32_t id, Devel::PixelBuffer pixelBuffer )
{
- AsyncLoadComplete( mAsyncRemoteLoadingInfoContainer, id, pixelData );
+ AsyncLoadComplete( mAsyncRemoteLoadingInfoContainer, id, pixelBuffer );
}
-void TextureManager::AsyncLoadComplete( AsyncLoadingInfoContainerType& loadingContainer, uint32_t id, PixelData pixelData )
+void TextureManager::AsyncLoadComplete( AsyncLoadingInfoContainerType& loadingContainer, uint32_t id, Devel::PixelBuffer pixelBuffer )
{
DALI_LOG_INFO( gTextureManagerLogFilter, Debug::Concise, "TextureManager::AsyncLoadComplete( id:%d )\n", id );
if( textureInfo.loadState != CANCELLED )
{
// textureInfo can be invalidated after this call (as the mTextureInfoContainer may be modified)
- PostLoad( textureInfo, pixelData );
+ PostLoad( textureInfo, pixelBuffer );
}
else
{
}
}
-void TextureManager::PostLoad( TextureInfo& textureInfo, PixelData pixelData )
+void TextureManager::PostLoad( TextureInfo& textureInfo, Devel::PixelBuffer& pixelBuffer )
{
// Was the load successful?
- if( pixelData && ( pixelData.GetWidth() != 0 ) && ( pixelData.GetHeight() != 0 ) )
+ if( pixelBuffer && ( pixelBuffer.GetWidth() != 0 ) && ( pixelBuffer.GetHeight() != 0 ) )
{
// No atlas support for now
textureInfo.useAtlas = NO_ATLAS;
- if( textureInfo.storageType == GPU_UPLOAD )
+ if( textureInfo.storageType == UPLOAD_TO_TEXTURE )
{
// If there is a mask texture ID associated with this texture, then apply the mask
// if it's already loaded. If it hasn't, and the mask is still loading,
LoadState maskLoadState = GetTextureState( textureInfo.maskTextureId );
if( maskLoadState == LOADING )
{
- textureInfo.pixelData = pixelData; // Store the pixel data temporarily
+ textureInfo.pixelBuffer = pixelBuffer; // Store the pixel buffer temporarily
textureInfo.loadState = WAITING_FOR_MASK;
}
else if( maskLoadState == LOAD_FINISHED )
{
- ApplyMask( pixelData, textureInfo.maskTextureId );
- UploadTexture( pixelData, textureInfo );
+ ApplyMask( pixelBuffer, textureInfo.maskTextureId );
+ UploadTexture( pixelBuffer, textureInfo );
NotifyObservers( textureInfo, true );
}
}
else
{
- UploadTexture( pixelData, textureInfo );
+ UploadTexture( pixelBuffer, textureInfo );
NotifyObservers( textureInfo, true );
}
}
- else // currently, CPU textures are local to texture manager
+ else
{
- textureInfo.pixelData = pixelData; // Store the pixel data
+ textureInfo.pixelBuffer = pixelBuffer; // Store the pixel data
textureInfo.loadState = LOAD_FINISHED;
// Check if there was another texture waiting for this load to complete
mTextureInfoContainer[cacheIndex].loadState == WAITING_FOR_MASK )
{
TextureInfo& textureInfo( mTextureInfoContainer[cacheIndex] );
- PixelData pixelData = textureInfo.pixelData;
- textureInfo.pixelData.Reset();
+ Devel::PixelBuffer pixelBuffer = textureInfo.pixelBuffer;
+ textureInfo.pixelBuffer.Reset();
if( maskTextureInfo.loadState == LOAD_FINISHED )
{
- ApplyMask( pixelData, maskTextureInfo.textureId );
- UploadTexture( pixelData, textureInfo );
+ ApplyMask( pixelBuffer, maskTextureInfo.textureId );
+ UploadTexture( pixelBuffer, textureInfo );
NotifyObservers( textureInfo, true );
}
else
}
}
-void TextureManager::ApplyMask( PixelData pixelData, TextureId maskTextureId )
+void TextureManager::ApplyMask( Devel::PixelBuffer& pixelBuffer, TextureId maskTextureId )
{
int maskCacheIndex = GetCacheIndexFromId( maskTextureId );
- PixelData maskPixelData = mTextureInfoContainer[maskCacheIndex].pixelData;
- Dali::ApplyMask( pixelData, maskPixelData );
+ Devel::PixelBuffer maskPixelBuffer = mTextureInfoContainer[maskCacheIndex].pixelBuffer;
+ pixelBuffer.ApplyMask( maskPixelBuffer );
}
-void TextureManager::UploadTexture( PixelData pixelData, TextureInfo& textureInfo )
+void TextureManager::UploadTexture( Devel::PixelBuffer& pixelBuffer, TextureInfo& textureInfo )
{
if( textureInfo.useAtlas != USE_ATLAS )
{
DALI_LOG_INFO( gTextureManagerLogFilter, Debug::Concise, " TextureManager::UploadTexture() New Texture for textureId:%d\n", textureInfo.textureId );
- Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
+ Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, pixelBuffer.GetPixelFormat(), pixelBuffer.GetWidth(), pixelBuffer.GetHeight() );
+ PixelData pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
texture.Upload( pixelData );
textureInfo.textureSet = TextureSet::New();
textureInfo.textureSet.SetTexture( 0u, texture );
for( unsigned int i = 0; i < count; ++i )
{
TextureInfo& textureInfo( mTextureInfoContainer[i] );
- for( TextureInfo::ObserverListType::Iterator j = textureInfo.observerList.Begin(); j != textureInfo.observerList.End(); ++j )
+ for( TextureInfo::ObserverListType::Iterator j = textureInfo.observerList.Begin(); j != textureInfo.observerList.End(); )
{
if( *j == observer )
{
- textureInfo.observerList.Erase( j );
- break;
+ j = textureInfo.observerList.Erase( j );
+ }
+ else
+ {
+ ++j;
}
}
}
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/rendering/texture-set.h>
#include <dali/devel-api/common/owner-container.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <deque>
// INTERNAL INCLUDES
};
/**
- * Whether the texture should be stored in CPU memory, or uploaded to a GPU texture
+ * Whether the pixel data should be kept in TextureManager, or uploaded for rendering
*/
enum StorageType
{
- CPU,
- GPU_UPLOAD
+ KEEP_PIXEL_BUFFER,
+ UPLOAD_TO_TEXTURE
};
/**
/**
* @brief Requests an image load of the given URL, when the texture has
- * have loaded, it will perform a CPU blend with the image mask, and upload
- * the blend texture.
+ * have loaded, it will perform a blend with the image mask, and upload
+ * the blended texture.
*
* The parameters are used to specify how the image is loaded.
* The observer has the UploadComplete method called when the load is ready.
void Remove( const TextureManager::TextureId textureId );
/**
+ * Get the visualUrl associated with the texture id
+ */
+ const VisualUrl& GetVisualUrl( TextureId textureId );
+
+ /**
* @brief Get the current state of a texture
* @param[in] textureId The texture id to query
* @return The loading state if the texture is valid, or NOT_STARTED if the textureId
* This is called when an image load completes (or fails).
* @return A TextureId to use as a handle to reference this Texture
*/
- TextureId RequestInternalLoad(
+ TextureId RequestLoadInternal(
const VisualUrl& url,
TextureId maskTextureId,
const ImageDimensions desiredSize,
loadState( NOT_STARTED ),
fittingMode( fittingMode ),
samplingMode( samplingMode ),
- storageType( GPU_UPLOAD ),
+ storageType( UPLOAD_TO_TEXTURE ),
loadSynchronously( loadSynchronously ),
useAtlas( useAtlas )
{
ObserverListType observerList; ///< Container used to store all observer clients of this Texture
Toolkit::ImageAtlas atlas; ///< The atlas this Texture lays within (if any)
- PixelData pixelData; ///< The PixelData holding the image data (this is used if atlasing is deferred or CPU storage is required)
+ Devel::PixelBuffer pixelBuffer;///< The PixelBuffer holding the image data (May be empty after upload)
TextureSet textureSet; ///< The TextureSet holding the Texture
VisualUrl url; ///< The URL of the image
ImageDimensions desiredSize; ///< The size requested
/**
* @brief This signal handler is called when the async local loader finishes loading.
* @param[in] id This is the async image loaders Id
- * @param[in] pixelData The loaded image data
+ * @param[in] pixelBuffer The loaded image data
*/
- void AsyncLocalLoadComplete( uint32_t id, PixelData pixelData );
+ void AsyncLocalLoadComplete( uint32_t id, Devel::PixelBuffer pixelBuffer );
/**
* @brief This signal handler is called when the async local loader finishes loading.
* @param[in] id This is the async image loaders Id
- * @param[in] pixelData The loaded image data
+ * @param[in] pixelBuffer The loaded image data
*/
- void AsyncRemoteLoadComplete( uint32_t id, PixelData pixelData );
+ void AsyncRemoteLoadComplete( uint32_t id, Devel::PixelBuffer pixelBuffer );
/**
* Common method to handle loading completion
* @param[in] container The Async loading container
* @param[in] id This is the async image loaders Id
- * @param[in] pixelData The loaded image data
+ * @param[in] pixelBuffer The loaded image data
*/
- void AsyncLoadComplete( AsyncLoadingInfoContainerType& container, uint32_t id, PixelData pixelData );
+ void AsyncLoadComplete( AsyncLoadingInfoContainerType& container, uint32_t id, Devel::PixelBuffer pixelBuffer );
/**
* @brief Performs Post-Load steps including atlasing.
* @param[in] textureInfo The struct associated with this Texture
- * @param[in] pixelData The image pixelData
+ * @param[in] pixelBuffer The image pixelBuffer
* @return True if successful
*/
- void PostLoad( TextureManager::TextureInfo& textureInfo, PixelData pixelData );
+ void PostLoad( TextureManager::TextureInfo& textureInfo, Devel::PixelBuffer& pixelBuffer );
/**
* Check if there is a texture waiting to be masked. If there
void CheckForWaitingTexture( TextureInfo& maskTextureInfo );
/**
- * Apply the mask texture to the image texture.
- * @param[in] pixelData The image pixelData to apply the mask to
+ * Apply the mask to the pixelBuffer.
+ * @param[in] pixelBuffer The pixelBuffer to apply the mask to
* @param[in] maskTextureId The texture id of the mask.
*/
- void ApplyMask( PixelData pixelData, TextureId maskTextureId );
+ void ApplyMask( Devel::PixelBuffer& pixelBuffer, TextureId maskTextureId );
/**
- * Upload the texture specified in pixelData to the appropriate location
- * @param[in] pixelData The image data to upload
+ * Upload the texture specified in pixelBuffer to the appropriate location
+ * @param[in] pixelBuffer The image data to upload
* @param[in] textureInfo The texture info containing the location to
* store the data to.
*/
- void UploadTexture( PixelData pixelData, TextureInfo& textureInfo );
+ void UploadTexture( Devel::PixelBuffer& pixelBuffer, TextureInfo& textureInfo );
/**
* Mark the texture as complete, and inform observers
TEXT_COLOR, ///< name "textColor", The text color, type VECTOR4 @SINCE_1_1.37
FONT_FAMILY, ///< name "fontFamily", The requested font family, type STRING @SINCE_1_1.37
FONT_STYLE, ///< name "fontStyle", The requested font style, type STRING or MAP @SINCE_1_2.13
- POINT_SIZE, ///< name "pointSize", The size of font in points, type FLOAT @SINCE_1_1.37
+ POINT_SIZE, ///< name "pointSize", The size of font in points (Conversion from Pixel size to Point size : Point size = Pixel size * 72 / DPI), type FLOAT @SINCE_1_1.37
HORIZONTAL_ALIGNMENT, ///< name "horizontalAlignment", The text horizontal alignment, type STRING, values "BEGIN", "CENTER", "END" @SINCE_1_1.37
SCROLL_THRESHOLD, ///< name "scrollThreshold" Vertical scrolling will occur if the cursor is this close to the control border, type FLOAT @SINCE_1_1.37
SCROLL_SPEED, ///< name "scrollSpeed" The scroll speed in pixels per second, type FLOAT @SINCE_1_1.37
PLACEHOLDER_TEXT_FOCUSED, ///< name "placeholderTextFocused", The text to display when the TextField is empty with key-input focus, type STRING @SINCE_1_0.0
FONT_FAMILY, ///< name "fontFamily", The requested font family, type STRING @SINCE_1_0.0
FONT_STYLE, ///< name "fontStyle", The requested font style, type STRING or MAP @SINCE_1_2.13
- POINT_SIZE, ///< name "pointSize", The size of font in points, type FLOAT @SINCE_1_0.0
+ POINT_SIZE, ///< name "pointSize", The size of font in points (Conversion from Pixel size to Point size : Point size = Pixel size * 72 / DPI), type FLOAT @SINCE_1_0.0
MAX_LENGTH, ///< name "maxLength" The maximum number of characters that can be inserted, type INTEGER @SINCE_1_0.0
EXCEED_POLICY, ///< name "exceedPolicy" Specifies how the text is truncated when it does not fit, type INTEGER @SINCE_1_0.0
HORIZONTAL_ALIGNMENT, ///< name "horizontalAlignment", The line horizontal alignment, type STRING, values "BEGIN", "CENTER", "END" @SINCE_1_0.0
/**
* @brief The size of font in points.
+ *
+ * Conversion from Pixel size to Point size :
+ * Point size = Pixel size * 72 / DPI
* @details name "pointSize", type FLOAT.
* @SINCE_1_0.0
*/
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 44;
+const unsigned int TOOLKIT_MICRO_VERSION = 46;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
bool orientationCorrection )
{
// Load the image synchronously (block the thread here).
- return Dali::LoadImageFromFile( url, dimensions, fittingMode, samplingMode, orientationCorrection );
+ Devel::PixelBuffer pixelBuffer = Dali::LoadImageFromFile( url, dimensions, fittingMode, samplingMode, orientationCorrection );
+ if( pixelBuffer )
+ {
+ return Devel::PixelBuffer::Convert( pixelBuffer );
+ }
+ return Dali::PixelData(); // return empty handle
}
//******************************************************************************
{
+ "config":
+ {
+ "alwaysShowFocus":false
+ },
"styles":
{
"Tooltip":
"selectionHighlightColor":[0.75,0.96,1.0,1.0],
"grabHandleImage" : "{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png",
"selectionHandleImageLeft" : {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png" },
- "selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" }
+ "selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" },
+ "enableSelection":false
},
"TextFieldFontSize0":
"selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" },
"enableScrollBar":true,
"scrollBarShowDuration":0.8,
- "scrollBarFadeDuration":0.5
+ "scrollBarFadeDuration":0.5,
+ "enableSelection":false
},
"ProgressBar":
{
//******************************************************************************
{
+ "config":
+ {
+ "alwaysShowFocus":false
+ },
"styles":
{
"Tooltip":
"selectionHighlightColor":[0.75,0.96,1.0,1.0],
"grabHandleImage" : "{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png",
"selectionHandleImageLeft" : {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png" },
- "selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" }
+ "selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" },
+ "enableSelection":true
},
"TextFieldFontSize0":
"selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" },
"enableScrollBar":true,
"scrollBarShowDuration":0.8,
- "scrollBarFadeDuration":0.5
+ "scrollBarFadeDuration":0.5,
+ "enableSelection":true
},
"Popup":
{
//******************************************************************************
{
+ "config":
+ {
+ "alwaysShowFocus":false
+ },
"styles":
{
"TextLabel":
"selectionHighlightColor":[0.75,0.96,1.0,1.0],
"grabHandleImage" : "{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png",
"selectionHandleImageLeft" : {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png" },
- "selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" }
+ "selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" },
+ "enableSelection":true
},
"TextFieldFontSize0":
"selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" },
"enableScrollBar":true,
"scrollBarShowDuration":0.8,
- "scrollBarFadeDuration":0.5
+ "scrollBarFadeDuration":0.5,
+ "enableSelection":true
},
"Popup":
{
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.2.44
+Version: 1.2.46
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT