#include <iostream>
#include <stdlib.h>
-//#include <chrono>
-//#include <thread>
#include <dali-toolkit-test-suite-utils.h>
-//#include <toolkit-timer.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/visuals/arc-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/arc-visual-actions-devel.h>
#include <dali/devel-api/rendering/renderer-devel.h>
#include "dummy-control.h"
END_TEST;
}
+
+int UtcDaliArcVisualUpdateProperty(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliArcVisualUpdateProperty" );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ float thickness = 20.0f;
+ float startAngle = 0.0f;
+ float sweepAngle = 90.0f;
+
+ Property::Map propertyMap;
+ propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ARC )
+ .Add( Visual::Property::MIX_COLOR, Color::RED )
+ .Add( DevelArcVisual::Property::THICKNESS, thickness )
+ .Add( DevelArcVisual::Property::START_ANGLE, startAngle )
+ .Add( DevelArcVisual::Property::SWEEP_ANGLE, sweepAngle );
+
+ Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ DummyControl actor = DummyControl::New( true );
+ DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) );
+ Stage::GetCurrent().Add( actor );
+
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ Property::Value* value = map.Find( DevelArcVisual::Property::THICKNESS, Property::FLOAT );
+ DALI_TEST_EQUALS( value->Get< float >(), thickness, TEST_LOCATION );
+ DALI_TEST_EQUALS( gl.CheckUniformValue< float >( "thickness", thickness ), true, TEST_LOCATION );
+
+ value = map.Find( DevelArcVisual::Property::START_ANGLE, Property::FLOAT );
+ DALI_TEST_EQUALS( value->Get< float >(), startAngle, TEST_LOCATION );
+ DALI_TEST_EQUALS( gl.CheckUniformValue< float >( "startAngle", startAngle ), true, TEST_LOCATION );
+
+ value = map.Find( DevelArcVisual::Property::SWEEP_ANGLE, Property::FLOAT );
+ DALI_TEST_EQUALS( value->Get< float >(), sweepAngle, TEST_LOCATION );
+ DALI_TEST_EQUALS( gl.CheckUniformValue< float >( "sweepAngle", sweepAngle ), true, TEST_LOCATION );
+
+ thickness = 10.0f;
+ startAngle = 90.0f;
+ sweepAngle = 180.0f;
+
+ Property::Map attributes;
+ attributes.Add( DevelArcVisual::Property::THICKNESS, thickness )
+ .Add( DevelArcVisual::Property::START_ANGLE, startAngle )
+ .Add( DevelArcVisual::Property::SWEEP_ANGLE, sweepAngle );
+
+ DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelArcVisual::Action::UPDATE_PROPERTY, attributes );
+
+ application.SendNotification();
+ application.Render();
+
+ map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelArcVisual::Property::THICKNESS, Property::FLOAT );
+ DALI_TEST_EQUALS( value->Get< float >(), thickness, TEST_LOCATION );
+ DALI_TEST_EQUALS( gl.CheckUniformValue< float >( "thickness", thickness ), true, TEST_LOCATION );
+
+ value = map.Find( DevelArcVisual::Property::START_ANGLE, Property::FLOAT );
+ DALI_TEST_EQUALS( value->Get< float >(), startAngle, TEST_LOCATION );
+ DALI_TEST_EQUALS( gl.CheckUniformValue< float >( "startAngle", startAngle ), true, TEST_LOCATION );
+
+ value = map.Find( DevelArcVisual::Property::SWEEP_ANGLE, Property::FLOAT );
+ DALI_TEST_EQUALS( value->Get< float >(), sweepAngle, TEST_LOCATION );
+ DALI_TEST_EQUALS( gl.CheckUniformValue< float >( "sweepAngle", sweepAngle ), true, TEST_LOCATION );
+
+ END_TEST;
+}
${devel_api_src_dir}/visuals/animated-image-visual-actions-devel.h
${devel_api_src_dir}/visuals/animated-vector-image-visual-actions-devel.h
${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-properties-devel.h
${devel_api_src_dir}/visuals/image-visual-properties-devel.h
--- /dev/null
+#ifndef DALI_TOOLKIT_DEVEL_API_VISUALS_ARC_VISUAL_ACTIONS_DEVEL_H
+#define DALI_TOOLKIT_DEVEL_API_VISUALS_ARC_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 DevelArcVisual
+{
+
+/**
+ * @brief Actions that the arc 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.
+ * @note DevelArcVisual::Property::THICKNESS, DevelArcVisual::Property::START_ANGLE and DevelArcVisual::Property::SWEEP_ANGLE can be updated.
+ */
+ UPDATE_PROPERTY = 0
+};
+
+} // namespace Actions
+
+} // namespace DevelArcVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_DEVEL_API_VISUALS_ARC_VISUAL_ACTIONS_DEVEL_H
//INTERNAL INCLUDES
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/arc-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>
mStartAngle( 0.0f ),
mSweepAngle( 360.0f ),
mRadiusIndex( Property::INVALID_INDEX ),
+ mThicknessIndex( Property::INVALID_INDEX ),
+ mStartAngleIndex( Property::INVALID_INDEX ),
+ mSweepAngleIndex( Property::INVALID_INDEX ),
mCapType( DevelArcVisual::Cap::BUTT )
{
}
{
DALI_LOG_ERROR( "ArcVisual:DoSetProperties:: THICKNESS property has incorrect type: %d\n", thicknessValue->GetType() );
}
+ else
+ {
+ if( mImpl->mRenderer )
+ {
+ mImpl->mRenderer.SetProperty( mThicknessIndex, mThickness );
+
+ // Need to calculate radius again
+ OnSetTransform();
+ }
+ }
}
Property::Value* startAngleValue = propertyMap.Find( Toolkit::DevelArcVisual::Property::START_ANGLE, START_ANGLE_NAME );
{
DALI_LOG_ERROR( "ArcVisual:DoSetProperties:: START_ANGLE property has incorrect type: %d\n", startAngleValue->GetType() );
}
+ else
+ {
+ if( mImpl->mRenderer )
+ {
+ mImpl->mRenderer.SetProperty( mStartAngleIndex, mStartAngle );
+ }
+ }
}
Property::Value* sweepAngleValue = propertyMap.Find( Toolkit::DevelArcVisual::Property::SWEEP_ANGLE, SWEEP_ANGLE_NAME );
{
DALI_LOG_ERROR( "ArcVisual:DoSetProperties:: SWEEP_ANGLE property has incorrect type: %d\n", sweepAngleValue->GetType() );
}
+ else
+ {
+ if( mImpl->mRenderer )
+ {
+ mImpl->mRenderer.SetProperty( mSweepAngleIndex, mSweepAngle );
+ }
+ }
}
Property::Value* capValue = propertyMap.Find( Toolkit::DevelArcVisual::Property::CAP, CAP_NAME );
}
}
+void ArcVisual::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 DevelArcVisual::Action::UPDATE_PROPERTY:
+ {
+ Property::Map* map = attributes.GetMap();
+ if( map )
+ {
+ DoSetProperties( *map );
+ }
+ break;
+ }
+ }
+}
+
void ArcVisual::InitializeRenderer()
{
Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
mImpl->mRenderer = Renderer::New( geometry, shader );
- mImpl->mRenderer.RegisterProperty( THICKNESS_NAME, mThickness );
- mImpl->mRenderer.RegisterProperty( START_ANGLE_NAME, mStartAngle );
- mImpl->mRenderer.RegisterProperty( SWEEP_ANGLE_NAME, mSweepAngle );
- mImpl->mRenderer.RegisterProperty( CAP_NAME, 0.0f );
+ mThicknessIndex = mImpl->mRenderer.RegisterProperty( THICKNESS_NAME, mThickness );
+ mStartAngleIndex = mImpl->mRenderer.RegisterProperty( START_ANGLE_NAME, mStartAngle );
+ mSweepAngleIndex = mImpl->mRenderer.RegisterProperty( SWEEP_ANGLE_NAME, mSweepAngle );
mRadiusIndex = mImpl->mRenderer.RegisterProperty( RADIUS_NAME, mRadius );
*/
void OnSetTransform() override;
+ /**
+ * @copydoc Visual::Base::OnDoAction
+ */
+ void OnDoAction( const Property::Index actionId, const Property::Value& attributes ) override;
+
private:
/**
float mStartAngle; ///< The start angle of the arc.
float mSweepAngle; ///< The sweep angle of the arc.
Property::Index mRadiusIndex; ///< The index of the radius property.
+ Property::Index mThicknessIndex; ///< The index of the thickness property.
+ Property::Index mStartAngleIndex; ///< The index of the start angle property.
+ Property::Index mSweepAngleIndex; ///< The index of the sweep angle property.
DevelArcVisual::Cap::Type mCapType; ///< The cap type.
};