DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
DALI_TEST_EQUALS( GetControlBackgroundColor( control ), semiTransparent, TEST_LOCATION );
+ Renderer renderer = control.GetRendererAt( 0 );
+ DALI_TEST_CHECK( renderer );
+
+ tet_infoline( "Set semi transparent alpha with positive RGB values, renderer should not be changed" );
+ const Vector4 newColor( 1.0f, 1.0f, 0.5f, 0.5f );
+ control.SetBackgroundColor( newColor );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetControlBackgroundColor( control ), newColor, TEST_LOCATION );
+ DALI_TEST_EQUALS( renderer, control.GetRendererAt( 0 ), TEST_LOCATION );
+
tet_infoline( "Set transparent, ensure no renderers are created" );
control.SetBackgroundColor( Color::TRANSPARENT );
application.SendNotification();
${devel_api_src_dir}/visuals/animated-vector-image-visual-signals-devel.h
${devel_api_src_dir}/visuals/arc-visual-actions-devel.h
${devel_api_src_dir}/visuals/arc-visual-properties-devel.h
+ ${devel_api_src_dir}/visuals/color-visual-actions-devel.h
${devel_api_src_dir}/visuals/color-visual-properties-devel.h
${devel_api_src_dir}/visuals/image-visual-properties-devel.h
${devel_api_src_dir}/visuals/image-visual-actions-devel.h
--- /dev/null
+#ifndef DALI_TOOLKIT_DEVEL_API_VISUALS_COLOR_VISUAL_ACTIONS_DEVEL_H
+#define DALI_TOOLKIT_DEVEL_API_VISUALS_COLOR_VISUAL_ACTIONS_DEVEL_H
+
+/*
+ * Copyright (c) 2020 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.
+ *
+ */
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelColorVisual
+{
+
+/**
+ * @brief Actions that the color visual can perform. These actions are called through the Visual::Base::DoAction API.
+ */
+namespace Action
+{
+/**
+ * @brief The available actions for this visual
+ */
+enum Type
+{
+ /**
+ * @brief Update the properties of the visual.
+ */
+ UPDATE_PROPERTY = 0
+};
+
+} // namespace Actions
+
+} // namespace DevelVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_DEVEL_API_VISUALS_COLOR_VISUAL_ACTIONS_DEVEL_H
#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/color-visual-actions-devel.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-string-constants.h>
}
}
+void ColorVisual::OnDoAction( const Property::Index actionId, const Property::Value& attributes )
+{
+ // Check if action is valid for this visual type and perform action if possible
+ switch( actionId )
+ {
+ case DevelColorVisual::Action::UPDATE_PROPERTY:
+ {
+ Property::Map* map = attributes.GetMap();
+ if( map )
+ {
+ DoSetProperties( *map );
+ }
+ break;
+ }
+ }
+}
+
void ColorVisual::InitializeRenderer()
{
Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
*/
void OnSetTransform() override;
+ /**
+ * @copydoc Visual::Base::OnDoAction
+ */
+ void OnDoAction( const Property::Index actionId, const Property::Value& attributes ) override;
+
private:
/**
* @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
#include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/color-visual-actions-devel.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#include <dali-toolkit/internal/visuals/color/color-visual.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
Toolkit::Visual::Base backgroundVisual = controlDataImpl.GetVisual( Toolkit::Control::Property::BACKGROUND );
- if( backgroundVisual )
+ if( backgroundVisual && backgroundVisual.GetType() == Toolkit::Visual::COLOR )
{
Property::Map map;
backgroundVisual.CreatePropertyMap( map );
- Property::Value* typeValue = map.Find( Toolkit::Visual::Property::TYPE );
- if( typeValue && typeValue->Get< int >() == Toolkit::Visual::COLOR )
- {
- // Only change it if it's a color visual
- map[ Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = renderIfTransparent;
- controlImpl.SetBackground( map );
- }
+
+ // Only change it if it's a color visual
+ map[ Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = renderIfTransparent;
+ controlImpl.SetBackground( map );
}
}
void Control::SetBackgroundColor( const Vector4& color )
{
mImpl->mBackgroundColor = color;
+
Property::Map map;
map[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::COLOR;
map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
+ bool renderIfTransparent = false;
int clippingMode = ClippingMode::DISABLED;
if( ( Self().GetProperty( Actor::Property::CLIPPING_MODE ).Get( clippingMode ) ) &&
( clippingMode == ClippingMode::CLIP_CHILDREN ) )
{
// If clipping-mode is set to CLIP_CHILDREN, then force visual to add the render even if transparent
map[ Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = true;
+ renderIfTransparent = true;
+ }
+
+ Toolkit::Visual::Base visual = mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
+ if( visual && visual.GetType() == Toolkit::Visual::COLOR )
+ {
+ Property::Map visualMap;
+ visual.CreatePropertyMap( visualMap );
+
+ Property::Value* renderValue = visualMap.Find( Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT );
+ Property::Value* colorValue = visualMap.Find( Toolkit::ColorVisual::Property::MIX_COLOR );
+ if( renderValue && colorValue )
+ {
+ if( ( renderValue->Get< bool >() == true || colorValue->Get< Vector4 >().a > 0.0f )
+ && ( renderIfTransparent || color.a > 0.0f ) )
+ {
+ // Update background color only
+ mImpl->DoAction( Toolkit::Control::Property::BACKGROUND, DevelColorVisual::Action::UPDATE_PROPERTY, map );
+ return;
+ }
+ }
}
SetBackground( map );