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 * Checking of the table index VS the property enum index happens during compile time.
38 * the macros define an instance of PropertyMetadata with the name that is passed to DALI_PROPERTY_TABLE_END
40 #define DALI_PROPERTY_TABLE_BEGIN static constexpr Dali::PropertyDetails DEFAULT_PROPERTY_DETAILS[] = {
42 #define DALI_PROPERTY_TABLE_END(startIndex, tableName) \
44 static constexpr auto tableName = GeneratePropertyMetadata(DEFAULT_PROPERTY_DETAILS); \
45 static_assert(CheckPropertyMetadata(tableName, startIndex), "Property enumeration mismatch");
47 #define DALI_PROPERTY( text, type, writable, animatable, constraint, index ) { text, index, Dali::Property::type, writable, animatable, constraint },
50 * @brief Case insensitive string comparison.
52 * Additionally, '-' and '_' can be used interchangeably as well.
53 * Returns if both strings have a ',' or a '\0' at the same point.
55 * @param[in] first The first string.
56 * @param[in] second The string to compare it to.
57 * @param[out] size The size of the string.
59 * @return true if strings are the same
61 bool CompareTokens( const char * first, const char * second, uint32_t& size );
65 * @brief Helper to adjust the current value of a variable from the given property-value
66 * @param[in] currentValue The current value of the property
67 * @param[in] value The relative value as a Property::Value
68 * @return true if value adjusted, false otherwise
70 template< typename PropertyType >
71 bool AdjustValue( PropertyType& currentValue, const Property::Value& value )
73 PropertyType relativeValue;
74 if( value.Get( relativeValue ) )
76 currentValue += relativeValue;
82 } // namespace Internal
86 #endif // DALI_PROPERTY_HELPER_H