/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
#include <dali/public-api/object/type-registry.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
return std::unique_ptr<Dali::Accessibility::Accessible>(
- new DevelControl::AccessibleImpl(actor, Dali::Accessibility::Role::IMAGE));
+ new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::IMAGE));
});
-
- //Enable highightability
- Self().SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true);
}
void ImageView::SetImage(const Property::Map& map)
// Signal that a Relayout may be needed
}
+void ImageView::ClearImageVisual()
+{
+ // Clear cached properties
+ mPropertyMap.Clear();
+ mUrl.clear();
+
+ // Unregister the exsiting visual
+ DevelControl::UnregisterVisual(*this, Toolkit::ImageView::Property::IMAGE);
+
+ // Trigger a size negotiation request that may be needed when unregistering a visual.
+ RelayoutRequest();
+}
+
void ImageView::EnablePreMultipliedAlpha(bool preMultipled)
{
if(mVisual)
}
}
+void ImageView::OnCreateTransitions(std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& sourceProperties,
+ std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& destinationProperties,
+ Dali::Toolkit::Control source,
+ Dali::Toolkit::Control destination)
+{
+ // Retrieves image properties to be transitioned.
+ Dali::Property::Map imageSourcePropertyMap, imageDestinationPropertyMap;
+ MakeVisualTransition(imageSourcePropertyMap, imageDestinationPropertyMap, source, destination, Toolkit::ImageView::Property::IMAGE);
+ if(imageSourcePropertyMap.Count() > 0)
+ {
+ sourceProperties.push_back(std::pair<Dali::Property::Index, Dali::Property::Map>(Toolkit::ImageView::Property::IMAGE, imageSourcePropertyMap));
+ destinationProperties.push_back(std::pair<Dali::Property::Index, Dali::Property::Map>(Toolkit::ImageView::Property::IMAGE, imageDestinationPropertyMap));
+ }
+}
+
+void ImageView::OnUpdateVisualProperties(const std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& properties)
+{
+ Toolkit::Visual::Base visual = DevelControl::GetVisual(*this, Toolkit::ImageView::Property::IMAGE);
+ if(visual)
+ {
+ Dali::Toolkit::Control handle(GetOwner());
+
+ for(auto&& data : properties)
+ {
+ if(data.first == Toolkit::ImageView::Property::IMAGE)
+ {
+ DevelControl::DoAction(handle, Toolkit::ImageView::Property::IMAGE, DevelVisual::Action::UPDATE_PROPERTY, data.second);
+ break;
+ }
+ }
+ }
+}
+
void ImageView::OnResourceReady(Toolkit::Control control)
{
// Visual ready so update visual attached to this ImageView, following call to RelayoutRequest will use this visual.
else
{
map = value.GetMap();
- if(map)
+ if(DALI_LIKELY(map))
{
- Property::Value* shaderValue = map->Find(Toolkit::Visual::Property::SHADER, CUSTOM_SHADER);
- // set image only if property map contains image information other than custom shader
- if(map->Count() > 1u || !shaderValue)
+ // the property map is emtpy map. Unregister visual.
+ if(DALI_UNLIKELY(map->Count() == 0u))
{
- impl.SetImage(*map);
+ impl.ClearImageVisual();
}
- // the property map contains only the custom shader
- else if((map->Count() == 1u) && (shaderValue))
+ else
{
- Property::Map* shaderMap = shaderValue->GetMap();
- if(shaderMap)
+ Property::Value* shaderValue = map->Find(Toolkit::Visual::Property::SHADER, CUSTOM_SHADER);
+ // set image only if property map contains image information other than custom shader
+ if(map->Count() > 1u || !shaderValue)
{
- impl.mShaderMap = *shaderMap;
-
- if(!impl.mUrl.empty())
- {
- impl.SetImage(impl.mUrl, impl.mImageSize);
- }
- else if(!impl.mPropertyMap.Empty())
+ impl.SetImage(*map);
+ }
+ // the property map contains only the custom shader
+ else if((map->Count() == 1u) && (shaderValue))
+ {
+ Property::Map* shaderMap = shaderValue->GetMap();
+ if(shaderMap)
{
- impl.SetImage(impl.mPropertyMap);
+ impl.mShaderMap = *shaderMap;
+
+ if(!impl.mUrl.empty())
+ {
+ impl.SetImage(impl.mUrl, impl.mImageSize);
+ }
+ else if(!impl.mPropertyMap.Empty())
+ {
+ impl.SetImage(impl.mPropertyMap);
+ }
}
}
}
}
+ else
+ {
+ // invalid property value comes. Unregister visual.
+ impl.ClearImageVisual();
+ }
}
break;
}