1 #ifndef DALI_PROPERTY_HELPER_H
2 #define DALI_PROPERTY_HELPER_H
5 * Copyright (c) 2021 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/devel-api/scripting/enum-helper.h>
26 #include <dali/integration-api/bitmap.h>
27 #include <dali/internal/event/object/default-property-metadata.h>
34 * These macros are used to define a table of property details per object.
35 * Checking of the table index VS the property enum index happens during compile time.
36 * the macros define an instance of PropertyMetadata with the name that is passed to DALI_PROPERTY_TABLE_END
38 #define DALI_PROPERTY_TABLE_BEGIN static constexpr Dali::PropertyDetails DEFAULT_PROPERTY_DETAILS[] = {
39 #define DALI_PROPERTY_TABLE_END(startIndex, tableName) \
42 static constexpr auto tableName = GeneratePropertyMetadata(DEFAULT_PROPERTY_DETAILS); \
43 static_assert(CheckPropertyMetadata(tableName, startIndex), "Property enumeration mismatch");
45 #define DALI_PROPERTY(text, type, writable, animatable, constraint, index) {text, index, Dali::Property::type, writable, animatable, constraint},
48 * @brief Case insensitive string comparison.
50 * Additionally, '-' and '_' can be used interchangeably as well.
51 * Returns if both strings have a ',' or a '\0' at the same point.
53 * @param[in] first The first string.
54 * @param[in] second The string to compare it to.
55 * @param[out] size The size of the string.
57 * @return true if strings are the same
59 bool CompareTokens(const char* first, const char* second, uint32_t& size);
62 * @brief Helper to adjust the current value of a variable from the given property-value
63 * @param[in] currentValue The current value of the property
64 * @param[in] value The relative value as a Property::Value
65 * @return true if value adjusted, false otherwise
67 template<typename PropertyType>
68 bool AdjustValue(PropertyType& currentValue, const Property::Value& value)
70 PropertyType relativeValue;
71 if(value.Get(relativeValue))
73 currentValue += relativeValue;
79 } // namespace Internal
83 #endif // DALI_PROPERTY_HELPER_H