X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fhelpers%2Fcolor-conversion.cpp;h=76415ff197397ce9394f04dca8622c11cb0c9125;hp=6789cee63e1ca667c9fd35c236da0b041c11de65;hb=f2039d47f9bed8104575da80a2ecf0bb6e37ff8d;hpb=f3e45e41c5f16ccc2538b283897ed6efb07e4ea9 diff --git a/dali-toolkit/internal/helpers/color-conversion.cpp b/dali-toolkit/internal/helpers/color-conversion.cpp index 6789cee..76415ff 100644 --- a/dali-toolkit/internal/helpers/color-conversion.cpp +++ b/dali-toolkit/internal/helpers/color-conversion.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -18,29 +18,28 @@ #include // EXTERNAL INCLUDES -#include -#include #include +#include +#include using Dali::Vector4; namespace { - /** * Converts a HTML style 'color' hex string ("#FF0000" for bright red) to a Vector4. * The Vector4 alpha component will be set to 1.0f * @param hexString The HTML style hex string * @return a Vector4 containing the new color value */ -Vector4 HexStringToVector4( const char* s ) +Vector4 HexStringToVector4(const char* s) { unsigned int value(0u); - std::istringstream( s ) >> std::hex >> value; - return Vector4( ((value >> 16 ) & 0xff ) / 255.0f, - ((value >> 8 ) & 0xff ) / 255.0f, - (value & 0xff ) / 255.0f, - 1.0f ); + std::istringstream(s) >> std::hex >> value; + return Vector4(((value >> 16) & 0xff) / 255.0f, + ((value >> 8) & 0xff) / 255.0f, + (value & 0xff) / 255.0f, + 1.0f); } } // unnamed namespace @@ -51,51 +50,50 @@ namespace Toolkit { namespace Internal { - -bool ConvertStringToColor( const std::string& colorString, Vector4& outColor ) +bool ConvertStringToColor(const std::string& colorString, Vector4& outColor) { - bool success( false ); + bool success(false); - if( ( '#' == colorString[0] ) && - ( 7 == colorString.size() ) ) + if(('#' == colorString[0]) && + (7 == colorString.size())) { const char* cString = colorString.c_str(); - outColor = HexStringToVector4( &cString[1] ); - success = true; + outColor = HexStringToVector4(&cString[1]); + success = true; } else { Dali::ColorController controller = Dali::ColorController::Get(); - if( controller ) + if(controller) { - success = controller.RetrieveColor( colorString, outColor ); + success = controller.RetrieveColor(colorString, outColor); } } return success; } -bool ConvertPropertyToColor( const Property::Value& colorValue, Vector4& outColor ) +bool ConvertPropertyToColor(const Property::Value& colorValue, Vector4& outColor) { - bool success( false ); + bool success(false); - if( Property::VECTOR4 == colorValue.GetType() ) + if(Property::VECTOR4 == colorValue.GetType()) { - success = colorValue.Get( outColor ); + success = colorValue.Get(outColor); } - else if( Property::STRING == colorValue.GetType() ) + else if(Property::STRING == colorValue.GetType()) { std::string colorString; - if( colorValue.Get( colorString ) ) + if(colorValue.Get(colorString)) { - success = ConvertStringToColor( colorString, outColor ); + success = ConvertStringToColor(colorString, outColor); } } return success; } -} // Internal -} // Toolkit -} // Dali +} // namespace Internal +} // namespace Toolkit +} // namespace Dali