utc-Dali-ItemLayout.cpp
utc-Dali-ItemView.cpp
utc-Dali-KeyboardFocusManager.cpp
+ utc-Dali-Magnifier.cpp
utc-Dali-MaskEffect.cpp
utc-Dali-NinePatchMaskEffect.cpp
utc-Dali-Popup.cpp
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <sstream>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/magnifier/magnifier.h>
+
+using namespace Dali;
+using namespace Toolkit;
+
+void dali_magnifier_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void dali_magnifier_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliMagnifierNew(void)
+{
+ ToolkitTestApplication application;
+
+ Magnifier magnifier;
+ DALI_TEST_CHECK( !magnifier );
+
+ magnifier = Magnifier::New();
+ DALI_TEST_CHECK( magnifier );
+
+ Stage::GetCurrent().Add( magnifier );
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
+int UtcDaliMagnifierCopyAndAssignment(void)
+{
+ ToolkitTestApplication application;
+
+ Magnifier view = Magnifier::New();
+ DALI_TEST_CHECK( view );
+
+ Magnifier copy( view );
+ DALI_TEST_CHECK( copy == view );
+
+ Magnifier assign;
+ DALI_TEST_CHECK( !assign );
+ assign = view;
+ DALI_TEST_CHECK( assign == view );
+
+ // Self assignment
+ assign = assign;
+ DALI_TEST_CHECK( assign );
+ DALI_TEST_CHECK( assign == view );
+
+ END_TEST;
+}
+
+int UtcDaliMagnifierDownCast(void)
+{
+ ToolkitTestApplication application;
+
+ BaseHandle view = Magnifier::New();
+ DALI_TEST_CHECK( Magnifier::DownCast( view ) );
+
+ BaseHandle empty;
+ DALI_TEST_CHECK( ! Magnifier::DownCast( empty ) );
+
+ BaseHandle another = Actor::New();
+ DALI_TEST_CHECK( ! Magnifier::DownCast( another ) );
+
+ END_TEST;
+}
+
+int UtcDaliMagnifierTypeRegistry(void)
+{
+ ToolkitTestApplication application;
+
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+ DALI_TEST_CHECK( typeRegistry );
+
+ TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Magnifier" );
+ DALI_TEST_CHECK( typeInfo );
+
+ BaseHandle handle = typeInfo.CreateInstance();
+ DALI_TEST_CHECK( handle );
+
+ Magnifier view = Magnifier::DownCast( handle );
+ DALI_TEST_CHECK( view );
+
+ END_TEST;
+}
+
+int UtcDaliMagnifierSetSourceActorP(void)
+{
+ ToolkitTestApplication application;
+
+ Stage stage = Stage::GetCurrent();
+
+ Magnifier view = Magnifier::New();
+ stage.Add( view );
+
+ application.SendNotification();
+ application.Render();
+
+ RenderTaskList renderTaskList = stage.GetRenderTaskList();
+ DALI_TEST_CHECK( renderTaskList.GetTaskCount() > 1 );
+
+ Actor actor = Actor::New();
+ stage.Add( actor );
+ DALI_TEST_CHECK( stage.GetRenderTaskList().GetTask( 1 ).GetSourceActor() != actor );
+
+ view.SetSourceActor( actor );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( stage.GetRenderTaskList().GetTask( 1 ).GetSourceActor(), actor, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliMagnifierSetSourceActorN(void)
+{
+ ToolkitTestApplication application;
+
+ Magnifier view;
+
+ try
+ {
+ view.SetSourceActor( Actor::New() );
+ DALI_TEST_CHECK( false ); // should not get here
+ }
+ catch( ... )
+ {
+ DALI_TEST_CHECK( true );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliMagnifierFrameVisibility(void)
+{
+ ToolkitTestApplication application;
+
+ Stage stage = Stage::GetCurrent();
+
+ Magnifier view = Magnifier::New();
+ stage.Add( view );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), true, TEST_LOCATION );
+
+ view.SetProperty( Magnifier::Property::FRAME_VISIBILITY, false );
+ DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), false, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), false, TEST_LOCATION );
+
+ view.SetProperty( Magnifier::Property::FRAME_VISIBILITY, true );
+ DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliMagnifierMagnificationFactor(void)
+{
+ ToolkitTestApplication application;
+
+ Stage stage = Stage::GetCurrent();
+
+ Magnifier view = Magnifier::New();
+ stage.Add( view );
+
+ application.SendNotification();
+ application.Render();
+
+ float magnificationFactor( 200.0f );
+
+ DALI_TEST_CHECK( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >() != magnificationFactor );
+
+ view.SetProperty( Magnifier::Property::MAGNIFICATION_FACTOR, magnificationFactor );
+ DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), magnificationFactor, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), magnificationFactor, TEST_LOCATION );
+
+ view.SetProperty( Magnifier::Property::MAGNIFICATION_FACTOR, 1.0f );
+ DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), 1.0f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), 1.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliMagnifierSourcePosition(void)
+{
+ ToolkitTestApplication application;
+
+ Stage stage = Stage::GetCurrent();
+
+ Magnifier view = Magnifier::New();
+ stage.Add( view );
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 position( 100.0f, 200.0f, 300.0f );
+
+ DALI_TEST_CHECK( view.GetProperty( Magnifier::Property::SOURCE_POSITION ).Get< Vector3 >() != position );
+
+ view.SetProperty( Magnifier::Property::SOURCE_POSITION, position );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::SOURCE_POSITION ).Get< Vector3 >(), position, TEST_LOCATION );
+
+ view.SetProperty( Magnifier::Property::SOURCE_POSITION, Vector3::ONE );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::SOURCE_POSITION ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliMagnifierOnSizeSet(void)
+{
+ ToolkitTestApplication application;
+
+ Magnifier view = Magnifier::New();
+
+ Stage::GetCurrent().Add( view );
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 size( 200.0f, 300.0f, 200.0f );
+ view.SetSize( size );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( view.GetCurrentSize(), size, TEST_LOCATION );
+
+ END_TEST;
+}
// Magnifier
///////////////////////////////////////////////////////////////////////////////////////////////////
-const std::string Magnifier::SOURCE_POSITION_PROPERTY_NAME( "source-position" );
-
Magnifier::Magnifier()
{
}
GetImpl(*this).SetSourceActor( actor );
}
-void Magnifier::SetSourcePosition(Vector3 position)
-{
- GetImpl(*this).SetSourcePosition( position );
-}
-
-bool Magnifier::GetFrameVisibility() const
-{
- return GetImpl(*this).GetFrameVisibility();
-}
-
-void Magnifier::SetFrameVisibility(bool visible)
-{
- GetImpl(*this).SetFrameVisibility(visible);
-}
-
-float Magnifier::GetMagnificationFactor() const
-{
- return GetImpl(*this).GetMagnificationFactor();
-}
-
-void Magnifier::SetMagnificationFactor(float value)
-{
- GetImpl(*this).SetMagnificationFactor( value );
-}
-
-
} // namespace Toolkit
} // namespace Dali
{
public:
- // Custom properties
+ /**
+ * @brief The start and end property ranges for this control.
+ */
+ enum PropertyRange
+ {
+ PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
+ PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, ///< Reserve property indices
+
+ ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
+ ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000 ///< Reserve animatable property indices
+ };
- static const std::string SOURCE_POSITION_PROPERTY_NAME; ///< Property, name "source-position", type Vector3
+ /**
+ * @brief An enumeration of properties belonging to the Magnifier class.
+ */
+ struct Property
+ {
+ enum
+ {
+ // Event side properties
+ FRAME_VISIBILITY = PROPERTY_START_INDEX, ///< name "frame-visibility", Whether a frame is visible or not, type boolean
+ MAGNIFICATION_FACTOR, ///< name "magnification-factor", Larger value means greater magnification, type float
+
+ // Animatable properties
+ SOURCE_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< name "source-position", The position of the source, type Vector3
+ };
+ };
public:
*/
void SetSourceActor(Actor actor);
- /**
- * Set the source camera position to render in magnifier
- * @param[in] position The target position from which to render source.
- */
- void SetSourcePosition(Vector3 position);
-
- /**
- * Returns whether the frame is visible or not.
- * @return true if frame is visible, false if not.
- */
- bool GetFrameVisibility() const;
-
- /**
- * Sets whether the frame part of the magnifier should be visible
- * or not.
- * @param[in] visible true to display frame, false to hide frame.
- */
- void SetFrameVisibility(bool visible);
-
- /**
- * Get the magnification factor of the magnifier
- * The larger the value the larger the contents magnified.
- * A value of 1.0f indications 1x magnification.
- * @return Magnification factor is returned
- */
- float GetMagnificationFactor() const;
-
- /**
- * Set the magnification factor of the magnifier
- * The larger the value the larger the contents magnified.
- * A value of 1.0f indications 1x magnification.
- * @param[in] value Magnification factor.
- */
- void SetMagnificationFactor(float value);
-
public: // Not intended for application developers
/**
#include <dali/public-api/common/stage.h>
#include <dali/public-api/render-tasks/render-task-list.h>
#include <dali/public-api/images/resource-image.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/devel-api/object/type-registry-helper.h>
-using namespace Dali;
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
namespace // unnamed namespace
{
+
+Dali::BaseHandle Create()
+{
+ return Toolkit::Magnifier::New();
+}
+
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Magnifier, Toolkit::Control, Create )
+
+DALI_PROPERTY_REGISTRATION( Toolkit, Magnifier, "frame-visibility", BOOLEAN, FRAME_VISIBILITY )
+DALI_PROPERTY_REGISTRATION( Toolkit, Magnifier, "magnification-factor", FLOAT, MAGNIFICATION_FACTOR )
+
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Magnifier, "source-position", VECTOR3, SOURCE_POSITION )
+
+DALI_TYPE_REGISTRATION_END()
+
const char* DEFAULT_FRAME_IMAGE_PATH = DALI_IMAGE_DIR "magnifier-image-frame.png";
const float IMAGE_BORDER_INDENT = 14.0f; ///< Indent of border in pixels.
}
};
-}
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
+} // unnamed namespace
///////////////////////////////////////////////////////////////////////////////////////////////////
// Magnifier
Magnifier::Magnifier()
: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ),
- mPropertySourcePosition(Property::INVALID_INDEX),
mDefaultCameraDistance(1000.f),
mActorSize(Vector3::ZERO),
mMagnificationFactor(1.0f)
mTask.SetSourceActor( actor );
}
-void Magnifier::SetSourcePosition(const Vector3& position)
-{
- Self().SetProperty(mPropertySourcePosition, position);
-}
-
void Magnifier::Initialize()
{
Actor self = Self();
- mPropertySourcePosition = self.RegisterProperty( Toolkit::Magnifier::SOURCE_POSITION_PROPERTY_NAME, Vector3::ZERO );
Vector2 stageSize(Stage::GetCurrent().GetSize());
// NOTE:
Stage().GetCurrent().Add(mSourceActor);
mSourceActor.SetParentOrigin(ParentOrigin::CENTER);
Constraint constraint = Constraint::New<Vector3>( mSourceActor, Actor::Property::POSITION, EqualToConstraint() );
- constraint.AddSource( Source( self, mPropertySourcePosition ) );
+ constraint.AddSource( Source( self, Toolkit::Magnifier::Property::SOURCE_POSITION ) );
constraint.Apply();
// create the render task this will render content on top of everything
mCameraActor.SetAspectRatio( worldSize.width / worldSize.height );
}
+void Magnifier::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+ Toolkit::Magnifier magnifier = Toolkit::Magnifier::DownCast( Dali::BaseHandle( object ) );
+
+ if( magnifier )
+ {
+ Magnifier& magnifierImpl( GetImpl( magnifier ) );
+ switch( index )
+ {
+ case Toolkit::Magnifier::Property::FRAME_VISIBILITY:
+ {
+ magnifierImpl.SetFrameVisibility( value.Get< bool >() );
+ break;
+ }
+ case Toolkit::Magnifier::Property::MAGNIFICATION_FACTOR:
+ {
+ magnifierImpl.SetMagnificationFactor( value.Get< float >() );
+ break;
+ }
+ }
+ }
+}
+
+Property::Value Magnifier::GetProperty( BaseObject* object, Property::Index index )
+{
+ Property::Value value;
+
+ Toolkit::Magnifier magnifier = Toolkit::Magnifier::DownCast( Dali::BaseHandle( object ) );
+
+ if( magnifier )
+ {
+ Magnifier& magnifierImpl( GetImpl( magnifier ) );
+ switch( index )
+ {
+ case Toolkit::Magnifier::Property::FRAME_VISIBILITY:
+ {
+ value = magnifierImpl.GetFrameVisibility();
+ break;
+ }
+ case Toolkit::Magnifier::Property::MAGNIFICATION_FACTOR:
+ {
+ value = magnifierImpl.GetMagnificationFactor();
+ break;
+ }
+ }
+ }
+
+ return value;
+}
+
} // namespace Internal
} // namespace Toolkit
void SetSourceActor(Actor actor);
/**
- * @copydoc Toolkit::ImageView::SetSourcePosition
- */
- void SetSourcePosition(const Vector3& position);
-
- /**
- * @copydoc Toolkit::ImageView::GetFrameVisibility
+ * Returns whether the frame is visible or not.
+ * @return true if frame is visible, false if not.
*/
bool GetFrameVisibility() const;
/**
- * @copydoc Toolkit::ImageView::SetFrameVisibility
+ * Sets whether the frame part of the magnifier should be visible or not.
+ * @param[in] visible true to display frame, false to hide frame.
*/
void SetFrameVisibility(bool visible);
/**
- * @copydoc Toolkit::ImageView::GetMagnificationFactor
+ * Get the magnification factor of the magnifier
+ * The larger the value the larger the contents magnified.
+ * A value of 1.0f indications 1x magnification.
+ * @return Magnification factor is returned
*/
float GetMagnificationFactor() const;
/**
- * @copydoc Toolkit::ImageView::SetMagnificationFactor
+ * Set the magnification factor of the magnifier
+ * The larger the value the larger the contents magnified.
+ * A value of 1.0f indications 1x magnification.
+ * @param[in] value Magnification factor.
*/
void SetMagnificationFactor(float value);
*/
void Update();
+ // Properties
+
+ /**
+ * Called when a property of an object of this type is set.
+ * @param[in] object The object whose property is set.
+ * @param[in] index The property index.
+ * @param[in] value The new property value.
+ */
+ static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
+
+ /**
+ * Called to retrieve a property of an object of this type.
+ * @param[in] object The object whose property is to be retrieved.
+ * @param[in] index The property index.
+ * @return The current value of the property.
+ */
+ static Property::Value GetProperty( BaseObject* object, Property::Index index );
+
protected:
/**
RenderTask mTask; ///< Render Task to render the source actor contents.
CameraActor mCameraActor; ///< CameraActor attached to RenderTask
ImageActor mFrame; ///< The Magnifier Frame
- Property::Index mPropertySourcePosition; ///< Source Position ("source-position")
Actor mSourceActor; ///< Source Delegate Actor represents the source position to read.
float mDefaultCameraDistance; ///< Default RenderTask's camera distance from target.
Vector3 mActorSize; ///< The Actor size