1 #ifndef DALI_PROPERTY_HELPER_H
2 #define DALI_PROPERTY_HELPER_H
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
25 #include <dali/integration-api/bitmap.h>
26 #include <dali/devel-api/scripting/enum-helper.h>
27 #include <dali/internal/event/object/default-property-metadata.h>
36 * These macros are used to define a table of property details per object.
37 * The index property is only compiled in for DEBUG_ENABLED builds and allows checking the table index VS the property enum index.
38 * DALI_PROPERTY_TABLE_END Forces a run-time check that will happen once.
39 * the macros define an instance of PropertyMetadata with the name that is passed to DALI_PROPERTY_TABLE_END
41 #define DALI_PROPERTY_TABLE_BEGIN const Dali::PropertyDetails DEFAULT_PROPERTY_DETAILS[] = {
43 #define DALI_PROPERTY_TABLE_END( startIndex, constantName ) }; const Property::Index DEFAULT_PROPERTY_COUNT = static_cast<Property::Index>( sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( Dali::PropertyDetails ) ); \
44 struct PROPERTY_CHECK \
48 for( int i = 0; i < DEFAULT_PROPERTY_COUNT; i++ ) \
50 if ( DEFAULT_PROPERTY_DETAILS[i].enumIndex != ( startIndex + i ) ) \
52 DALI_LOG_ERROR( "Checking property failed: index:%d, enumIndex:%d == index+start:%d, (name:%s)\n", i, \
53 DEFAULT_PROPERTY_DETAILS[i].enumIndex, (startIndex + i), DEFAULT_PROPERTY_DETAILS[i].name ); \
54 DALI_ASSERT_DEBUG( false && "Property enumeration mismatch" ); \
59 constexpr Dali::DefaultPropertyMetadata constantName{ DEFAULT_PROPERTY_DETAILS, DEFAULT_PROPERTY_COUNT }; \
60 static PROPERTY_CHECK PROPERTY_CHECK_INSTANCE;
62 #define DALI_PROPERTY_TABLE_END( startIndex, constantName ) }; const Property::Index DEFAULT_PROPERTY_COUNT = static_cast<Property::Index>( sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( Dali::PropertyDetails ) );\
63 constexpr Dali::DefaultPropertyMetadata constantName{ DEFAULT_PROPERTY_DETAILS, DEFAULT_PROPERTY_COUNT };
65 #define DALI_PROPERTY( text, type, writable, animatable, constraint, index ) { text, index, Dali::Property::type, writable, animatable, constraint },
68 * @brief Case insensitive string comparison.
70 * Additionally, '-' and '_' can be used interchangeably as well.
71 * Returns if both strings have a ',' or a '\0' at the same point.
73 * @param[in] first The first string.
74 * @param[in] second The string to compare it to.
75 * @param[out] size The size of the string.
77 * @return true if strings are the same
79 bool CompareTokens( const char * first, const char * second, uint32_t& size );
83 * @brief Helper to adjust the current value of a variable from the given property-value
84 * @param[in] currentValue The current value of the property
85 * @param[in] value The relative value as a Property::Value
86 * @return true if value adjusted, false otherwise
88 template< typename PropertyType >
89 bool AdjustValue( PropertyType& currentValue, const Property::Value& value )
91 PropertyType relativeValue;
92 if( value.Get( relativeValue ) )
94 currentValue += relativeValue;
100 } // namespace Internal
104 #endif // DALI_PROPERTY_HELPER_H