X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fpublic-api%2Fshader-effects%2Fsoft-button-effect.cpp;h=fbf3da2ec1c4f318dfcf48c17061fcafb10b9a5b;hp=92015b9691e306ac7775d4ff6c0d32ce3fa5c9bd;hb=61be2f8d3c96e01da8e6ade2a76a192ff6ab6945;hpb=306d2f61a1b64179e801fa8a0bb2bd7b4e9dd682 diff --git a/dali-toolkit/public-api/shader-effects/soft-button-effect.cpp b/dali-toolkit/public-api/shader-effects/soft-button-effect.cpp index 92015b9..fbf3da2 100644 --- a/dali-toolkit/public-api/shader-effects/soft-button-effect.cpp +++ b/dali-toolkit/public-api/shader-effects/soft-button-effect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 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. @@ -15,7 +15,13 @@ * */ +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES #include + namespace Dali { @@ -51,20 +57,14 @@ const float SOFT_BUTTON_RECTANGLE_SIZE_SCALE_DEFAULT = 0.5f; } // namespace /** - * ReciprocalConstraint + * InverseConstraint * * f(current, property) = 1.0 / property */ -struct ReciprocalConstraint +void InverseConstraint( float& current, const PropertyInputContainer& inputs ) { - ReciprocalConstraint(){} - - float operator()(const float current, const PropertyInput& property) - { - return 1.0f / property.GetFloat(); - } -}; - + current = 1.0f / inputs[0]->GetFloat(); +} //////////////////////////////////////////////////// // @@ -364,10 +364,11 @@ SoftButtonEffect SoftButtonEffect::New(Type type) } // precalc 1.0 / uInsideCircleSizeScale on CPU to save shader insns, using constraint to tie to the normal property - Property::Index insideCircleSizeScalePropertyIndex = handle.GetPropertyIndex(SOFT_BUTTON_INSIDE_SHAPE_SIZE_SCALE_PROPERTY_NAME); - Property::Index recipInsideCircleSizeScalePropertyIndex = handle.GetPropertyIndex(SOFT_BUTTON_RECIP_INSIDE_SHAPE_SIZE_SCALE_PROPERTY_NAME); - Constraint constraint = Constraint::New( recipInsideCircleSizeScalePropertyIndex, LocalSource(insideCircleSizeScalePropertyIndex), ReciprocalConstraint()); - handle.ApplyConstraint(constraint); + Dali::Property::Index insideCircleSizeScalePropertyIndex = handle.GetPropertyIndex(SOFT_BUTTON_INSIDE_SHAPE_SIZE_SCALE_PROPERTY_NAME); + Dali::Property::Index recipInsideCircleSizeScalePropertyIndex = handle.GetPropertyIndex(SOFT_BUTTON_RECIP_INSIDE_SHAPE_SIZE_SCALE_PROPERTY_NAME); + Constraint constraint = Constraint::New( handle, recipInsideCircleSizeScalePropertyIndex, InverseConstraint ); + constraint.AddSource( LocalSource(insideCircleSizeScalePropertyIndex) ); + constraint.Apply(); } return handle; @@ -421,4 +422,3 @@ const std::string& SoftButtonEffect::GetRectangleSizeScalePropertyName() const } } -