{
return CreateBufferImage(4, 4, Color::WHITE);
}
-
-namespace Test
-{
-
-struct ObjectDestructionFunctor
-{
- // Create a ObjectDestructionFunctor passing in a Dali::RefObject* to be monitored and a bool variable.
- // Create ObjectRegistry instance and connect to the ObjectDestroyedSignal passing in the above functor for the callback.
- // Get the ObjectPointer (Actor::GetObjectPtr) of the Actor to be checked for destruction and assign it to the Dali::RefObject*
- // Check the bool variable which would be true when object destroyed.
- ObjectDestructionFunctor( Dali::RefObject* objectPtr, bool& refObjectDestroyed )
- : refObjectPointerToCheck( objectPtr ),
- refObjectDestroyedBoolean( refObjectDestroyed )
- {
- refObjectDestroyed = false;
- }
-
- void operator()( const Dali::RefObject* objectPointer )
- {
- if ( refObjectPointerToCheck == objectPointer )
- {
- refObjectDestroyedBoolean = true;
- }
- }
-
- Dali::RefObject* refObjectPointerToCheck;
- bool& refObjectDestroyedBoolean;
-};
-
-ObjectDestructionTracker::ObjectDestructionTracker()
- :mRefObjectDestroyed( false)
-{
-}
-
-void ObjectDestructionTracker::Start( Actor actor )
-{
- ObjectDestructionFunctor destructionFunctor( actor.GetObjectPtr(), mRefObjectDestroyed );
-
- ObjectRegistry objectRegistry = Stage::GetCurrent().GetObjectRegistry();
- objectRegistry.ObjectDestroyedSignal().Connect( this, destructionFunctor );
-}
-
-bool ObjectDestructionTracker::IsDestroyed()
-{
- return mRefObjectDestroyed;
-}
-
-} // namespace Test
BufferImage CreateBufferImage();
BufferImage CreateBufferImage(int width, int height, const Vector4& color);
-// Test namespace to prevent pollution of Dali namespace, add Test helper functions here
-namespace Test
-{
-/**
- * @brief
- *
- * Helper to check object destruction occurred
- * 1) In main part of code create an ObjectDestructionTracker
- * 2) Within sub section of main create object Actor test and call Start with Actor to test for destruction
- * 3) Perform code which is expected to destroy Actor
- * 4) Back in main part of code use IsDestroyed() to test if Actor was destroyed
- */
-class ObjectDestructionTracker : public ConnectionTracker
-{
-public:
-
- /**
- * @brief
- *
- * Call in main part of code
- */
- ObjectDestructionTracker();
-
- /**
- * @brief Call in sub bock of code where the Actor being checked is still alive.
- *
- * @param[in] actor Actor to be checked for destruction
- */
- void Start( Actor actor );
-
- /**
- * @brief Call to check if Actor alive or destroyed.
- * @return bool true if Actor was destroyed
- */
- bool IsDestroyed();
-
-private:
- bool mRefObjectDestroyed;
-};
-
-} // namespace Test
-
#endif // __DALI_TEST_SUITE_UTILS_H__
#include "dummy-control.h"
#include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
namespace Dali
{
{
}
-void DummyControlImpl::RegisterVisual( Property::Index index, Actor placementActor, Toolkit::Visual::Base visual )
-{
- Control::RegisterVisual( index, placementActor, visual );
-}
-
-void DummyControlImpl::UnregisterVisual( Property::Index index )
-{
- Control::UnregisterVisual( index );
-}
-
DummyControl DummyControlImplOverride::New()
{
IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
{
class DummyControlImpl;
-class ControlRenderer;
+
/**
* Control does not have a New method so use this dummy class for the handle.
*/
inline TapGestureDetector GetTapGestureDetector() const { return Internal::Control::GetTapGestureDetector(); }
inline LongPressGestureDetector GetLongPressGestureDetector() const { return Internal::Control::GetLongPressGestureDetector(); }
- void RegisterVisual( Property::Index index, Actor placementActor, Toolkit::Visual::Base visual);
- void UnregisterVisual( Property::Index index );
-
// Used to test signal connections
void CustomSlot1( Actor actor );
mLastShaderIdUsed = 0;
mLastProgramIdUsed = 0;
mLastUniformIdUsed = 0;
- mLastDepthMask = false;
mUniforms.clear();
mProgramUniforms1i.clear();
mProgramUniforms4f.clear();
mCullFaceTrace.Reset();
- mDepthFunctionTrace.Reset();
mEnableDisableTrace.Reset();
mShaderTrace.Reset();
- mStencilFunctionTrace.Reset();
mTextureTrace.Reset();
mTexParamaterTrace.Reset();
mDrawTrace.Reset();
-#ifndef TEST_GL_ABSTRACTION_H
-#define TEST_GL_ABSTRACTION_H
+#ifndef __TEST_GL_ABSTRACTION_H__
+#define __TEST_GL_ABSTRACTION_H__
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
inline void DepthMask(GLboolean flag)
{
- mLastDepthMask = flag;
- }
-
- inline bool GetLastDepthMask() const
- {
- return mLastDepthMask;
}
inline void DepthRangef(GLclampf zNear, GLclampf zFar)
GLenum mLastBlendFuncSrcAlpha;
GLenum mLastBlendFuncDstAlpha;
- GLboolean mLastDepthMask;
-
// Data for manipulating the IDs returned by GenTextures
GLuint mLastAutoTextureIdUsed;
std::vector<GLuint> mNextTextureIds;
bool BlendDisabled(const Dali::TraceCallStack& callStack);
-#endif // TEST_GL_ABSTRACTION_H
+
+
+#endif // __TEST_GL_ES_H__
END_TEST;
}
-int UtcDaliButtonResetSelectedColorP(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliButtonSetSelectedColorP");
-
- PushButton pushButton = PushButton::New();
- Stage::GetCurrent().Add( pushButton );
-
- application.SendNotification();
- application.Render();
-
- const Vector4 FIRST_COLOR = Color::BLUE;
- const Vector4 SECOND_COLOR = Color::BLUE;
-
- pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
- pushButton.SetProperty( Button::Property::SELECTED_COLOR, FIRST_COLOR );
-
- application.SendNotification();
- application.Render();
-
- Vector4 color = pushButton.GetProperty<Vector4>( Button::Property::SELECTED_COLOR );
-
- DALI_TEST_EQUALS( color, FIRST_COLOR, TEST_LOCATION );
-
- pushButton.SetProperty( Button::Property::SELECTED_COLOR, SECOND_COLOR );
-
- application.SendNotification();
- application.Render();
-
- color = pushButton.GetProperty<Vector4>( Button::Property::SELECTED_COLOR );
-
- DALI_TEST_EQUALS( color, SECOND_COLOR, TEST_LOCATION );
-
- END_TEST;
-}
#include <dali.h>
#include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/wheel-event-integ.h>
#include <dali/integration-api/events/long-press-gesture-event.h>
END_TEST;
}
-
-int UtcDaliControlImplRegisterThenReRegisterVisual(void)
-{
- ToolkitTestApplication application;
-
- DummyControl dummy = DummyControl::New();
- DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
-
- Property::Index index =1;
- Actor placementActor = Actor::New();
-
- Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
- Toolkit::Visual::Base visual;
-
- Property::Map map;
- map[Visual::Property::TYPE] = Visual::COLOR;
- map[ColorVisual::Property::MIX_COLOR] = Color::RED;
-
- visual = visualFactory.CreateVisual( map );
- DALI_TEST_CHECK(visual);
-
- // Register index with a color visual
- dummyImpl.RegisterVisual( index, placementActor, visual );
-
-
- Property::Map newMap;
- newMap[Visual::Property::TYPE] = Visual::COLOR;
- newMap[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
-
- visual = visualFactory.CreateVisual( newMap );
- DALI_TEST_CHECK(visual);
-
- // ReRegister with altered color visual
- dummyImpl.RegisterVisual( index, placementActor, visual );
-
- tet_result(TET_PASS);
-
- END_TEST;
-}
-
-int UtcDaliControlImplRegisterVisaulThenReRegisterToSelf(void)
-{
- ToolkitTestApplication application;
-
- DummyControl dummy = DummyControl::New();
- DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
-
- Property::Index index =1;
- Actor placementActor = Actor::New();
-
- Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
- Toolkit::Visual::Base visual;
-
- Property::Map map;
- map[Visual::Property::TYPE] = Visual::COLOR;
- map[ColorVisual::Property::MIX_COLOR] = Color::RED;
-
- visual = visualFactory.CreateVisual( map );
- DALI_TEST_CHECK(visual);
-
- // Register index with a color visual
- dummyImpl.RegisterVisual( index, placementActor, visual );
-
- // ReRegister to self
- dummyImpl.RegisterVisual( index, dummy, visual );
-
- END_TEST;
-}
-
-int UtcDaliControlImplRegisterVisualToSelf(void)
-{
- ToolkitTestApplication application;
-
- Test::ObjectDestructionTracker objectDestructionTracker;
-
- {
- DummyControl dummy = DummyControl::New();
- DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
- objectDestructionTracker.Start( dummy );
-
- Property::Index index = 1;
- Actor placementActor = Actor::New();
-
- Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
- Toolkit::Visual::Base visual;
-
- Property::Map map;
- map[Visual::Property::TYPE] = Visual::COLOR;
- map[ColorVisual::Property::MIX_COLOR] = Color::RED;
-
- visual = visualFactory.CreateVisual( map );
- DALI_TEST_CHECK(visual);
-
- // Register to self
- dummyImpl.RegisterVisual( index, dummy, visual );
- DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), false, TEST_LOCATION ); // Control not destroyed yet
- }
-
- DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), true, TEST_LOCATION ); // Should be destroyed
-
- END_TEST;
-}
-
-int UtcDaliControlImplRegisterTwoVisuals(void)
-{
- ToolkitTestApplication application;
-
- DummyControl dummy = DummyControl::New();
- DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
-
- Property::Index index =1;
- Actor placementActor = Actor::New();
-
- Property::Index index2 =2;
- Actor secondPlacementActor = Actor::New();
-
- Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
- Toolkit::Visual::Base visual;
- Toolkit::Visual::Base secondVisual;
-
- Property::Map map;
- map[Visual::Property::TYPE] = Visual::COLOR;
- map[ColorVisual::Property::MIX_COLOR] = Color::RED;
-
- visual = visualFactory.CreateVisual( map );
- DALI_TEST_CHECK(visual);
-
- // Register index with a color visual
- dummyImpl.RegisterVisual( index, placementActor, visual );
-
- Property::Map newMap;
- newMap[Visual::Property::TYPE] = Visual::COLOR;
- newMap[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
-
- secondVisual = visualFactory.CreateVisual( newMap );
- DALI_TEST_CHECK( secondVisual );
-
- // ReRegister with altered color visual
- dummyImpl.RegisterVisual( index2, secondPlacementActor, secondVisual );
-
- END_TEST;
-}
-
-int UtcDaliControlImplRegisterUnregisterVisual(void)
-{
- ToolkitTestApplication application;
-
- DummyControl dummy = DummyControl::New();
- DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
-
- Property::Index index =1;
- Actor placementActor = Actor::New();
-
- Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
- Toolkit::Visual::Base visual;
-
- Property::Map map;
- map[Visual::Property::TYPE] = Visual::COLOR;
- map[ColorVisual::Property::MIX_COLOR] = Color::RED;
-
- visual = visualFactory.CreateVisual( map );
- DALI_TEST_CHECK(visual);
-
- // Register index with a color visual
- dummyImpl.RegisterVisual( index, placementActor, visual );
-
- // Unregister visual
- dummyImpl.UnregisterVisual( index );
-
- END_TEST;
-}
gradientVisual.GetNaturalSize(naturalSize);
DALI_TEST_EQUALS( naturalSize, Vector2::ZERO,TEST_LOCATION );
- // svg visual
+ //svg visual
Visual::Base svgVisual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
svgVisual.SetSize( visualSize );
DALI_TEST_EQUALS( svgVisual.GetSize(), visualSize, TEST_LOCATION );
// <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
// </svg>
DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION );
-
- // Batch Image visual
- propertyMap.Clear();
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
- propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
- Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
- batchImageVisual.SetSize( visualSize );
- DALI_TEST_EQUALS( batchImageVisual.GetSize(), visualSize, TEST_LOCATION );
- batchImageVisual.GetNaturalSize( naturalSize );
- DALI_TEST_EQUALS( naturalSize, Vector2( 80.0f, 160.0f ), TEST_LOCATION );
-
END_TEST;
}
END_TEST;
}
-
-int UtcDaliVisualGetPropertyMapBatchImageVisual(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualGetPropertyMapBatchImageVisual:" );
-
- VisualFactory factory = VisualFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
- propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
- propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 );
- propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 );
-
- Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( batchImageVisual );
-
- Property::Map resultMap;
- batchImageVisual.CreatePropertyMap( resultMap );
-
- // Check the property values from the returned map from visual
- Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
-
- value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
-
- value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == 20 );
-
- value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == 30 );
-
- END_TEST;
-}
-
-int UtcDaliVisualGetPropertyMapBatchImageVisualNoAtlas(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualGetPropertyMapBatchImageVisualNoAtlas:" );
-
- VisualFactory factory = VisualFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
- propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
-
- // Set the desired size to be larger than the atlas limit of 1024x1024.
- propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 2048 );
- propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 2048 );
-
- // Create the visual.
- Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
-
- DALI_TEST_CHECK( batchImageVisual );
-
- Actor actor = Actor::New();
- batchImageVisual.SetOnStage( actor );
-
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- END_TEST;
-}
END_TEST;
}
-
-int UtcDaliVisualFactoryGetBatchImageVisual1(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual1: Request a Batch Image visual with a Property::Map" );
-
- VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
- propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
-
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
-
- Actor actor = Actor::New();
-
- actor.SetSize( 200.0f, 200.0f );
- Stage::GetCurrent().Add( actor );
- visual.SetSize( Vector2( 200.0f, 200.0f ) );
-
- // Test SetOnStage().
- visual.SetOnStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- application.SendNotification();
- application.Render();
-
- // Test SetOffStage().
- visual.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
- END_TEST;
-}
-
-int UtcDaliVisualFactoryGetBatchImageVisual2(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual2: Request Batch Image visual from an Image Visual with batchingEnabled set" );
-
- VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- Property::Map propertyMap;
- // Create a normal Image Visual.
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- // Instruct the factory to change Image Visuals to Batch-Image Visuals.
- propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
-
- // Properties for the Batch-Image Visual.
- propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
-
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
-
- // Check that a Batch-Image visual was created instead of an Image visual.
- Property::Map resultMap;
- visual.CreatePropertyMap( resultMap );
-
- Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::IMAGE, TEST_LOCATION );
-
- Actor actor = Actor::New();
-
- actor.SetSize( 200.0f, 200.0f );
- Stage::GetCurrent().Add( actor );
- visual.SetSize( Vector2( 200.0f, 200.0f ) );
-
- // Test SetOnStage().
- visual.SetOnStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
-
- application.SendNotification();
- application.Render();
-
- // Test SetOffStage().
- visual.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
- END_TEST;
-}
-
-int UtcDaliVisualFactoryGetBatchImageVisual3(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual3: Create an ImageView that uses a batched visual internally" );
-
- VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- // Create a property-map that enables batching.
- Property::Map propertyMap;
- propertyMap.Insert( Dali::Toolkit::ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
- propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
-
- // Create an ImageView, passing the property-map in to instruct it to use batching.
- Toolkit::ImageView imageView = Toolkit::ImageView::New();
- imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, propertyMap );
-
- imageView.SetSize( 200.0f, 200.0f );
- Stage::GetCurrent().Add( imageView );
-
- END_TEST;
-}
# For Open Source DALi API Reference
ALIASES += SINCE_1_0="@since 1.0"
ALIASES += SINCE_1_1="@since 1.1"
-ALIASES += SINCE_1_2="@since 1.2"
ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 1.0"
ALIASES += DEPRECATED_1_1="@deprecated Deprecated since 1.1"
-ALIASES += DEPRECATED_1_2="@deprecated Deprecated since 1.2"
ALIASES += PLATFORM=""
ALIASES += PRIVLEVEL_PLATFORM=""
-#ifndef DALI_TOOLKIT_H
-#define DALI_TOOLKIT_H
+#ifndef __DALI_TOOLKIT_H__
+#define __DALI_TOOLKIT_H__
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
#include <dali-toolkit/public-api/enums.h>
#include <dali-toolkit/public-api/toolkit-property-index-ranges.h>
-#endif // DALI_TOOLKIT_H
+#endif // __DALI_TOOLKIT_H__
if(!mCurrentGesturedActor)
{
- DALI_LOG_ERROR("Gesture detected, but no hit actor\n");
+ DALI_LOG_ERROR("Gesture detected, but no hit actor");
}
}
if(!mCurrentGesturedActor)
{
- DALI_LOG_ERROR("no more gestured actor\n");
+ DALI_LOG_ERROR("no more gestured actor");
}
}
else
{
Actor* contentActor = NULL; // Using a pointer as SetupContent assigns the new Actor to this.
bool imageFileExists = false;
- Property::Index visualIndex = Toolkit::Button::Property::SELECTED_STATE_IMAGE;
if ( selectedState == SelectedState || selectedState == DisabledSelectedState )
{
mUnselectedColor = color;
contentActor = &mUnselectedContent;
imageFileExists = !GetUnselectedImageFilename().empty();
- visualIndex = Toolkit::Button::Property::UNSELECTED_STATE_IMAGE;
}
if ( contentActor )
{
// If there is no existing content, create a new actor to use for flat color.
Actor placementActor = Actor::New();
- Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
- Toolkit::Visual::Base visual;
+ Toolkit::VisualFactory rendererFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base colorRenderer;
Property::Map map;
map[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::COLOR;
map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
- visual = visualFactory.CreateVisual( map );
-
- RegisterVisual( visualIndex, placementActor, visual );
- visual.SetOnStage( placementActor );
+ colorRenderer = rendererFactory.CreateVisual( map );
+ colorRenderer.SetOnStage( placementActor );
SetupContent( *contentActor, placementActor ); //
contentActor->SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
$(toolkit_src_dir)/visuals/svg/svg-visual.cpp \
$(toolkit_src_dir)/visuals/mesh/mesh-visual.cpp \
$(toolkit_src_dir)/visuals/primitive/primitive-visual.cpp \
- $(toolkit_src_dir)/visuals/image/batch-image-visual.cpp \
$(toolkit_src_dir)/controls/alignment/alignment-impl.cpp \
$(toolkit_src_dir)/controls/bloom-view/bloom-view-impl.cpp \
$(toolkit_src_dir)/controls/bubble-effect/bubble-emitter-impl.cpp \
{
const Dali::Vector3 DEFAULT_GRAB_HANDLE_RELATIVE_SIZE( 1.25f, 1.5f, 1.0f );
const Dali::Vector3 DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE( 1.25f, 1.5f, 1.0f );
-const Dali::Vector3 ACTIVE_LAYER_ANCHOR_POINT( 0.5f, 0.5f, 0.5f );
const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color. TODO: due some problems, maybe with the blending function in the text clipping, the color is fully opaque.
const float CURSOR_WIDTH = 1.f; ///< The cursor's width in pixels.
-const float POPUP_PADDING = 2.f; ///< Padding space between the highlight box and the text's popup.
+/**
+ * structure to hold coordinates of each quad, which will make up the mesh.
+ */
+struct QuadCoordinates
+{
+ /**
+ * Default constructor
+ */
+ QuadCoordinates()
+ {
+ }
+
+ /**
+ * Constructor
+ * @param[in] x1 left co-ordinate
+ * @param[in] y1 top co-ordinate
+ * @param[in] x2 right co-ordinate
+ * @param[in] y2 bottom co-ordinate
+ */
+ QuadCoordinates(float x1, float y1, float x2, float y2)
+ : min(x1, y1),
+ max(x2, y2)
+ {
+ }
-typedef Dali::Vector<Dali::Vector4> QuadContainer;
+ Dali::Vector2 min; ///< top-left (minimum) position of quad
+ Dali::Vector2 max; ///< bottom-right (maximum) position of quad
+};
+
+typedef std::vector<QuadCoordinates> QuadContainer;
/**
* @brief Takes a bounding rectangle in the local coordinates of an actor and returns the world coordinates Bounding Box.
grabDisplacementX( 0.f ),
grabDisplacementY( 0.f ),
active( false ),
- horizontallyVisible( false ),
- verticallyVisible( false ),
+ visible( false ),
pressed( false ),
verticallyFlippedPreferred( false ),
horizontallyFlipped( false ),
- verticallyFlipped( false ),
- verticallyFlippedOnTouch( false )
+ verticallyFlipped( false )
{
}
float lineHeight; ///< Not the handle height
float grabDisplacementX;
float grabDisplacementY;
- bool active : 1;
- bool horizontallyVisible : 1;
- bool verticallyVisible : 1;
- bool pressed : 1;
+ bool active : 1;
+ bool visible : 1;
+ bool pressed : 1;
bool verticallyFlippedPreferred : 1; ///< Whether the handle is preferred to be vertically flipped.
bool horizontallyFlipped : 1; ///< Whether the handle has been horizontally flipped.
bool verticallyFlipped : 1; ///< Whether the handle has been vertically flipped.
- bool verticallyFlippedOnTouch : 1; ///< Whether the handle is vertically flipped on touch.
};
struct PopupImpl
mCursorBlinkDuration( 0.0f ),
mCursorWidth( CURSOR_WIDTH ),
mHandleScrolling( HANDLE_TYPE_COUNT ),
- mHandleReleased( HANDLE_TYPE_COUNT ),
mScrollDirection( SCROLL_NONE ),
mScrollThreshold( SCROLL_THRESHOLD ),
mScrollSpeed( SCROLL_SPEED ),
mIsHandlePreviouslyCrossed( false ),
mNotifyEndOfScroll( false ),
mHorizontalScrollingEnabled( false ),
- mVerticalScrollingEnabled( false ),
- mSmoothHandlePanEnabled( false ),
- mIsHighlightBoxActive( false )
+ mVerticalScrollingEnabled( false )
{
mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
mHighlightShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
if( mPrimaryCursor )
{
const CursorImpl& cursor = mCursor[PRIMARY_CURSOR];
- mPrimaryCursorVisible = ( ( mControlSize.width - ( cursor.position.x + mCursorWidth ) > -Math::MACHINE_EPSILON_1000 ) &&
- ( cursor.position.x > -Math::MACHINE_EPSILON_1000 ) &&
- ( mControlSize.height - ( cursor.position.y + cursor.cursorHeight ) > -Math::MACHINE_EPSILON_1000 ) &&
- ( cursor.position.y > -Math::MACHINE_EPSILON_1000 ) );
+ mPrimaryCursorVisible = ( ( cursor.position.x + mCursorWidth <= mControlSize.width ) &&
+ ( cursor.position.x >= 0.f ) &&
+ ( cursor.position.y + cursor.cursorHeight <= mControlSize.height ) &&
+ ( cursor.position.y >= 0.f ) );
if( mPrimaryCursorVisible )
{
mPrimaryCursor.SetPosition( cursor.position.x,
if( mSecondaryCursor )
{
const CursorImpl& cursor = mCursor[SECONDARY_CURSOR];
- mSecondaryCursorVisible = ( ( mControlSize.width - ( cursor.position.x + mCursorWidth ) > -Math::MACHINE_EPSILON_1000 ) &&
- ( cursor.position.x > -Math::MACHINE_EPSILON_1000 ) &&
- ( mControlSize.height - ( cursor.position.y + cursor.cursorHeight ) > -Math::MACHINE_EPSILON_1000 ) &&
- ( cursor.position.y > -Math::MACHINE_EPSILON_1000 ) );
+ mSecondaryCursorVisible = ( ( cursor.position.x + mCursorWidth <= mControlSize.width ) &&
+ ( cursor.position.x >= 0.f ) &&
+ ( cursor.position.y + cursor.cursorHeight <= mControlSize.height ) &&
+ ( cursor.position.y >= 0.f ) );
if( mSecondaryCursorVisible )
{
mSecondaryCursor.SetPosition( cursor.position.x,
// Show or hide the grab handle
HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
bool newGrabHandlePosition = false;
- grabHandle.horizontallyVisible = false;
- grabHandle.verticallyVisible = false;
if( grabHandle.active )
{
- grabHandle.horizontallyVisible = ( ( mControlSize.width - ( grabHandle.position.x + floor( 0.5f * mCursorWidth ) ) > -Math::MACHINE_EPSILON_1000 ) &&
- ( grabHandle.position.x > -Math::MACHINE_EPSILON_1000 ) );
- grabHandle.verticallyVisible = ( ( ( mControlSize.height - grabHandle.lineHeight ) - grabHandle.position.y > -Math::MACHINE_EPSILON_1000 ) &&
- ( grabHandle.position.y > -Math::MACHINE_EPSILON_1000 ) );
+ const bool isVisible = ( ( grabHandle.position.x + floor( 0.5f * mCursorWidth ) <= mControlSize.width ) &&
+ ( grabHandle.position.x >= 0.f ) &&
+ ( grabHandle.position.y <= mControlSize.height - grabHandle.lineHeight ) &&
+ ( grabHandle.position.y >= 0.f ) );
- const bool isVisible = grabHandle.horizontallyVisible && grabHandle.verticallyVisible;
if( isVisible )
{
CreateGrabHandle();
HandleImpl& secondary = mHandle[ RIGHT_SELECTION_HANDLE ];
bool newPrimaryHandlePosition = false;
bool newSecondaryHandlePosition = false;
-
- primary.horizontallyVisible = ( ( mControlSize.width - primary.position.x > -Math::MACHINE_EPSILON_1000 ) &&
- ( primary.position.x > -Math::MACHINE_EPSILON_1000 ) );
- primary.verticallyVisible = ( ( ( mControlSize.height - primary.lineHeight ) - primary.position.y > -Math::MACHINE_EPSILON_1000 ) &&
- ( primary.position.y + ( primary.verticallyFlipped ? 0.f : primary.lineHeight ) > -Math::MACHINE_EPSILON_1000 ) );
- secondary.horizontallyVisible = ( ( mControlSize.width - secondary.position.x > -Math::MACHINE_EPSILON_1000 ) &&
- ( secondary.position.x > -Math::MACHINE_EPSILON_1000 ) );
- secondary.verticallyVisible = ( ( ( mControlSize.height - secondary.lineHeight ) - secondary.position.y > -Math::MACHINE_EPSILON_1000 ) &&
- ( secondary.position.y + ( secondary.verticallyFlipped ? 0.f : secondary.lineHeight ) > -Math::MACHINE_EPSILON_1000 ) );
-
- const bool primaryVisible = primary.horizontallyVisible && primary.verticallyVisible;
- const bool secondaryVisible = secondary.horizontallyVisible && secondary.verticallyVisible;
-
if( primary.active || secondary.active )
{
- if( primaryVisible || secondaryVisible )
+ const bool isPrimaryVisible = ( ( primary.position.x <= mControlSize.width ) &&
+ ( primary.position.x >= 0.f ) &&
+ ( primary.position.y <= mControlSize.height - primary.lineHeight ) &&
+ ( primary.position.y >= 0.f ) );
+ const bool isSecondaryVisible = ( ( secondary.position.x <= mControlSize.width ) &&
+ ( secondary.position.x >= 0.f ) &&
+ ( secondary.position.y <= mControlSize.height - secondary.lineHeight ) &&
+ ( secondary.position.y >= 0.f ) );
+
+ if( isPrimaryVisible || isSecondaryVisible )
{
CreateSelectionHandles();
- if( primaryVisible )
+ if( isPrimaryVisible )
{
SetSelectionHandlePosition( LEFT_SELECTION_HANDLE );
newPrimaryHandlePosition = true;
}
- if( secondaryVisible )
+ if( isSecondaryVisible )
{
SetSelectionHandlePosition( RIGHT_SELECTION_HANDLE );
if( primary.actor )
{
- primary.actor.SetVisible( primaryVisible );
+ primary.actor.SetVisible( isPrimaryVisible );
}
if( secondary.actor )
{
- secondary.actor.SetVisible( secondaryVisible );
+ secondary.actor.SetVisible( isSecondaryVisible );
}
+ CreateHighlight();
+ UpdateHighlight();
}
else
{
{
secondary.actor.Unparent();
}
- }
-
- if( mIsHighlightBoxActive )
- {
- CreateHighlight();
- UpdateHighlight();
- }
- else
- {
if( mHighlightActor )
{
mHighlightActor.Unparent();
SetupActiveLayerPropertyNotifications();
}
- if( mActiveCopyPastePopup &&
- ( primaryVisible || secondaryVisible ) )
+ if( mActiveCopyPastePopup )
{
ShowPopup();
mPopupSetNewPosition = true;
void ShowPopup()
{
- if( !mCopyPastePopup.actor )
+ if ( !mCopyPastePopup.actor )
{
return;
}
mCopyPastePopup.actor.ShowPopup();
}
- float CalculateVerticalPopUpPosition( float halfHeight, bool preferBelow )
- {
- float yPosition = 0.f;
-
- const HandleImpl& primaryHandle = mHandle[LEFT_SELECTION_HANDLE];
- const HandleImpl& secondaryHandle = mHandle[RIGHT_SELECTION_HANDLE];
- const HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
-
- if( primaryHandle.active || secondaryHandle.active )
- {
- // The origin of the decorator's coordinate system in world coords.
- const Vector3 originWorldCoords = mActiveLayer.GetCurrentWorldPosition() - mActiveLayer.GetCurrentSize() * ACTIVE_LAYER_ANCHOR_POINT;
-
- if( preferBelow )
- {
- // Find out if there is enough space for the popup at the bottom.
- const float primaryBelowY = primaryHandle.position.y + primaryHandle.lineHeight + primaryHandle.size.height;
- const float secondaryBelowY = secondaryHandle.position.y + secondaryHandle.lineHeight + secondaryHandle.size.height;
-
- float maxY = std::max( primaryBelowY, secondaryBelowY );
-
- yPosition = halfHeight + maxY;
-
- if( originWorldCoords.y + yPosition + halfHeight > mBoundingBox.w )
- {
- // Does not fit below.
-
- // Try to fit first below the non active handle. Otherwise above the active handle.
- if( RIGHT_SELECTION_HANDLE == mHandleReleased )
- {
- if( primaryBelowY < secondaryBelowY )
- {
- yPosition = halfHeight + primaryBelowY;
- }
- else
- {
- yPosition = primaryHandle.position.y - primaryHandle.size.height - halfHeight;
- }
- }
- else if( LEFT_SELECTION_HANDLE == mHandleReleased )
- {
- if( secondaryBelowY < primaryBelowY )
- {
- yPosition = halfHeight + secondaryBelowY;
- }
- else
- {
- yPosition = secondaryHandle.position.y - secondaryHandle.size.height - halfHeight;
- }
- }
-
- // Check the handle is whithin the decoration box.
- if( originWorldCoords.y + yPosition < mBoundingBox.y )
- {
- yPosition = mBoundingBox.y - originWorldCoords.y + halfHeight;
- }
-
- if( originWorldCoords.y + yPosition > mBoundingBox.w )
- {
- yPosition = mBoundingBox.w - originWorldCoords.y - halfHeight;
- }
- }
- } // preferBelow
- else
- {
- // Find out if there is enough space for the popup at the top.
- const float primaryTopY = primaryHandle.position.y - primaryHandle.size.height;
- const float secondaryTopY = secondaryHandle.position.y - secondaryHandle.size.height;
-
- float minY = std::min( primaryTopY, secondaryTopY );
-
- yPosition = -halfHeight + minY;
- } // !preferBelow
- } // ( primaryHandle.active || secondaryHandle.active )
- else if( grabHandle.active )
- {
- if( preferBelow )
- {
- yPosition = halfHeight + grabHandle.lineHeight + grabHandle.size.height + grabHandle.position.y;
- }
- else
- {
- yPosition = -halfHeight + grabHandle.position.y - POPUP_PADDING;
- }
- }
-
- return yPosition;
- }
-
- void ConstrainPopupPosition( const Vector3& popupHalfSize )
- {
- // Check if the popup is within the boundaries of the decoration box.
-
- // Check first the horizontal dimension. If is not within the boundaries, it calculates the offset.
-
- // The origin of the decorator's coordinate system in world coords.
- const Vector3 originWorldCoords = mActiveLayer.GetCurrentWorldPosition() - mActiveLayer.GetCurrentSize() * ACTIVE_LAYER_ANCHOR_POINT;
-
- // The popup's position in world coords.
- Vector3 popupPositionWorldCoords = originWorldCoords + mCopyPastePopup.position;
-
- if( popupPositionWorldCoords.x - popupHalfSize.width < mBoundingBox.x )
- {
- mCopyPastePopup.position.x += mBoundingBox.x - ( popupPositionWorldCoords.x - popupHalfSize.width );
- }
- else if( popupPositionWorldCoords.x + popupHalfSize.width > mBoundingBox.z )
- {
- mCopyPastePopup.position.x += mBoundingBox.z - ( popupPositionWorldCoords.x + popupHalfSize.width );
- }
-
- // Check the vertical dimension. If the popup doesn't fit above the handles, it looks for a valid position below.
- if( popupPositionWorldCoords.y - popupHalfSize.height < mBoundingBox.y )
- {
- mCopyPastePopup.position.y = CalculateVerticalPopUpPosition( popupHalfSize.height, true ); // true -> prefer to set the popup's position below.
- }
- }
-
- void SetPopupPosition( Actor actor )
+ void DeterminePositionPopup()
{
if( !mActiveCopyPastePopup )
{
}
// Retrieves the popup's size after relayout.
- const Vector3 popupSize( mCopyPastePopup.actor.GetRelayoutSize( Dimension::WIDTH ), mCopyPastePopup.actor.GetRelayoutSize( Dimension::HEIGHT ), 0.0f );
- const Vector3 popupHalfSize = popupSize * 0.5f;
+ const Vector3 popupSize = Vector3( mCopyPastePopup.actor.GetRelayoutSize( Dimension::WIDTH ), mCopyPastePopup.actor.GetRelayoutSize( Dimension::HEIGHT ), 0.0f );
if( mPopupSetNewPosition )
{
const HandleImpl& primaryHandle = mHandle[LEFT_SELECTION_HANDLE];
const HandleImpl& secondaryHandle = mHandle[RIGHT_SELECTION_HANDLE];
- const HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
+ const CursorImpl& cursor = mCursor[PRIMARY_CURSOR];
if( primaryHandle.active || secondaryHandle.active )
{
+ // Calculates the popup's position if selection handles are active.
const float minHandleXPosition = std::min( primaryHandle.position.x, secondaryHandle.position.x );
const float maxHandleXPosition = std::max( primaryHandle.position.x, secondaryHandle.position.x );
+ const float maxHandleHeight = std::max( primaryHandle.size.height, secondaryHandle.size.height );
mCopyPastePopup.position.x = minHandleXPosition + ( ( maxHandleXPosition - minHandleXPosition ) * 0.5f );
-
- const float primaryY = -popupHalfSize.height + primaryHandle.position.y - ( primaryHandle.verticallyFlipped ? primaryHandle.size.height : POPUP_PADDING );
- const float secondaryY = -popupHalfSize.height + secondaryHandle.position.y - ( secondaryHandle.verticallyFlipped ? secondaryHandle.size.height : POPUP_PADDING );
-
- mCopyPastePopup.position.y = std::min( primaryY, secondaryY );
+ mCopyPastePopup.position.y = -0.5f * popupSize.height - maxHandleHeight + std::min( primaryHandle.position.y, secondaryHandle.position.y );
}
- else if( grabHandle.active )
+ else
{
- mCopyPastePopup.position.x = grabHandle.position.x;
-
- mCopyPastePopup.position.y = -popupHalfSize.height + grabHandle.position.y - ( grabHandle.verticallyFlipped ? grabHandle.size.height : POPUP_PADDING );
+ // Calculates the popup's position if the grab handle is active.
+ const HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
+ if( grabHandle.verticallyFlipped )
+ {
+ mCopyPastePopup.position = Vector3( cursor.position.x, -0.5f * popupSize.height - grabHandle.size.height + cursor.position.y, 0.0f );
+ }
+ else
+ {
+ mCopyPastePopup.position = Vector3( cursor.position.x, -0.5f * popupSize.height + cursor.position.y, 0.0f );
+ }
}
- } // mPopupSetNewPosition
-
- // It may change the popup's position to fit within the decoration box.
- ConstrainPopupPosition( popupHalfSize );
+ }
- SetUpPopupPositionNotifications( popupHalfSize );
+ // Checks if there is enough space above the text control. If not it places the popup under it.
+ GetConstrainedPopupPosition( mCopyPastePopup.position, popupSize * AnchorPoint::CENTER, mActiveLayer, mBoundingBox );
- // Prevent pixel mis-alignment by rounding down.
- mCopyPastePopup.position.x = floorf( mCopyPastePopup.position.x );
- mCopyPastePopup.position.y = floorf( mCopyPastePopup.position.y );
+ SetUpPopupPositionNotifications();
mCopyPastePopup.actor.SetPosition( mCopyPastePopup.position );
mPopupSetNewPosition = false;
}
+ void PopupRelayoutComplete( Actor actor )
+ {
+ // Size negotiation for CopyPastePopup complete so can get the size and constrain position within bounding box.
+
+ DeterminePositionPopup();
+ }
+
void CreateCursor( Control& cursor, const Vector4& color )
{
cursor = Control::New();
mHighlightActor.SetPosition( mHighlightPosition.x,
mHighlightPosition.y );
- const unsigned int numberOfQuads = mHighlightQuadList.Count();
+ const unsigned int numberOfQuads = mHighlightQuadList.size();
if( 0u != numberOfQuads )
{
// Set the size of the highlighted text to the actor.
unsigned int v = 0u;
// Traverse all quads.
- for( Vector<Vector4>::ConstIterator it = mHighlightQuadList.Begin(),
- endIt = mHighlightQuadList.End();
+ for( std::vector<QuadCoordinates>::iterator it = mHighlightQuadList.begin(),
+ endIt = mHighlightQuadList.end();
it != endIt;
++it, v += 4u )
{
- const Vector4& quad = *it;
+ QuadCoordinates& quad = *it;
Vector2 vertex;
// top-left (v+0)
- vertex.x = quad.x - offsetX;
- vertex.y = quad.y - offsetY;
+ vertex.x = quad.min.x - offsetX;
+ vertex.y = quad.min.y - offsetY;
vertices.PushBack( vertex );
// top-right (v+1)
- vertex.x = quad.z - offsetX;
- vertex.y = quad.y - offsetY;
+ vertex.x = quad.max.x - offsetX;
+ vertex.y = quad.min.y - offsetY;
vertices.PushBack( vertex );
// bottom-left (v+2)
- vertex.x = quad.x - offsetX;
- vertex.y = quad.w - offsetY;
+ vertex.x = quad.min.x - offsetX;
+ vertex.y = quad.max.y - offsetY;
vertices.PushBack( vertex );
// bottom-right (v+3)
- vertex.x = quad.z - offsetX;
- vertex.y = quad.w - offsetY;
+ vertex.x = quad.max.x - offsetX;
+ vertex.y = quad.max.y - offsetY;
vertices.PushBack( vertex );
// triangle A (3, 1, 0)
}
}
- mHighlightQuadList.Clear();
+ mHighlightQuadList.clear();
if( mHighlightRenderer )
{
const float x = handle.globalPosition.x + handle.grabDisplacementX;
const float y = handle.globalPosition.y + handle.grabDisplacementY + 0.5f * handle.lineHeight;
- const float yVerticallyFlippedCorrected = y - ( handle.verticallyFlippedOnTouch ? handle.lineHeight : 0.f );
+ const float yVerticallyFlippedCorrected = y - ( handle.verticallyFlipped ? handle.lineHeight : 0.f );
if( ( Gesture::Started == gesture.state ) ||
( Gesture::Continuing == gesture.state ) )
if( PointState::DOWN == state )
{
primarySelectionHandle.pressed = true;
- primarySelectionHandle.verticallyFlippedOnTouch = primarySelectionHandle.verticallyFlipped;
}
else if( ( PointState::UP == state ) ||
( PointState::INTERRUPTED == state ) )
primarySelectionHandle.pressed = false;
mIsHandlePreviouslyCrossed = mIsHandleCurrentlyCrossed;
mIsHandlePanning = false;
- mHandleReleased = LEFT_SELECTION_HANDLE;
}
SetHandleImage( LEFT_SELECTION_HANDLE );
if( PointState::DOWN == state )
{
secondarySelectionHandle.pressed = true;
- secondarySelectionHandle.verticallyFlippedOnTouch = secondarySelectionHandle.verticallyFlipped;
}
else if( ( PointState::UP == state ) ||
( PointState::INTERRUPTED == state ) )
secondarySelectionHandle.pressed = false;
mIsHandlePreviouslyCrossed = mIsHandleCurrentlyCrossed;
mIsHandlePanning = false;
- mHandleReleased = RIGHT_SELECTION_HANDLE;
}
SetHandleImage( RIGHT_SELECTION_HANDLE );
// Vertical notifications.
// Disconnect any previous connected callback.
- if( mHandleVerticalLessThanNotification )
+ if( mVerticalLessThanNotification )
{
- mHandleVerticalLessThanNotification.NotifySignal().Disconnect( this, &Decorator::Impl::HandleResetPosition );
- mActiveLayer.RemovePropertyNotification( mHandleVerticalLessThanNotification );
+ mVerticalLessThanNotification.NotifySignal().Disconnect( this, &Decorator::Impl::HandleResetPosition );
+ mActiveLayer.RemovePropertyNotification( mVerticalLessThanNotification );
}
- if( mHandleVerticalGreaterThanNotification )
+ if( mVerticalGreaterThanNotification )
{
- mHandleVerticalGreaterThanNotification.NotifySignal().Disconnect( this, &Decorator::Impl::HandleResetPosition );
- mActiveLayer.RemovePropertyNotification( mHandleVerticalGreaterThanNotification );
+ mVerticalGreaterThanNotification.NotifySignal().Disconnect( this, &Decorator::Impl::HandleResetPosition );
+ mActiveLayer.RemovePropertyNotification( mVerticalGreaterThanNotification );
}
const HandleImpl& grabHandle = mHandle[GRAB_HANDLE];
if( grabHandle.verticallyFlipped )
{
// The grab handle is vertically flipped. Never is going to exceed the bottom edje of the display.
- mHandleVerticalGreaterThanNotification.Reset();
+ mVerticalGreaterThanNotification.Reset();
// The vertical distance from the center of the active layer to the top edje of the display.
const float topHeight = 0.5f * mControlSize.height - grabHandle.position.y + grabHandle.size.height;
- mHandleVerticalLessThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
- LessThanCondition( mBoundingBox.y + topHeight ) );
+ mVerticalLessThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
+ LessThanCondition( mBoundingBox.y + topHeight ) );
// Notifies the change from false to true and from true to false.
- mHandleVerticalLessThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
+ mVerticalLessThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
// Connects the signals with the callbacks.
- mHandleVerticalLessThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
+ mVerticalLessThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
}
else
{
// The grab handle is not vertically flipped. Never is going to exceed the top edje of the display.
- mHandleVerticalLessThanNotification.Reset();
+ mVerticalLessThanNotification.Reset();
// The vertical distance from the center of the active layer to the bottom edje of the display.
const float bottomHeight = -0.5f * mControlSize.height + grabHandle.position.y + grabHandle.lineHeight + grabHandle.size.height;
- mHandleVerticalGreaterThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
- GreaterThanCondition( mBoundingBox.w - bottomHeight ) );
+ mVerticalGreaterThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
+ GreaterThanCondition( mBoundingBox.w - bottomHeight ) );
// Notifies the change from false to true and from true to false.
- mHandleVerticalGreaterThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
+ mVerticalGreaterThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
// Connects the signals with the callbacks.
- mHandleVerticalGreaterThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
+ mVerticalGreaterThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
}
}
else // The selection handles are active
if( primaryHandle.verticallyFlipped && secondaryHandle.verticallyFlipped )
{
// Both selection handles are vertically flipped. Never are going to exceed the bottom edje of the display.
- mHandleVerticalGreaterThanNotification.Reset();
+ mVerticalGreaterThanNotification.Reset();
// The vertical distance from the center of the active layer to the top edje of the display.
const float topHeight = 0.5f * mControlSize.height + std::max( -primaryHandle.position.y + primaryHandle.size.height, -secondaryHandle.position.y + secondaryHandle.size.height );
- mHandleVerticalLessThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
- LessThanCondition( mBoundingBox.y + topHeight ) );
+ mVerticalLessThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
+ LessThanCondition( mBoundingBox.y + topHeight ) );
// Notifies the change from false to true and from true to false.
- mHandleVerticalLessThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
+ mVerticalLessThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
// Connects the signals with the callbacks.
- mHandleVerticalLessThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
+ mVerticalLessThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
}
else if( !primaryHandle.verticallyFlipped && !secondaryHandle.verticallyFlipped )
{
// Both selection handles aren't vertically flipped. Never are going to exceed the top edje of the display.
- mHandleVerticalLessThanNotification.Reset();
+ mVerticalLessThanNotification.Reset();
// The vertical distance from the center of the active layer to the bottom edje of the display.
const float bottomHeight = -0.5f * mControlSize.height + std::max( primaryHandle.position.y + primaryHandle.lineHeight + primaryHandle.size.height,
secondaryHandle.position.y + secondaryHandle.lineHeight + secondaryHandle.size.height );
- mHandleVerticalGreaterThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
- GreaterThanCondition( mBoundingBox.w - bottomHeight ) );
+ mVerticalGreaterThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
+ GreaterThanCondition( mBoundingBox.w - bottomHeight ) );
// Notifies the change from false to true and from true to false.
- mHandleVerticalGreaterThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
+ mVerticalGreaterThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
// Connects the signals with the callbacks.
- mHandleVerticalGreaterThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
+ mVerticalGreaterThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
}
else
{
-primaryHandle.position.y + primaryHandle.size.height :
-secondaryHandle.position.y + secondaryHandle.size.height );
- mHandleVerticalLessThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
- LessThanCondition( mBoundingBox.y + topHeight ) );
+ mVerticalLessThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
+ LessThanCondition( mBoundingBox.y + topHeight ) );
// Notifies the change from false to true and from true to false.
- mHandleVerticalLessThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
+ mVerticalLessThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
// Connects the signals with the callbacks.
- mHandleVerticalLessThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
+ mVerticalLessThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
// The vertical distance from the center of the active layer to the bottom edje of the display.
const float bottomHeight = -0.5f * mControlSize.height + ( primaryHandle.verticallyFlipped ?
secondaryHandle.position.y + secondaryHandle.lineHeight + secondaryHandle.size.height :
primaryHandle.position.y + primaryHandle.lineHeight + primaryHandle.size.height );
- mHandleVerticalGreaterThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
- GreaterThanCondition( mBoundingBox.w - bottomHeight ) );
+ mVerticalGreaterThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
+ GreaterThanCondition( mBoundingBox.w - bottomHeight ) );
// Notifies the change from false to true and from true to false.
- mHandleVerticalGreaterThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
+ mVerticalGreaterThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
// Connects the signals with the callbacks.
- mHandleVerticalGreaterThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
+ mVerticalGreaterThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
}
}
// Horizontal notifications.
// Disconnect any previous connected callback.
- if( mHandleHorizontalLessThanNotification )
+ if( mHorizontalLessThanNotification )
{
- mHandleHorizontalLessThanNotification.NotifySignal().Disconnect( this, &Decorator::Impl::HandleResetPosition );
- mActiveLayer.RemovePropertyNotification( mHandleHorizontalLessThanNotification );
+ mHorizontalLessThanNotification.NotifySignal().Disconnect( this, &Decorator::Impl::HandleResetPosition );
+ mActiveLayer.RemovePropertyNotification( mHorizontalLessThanNotification );
}
- if( mHandleHorizontalGreaterThanNotification )
+ if( mHorizontalGreaterThanNotification )
{
- mHandleHorizontalGreaterThanNotification.NotifySignal().Disconnect( this, &Decorator::Impl::HandleResetPosition );
- mActiveLayer.RemovePropertyNotification( mHandleHorizontalGreaterThanNotification );
+ mHorizontalGreaterThanNotification.NotifySignal().Disconnect( this, &Decorator::Impl::HandleResetPosition );
+ mActiveLayer.RemovePropertyNotification( mHorizontalGreaterThanNotification );
}
if( primaryHandle.active || secondaryHandle.active )
const float leftWidth = 0.5f * mControlSize.width + std::max( -primaryHandle.position.x + primaryHandle.size.width,
-secondaryHandle.position.x + secondaryHandle.size.width );
- mHandleHorizontalLessThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_X,
- LessThanCondition( mBoundingBox.x + leftWidth ) );
+ mHorizontalLessThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_X,
+ LessThanCondition( mBoundingBox.x + leftWidth ) );
// Notifies the change from false to true and from true to false.
- mHandleHorizontalLessThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
+ mHorizontalLessThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
// Connects the signals with the callbacks.
- mHandleHorizontalLessThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
+ mHorizontalLessThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
// The horizontal distance from the center of the active layer to the right edje of the display.
const float rightWidth = -0.5f * mControlSize.width + std::max( primaryHandle.position.x + primaryHandle.size.width,
secondaryHandle.position.x + secondaryHandle.size.width );
- mHandleHorizontalGreaterThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_X,
- GreaterThanCondition( mBoundingBox.z - rightWidth ) );
+ mHorizontalGreaterThanNotification = mActiveLayer.AddPropertyNotification( Actor::Property::WORLD_POSITION_X,
+ GreaterThanCondition( mBoundingBox.z - rightWidth ) );
// Notifies the change from false to true and from true to false.
- mHandleHorizontalGreaterThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
+ mHorizontalGreaterThanNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
// Connects the signals with the callbacks.
- mHandleHorizontalGreaterThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
+ mHorizontalGreaterThanNotification.NotifySignal().Connect( this, &Decorator::Impl::HandleResetPosition );
}
}
// Popup
- float AlternatePopUpPositionRelativeToCursor( bool topBottom )
+ float AlternatePopUpPositionRelativeToCursor()
{
float alternativePosition = 0.0f;
- const float halfPopupHeight = 0.5f * mCopyPastePopup.actor.GetRelayoutSize( Dimension::HEIGHT );
+ const float popupHeight = mCopyPastePopup.actor.GetRelayoutSize( Dimension::HEIGHT );
const HandleImpl& primaryHandle = mHandle[LEFT_SELECTION_HANDLE];
const HandleImpl& secondaryHandle = mHandle[RIGHT_SELECTION_HANDLE];
if( primaryHandle.active || secondaryHandle.active )
{
- float handleY = 0.f;
- float maxHandleHeight = 0.f;
-
- const bool primaryVisible = primaryHandle.horizontallyVisible && primaryHandle.verticallyVisible;
- const bool secondaryVisible = secondaryHandle.horizontallyVisible && secondaryHandle.verticallyVisible;
-
- if( primaryVisible && secondaryVisible )
- {
- handleY = std::max( primaryHandle.position.y, secondaryHandle.position.y );
- maxHandleHeight = std::max( primaryHandle.size.height, secondaryHandle.size.height );
- }
- else if( primaryVisible && !secondaryVisible )
- {
- handleY = primaryHandle.position.y;
- maxHandleHeight = primaryHandle.size.height;
- }
- else if( !primaryVisible && secondaryVisible )
- {
- handleY = secondaryHandle.position.y;
- maxHandleHeight = secondaryHandle.size.height;
- }
-
- alternativePosition = handleY + ( topBottom ? halfPopupHeight + maxHandleHeight + cursor.lineHeight : -halfPopupHeight - maxHandleHeight );
+ const float maxHandleHeight = std::max( primaryHandle.size.height, secondaryHandle.size.height );
+ alternativePosition = 0.5f * popupHeight + cursor.lineHeight + maxHandleHeight + std::min( primaryHandle.position.y, secondaryHandle.position.y );
}
else
{
- alternativePosition = cursor.position.y + ( topBottom ? halfPopupHeight + grabHandle.size.height + cursor.lineHeight : -halfPopupHeight - grabHandle.size.height );
+ alternativePosition = 0.5f * popupHeight + cursor.lineHeight + grabHandle.size.height + cursor.position.y;
}
return alternativePosition;
}
- void PopUpLeavesTopBoundary( PropertyNotification& source )
+ void PopUpLeavesVerticalBoundary( PropertyNotification& source )
{
- const float popupHeight = mCopyPastePopup.actor.GetRelayoutSize( Dimension::HEIGHT );
+ float alternativeYPosition = 0.0f;
+ // todo use AlternatePopUpPositionRelativeToSelectionHandles() if text is highlighted
+ // if can't be positioned above, then position below row.
+ alternativeYPosition = AlternatePopUpPositionRelativeToCursor();
- // Sets the position of the popup below.
- mCopyPastePopup.actor.SetY( floorf( CalculateVerticalPopUpPosition( 0.5f * popupHeight, true ) ) );
+ mCopyPastePopup.actor.SetY( alternativeYPosition );
}
- void PopUpLeavesBottomBoundary( PropertyNotification& source )
+ void SetUpPopupPositionNotifications()
{
+ // Note Property notifications ignore any set anchor point so conditions must allow for this. Default is Top Left.
+
+ // Exceeding vertical boundary
+
const float popupHeight = mCopyPastePopup.actor.GetRelayoutSize( Dimension::HEIGHT );
- // Sets the position of the popup above.
- mCopyPastePopup.actor.SetY( floorf( CalculateVerticalPopUpPosition( 0.5f * popupHeight, false ) ) );
+ PropertyNotification verticalExceedNotification = mCopyPastePopup.actor.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
+ OutsideCondition( mBoundingBox.y + popupHeight * 0.5f,
+ mBoundingBox.w - popupHeight * 0.5f ) );
+
+ verticalExceedNotification.NotifySignal().Connect( this, &Decorator::Impl::PopUpLeavesVerticalBoundary );
}
- void SetUpPopupPositionNotifications( const Vector3& popupHalfSize )
+ void GetConstrainedPopupPosition( Vector3& requiredPopupPosition, const Vector3& popupDistanceFromAnchorPoint, Actor parent, const Vector4& boundingRectangleWorld )
{
- // Disconnect any previous connected callback.
- if( mPopupTopExceedNotification )
+ DALI_ASSERT_DEBUG ( "Popup parent not on stage" && parent.OnStage() )
+
+ // Parent must already by added to Stage for these Get calls to work
+ const Vector3 parentWorldPositionLeftAnchor = parent.GetCurrentWorldPosition() - parent.GetCurrentSize() * parent.GetCurrentAnchorPoint();
+ const Vector3 popupWorldPosition = parentWorldPositionLeftAnchor + requiredPopupPosition; // Parent World position plus popup local position gives World Position
+
+ // Calculate distance to move popup (in local space) so fits within the boundary
+ float xOffSetToKeepWithinBounds = 0.0f;
+ if( popupWorldPosition.x - popupDistanceFromAnchorPoint.x < boundingRectangleWorld.x )
{
- mPopupTopExceedNotification.NotifySignal().Disconnect( this, &Decorator::Impl::PopUpLeavesTopBoundary );
- mCopyPastePopup.actor.RemovePropertyNotification( mPopupTopExceedNotification );
+ xOffSetToKeepWithinBounds = boundingRectangleWorld.x - ( popupWorldPosition.x - popupDistanceFromAnchorPoint.x );
}
-
- if( mPopupBottomExceedNotification )
+ else if( popupWorldPosition.x + popupDistanceFromAnchorPoint.x > boundingRectangleWorld.z )
{
- mPopupBottomExceedNotification.NotifySignal().Disconnect( this, &Decorator::Impl::PopUpLeavesBottomBoundary );
- mCopyPastePopup.actor.RemovePropertyNotification( mPopupBottomExceedNotification );
+ xOffSetToKeepWithinBounds = boundingRectangleWorld.z - ( popupWorldPosition.x + popupDistanceFromAnchorPoint.x );
}
- // Note Property notifications ignore any set anchor point so conditions must allow for this. Default is Top Left.
-
- // Exceeding vertical boundary
-
- mPopupTopExceedNotification = mCopyPastePopup.actor.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
- LessThanCondition( mBoundingBox.y + popupHalfSize.height ) );
-
- mPopupBottomExceedNotification = mCopyPastePopup.actor.AddPropertyNotification( Actor::Property::WORLD_POSITION_Y,
- GreaterThanCondition( mBoundingBox.w - popupHalfSize.height ) );
+ // Ensure initial display of Popup is in alternative position if can not fit above. As Property notification will be a frame behind.
+ if( popupWorldPosition.y - popupDistanceFromAnchorPoint.y < boundingRectangleWorld.y )
+ {
+ requiredPopupPosition.y = AlternatePopUpPositionRelativeToCursor();
+ }
- // Notifies the change from false to true and from true to false.
- mPopupTopExceedNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
- mPopupBottomExceedNotification.SetNotifyMode( PropertyNotification::NotifyOnChanged );
+ requiredPopupPosition.x = requiredPopupPosition.x + xOffSetToKeepWithinBounds;
- mPopupTopExceedNotification.NotifySignal().Connect( this, &Decorator::Impl::PopUpLeavesTopBoundary );
- mPopupBottomExceedNotification.NotifySignal().Connect( this, &Decorator::Impl::PopUpLeavesBottomBoundary );
+ // Prevent pixel mis-alignment by rounding down.
+ requiredPopupPosition.x = floor( requiredPopupPosition.x );
+ requiredPopupPosition.y = floor( requiredPopupPosition.y );
}
void SetHandleImage( HandleType handleType, HandleImageType handleImageType, Dali::Image image )
Timer mCursorBlinkTimer; ///< Timer to signal cursor to blink
Timer mScrollTimer; ///< Timer used to scroll the text when the grab handle is moved close to the edges.
- Layer mActiveLayer; ///< Layer for active handles and alike that ensures they are above all else.
- PropertyNotification mHandleVerticalLessThanNotification; ///< Notifies when the 'y' coord of the active layer is less than a given value.
- PropertyNotification mHandleVerticalGreaterThanNotification; ///< Notifies when the 'y' coord of the active layer is grater than a given value.
- PropertyNotification mHandleHorizontalLessThanNotification; ///< Notifies when the 'x' coord of the active layer is less than a given value.
- PropertyNotification mHandleHorizontalGreaterThanNotification; ///< Notifies when the 'x' coord of the active layer is grater than a given value.
- PropertyNotification mPopupTopExceedNotification; ///< Notifies when the popup leaves the bounding box through the top.
- PropertyNotification mPopupBottomExceedNotification; ///< Notifies when the popup leaves the bounding box through the bottom.
+ Layer mActiveLayer; ///< Layer for active handles and alike that ensures they are above all else.
+ PropertyNotification mVerticalLessThanNotification; ///< Notifies when the 'y' coord of the active layer is less than a given value.
+ PropertyNotification mVerticalGreaterThanNotification; ///< Notifies when the 'y' coord of the active layer is grater than a given value.
+ PropertyNotification mHorizontalLessThanNotification; ///< Notifies when the 'x' coord of the active layer is less than a given value.
+ PropertyNotification mHorizontalGreaterThanNotification; ///< Notifies when the 'x' coord of the active layer is grater than a given value.
Control mPrimaryCursor;
Control mSecondaryCursor;
PropertyBuffer mQuadVertices;
Geometry mQuadGeometry;
- QuadContainer mHighlightQuadList; ///< Sub-selections that combine to create the complete selection highlight.
+ QuadContainer mHighlightQuadList; ///< Sub-selections that combine to create the complete selection highlight
Vector4 mBoundingBox; ///< The bounding box in world coords.
Vector4 mHighlightColor; ///< Color of the highlight
float mCursorBlinkDuration;
float mCursorWidth; ///< The width of the cursors in pixels.
HandleType mHandleScrolling; ///< The handle which is scrolling.
- HandleType mHandleReleased; ///< The last handle released.
ScrollDirection mScrollDirection; ///< The direction of the scroll.
float mScrollThreshold; ///< Defines a square area inside the control, close to the edge. A cursor entering this area will trigger scroll events.
float mScrollSpeed; ///< The scroll speed in pixels per second.
bool mHorizontalScrollingEnabled : 1; ///< Whether the horizontal scrolling is enabled.
bool mVerticalScrollingEnabled : 1; ///< Whether the vertical scrolling is enabled.
bool mSmoothHandlePanEnabled : 1; ///< Whether to pan smoothly the handles.
- bool mIsHighlightBoxActive : 1; ///< Whether the highlight box is active.
};
DecoratorPtr Decorator::New( ControllerInterface& controller,
mImpl->mFlipRightSelectionHandleDirection = right;
}
-void Decorator::AddHighlight( unsigned int index, const Vector4& quad )
+void Decorator::AddHighlight( float x1, float y1, float x2, float y2 )
{
- *( mImpl->mHighlightQuadList.Begin() + index ) = quad;
+ mImpl->mHighlightQuadList.push_back( QuadCoordinates(x1, y1, x2, y2) );
}
void Decorator::SetHighLightBox( const Vector2& position, const Size& size )
void Decorator::ClearHighlights()
{
- mImpl->mHighlightQuadList.Clear();
+ mImpl->mHighlightQuadList.clear();
mImpl->mHighlightPosition = Vector2::ZERO;
}
-void Decorator::ResizeHighlightQuads( unsigned int numberOfQuads )
-{
- mImpl->mHighlightQuadList.Resize( numberOfQuads );
-}
-
void Decorator::SetHighlightColor( const Vector4& color )
{
mImpl->mHighlightColor = color;
return mImpl->mHighlightColor;
}
-void Decorator::SetHighlightActive( bool active )
-{
- mImpl->mIsHighlightBoxActive = active;
-}
-
-bool Decorator::IsHighlightActive() const
-{
- return mImpl->mIsHighlightBoxActive;
-}
-
void Decorator::SetTextDepth( int textDepth )
{
mImpl->mTextDepth = textDepth;
bool Decorator::IsPopupActive() const
{
- return mImpl->mActiveCopyPastePopup;
+ return mImpl->mActiveCopyPastePopup ;
}
void Decorator::SetEnabledPopupButtons( TextSelectionPopup::Buttons& enabledButtonsBitMask )
mImpl->mCopyPastePopup.actor.SetName("mCopyPastePopup");
#endif
mImpl->mCopyPastePopup.actor.SetAnchorPoint( AnchorPoint::CENTER );
- mImpl->mCopyPastePopup.actor.OnRelayoutSignal().Connect( mImpl, &Decorator::Impl::SetPopupPosition ); // Position popup after size negotiation
+ mImpl->mCopyPastePopup.actor.OnRelayoutSignal().Connect( mImpl, &Decorator::Impl::PopupRelayoutComplete ); // Position popup after size negotiation
}
mImpl->mCopyPastePopup.actor.EnableButtons( mImpl->mEnabledPopupButtons );
/**
* @brief Adds a quad to the existing selection highlights. Vertices are in decorator's coordinates.
*
- * @param[in] index Position in the vector where to add the quad.
- * @param[in] quad The quad. The 'x' and 'y' coordinates store the min 'x' and min 'y'. The 'z' and 'w' coordinates store the max 'x' and max 'y'.
+ * @param[in] x1 The top-left x position.
+ * @param[in] y1 The top-left y position.
+ * @param[in] x2 The bottom-right x position.
+ * @param[in] y3 The bottom-right y position.
*/
- void AddHighlight( unsigned int index, const Vector4& quad );
+ void AddHighlight( float x1, float y1, float x2, float y2 );
/**
* @brief Sets the min 'x,y' coordinates and the size of the highlighted box.
void ClearHighlights();
/**
- * @brief Reserves space for the highlight quads.
- *
- * @param[in] numberOfQuads The expected number of quads.
- */
- void ResizeHighlightQuads( unsigned int numberOfQuads );
-
- /**
* @brief Sets the selection highlight color.
*
* @param[in] color The color to use.
const Vector4& GetHighlightColor() const;
/**
- * @brief Sets whether the highlight is active.
- *
- * @param[in] active Whether the highlight is active.
- */
- void SetHighlightActive( bool active );
-
- /**
- * @brief Retrieves whether the highlight is active.
- *
- * @return @e true if the highlight is active, @e false otherwise.
- */
- bool IsHighlightActive() const;
-
- /**
* @brief Sets into the decorator the depth used to render the text.
*
* @param[in] depth The text's depth.
default:
{
- DALI_LOG_WARNING( "Unknown renderer type: %d\n", renderingType );
+ DALI_LOG_WARNING( "Unknown renderer type: %d", renderingType );
break;
}
}
mUpdateGrabHandlePosition( false ),
mUpdateLeftSelectionPosition( false ),
mUpdateRightSelectionPosition( false ),
- mIsLeftHandleSelected( false ),
mUpdateHighlightBox( false ),
mScrollAfterUpdatePosition( false ),
mScrollAfterDelete( false ),
GetCursorPosition( mEventData->mRightSelectionPosition,
rightHandleInfo );
- if( mEventData->mScrollAfterUpdatePosition && ( mEventData->mIsLeftHandleSelected ? mEventData->mUpdateLeftSelectionPosition : mEventData->mUpdateRightSelectionPosition ) )
+ if( mEventData->mScrollAfterUpdatePosition && mEventData->mUpdateLeftSelectionPosition )
{
- CursorInfo& info = mEventData->mIsLeftHandleSelected ? leftHandleInfo : rightHandleInfo;
+ const Vector2 currentCursorPosition( leftHandleInfo.primaryPosition.x, leftHandleInfo.lineOffset );
+ ScrollToMakePositionVisible( currentCursorPosition, leftHandleInfo.lineHeight );
+ }
- const Vector2 currentCursorPosition( info.primaryPosition.x, info.lineOffset );
- ScrollToMakePositionVisible( currentCursorPosition, info.lineHeight );
+ if( mEventData->mScrollAfterUpdatePosition && mEventData->mUpdateRightSelectionPosition )
+ {
+ const Vector2 currentCursorPosition( rightHandleInfo.primaryPosition.x, rightHandleInfo.lineOffset );
+ ScrollToMakePositionVisible( currentCursorPosition, rightHandleInfo.lineHeight );
}
}
return;
}
- const bool isHorizontalScrollEnabled = mEventData->mDecorator->IsHorizontalScrollEnabled();
- const bool isVerticalScrollEnabled = mEventData->mDecorator->IsVerticalScrollEnabled();
+ int state = event.p1.mInt;
- if( !isHorizontalScrollEnabled && !isVerticalScrollEnabled )
+ if( ( Gesture::Started == state ) ||
+ ( Gesture::Continuing == state ) )
{
- // Nothing to do if scrolling is not enabled.
- return;
- }
-
- const int state = event.p1.mInt;
-
- switch( state )
- {
- case Gesture::Started:
- {
- // Will remove the cursor, handles or text's popup, ...
- ChangeState( EventData::TEXT_PANNING );
- break;
- }
- case Gesture::Continuing:
+ if( mEventData->mDecorator )
{
const Vector2& layoutSize = mVisualModel->GetLayoutSize();
const Vector2 currentScroll = mScrollPosition;
- if( isHorizontalScrollEnabled )
+ if( mEventData->mDecorator->IsHorizontalScrollEnabled() )
{
const float displacementX = event.p2.mFloat;
mScrollPosition.x += displacementX;
ClampHorizontalScroll( layoutSize );
}
- if( isVerticalScrollEnabled )
+ if( mEventData->mDecorator->IsVerticalScrollEnabled() )
{
const float displacementY = event.p3.mFloat;
mScrollPosition.y += displacementY;
}
mEventData->mDecorator->UpdatePositions( mScrollPosition - currentScroll );
- break;
- }
- case Gesture::Finished:
- case Gesture::Cancelled: // FALLTHROUGH
- {
- // Will go back to the previous state to show the cursor, handles, the text's popup, ...
- ChangeState( mEventData->mPreviousState );
- break;
}
- default:
- break;
}
}
// Updates the decorator if the soft handle panning is enabled. It triggers a relayout in the decorator and the new position of the handle is set.
mEventData->mDecoratorUpdated = isSmoothHandlePanEnabled;
-
- // Will define the order to scroll the text to match the handle position.
- mEventData->mIsLeftHandleSelected = true;
}
else if( Event::RIGHT_SELECTION_HANDLE_EVENT == event.type )
{
// Updates the decorator if the soft handle panning is enabled. It triggers a relayout in the decorator and the new position of the handle is set.
mEventData->mDecoratorUpdated = isSmoothHandlePanEnabled;
-
- // Will define the order to scroll the text to match the handle position.
- mEventData->mIsLeftHandleSelected = false;
}
} // end ( HANDLE_PRESSED == state )
else if( ( HANDLE_RELEASED == state ) ||
mEventData->mUpdateHighlightBox = true;
mEventData->mUpdateLeftSelectionPosition = true;
- mEventData->mUpdateRightSelectionPosition = true;
if( handleStopScrolling || isSmoothHandlePanEnabled )
{
mEventData->mUpdateHighlightBox = true;
mEventData->mUpdateRightSelectionPosition = true;
- mEventData->mUpdateLeftSelectionPosition = true;
if( handleStopScrolling || isSmoothHandlePanEnabled )
{
const Length numberOfCharactersEnd = *( charactersPerGlyphBuffer + glyphEnd );
bool splitEndGlyph = ( glyphStart != glyphEnd ) && ( numberOfCharactersEnd > 1u ) && HasLigatureMustBreak( mLogicalModel->GetScript( selectionEndMinusOne ) );
- // The number of quads of the selection box.
- const unsigned int numberOfQuads = 1u + ( glyphEnd - glyphStart ) + ( ( numberOfLines > 1u ) ? 2u * numberOfLines : 0u );
- mEventData->mDecorator->ResizeHighlightQuads( numberOfQuads );
-
- // Count the actual number of quads.
- unsigned int actualNumberOfQuads = 0u;
- Vector4 quad;
-
// Traverse the glyphs.
for( GlyphIndex index = glyphStart; index <= glyphEnd; ++index )
{
// Calculate the number of characters selected.
const Length numberOfCharacters = ( glyphStart == glyphEnd ) ? ( selectionEnd - selectionStart ) : ( numberOfCharactersStart - interGlyphIndex );
- quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x + glyphAdvance * static_cast<float>( isCurrentRightToLeft ? ( numberOfCharactersStart - interGlyphIndex - numberOfCharacters ) : interGlyphIndex );
- quad.y = selectionBoxInfo->lineOffset;
- quad.z = quad.x + static_cast<float>( numberOfCharacters ) * glyphAdvance;
- quad.w = selectionBoxInfo->lineOffset + selectionBoxInfo->lineHeight;
+ const float xPosition = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x + glyphAdvance * static_cast<float>( isCurrentRightToLeft ? ( numberOfCharactersStart - interGlyphIndex - numberOfCharacters ) : interGlyphIndex );
+ const float xPositionAdvance = xPosition + static_cast<float>( numberOfCharacters ) * glyphAdvance;
+ const float yPosition = selectionBoxInfo->lineOffset;
// Store the min and max 'x' for each line.
- selectionBoxInfo->minX = std::min( selectionBoxInfo->minX, quad.x );
- selectionBoxInfo->maxX = std::max( selectionBoxInfo->maxX, quad.z );
+ selectionBoxInfo->minX = std::min( selectionBoxInfo->minX, xPosition );
+ selectionBoxInfo->maxX = std::max( selectionBoxInfo->maxX, xPositionAdvance );
- mEventData->mDecorator->AddHighlight( actualNumberOfQuads, quad );
- ++actualNumberOfQuads;
+ mEventData->mDecorator->AddHighlight( xPosition,
+ yPosition,
+ xPositionAdvance,
+ yPosition + selectionBoxInfo->lineHeight );
splitStartGlyph = false;
continue;
const Length numberOfCharacters = numberOfCharactersEnd - interGlyphIndex;
- quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x + ( isCurrentRightToLeft ? ( glyphAdvance * static_cast<float>( numberOfCharacters ) ) : 0.f );
- quad.y = selectionBoxInfo->lineOffset;
- quad.z = quad.x + static_cast<float>( interGlyphIndex ) * glyphAdvance;
- quad.w = quad.y + selectionBoxInfo->lineHeight;
+ const float xPosition = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x + ( isCurrentRightToLeft ? ( glyphAdvance * static_cast<float>( numberOfCharacters ) ) : 0.f );
+ const float xPositionAdvance = xPosition + static_cast<float>( interGlyphIndex ) * glyphAdvance;
+ const float yPosition = selectionBoxInfo->lineOffset;
// Store the min and max 'x' for each line.
- selectionBoxInfo->minX = std::min( selectionBoxInfo->minX, quad.x );
- selectionBoxInfo->maxX = std::max( selectionBoxInfo->maxX, quad.z );
+ selectionBoxInfo->minX = std::min( selectionBoxInfo->minX, xPosition );
+ selectionBoxInfo->maxX = std::max( selectionBoxInfo->maxX, xPositionAdvance );
- mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
- quad );
- ++actualNumberOfQuads;
+ mEventData->mDecorator->AddHighlight( xPosition,
+ yPosition,
+ xPositionAdvance,
+ yPosition + selectionBoxInfo->lineHeight );
splitEndGlyph = false;
continue;
}
- quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x;
- quad.y = selectionBoxInfo->lineOffset;
- quad.z = quad.x + glyph.advance;
- quad.w = quad.y + selectionBoxInfo->lineHeight;
+ const float xPosition = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x;
+ const float xPositionAdvance = xPosition + glyph.advance;
+ const float yPosition = selectionBoxInfo->lineOffset;
// Store the min and max 'x' for each line.
- selectionBoxInfo->minX = std::min( selectionBoxInfo->minX, quad.x );
- selectionBoxInfo->maxX = std::max( selectionBoxInfo->maxX, quad.z );
+ selectionBoxInfo->minX = std::min( selectionBoxInfo->minX, xPosition );
+ selectionBoxInfo->maxX = std::max( selectionBoxInfo->maxX, xPositionAdvance );
- mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
- quad );
- ++actualNumberOfQuads;
+ mEventData->mDecorator->AddHighlight( xPosition,
+ yPosition,
+ xPositionAdvance,
+ yPosition + selectionBoxInfo->lineHeight );
// Whether to retrieve the next line.
if( index == lastGlyphOfLine )
const SelectionBoxInfo& info = *it;
// Update the size of the highlighted text.
- highLightSize.height += info.lineHeight;
+ highLightSize.height += selectionBoxInfo->lineHeight;
minHighlightX = std::min( minHighlightX, info.minX );
maxHighlightX = std::max( maxHighlightX, info.maxX );
}
if( boxifyBegin )
{
- quad.x = 0.f;
- quad.y = firstSelectionBoxLineInfo.lineOffset;
- quad.z = firstSelectionBoxLineInfo.minX;
- quad.w = firstSelectionBoxLineInfo.lineOffset + firstSelectionBoxLineInfo.lineHeight;
-
// Boxify at the beginning of the line.
- mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
- quad );
- ++actualNumberOfQuads;
+ mEventData->mDecorator->AddHighlight( 0.f,
+ firstSelectionBoxLineInfo.lineOffset,
+ firstSelectionBoxLineInfo.minX,
+ firstSelectionBoxLineInfo.lineOffset + firstSelectionBoxLineInfo.lineHeight );
// Update the size of the highlighted text.
minHighlightX = 0.f;
if( boxifyEnd )
{
- quad.x = firstSelectionBoxLineInfo.maxX;
- quad.y = firstSelectionBoxLineInfo.lineOffset;
- quad.z = mVisualModel->mControlSize.width;
- quad.w = firstSelectionBoxLineInfo.lineOffset + firstSelectionBoxLineInfo.lineHeight;
-
// Boxify at the end of the line.
- mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
- quad );
- ++actualNumberOfQuads;
+ mEventData->mDecorator->AddHighlight( firstSelectionBoxLineInfo.maxX,
+ firstSelectionBoxLineInfo.lineOffset,
+ mVisualModel->mControlSize.width,
+ firstSelectionBoxLineInfo.lineOffset + firstSelectionBoxLineInfo.lineHeight );
// Update the size of the highlighted text.
maxHighlightX = mVisualModel->mControlSize.width;
{
const SelectionBoxInfo& info = *it;
- quad.x = 0.f;
- quad.y = info.lineOffset;
- quad.z = info.minX;
- quad.w = info.lineOffset + info.lineHeight;
-
- mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
- quad );
- ++actualNumberOfQuads;
-
- quad.x = info.maxX;
- quad.y = info.lineOffset;
- quad.z = mVisualModel->mControlSize.width;
- quad.w = info.lineOffset + info.lineHeight;
+ mEventData->mDecorator->AddHighlight( 0.f,
+ info.lineOffset,
+ info.minX,
+ info.lineOffset + info.lineHeight );
- mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
- quad );
- ++actualNumberOfQuads;
+ mEventData->mDecorator->AddHighlight( info.maxX,
+ info.lineOffset,
+ mVisualModel->mControlSize.width,
+ info.lineOffset + info.lineHeight );
}
// Update the size of the highlighted text.
if( boxifyBegin )
{
- quad.x = 0.f;
- quad.y = lastSelectionBoxLineInfo.lineOffset;
- quad.z = lastSelectionBoxLineInfo.minX;
- quad.w = lastSelectionBoxLineInfo.lineOffset + lastSelectionBoxLineInfo.lineHeight;
-
// Boxify at the beginning of the line.
- mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
- quad );
- ++actualNumberOfQuads;
+ mEventData->mDecorator->AddHighlight( 0.f,
+ lastSelectionBoxLineInfo.lineOffset,
+ lastSelectionBoxLineInfo.minX,
+ lastSelectionBoxLineInfo.lineOffset + lastSelectionBoxLineInfo.lineHeight );
// Update the size of the highlighted text.
minHighlightX = 0.f;
if( boxifyEnd )
{
- quad.x = lastSelectionBoxLineInfo.maxX;
- quad.y = lastSelectionBoxLineInfo.lineOffset;
- quad.z = mVisualModel->mControlSize.width;
- quad.w = lastSelectionBoxLineInfo.lineOffset + lastSelectionBoxLineInfo.lineHeight;
-
// Boxify at the end of the line.
- mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
- quad );
- ++actualNumberOfQuads;
+ mEventData->mDecorator->AddHighlight( lastSelectionBoxLineInfo.maxX,
+ lastSelectionBoxLineInfo.lineOffset,
+ mVisualModel->mControlSize.width,
+ lastSelectionBoxLineInfo.lineOffset + lastSelectionBoxLineInfo.lineHeight );
// Update the size of the highlighted text.
maxHighlightX = mVisualModel->mControlSize.width;
}
}
- // Set the actual number of quads.
- mEventData->mDecorator->ResizeHighlightQuads( actualNumberOfQuads );
-
// Sets the highlight's size and position. In decorator's coords.
// The highlight's height has been calculated above (before 'boxifying' the highlight).
highLightSize.width = maxHighlightX - minHighlightX;
if( mEventData->mState != newState )
{
- mEventData->mPreviousState = mEventData->mState;
mEventData->mState = newState;
- switch( mEventData->mState )
+ if( EventData::INACTIVE == mEventData->mState )
+ {
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
+ mEventData->mDecorator->StopCursorBlink();
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
+ mEventData->mDecorator->SetPopupActive( false );
+ mEventData->mDecoratorUpdated = true;
+ HideClipboard();
+ }
+ else if( EventData::INTERRUPTED == mEventData->mState)
{
- case EventData::INACTIVE:
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
+ mEventData->mDecorator->SetPopupActive( false );
+ mEventData->mDecoratorUpdated = true;
+ HideClipboard();
+ }
+ else if( EventData::SELECTING == mEventData->mState )
+ {
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
+ mEventData->mDecorator->StopCursorBlink();
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, true );
+ mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, true );
+ if( mEventData->mGrabHandlePopupEnabled )
{
- mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
- mEventData->mDecorator->StopCursorBlink();
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
- mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHighlightActive( false );
- mEventData->mDecorator->SetPopupActive( false );
- mEventData->mDecoratorUpdated = true;
- HideClipboard();
- break;
+ SetPopupButtons();
+ mEventData->mDecorator->SetPopupActive( true );
}
- case EventData::INTERRUPTED:
+ mEventData->mDecoratorUpdated = true;
+ }
+ else if( EventData::EDITING == mEventData->mState )
+ {
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
+ if( mEventData->mCursorBlinkEnabled )
+ {
+ mEventData->mDecorator->StartCursorBlink();
+ }
+ // Grab handle is not shown until a tap is received whilst EDITING
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
+ if( mEventData->mGrabHandlePopupEnabled )
{
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
- mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHighlightActive( false );
mEventData->mDecorator->SetPopupActive( false );
- mEventData->mDecoratorUpdated = true;
- HideClipboard();
- break;
}
- case EventData::SELECTING:
+ mEventData->mDecoratorUpdated = true;
+ HideClipboard();
+ }
+ else if( EventData::EDITING_WITH_POPUP == mEventData->mState )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "EDITING_WITH_POPUP \n", newState );
+
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
+ if( mEventData->mCursorBlinkEnabled )
{
- mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
- mEventData->mDecorator->StopCursorBlink();
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
- mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, true );
- mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, true );
- mEventData->mDecorator->SetHighlightActive( true );
- if( mEventData->mGrabHandlePopupEnabled )
- {
- SetPopupButtons();
- mEventData->mDecorator->SetPopupActive( true );
- }
- mEventData->mDecoratorUpdated = true;
- break;
+ mEventData->mDecorator->StartCursorBlink();
}
- case EventData::EDITING:
+ if( mEventData->mSelectionEnabled )
{
- mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
- if( mEventData->mCursorBlinkEnabled )
- {
- mEventData->mDecorator->StartCursorBlink();
- }
- // Grab handle is not shown until a tap is received whilst EDITING
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHighlightActive( false );
- if( mEventData->mGrabHandlePopupEnabled )
- {
- mEventData->mDecorator->SetPopupActive( false );
- }
- mEventData->mDecoratorUpdated = true;
- HideClipboard();
- break;
}
- case EventData::EDITING_WITH_POPUP:
+ else
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "EDITING_WITH_POPUP \n", newState );
-
- mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
- if( mEventData->mCursorBlinkEnabled )
- {
- mEventData->mDecorator->StartCursorBlink();
- }
- if( mEventData->mSelectionEnabled )
- {
- mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHighlightActive( false );
- }
- else
- {
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
- }
- if( mEventData->mGrabHandlePopupEnabled )
- {
- SetPopupButtons();
- mEventData->mDecorator->SetPopupActive( true );
- }
- HideClipboard();
- mEventData->mDecoratorUpdated = true;
- break;
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
}
- case EventData::EDITING_WITH_GRAB_HANDLE:
+ if( mEventData->mGrabHandlePopupEnabled )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "EDITING_WITH_GRAB_HANDLE \n", newState );
+ SetPopupButtons();
+ mEventData->mDecorator->SetPopupActive( true );
+ }
+ HideClipboard();
+ mEventData->mDecoratorUpdated = true;
+ }
+ else if( EventData::EDITING_WITH_GRAB_HANDLE == mEventData->mState )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "EDITING_WITH_GRAB_HANDLE \n", newState );
- mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
- if( mEventData->mCursorBlinkEnabled )
- {
- mEventData->mDecorator->StartCursorBlink();
- }
- // Grab handle is not shown until a tap is received whilst EDITING
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
- mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHighlightActive( false );
- if( mEventData->mGrabHandlePopupEnabled )
- {
- mEventData->mDecorator->SetPopupActive( false );
- }
- mEventData->mDecoratorUpdated = true;
- HideClipboard();
- break;
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
+ if( mEventData->mCursorBlinkEnabled )
+ {
+ mEventData->mDecorator->StartCursorBlink();
}
- case EventData::SELECTION_HANDLE_PANNING:
+ // Grab handle is not shown until a tap is received whilst EDITING
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
+ mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
+ if( mEventData->mGrabHandlePopupEnabled )
{
- mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
- mEventData->mDecorator->StopCursorBlink();
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
- mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, true );
- mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, true );
- mEventData->mDecorator->SetHighlightActive( true );
- if( mEventData->mGrabHandlePopupEnabled )
- {
- mEventData->mDecorator->SetPopupActive( false );
- }
- mEventData->mDecoratorUpdated = true;
- break;
+ mEventData->mDecorator->SetPopupActive( false );
}
- case EventData::GRAB_HANDLE_PANNING:
+ mEventData->mDecoratorUpdated = true;
+ HideClipboard();
+ }
+ else if( EventData::SELECTION_HANDLE_PANNING == mEventData->mState )
+ {
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
+ mEventData->mDecorator->StopCursorBlink();
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, true );
+ mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, true );
+ if( mEventData->mGrabHandlePopupEnabled )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "GRAB_HANDLE_PANNING \n", newState );
+ mEventData->mDecorator->SetPopupActive( false );
+ }
+ mEventData->mDecoratorUpdated = true;
+ }
+ else if( EventData::GRAB_HANDLE_PANNING == mEventData->mState )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "GRAB_HANDLE_PANNING \n", newState );
- mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
- if( mEventData->mCursorBlinkEnabled )
- {
- mEventData->mDecorator->StartCursorBlink();
- }
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
- mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHighlightActive( false );
- if( mEventData->mGrabHandlePopupEnabled )
- {
- mEventData->mDecorator->SetPopupActive( false );
- }
- mEventData->mDecoratorUpdated = true;
- break;
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
+ if( mEventData->mCursorBlinkEnabled )
+ {
+ mEventData->mDecorator->StartCursorBlink();
}
- case EventData::EDITING_WITH_PASTE_POPUP:
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
+ mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
+ if( mEventData->mGrabHandlePopupEnabled )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "EDITING_WITH_PASTE_POPUP \n", newState );
-
- mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
- if( mEventData->mCursorBlinkEnabled )
- {
- mEventData->mDecorator->StartCursorBlink();
- }
-
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
- mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHighlightActive( false );
-
- if( mEventData->mGrabHandlePopupEnabled )
- {
- SetPopupButtons();
- mEventData->mDecorator->SetPopupActive( true );
- }
- HideClipboard();
- mEventData->mDecoratorUpdated = true;
- break;
+ mEventData->mDecorator->SetPopupActive( false );
}
- case EventData::TEXT_PANNING:
+ mEventData->mDecoratorUpdated = true;
+ }
+ else if( EventData::EDITING_WITH_PASTE_POPUP == mEventData->mState )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "EDITING_WITH_PASTE_POPUP \n", newState );
+
+ mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY );
+ if( mEventData->mCursorBlinkEnabled )
{
- mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
- mEventData->mDecorator->StopCursorBlink();
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
- if( mEventData->mDecorator->IsHandleActive( LEFT_SELECTION_HANDLE ) ||
- mEventData->mDecorator->IsHandleActive( RIGHT_SELECTION_HANDLE ) )
- {
- mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
- mEventData->mDecorator->SetHighlightActive( true );
- }
+ mEventData->mDecorator->StartCursorBlink();
+ }
- if( mEventData->mGrabHandlePopupEnabled )
- {
- mEventData->mDecorator->SetPopupActive( false );
- }
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
+ mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
+ mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
- mEventData->mDecoratorUpdated = true;
- break;
+ if( mEventData->mGrabHandlePopupEnabled )
+ {
+ SetPopupButtons();
+ mEventData->mDecorator->SetPopupActive( true );
}
+ HideClipboard();
+ mEventData->mDecoratorUpdated = true;
}
}
}
EDITING_WITH_GRAB_HANDLE,
EDITING_WITH_PASTE_POPUP,
GRAB_HANDLE_PANNING,
- SELECTION_HANDLE_PANNING,
- TEXT_PANNING
+ SELECTION_HANDLE_PANNING
};
EventData( DecoratorPtr decorator );
InputStyle mInputStyle; ///< The style to be set to the new inputed text.
- State mPreviousState; ///< Stores the current state before it's updated with the new one.
State mState; ///< Selection mode, edit mode etc.
CharacterIndex mPrimaryCursorPosition; ///< Index into logical model for primary cursor.
bool mUpdateGrabHandlePosition : 1; ///< True if the visual position of the grab handle must be recalculated.
bool mUpdateLeftSelectionPosition : 1; ///< True if the visual position of the left selection handle must be recalculated.
bool mUpdateRightSelectionPosition : 1; ///< True if the visual position of the right selection handle must be recalculated.
- bool mIsLeftHandleSelected : 1; ///< Whether is the left handle the one which is selected.
bool mUpdateHighlightBox : 1; ///< True if the text selection high light box must be updated.
bool mScrollAfterUpdatePosition : 1; ///< Whether to scroll after the cursor position is updated.
bool mScrollAfterDelete : 1; ///< Whether to scroll after delete characters.
}
else
{
- DALI_LOG_WARNING( "Attempted AutoScrolling on a non SINGLE_LINE_BOX, request ignored\n" );
+ DALI_LOG_WARNING( "Attempted AutoScrolling on a non SINGLE_LINE_BOX, request ignored" );
mImpl->mAutoScrollEnabled = false;
}
}
void Controller::UpdateAfterFontChange( const std::string& newDefaultFont )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::UpdateAfterFontChange\n");
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::UpdateAfterFontChange");
if( !mImpl->mFontDefaults->familyDefined ) // If user defined font then should not update when system font changes
{
{
if( !mImpl->mEventData->mPreEditFlag )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Entered PreEdit state\n" );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Entered PreEdit state" );
// Record the start of the pre-edit text
mImpl->mEventData->mPreEditStartPosition = mImpl->mEventData->mPrimaryCursorPosition;
{
if( !mCurrentRenderer )
{
- DALI_LOG_ERROR( "Trying to transition a cube transition without an image set\n" );
+ DALI_LOG_ERROR( "Trying to transition a cube transition without an image set" );
return;
}
Property::Value* color = propertyMap.Find( Toolkit::BorderVisual::Property::COLOR, COLOR_NAME );
if( !( color && color->Get(mBorderColor) ) )
{
- DALI_LOG_ERROR( "Fail to provide a border color to the BorderVisual object\n" );
+ DALI_LOG_ERROR( "Fail to provide a border color to the BorderVisual object" );
}
Property::Value* size = propertyMap.Find( Toolkit::BorderVisual::Property::SIZE, SIZE_NAME );
if( !( size && size->Get(mBorderSize) ) )
{
- DALI_LOG_ERROR( "Fail to provide a border size to the BorderVisual object\n" );
+ DALI_LOG_ERROR( "Fail to provide a border size to the BorderVisual object" );
}
Property::Value* antiAliasing = propertyMap.Find( Toolkit::BorderVisual::Property::ANTI_ALIASING, ANTI_ALIASING );
Property::Value* color = propertyMap.Find( Toolkit::ColorVisual::Property::MIX_COLOR, COLOR_NAME );
if( !( color && color->Get(mMixColor) ) )
{
- DALI_LOG_ERROR( "Fail to provide a color to the ColorVisual object\n" );
+ DALI_LOG_ERROR( "Fail to provide a color to the ColorVisual object" );
}
}
}
else
{
- DALI_LOG_ERROR( "Fail to provide valid properties to create a GradientVisual object\n" );
+ DALI_LOG_ERROR( "Fail to provide valid properties to create a GradientVisual object" );
}
}
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "batch-image-visual.h"
-
-// EXTERNAL HEADER
-#include <cstring> // for strncasecmp
-#include <dali/public-api/images/resource-image.h>
-#include <dali/public-api/images/native-image.h>
-#include <dali/integration-api/debug.h>
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
-#include <dali/public-api/images/pixel-data.h>
-#include <dali/public-api/rendering/texture.h>
-#include <dali/public-api/rendering/texture-set.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
-#include <dali/public-api/rendering/texture-set.h>
-
-// INTERNAL HEADER
-#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
-#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
-#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
-#include <dali-toolkit/internal/visuals/visual-base-impl.h>
-#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
-#include <dali-toolkit/internal/visuals/visual-string-constants.h>
-#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace
-{
-const char HTTP_URL[] = "http://";
-const char HTTPS_URL[] = "https://";
-
-// Properties:
-const char * const DESIRED_WIDTH( "desiredWidth" );
-const char * const DESIRED_HEIGHT( "desiredHeight" );
-
-const Vector4 FULL_TEXTURE_RECT( 0.f, 0.f, 1.f, 1.f );
-
-// The shader used for batched rendering. It uses interleaved data for
-// attributes. Limitation is that all batched renderers will share same set of uniforms.
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- attribute mediump vec2 aTexCoord;\n
- uniform mediump mat4 uMvpMatrix;\n
- varying mediump vec2 vTexCoord;\n
- \n
- void main()\n
- {\n
- vTexCoord = aTexCoord;\n
- gl_Position = uMvpMatrix * vec4( aPosition, 0.0, 1.0 );\n
- }\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform lowp vec4 uColor;\n
- uniform lowp float uAlphaBlending; // Set to 1.0 for conventional alpha blending; if pre-multiplied alpha blending, set to 0.0
- \n
- void main()\n
- {\n
- gl_FragColor = texture2D( sTexture, vTexCoord ) * vec4( uColor.rgb*max( uAlphaBlending, uColor.a ), uColor.a );\n
- }\n
-);
-
-} //unnamed namespace
-
-BatchImageVisual::BatchImageVisual( VisualFactoryCache& factoryCache, ImageAtlasManager& atlasManager )
- : Visual::Base( factoryCache ),
- mAtlasManager( atlasManager ),
- mDesiredSize()
-{
-}
-
-BatchImageVisual::~BatchImageVisual()
-{
-}
-
-void BatchImageVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
-{
- std::string oldImageUrl = mImageUrl;
- Property::Value* imageURLValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::URL, Dali::Toolkit::Internal::IMAGE_URL_NAME );
-
- if( imageURLValue )
- {
- imageURLValue->Get( mImageUrl );
-
- int desiredWidth = 0;
- Property::Value* desiredWidthValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH, DESIRED_WIDTH );
- if( desiredWidthValue )
- {
- desiredWidthValue->Get( desiredWidth );
- }
-
- int desiredHeight = 0;
- Property::Value* desiredHeightValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT, DESIRED_HEIGHT );
- if( desiredHeightValue )
- {
- desiredHeightValue->Get( desiredHeight );
- }
-
- mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
- }
-
- // Remove old renderer if exit.
- if( mImpl->mRenderer )
- {
- if( actor ) // Remove old renderer from actor.
- {
- actor.RemoveRenderer( mImpl->mRenderer );
- }
- if( !oldImageUrl.empty() ) // Clean old renderer from cache.
- {
- CleanCache( oldImageUrl );
- }
- }
-
- // If actor is on stage, create new renderer and apply to actor.
- if( actor && actor.OnStage() )
- {
- SetOnStage( actor );
- }
-}
-
-void BatchImageVisual::SetSize( const Vector2& size )
-{
- Visual::Base::SetSize( size );
-}
-
-void BatchImageVisual::GetNaturalSize( Vector2& naturalSize ) const
-{
- if( mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0 )
- {
- naturalSize.x = mDesiredSize.GetWidth();
- naturalSize.y = mDesiredSize.GetHeight();
- return;
- }
- else if( !mImageUrl.empty() )
- {
- ImageDimensions dimentions = ResourceImage::GetImageSize( mImageUrl );
- naturalSize.x = dimentions.GetWidth();
- naturalSize.y = dimentions.GetHeight();
- return;
- }
-
- naturalSize = Vector2::ZERO;
-}
-
-void BatchImageVisual::SetClipRect( const Rect<int>& clipRect )
-{
- Visual::Base::SetClipRect( clipRect );
-}
-
-void BatchImageVisual::InitializeRenderer( const std::string& imageUrl )
-{
- if( imageUrl.empty() )
- {
- return;
- }
-
- mImageUrl = imageUrl;
- mImpl->mRenderer.Reset();
- mAtlasRect = FULL_TEXTURE_RECT;
-
- if( !mImpl->mCustomShader &&
- ( strncasecmp( imageUrl.c_str(),HTTP_URL, sizeof( HTTP_URL ) -1 ) != 0 ) && // Ignore remote images
- ( strncasecmp( imageUrl.c_str(), HTTPS_URL, sizeof( HTTPS_URL ) -1 ) != 0 ) )
- {
- if( !mImpl->mRenderer )
- {
- TextureSet textureSet = mAtlasManager.Add(
- mAtlasRect,
- imageUrl,
- mDesiredSize );
-
- // If image doesn't fit the atlas, create new texture set with texture that
- // is used as whole.
- if( !textureSet )
- {
- BitmapLoader loader = BitmapLoader::New( imageUrl, mDesiredSize );
- loader.Load();
- Dali::PixelData pixelData = loader.GetPixelData();
- Texture texture = Texture::New( TextureType::TEXTURE_2D,
- pixelData.GetPixelFormat(),
- pixelData.GetWidth(),
- pixelData.GetHeight() );
- texture.Upload( pixelData );
- textureSet = TextureSet::New();
- textureSet.SetTexture( 0, texture );
- mAtlasRect = FULL_TEXTURE_RECT;
- }
-
- Geometry geometry = mFactoryCache.CreateBatchQuadGeometry( mAtlasRect );
- Shader shader( GetBatchShader( mFactoryCache ) );
- mImpl->mRenderer = Renderer::New( geometry, shader );
- mImpl->mRenderer.SetTextures( textureSet );
-
- // Turn batching on, to send message it must be on stage.
- mImpl->mRenderer.SetProperty( Dali::Renderer::Property::BATCHING_ENABLED, true );
- }
- mImpl->mFlags |= Impl::IS_FROM_CACHE;
- }
-}
-
-void BatchImageVisual::DoSetOnStage( Actor& actor )
-{
- if( !mImageUrl.empty() )
- {
- InitializeRenderer( mImageUrl );
- }
- // Turn batching on, to send message it must be on stage
- mImpl->mRenderer.SetProperty( Dali::Renderer::Property::BATCHING_ENABLED, true );
-}
-
-void BatchImageVisual::DoSetOffStage( Actor& actor )
-{
- actor.RemoveRenderer( mImpl->mRenderer );
-
- // If we own the image then make sure we release it when we go off stage
- if( !mImageUrl.empty() )
- {
- CleanCache( mImageUrl );
- }
- else
- {
- mImpl->mRenderer.Reset();
- }
-}
-
-void BatchImageVisual::DoCreatePropertyMap( Property::Map& map ) const
-{
- map.Clear();
- map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
-
- if( !mImageUrl.empty() )
- {
- map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl );
- map.Insert( Toolkit::ImageVisual::Property::BATCHING_ENABLED, true );
- map.Insert( Toolkit::ImageVisual::Property::DESIRED_WIDTH, mDesiredSize.GetWidth() );
- map.Insert( Toolkit::ImageVisual::Property::DESIRED_HEIGHT, mDesiredSize.GetHeight() );
- }
-}
-
-Shader BatchImageVisual::GetBatchShader( VisualFactoryCache& factoryCache )
-{
- Shader shader = factoryCache.GetShader( VisualFactoryCache::BATCH_IMAGE_SHADER );
- if( !shader )
- {
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- factoryCache.SaveShader( VisualFactoryCache::BATCH_IMAGE_SHADER, shader );
- }
- return shader;
-}
-
-void BatchImageVisual::CleanCache(const std::string& url)
-{
- TextureSet textureSet = mImpl->mRenderer.GetTextures();
- mImpl->mRenderer.Reset();
- if( mFactoryCache.CleanRendererCache( url ) )
- {
- mAtlasManager.Remove( textureSet, mAtlasRect );
- }
-}
-
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_TOOLKIT_INTERNAL_BATCH_IMAGE_VISUAL_H
-#define DALI_TOOLKIT_INTERNAL_BATCH_IMAGE_VISUAL_H
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL HEADER
-#include <dali-toolkit/internal/visuals/visual-base-impl.h>
-#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/images/resource-image.h>
-
-namespace Dali
-{
-namespace Toolkit
-{
-namespace Internal
-{
-
-class BatchImageVisual: public Visual::Base, public ConnectionTracker
-{
-public:
-
- /**
- * @brief Constructor.
- *
- * @param[in] factoryCache The VisualFactoryCache object
- * @param[in] atlasManager The atlasManager object
- */
- BatchImageVisual( VisualFactoryCache& factoryCache, ImageAtlasManager& atlasManager );
-
- /**
- * @brief A reference counted object may only be deleted by calling Unreference().
- */
- ~BatchImageVisual();
-
-public: // from Visual
-
- /**
- * @copydoc Visual::Base::SetSize
- */
- virtual void SetSize( const Vector2& size );
-
- /**
- * @copydoc Visual::Base::GetNaturalSize
- */
- virtual void GetNaturalSize( Vector2& naturalSize ) const;
-
- /**
- * @copydoc Visual::Base::SetClipRect
- */
- virtual void SetClipRect( const Rect<int>& clipRect );
-
- /**
- * @copydoc Visual::Base::CreatePropertyMap
- */
- virtual void DoCreatePropertyMap( Property::Map& map ) const;
-
-protected:
-
- /**
- * @copydoc Visua::Base::DoInitialize
- */
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
-
- /**
- * @copydoc Visual::Base::DoSetOnStage
- */
- virtual void DoSetOnStage( Actor& actor );
-
- /**
- * @copydoc Visual::Base::DoSetOffStage
- */
- virtual void DoSetOffStage( Actor& actor );
-
-private:
-
- /**
- * Get the batch image rendering shader.
- * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
- */
- static Shader GetBatchShader( VisualFactoryCache& factoryCache );
-
- /**
- * @brief Initializes the Dali::Renderer from an image url string
- *
- * @param[in] imageUrl The image url string to intialize this ImageVisual from
- */
- void InitializeRenderer( const std::string& imageUrl );
-
- /**
- * Clean the Visual from cache, and remove the image from atlas if it is not used anymore
- */
- void CleanCache( const std::string& url );
-
-private:
-
- ImageAtlasManager& mAtlasManager;
- Vector4 mAtlasRect;
- std::string mImageUrl;
- Dali::ImageDimensions mDesiredSize;
-};
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // DALI_TOOLKIT_INTERNAL_BATCH_IMAGE_VISUAL_H
const char * const IMAGE_DESIRED_WIDTH( "desiredWidth" );
const char * const IMAGE_DESIRED_HEIGHT( "desiredHeight" );
const char * const SYNCHRONOUS_LOADING( "synchronousLoading" );
-const char * const BATCHING_ENABLED( "batchingEnabled" );
// fitting modes
DALI_ENUM_TO_STRING_TABLE_BEGIN( FITTING_MODE )
}
}
+
void ImageVisual::DoSetOnStage( Actor& actor )
{
if( !mImageUrl.empty() )
{
if( !vertexShaderValue->Get( mVertexShader ) )
{
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string\n", CUSTOM_VERTEX_SHADER );
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string", CUSTOM_VERTEX_SHADER );
}
}
{
if( !fragmentShaderValue->Get( mFragmentShader ) )
{
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string\n", CUSTOM_FRAGMENT_SHADER );
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string", CUSTOM_FRAGMENT_SHADER );
}
}
int subdivideX;
if( !subdivideXValue->Get( subdivideX ) || subdivideX < 1 )
{
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1\n", CUSTOM_SUBDIVIDE_GRID_X );
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1", CUSTOM_SUBDIVIDE_GRID_X );
}
else
{
int subdivideY;
if( !subdivideYValue->Get( subdivideY ) || subdivideY < 1 )
{
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1\n", CUSTOM_SUBDIVIDE_GRID_Y );
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a value greater than 1", CUSTOM_SUBDIVIDE_GRID_Y );
}
else
{
{
if ( ! Scripting::GetBitmaskEnumerationProperty( *hintsValue, SHADER_HINT_TABLE, SHADER_HINT_TABLE_COUNT, mHints ) )
{
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a hint or an array of hint strings\n", CUSTOM_SHADER_HINTS );
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a hint or an array of hint strings", CUSTOM_SHADER_HINTS );
}
}
}
mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled());
mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex );
actor.AddRenderer( mImpl->mRenderer );
-
mImpl->mFlags |= Impl::IS_ON_STAGE;
}
* @param[in] actor The Actor the visual is applied to if, empty if the visual has not been applied to any Actor
* @param[in] propertyMap The properties for the requested Visual object.
*/
- virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap ) {}
+ virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap ) {};
protected:
return geometry;
}
-Geometry VisualFactoryCache::CreateBatchQuadGeometry( Vector4 texCoords )
-{
- const float halfWidth = 0.5f;
- const float halfHeight = 0.5f;
- struct QuadVertex {
- QuadVertex( const Vector2& vertexPosition, const Vector2& vertexTexCoords )
- : position( vertexPosition ),
- texCoords( vertexTexCoords )
- {}
- Vector2 position;
- Vector2 texCoords;
- };
-
- // special case, when texture takes whole space
- if( texCoords == Vector4::ZERO )
- {
- texCoords = Vector4(0.0f, 0.0f, 1.0f, 1.0f);
- }
-
- QuadVertex quadVertexData[6] =
- {
- QuadVertex( Vector2(-halfWidth, -halfHeight ), Vector2(texCoords.x, texCoords.y) ),
- QuadVertex( Vector2( halfWidth, -halfHeight ), Vector2(texCoords.z, texCoords.y) ),
- QuadVertex( Vector2(-halfWidth, halfHeight ), Vector2(texCoords.x, texCoords.w) ),
- QuadVertex( Vector2( halfWidth, -halfHeight ), Vector2(texCoords.z, texCoords.y) ),
- QuadVertex( Vector2(-halfWidth, halfHeight ), Vector2(texCoords.x, texCoords.w) ),
- QuadVertex( Vector2( halfWidth, halfHeight ), Vector2(texCoords.z, texCoords.w) ),
- };
-
- Property::Map vertexFormat;
- vertexFormat[ "aPosition" ] = Property::VECTOR2;
- vertexFormat[ "aTexCoord" ] = Property::VECTOR2;
- PropertyBuffer vertexBuffer = PropertyBuffer::New( vertexFormat );
- vertexBuffer.SetData( quadVertexData, 6 );
-
- // create geometry as normal, single quad
- Geometry geometry = Geometry::New();
- geometry.AddVertexBuffer( vertexBuffer );
- geometry.SetType( Geometry::TRIANGLES );
-
- return geometry;
-}
-
} // namespace Internal
} // namespace Toolkit
GRADIENT_SHADER_RADIAL_USER_SPACE,
GRADIENT_SHADER_RADIAL_BOUNDING_BOX,
IMAGE_SHADER,
- BATCH_IMAGE_SHADER,
NINE_PATCH_SHADER,
SVG_SHADER,
SHADER_TYPE_MAX = SVG_SHADER
*/
static Geometry CreateGridGeometry( Uint16Pair gridSize );
- /**
- * Create the batchable geometry
- * @param[in] texCoords The texture atlas rect coordinates
- * @return The created batchable geometry
- */
- static Geometry CreateBatchQuadGeometry( Vector4 texCoords );
-
public:
/**
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
-#include <dali-toolkit/internal/visuals/image/batch-image-visual.h>
namespace
{
DALI_ENUM_TO_STRING_TABLE_END( VISUAL_TYPE )
const char * const VISUAL_TYPE( "visualType" );
-const char * const BATCHING_ENABLED( "batchingEnabled" );
+
BaseHandle Create()
{
BaseHandle handle = Toolkit::VisualFactory::Get();
Visual::Base* visualPtr = NULL;
Property::Value* typeValue = propertyMap.Find( Toolkit::Visual::Property::TYPE, VISUAL_TYPE );
- Toolkit::Visual::Type visualType = Toolkit::Visual::IMAGE; // Default to IMAGE type.
+ Toolkit::Visual::Type visualType = Toolkit::Visual::IMAGE; // Default to IMAGE type
if( typeValue )
{
Scripting::GetEnumerationProperty( *typeValue, VISUAL_TYPE_TABLE, VISUAL_TYPE_TABLE_COUNT, visualType );
std::string imageUrl;
if( imageURLValue && imageURLValue->Get( imageUrl ) )
{
- Property::Value* batchingEnabledValue = propertyMap.Find( Toolkit::ImageVisual::Property::BATCHING_ENABLED, BATCHING_ENABLED );
- if( batchingEnabledValue )
- {
- bool batchingEnabled( false );
- batchingEnabledValue->Get( batchingEnabled );
- if( batchingEnabled )
- {
- CreateAtlasManager();
- visualPtr = new BatchImageVisual( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
- break;
- }
- }
- else if( NinePatchImage::IsNinePatchUrl( imageUrl ) )
+ if( NinePatchImage::IsNinePatchUrl( imageUrl ) )
{
visualPtr = new NPatchVisual( *( mFactoryCache.Get() ) );
}
visualPtr = new DebugVisual( *( mFactoryCache.Get() ) );
break;
}
-
}
if( visualPtr )
}
else
{
- DALI_LOG_ERROR( "Renderer type unknown\n" );
+ DALI_LOG_ERROR( "Renderer type unknown" );
}
return Toolkit::Visual::Base( visualPtr );
const char * const CUSTOM_SHADER_HINTS( "hints" );
// Image visual
-const char * const IMAGE_URL_NAME( "url" );
+const char * const IMAGE_URL_NAME("url");
const char * const ATLAS_RECT_UNIFORM_NAME ( "uAtlasRect" );
} // namespace Internal
{
/**
- * Struct used to store Visual within the control, index is a unique key for each visual.
- */
-struct RegisteredVisual
-{
- Property::Index index;
- Toolkit::Visual::Base visual;
- Actor placementActor;
-
- RegisteredVisual( Property::Index aIndex, Toolkit::Visual::Base &aVisual, Actor &aPlacementActor) : index(aIndex), visual(aVisual), placementActor(aPlacementActor) {}
-};
-
-/**
- * Finds visual in given array, returning true if found along with the iterator for that visual as a out parameter
- */
-bool FindVisual( Property::Index targetIndex, std::vector<RegisteredVisual>& visuals, std::vector<RegisteredVisual>::iterator& iter )
-{
- for ( iter = visuals.begin(); iter != visuals.end(); iter++ )
- {
- if ( (*iter).index == targetIndex )
- {
- return true;
- }
- }
- return false;
-}
-
-/**
* Creates control through type registry
*/
BaseHandle Create()
// Data
Control& mControlImpl;
- std::vector<RegisteredVisual> mVisuals; // Stores visuals needed by the control, non trivial type so std::vector used.
std::string mStyleName;
Toolkit::Visual::Base mBackgroundVisual; ///< The visual to render the background
Vector4 mBackgroundColor; ///< The color of the background visual
OnKeyboardEnter();
}
-void Control::RegisterVisual( Property::Index index, Actor placementActor, Toolkit::Visual::Base visual )
-{
- bool visualReplaced ( false );
- Actor actorToRegister; // Null actor, replaced if placement actor not Self
-
- if ( placementActor != Self() ) // Prevent increasing ref count if actor self
- {
- actorToRegister = placementActor;
- }
-
- if ( !mImpl->mVisuals.empty() )
- {
- std::vector<RegisteredVisual>::iterator iter;
- // Check if visual (index) is already registered. Replace if so.
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- (*iter).visual = visual;
- (*iter).placementActor = actorToRegister;
- visualReplaced = true;
- }
- }
-
- if ( !visualReplaced ) // New registration entry
- {
- RegisteredVisual newVisual = RegisteredVisual( index, visual, actorToRegister );
- mImpl->mVisuals.push_back( newVisual );
- }
-}
-
-void Control::UnregisterVisual( Property::Index index )
-{
- std::vector< RegisteredVisual >::iterator iter;
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- mImpl->mVisuals.erase( iter );
- }
-}
-
bool Control::OnAccessibilityActivated()
{
return false; // Accessibility activation is not handled by default
class StyleManager;
-namespace Visual
-{
-class Base;
-}
namespace Internal
{
/**
protected: // For derived classes to call
/**
- * @brief Register a visual by Property Index, linking an Actor to controlRenderer when required.
- * In the case of the visual being an actor or control deeming controlRenderer not required then controlRenderer should be an empty handle.
- * No parenting is done during registration, this should be done by derived class.
- *
- * @SINCE_1_2.0
- *
- * @param[in] index The Property index of the visual, used to reference visual
- * @param[in] placementActor The actor used to by the visual.
- * @param[in] visual The visual to register
- */
- void RegisterVisual( Property::Index index, Actor placementActor, Toolkit::Visual::Base visual );
-
- /**
- * @brief Erase the entry matching the given index from the list of registered visuals
- * @param[in] index The Property index of the visual, used to reference visual
- *
- * @SINCE_1_2.0
- */
- void UnregisterVisual( Property::Index index );
-
- /**
* @brief Emits KeyInputFocusGained signal if true else emits KeyInputFocusLost signal
*
* Should be called last by the control after it acts on the Input Focus change.
{
if(fabsf(mSpacing) <= Math::MACHINE_EPSILON_1)
{
- DALI_LOG_ERROR( "Page spacing too small (%f).\n", double(spacing) );
+ DALI_LOG_ERROR( "Page spacing too small (%f).", double(spacing) );
mSpacing = spacing >= 0.0f ? Math::MACHINE_EPSILON_1 : -Math::MACHINE_EPSILON_1;
}
mType = Fixed;
if(pagesPerVolume < 1u)
{
pagesPerVolume = 1u;
- DALI_LOG_ERROR("Ruler domain(%f) is smaller than its spacing(%f).\n", mDomain.GetSize() * 1.0, mSpacing * 1.0 );
+ DALI_LOG_ERROR("Ruler domain(%f) is smaller than its spacing(%f).", mDomain.GetSize() * 1.0, mSpacing * 1.0 );
}
page %= pagesPerVolume;
}
{
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
-const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 0;
+const unsigned int TOOLKIT_MINOR_VERSION = 1;
+const unsigned int TOOLKIT_MICRO_VERSION = 45;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
* @note For N-Patch images only.
*/
BORDER_ONLY,
-
- /**
- * @brief This enables Image visuals to automatically be converted to Batch-Image visuals.
- * @details Name "batchingEnabled", type Property::BOOLEAN.
- * @SINCE_1_2.0
- * @note Optional. For Image visuals only. Not to be used with NPatch or SVG images.
- */
- BATCHING_ENABLED,
};
} // namespace Property
* @note Will override the existing shaders.
* @see Shader::Property
*/
- SHADER,
+ SHADER
};
} // namespace Property
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.2.0
+Version: 1.1.45
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-2-Clause and MIT
/**
* TextureSet API see texture-set.h for a description
*/
+ void SetImage( const v8::FunctionCallbackInfo< v8::Value >& args );
void SetSampler( const v8::FunctionCallbackInfo< v8::Value >& args );
}; // namespace TextureSetApi
* TextureSet API (in order of texture-set.h)
**************************************/
+ { "SetImage" , TextureSetApi::SetImage },
{ "SetSampler" , TextureSetApi::SetSampler },
};
output += *utf8_value;
output +="\n";
}
- DALI_LOG_ERROR_NOFN( "JavaScript: %s\n",output.c_str() );
+ DALI_LOG_ERROR_NOFN( "JavaScript: %s",output.c_str() );
}
void GetFileContents(const std::string &fileName, std::string& contents)