added class FloatColor
authorDae Young Ryu <karzia@samsung.com>
Tue, 5 Nov 2013 02:52:19 +0000 (11:52 +0900)
committerDae Young Ryu <karzia@samsung.com>
Tue, 5 Nov 2013 02:52:19 +0000 (11:52 +0900)
Change-Id: Ib4c64f584828bf6087440d87a8eab3c9daa1813f
Signed-off-by: Dae Young Ryu <karzia@samsung.com>
inc/FUiAnimFloatColor.h [new file with mode: 0644]
src/ui/CMakeLists.txt
src/ui/animations/FUiAnimFloatColor.cpp [new file with mode: 0644]

diff --git a/inc/FUiAnimFloatColor.h b/inc/FUiAnimFloatColor.h
new file mode 100644 (file)
index 0000000..c294649
--- /dev/null
@@ -0,0 +1,297 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 3.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-3.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.
+//
+
+/**
+ * @file       FGrpColor.h
+ * @brief      This is the header file for the %FloatColor class.
+ *
+ * This header file contains the declarations of the %FloatColor class.
+ *
+ */
+
+#ifndef _FUI_ANIM_FLOAT_COLOR_H_
+#define _FUI_ANIM_FLOAT_COLOR_H_
+
+#include <FBaseTypes.h>
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Graphics {
+class Color;
+}}
+
+namespace Tizen { namespace Ui { namespace Animations
+{
+
+
+
+
+
+/**
+ * @class      FloatColor
+ * @brief      This class encapsulates a color.
+ *
+ * @since      3.0
+ *
+ * @final      This class is not intended for extension.
+ *
+ * The %FloatColor class provides an normalized RGBA (Red, Green, Blue, Alpha) color model.
+ * each parameter has a value between 0.0 to 1.0.
+ *
+ * @code
+ *
+ *     #include <FUi.h>
+ *
+ *     using namespace Tizen::Ui::Animations;
+ *
+ *     const unsigned FloatColor(1.0f, 1.0f, 1.0f, 1.0f); //r,g,b,a value
+ *
+ *
+ * @endcode
+ *
+ */
+class _OSP_EXPORT_ FloatColor
+       : public Tizen::Base::Object
+{
+
+public:
+       /**
+        * This is the default constructor for this class.
+        *
+        * @since       3.0
+        */
+       FloatColor(void);
+
+       /**
+        * This is the copy constructor for the %FloatColor class. @n
+        * This constructor initializes the instance of %FloatColor with the attributes of the specified instance of %FloatColor.
+        *
+        * @since                       3.0
+        *
+        * @param[in]   rhs     An instance of %FloatColor
+        */
+       FloatColor(const FloatColor& rhs);
+
+       /**
+        * This is the copy constructor for the %FloatColor class. @n
+        * This constructor initializes the instance of %FloatColor with the attributes of the specified instance of %FloatColor.
+        *
+        * @since                       3.0
+        *
+        * @param[in]   rhs     An instance of %Graphics::Color
+        */
+       FloatColor(const Color& rhs);
+
+       /**
+        * Initializes the instance of %FloatColor with the specified ARGB values.
+        *
+        * @since                       3.0
+        *
+        * @param[in]   r       The red component
+        * @param[in]   g       The green component
+        * @param[in]   b       The blue component
+        * @param[in]   a       The alpha component
+        */
+       FloatColor(float red, float green, float blue, float alpha = 1.0f);
+
+       /**
+        * This is the destructor for this class.
+        *
+        * @since       3.0
+        */
+       virtual ~FloatColor(void);
+
+
+public:
+       /**
+        * Checks whether the two instances of %FloatColor are equal.
+        *
+        * @since                       3.0
+        *
+        * @return              @c true if the values of the two instances of %FloatColor are equal, @n
+        *               else @c false
+        * @param[in]   rhs             An instance of %FloatColor
+        */
+       bool operator ==(const FloatColor& rhs) const;
+
+       /**
+        * Checks whether the two instances of %FloatColor are not equal.
+        *
+        * @since                       3.0
+        *
+        * @return              @c true if the values of the two instances of %FloatColor are not equal, @n
+        *               else @c false
+        * @param[in]   rhs             An instance of %FloatColor
+        *
+        */
+       bool operator !=(const FloatColor& rhs) const;
+
+       /**
+        * Assigns the values of the RGB components of the specified instance to the current instance of %FloatColor.
+        *
+        * @since                       3.0
+        *
+        * @return              The reference to the instance of %FloatColor
+        * @param[in]   rhs             An instance of %FloatColor
+        */
+       FloatColor& operator =(const FloatColor& rhs);
+
+
+public:
+       /**
+        * Checks whether the current instance of %FloatColor equals the specified instance of %FloatColor.
+        *
+        * @since                       3.0
+        *
+        * @return              @c true if the values of the current instance is equal to the value of the specified instance, @n
+        *               else @c false
+        * @param[in]   rhs             An instance of %FloatColor
+        * @remarks     This method overrides Tizen::Base::Object::Equals(). This method uses the values of the RGB components to compare the two instances.
+        */
+       virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+       /**
+        * Gets the hash value of the current instance of %FloatColor.
+        *
+        * @since               3.0
+        *
+        * @return              The hash value of the current instance
+        * @remarks     Two equal instances must return the same hash value. For better performance,
+        *                              the used hash function must generate a random distribution for all inputs.
+        */
+       virtual int GetHashCode(void) const;
+
+
+public:
+       /**
+        * Gets the value of the alpha component of the current instance of %FloatColor.
+        *
+        * @since               3.0
+        *
+        * @return      A @c byte representation of the alpha component of the current instance of %FloatColor
+        */
+       float GetAlpha(void) const;
+
+       /**
+        * Gets the value of the red component of the current instance of %FloatColor.
+        *
+        * @since               3.0
+        *
+        * @return      A @c byte representation of the red component of the current instance of %FloatColor
+        */
+       float GetRed(void) const;
+
+       /**
+        * Gets the value of the blue component of the current instance of %FloatColor.
+        *
+        * @since               3.0
+        *
+        * @return      A @c byte representation of the blue component of the current instance of %FloatColor
+        */
+       float GetBlue(void) const;
+
+       /**
+        * Gets the value of the green component of the current instance of %FloatColor.
+        *
+        * @since               3.0
+        *
+        * @return      A @c byte representation of the green component of the current instance of %FloatColor
+        */
+       float GetGreen(void) const;
+
+       /**
+        * Gets the ARGB components of the current instance of %FloatColor.
+        *
+        * @since                               3.0
+        *
+        * @param[out]  r       The red component
+        * @param[out]  g       The green component
+        * @param[out]  b       The blue component
+        * @param[out]  a       The alpha component
+        */
+       void GetColorComponents(float& r, float& g, float& b, float& a) const;
+
+
+       /**
+        * Sets the value of the alpha component of the current instance of %FloatColor.
+        *
+        * @since                       3.0
+        *
+        * @param[in]   a       The new value of the alpha component
+        */
+       void SetAlpha(float a);
+
+       /**
+        * Sets the value of the red component of the current instance of %FloatColor.
+        *
+        * @since                       3.0
+        *
+        * @param[in]   r       The new value of the red component
+        */
+       void SetRed(float r);
+
+       /**
+        * Sets the value of the green component of the current instance of %FloatColor.
+        *
+        * @since                       3.0
+        *
+        * @param[in]   g       The new value of the green component
+        */
+       void SetGreen(float g);
+
+       /**
+        * Sets the value of the blue component of the current instance of %FloatColor.
+        *
+        * @since                       3.0
+        *
+        * @param[in]   b       The new value of the blue component
+        */
+       void SetBlue(float b);
+
+       /**
+        * Sets the values of the ARGB components of the current instance of %FloatColor.
+        *
+        * @since                       3.0
+        *
+        * @param[in]   r       The red component
+        * @param[in]   g       The green component
+        * @param[in]   b       The blue component
+        * @param[in]   a       The alpha component
+        */
+       void SetColorComponents(float r, float g, float b, float a = 1.0f);
+
+
+public:
+       float red;
+       float green;
+       float blue;
+       float alpha;
+
+       friend class _FloatColorImpl;
+
+       //
+       // This variable is for internal use only.
+       // Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
+       //
+       // @since 3.0
+       //
+       class _FloatColorImpl * __pImpl;
+
+}; // FloatColor
+
+}}} // Tizen::Ui::Animations
+
+#endif //_FGRP_COLOR_H_
index b49d10b..4b06671 100644 (file)
@@ -144,6 +144,7 @@ SET (${this_target}_SOURCE_FILES
        animations/FUiAnimVisualElement.cpp
        animations/FUiAnimVisualElementAnimationProvider.cpp
        animations/FUiAnimVisualElementContentProvider.cpp
+       animations/FUiAnimFloatColor.cpp
        FUiAccessibilityContainer.cpp
        FUiAccessibilityElement.cpp
        FUi_AccessibilityContainer.cpp
diff --git a/src/ui/animations/FUiAnimFloatColor.cpp b/src/ui/animations/FUiAnimFloatColor.cpp
new file mode 100644 (file)
index 0000000..0769da5
--- /dev/null
@@ -0,0 +1,218 @@
+//
+// Open Service Platform
+// Copyright (c) 2012-2013 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.
+//
+
+/*
+ * @file       FGrpColor.cpp
+ * @brief      This is the implementation file for FloatColor class.
+ *
+ * This file contains implementation of FloatColor class.
+ *
+ */
+
+#include <FGrpColor.h>
+#include <FUiAnimFloatColor.h>
+
+
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Ui { namespace Animations
+{
+
+FloatColor::FloatColor(void)
+       : red(0.0f)
+       , green(0.0f)
+       , blue(0.0f)
+       , alpha(0.0f)
+       , __pImpl(null)
+{
+}
+
+FloatColor::FloatColor(const Color& rhs)
+       : red(0.0f)
+       , green(0.0f)
+       , blue(0.0f)
+       , alpha(0.0f)
+       , __pImpl(null)
+{
+       byte r = 0, g = 0, b = 0, a = 0;
+       rhs.GetColorComponents(r,g,b,a);
+
+       red   = (float)r/255;
+       green = (float)g/255;
+       blue  = (float)b/255;
+       alpha = (float)a/255;
+
+}
+
+FloatColor::FloatColor(const FloatColor& rhs)
+       : red(rhs.red)
+       , green(rhs.green)
+       , blue(rhs.blue)
+       , alpha(rhs.alpha)
+       , __pImpl(null)
+{
+}
+
+FloatColor::FloatColor(float r, float g, float b, float a)
+       : red(r)
+       , green(g)
+       , blue(b)
+       , alpha(a)
+       , __pImpl(null)
+{
+
+}
+
+FloatColor::~FloatColor(void)
+{
+}
+
+bool
+FloatColor::operator ==(const FloatColor& rhs) const
+{
+       return (red == rhs.red && green == rhs.green && blue == rhs.blue && alpha == rhs.alpha)?true:false;
+}
+
+bool
+FloatColor::operator !=(const FloatColor& rhs) const
+{
+       return (!operator ==(rhs));
+}
+
+FloatColor&
+FloatColor::operator =(const FloatColor& rhs)
+{
+       if (this == &rhs)
+       {
+               return *this;
+       }
+
+       red             = rhs.red;
+       green   = rhs.green;
+       blue    = rhs.blue;
+       alpha   = rhs.alpha;
+
+       return (*this);
+}
+
+bool
+FloatColor::Equals(const Tizen::Base::Object& rhs) const
+{
+       if (&rhs == null)
+       {
+               return false;
+       }
+
+       const FloatColor* pColor = dynamic_cast <const FloatColor*>(&rhs);
+
+       if (pColor == null)
+       {
+               return false;
+       }
+
+       return (*this == *pColor);
+}
+
+int
+FloatColor::GetHashCode(void) const
+{
+       //argb
+       int color = 0;
+       unsigned char tmp = 0;
+
+       tmp = static_cast<unsigned char>(alpha*255);
+       color = tmp;
+       color = color<<8;
+       tmp = static_cast<unsigned char>(red*255);
+       color |= tmp;
+       color = color<<8;
+       tmp = static_cast<unsigned char>(green*255);
+       color |= tmp;
+       color = color<<8;
+       tmp = static_cast<unsigned char>(blue*255);
+       color |= tmp;
+
+       return int(color);
+}
+
+float
+FloatColor::GetAlpha(void) const
+{
+       return alpha;
+}
+
+float
+FloatColor::GetRed(void) const
+{
+       return red;
+}
+
+float
+FloatColor::GetGreen(void) const
+{
+       return green;
+}
+
+float
+FloatColor::GetBlue(void) const
+{
+       return blue;
+}
+
+void
+FloatColor::GetColorComponents(float& r, float& g, float& b, float& a) const
+{
+       r = red;
+       g = green;
+       b = blue;
+       a = alpha;
+}
+
+void
+FloatColor::SetAlpha(float a)
+{
+       alpha = a;
+}
+
+void
+FloatColor::SetRed(float r)
+{
+       red = r;
+}
+
+void
+FloatColor::SetGreen(float g)
+{
+       green = g;
+}
+
+void
+FloatColor::SetBlue(float b)
+{
+       blue = b;
+}
+
+void
+FloatColor::SetColorComponents(float r, float g, float b, float a)
+{
+       red   = r;
+       green = g;
+       blue  = b;
+       alpha = a;
+}
+
+}}} // Tizen::Ui::Animations