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_divider_ffi.h"
17
18 #include "bridge/cj_frontend/interfaces/cj_ffi/utils.h"
19 #include "core/common/container.h"
20 #include "core/components_ng/pattern/divider/divider_model_ng.h"
21
22 using namespace OHOS::Ace;
23 using namespace OHOS::Ace::Framework;
24
25 namespace {
26 const std::vector<LineCap> LINECAP = { LineCap::BUTT, LineCap::ROUND, LineCap::SQUARE };
27 } // namespace
28
29 extern "C" {
FfiOHOSAceFrameworkDividerCreate()30 void FfiOHOSAceFrameworkDividerCreate()
31 {
32 DividerModel::GetInstance()->Create();
33 }
34
FfiOHOSAceFrameworkDividerSetVertical(bool isVertical)35 void FfiOHOSAceFrameworkDividerSetVertical(bool isVertical)
36 {
37 DividerModel::GetInstance()->Vertical(isVertical);
38 }
39
FfiOHOSAceFrameworkDividerSetLineCap(int32_t style)40 void FfiOHOSAceFrameworkDividerSetLineCap(int32_t style)
41 {
42 if (!Utils::CheckParamsValid(style, LINECAP.size())) {
43 LOGE("invalid value for image repeat");
44 return;
45 }
46
47 DividerModel::GetInstance()->LineCap(LINECAP[style]);
48 }
49
FfiOHOSAceFrameworkDividerSetStrokeWidth(double width,int32_t unit)50 void FfiOHOSAceFrameworkDividerSetStrokeWidth(double width, int32_t unit)
51 {
52 Dimension widthDime(width, static_cast<DimensionUnit>(unit));
53
54 DividerModel::GetInstance()->StrokeWidth(widthDime);
55 }
56
FfiOHOSAceFrameworkDividerSetDividerColor(uint32_t color)57 void FfiOHOSAceFrameworkDividerSetDividerColor(uint32_t color)
58 {
59 DividerModel::GetInstance()->DividerColor(Color(color));
60 }
61 }
62