[4.0] Add Property::EXTENTS type 20/155920/2 accepted/tizen/4.0/unified/20171017.212908 submit/tizen_4.0/20171017.144330 submit/tizen_4.0/20171017.145254 tizen_4.0.m2_release
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Wed, 11 Oct 2017 02:53:06 +0000 (11:53 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Mon, 16 Oct 2017 13:22:04 +0000 (22:22 +0900)
- Extents is a collection of 4 uint16_t.

Change-Id: Ia39db06622d22775cc8a81e61d991508b0f760d3
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
18 files changed:
automated-tests/src/dali/CMakeLists.txt
automated-tests/src/dali/dali-test-suite-utils/test-compare-types.h
automated-tests/src/dali/utc-Dali-Extents.cpp [new file with mode: 0644]
automated-tests/src/dali/utc-Dali-PropertyValue.cpp
dali/internal/event/common/object-impl.cpp
dali/internal/event/common/property-buffer-impl.cpp
dali/internal/event/common/property-metadata.cpp
dali/internal/render/renderers/render-property-buffer.cpp
dali/public-api/CMakeLists.txt
dali/public-api/common/extents.cpp [new file with mode: 0644]
dali/public-api/common/extents.h [new file with mode: 0644]
dali/public-api/dali-core.h
dali/public-api/file.list
dali/public-api/object/property-types.cpp
dali/public-api/object/property-types.h
dali/public-api/object/property-value.cpp
dali/public-api/object/property-value.h
dali/public-api/object/property.h

index ad992d5..e75f2d2 100644 (file)
@@ -27,6 +27,7 @@ SET(TC_SOURCES
         utc-Dali-Degree.cpp
         utc-Dali-DistanceField.cpp
         utc-Dali-EncodedBufferImage.cpp
+        utc-Dali-Extents.cpp
         utc-Dali-FrameBuffer.cpp
         utc-Dali-FrameBufferImage.cpp
         utc-Dali-Geometry.cpp
index dd6ba24..5870028 100644 (file)
@@ -105,6 +105,15 @@ inline bool CompareType<Degree>(Degree q1, Degree q2, float epsilon)
 }
 
 template <>
+inline bool CompareType<Extents>(Extents extents1, Extents extents2, float epsilon)
+{
+  return (extents1.start == extents2.start) &&
+         (extents1.end == extents2.end) &&
+         (extents1.top == extents2.top) &&
+         (extents1.bottom == extents2.bottom);
+}
+
+template <>
 inline bool CompareType<Property::Value>(Property::Value q1, Property::Value q2, float epsilon)
 {
   Property::Type type = q1.GetType();
@@ -191,6 +200,14 @@ inline bool CompareType<Property::Value>(Property::Value q1, Property::Value q2,
       result = false;
       break;
     }
+    case Property::EXTENTS:
+    {
+      Extents a, b;
+      q1.Get(a);
+      q2.Get(b);
+      result = CompareType<Extents>( a, b, epsilon );
+      break;
+    }
     case Property::NONE:
     {
       result = false;
diff --git a/automated-tests/src/dali/utc-Dali-Extents.cpp b/automated-tests/src/dali/utc-Dali-Extents.cpp
new file mode 100644 (file)
index 0000000..d2c2280
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2017 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.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+namespace
+{
+/// Compare a uint16_t value with an unsigned int
+void DALI_TEST_EQUALS( uint16_t value1, unsigned int value2, const char* location )
+{
+  ::DALI_TEST_EQUALS< uint16_t >( value1, static_cast< uint16_t >( value2 ), location );
+}
+} // unnamed namespace
+
+void utc_dali_extents_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_extents_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+int UtcDaliExtentsConstructor01(void)
+{
+  TestApplication application;
+
+  Extents extent;
+  DALI_TEST_EQUALS( extent.start, 0u, TEST_LOCATION );
+  DALI_TEST_EQUALS( extent.end, 0u, TEST_LOCATION );
+  DALI_TEST_EQUALS( extent.top, 0u, TEST_LOCATION );
+  DALI_TEST_EQUALS( extent.bottom, 0u, TEST_LOCATION );
+  END_TEST;
+}
+
+int UtcDaliExtentsConstructor02(void)
+{
+  TestApplication application;
+
+  Extents extent( 10u, 20u, 400u, 200u );
+  DALI_TEST_EQUALS( extent.start, 10u, TEST_LOCATION );
+  DALI_TEST_EQUALS( extent.end, 20u, TEST_LOCATION );
+  DALI_TEST_EQUALS( extent.top, 400u, TEST_LOCATION );
+  DALI_TEST_EQUALS( extent.bottom, 200u, TEST_LOCATION );
+  END_TEST;
+}
+
+int UtcDaliExtentsConstructor03(void)
+{
+  TestApplication application;
+
+  Extents extent( 10u, 20u, 400u, 200u );
+
+  Extents e2 = extent;
+
+  DALI_TEST_EQUALS( e2.start, 10u, TEST_LOCATION );
+  DALI_TEST_EQUALS( e2.end, 20u, TEST_LOCATION );
+  DALI_TEST_EQUALS( e2.top, 400u, TEST_LOCATION );
+  DALI_TEST_EQUALS( e2.bottom, 200u, TEST_LOCATION );
+  END_TEST;
+}
+
+int UtcDaliExtentsCopyConstructor(void)
+{
+  TestApplication application;
+
+  Extents extent( 10u, 20u, 400u, 200u );
+
+  Extents extent2( extent );
+
+  DALI_TEST_EQUALS( extent2.start, 10u, TEST_LOCATION );
+  DALI_TEST_EQUALS( extent2.end, 20u, TEST_LOCATION );
+  DALI_TEST_EQUALS( extent2.top, 400u, TEST_LOCATION );
+  DALI_TEST_EQUALS( extent2.bottom, 200u, TEST_LOCATION );
+  END_TEST;
+}
+
+int UtcDaliExtentsCopyAssignment(void)
+{
+  TestApplication application;
+
+  Extents extent;
+
+  Extents extent2( 10u, 20u, 400u, 200u );
+  extent = extent2;
+
+  DALI_TEST_EQUALS( extent.start, 10u, TEST_LOCATION );
+  DALI_TEST_EQUALS( extent.end, 20u, TEST_LOCATION );
+  DALI_TEST_EQUALS( extent.top, 400u, TEST_LOCATION );
+  DALI_TEST_EQUALS( extent.bottom, 200u, TEST_LOCATION );
+  END_TEST;
+}
+
+int UtcDaliExtentsAssignP(void)
+{
+  Extents extent;
+  const uint16_t array[] = { 1u, 2u, 3u, 4u };
+  extent = (const uint16_t*)array;
+
+  DALI_TEST_EQUALS( extent.start, 1u, TEST_LOCATION);
+  DALI_TEST_EQUALS( extent.end, 2u, TEST_LOCATION);
+  DALI_TEST_EQUALS( extent.top, 3u, TEST_LOCATION);
+  DALI_TEST_EQUALS( extent.bottom, 4u, TEST_LOCATION);
+  END_TEST;
+}
+
+int UtcDaliExtentsOperatorNotEquals(void)
+{
+  TestApplication application;
+
+  Extents extent1( 10u, 20u, 200u, 200u );
+  Extents extent2( 10u, 120u, 200u, 200u );
+  Extents extent3( 10u, 80u, 200u, 200u );
+
+  DALI_TEST_CHECK( extent1 != extent2 );
+  DALI_TEST_CHECK( extent1 != extent3 );
+  END_TEST;
+}
+
+int UtcDaliExtentsOperatorEquals(void)
+{
+  TestApplication application;
+
+  Extents extent1( 10u, 20u, 200u, 200u );
+  Extents extent1p( 10u, 20u, 200u, 200u );
+
+  Extents extent2( 10u, 120u, 200u, 200u );
+  Extents extent3( 10u, 80u, 200u, 200u );
+
+  DALI_TEST_CHECK( extent1 == extent1p );
+  DALI_TEST_CHECK( extent1 == extent1 );
+  DALI_TEST_CHECK( !( extent1 == extent2 ) );
+  DALI_TEST_CHECK( !( extent1 == extent3 ) );
+
+  END_TEST;
+}
+
+int UtcDaliExtentsOStreamOperatorP(void)
+{
+  TestApplication application;
+  std::ostringstream oss;
+
+  Extents extent( 1u, 2u, 10u, 10u );
+
+  oss << extent;
+
+  std::string expectedOutput = "[1, 2, 10, 10]";
+
+  DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION);
+  END_TEST;
+}
index 99abb22..91b4768 100644 (file)
@@ -377,6 +377,26 @@ int UtcDaliPropertyValueConstructorsMapTypeP(void)
   END_TEST;
 }
 
+int UtcDaliPropertyValueConstructorsExtentsTypeP(void)
+{
+  Property::Value value( Property::EXTENTS );
+
+  DALI_TEST_CHECK( value.GetType() == Property::EXTENTS );
+  DALI_TEST_CHECK( value.Get<Extents>() == Extents( 0u, 0u, 0u, 0u ) );
+
+  END_TEST;
+}
+
+int UtcDaliPropertyValueConstructorsExtentsType2P(void)
+{
+  Property::Value value( Property::VECTOR4 );
+
+  DALI_TEST_CHECK( value.GetType() == Property::VECTOR4 );
+  DALI_TEST_CHECK( value.Get<Extents>() == Extents( 0u, 0u, 0u, 0u ) );
+
+  END_TEST;
+}
+
 int UtcDaliPropertyValueCopyConstructorP(void)
 {
   Property::Value value;
@@ -679,6 +699,19 @@ int UtcDaliPropertyValueAssignmentOperatorMapP(void)
   END_TEST;
 }
 
+int UtcDaliPropertyValueAssignmentOperatorExtentsP(void)
+{
+  Property::Value value;
+  value = Property::Value( Extents( 4, 3, 2, 1 ) ); // mismatch
+  DALI_TEST_CHECK( Extents( 4, 3, 2, 1 ) == value.Get<Extents>() );
+  Property::Value copy( Property::EXTENTS );
+  copy = value; // match
+  Extents copyExtents;
+  copy.Get(copyExtents);
+  DALI_TEST_CHECK( Extents( 4, 3, 2, 1 ) == copyExtents );
+  END_TEST;
+}
+
 int UtcDaliPropertyValueGetTypeP(void)
 {
   Property::Value value;
@@ -1117,6 +1150,16 @@ int UtcDaliPropertyValueGetMapN(void)
   END_TEST;
 }
 
+int UtcDaliPropertyValueGetExtentsP(void)
+{
+  Property::Value value( Extents( 1u, 2u, 3u, 4u ) );
+  Extents result( 4u, 3u, 2u, 1u );
+  DALI_TEST_EQUALS( Extents( 1u, 2u, 3u, 4u ), value.Get<Extents>(), TEST_LOCATION );
+  DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+  DALI_TEST_EQUALS( Extents( 1u, 2u, 3u, 4u ), result, TEST_LOCATION );
+  END_TEST;
+}
+
 int UtcDaliPropertyValueOutputStream(void)
 {
   TestApplication application;
@@ -1263,6 +1306,12 @@ int UtcDaliPropertyValueOutputStream(void)
     DALI_TEST_CHECK( !stream.str().compare("Map(3) = {color:[1, 0.5, 1, 1], timePeriod:Map(2) = {key:value, duration:10}, texCoords:Array(4) = [[1, 0], [0, 1], [1, 0], [0, 0.5]]}"));
   }
 
+  {
+    value = Property::Value( Extents( 1u, 2u, 3u, 4u ) );
+    std::ostringstream stream;
+    stream <<  value;
+    DALI_TEST_CHECK( stream.str() == "[1, 2, 3, 4]" );
+  }
 
   END_TEST;
 }
