1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_INTERFACES_NODE_UTILS_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_INTERFACES_NODE_UTILS_H
18 
19 #include "core/interfaces/arkoala/arkoala_api.h"
20 #include "core/interfaces/cjui/cjui_api.h"
21 #include "core/components/theme/theme_manager.h"
22 #include "core/pipeline/pipeline_base.h"
23 
nodePtr(void * ptr)24 inline ArkUINodeHandle nodePtr(void* ptr)
25 {
26     return reinterpret_cast<ArkUINodeHandle>(ptr);
27 }
28 
29 constexpr int32_t INVALID_FONT_STYLE = -1;
30 constexpr int32_t INVALID_COLOR_VALUE = -1;
31 
32 namespace OHOS::Ace::NG {
33 
34 namespace NodeModifier {
35     const ArkUIStateModifier* GetUIStateModifier();
36     const CJUIStateModifier* GetCJUIStateModifier();
37 }
38 
GetTheme()39 template<typename T> OHOS::Ace::RefPtr<T> GetTheme()
40 {
41     auto pipelineContext = OHOS::Ace::PipelineBase::GetCurrentContextSafely();
42     CHECK_NULL_RETURN(pipelineContext, nullptr);
43     auto themeManager = pipelineContext->GetThemeManager();
44     CHECK_NULL_RETURN(themeManager, nullptr);
45     return themeManager->GetTheme<T>();
46 }
47 }
48 
49 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_INTERFACES_NODE_UTILS_H
50