Let we allow to call DoAction by action-id for public, not only for internal.
And also, let we remove copy operation when we call DoAction to visual.
Change-Id: I974a89fc9a0749ee34de8a3f2f173330b6ddd281
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
namespace Dali
{
-
namespace Toolkit
{
-
namespace Internal
{
-
-DummyVisualPtr DummyVisual::New( const Property::Map& properties )
+DummyVisualPtr DummyVisual::New(const Property::Map& properties)
{
VisualFactoryCache* factoryCache = new VisualFactoryCache(false);
- DummyVisualPtr dummyVisualPtr( new DummyVisual( *factoryCache ) );
+ DummyVisualPtr dummyVisualPtr(new DummyVisual(*factoryCache));
dummyVisualPtr->Initialize();
return dummyVisualPtr;
}
-DummyVisual::DummyVisual( VisualFactoryCache& factoryCache )
-: Visual::Base( factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::Type::COLOR ),
- mActionCounter( 0 )
+DummyVisual::DummyVisual(VisualFactoryCache& factoryCache)
+: Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::Type::COLOR),
+ mActionCounter(0)
{
}
// Implement if required
}
-void DummyVisual::DoCreatePropertyMap( Property::Map& map ) const
+void DummyVisual::DoCreatePropertyMap(Property::Map& map) const
{
// Implement if required
}
-void DummyVisual::DoCreateInstancePropertyMap( Property::Map& map ) const
+void DummyVisual::DoCreateInstancePropertyMap(Property::Map& map) const
{
// Implement if required
}
-void DummyVisual::DoSetProperties( const Property::Map& propertyMap )
+void DummyVisual::DoSetProperties(const Property::Map& propertyMap)
{
// Implement if required
}
// Implement if required
}
-void DummyVisual::DoSetOnScene( Actor& actor )
+void DummyVisual::DoSetOnScene(Actor& actor)
{
// Implement if required
}
-void DummyVisual::OnDoAction( const Property::Index actionName, const Property::Value& attributes )
+void DummyVisual::OnDoAction(const Property::Index actionName, const Property::Value& attributes)
+{
+ if(DummyVisual::TEST_ACTION == actionName)
+ {
+ mActionCounter++; // GetActionCounter can be used to test for this.
+ }
+ // Further Actions can be added here
+}
+
+void DummyVisual::OnDoActionExtension(const Property::Index actionName, const Dali::Any& attributes)
{
- if ( DummyVisual::TEST_ACTION == actionName )
+ if(DummyVisual::TEST_ACTION_EXTENSION == actionName)
{
- mActionCounter++; // GetActionCounter can be used to test for this.
+ mActionCounter++; // GetActionCounter can be used to test for this.
}
// Further Actions can be added here
}
mActionCounter = 0;
}
-} // Internal
+} // namespace Internal
} // namespace Toolkit
#define DALI_TOOLKIT_TEST_DUMMY_VISUAL_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
// INTERNAL INCLUDES
#include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
+#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
namespace Dali
{
-
namespace Toolkit
{
-
namespace Internal
{
-
class DummyVisual;
-typedef IntrusivePtr< DummyVisual > DummyVisualPtr;
+typedef IntrusivePtr<DummyVisual> DummyVisualPtr;
/**
* Dummy Visual that can be used for testing
class DummyVisual : public Visual::Base
{
public:
-
// Actions that the dummy visual can perform. These actions are called through the Visual::Base::DoAction API.
enum Type
{
- TEST_ACTION = 0, ///< Updates the action counter
+ TEST_ACTION = 0, ///< Updates the action counter
+ TEST_ACTION_EXTENSION = 1, ///< Updates the action counter when we call DoActionExtension
};
public:
-
// Constructor for DummyVisual
- static DummyVisualPtr New( const Property::Map& properties );
+ static DummyVisualPtr New(const Property::Map& properties);
// Prevent default methods being used.
- DummyVisual( const DummyVisual& dummyVisual ) = delete;
- DummyVisual( const DummyVisual&& dummyVisual ) = delete;
- DummyVisual& operator=( const DummyVisual& dummyVisual ) = delete;
- DummyVisual& operator=( const DummyVisual&& dummyVisual ) = delete;
+ DummyVisual(const DummyVisual& dummyVisual) = delete;
+ DummyVisual(const DummyVisual&& dummyVisual) = delete;
+ DummyVisual& operator=(const DummyVisual& dummyVisual) = delete;
+ DummyVisual& operator=(const DummyVisual&& dummyVisual) = delete;
// Get the Action counter, action counter incremented with every successful Action
unsigned int GetActionCounter() const;
void ResetActionCounter();
protected:
-
- DummyVisual( VisualFactoryCache& factoryCache );
+ DummyVisual(VisualFactoryCache& factoryCache);
void OnInitialize() override;
- void DoCreatePropertyMap( Property::Map& map ) const override;
- void DoCreateInstancePropertyMap( Property::Map& map ) const override;
- void DoSetProperties( const Property::Map& propertyMap ) override;
+ void DoCreatePropertyMap(Property::Map& map) const override;
+ void DoCreateInstancePropertyMap(Property::Map& map) const override;
+ void DoSetProperties(const Property::Map& propertyMap) override;
void OnSetTransform() override;
- void DoSetOnScene( Actor& actor ) override;
- void OnDoAction( const Property::Index actionName, const Property::Value& attributes ) override;
+ void DoSetOnScene(Actor& actor) override;
+ void OnDoAction(const Property::Index actionName, const Property::Value& attributes) override;
+ void OnDoActionExtension(const Property::Index actionName, const Dali::Any& attributes) override;
private:
unsigned int mActionCounter;
-
};
-
-} // Internal
+} // namespace Internal
} // namespace Toolkit
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
tet_infoline("Perform TEST_ACTION action on Visual. Should increase the action counter");
- Property::Map attributes;
- Toolkit::Internal::Visual::Base& internalVisualBase = GetImplementation(visualBaseHandle);
- internalVisualBase.DoAction(Dali::Toolkit::Internal::DummyVisual::TEST_ACTION, attributes);
+ Property::Map attributes;
+ visualBaseHandle.DoAction(Dali::Toolkit::Internal::DummyVisual::TEST_ACTION, attributes);
application.SendNotification();
DALI_TEST_EQUALS(dummyVisualPtr->GetActionCounter(), 1, TEST_LOCATION);
tet_infoline("Perform TEST_ACTION action on Color Visual which does not support it.. Should not increment the action counter");
Property::Map attributes;
- GetImplementation(visual).DoAction(Dali::Toolkit::Internal::DummyVisual::TEST_ACTION, attributes);
+ visual.DoAction(Dali::Toolkit::Internal::DummyVisual::TEST_ACTION, attributes);
+ application.SendNotification();
+ DALI_TEST_EQUALS(dummyVisualPtr->GetActionCounter(), 0, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliVisualActionExtension(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("Register an ImageVisual and and perform an Action with Any attributes on Visual directly");
+ Vector2 controlSize(20.f, 30.f);
+
+ //Created DummyVisual
+ Property::Map settings;
+ Toolkit::Internal::DummyVisualPtr dummyVisualPtr = Toolkit::Internal::DummyVisual::New(settings);
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+
+ tet_infoline("Register visual and stage control");
+
+ Toolkit::Visual::Base visualBaseHandle = Toolkit::Visual::Base(dummyVisualPtr.Get());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visualBaseHandle);
+ dummyControl.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(dummyControl);
+
+ application.SendNotification();
+ application.Render();
+
+ tet_infoline("Check action counter is 0 before DoAction");
+ DALI_TEST_EQUALS(dummyVisualPtr->GetActionCounter(), 0, TEST_LOCATION);
+
+ tet_infoline("Perform TEST_ACTION_EXTENSION action on Visual. Should increase the action counter");
+ Dali::Any attributes;
+ visualBaseHandle.DoActionExtension(Dali::Toolkit::Internal::DummyVisual::TEST_ACTION_EXTENSION, attributes);
+ application.SendNotification();
+ DALI_TEST_EQUALS(dummyVisualPtr->GetActionCounter(), 1, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliVisualActionExtensionNotImplemented(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("Register an ImageVisual and and perform an ActionExtension on a Visual which does not support any Actions");
+ Vector2 controlSize(20.f, 30.f);
+
+ //Created DummyVisual
+ Property::Map settings;
+ Toolkit::Internal::DummyVisualPtr dummyVisualPtr = Toolkit::Internal::DummyVisual::New(settings);
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+
+ tet_infoline("Register visual and stage control");
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+ dummyControl.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(dummyControl);
+
+ application.SendNotification();
+ application.Render();
+
+ tet_infoline("Check action counter is 0 before DoActionExtension");
+ DALI_TEST_EQUALS(dummyVisualPtr->GetActionCounter(), 0, TEST_LOCATION);
+
+ tet_infoline("Perform TEST_ACTION_EXTENSION action on Color Visual which does not support it.. Should not increment the action counter");
+ Dali::Any attributes;
+ visual.DoActionExtension(Dali::Toolkit::Internal::DummyVisual::TEST_ACTION_EXTENSION, attributes);
application.SendNotification();
DALI_TEST_EQUALS(dummyVisualPtr->GetActionCounter(), 0, TEST_LOCATION);
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
GetImplementation(*this).CreatePropertyMap(map);
}
+void Visual::Base::DoAction(const Dali::Property::Index actionId, const Dali::Property::Value& attributes)
+{
+ GetImplementation(*this).DoAction(actionId, attributes);
+}
+
+void Visual::Base::DoActionExtension(const Dali::Property::Index actionId, const Dali::Any& attributes)
+{
+ GetImplementation(*this).DoActionExtension(actionId, attributes);
+}
+
Visual::Type Visual::Base::GetType() const
{
return GetImplementation(*this).GetType();
// EXTERNAL INCLUDES
#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/object/any.h>
#include <dali/public-api/object/base-handle.h>
// INTERNAL INCLUDES
void CreatePropertyMap(Dali::Property::Map& map) const;
/**
+ * @brief Performs an action on the visual with the given action id and attributes.
+ *
+ * @param[in] actionId The id of the action to perform this API only takes an Index
+ * @param[in] attributes The list of attributes for the action. ( optional for this data structure to have content )
+ */
+ void DoAction(const Dali::Property::Index actionId, const Dali::Property::Value& attributes);
+
+ /**
+ * @brief Performs an action on the visual with the given action id and attributes.
+ *
+ * @param[in] actionId The id of the action to perform this API only takes an Index
+ * @param[in] attributes The list of attributes for the action. ( optional for this data structure to have content )
+ */
+ void DoActionExtension(const Dali::Property::Index actionId, const Dali::Any& attributes);
+
+ /**
* @brief Get the type of this visual.
*
* @return The the type of this visual.
TriggerVectorRasterization();
}
-void AnimatedVectorImageVisual::OnDoActionExtension(const Property::Index actionId, Dali::Any attributes)
+void AnimatedVectorImageVisual::OnDoActionExtension(const Property::Index actionId, const Dali::Any& attributes)
{
switch(actionId)
{
/**
* @copydoc Visual::Base::OnDoActionExtension
*/
- void OnDoActionExtension(const Property::Index actionId, Dali::Any attributes) override;
+ void OnDoActionExtension(const Property::Index actionId, const Dali::Any& attributes) override;
private:
/**
naturalSize = Vector2::ZERO;
}
-void Visual::Base::DoAction(const Property::Index actionId, const Property::Value attributes)
+void Visual::Base::DoAction(const Property::Index actionId, const Property::Value& attributes)
{
OnDoAction(actionId, attributes);
}
}
-void Visual::Base::DoActionExtension(const Dali::Property::Index actionId, const Dali::Any attributes)
+void Visual::Base::DoActionExtension(const Dali::Property::Index actionId, const Dali::Any& attributes)
{
OnDoActionExtension(actionId, attributes);
}
// May be overriden by derived class
}
-void Visual::Base::OnDoActionExtension(const Property::Index actionId, const Dali::Any attributes)
+void Visual::Base::OnDoActionExtension(const Property::Index actionId, const Dali::Any& attributes)
{
// May be overriden by derived class
}
#define DALI_TOOLKIT_INTERNAL_VISUAL_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
void SetTransformAndSize(const Property::Map& transform, Size controlSize);
/**
- * @brief Performs an action on the visual with the given action id and attributes.
- *
- * @param[in] actionId The id of the action to perform this API only takes an Index
- * @param[in] attributes The list of attributes for the action. ( optional for this data structure to have content )
- */
- void DoAction(const Dali::Property::Index actionId, const Dali::Property::Value attributes);
-
- /**
- * @brief Performs an action on the visual with the given action id and attributes.
- *
- * @param[in] actionId The id of the action to perform this API only takes an Index
- * @param[in] attributes The list of attributes for the action. ( optional for this data structure to have content )
- */
- void DoActionExtension(const Dali::Property::Index actionId, const Dali::Any attributes);
-
- /**
* @copydoc Toolkit::Visual::Base::GetHeightForWidth
*/
virtual float GetHeightForWidth(float width);
void CreatePropertyMap(Property::Map& map) const;
/**
+ * @copydoc Toolkit::Visual::Base::DoAction
+ */
+ void DoAction(const Dali::Property::Index actionId, const Dali::Property::Value& attributes);
+
+ /**
+ * @copydoc Toolkit::Visual::Base::DoActionExtension
+ */
+ void DoActionExtension(const Dali::Property::Index actionId, const Dali::Any& attributes);
+
+ /**
* @brief Create a property map containing per-instance visual properties.
*
* This will enable creation of new visuals on control state change with
* @param[in] actionId The action to perform
* @param[in] attributes The list of attributes for the action. ( optional for this data structure to have content )
*/
- virtual void OnDoActionExtension(const Property::Index actionId, Dali::Any attributes);
+ virtual void OnDoActionExtension(const Property::Index actionId, const Dali::Any& attributes);
/**
* @brief Update the shader when some properties are changed.