index f8c9312..2396fd1 100644 (file)
@@ -736,6 +736,7 @@ Property::Index Object::RegisterSceneGraphProperty(const std::string& name, Prop
     case Property::STRING:
     case Property::ARRAY:
     case Property::MAP:
+    case Property::EXTENTS:
     case Property::NONE:
     {
       DALI_ASSERT_ALWAYS( !"PropertyType is not animatable" );
index 0a83cc9..0718c4b 100644 (file)
@@ -110,6 +110,7 @@ unsigned int GetPropertyImplementationAlignment( Property::Type& propertyType )
     case Property::STRING:
     case Property::ARRAY:
     case Property::MAP:
+    case Property::EXTENTS:
     {
       // already handled by higher level code
     }
@@ -317,6 +318,7 @@ unsigned int GetPropertyImplementationSize( Property::Type& propertyType )
     case Property::STRING:
     case Property::ARRAY:
     case Property::MAP:
+    case Property::EXTENTS:
     {
       // already handled by higher level code
     }
index 41e0848..c77a570 100644 (file)
@@ -57,6 +57,7 @@ void PropertyMetadata::SetPropertyValue( const Property::Value& propertyValue )
     case Property::STRING:
     case Property::ARRAY:
     case Property::MAP:
+    case Property::EXTENTS:
     case Property::BOOLEAN:
     case Property::INTEGER:
     case Property::FLOAT:
@@ -165,6 +166,7 @@ Property::Value PropertyMetadata::GetPropertyValue() const
       case Property::STRING:
       case Property::ARRAY:
       case Property::MAP:
+      case Property::EXTENTS:
       case Property::BOOLEAN:
       case Property::INTEGER:
       case Property::FLOAT:
@@ -262,6 +264,7 @@ void PropertyMetadata::AdjustPropertyValueBy( const Property::Value& relativePro
     case Property::STRING:
     case Property::ARRAY:
     case Property::MAP:
+    case Property::EXTENTS:
     case Property::MATRIX:
     case Property::MATRIX3:
     {
index ccbd2d0..26d86c1 100644 (file)
@@ -35,6 +35,7 @@ Dali::GLenum GetPropertyImplementationGlType( Property::Type propertyType )
     case Property::STRING:
     case Property::ARRAY:
     case Property::MAP:
+    case Property::EXTENTS:
     case Property::RECTANGLE:
     case Property::ROTATION:
     {
@@ -76,6 +77,7 @@ size_t GetPropertyImplementationGlSize( Property::Type propertyType )
     case Property::STRING:
     case Property::ARRAY:
     case Property::MAP:
+    case Property::EXTENTS:
     case Property::RECTANGLE:
     case Property::ROTATION:
     {
index 19f1972..bf57dcd 100644 (file)
@@ -18,6 +18,7 @@ SET(SOURCES ${SOURCES}
   ${CMAKE_CURRENT_SOURCE_DIR}/common/constants.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/common/dali-common.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/common/dali-vector.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/common/extents.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/common/stage.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/events/gesture.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/events/gesture-detector.cpp
@@ -119,6 +120,7 @@ SET(PUBLIC_API_HEADERS
   ${CMAKE_CURRENT_SOURCE_DIR}/common/constants.h
   ${CMAKE_CURRENT_SOURCE_DIR}/common/dali-common.h
   ${CMAKE_CURRENT_SOURCE_DIR}/common/dali-vector.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/common/extents.h
   ${CMAKE_CURRENT_SOURCE_DIR}/common/intrusive-ptr.h
   ${CMAKE_CURRENT_SOURCE_DIR}/common/loading-state.h
   ${CMAKE_CURRENT_SOURCE_DIR}/common/stage.h
diff --git a/dali/public-api/common/extents.cpp b/dali/public-api/common/extents.cpp
new file mode 100644 (file)
index 0000000..95bdf19
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/public-api/common/extents.h>
+
+namespace Dali
+{
+
+Extents::Extents()
+: start(0),
+  end(0),
+  top(0),
+  bottom(0)
+  {
+  }
+
+Extents::Extents( uint16_t start, uint16_t end, uint16_t top, uint16_t bottom )
+: start( start ),
+  end( end ),
+  top( top ),
+  bottom( bottom )
+  {
+  }
+
+Extents& Extents::operator=( const uint16_t* array )
+{
+  start = array[0];
+  end = array[1];
+  top = array[2];
+  bottom = array[3];
+
+  return *this;
+}
+
+bool Extents::operator==( const Extents &rhs ) const
+{
+  return ( start == rhs.start )&&
+    ( end == rhs.end )&&
+    ( top == rhs.top )&&
+    ( bottom == rhs.bottom );
+}
+
+bool Extents::operator!=( const Extents &rhs ) const
+{
+  return !( *this == rhs );
+}
+
+std::ostream& operator<<( std::ostream& stream, const Extents& extents )
+{
+  return stream << "[" << extents.start << ", " << extents.end << ", " << extents.top << ", " << extents.bottom << "]";
+}
+
+} // Dali
diff --git a/dali/public-api/common/extents.h b/dali/public-api/common/extents.h
new file mode 100644 (file)
index 0000000..da62978
--- /dev/null
@@ -0,0 +1,123 @@
+#ifndef DALI_EXTENTS_H
+#define DALI_EXTENTS_H
+
+/*
+ * Copyright (c) 2017 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <cstdint>
+#include <ostream>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+
+namespace Dali
+{
+/**
+ * @addtogroup dali_core_common
+ * @{
+ */
+
+/**
+ * @brief Structure describing the a collection of uint16_t.
+ * @SINCE_1_2.62
+ */
+struct DALI_EXPORT_API Extents
+{
+  /**
+   * @brief Default constructor which provides an initialized Dali::Extents( 0u, 0u, 0u, 0u ).
+   * @SINCE_1_2.62
+   */
+  Extents();
+
+  /**
+   * @brief Copy constructor.
+   * @SINCE_1_2.62
+   * @param[in] copy A reference to the copied Extents
+   */
+  Extents( const Extents& copy ) = default;
+
+  /**
+   * @brief Constructor.
+   *
+   * @SINCE_1_2.62
+   * @param[in] start     Start extent
+   * @param[in] end       End extent
+   * @param[in] top       Top extent
+   * @param[in] bottom    Bottom extent
+   */
+  Extents( uint16_t start, uint16_t end, uint16_t top, uint16_t bottom );
+
+  /**
+   * @brief Copy Assignment operator.
+   * @SINCE_1_2.62
+   * @param[in] copy A reference to the copied Extents
+   * @return Itself
+   */
+  Extents& operator=( const Extents& copy ) = default;
+
+  /**
+   * @brief Assignment operator.
+   *
+   * @SINCE_1_2.62
+   * @param[in] array Array of uint16_t
+   * @return Itself
+   */
+  Extents& operator=( const uint16_t* array );
+
+  /**
+   * @brief Equality operator.
+   *
+   * @SINCE_1_2.62
+   * @param[in] rhs The Extents to test against
+   * @return True if the extents are equal
+   */
+  bool operator==( const Extents &rhs ) const;
+
+  /**
+   * @brief Inequality operator.
+   *
+   * @SINCE_1_2.62
+   * @param[in] rhs The Extents to test against
+   * @return True if the extents are not equal
+   */
+  bool operator!=( const Extents &rhs ) const;
+
+public:
+  uint16_t start;   ///< The start extent.  @SINCE_1_2.62
+  uint16_t end;     ///< The end extent.    @SINCE_1_2.62
+  uint16_t top;     ///< The top extent.    @SINCE_1_2.62
+  uint16_t bottom;  ///< The bottom extent. @SINCE_1_2.62
+
+};
+
+/**
+ * @brief Converts the value of the extents into a string and insert in to an output stream.
+ *
+ * @SINCE_1_2.62
+ * @param[in] stream The output stream operator
+ * @param[in] extents The Extents to output
+ * @return The output stream operator
+ */
+DALI_EXPORT_API std::ostream& operator<<( std::ostream& stream, const Extents& extents );
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // DALI_EXTENTS_H
index 3e602bf..ccbb290 100644 (file)
@@ -41,6 +41,7 @@
 #include <dali/public-api/common/constants.h>
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/common/extents.h>
 #include <dali/public-api/common/intrusive-ptr.h>
 #include <dali/public-api/common/loading-state.h>
 #include <dali/public-api/common/stage.h>
index 0315f04..ba9f26b 100644 (file)
@@ -19,6 +19,7 @@ public_api_src_files = \
   $(public_api_src_dir)/common/constants.cpp \
   $(public_api_src_dir)/common/dali-common.cpp \
   $(public_api_src_dir)/common/dali-vector.cpp \
+  $(public_api_src_dir)/common/extents.cpp \
   $(public_api_src_dir)/common/stage.cpp \
   $(public_api_src_dir)/events/gesture.cpp \
   $(public_api_src_dir)/events/gesture-detector.cpp \
@@ -124,6 +125,7 @@ public_api_core_common_header_files = \
   $(public_api_src_dir)/common/constants.h \
   $(public_api_src_dir)/common/dali-common.h \
   $(public_api_src_dir)/common/dali-vector.h \
+  $(public_api_src_dir)/common/extents.h \
   $(public_api_src_dir)/common/intrusive-ptr.h \
   $(public_api_src_dir)/common/loading-state.h \
   $(public_api_src_dir)/common/stage.h \
index a5e8d81..7f6e398 100644 (file)
@@ -39,6 +39,7 @@ const char* const PROPERTY_TYPE_NAMES[] =
   "STRING",
   "ARRAY",
   "MAP",
+  "EXTENTS",
 };
 const unsigned int PROPERTY_TYPE_NAMES_COUNT = sizeof( PROPERTY_TYPE_NAMES ) / sizeof( const char* );
 }
index f4fb499..fcbd608 100644 (file)
@@ -20,6 +20,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/constants.h>
+#include <dali/public-api/common/extents.h>
 #include <dali/public-api/math/angle-axis.h>
 #include <dali/public-api/math/degree.h>
 #include <dali/public-api/math/quaternion.h>
@@ -91,6 +92,8 @@ template <>
 inline Property::Type Get<Property::Map>()    { return Property::MAP; }
 template <>
 inline Property::Type Get<Property::Array>()  { return Property::ARRAY; }
+template <>
+inline Property::Type Get<Extents>()          { return Property::EXTENTS; }
 
 
 }; // namespace PropertyTypes
index d2d3e66..6c3738d 100644 (file)
@@ -22,6 +22,7 @@
 #include <ostream>
 
 // INTERNAL INCLUDES
+#include <dali/public-api/common/extents.h>
 #include <dali/public-api/math/angle-axis.h>
 #include <dali/public-api/math/radian.h>
 #include <dali/public-api/math/vector2.h>
@@ -136,6 +137,12 @@ struct Property::Value::Impl
   {
   }
 
+  Impl( const Extents& extentsValue )
+  : type( Property::EXTENTS ),
+    extentsValue( new Extents( extentsValue ) )
+  {
+  }
+
   /**
    * Destructor, takes care of releasing the dynamically allocated types
    */
@@ -200,6 +207,11 @@ struct Property::Value::Impl
         delete mapValue;
         break;
       }
+      case Property::EXTENTS:
+      {
+        delete extentsValue;
+        break;
+      }
     }
   }
 
@@ -221,6 +233,7 @@ public: // Data
     Rect<int>* rectValue;
     Property::Array* arrayValue;
     Property::Map* mapValue;
+    Extents* extentsValue;
   };
 
 private:
@@ -317,6 +330,11 @@ Property::Value::Value( Property::Map& mapValue )
 {
 }
 
+Property::Value::Value( const Extents& extentsValue )
+: mImpl( new Impl( extentsValue ) )
+{
+}
+
 Property::Value::Value( Type type )
 : mImpl( NULL )
 {
@@ -387,6 +405,11 @@ Property::Value::Value( Type type )
       mImpl = new Impl( Property::Map() );
       break;
     }
+    case Property::EXTENTS:
+    {
+      mImpl = new Impl( Extents() );
+      break;
+    }
     case Property::NONE:
     {
       mImpl = new Impl();
@@ -486,6 +509,11 @@ Property::Value& Property::Value::operator=( const Property::Value& value )
         *mImpl->mapValue = *value.mImpl->mapValue; // type cannot change in mImpl so map is allocated
         break;
       }
+      case Property::EXTENTS:
+      {
+        *mImpl->extentsValue = *value.mImpl->extentsValue; // type cannot change in mImpl so extents is allocated
+        break;
+      }
       case Property::NONE:
       { // mImpl will be NULL, there's no way to get to this case
       }
@@ -562,6 +590,11 @@ Property::Value& Property::Value::operator=( const Property::Value& value )
         newImpl = new Impl( *value.mImpl->mapValue ); // type cannot change in mImpl so map is allocated
         break;
       }
