{
InstallLogFunction(TestLogFunction);
DefaultErrorCallback("Hello world!");
- DALI_TEST_EQUAL(std::string(sBuffer), "2: DefaultErrorCallback Hello world!");
+ DALI_TEST_EQUAL(std::string(sBuffer), "2: string-callback.cpp: DefaultErrorCallback(26) > Hello world!");
END_TEST;
}
public:
CanvasRenderer( const Vector2& size )
: mDrawable(nullptr),
- mPixelBuffer( Devel::PixelBuffer::New(size.width, size.height, Dali::Pixel::RGBA8888) ),
+ mTexture ( Dali::Texture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGBA8888, size.width, size.height ) ),
mSize(size),
mViewBox(size)
{
return true;
}
+ Dali::Texture GetRasterizedTexture()
+ {
+ return mTexture;
+ }
+
bool Rasterize()
{
return true;
return false;
}
- Devel::PixelBuffer GetPixelBuffer()
- {
- return mPixelBuffer;
- }
-
-
bool SetSize(Vector2 size)
{
mSize = size;
public:
Dali::CanvasRenderer::Drawable* mDrawable;
- Devel::PixelBuffer mPixelBuffer;
+ Dali::Texture mTexture;
Vector2 mSize;
Vector2 mViewBox;
};
return Internal::Adaptor::GetImplementation(*this).Rasterize();
}
-Devel::PixelBuffer CanvasRenderer::GetPixelBuffer()
+Dali::Texture CanvasRenderer::GetRasterizedTexture()
{
- return Internal::Adaptor::GetImplementation(*this).GetPixelBuffer();
+ return Internal::Adaptor::GetImplementation(*this).GetRasterizedTexture();
}
bool CanvasRenderer::AddDrawable(Dali::CanvasRenderer::Drawable& drawable)
END_TEST;
}
-int UtcDaliCanvasViewRasterizeTaskGetBufferSizeP(void)
-{
- ToolkitTestApplication application;
-
- Dali::Toolkit::Internal::CanvasView* dummyInternalCanvasView = new Dali::Toolkit::Internal::CanvasView(Vector2(100,100));
- DALI_TEST_CHECK( dummyInternalCanvasView );
-
- Dali::CanvasRenderer dummyCanvasRenderer = Dali::CanvasRenderer::New(Vector2(100, 100));
- DALI_TEST_CHECK( dummyCanvasRenderer );
-
- IntrusivePtr<Dali::Toolkit::Internal::CanvasRendererRasterizingTask> task = new Dali::Toolkit::Internal::CanvasRendererRasterizingTask(dummyInternalCanvasView, dummyCanvasRenderer);
- DALI_TEST_CHECK( task );
-
- //There is no rasterized buffer.
- DALI_TEST_EQUALS( task->GetBufferSize(), Vector2(0, 0), TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliCanvasViewRasterizeTaskGetPixelDataP(void)
-{
-
- Dali::Toolkit::Internal::CanvasView* dummyInternalCanvasView = new Dali::Toolkit::Internal::CanvasView(Vector2(100,100));
- DALI_TEST_CHECK( dummyInternalCanvasView );
-
- Dali::CanvasRenderer dummyCanvasRenderer = Dali::CanvasRenderer::New(Vector2(100, 100));
- DALI_TEST_CHECK( dummyCanvasRenderer );
-
- IntrusivePtr<Dali::Toolkit::Internal::CanvasRendererRasterizingTask> task = new Dali::Toolkit::Internal::CanvasRendererRasterizingTask(dummyInternalCanvasView, dummyCanvasRenderer);
- DALI_TEST_CHECK( task );
-
- DALI_TEST_EQUALS( task->GetPixelData(), PixelData(), TEST_LOCATION );
-
- END_TEST;
-}
-
int UtcDaliCanvasViewRasterizeThreadP(void)
{
ToolkitTestApplication application;
{
ToolkitTestApplication application;
- Dali::Toolkit::Internal::CanvasView* dummyInternalCanvasView = new Dali::Toolkit::Internal::CanvasView(Vector2(100,100));
- DALI_TEST_CHECK( dummyInternalCanvasView );
+ Dali::Toolkit::CanvasView canvasView = Dali::Toolkit::CanvasView::New(Vector2(100, 100));
+ Dali::Toolkit::Internal::CanvasView& dummyInternalCanvasView = GetImpl(canvasView);
Dali::CanvasRenderer dummyCanvasRenderer = Dali::CanvasRenderer::New(Vector2(100, 100));
DALI_TEST_CHECK( dummyCanvasRenderer );
- IntrusivePtr<Dali::Toolkit::Internal::CanvasRendererRasterizingTask> task = new Dali::Toolkit::Internal::CanvasRendererRasterizingTask(dummyInternalCanvasView, dummyCanvasRenderer);
+ IntrusivePtr<Dali::Toolkit::Internal::CanvasRendererRasterizingTask> task = new Dali::Toolkit::Internal::CanvasRendererRasterizingTask(&dummyInternalCanvasView, dummyCanvasRenderer);
DALI_TEST_CHECK( task );
Dali::Toolkit::Internal::CanvasViewRasterizeThread *dummyThread = new Dali::Toolkit::Internal::CanvasViewRasterizeThread();
dummyThread->Process(false);
- PixelData pixelData = CreatePixelData( 100, 100 );
+ auto texture = Texture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGBA8888, 100, 100 );
- dummyThread->RasterizationCompletedSignal().Connect(dummyInternalCanvasView, &Dali::Toolkit::Internal::CanvasView::ApplyRasterizedImage);
- dummyThread->RasterizationCompletedSignal().Emit(pixelData);
+ dummyThread->RasterizationCompletedSignal().Connect(&dummyInternalCanvasView, &Dali::Toolkit::Internal::CanvasView::ApplyRasterizedImage);
+ dummyThread->RasterizationCompletedSignal().Emit(texture);
application.SendNotification();
application.Render();
application.SendNotification();
application.Render(20);
- Transition transition = Transition::New(control1, control2, TimePeriod(-0.1f, -0.1f));
+ Transition transition = Transition::New(control1, control2, true, TimePeriod(-0.1f, -0.1f));
TimePeriod timePeriod = transition.GetTimePeriod();
DALI_TEST_EQUALS(0.0f, timePeriod.durationSeconds, TEST_LOCATION);
DALI_TEST_EQUALS(0.0f, timePeriod.delaySeconds, TEST_LOCATION);
application.SendNotification();
application.Render(20);
- Transition transition = Transition::New(control1, control2, TimePeriod(-0.1f));
+ Transition transition = Transition::New(control1, control2, true, TimePeriod(-0.1f));
TimePeriod timePeriod = transition.GetTimePeriod();
DALI_TEST_EQUALS(0.0f, timePeriod.durationSeconds, TEST_LOCATION);
DALI_TEST_EQUALS(0.0f, timePeriod.delaySeconds, TEST_LOCATION);
application.SendNotification();
application.Render(20);
- Transition transition = Transition::New(control1, control2, TimePeriod(0.5f));
+ Transition transition = Transition::New(control1, control2, true, TimePeriod(0.5f));
TransitionSet transitionSet = TransitionSet::New();
transitionSet.AddTransition(transition);
transitionSet.Play();
END_TEST;
}
+int UtcDaliTransitionBetweenControlPair2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTransitionBetweenControlPair2 - source target will be transitioned.");
+
+ Vector3 sourcePosition(100, 200, 0);
+ Vector3 sourceSize(150, 150, 0);
+ Vector3 sourceScale(1, 2, 0);
+ Vector4 sourceColor(1.0f, 1.0f, 1.0f, 0.5f);
+ float sourceOpacity(0.5f);
+ float sourceRadius(30.f);
+ float sourceBorderlineWidth(60.0f);
+ Vector4 sourceBorderlineColor(1.0f, 0.0f, 0.0f, 1.0f);
+ float sourceBorderlineOffset(1.f);
+ Vector4 sourceRadiusV4 = Vector4(sourceRadius, sourceRadius, sourceRadius, sourceRadius);
+
+ Vector3 destinationPosition(50, 50, 0);
+ Vector3 destinationSize(120, 120, 0);
+ Vector3 destinationScale(2, 1, 0);
+ Vector4 destinationColor(1.0f, 0.5f, 1.0f, 0.8f);
+ float destinationOpacity(0.8f);
+ float destinationRadius(50.f);
+ float destinationBorderlineWidth(80.0f);
+ Vector4 destinationBorderlineColor(0.5f, 1.0f, 0.5f, 0.3f);
+ float destinationBorderlineOffset(-1.0f);
+ Vector4 destinationRadiusV4 = Vector4(destinationRadius, destinationRadius, destinationRadius, destinationRadius);
+
+ Control control1 = Control::New();
+ control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ control1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ control1.SetProperty(Actor::Property::POSITION, sourcePosition);
+ control1.SetProperty(Actor::Property::SIZE, sourceSize);
+ control1.SetProperty(Actor::Property::SCALE, sourceScale);
+ control1.SetProperty(Actor::Property::COLOR, sourceColor);
+ control1.SetProperty(Actor::Property::OPACITY, sourceOpacity);
+ Property::Map controlProperty1;
+ controlProperty1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
+ controlProperty1.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
+ controlProperty1.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, sourceRadius);
+ controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, sourceBorderlineWidth);
+ controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, sourceBorderlineColor);
+ controlProperty1.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, sourceBorderlineOffset);
+ control1.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty1);
+
+ Control control2 = Control::New();
+ control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ control2.SetProperty(Actor::Property::ANCHOR_POINT, ParentOrigin::CENTER);
+ control2.SetProperty(Actor::Property::POSITION, destinationPosition);
+ control2.SetProperty(Actor::Property::SIZE, destinationSize);
+ control2.SetProperty(Actor::Property::SCALE, destinationScale);
+ control2.SetProperty(Actor::Property::COLOR, destinationColor);
+ control2.SetProperty(Actor::Property::OPACITY, destinationOpacity);
+ Property::Map controlProperty2;
+ controlProperty2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
+ controlProperty2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 1.0f, 0.0f, 0.5f));
+ controlProperty2.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, destinationRadius);
+ controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, destinationBorderlineWidth);
+ controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, destinationBorderlineColor);
+ controlProperty2.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, destinationBorderlineOffset);
+ control2.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty2);
+
+ DALI_TEST_EQUALS(destinationPosition, control2.GetProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
+ Property::Map backgroundMap = control2.GetProperty<Property::Map>(Toolkit::Control::Property::BACKGROUND);
+ Vector4 cornerRadius = backgroundMap.Find(Toolkit::DevelVisual::Property::CORNER_RADIUS)->Get<Vector4>();
+ DALI_TEST_EQUALS(destinationRadiusV4, cornerRadius, TEST_LOCATION);
+ float borderlineWidth = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH)->Get<float>();
+ DALI_TEST_EQUALS(destinationBorderlineWidth, borderlineWidth, TEST_LOCATION);
+ Vector4 borderlineColor = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_COLOR)->Get<Vector4>();
+ DALI_TEST_EQUALS(destinationBorderlineColor, borderlineColor, TEST_LOCATION);
+ float borderlineOffset = backgroundMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET)->Get<float>();
+ DALI_TEST_EQUALS(destinationBorderlineOffset, borderlineOffset, TEST_LOCATION);
+
+ application.GetScene().Add(control1);
+ application.GetScene().Add(control2);
+
+ application.SendNotification();
+ application.Render(20);
+
+ Transition transition = Transition::New(control1, control2, false, TimePeriod(0.5f));
+ TransitionSet transitionSet = TransitionSet::New();
+ transitionSet.AddTransition(transition);
+ transitionSet.Play();
+
+ bool signalReceived(false);
+ TransitionFinishCheck finishCheck(signalReceived);
+ transitionSet.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(50);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+
+ DALI_TEST_NOT_EQUALS(destinationPosition, control1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.00001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(1, control1.GetRendererCount(), TEST_LOCATION);
+
+ Dali::Renderer renderer = control1.GetRendererAt(0);
+ Property::Index index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
+ cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
+ DALI_TEST_NOT_EQUALS(destinationRadiusV4, cornerRadius, 0.00001f, TEST_LOCATION);
+
+ index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
+ borderlineWidth = renderer.GetCurrentProperty<float>(index);
+ DALI_TEST_NOT_EQUALS(destinationBorderlineWidth, borderlineWidth, 0.00001f, TEST_LOCATION);
+
+ index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
+ borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
+ DALI_TEST_NOT_EQUALS(destinationBorderlineColor, borderlineColor, 0.00001f, TEST_LOCATION);
+
+ index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
+ borderlineOffset = renderer.GetCurrentProperty<float>(index);
+ DALI_TEST_NOT_EQUALS(destinationBorderlineOffset, borderlineOffset, 0.00001f, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(700);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+
+ // After the transition is finished,
+ // every current and renderer propeties of control1 are equal to destination properties.
+ DALI_TEST_EQUALS(destinationPosition, control1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
+ DALI_TEST_EQUALS(destinationSize, control1.GetCurrentProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
+ DALI_TEST_EQUALS(destinationScale, control1.GetCurrentProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
+ DALI_TEST_EQUALS(destinationColor, control1.GetCurrentProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
+ DALI_TEST_EQUALS(destinationOpacity, control1.GetCurrentProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
+
+ DALI_TEST_EQUALS(1, control1.GetRendererCount(), TEST_LOCATION);
+ renderer = control1.GetRendererAt(0);
+ index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
+ cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
+ DALI_TEST_EQUALS(destinationRadiusV4, cornerRadius, TEST_LOCATION);
+
+ index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
+ borderlineWidth = renderer.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(destinationBorderlineWidth, borderlineWidth, TEST_LOCATION);
+
+ index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
+ borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
+ DALI_TEST_EQUALS(destinationBorderlineColor, borderlineColor, TEST_LOCATION);
+
+ index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
+ borderlineOffset = renderer.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(destinationBorderlineOffset, borderlineOffset, TEST_LOCATION);
+
+ // every actor properties of control1 are returned to the source properties.
+ DALI_TEST_EQUALS(sourcePosition, control1.GetProperty<Vector3>(Actor::Property::POSITION), TEST_LOCATION);
+ DALI_TEST_EQUALS(sourceSize, control1.GetProperty<Vector3>(Actor::Property::SIZE), TEST_LOCATION);
+ DALI_TEST_EQUALS(sourceScale, control1.GetProperty<Vector3>(Actor::Property::SCALE), TEST_LOCATION);
+ DALI_TEST_EQUALS(sourceColor, control1.GetProperty<Vector4>(Actor::Property::COLOR), TEST_LOCATION);
+ DALI_TEST_EQUALS(sourceOpacity, control1.GetProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(20);
+
+ // after next update, renderer properties are returned to the source properties.
+ DALI_TEST_EQUALS(1, control1.GetRendererCount(), TEST_LOCATION);
+ renderer = control1.GetRendererAt(0);
+ index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
+ cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
+ DALI_TEST_EQUALS(sourceRadiusV4, cornerRadius, TEST_LOCATION);
+
+ index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
+ borderlineWidth = renderer.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(sourceBorderlineWidth, borderlineWidth, TEST_LOCATION);
+
+ index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
+ borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
+ DALI_TEST_EQUALS(sourceBorderlineColor, borderlineColor, TEST_LOCATION);
+
+ index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
+ borderlineOffset = renderer.GetCurrentProperty<float>(index);
+ DALI_TEST_EQUALS(sourceBorderlineOffset, borderlineOffset, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliTransitionBetweenControlPairWithoutEmptySourceBackground(void)
{
ToolkitTestApplication application;
application.SendNotification();
application.Render(20);
- Transition transition = Transition::New(control1, control2, TimePeriod(0.5f));
+ Transition transition = Transition::New(control1, control2, true, TimePeriod(0.5f));
TransitionSet transitionSet = TransitionSet::New();
transitionSet.AddTransition(transition);
transitionSet.Play();
Vector3 startWorldPosition = control1.GetProperty<Vector3>(Actor::Property::WORLD_POSITION);
Vector3 finishWorldPosition = control2.GetProperty<Vector3>(Actor::Property::WORLD_POSITION);
- Transition transition = Transition::New(control1, control2, TimePeriod(0.5f));
+ Transition transition = Transition::New(control1, control2, true, TimePeriod(0.5f));
TransitionSet transitionSet = TransitionSet::New();
transitionSet.AddTransition(transition);
transitionSet.Play();
Vector3 startWorldPosition = control1.GetProperty<Vector3>(Actor::Property::WORLD_POSITION);
Vector3 finishWorldPosition = control2.GetProperty<Vector3>(Actor::Property::WORLD_POSITION);
- Transition transition = Transition::New(control1, control2, TimePeriod(0.5f, 0.5f));
+ Transition transition = Transition::New(control1, control2, true, TimePeriod(0.5f, 0.5f));
TransitionSet transitionSet = TransitionSet::New();
transitionSet.AddTransition(transition);
transitionSet.Play();
application.SendNotification();
application.Render(20);
- Transition transition = Transition::New(control1, control2, TimePeriod(0.5f));
+ Transition transition = Transition::New(control1, control2, true, TimePeriod(0.5f));
TransitionSet transitionSet = TransitionSet::New();
transitionSet.AddTransition(transition);
transitionSet.Play();
application.SendNotification();
application.Render(20);
- Transition transition = Transition::New(control1, control2, TimePeriod(0.5f));
+ Transition transition = Transition::New(control1, control2, true, TimePeriod(0.5f));
transition.TransitionWithChild(true);
TransitionSet transitionSet = TransitionSet::New();
transitionSet.AddTransition(transition);
control3.SetProperty(Actor::Property::INHERIT_ORIENTATION, true);
control3.SetProperty(Actor::Property::INHERIT_SCALE, true);
- transition = Transition::New(control1, control3, TimePeriod(0.5f));
+ transition = Transition::New(control1, control3, true, TimePeriod(0.5f));
transitionSet = TransitionSet::New();
transitionSet.AddTransition(transition);
transitionSet.Play();
bool signalReceived(false);
TransitionFinishCheck finishCheck(signalReceived);
- transition = Transition::New(control1, control3, TimePeriod(0.5f));
+ transition = Transition::New(control1, control3, true, TimePeriod(0.5f));
transitionSet = TransitionSet::New();
transitionSet.AddTransition(transition);
transitionSet.Play();
bool signalReceived(false);
TransitionFinishCheck finishCheck(signalReceived);
- transition = Transition::New(control1, control3, TimePeriod(0.5f));
+ transition = Transition::New(control1, control3, true, TimePeriod(0.5f));
transitionSet = TransitionSet::New();
transitionSet.AddTransition(transition);
transitionSet.Play();
return controlDataImpl.GetVisualProperty(index, visualPropertyKey);
}
-void CreateTransitions(Control control, Dali::Animation& animation, Dali::Toolkit::Control source, AlphaFunction alphaFunction, TimePeriod timePeriod)
-{
- if(animation)
- {
- // make visual transition of control visual.
- Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control);
- Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(internalControl);
- controlDataImpl.MakeVisualTransition(animation, source, Toolkit::Control::Property::BACKGROUND, alphaFunction, timePeriod);
- controlDataImpl.MakeVisualTransition(animation, source, Toolkit::DevelControl::Property::SHADOW, alphaFunction, timePeriod);
- internalControl.OnCreateTransitions(animation, source, alphaFunction, timePeriod);
- }
-}
-
static Toolkit::Internal::Control::Impl* GetControlImplementation(Dali::Actor actor)
{
Dali::Toolkit::Control control = Toolkit::Control::DownCast(actor);
DALI_TOOLKIT_API Dali::Property GetVisualProperty(Control control, Dali::Property::Index index, Dali::Property::Key visualPropertyKey);
/**
- * @brief Retrieve visual/renderer property animation between this Control and source control.
- * Input animation must be created before this method called.
- * And the animations between this method created are added the input animation.
- * This method generates visual/renderer property animation but not creates Actor property animation.
- *
- * @param[in] control The control
- * @param[in] animation generated animation
- * @param[in] source source control of the animation.
- * @param[in] alphaFunction AlphaFunction of the animation
- * @param[in] timePeriod TimePeriod of the animation
- */
-DALI_TOOLKIT_API void CreateTransitions(Control control, Dali::Animation& animation, Dali::Toolkit::Control source, AlphaFunction alphaFunction, TimePeriod timePeriod);
-
-/**
* @brief The signal is emmited as a succession of "activate" signal send by accessibility client.
* @return The signal to connect to
*/
}
}
-void CanvasView::ApplyRasterizedImage(PixelData rasterizedPixelData)
+void CanvasView::ApplyRasterizedImage(Texture rasterizedTexture)
{
- if(rasterizedPixelData)
+ if (rasterizedTexture && rasterizedTexture.GetWidth() != 0 && rasterizedTexture.GetHeight() != 0)
{
- auto rasterizedPixelDataWidth = rasterizedPixelData.GetWidth();
- auto rasterizedPixelDataHeight = rasterizedPixelData.GetHeight();
-
- if(rasterizedPixelDataWidth > 0 && rasterizedPixelDataHeight > 0)
+ if(!mTextureSet)
{
- if(!mTexture || mTexture.GetWidth() != rasterizedPixelDataWidth || mTexture.GetHeight() != rasterizedPixelDataHeight)
- {
- mTexture = Texture::New(TextureType::TEXTURE_2D, rasterizedPixelData.GetPixelFormat(), rasterizedPixelDataWidth, rasterizedPixelDataHeight);
- mTexture.Upload(rasterizedPixelData);
-
- if(!mTextureSet)
- {
- mTextureSet = TextureSet::New();
- Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
- Shader shader = Shader::New(SHADER_CANVAS_VIEW_VERT, SHADER_CANVAS_VIEW_FRAG);
- Renderer renderer = Renderer::New(geometry, shader);
- renderer.SetTextures(mTextureSet);
- renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
-
- Actor actor = Self();
- if(actor)
- {
- actor.AddRenderer(renderer);
- }
- }
- mTextureSet.SetTexture(0, mTexture);
- }
- else
- {
- //Update texture
- mTexture.Upload(rasterizedPixelData);
- }
+ mTextureSet = TextureSet::New();
+ Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
+ Shader shader = Shader::New(SHADER_CANVAS_VIEW_VERT, SHADER_CANVAS_VIEW_FRAG);
+ Renderer renderer = Renderer::New(geometry, shader);
+ renderer.SetTextures(mTextureSet);
+ renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
+ Self().AddRenderer(renderer);
}
+ mTextureSet.SetTexture(0, rasterizedTexture);
}
//If there are accumulated changes to CanvasRenderer during Rasterize, Rasterize once again.
/**
* @bried Apply the rasterized image to the canvas view
*
- * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
+ * @param[in] rasterizedTexture The texture with the rasterized pixels
*/
- void ApplyRasterizedImage(PixelData rasterizedPixelData);
+ void ApplyRasterizedImage(Texture rasterizedTexture);
private:
CanvasView(const CanvasView&) = delete;
CanvasRendererRasterizingTask::CanvasRendererRasterizingTask(CanvasView* canvasView, CanvasRenderer canvasRenderer)
: mCanvasView(canvasView),
mCanvasRenderer(canvasRenderer),
- mPixelData(PixelData()),
- mBufferSize(0, 0)
+ mRasterizedTexture()
{
}
{
if(mCanvasRenderer && mCanvasRenderer.Rasterize())
{
- Devel::PixelBuffer pixbuf = mCanvasRenderer.GetPixelBuffer();
- auto width = pixbuf.GetWidth();
- auto height = pixbuf.GetHeight();
- if(width > 0 && height > 0)
- {
- mBufferSize.width = width;
- mBufferSize.height = height;
-
- mPixelData = Devel::PixelBuffer::Convert(pixbuf);
- return true;
- }
+ return true;
}
return false;
}
return mCanvasView.Get();
}
-PixelData CanvasRendererRasterizingTask::GetPixelData() const
-{
- return mPixelData;
-}
-
-Vector2 CanvasRendererRasterizingTask::GetBufferSize() const
+Texture CanvasRendererRasterizingTask::GetRasterizedTexture()
{
- return mBufferSize;
+ return mCanvasRenderer.GetRasterizedTexture();
}
CanvasViewRasterizeThread::CanvasViewRasterizeThread()
{
while(CanvasRendererRasterizingTaskPtr task = NextCompletedTask())
{
- RasterizationCompletedSignal().Emit(task->GetPixelData());
+ RasterizationCompletedSignal().Emit(task->GetRasterizedTexture()); // Here texture get
}
UnregisterProcessor();
#include <dali/devel-api/threading/thread.h>
#include <dali/integration-api/adaptor-framework/log-factory-interface.h>
#include <dali/public-api/common/intrusive-ptr.h>
-#include <dali/public-api/images/pixel-data.h>
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/rendering/texture-set.h>
#include <memory>
/**
* Get the rasterization result.
- * @return The pixel data with the rasterized pixels.
+ * @return The texture with the rasterized pixels.
*/
- PixelData GetPixelData() const;
-
- /**
- * Get size of rasterization result.
- * @return The size of the pixel data.
- */
- Vector2 GetBufferSize() const;
+ Texture GetRasterizedTexture();
private:
// Undefined
private:
CanvasViewPtr mCanvasView;
CanvasRenderer mCanvasRenderer;
- PixelData mPixelData;
- Vector2 mBufferSize;
+ Texture mRasterizedTexture;
};
/**
{
public:
/// @brief ApplyRasterizedImage Event signal type
- using RasterizationCompletedSignalType = Signal<void(PixelData)>;
+ using RasterizationCompletedSignalType = Signal<void(Texture)>;
public:
/**
#include <limits>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
#include <dali-toolkit/devel-api/asset-manager/asset-manager.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
return Dali::Property(handle, Property::INVALID_INDEX);
}
-void Control::Impl::MakeVisualTransition(Dali::Animation& animation, Dali::Toolkit::Control source, Dali::Property::Index visualIndex, AlphaFunction alphaFunction, TimePeriod timePeriod)
+void Control::Impl::CreateTransitions(std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& sourceProperties,
+ std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& destinationProperties,
+ Dali::Toolkit::Control source, Dali::Toolkit::Control destination)
{
- Dali::Toolkit::Control sourceHandle = Dali::Toolkit::Control::DownCast(source);
- Property::Map sourceMap = sourceHandle.GetProperty<Property::Map>(visualIndex);
- Dali::Toolkit::Control destinationHandle = Dali::Toolkit::Control::DownCast(mControlImpl.Self());
- Property::Map destinationMap = destinationHandle.GetProperty<Property::Map>(visualIndex);
-
- Vector4 mixColor(1.0f, 1.0f, 1.0f, 1.0f);
- Vector4 cornerRadius(0.0f, 0.0f, 0.0f, 0.0f);
- float borderlineWidth(0.0f);
- Vector4 borderlineColor(0.0f, 0.0f, 0.0f, 1.0f);
- float borderlineOffset(0.0f);
-
- if(!destinationMap.Empty())
+ // Retrieves background properties to be transitioned.
+ Dali::Property::Map backgroundSourcePropertyMap, backgroundDestinationPropertyMap;
+ mControlImpl.MakeVisualTransition(backgroundSourcePropertyMap, backgroundDestinationPropertyMap, source, destination, Toolkit::Control::Property::BACKGROUND);
+ if(backgroundSourcePropertyMap.Count() > 0)
{
- static auto findValueVector4 = [](const Property::Map& map, Property::Index index, const Vector4& defaultValue = Vector4()) -> Vector4 {
- Property::Value* propertyValue = map.Find(index);
- if(propertyValue)
- {
- return propertyValue->Get<Vector4>();
- }
- return defaultValue;
- };
-
- static auto findValueFloat = [](const Property::Map& map, Property::Index index, const float& defaultValue = 0.0f) -> float {
- Property::Value* propertyValue = map.Find(index);
- if(propertyValue)
- {
- return propertyValue->Get<float>();
- }
- return defaultValue;
- };
-
- mixColor = findValueVector4(destinationMap, Dali::Toolkit::Visual::Property::MIX_COLOR, mixColor);
- cornerRadius = findValueVector4(destinationMap, Toolkit::DevelVisual::Property::CORNER_RADIUS, cornerRadius);
- borderlineWidth = findValueFloat(destinationMap, Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth);
- borderlineColor = findValueVector4(destinationMap, Toolkit::DevelVisual::Property::BORDERLINE_COLOR, borderlineColor);
- borderlineOffset = findValueFloat(destinationMap, Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset);
-
- if(sourceMap.Empty())
- {
- sourceMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
- sourceMap.Insert(Dali::Toolkit::Visual::Property::MIX_COLOR, Color::TRANSPARENT);
- sourceMap.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, cornerRadius);
- sourceMap.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth);
- sourceMap.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, borderlineColor);
- sourceMap.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset);
- }
-
- Vector4 sourceMixColor = findValueVector4(sourceMap, Dali::Toolkit::Visual::Property::MIX_COLOR, mixColor);
- Vector4 sourceCornerRadius = findValueVector4(sourceMap, Toolkit::DevelVisual::Property::CORNER_RADIUS, cornerRadius);
- float sourceBorderlineWidth = findValueFloat(sourceMap, Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth);
- Vector4 sourceBorderlineColor = findValueVector4(sourceMap, Toolkit::DevelVisual::Property::BORDERLINE_COLOR, borderlineColor);
- float sourceBorderlineOffset = findValueFloat(sourceMap, Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset);
-
- std::vector<Dali::Property> properties;
- std::vector<std::pair<Property::Value, Property::Value>> values;
-
- if(Vector3(sourceMixColor) != Vector3(mixColor))
- {
- properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::Visual::Property::MIX_COLOR));
- values.push_back(std::make_pair(Vector3(sourceMixColor), Vector3(mixColor)));
- }
-
- if(std::abs(sourceMixColor.a - mixColor.a) > Math::MACHINE_EPSILON_1)
- {
- properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::Visual::Property::OPACITY));
- values.push_back(std::make_pair(sourceMixColor.a, mixColor.a));
- }
-
- if(sourceCornerRadius != cornerRadius)
- {
- properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::DevelVisual::Property::CORNER_RADIUS));
- values.push_back(std::make_pair(sourceCornerRadius, cornerRadius));
- }
+ sourceProperties.push_back(std::pair<Dali::Property::Index, Dali::Property::Map>(Toolkit::Control::Property::BACKGROUND, backgroundSourcePropertyMap));
+ destinationProperties.push_back(std::pair<Dali::Property::Index, Dali::Property::Map>(Toolkit::Control::Property::BACKGROUND, backgroundDestinationPropertyMap));
+ }
- if(sourceBorderlineWidth != borderlineWidth)
- {
- properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::DevelVisual::Property::BORDERLINE_WIDTH));
- values.push_back(std::make_pair(sourceBorderlineWidth, borderlineWidth));
- }
+ // Retrieves shadow properties to be transitioned.
+ Dali::Property::Map shadowSourcePropertyMap, shadowDestinationPropertyMap;
+ mControlImpl.MakeVisualTransition(shadowSourcePropertyMap, shadowDestinationPropertyMap, source, destination, Toolkit::DevelControl::Property::SHADOW);
+ if(shadowSourcePropertyMap.Count() > 0)
+ {
+ sourceProperties.push_back(std::pair<Dali::Property::Index, Dali::Property::Map>(Toolkit::DevelControl::Property::SHADOW, shadowSourcePropertyMap));
+ destinationProperties.push_back(std::pair<Dali::Property::Index, Dali::Property::Map>(Toolkit::DevelControl::Property::SHADOW, shadowDestinationPropertyMap));
+ }
- if(sourceBorderlineColor != borderlineColor)
- {
- properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::DevelVisual::Property::BORDERLINE_COLOR));
- values.push_back(std::make_pair(sourceBorderlineColor, borderlineColor));
- }
+ // Retrieves transition from inherited class.
+ mControlImpl.OnCreateTransitions(sourceProperties, destinationProperties, source, destination);
+}
- if(sourceBorderlineOffset != borderlineOffset)
+void Control::Impl::UpdateVisualProperties(const std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& properties)
+{
+ for(auto&& data : properties)
+ {
+ if(data.first == Toolkit::Control::Property::BACKGROUND)
{
- properties.push_back(GetVisualProperty(visualIndex, Dali::Toolkit::DevelVisual::Property::BORDERLINE_OFFSET));
- values.push_back(std::make_pair(sourceBorderlineOffset, borderlineOffset));
+ DoAction(Toolkit::Control::Property::BACKGROUND, DevelVisual::Action::UPDATE_PROPERTY, data.second);
}
-
- for(uint32_t i = 0; i < properties.size(); ++i)
+ else if(data.first == Toolkit::DevelControl::Property::SHADOW)
{
- if(timePeriod.delaySeconds > 0.0f)
- {
- Dali::KeyFrames initialKeyframes = Dali::KeyFrames::New();
- initialKeyframes.Add(0.0f, values[i].first);
- initialKeyframes.Add(1.0f, values[i].first);
- animation.AnimateBetween(properties[i], initialKeyframes, TimePeriod(timePeriod.delaySeconds));
- }
- Dali::KeyFrames keyframes = Dali::KeyFrames::New();
- keyframes.Add(0.0f, values[i].first);
- keyframes.Add(1.0f, values[i].second);
- animation.AnimateBetween(properties[i], keyframes, alphaFunction, timePeriod);
+ DoAction(Toolkit::DevelControl::Property::SHADOW, DevelVisual::Action::UPDATE_PROPERTY, data.second);
}
}
+ mControlImpl.OnUpdateVisualProperties(properties);
}
void Control::Impl::EmitResourceReadySignal()
Dali::Property GetVisualProperty(Dali::Property::Index index, Dali::Property::Key visualPropertyKey);
/**
- * @brief Make visual transition from source control to this control about specific Property::Index
- * If both of source and this control have Property::Index property, than create animation between them.
+ * @brief Retrieves source and destination visual properties for the Transition of this Control.
+ * The properties of this Control will be transitioned from the propeties of source Control to that of destination control.
+ * If a property value is different between source and destination Control,
+ * the property information of each Control will be included in sourceProperties and destinationProperties.
*
- * @param[in] animation Return animation from source to this control.
- * @param[in] source Source control to be used property animation.
- * @param[in] visualIndex Property::Index to make animation.
- * @param[in] alphaFunction alpha function of the animation.
- * @param[in] timePeriod time period of the animation.
+ * @param[out] sourceProperties Source property list to be applied on this Control.
+ * @param[out] destinationProperties Destination property list to be applied on this Control.
+ * @param[in] source Source control of the animation.
+ * @param[in] destination Destination control of the animation.
+ *
+ * @note This method do not handle Actor properties.
+ * And the size and order of the sourceProperties and destinationProperties must be synchronized.
+ *
+ * This method triggers Control::OnCreateTransition().
+ */
+ void CreateTransitions(std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& sourceProperties,
+ std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& destinationProperties,
+ Dali::Toolkit::Control source, Dali::Toolkit::Control destination);
+
+ /**
+ * @brief Update visual properties.
+ * @param[in] properties Property list to be used to update visual properties of this Control.
+ *
+ * @note This method triggers Control::OnUpdateVisualProperties().
*/
- void MakeVisualTransition(Dali::Animation& animation, Dali::Toolkit::Control source, Dali::Property::Index visualIndex, AlphaFunction alphaFunction, TimePeriod timePeriod);
+ void UpdateVisualProperties(const std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& properties);
/**
* @brief Gets the current control's accessible object.
// currently not called from code so compiler will optimize these away, kept here for future debugging
#define FLEX_CONTAINER_TAG "DALI Toolkit::FlexContainer "
-#define FC_LOG(fmt, args, ...) Debug::LogMessage(Debug::DebugInfo, FLEX_CONTAINER_TAG fmt, ##args)
+#define FC_LOG(fmt, args, ...) Debug::LogMessageWithFunctionLine(Debug::DebugInfo, FLEX_CONTAINER_TAG fmt, ##args)
// #define FLEX_CONTAINER_DEBUG 1
#if defined(FLEX_CONTAINER_DEBUG)
#include <dali/public-api/object/type-registry.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
}
}
-void ImageView::OnCreateTransitions(Dali::Animation& animation, Dali::Toolkit::Control source, AlphaFunction alphaFunction, TimePeriod timePeriod)
+void ImageView::OnCreateTransitions(std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& sourceProperties,
+ std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& destinationProperties,
+ Dali::Toolkit::Control source,
+ Dali::Toolkit::Control destination)
{
- Dali::Toolkit::ImageView destinationHandle = Toolkit::ImageView(GetOwner());
- Toolkit::Visual::Base destinationVisual = DevelControl::GetVisual(GetImplementation(destinationHandle), Toolkit::ImageView::Property::IMAGE);
- Property::Map destinationMap;
-
- if(!destinationVisual)
- {
- return;
- }
-
- destinationVisual.CreatePropertyMap(destinationMap);
-
- static auto findValueVector4 = [](const Property::Map& map, Property::Index index, const Vector4& defaultValue = Vector4()) -> Vector4 {
- Property::Value* propertyValue = map.Find(index);
- if(propertyValue)
- {
- return propertyValue->Get<Vector4>();
- }
- return defaultValue;
- };
-
- static auto findValueFloat = [](const Property::Map& map, Property::Index index, const float& defaultValue = 0.0f) -> float {
- Property::Value* propertyValue = map.Find(index);
- if(propertyValue)
- {
- return propertyValue->Get<float>();
- }
- return defaultValue;
- };
-
- Vector4 sourceMixColor(0.0f, 0.0f, 0.0f, 0.0f);
- Vector4 sourceCornerRadius(0.0f, 0.0f, 0.0f, 0.0f);
- float sourceBorderlineWidth(0.0f);
- Vector4 sourceBorderlineColor(0.0f, 0.0f, 0.0f, 1.0f);
- float sourceBorderlineOffset(0.0f);
- Vector4 destinationMixColor = findValueVector4(destinationMap, Dali::Toolkit::Visual::Property::MIX_COLOR, sourceMixColor);
- Vector4 destinationCornerRadius = findValueVector4(destinationMap, Toolkit::DevelVisual::Property::CORNER_RADIUS, sourceCornerRadius);
- float destinationBorderlineWidth = findValueFloat(destinationMap, Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, sourceBorderlineWidth);
- Vector4 destinationBorderlineColor = findValueVector4(destinationMap, Toolkit::DevelVisual::Property::BORDERLINE_COLOR, sourceBorderlineColor);
- float destinationBorderlineOffset = findValueFloat(destinationMap, Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, sourceBorderlineOffset);
-
- Dali::Toolkit::ImageView sourceHandle = Dali::Toolkit::ImageView::DownCast(source);
- Toolkit::Visual::Base sourceVisual;
- Property::Map sourceMap;
-
- if(sourceHandle)
- {
- sourceVisual = DevelControl::GetVisual(GetImplementation(sourceHandle), Toolkit::ImageView::Property::IMAGE);
- }
-
- if(sourceVisual)
+ // Retrieves image properties to be transitioned.
+ Dali::Property::Map imageSourcePropertyMap, imageDestinationPropertyMap;
+ MakeVisualTransition(imageSourcePropertyMap, imageDestinationPropertyMap, source, destination, Toolkit::ImageView::Property::IMAGE);
+ if(imageSourcePropertyMap.Count() > 0)
{
- sourceVisual.CreatePropertyMap(sourceMap);
- sourceMixColor = findValueVector4(sourceMap, Dali::Toolkit::Visual::Property::MIX_COLOR, sourceMixColor);
- sourceCornerRadius = findValueVector4(sourceMap, Toolkit::DevelVisual::Property::CORNER_RADIUS, sourceCornerRadius);
- sourceBorderlineWidth = findValueFloat(sourceMap, Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, sourceBorderlineWidth);
- sourceBorderlineColor = findValueVector4(sourceMap, Toolkit::DevelVisual::Property::BORDERLINE_COLOR, sourceBorderlineColor);
- sourceBorderlineOffset = findValueFloat(sourceMap, Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, sourceBorderlineOffset);
+ sourceProperties.push_back(std::pair<Dali::Property::Index, Dali::Property::Map>(Toolkit::ImageView::Property::IMAGE, imageSourcePropertyMap));
+ destinationProperties.push_back(std::pair<Dali::Property::Index, Dali::Property::Map>(Toolkit::ImageView::Property::IMAGE, imageDestinationPropertyMap));
}
+}
- std::vector<Dali::Property> properties;
- std::vector<std::pair<Property::Value, Property::Value>> values;
-
- if(Vector3(sourceMixColor) != Vector3(destinationMixColor))
- {
- properties.push_back(DevelControl::GetVisualProperty(destinationHandle, Toolkit::ImageView::Property::IMAGE, Toolkit::Visual::Property::MIX_COLOR));
- values.push_back(std::make_pair(Vector3(sourceMixColor), Vector3(destinationMixColor)));
- }
- if(std::abs(sourceMixColor.a - destinationMixColor.a) > Math::MACHINE_EPSILON_1)
- {
- properties.push_back(DevelControl::GetVisualProperty(destinationHandle, Toolkit::ImageView::Property::IMAGE, Toolkit::Visual::Property::OPACITY));
- values.push_back(std::make_pair(sourceMixColor.a, destinationMixColor.a));
- }
- if(sourceCornerRadius != destinationCornerRadius)
- {
- properties.push_back(DevelControl::GetVisualProperty(destinationHandle, Toolkit::ImageView::Property::IMAGE, Toolkit::DevelVisual::Property::CORNER_RADIUS));
- values.push_back(std::make_pair(sourceCornerRadius, destinationCornerRadius));
- }
- if(sourceBorderlineWidth != destinationBorderlineWidth)
- {
- properties.push_back(DevelControl::GetVisualProperty(destinationHandle, Toolkit::ImageView::Property::IMAGE, Toolkit::DevelVisual::Property::BORDERLINE_WIDTH));
- values.push_back(std::make_pair(sourceBorderlineWidth, destinationBorderlineWidth));
- }
- if(sourceBorderlineColor != destinationBorderlineColor)
- {
- properties.push_back(DevelControl::GetVisualProperty(destinationHandle, Toolkit::ImageView::Property::IMAGE, Toolkit::DevelVisual::Property::BORDERLINE_COLOR));
- values.push_back(std::make_pair(sourceBorderlineColor, destinationBorderlineColor));
- }
- if(sourceBorderlineOffset != destinationBorderlineOffset)
+void ImageView::OnUpdateVisualProperties(const std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& properties)
+{
+ Toolkit::Visual::Base visual = DevelControl::GetVisual(*this, Toolkit::ImageView::Property::IMAGE);
+ if(visual)
{
- properties.push_back(DevelControl::GetVisualProperty(destinationHandle, Toolkit::ImageView::Property::IMAGE, Toolkit::DevelVisual::Property::BORDERLINE_OFFSET));
- values.push_back(std::make_pair(sourceBorderlineOffset, destinationBorderlineOffset));
- }
+ Dali::Toolkit::Control handle(GetOwner());
- for(uint32_t i = 0; i < properties.size(); ++i)
- {
- if(timePeriod.delaySeconds > 0.0f)
+ for(auto&& data : properties)
{
- Dali::KeyFrames initialKeyframes = Dali::KeyFrames::New();
- initialKeyframes.Add(0.0f, values[i].first);
- initialKeyframes.Add(1.0f, values[i].first);
- animation.AnimateBetween(properties[i], initialKeyframes, TimePeriod(timePeriod.delaySeconds));
+ if(data.first == Toolkit::ImageView::Property::IMAGE)
+ {
+ DevelControl::DoAction(handle, Toolkit::ImageView::Property::IMAGE, DevelVisual::Action::UPDATE_PROPERTY, data.second);
+ break;
+ }
}
- Dali::KeyFrames keyframes = Dali::KeyFrames::New();
- keyframes.Add(0.0f, values[i].first);
- keyframes.Add(1.0f, values[i].second);
- animation.AnimateBetween(properties[i], keyframes, alphaFunction, timePeriod);
}
}
/**
* @copydoc Toolkit::Control::OnCreateTransitions()
*/
- virtual void OnCreateTransitions(Dali::Animation& animation, Dali::Toolkit::Control source, AlphaFunction alphaFunction, TimePeriod timePeriod) override;
+ virtual void OnCreateTransitions(std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& sourceProperties,
+ std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& destinationProperties,
+ Dali::Toolkit::Control source,
+ Dali::Toolkit::Control destination) override;
+
+ /**
+ * @copydoc Toolkit::Control::OnUpdateVisualProperties()
+ */
+ virtual void OnUpdateVisualProperties(const std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& properties) override;
private:
/**
//#define ENABLED_SCROLL_STATE_LOGGING
#ifdef ENABLED_SCROLL_STATE_LOGGING
-#define DALI_LOG_SCROLL_STATE(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s:%d " format "\n", __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
+#define DALI_LOG_SCROLL_STATE(format, ...) Dali::Integration::Log::LogMessageWithFunctionLine(Dali::Integration::Log::DebugInfo, "%s:%d " format "\n", __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define DALI_LOG_SCROLL_STATE(format, ...)
#endif
// currently not called from code so compiler will optimize these away, kept here for future debugging
#define TABLEVIEW_TAG "DALI Toolkit::TableView "
-#define TV_LOG(fmt, args, ...) Debug::LogMessage(Debug::DebugInfo, TABLEVIEW_TAG fmt, ##args)
+#define TV_LOG(fmt, args, ...) Debug::LogMessageWithFunctionLine(Debug::DebugInfo, TABLEVIEW_TAG fmt, ##args)
//#define TABLEVIEW_DEBUG 1
#if defined(TABLEVIEW_DEBUG)
// solve (v.x - x)^2 + (v.y - x)^2 = (cr / cy * x)^2
#if IS_REQUIRED_ROUNDED_CORNER
- // NOTE : lowspec HW cannot calculate here. need to reduce numeric error
- mediump float A = (cr * cr - 2.0 * cy * cy);
- mediump float B = cy * (v.x + v.y);
- mediump float V = dot(v,v);
- mediump float D = B * B + A * V;
+ // Note : lowspec HW cannot calculate here. need to reduce numeric error
+ highp float A = (cr * cr - 2.0 * cy * cy);
+ highp float B = cy * (v.x + v.y);
+ highp float V = dot(v,v);
+ highp float D = B * B + A * V;
potential = V * (cr + cy) / (sqrt(D) + B);
#else
// We can simplify this value cause cy = 0.8 * blurRadius, cr = 1.2 * blurRadius
// potential = 5.0*(sqrt(4.0*(v.x+v.y)^2 + dot(v,v)) - 2.0*(v.x+v.y));
// = 10.0*(v.x+v.y) * (sqrt(1.0 + (length(v) / (2.0*(v.x+v.y)))^2) - 1.0);
// = 10.0*(v.x+v.y) * (sqrt(1.25 - x + x^2) - 1.0);
- // ~= 10.0*(v.x+v.y) * (0.11803399 - 0.44721360x + 0.35777088x^2 - 0.14310x^3 + O(x^4)) (Taylor series)
+ // ~= 10.0*(v.x+v.y) * (0.11803399 - 0.44721360x + 0.35777088x^2 - 0.14310x^3 + O(x^5)) (Taylor series)
// ~= -1.0557281 * (v.x + v.y) + 2.236068 * length(v) - ~~~ (here, x <= 0.5 * (1.0 - sqrt(0.5)) < 0.1464467)
// Note : This simplify need cause we should use it on lowspec HW.
mediump float x = 0.5 * (1.0 - length(v) / (v.x + v.y));
const std::string EMPTY_STRING("");
-int ConvertPixelToPint(float pixel)
+template<typename Type>
+void EnsureCreated(Type*& object)
{
- unsigned int horizontalDpi = 0u;
- unsigned int verticalDpi = 0u;
- Dali::TextAbstraction::FontClient fontClient = Dali::TextAbstraction::FontClient::Get();
- fontClient.GetDpi(horizontalDpi, verticalDpi);
-
- return (pixel * 72.f) / static_cast<float>(horizontalDpi);
+ if(!object)
+ {
+ object = new Type();
+ }
}
-} // namespace
+template<typename Type>
+void EnsureCreated(std::unique_ptr<Type>& object)
+{
+ if(!object)
+ {
+ object = std::unique_ptr<Type>(new Type());
+ }
+}
-namespace Dali
+template<typename Type, typename Arg1>
+void EnsureCreated(Type*& object, Arg1 arg1)
{
-namespace Toolkit
+ if(!object)
+ {
+ object = new Type(arg1);
+ }
+}
+
+template<typename Type, typename Arg1, typename Arg2>
+void EnsureCreated(Type*& object, Arg1 arg1, Arg2 arg2)
{
-namespace Text
+ if(!object)
+ {
+ object = new Type(arg1, arg2);
+ }
+}
+
+float GetDpi()
{
-// public : Constructor.
+ unsigned int horizontalDpi = 0u;
+ unsigned int verticalDpi = 0u;
+ Dali::TextAbstraction::FontClient fontClient = Dali::TextAbstraction::FontClient::Get();
+ fontClient.GetDpi(horizontalDpi, verticalDpi);
+ return static_cast<float>(horizontalDpi);
+}
-ControllerPtr Controller::New()
+float ConvertPixelToPoint(float pixel)
{
- return ControllerPtr(new Controller());
+ return pixel * 72.0f / GetDpi();
}
-ControllerPtr Controller::New(ControlInterface* controlInterface)
+float ConvertPointToPixel(float point)
{
- return ControllerPtr(new Controller(controlInterface));
+ // Pixel size = Point size * DPI / 72.f
+ return point * GetDpi() / 72.0f;
}
-ControllerPtr Controller::New(ControlInterface* controlInterface,
- EditableControlInterface* editableControlInterface,
- SelectableControlInterface* selectableControlInterface,
- AnchorControlInterface* anchorControlInterface)
+void UpdateCursorPosition(Dali::Toolkit::Text::EventData* eventData)
{
- return ControllerPtr(new Controller(controlInterface,
- editableControlInterface,
- selectableControlInterface,
- anchorControlInterface));
+ if(eventData && Dali::Toolkit::Text::EventData::IsEditingState(eventData->mState))
+ {
+ // Update the cursor position if it's in editing mode
+ eventData->mDecoratorUpdated = true;
+ eventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font size is updated.
+ }
}
-// public : Configure the text controller.
+} // namespace
+
+namespace Dali::Toolkit::Text
+{
void Controller::EnableTextInput(DecoratorPtr decorator, InputMethodContext& inputMethodContext)
{
return;
}
- if(NULL == mImpl->mEventData)
- {
- mImpl->mEventData = new EventData(decorator, inputMethodContext);
- }
+ EnsureCreated(mImpl->mEventData, decorator, inputMethodContext);
}
void Controller::SetGlyphType(TextAbstraction::GlyphType glyphType)
if(mImpl->mLayoutEngine.GetLayout() == Layout::Engine::SINGLE_LINE_BOX)
{
+ mImpl->mOperationsPending = static_cast<OperationsMask>(mImpl->mOperationsPending |
+ LAYOUT |
+ ALIGN |
+ UPDATE_LAYOUT_SIZE |
+ REORDER);
+
if(enable)
{
DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled for SINGLE_LINE_BOX\n");
- mImpl->mOperationsPending = static_cast<OperationsMask>(mImpl->mOperationsPending |
- LAYOUT |
- ALIGN |
- UPDATE_LAYOUT_SIZE |
- UPDATE_DIRECTION |
- REORDER);
+ mImpl->mOperationsPending = static_cast<OperationsMask>(mImpl->mOperationsPending | UPDATE_DIRECTION);
}
else
{
DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled Disabling autoscroll\n");
- mImpl->mOperationsPending = static_cast<OperationsMask>(mImpl->mOperationsPending |
- LAYOUT |
- ALIGN |
- UPDATE_LAYOUT_SIZE |
- REORDER);
}
mImpl->mIsAutoScrollEnabled = enable;
float Controller::GetAutoScrollLineAlignment() const
{
float offset = 0.f;
-
- if(mImpl->mModel->mVisualModel &&
- (0u != mImpl->mModel->mVisualModel->mLines.Count()))
+ if(mImpl->mModel->mVisualModel && (0u != mImpl->mModel->mVisualModel->mLines.Count()))
{
offset = (*mImpl->mModel->mVisualModel->mLines.Begin()).alignmentOffset;
}
-
return offset;
}
void Controller::SetHorizontalScrollEnabled(bool enable)
{
- if((NULL != mImpl->mEventData) &&
- mImpl->mEventData->mDecorator)
+ if(mImpl->mEventData && mImpl->mEventData->mDecorator)
{
mImpl->mEventData->mDecorator->SetHorizontalScrollEnabled(enable);
}
}
+
bool Controller::IsHorizontalScrollEnabled() const
{
- if((NULL != mImpl->mEventData) &&
- mImpl->mEventData->mDecorator)
- {
- return mImpl->mEventData->mDecorator->IsHorizontalScrollEnabled();
- }
-
- return false;
+ return mImpl->mEventData && mImpl->mEventData->mDecorator && mImpl->mEventData->mDecorator->IsHorizontalScrollEnabled();
}
void Controller::SetVerticalScrollEnabled(bool enable)
{
- if((NULL != mImpl->mEventData) &&
- mImpl->mEventData->mDecorator)
+ if(mImpl->mEventData && mImpl->mEventData->mDecorator)
{
- if(mImpl->mEventData->mDecorator)
- {
- mImpl->mEventData->mDecorator->SetVerticalScrollEnabled(enable);
- }
+ mImpl->mEventData->mDecorator->SetVerticalScrollEnabled(enable);
}
}
bool Controller::IsVerticalScrollEnabled() const
{
- if((NULL != mImpl->mEventData) &&
- mImpl->mEventData->mDecorator)
- {
- return mImpl->mEventData->mDecorator->IsVerticalScrollEnabled();
- }
-
- return false;
+ return mImpl->mEventData && mImpl->mEventData->mDecorator && mImpl->mEventData->mDecorator->IsVerticalScrollEnabled();
}
void Controller::SetSmoothHandlePanEnabled(bool enable)
{
- if((NULL != mImpl->mEventData) &&
- mImpl->mEventData->mDecorator)
+ if(mImpl->mEventData && mImpl->mEventData->mDecorator)
{
mImpl->mEventData->mDecorator->SetSmoothHandlePanEnabled(enable);
}
bool Controller::IsSmoothHandlePanEnabled() const
{
- if((NULL != mImpl->mEventData) &&
- mImpl->mEventData->mDecorator)
- {
- return mImpl->mEventData->mDecorator->IsSmoothHandlePanEnabled();
- }
-
- return false;
+ return mImpl->mEventData && mImpl->mEventData->mDecorator && mImpl->mEventData->mDecorator->IsSmoothHandlePanEnabled();
}
void Controller::SetMaximumNumberOfCharacters(Length maxCharacters)
{
DALI_ASSERT_DEBUG(NULL != mImpl->mEventData && "TextInput disabled");
- if(NULL != mImpl->mEventData)
+ if(mImpl->mEventData)
{
mImpl->mEventData->mCursorBlinkEnabled = enable;
- if(!enable &&
- mImpl->mEventData->mDecorator)
+ if(!enable && mImpl->mEventData->mDecorator)
{
mImpl->mEventData->mDecorator->StopCursorBlink();
}
bool Controller::GetEnableCursorBlink() const
{
- if(NULL != mImpl->mEventData)
- {
- return mImpl->mEventData->mCursorBlinkEnabled;
- }
-
- return false;
+ return mImpl->mEventData && mImpl->mEventData->mCursorBlinkEnabled;
}
void Controller::SetMultiLineEnabled(bool enable)
{
// Set the alignment.
mImpl->mModel->mVerticalAlignment = alignment;
-
mImpl->mOperationsPending = static_cast<OperationsMask>(mImpl->mOperationsPending | ALIGN);
-
mImpl->RequestRelayout();
}
}
void Controller::SetTextFitMinSize(float minSize, FontSizeType type)
{
- switch(type)
- {
- case POINT_SIZE:
- {
- mImpl->mTextFitMinSize = minSize;
- break;
- }
- case PIXEL_SIZE:
- {
- mImpl->mTextFitMinSize = ConvertPixelToPint(minSize);
- break;
- }
- }
+ mImpl->mTextFitMinSize = (type == POINT_SIZE) ? minSize : ConvertPixelToPoint(minSize);
}
float Controller::GetTextFitMinSize() const
void Controller::SetTextFitMaxSize(float maxSize, FontSizeType type)
{
- switch(type)
- {
- case POINT_SIZE:
- {
- mImpl->mTextFitMaxSize = maxSize;
- break;
- }
- case PIXEL_SIZE:
- {
- mImpl->mTextFitMaxSize = ConvertPixelToPint(maxSize);
- break;
- }
- }
+ mImpl->mTextFitMaxSize = (type == POINT_SIZE) ? maxSize : ConvertPixelToPoint(maxSize);
}
float Controller::GetTextFitMaxSize() const
void Controller::SetTextFitStepSize(float step, FontSizeType type)
{
- switch(type)
- {
- case POINT_SIZE:
- {
- mImpl->mTextFitStepSize = step;
- break;
- }
- case PIXEL_SIZE:
- {
- mImpl->mTextFitStepSize = ConvertPixelToPint(step);
- break;
- }
- }
+ mImpl->mTextFitStepSize = (type == POINT_SIZE) ? step : ConvertPixelToPoint(step);
}
float Controller::GetTextFitStepSize() const
return mImpl->mEventData->mGrabHandlePopupEnabled;
}
-// public : Update
-
void Controller::SetText(const std::string& text)
{
TextUpdater::SetText(*this, text);
mImpl->SendSelectionToClipboard(deleteAfterSending);
}
-// public : Default style & Input style
-
void Controller::SetDefaultFontFamily(const std::string& defaultFontFamily)
{
- if(NULL == mImpl->mFontDefaults)
- {
- mImpl->mFontDefaults = new FontDefaults();
- }
+ EnsureCreated(mImpl->mFontDefaults);
mImpl->mFontDefaults->mFontDescription.family = defaultFontFamily;
DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::SetDefaultFontFamily %s\n", defaultFontFamily.c_str());
mImpl->mFontDefaults->familyDefined = !defaultFontFamily.empty();
- if(mImpl->mEventData)
- {
- // Update the cursor position if it's in editing mode
- if(EventData::IsEditingState(mImpl->mEventData->mState))
- {
- mImpl->mEventData->mDecoratorUpdated = true;
- mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font family is updated.
- }
- }
+ // Update the cursor position if it's in editing mode
+ UpdateCursorPosition(mImpl->mEventData);
// Clear the font-specific data
ClearFontData();
const std::string& Controller::GetDefaultFontFamily() const
{
- if(NULL != mImpl->mFontDefaults)
- {
- return mImpl->mFontDefaults->mFontDescription.family;
- }
-
- return EMPTY_STRING;
+ return mImpl->mFontDefaults ? mImpl->mFontDefaults->mFontDescription.family : EMPTY_STRING;
}
void Controller::SetPlaceholderFontFamily(const std::string& placeholderTextFontFamily)
void Controller::SetDefaultFontWeight(FontWeight weight)
{
- if(NULL == mImpl->mFontDefaults)
- {
- mImpl->mFontDefaults = new FontDefaults();
- }
+ EnsureCreated(mImpl->mFontDefaults);
mImpl->mFontDefaults->mFontDescription.weight = weight;
mImpl->mFontDefaults->weightDefined = true;
- if(mImpl->mEventData)
- {
- // Update the cursor position if it's in editing mode
- if(EventData::IsEditingState(mImpl->mEventData->mState))
- {
- mImpl->mEventData->mDecoratorUpdated = true;
- mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font weight is updated.
- }
- }
+ // Update the cursor position if it's in editing mode
+ UpdateCursorPosition(mImpl->mEventData);
// Clear the font-specific data
ClearFontData();
bool Controller::IsDefaultFontWeightDefined() const
{
- if(NULL != mImpl->mFontDefaults)
- {
- return mImpl->mFontDefaults->weightDefined;
- }
-
- return false;
+ return mImpl->mFontDefaults && mImpl->mFontDefaults->weightDefined;
}
FontWeight Controller::GetDefaultFontWeight() const
{
- if(NULL != mImpl->mFontDefaults)
- {
- return mImpl->mFontDefaults->mFontDescription.weight;
- }
-
- return TextAbstraction::FontWeight::NORMAL;
+ return mImpl->mFontDefaults ? mImpl->mFontDefaults->mFontDescription.weight : TextAbstraction::FontWeight::NORMAL;
}
void Controller::SetPlaceholderTextFontWeight(FontWeight weight)
bool Controller::IsPlaceholderTextFontWeightDefined() const
{
return PlaceholderHandler::IsPlaceholderTextFontWeightDefined(*this);
- ;
}
FontWeight Controller::GetPlaceholderTextFontWeight() const
void Controller::SetDefaultFontWidth(FontWidth width)
{
- if(NULL == mImpl->mFontDefaults)
- {
- mImpl->mFontDefaults = new FontDefaults();
- }
+ EnsureCreated(mImpl->mFontDefaults);
mImpl->mFontDefaults->mFontDescription.width = width;
mImpl->mFontDefaults->widthDefined = true;
- if(mImpl->mEventData)
- {
- // Update the cursor position if it's in editing mode
- if(EventData::IsEditingState(mImpl->mEventData->mState))
- {
- mImpl->mEventData->mDecoratorUpdated = true;
- mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font width is updated.
- }
- }
+ // Update the cursor position if it's in editing mode
+ UpdateCursorPosition(mImpl->mEventData);
// Clear the font-specific data
ClearFontData();
bool Controller::IsDefaultFontWidthDefined() const
{
- if(NULL != mImpl->mFontDefaults)
- {
- return mImpl->mFontDefaults->widthDefined;
- }
-
- return false;
+ return mImpl->mFontDefaults && mImpl->mFontDefaults->widthDefined;
}
FontWidth Controller::GetDefaultFontWidth() const
{
- if(NULL != mImpl->mFontDefaults)
- {
- return mImpl->mFontDefaults->mFontDescription.width;
- }
-
- return TextAbstraction::FontWidth::NORMAL;
+ return mImpl->mFontDefaults ? mImpl->mFontDefaults->mFontDescription.width : TextAbstraction::FontWidth::NORMAL;
}
void Controller::SetPlaceholderTextFontWidth(FontWidth width)
void Controller::SetDefaultFontSlant(FontSlant slant)
{
- if(NULL == mImpl->mFontDefaults)
- {
- mImpl->mFontDefaults = new FontDefaults();
- }
+ EnsureCreated(mImpl->mFontDefaults);
mImpl->mFontDefaults->mFontDescription.slant = slant;
mImpl->mFontDefaults->slantDefined = true;
- if(mImpl->mEventData)
- {
- // Update the cursor position if it's in editing mode
- if(EventData::IsEditingState(mImpl->mEventData->mState))
- {
- mImpl->mEventData->mDecoratorUpdated = true;
- mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font slant is updated.
- }
- }
+ // Update the cursor position if it's in editing mode
+ UpdateCursorPosition(mImpl->mEventData);
// Clear the font-specific data
ClearFontData();
bool Controller::IsDefaultFontSlantDefined() const
{
- if(NULL != mImpl->mFontDefaults)
- {
- return mImpl->mFontDefaults->slantDefined;
- }
- return false;
+ return mImpl->mFontDefaults && mImpl->mFontDefaults->slantDefined;
}
FontSlant Controller::GetDefaultFontSlant() const
{
- if(NULL != mImpl->mFontDefaults)
- {
- return mImpl->mFontDefaults->mFontDescription.slant;
- }
-
- return TextAbstraction::FontSlant::NORMAL;
+ return mImpl->mFontDefaults ? mImpl->mFontDefaults->mFontDescription.slant : TextAbstraction::FontSlant::NORMAL;
}
void Controller::SetPlaceholderTextFontSlant(FontSlant slant)
{
mImpl->mFontSizeScale = scale;
- if(mImpl->mEventData)
- {
- // Update the cursor position if it's in editing mode
- if(EventData::IsEditingState(mImpl->mEventData->mState))
- {
- mImpl->mEventData->mDecoratorUpdated = true;
- mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font size is updated.
- }
- }
+ // Update the cursor position if it's in editing mode
+ UpdateCursorPosition(mImpl->mEventData);
// Clear the font-specific data
ClearFontData();
float Controller::GetFontSizeScale() const
{
- if(nullptr != mImpl->mFontDefaults)
- {
- return mImpl->mFontSizeScale;
- }
-
- return 1.f;
+ return mImpl->mFontDefaults ? mImpl->mFontSizeScale : 1.0f;
}
void Controller::SetDefaultFontSize(float fontSize, FontSizeType type)
{
- if(NULL == mImpl->mFontDefaults)
- {
- mImpl->mFontDefaults = new FontDefaults();
- }
+ EnsureCreated(mImpl->mFontDefaults);
- switch(type)
- {
- case POINT_SIZE:
- {
- mImpl->mFontDefaults->mDefaultPointSize = fontSize;
- mImpl->mFontDefaults->sizeDefined = true;
- 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->mFontDefaults->mDefaultPointSize = (fontSize * 72.f) / static_cast<float>(horizontalDpi);
- mImpl->mFontDefaults->sizeDefined = true;
- break;
- }
- }
+ mImpl->mFontDefaults->mDefaultPointSize = (type == POINT_SIZE) ? fontSize : ConvertPixelToPoint(fontSize);
+ mImpl->mFontDefaults->sizeDefined = true;
- if(mImpl->mEventData)
- {
- // Update the cursor position if it's in editing mode
- if(EventData::IsEditingState(mImpl->mEventData->mState))
- {
- mImpl->mEventData->mDecoratorUpdated = true;
- mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font size is updated.
- }
- }
+ // Update the cursor position if it's in editing mode
+ UpdateCursorPosition(mImpl->mEventData);
// Clear the font-specific data
ClearFontData();
float Controller::GetDefaultFontSize(FontSizeType type) const
{
- float value = 0.0f;
- if(NULL != mImpl->mFontDefaults)
+ if(mImpl->mFontDefaults)
{
- switch(type)
- {
- case POINT_SIZE:
- {
- value = mImpl->mFontDefaults->mDefaultPointSize;
- break;
- }
- case PIXEL_SIZE:
- {
- // 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 * static_cast<float>(horizontalDpi) / 72.f;
- break;
- }
- }
- return value;
+ return (type == POINT_SIZE) ? mImpl->mFontDefaults->mDefaultPointSize : ConvertPointToPixel(mImpl->mFontDefaults->mDefaultPointSize);
}
-
- return value;
+ return 0.0f;
}
void Controller::SetPlaceholderTextFontSize(float fontSize, FontSizeType type)
if(!mImpl->IsShowingPlaceholderText())
{
mImpl->mModel->mVisualModel->SetTextColor(color);
-
mImpl->mModel->mLogicalModel->mColorRuns.Clear();
-
mImpl->mOperationsPending = static_cast<OperationsMask>(mImpl->mOperationsPending | COLOR);
-
mImpl->RequestRelayout();
}
}
void Controller::SetShadowOffset(const Vector2& shadowOffset)
{
mImpl->mModel->mVisualModel->SetShadowOffset(shadowOffset);
-
mImpl->RequestRelayout();
}
void Controller::SetShadowColor(const Vector4& shadowColor)
{
mImpl->mModel->mVisualModel->SetShadowColor(shadowColor);
-
mImpl->RequestRelayout();
}
if(fabsf(GetShadowBlurRadius() - shadowBlurRadius) > Math::MACHINE_EPSILON_1)
{
mImpl->mModel->mVisualModel->SetShadowBlurRadius(shadowBlurRadius);
-
mImpl->RequestRelayout();
}
}
void Controller::SetUnderlineColor(const Vector4& color)
{
mImpl->mModel->mVisualModel->SetUnderlineColor(color);
-
mImpl->RequestRelayout();
}
void Controller::SetUnderlineEnabled(bool enabled)
{
mImpl->mModel->mVisualModel->SetUnderlineEnabled(enabled);
-
mImpl->RequestRelayout();
}
void Controller::SetUnderlineHeight(float height)
{
mImpl->mModel->mVisualModel->SetUnderlineHeight(height);
-
mImpl->RequestRelayout();
}
void Controller::SetOutlineColor(const Vector4& color)
{
mImpl->mModel->mVisualModel->SetOutlineColor(color);
-
mImpl->RequestRelayout();
}
void Controller::SetOutlineWidth(uint16_t width)
{
mImpl->mModel->mVisualModel->SetOutlineWidth(width);
-
mImpl->RequestRelayout();
}
void Controller::SetBackgroundColor(const Vector4& color)
{
mImpl->mModel->mVisualModel->SetBackgroundColor(color);
-
mImpl->RequestRelayout();
}
void Controller::SetBackgroundEnabled(bool enabled)
{
mImpl->mModel->mVisualModel->SetBackgroundEnabled(enabled);
-
mImpl->RequestRelayout();
}
void Controller::SetDefaultEmbossProperties(const std::string& embossProperties)
{
- if(NULL == mImpl->mEmbossDefaults)
- {
- mImpl->mEmbossDefaults = new EmbossDefaults();
- }
-
+ EnsureCreated(mImpl->mEmbossDefaults);
mImpl->mEmbossDefaults->properties = embossProperties;
}
const std::string& Controller::GetDefaultEmbossProperties() const
{
- if(NULL != mImpl->mEmbossDefaults)
- {
- return mImpl->mEmbossDefaults->properties;
- }
-
- return EMPTY_STRING;
+ return mImpl->mEmbossDefaults ? mImpl->mEmbossDefaults->properties : EMPTY_STRING;
}
void Controller::SetDefaultOutlineProperties(const std::string& outlineProperties)
{
- if(NULL == mImpl->mOutlineDefaults)
- {
- mImpl->mOutlineDefaults = new OutlineDefaults();
- }
-
+ EnsureCreated(mImpl->mOutlineDefaults);
mImpl->mOutlineDefaults->properties = outlineProperties;
}
const std::string& Controller::GetDefaultOutlineProperties() const
{
- if(NULL != mImpl->mOutlineDefaults)
- {
- return mImpl->mOutlineDefaults->properties;
- }
-
- return EMPTY_STRING;
+ return mImpl->mOutlineDefaults ? mImpl->mOutlineDefaults->properties : EMPTY_STRING;
}
void Controller::RelayoutForNewLineSize()
mImpl->mOperationsPending = static_cast<OperationsMask>(mImpl->mOperationsPending | LAYOUT);
//remove selection
- if((mImpl->mEventData != nullptr) && (mImpl->mEventData->mState == EventData::SELECTING))
+ if(mImpl->mEventData && mImpl->mEventData->mState == EventData::SELECTING)
{
mImpl->ChangeState(EventData::EDITING);
}
void Controller::SetInputColor(const Vector4& color)
{
- if(NULL != mImpl->mEventData)
+ if(mImpl->mEventData)
{
mImpl->mEventData->mInputStyle.textColor = color;
mImpl->mEventData->mInputStyle.isDefaultColor = false;
const Vector4& Controller::GetInputColor() const
{
- if(NULL != mImpl->mEventData)
- {
- return mImpl->mEventData->mInputStyle.textColor;
- }
-
- // Return the default text's color if there is no EventData.
- return mImpl->mTextColor;
+ // Return event text input color if we have it, otherwise just return the default text's color
+ return mImpl->mEventData ? mImpl->mEventData->mInputStyle.textColor : mImpl->mTextColor;
}
void Controller::SetInputFontFamily(const std::string& fontFamily)
void Controller::SetInputLineSpacing(float lineSpacing)
{
- if(NULL != mImpl->mEventData)
+ if(mImpl->mEventData)
{
mImpl->mEventData->mInputStyle.lineSpacing = lineSpacing;
mImpl->mEventData->mInputStyle.isLineSpacingDefined = true;
float Controller::GetInputLineSpacing() const
{
- if(NULL != mImpl->mEventData)
- {
- return mImpl->mEventData->mInputStyle.lineSpacing;
- }
-
- return 0.f;
+ return mImpl->mEventData ? mImpl->mEventData->mInputStyle.lineSpacing : 0.0f;
}
void Controller::SetInputShadowProperties(const std::string& shadowProperties)
{
- if(NULL != mImpl->mEventData)
+ if(mImpl->mEventData)
{
mImpl->mEventData->mInputStyle.shadowProperties = shadowProperties;
}
const std::string& Controller::GetInputShadowProperties() const
{
- if(NULL != mImpl->mEventData)
- {
- return mImpl->mEventData->mInputStyle.shadowProperties;
- }
-
- return EMPTY_STRING;
+ return mImpl->mEventData ? mImpl->mEventData->mInputStyle.shadowProperties : EMPTY_STRING;
}
void Controller::SetInputUnderlineProperties(const std::string& underlineProperties)
{
- if(NULL != mImpl->mEventData)
+ if(mImpl->mEventData)
{
mImpl->mEventData->mInputStyle.underlineProperties = underlineProperties;
}
const std::string& Controller::GetInputUnderlineProperties() const
{
- if(NULL != mImpl->mEventData)
- {
- return mImpl->mEventData->mInputStyle.underlineProperties;
- }
-
- return EMPTY_STRING;
+ return mImpl->mEventData ? mImpl->mEventData->mInputStyle.underlineProperties : EMPTY_STRING;
}
void Controller::SetInputEmbossProperties(const std::string& embossProperties)
{
- if(NULL != mImpl->mEventData)
+ if(mImpl->mEventData)
{
mImpl->mEventData->mInputStyle.embossProperties = embossProperties;
}
const std::string& Controller::GetInputEmbossProperties() const
{
- if(NULL != mImpl->mEventData)
- {
- return mImpl->mEventData->mInputStyle.embossProperties;
- }
-
- return GetDefaultEmbossProperties();
+ return mImpl->mEventData ? mImpl->mEventData->mInputStyle.embossProperties : GetDefaultEmbossProperties();
}
void Controller::SetInputOutlineProperties(const std::string& outlineProperties)
{
- if(NULL != mImpl->mEventData)
+ if(mImpl->mEventData)
{
mImpl->mEventData->mInputStyle.outlineProperties = outlineProperties;
}
const std::string& Controller::GetInputOutlineProperties() const
{
- if(NULL != mImpl->mEventData)
- {
- return mImpl->mEventData->mInputStyle.outlineProperties;
- }
-
- return GetDefaultOutlineProperties();
+ return mImpl->mEventData ? mImpl->mEventData->mInputStyle.outlineProperties : GetDefaultOutlineProperties();
}
void Controller::SetInputModePassword(bool passwordInput)
{
- if(NULL != mImpl->mEventData)
+ if(mImpl->mEventData)
{
mImpl->mEventData->mPasswordInput = passwordInput;
}
bool Controller::IsInputModePassword()
{
- if(NULL != mImpl->mEventData)
- {
- return mImpl->mEventData->mPasswordInput;
- }
- return false;
+ return mImpl->mEventData && mImpl->mEventData->mPasswordInput;
}
void Controller::SetNoTextDoubleTapAction(NoTextTap::Action action)
{
- if(NULL != mImpl->mEventData)
+ if(mImpl->mEventData)
{
mImpl->mEventData->mDoubleTapAction = action;
}
Controller::NoTextTap::Action Controller::GetNoTextDoubleTapAction() const
{
- NoTextTap::Action action = NoTextTap::NO_ACTION;
-
- if(NULL != mImpl->mEventData)
- {
- action = mImpl->mEventData->mDoubleTapAction;
- }
-
- return action;
+ return mImpl->mEventData ? mImpl->mEventData->mDoubleTapAction : NoTextTap::NO_ACTION;
}
void Controller::SetNoTextLongPressAction(NoTextTap::Action action)
{
- if(NULL != mImpl->mEventData)
+ if(mImpl->mEventData)
{
mImpl->mEventData->mLongPressAction = action;
}
Controller::NoTextTap::Action Controller::GetNoTextLongPressAction() const
{
- NoTextTap::Action action = NoTextTap::NO_ACTION;
-
- if(NULL != mImpl->mEventData)
- {
- action = mImpl->mEventData->mLongPressAction;
- }
-
- return action;
+ return mImpl->mEventData ? mImpl->mEventData->mLongPressAction : NoTextTap::NO_ACTION;
}
bool Controller::IsUnderlineSetByString()
mImpl->mFontStyleSetByString = setByString;
}
-// public : Queries & retrieves.
-
Layout::Engine& Controller::GetLayoutEngine()
{
return mImpl->mLayoutEngine;
int Controller::GetLineCount(float width)
{
GetHeightForWidth(width);
- int numberofLines = mImpl->mModel->GetNumberOfLines();
- return numberofLines;
+ return mImpl->mModel->GetNumberOfLines();
}
const ModelInterface* const Controller::GetTextModel() const
void Controller::SetHiddenInputOption(const Property::Map& options)
{
- if(NULL == mImpl->mHiddenInput)
- {
- mImpl->mHiddenInput = new HiddenText(this);
- }
+ EnsureCreated<HiddenText, Controller*>(mImpl->mHiddenInput, this);
mImpl->mHiddenInput->SetProperties(options);
}
void Controller::GetHiddenInputOption(Property::Map& options)
{
- if(NULL != mImpl->mHiddenInput)
+ if(mImpl->mHiddenInput)
{
mImpl->mHiddenInput->GetProperties(options);
}
void Controller::SetInputFilterOption(const Property::Map& options)
{
- if(!mImpl->mInputFilter)
- {
- mImpl->mInputFilter = std::unique_ptr<InputFilter>(new InputFilter());
- }
+ EnsureCreated(mImpl->mInputFilter);
mImpl->mInputFilter->SetProperties(options);
}
void Controller::GetInputFilterOption(Property::Map& options)
{
- if(NULL != mImpl->mInputFilter)
+ if(mImpl->mInputFilter)
{
mImpl->mInputFilter->GetProperties(options);
}
mImpl->mModel->mVisualModel->SetEllipsisPosition(ellipsisPosition);
}
-// public : Relayout.
-
Controller::UpdateTextType Controller::Relayout(const Size& size, Dali::LayoutDirection::Type layoutDirection)
{
return Relayouter::Relayout(*this, size, layoutDirection);
mImpl->RequestRelayout();
}
-// public : Input style change signals.
-
bool Controller::IsInputStyleChangedSignalsQueueEmpty()
{
return (NULL == mImpl->mEventData) || (0u == mImpl->mEventData->mInputStyleChangedQueue.Count());
void Controller::ProcessInputStyleChangedSignals()
{
- if(NULL == mImpl->mEventData)
- {
- // Nothing to do.
- return;
- }
-
- for(Vector<InputStyle::Mask>::ConstIterator it = mImpl->mEventData->mInputStyleChangedQueue.Begin(),
- endIt = mImpl->mEventData->mInputStyleChangedQueue.End();
- it != endIt;
- ++it)
+ if(mImpl->mEventData)
{
- const InputStyle::Mask mask = *it;
-
- if(NULL != mImpl->mEditableControlInterface)
+ if(mImpl->mEditableControlInterface)
{
- // Emit the input style changed signal.
- mImpl->mEditableControlInterface->InputStyleChanged(mask);
+ // Emit the input style changed signal for each mask
+ std::for_each(mImpl->mEventData->mInputStyleChangedQueue.begin(),
+ mImpl->mEventData->mInputStyleChangedQueue.end(),
+ [&](const auto mask) { mImpl->mEditableControlInterface->InputStyleChanged(mask); } );
}
- }
- mImpl->mEventData->mInputStyleChangedQueue.Clear();
+ mImpl->mEventData->mInputStyleChangedQueue.Clear();
+ }
}
-// public : Text-input Event Queuing.
-
void Controller::KeyboardFocusGainEvent()
{
EventHandler::KeyboardFocusGainEvent(*this);
if(!IsEditable())
{
- return "";
+ return EMPTY_STRING;
}
mImpl->SendSelectionToClipboard(true); // Synchronous call to modify text
EventHandler::PasteClipboardItemEvent(*this);
}
-// protected : Inherit from Text::Decorator::ControllerInterface.
-
void Controller::GetTargetSize(Vector2& targetSize)
{
targetSize = mImpl->mModel->mVisualModel->mControlSize;
void Controller::AddDecoration(Actor& actor, bool needsClipping)
{
- if(NULL != mImpl->mEditableControlInterface)
+ if(mImpl->mEditableControlInterface)
{
mImpl->mEditableControlInterface->AddDecoration(actor, needsClipping);
}
float Controller::GetHorizontalScrollPosition()
{
- if(mImpl->mEventData)
- {
- //scroll values are negative internally so we convert them to positive numbers
- return -mImpl->mModel->mScrollPosition.x;
- }
- return 0;
+ // Scroll values are negative internally so we convert them to positive numbers
+ return mImpl->mEventData ? -mImpl->mModel->mScrollPosition.x : 0.0f;
}
float Controller::GetVerticalScrollPosition()
{
- if(mImpl->mEventData)
- {
- //scroll values are negative internally so we convert them to positive numbers
- return -mImpl->mModel->mScrollPosition.y;
- }
- return 0;
+ // Scroll values are negative internally so we convert them to positive numbers
+ return mImpl->mEventData ? -mImpl->mModel->mScrollPosition.y : 0.0f;
}
void Controller::DecorationEvent(HandleType handleType, HandleState state, float x, float y)
EventHandler::DecorationEvent(*this, handleType, state, x, y);
}
-// protected : Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
-
void Controller::TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::Buttons button)
{
EventHandler::TextPopupButtonTouched(*this, button);
mImpl->RequestRelayout();
}
-// private : Update.
-
void Controller::InsertText(const std::string& text, Controller::InsertType type)
{
TextUpdater::InsertText(*this, text, type);
TextUpdater::PasteText(*this, stringToPaste);
}
-bool Controller::RemoveText(int cursorOffset,
- int numberOfCharacters,
- UpdateInputStyleType type)
+bool Controller::RemoveText(int cursorOffset, int numberOfCharacters, UpdateInputStyleType type)
{
return TextUpdater::RemoveText(*this, cursorOffset, numberOfCharacters, type);
}
return TextUpdater::RemoveSelectedText(*this);
}
-void Controller::InsertTextAnchor(int numberOfCharacters,
- CharacterIndex previousCursorIndex)
+void Controller::InsertTextAnchor(int numberOfCharacters, CharacterIndex previousCursorIndex)
{
TextUpdater::InsertTextAnchor(*this, numberOfCharacters, previousCursorIndex);
}
-void Controller::RemoveTextAnchor(int cursorOffset,
- int numberOfCharacters,
- CharacterIndex previousCursorIndex)
+void Controller::RemoveTextAnchor(int cursorOffset, int numberOfCharacters, CharacterIndex previousCursorIndex)
{
TextUpdater::RemoveTextAnchor(*this, cursorOffset, numberOfCharacters, previousCursorIndex);
}
-// private : Relayout.
-
-bool Controller::DoRelayout(const Size& size,
- OperationsMask operationsRequired,
- Size& layoutSize)
+bool Controller::DoRelayout(const Size& size, OperationsMask operationsRequired, Size& layoutSize)
{
return Relayouter::DoRelayout(*this, size, operationsRequired, layoutSize);
}
Relayouter::CalculateVerticalOffset(*this, controlSize);
}
-// private : Events.
-
void Controller::ProcessModifyEvents()
{
EventHandler::ProcessModifyEvents(*this);
void Controller::ResetScrollPosition()
{
- if(NULL != mImpl->mEventData)
+ if(mImpl->mEventData)
{
// Reset the scroll position.
mImpl->mModel->mScrollPosition = Vector2::ZERO;
return mImpl->CreateBackgroundActor();
}
-// private : Private contructors & copy operator.
-
-Controller::Controller()
-: Controller(nullptr, nullptr, nullptr, nullptr)
-{
-}
-
-Controller::Controller(ControlInterface* controlInterface)
-: Controller(controlInterface, nullptr, nullptr, nullptr)
-{
-}
-
Controller::Controller(ControlInterface* controlInterface,
EditableControlInterface* editableControlInterface,
SelectableControlInterface* selectableControlInterface,
{
}
-// The copy constructor and operator are left unimplemented.
-
-// protected : Destructor.
-
Controller::~Controller()
{
delete mImpl;
}
-} // namespace Text
-
-} // namespace Toolkit
-
-} // namespace Dali
+} // namespace Dali::Toolkit::Text
#include <dali-toolkit/internal/text/text-selectable-control-interface.h>
#include <dali-toolkit/public-api/text/text-enumerations.h>
-namespace Dali
-{
-namespace Toolkit
-{
-namespace Text
+namespace Dali::Toolkit::Text
{
class Controller;
class ControlInterface;
*
* @return A pointer to a new Controller.
*/
- static ControllerPtr New();
+ static ControllerPtr New()
+ {
+ return ControllerPtr(new Controller());
+ }
/**
* @brief Create a new instance of a Controller.
*
* @return A pointer to a new Controller.
*/
- static ControllerPtr New(ControlInterface* controlInterface);
+ static ControllerPtr New(ControlInterface* controlInterface)
+ {
+ return ControllerPtr(new Controller(controlInterface));
+ }
/**
* @brief Create a new instance of a Controller.
static ControllerPtr New(ControlInterface* controlInterface,
EditableControlInterface* editableControlInterface,
SelectableControlInterface* selectableControlInterface,
- AnchorControlInterface* anchorControlInterface);
+ AnchorControlInterface* anchorControlInterface)
+ {
+ return ControllerPtr(new Controller(controlInterface,
+ editableControlInterface,
+ selectableControlInterface,
+ anchorControlInterface));
+ }
public: // Configure the text controller.
/**
/**
* @brief Private constructor.
*/
- Controller();
+ Controller()
+ : Controller(nullptr, nullptr, nullptr, nullptr)
+ {
+ }
/**
* @brief Private constructor.
*/
- Controller(ControlInterface* controlInterface);
+ Controller(ControlInterface* controlInterface)
+ : Controller(controlInterface, nullptr, nullptr, nullptr)
+ {
+ }
/**
* @brief Private constructor.
SelectableControlInterface* selectableControlInterface,
AnchorControlInterface* anchorControlInterface);
- // Undefined
- Controller(const Controller& handle);
-
- // Undefined
- Controller& operator=(const Controller& handle);
+ Controller(const Controller& handle) = delete;
+ Controller& operator=(const Controller& handle) = delete;
protected: // Destructor.
/**
Impl* mImpl;
};
-} // namespace Text
-
-} // namespace Toolkit
-
-} // namespace Dali
+} // namespace Dali::Toolkit::Text
#endif // DALI_TOOLKIT_TEXT_CONTROLLER_H
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/internal/controls/control/control-data-impl.h>
namespace Dali
{
namespace
{
const Dali::AlphaFunction DEFAULT_ALPHA_FUNCTION(Dali::AlphaFunction::DEFAULT);
-
} // anonymous namespace
-TransitionPtr Transition::New(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, TimePeriod timePeriod)
+TransitionPtr Transition::New(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, bool useDestinationTarget, TimePeriod timePeriod)
{
float delaySeconds = timePeriod.delaySeconds;
if(delaySeconds < 0.0f)
durationSeconds = 0.0f;
}
- TransitionPtr transition = new Transition(source, destination, TimePeriod(delaySeconds, durationSeconds));
+ TransitionPtr transition = new Transition(source, destination, useDestinationTarget, TimePeriod(delaySeconds, durationSeconds));
// Second-phase construction
transition->Initialize();
return transition;
}
-Transition::Transition(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, TimePeriod timePeriod)
+Transition::Transition(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, bool useDestinationTarget, TimePeriod timePeriod)
: TransitionBase(),
+ mUseDestinationTarget(useDestinationTarget),
+ mOriginalSize(),
mSourceControl(source),
mDestinationControl(destination)
{
- SetTarget(destination);
+ SetTarget(mUseDestinationTarget ? destination : source);
SetTimePeriod(timePeriod);
SetPairTransition(true);
}
}
//Make startPropertyMap and finishPropertyMap to use for property animation.
- Matrix sourceWorldTransform = sourceControl[Dali::Actor::Property::WORLD_MATRIX];
+ Matrix sourceWorldTransform = GetWorldTransform(sourceControl);
Vector3 sourcePosition, sourceScale;
Quaternion sourceOrientation;
sourceWorldTransform.GetTransformComponents(sourcePosition, sourceOrientation, sourceScale);
- Vector3 destinationPosition = destinationControl[Dali::Actor::Property::POSITION];
- Vector3 destinationScale = destinationControl[Dali::Actor::Property::SCALE];
- Quaternion destinationOrientation = destinationControl[Dali::Actor::Property::ORIENTATION];
- Vector4 targetColor = destinationControl[Dali::Actor::Property::COLOR];
- Vector3 targetSize = destinationControl[Dali::Actor::Property::SIZE];
+ Matrix destinationWorldTransform = GetWorldTransform(destinationControl);
+ Vector3 destinationPosition, destinationScale;
+ Quaternion destinationOrientation;
+ destinationWorldTransform.GetTransformComponents(destinationPosition, destinationOrientation, destinationScale);
Property::Map startPropertyMap;
Property::Map finishPropertyMap;
startPropertyMap.Insert(Dali::Actor::Property::SCALE, sourceScale);
finishPropertyMap.Insert(Dali::Actor::Property::SCALE, destinationScale);
- Vector4 sourceColor = sourceControl.GetCurrentProperty<Vector4>(Dali::Actor::Property::WORLD_COLOR);
+ Vector4 sourceColor = GetWorldColor(sourceControl);
+ Vector4 destinationColor = GetWorldColor(destinationControl);
startPropertyMap.Insert(Dali::Actor::Property::COLOR, sourceColor);
- finishPropertyMap.Insert(Dali::Actor::Property::COLOR, targetColor);
+ finishPropertyMap.Insert(Dali::Actor::Property::COLOR, destinationColor);
// Set animation for other properties if source and destination is different.
- Vector3 sourceSize = sourceControl.GetCurrentProperty<Vector3>(Dali::Actor::Property::SIZE);
- if(sourceSize != targetSize)
+ Vector3 sourceSize = sourceControl[Dali::Actor::Property::SIZE];
+ Vector3 destinationSize = destinationControl[Dali::Actor::Property::SIZE];
+ if(sourceSize != destinationSize)
{
startPropertyMap.Insert(Dali::Actor::Property::SIZE, sourceSize);
- finishPropertyMap.Insert(Dali::Actor::Property::SIZE, targetSize);
+ finishPropertyMap.Insert(Dali::Actor::Property::SIZE, destinationSize);
+ if(!mUseDestinationTarget)
+ {
+ mOriginalSize = GetTargetControl().GetProperty<Vector3>(Dali::Actor::Property::SIZE);
+ }
}
SetStartPropertyMap(startPropertyMap);
SetFinishPropertyMap(finishPropertyMap);
// source View becomes transparent during transition.
+ Dali::Toolkit::Control waitingControl = GetWaitingControl();
if(IsTransitionWithChild())
{
- sourceControl[Dali::Actor::Property::VISIBLE] = false;
+ waitingControl[Dali::Actor::Property::VISIBLE] = false;
}
else
{
- GetImplementation(sourceControl).SetTransparent(true);
+ GetImplementation(waitingControl).SetTransparent(true);
}
Dali::Animation animation = GetAnimation();
DALI_LOG_ERROR("animation is still not initialized\n");
return;
}
- Dali::Toolkit::DevelControl::CreateTransitions(destinationControl, animation, sourceControl, GetAlphaFunction(), GetTimePeriod());
+
+ mOriginalVisualProperties.clear();
+ std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>> destinationVisualProperties;
+ Dali::Toolkit::Control targetControl = GetTargetControl();
+ Internal::Control& internalControl = Toolkit::Internal::GetImplementation(targetControl);
+ Internal::Control::Impl& controlDataImpl = Toolkit::Internal::Control::Impl::Get(internalControl);
+ controlDataImpl.CreateTransitions(mOriginalVisualProperties, destinationVisualProperties, sourceControl, destinationControl);
+
+ for(uint32_t index = 0; index < mOriginalVisualProperties.size(); ++index)
+ {
+ Dali::Property::Map source = mOriginalVisualProperties[index].second;
+ Dali::Property::Map destination = destinationVisualProperties[index].second;
+ for(size_t i = 0; i < source.Count(); ++i)
+ {
+ Dali::Property property = DevelControl::GetVisualProperty(targetControl, mOriginalVisualProperties[index].first, source.GetKeyAt(i));
+ if(GetTimePeriod().delaySeconds > 0.0f)
+ {
+ Dali::KeyFrames initialKeyframes = Dali::KeyFrames::New();
+ initialKeyframes.Add(0.0f, source.GetValue(i));
+ animation.AnimateBetween(property, initialKeyframes, TimePeriod(GetTimePeriod().delaySeconds));
+ }
+ Dali::KeyFrames keyframes = Dali::KeyFrames::New();
+ keyframes.Add(0.0f, source.GetValue(i));
+ keyframes.Add(1.0f, destination.GetValue(i));
+ animation.AnimateBetween(property, keyframes, GetAlphaFunction(), GetTimePeriod());
+ }
+ }
}
void Transition::OnFinished()
{
- Dali::Toolkit::Control sourceControl = mSourceControl.GetHandle();
- if(!sourceControl)
+ Dali::Toolkit::Control waitingControl = GetWaitingControl();
+ if(!waitingControl)
{
return;
}
+ if(!mUseDestinationTarget)
+ {
+ Dali::Toolkit::Control target = GetTargetControl();
+ Dali::Animation resetAnimation = Dali::Animation::New(0.0f);
+ if(mOriginalSize != target.GetProperty<Vector3>(Dali::Actor::Property::SIZE))
+ {
+ // Use Animation not to notify size change and not to change width and height resize policy.
+ resetAnimation.AnimateTo(Dali::Property(target, Dali::Actor::Property::SIZE), mOriginalSize);
+ }
+ resetAnimation.Play();
+
+ Dali::Toolkit::Control targetControl = GetTargetControl();
+ Internal::Control& internalControl = Toolkit::Internal::GetImplementation(targetControl);
+ Internal::Control::Impl& controlDataImpl = Toolkit::Internal::Control::Impl::Get(internalControl);
+ controlDataImpl.UpdateVisualProperties(mOriginalVisualProperties);
+ }
+
if(IsTransitionWithChild())
{
- sourceControl[Dali::Actor::Property::VISIBLE] = true;
+ waitingControl[Dali::Actor::Property::VISIBLE] = true;
}
else
{
- GetImplementation(sourceControl).SetTransparent(false);
+ GetImplementation(waitingControl).SetTransparent(false);
}
}
+Dali::Toolkit::Control Transition::GetTargetControl()
+{
+ Dali::Toolkit::Control target = mUseDestinationTarget ? mDestinationControl.GetHandle() : mSourceControl.GetHandle();
+ return target;
+}
+
+Dali::Toolkit::Control Transition::GetWaitingControl()
+{
+ Dali::Toolkit::Control waitingControl = mUseDestinationTarget ? mSourceControl.GetHandle() : mDestinationControl.GetHandle();
+ return waitingControl;
+}
+
} // namespace Internal
} // namespace Toolkit
* @brief Create a new Transition object.
* @param[in] source A source control of this transition.
* @param[in] destination A destination control of this transition.
+ * @param[in] useDestinationTarget True if this transition uses destination control as target.
* @param[in] timePeriod The timePeriod of the animation.
* @return A smart-pointer to the newly allocated Transition.
*/
- static TransitionPtr New(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, TimePeriod timePeriod);
+ static TransitionPtr New(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, bool useDestinationTarget, TimePeriod timePeriod);
protected:
/**
*/
Transition(Dali::Toolkit::Control source,
Dali::Toolkit::Control destination,
+ bool useDestinationTarget,
TimePeriod timePeriod);
/**
Transition& operator=(const Transition& rhs);
private:
- WeakHandle<Dali::Toolkit::Control> mSourceControl;
- WeakHandle<Dali::Toolkit::Control> mDestinationControl;
+ Dali::Toolkit::Control GetTargetControl();
+ Dali::Toolkit::Control GetWaitingControl();
+
+private:
+ bool mUseDestinationTarget;
+ Vector3 mOriginalSize;
+ std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>> mOriginalVisualProperties;
+ WeakHandle<Dali::Toolkit::Control> mSourceControl;
+ WeakHandle<Dali::Toolkit::Control> mDestinationControl;
};
} // namespace Internal
{
mImpl->mBorderlineWidth = width;
}
+
+ if(mImpl->mBorderlineWidthIndex != Property::INVALID_INDEX)
+ {
+ mImpl->mRenderer.SetProperty(mImpl->mBorderlineWidthIndex, mImpl->mBorderlineWidth);
+ }
break;
}
case Toolkit::DevelVisual::Property::BORDERLINE_COLOR:
{
mImpl->mBorderlineColor = color;
}
+
+ if(mImpl->mBorderlineColorIndex != Property::INVALID_INDEX)
+ {
+ mImpl->mRenderer.SetProperty(mImpl->mBorderlineColorIndex, mImpl->mBorderlineColor);
+ }
break;
}
case Toolkit::DevelVisual::Property::BORDERLINE_OFFSET:
{
mImpl->mBorderlineOffset = offset;
}
+
+ if(mImpl->mBorderlineOffsetIndex != Property::INVALID_INDEX)
+ {
+ mImpl->mRenderer.SetProperty(mImpl->mBorderlineOffsetIndex, mImpl->mBorderlineOffset);
+ }
break;
}
case Toolkit::DevelVisual::Property::CORNER_RADIUS:
mImpl->mCornerRadius = Vector4(radius, radius, radius, radius);
}
}
+
+ if(mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
+ {
+ mImpl->mRenderer.SetProperty(mImpl->mCornerRadiusIndex, mImpl->mCornerRadius);
+ }
break;
}
case Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY:
mImpl->SignalDisconnected(slotObserver, callback);
}
+void Control::MakeVisualTransition(Dali::Property::Map& sourcePropertyMap, Dali::Property::Map& destinationPropertyMap,
+ Dali::Toolkit::Control source, Dali::Toolkit::Control destination, Dali::Property::Index visualIndex)
+{
+ sourcePropertyMap.Clear();
+ destinationPropertyMap.Clear();
+
+ Toolkit::Visual::Base sourceVisual = DevelControl::GetVisual(GetImplementation(source), visualIndex);
+ Toolkit::Visual::Base destinationVisual = DevelControl::GetVisual(GetImplementation(destination), visualIndex);
+
+ // If source or destination doesn't have the visual, do not create transition for the visual.
+ if(!sourceVisual || !destinationVisual)
+ {
+ return;
+ }
+
+ Property::Map sourceMap;
+ Property::Map destinationMap;
+ sourceVisual.CreatePropertyMap(sourceMap);
+ destinationVisual.CreatePropertyMap(destinationMap);
+
+ static auto findValueVector4 = [](const Property::Map& map, Property::Index index, const Vector4& defaultValue = Vector4()) -> Vector4
+ {
+ Property::Value* propertyValue = map.Find(index);
+ if(propertyValue)
+ {
+ return propertyValue->Get<Vector4>();
+ }
+ return defaultValue;
+ };
+
+ static auto findValueFloat = [](const Property::Map& map, Property::Index index, const float& defaultValue = 0.0f) -> float
+ {
+ Property::Value* propertyValue = map.Find(index);
+ if(propertyValue)
+ {
+ return propertyValue->Get<float>();
+ }
+ return defaultValue;
+ };
+
+ Vector4 defaultMixColor(Color::TRANSPARENT);
+ Vector4 defaultCornerRadius(0.0f, 0.0f, 0.0f, 0.0f);
+ float defaultBorderlineWidth(0.0f);
+ Vector4 defaultBorderlineColor(0.0f, 0.0f, 0.0f, 1.0f);
+ float defaultBorderlineOffset(0.0f);
+
+ Vector4 sourceMixColor = findValueVector4(sourceMap, Dali::Toolkit::Visual::Property::MIX_COLOR, defaultMixColor);
+ Vector4 sourceCornerRadius = findValueVector4(sourceMap, Toolkit::DevelVisual::Property::CORNER_RADIUS, defaultCornerRadius);
+ float sourceBorderlineWidth = findValueFloat(sourceMap, Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, defaultBorderlineWidth);
+ Vector4 sourceBorderlineColor = findValueVector4(sourceMap, Toolkit::DevelVisual::Property::BORDERLINE_COLOR, defaultBorderlineColor);
+ float sourceBorderlineOffset = findValueFloat(sourceMap, Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, defaultBorderlineOffset);
+
+ Vector4 destinationMixColor = findValueVector4(destinationMap, Dali::Toolkit::Visual::Property::MIX_COLOR, defaultMixColor);
+ Vector4 destinationCornerRadius = findValueVector4(destinationMap, Toolkit::DevelVisual::Property::CORNER_RADIUS, defaultCornerRadius);
+ float destinationBorderlineWidth = findValueFloat(destinationMap, Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, defaultBorderlineWidth);
+ Vector4 destinationBorderlineColor = findValueVector4(destinationMap, Toolkit::DevelVisual::Property::BORDERLINE_COLOR, defaultBorderlineColor);
+ float destinationBorderlineOffset = findValueFloat(destinationMap, Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, defaultBorderlineOffset);
+
+ // If the value of the source Control and that of destination Control is different, the property should be transitioned.
+ if(Vector3(sourceMixColor) != Vector3(destinationMixColor))
+ {
+ sourcePropertyMap.Add(Dali::Toolkit::Visual::Property::MIX_COLOR, Vector3(sourceMixColor));
+ destinationPropertyMap.Add(Dali::Toolkit::Visual::Property::MIX_COLOR, Vector3(destinationMixColor));
+ }
+
+ if(std::abs(sourceMixColor.a - destinationMixColor.a) > Math::MACHINE_EPSILON_1)
+ {
+ sourcePropertyMap.Add(Dali::Toolkit::Visual::Property::OPACITY, sourceMixColor.a);
+ destinationPropertyMap.Add(Dali::Toolkit::Visual::Property::OPACITY, destinationMixColor.a);
+ }
+
+ if(sourceCornerRadius != destinationCornerRadius)
+ {
+ sourcePropertyMap.Add(Dali::Toolkit::DevelVisual::Property::CORNER_RADIUS, sourceCornerRadius);
+ destinationPropertyMap.Add(Dali::Toolkit::DevelVisual::Property::CORNER_RADIUS, destinationCornerRadius);
+ }
+
+ if(sourceBorderlineWidth != destinationBorderlineWidth)
+ {
+ sourcePropertyMap.Add(Dali::Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, sourceBorderlineWidth);
+ destinationPropertyMap.Add(Dali::Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, destinationBorderlineWidth);
+ }
+
+ if(sourceBorderlineColor != destinationBorderlineColor)
+ {
+ sourcePropertyMap.Add(Dali::Toolkit::DevelVisual::Property::BORDERLINE_COLOR, sourceBorderlineColor);
+ destinationPropertyMap.Add(Dali::Toolkit::DevelVisual::Property::BORDERLINE_COLOR, destinationBorderlineColor);
+ }
+
+ if(sourceBorderlineOffset != destinationBorderlineOffset)
+ {
+ sourcePropertyMap.Add(Dali::Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, sourceBorderlineOffset);
+ destinationPropertyMap.Add(Dali::Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, destinationBorderlineOffset);
+ }
+}
+
Control& GetImplementation(Dali::Toolkit::Control& handle)
{
CustomActorImpl& customInterface = handle.GetImplementation();
namespace Internal
{
+
/**
* @brief This is the internal base class for all controls.
*
return NULL;
}
- // Transition
+ // Transition APIs
+
+ /**
+ * @brief Make visual transition from source control to destination control about specific Visual.
+ * If both of source and destination control have same visual index, than generates information for the transition of this Control.
+ *
+ * @param[out] sourcePropertyMap Source property map to be applied on this Control.
+ * @param[out] destinationPropertyMap Destination property map to be applied on this Control.
+ * @param[in] source Source control of the animation.
+ * @param[in] destination Destination control of the animation.
+ * @param[in] visualIndex Property::Index to make animation.
+ */
+ void MakeVisualTransition(Dali::Property::Map& sourcePropertyMap, Dali::Property::Map& destinationPropertyMap,
+ Dali::Toolkit::Control source, Dali::Toolkit::Control destination, Dali::Property::Index visualIndex);
/**
- * @brief Retrieve visual property animations.
- * This Control is a destination.
+ * @brief Retrieves source and destination visual properties for the Transition of this Control.
+ * The properties of this Control will be transitioned from the propeties of source Control to that of destination control.
+ * If a property value is different between source and destination Control,
+ * the property information of each Control will be included in sourceProperties and destinationProperties.
+ *
+ * @param[out] sourceProperties Source property list to be applied on this Control.
+ * @param[out] destinationProperties Destination property list to be applied on this Control.
+ * @param[in] source Source control of the animation.
+ * @param[in] destination Destination control of the animation.
*
- * @param[in] animation generated animation
- * @param[in] source source control of the animation.
- * @param[in] alphaFunction AlphaFunction of the animation
- * @param[in] timePeriod TimePeriod of the animation
+ * @note This method do not handle Actor properties.
+ * And the size and order of the sourceProperties and destinationProperties must be synchronized.
+ */
+ virtual void OnCreateTransitions(std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& sourceProperties,
+ std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& destinationProperties,
+ Dali::Toolkit::Control source,
+ Dali::Toolkit::Control destination)
+ {
+ }
+
+ /**
+ * @brief Update visual properties.
+ * @param[in] properties Property list to be used to update visual properties of this Control.
*/
- virtual void OnCreateTransitions(Dali::Animation& animation, Dali::Toolkit::Control source, AlphaFunction alphaFunction, TimePeriod timePeriod)
+ virtual void OnUpdateVisualProperties(const std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& properties)
{
}
{
const unsigned int TOOLKIT_MAJOR_VERSION = 2;
const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 49;
+const unsigned int TOOLKIT_MICRO_VERSION = 50;
const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
{
}
-Transition Transition::New(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, TimePeriod timePeriod)
+Transition Transition::New(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, bool useDestinationTarget, TimePeriod timePeriod)
{
- Internal::TransitionPtr internal = Dali::Toolkit::Internal::Transition::New(source, destination, timePeriod);
+ Internal::TransitionPtr internal = Dali::Toolkit::Internal::Transition::New(source, destination, useDestinationTarget, timePeriod);
return Transition(internal.Get());
}
/**
* @brief Creates an initialized Transition.
*
- * @param[in] source Source
- * @param[in] destination Destination
+ * @param[in] source A source control of this transition.
+ * @param[in] destination A destination control of this transition.
+ * @param[in] useDestinationTarget True if this transition uses destination control as target.
* @param[in] timePeriod The duration in seconds
* @return A handle to a newly allocated Dali resource
* @note durationSeconds can not be negative.
*/
- static Transition New(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, TimePeriod timePeriod);
+ static Transition New(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, bool useDestinationTarget, TimePeriod timePeriod);
/**
* @brief Downcasts a handle to Transition handle.
Name: dali2-toolkit
Summary: Dali 3D engine Toolkit
-Version: 2.0.49
+Version: 2.0.50
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT