• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #include "base/geometry/dimension.h"
16 #include "core/interfaces/native/node/api.h"
17 #include "frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h"
18 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_column_split_bridge.h"
19 
20 namespace OHOS::Ace::NG {
21 constexpr int NUM_0 = 0;
22 constexpr int NUM_1 = 1;
23 constexpr int NUM_2 = 2;
24 
SetResizeable(ArkUIRuntimeCallInfo * runtimeCallInfo)25 ArkUINativeModuleValue ColumnSplitBridge::SetResizeable(ArkUIRuntimeCallInfo *runtimeCallInfo)
26 {
27     EcmaVM *vm = runtimeCallInfo->GetVM();
28     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
29     Local<JSValueRef> nativeNodeArg = runtimeCallInfo->GetCallArgRef(0);
30     Local<JSValueRef> resizeableArg = runtimeCallInfo->GetCallArgRef(1);
31     void *nativeNode = nativeNodeArg->ToNativePointer(vm)->Value();
32     bool resizeable = false;
33     if (resizeableArg->IsBoolean()) {
34         resizeable = resizeableArg->ToBoolean(vm)->BooleaValue();
35     }
36     GetArkUIInternalNodeAPI()->GetColumnSplitModifier().SetColumnSplitResizeable(nativeNode, resizeable);
37     return panda::JSValueRef::Undefined(vm);
38 }
39 
ResetResizeable(ArkUIRuntimeCallInfo * runtimeCallInfo)40 ArkUINativeModuleValue ColumnSplitBridge::ResetResizeable(ArkUIRuntimeCallInfo *runtimeCallInfo)
41 {
42     EcmaVM *vm = runtimeCallInfo->GetVM();
43     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
44     Local<JSValueRef> nativeNodeArg = runtimeCallInfo->GetCallArgRef(0);
45     void *nativeNode = nativeNodeArg->ToNativePointer(vm)->Value();
46     GetArkUIInternalNodeAPI()->GetColumnSplitModifier().ResetColumnSplitResizeable(nativeNode);
47     return panda::JSValueRef::Undefined(vm);
48 }
49 
SetDivider(ArkUIRuntimeCallInfo * runtimeCallInfo)50 ArkUINativeModuleValue ColumnSplitBridge::SetDivider(ArkUIRuntimeCallInfo* runtimeCallInfo)
51 {
52     EcmaVM* vm = runtimeCallInfo->GetVM();
53     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
54     Local<JSValueRef> nativeNodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
55     Local<JSValueRef> startMarginArg = runtimeCallInfo->GetCallArgRef(NUM_1);
56     Local<JSValueRef> endMarginArg = runtimeCallInfo->GetCallArgRef(NUM_2);
57     void* nativeNode = nativeNodeArg->ToNativePointer(vm)->Value();
58     CalcDimension startMargin(0.0, DimensionUnit::VP);
59     CalcDimension endMargin(0.0, DimensionUnit::VP);
60     ArkTSUtils::ParseJsDimensionVp(vm, startMarginArg, startMargin);
61     ArkTSUtils::ParseJsDimensionVp(vm, endMarginArg, endMargin);
62     GetArkUIInternalNodeAPI()->GetColumnSplitModifier().SetColumnSplitDivider(nativeNode, startMargin.Value(),
63         static_cast<int32_t>(startMargin.Unit()), endMargin.Value(), static_cast<int32_t>(endMargin.Unit()));
64     return panda::JSValueRef::Undefined(vm);
65 }
66 
ResetDivider(ArkUIRuntimeCallInfo * runtimeCallInfo)67 ArkUINativeModuleValue ColumnSplitBridge::ResetDivider(ArkUIRuntimeCallInfo *runtimeCallInfo)
68 {
69     EcmaVM *vm = runtimeCallInfo->GetVM();
70     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
71     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
72     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
73     GetArkUIInternalNodeAPI()->GetColumnSplitModifier().ResetColumnSplitDivider(nativeNode);
74     return panda::JSValueRef::Undefined(vm);
75 }
76 } // namespace OHOS::Ace::NG
77