+      case Property::EXTENTS:
+      {
+        newImpl = new Impl( *value.mImpl->extentsValue ); // type cannot change in mImpl so extents is allocated
+        break;
+      }
       case Property::NONE:
       { // NULL value will be used for "empty" value
       }
@@ -804,6 +837,28 @@ Property::Map* Property::Value::GetMap() const
   return map;
 }
 
+bool Property::Value::Get( Extents& extentsValue ) const
+{
+  bool converted = false;
+  if( mImpl )
+  {
+    if( mImpl->type == EXTENTS )
+    {
+      extentsValue = *(mImpl->extentsValue);
+      converted = true;
+    }
+    else if( mImpl->type == VECTOR4 )
+    {
+      extentsValue.start = static_cast< uint16_t >( mImpl->vector4Value->x );
+      extentsValue.end = static_cast< uint16_t >( mImpl->vector4Value->y );
+      extentsValue.top = static_cast< uint16_t >( mImpl->vector4Value->z );
+      extentsValue.bottom = static_cast< uint16_t >( mImpl->vector4Value->w );
+      converted = true;
+    }
+  }
+  return converted;
+}
+
 std::ostream& operator<<( std::ostream& stream, const Property::Value& value )
 {
   if( value.mImpl )
@@ -877,6 +932,11 @@ std::ostream& operator<<( std::ostream& stream, const Property::Value& value )
         stream << *(value.GetMap());
         break;
       }
