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 "core/components_ng/pattern/linear_indicator/linear_indicator_layout_property.h"
17
18 #include "core/components_ng/pattern/linear_indicator/linear_indicator_theme.h"
19 #include "core/pipeline/pipeline_base.h"
20
21 namespace OHOS::Ace::NG {
22
LinearIndicatorLayoutProperty()23 LinearIndicatorLayoutProperty::LinearIndicatorLayoutProperty() : LinearLayoutProperty(false) {}
24
ToJsonValue(std::unique_ptr<JsonValue> & json,const InspectorFilter & filter) const25 void LinearIndicatorLayoutProperty::ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const
26 {
27 LayoutProperty::ToJsonValue(json, filter);
28 /* no fixed attr below, just return */
29 if (filter.IsFastFilter()) {
30 return;
31 }
32
33 auto pipeline = PipelineBase::GetCurrentContext();
34 CHECK_NULL_VOID(pipeline);
35 auto theme = pipeline->GetThemeManager()->GetTheme<NG::LinearIndicatorTheme>();
36 CHECK_NULL_VOID(theme);
37
38 auto jsonValue = JsonUtil::Create(true);
39
40 jsonValue->Put("space", GetSpaceValue(theme->GetDefaultSpace()).ToString().c_str());
41 jsonValue->Put("strokeWidth", GetStrokeWidthValue(theme->GetDefaultStrokeWidth()).ToString().c_str());
42 jsonValue->Put("strokeRadius", GetStrokeRadiusValue(theme->GetDefaultStrokeRadius()).ToString().c_str());
43 jsonValue->Put(
44 "trackBackgroundColor", GetTrackBackgroundColorValue(theme->GetTrackBackgroundColor()).ColorToString().c_str());
45 jsonValue->Put("trackColor", GetTrackColorValue(theme->GetTrackColor()).ColorToString().c_str());
46 json->PutExtAttr("indicatorStyle", jsonValue->ToString().c_str(), filter);
47 json->PutExtAttr("indicatorLoop", GetLoopValue(theme->GetDefaultLoop()) ? "True" : "False", filter);
48 json->PutExtAttr("count", GetProgressCountValue(theme->GetDefaultProgressCount()), filter);
49 }
50
51 } // namespace OHOS::Ace::NG
52