X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fvisual-base-impl.cpp;h=f155b868b1fc40737945c33007657ba39bf49cf1;hp=49b3120a8782d74711dcd6135d6a2bd0d6776418;hb=d2a6f4d721fbc03b51d4f1328a58b1fa65f90d43;hpb=6ae6f36998b3be4efa1114e2df856e51628bf812 diff --git a/dali-toolkit/internal/visuals/visual-base-impl.cpp b/dali-toolkit/internal/visuals/visual-base-impl.cpp index 49b3120..f155b86 100644 --- a/dali-toolkit/internal/visuals/visual-base-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-base-impl.cpp @@ -25,6 +25,7 @@ #include //INTERNAL HEARDER +#include #include #include #include @@ -60,6 +61,56 @@ DALI_ENUM_TO_STRING_TABLE_BEGIN(VISUAL_FITTING_MODE) DALI_ENUM_TO_STRING_WITH_SCOPE(Visual::FittingMode, FIT_HEIGHT) DALI_ENUM_TO_STRING_TABLE_END(VISUAL_FITTING_MODE) +/** + * @brief Check whether this visual type can use corner radius feature or not. + * @param type VisualType that want to checkup + * @return true if type can use corner radius feature. + */ +static bool IsTypeAvailableForCornerRadius(Toolkit::Visual::Type type) +{ + switch(static_cast(type)) + { + case Toolkit::Visual::Type::COLOR: + case Toolkit::Visual::Type::GRADIENT: + case Toolkit::Visual::Type::IMAGE: + case Toolkit::Visual::Type::SVG: + case Toolkit::Visual::Type::ANIMATED_IMAGE: + case Toolkit::DevelVisual::Type::ANIMATED_VECTOR_IMAGE: + { + return true; + } + default: + { + return false; + } + } +} + +/** + * @brief Check whether this visual type can use borderline feature or not. + * @param type VisualType that want to checkup + * @return true if type can use borderline feature. + */ +static bool IsTypeAvailableForBorderline(Toolkit::Visual::Type type) +{ + switch(static_cast(type)) + { + case Toolkit::Visual::Type::COLOR: + case Toolkit::Visual::Type::GRADIENT: + case Toolkit::Visual::Type::IMAGE: + case Toolkit::Visual::Type::SVG: + case Toolkit::Visual::Type::ANIMATED_IMAGE: + case Toolkit::DevelVisual::Type::ANIMATED_VECTOR_IMAGE: + { + return true; + } + default: + { + return false; + } + } +} + } // namespace Visual::Base::Base(VisualFactoryCache& factoryCache, FittingMode fittingMode, Toolkit::Visual::Type type) @@ -95,7 +146,7 @@ void Visual::Base::Initialize() mImpl->mBorderlineColorIndex = mImpl->mRenderer.RegisterProperty(DevelVisual::Property::BORDERLINE_COLOR, BORDERLINE_COLOR, mImpl->mBorderlineColor); mImpl->mBorderlineOffsetIndex = mImpl->mRenderer.RegisterProperty(DevelVisual::Property::BORDERLINE_OFFSET, BORDERLINE_OFFSET, mImpl->mBorderlineOffset); - mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); + mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL); } } } @@ -373,6 +424,20 @@ void Visual::Base::GetNaturalSize(Vector2& naturalSize) void Visual::Base::DoAction(const Property::Index actionId, const Property::Value attributes) { OnDoAction(actionId, attributes); + + // Check if action is valid for this visual type and perform action if possible + switch(actionId) + { + case DevelVisual::Action::UPDATE_PROPERTY: + { + const Property::Map* map = attributes.GetMap(); + if(map) + { + SetProperties(*map); + } + break; + } + } } void Visual::Base::SetDepthIndex(int index) @@ -525,22 +590,32 @@ bool Visual::Base::IsOnScene() const bool Visual::Base::IsRoundedCornerRequired() const { - if(mImpl->mRenderer && mImpl->mCornerRadiusIndex != Property::INVALID_INDEX) + // If VisualType doesn't support rounded corner, always return false. + if(IsTypeAvailableForCornerRadius(mImpl->mType)) { - // Update values from Renderer - mImpl->mCornerRadius = mImpl->mRenderer.GetProperty(mImpl->mCornerRadiusIndex); + if(mImpl->mRenderer && mImpl->mCornerRadiusIndex != Property::INVALID_INDEX) + { + // Update values from Renderer + mImpl->mCornerRadius = mImpl->mRenderer.GetProperty(mImpl->mCornerRadiusIndex); + } + return !(mImpl->mCornerRadius == Vector4::ZERO) || mImpl->mAlwaysUsingCornerRadius; } - return !(mImpl->mCornerRadius == Vector4::ZERO) || mImpl->mNeedCornerRadius; + return false; } bool Visual::Base::IsBorderlineRequired() const { - if(mImpl->mRenderer && mImpl->mBorderlineWidthIndex != Property::INVALID_INDEX) + // If VisualType doesn't support borderline, always return false. + if(IsTypeAvailableForBorderline(mImpl->mType)) { - // Update values from Renderer - mImpl->mBorderlineWidth = mImpl->mRenderer.GetProperty(mImpl->mBorderlineWidthIndex); + if(mImpl->mRenderer && mImpl->mBorderlineWidthIndex != Property::INVALID_INDEX) + { + // Update values from Renderer + mImpl->mBorderlineWidth = mImpl->mRenderer.GetProperty(mImpl->mBorderlineWidthIndex); + } + return !EqualsZero(mImpl->mBorderlineWidth) || mImpl->mAlwaysUsingBorderline; } - return !EqualsZero(mImpl->mBorderlineWidth) || mImpl->mNeedBorderline; + return false; } void Visual::Base::OnDoAction(const Property::Index actionId, const Property::Value& attributes) @@ -897,33 +972,42 @@ Dali::Property Visual::Base::GetPropertyObject(Dali::Property::Key key) Property::Index index = GetPropertyIndex(key); if(index == Property::INVALID_INDEX) { - if((key.type == Property::Key::INDEX && key.indexKey == DevelVisual::Property::BORDERLINE_WIDTH) || (key.type == Property::Key::STRING && key.stringKey == BORDERLINE_WIDTH) || - (key.type == Property::Key::INDEX && key.indexKey == DevelVisual::Property::BORDERLINE_COLOR) || (key.type == Property::Key::STRING && key.stringKey == BORDERLINE_COLOR) || - (key.type == Property::Key::INDEX && key.indexKey == DevelVisual::Property::BORDERLINE_OFFSET) || (key.type == Property::Key::STRING && key.stringKey == BORDERLINE_OFFSET)) + if(IsTypeAvailableForBorderline(mImpl->mType) && + ((key.type == Property::Key::INDEX && key.indexKey == DevelVisual::Property::BORDERLINE_WIDTH) || (key.type == Property::Key::STRING && key.stringKey == BORDERLINE_WIDTH) || + (key.type == Property::Key::INDEX && key.indexKey == DevelVisual::Property::BORDERLINE_COLOR) || (key.type == Property::Key::STRING && key.stringKey == BORDERLINE_COLOR) || + (key.type == Property::Key::INDEX && key.indexKey == DevelVisual::Property::BORDERLINE_OFFSET) || (key.type == Property::Key::STRING && key.stringKey == BORDERLINE_OFFSET))) { - mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); + mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL); // Register borderline properties mImpl->mBorderlineWidthIndex = mImpl->mRenderer.RegisterProperty(DevelVisual::Property::BORDERLINE_WIDTH, BORDERLINE_WIDTH, mImpl->mBorderlineWidth); mImpl->mBorderlineColorIndex = mImpl->mRenderer.RegisterProperty(DevelVisual::Property::BORDERLINE_COLOR, BORDERLINE_COLOR, mImpl->mBorderlineColor); mImpl->mBorderlineOffsetIndex = mImpl->mRenderer.RegisterProperty(DevelVisual::Property::BORDERLINE_OFFSET, BORDERLINE_OFFSET, mImpl->mBorderlineOffset); - mImpl->mNeedBorderline = true; + + // Borderline is animated now. we always have to use borderline feature. + mImpl->mAlwaysUsingBorderline = true; index = mImpl->mRenderer.GetPropertyIndex(key); // Change shader UpdateShader(); } - else if((key.type == Property::Key::INDEX && key.indexKey == DevelVisual::Property::CORNER_RADIUS) || (key.type == Property::Key::STRING && key.stringKey == CORNER_RADIUS)) + else if(IsTypeAvailableForCornerRadius(mImpl->mType) && ((key.type == Property::Key::INDEX && key.indexKey == DevelVisual::Property::CORNER_RADIUS) || (key.type == Property::Key::STRING && key.stringKey == CORNER_RADIUS))) { // Register CORNER_RADIUS property mImpl->mCornerRadiusIndex = mImpl->mRenderer.RegisterProperty(DevelVisual::Property::CORNER_RADIUS, CORNER_RADIUS, mImpl->mCornerRadius); mImpl->mRenderer.RegisterProperty(CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy); - mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); + // ConerRadius is animated now. we always have to use corner radius feature. + mImpl->mAlwaysUsingCornerRadius = true; + + if(!IsBorderlineRequired()) + { + // If IsBorderlineRequired is true, BLEND_MODE is already BlendMode::ON_WITHOUT_CULL. So we don't overwrite it. + mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); + } - index = mImpl->mCornerRadiusIndex; - mImpl->mNeedCornerRadius = true; + index = mImpl->mCornerRadiusIndex; // Change shader UpdateShader();