+      case Dali::Property::EXTENTS:
+      {
+        stream << *impl.extentsValue;
+        break;
+      }
       case Dali::Property::NONE:
       {
         stream << "undefined type";
index 5a4abed..5f2fa8e 100644 (file)
@@ -39,6 +39,7 @@ struct Vector3;
 struct Vector4;
 class Matrix3;
 class Matrix;
+struct Extents;
 
 /**
  * @brief A value-type representing a property value.
@@ -177,6 +178,14 @@ public:
   Value( Property::Map& mapValue );
 
   /**
+   * @brief Creates an extents property value.
+   *
+   * @SINCE_1_2.62
+   * @param[in] extentsValue A collection of 4 uint16_t values
+   */
+  Value( const Extents& extentsValue );
+
+  /**
    * @brief Explicitly sets a type and initialize it.
    *
    * @SINCE_1_0.0
@@ -390,6 +399,16 @@ public:
   Property::Map* GetMap() const;
 
   /**
+   * @brief Retrieves an extents.
+   *
+   * @SINCE_1_2.62
+   * @param[out] extentsValue Extents, a collection of 4 uint16_t
+   * @return @c true if the value is successfully retrieved, @c false if the type is not convertible
+   * @pre GetType() is a type convertible to Extents.
+   */
+  bool Get( Extents& extentsValue ) const;
+
+  /**
    * @brief Output to stream.
    * @SINCE_1_0.0
    */
index b24c365..acb5355 100644 (file)
@@ -93,7 +93,8 @@ struct DALI_IMPORT_API Property
     ROTATION,        ///< either a quaternion or an axis angle rotation @SINCE_1_0.0
     STRING,          ///< A string type @SINCE_1_0.0
     ARRAY,           ///< an array of Property::Value @SINCE_1_0.0
-    MAP              ///< a string key to Property:value mapping @SINCE_1_0.0
+    MAP,             ///< a string key to Property:value mapping @SINCE_1_0.0
+    EXTENTS          ///< a collection of 4 x uint16_t @SINCE_1_2.62
   };
 
   /**