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 #include "bridge/cj_frontend/interfaces/cj_ffi/cj_line_ffi.h"
17
18 #include "bridge/cj_frontend/interfaces/cj_ffi/cj_shape_ffi.h"
19 #include "bridge/cj_frontend/interfaces/cj_ffi/cj_view_abstract_ffi.h"
20 #include "core/components_ng/pattern/shape/line_model.h"
21 #include "core/components_ng/pattern/shape/line_model_ng.h"
22
23 using namespace OHOS::Ace;
24 using namespace OHOS::Ace::Framework;
25
26 extern "C" {
FfiOHOSAceFrameworkLineCreate(double width,int32_t widthUnit,double height,int32_t heightUnit)27 void FfiOHOSAceFrameworkLineCreate(double width, int32_t widthUnit, double height, int32_t heightUnit)
28 {
29 LineModel::GetInstance()->Create();
30 if (width > 0.0) {
31 FfiOHOSAceFrameworkShapeSetWidth(width, widthUnit);
32 }
33 if (height > 0.0) {
34 FfiOHOSAceFrameworkShapeSetHeight(height, heightUnit);
35 }
36 }
37
FfiOHOSAceFrameworkLineSetStart(double x,double y)38 void FfiOHOSAceFrameworkLineSetStart(double x, double y)
39 {
40 ShapePoint startPoint;
41 startPoint.first = Dimension(x, DimensionUnit::VP);
42 startPoint.second = Dimension(y, DimensionUnit::VP);
43 LineModel::GetInstance()->StartPoint(startPoint);
44 }
45
FfiOHOSAceFrameworkLineSetEnd(double x,double y)46 void FfiOHOSAceFrameworkLineSetEnd(double x, double y)
47 {
48 ShapePoint endPoint;
49 endPoint.first = Dimension(x, DimensionUnit::VP);
50 endPoint.second = Dimension(y, DimensionUnit::VP);
51 LineModel::GetInstance()->EndPoint(endPoint);
52 }
53 }
54