1 /* 2 * Copyright (c) 2021 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_COMPONENTS_PROGRESS_PROGRESS_ELEMENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PROGRESS_PROGRESS_ELEMENT_H 18 19 #include "core/common/container.h" 20 #include "core/components/padding/padding_component.h" 21 #include "core/pipeline/base/render_element.h" 22 23 namespace OHOS::Ace { 24 25 // Progress element implementation 26 class ProgressElement : public RenderElement { 27 DECLARE_ACE_TYPE(ProgressElement, RenderElement); 28 29 public: Update()30 void Update() override 31 { 32 customComponent_ = component_; 33 RenderElement::Update(); 34 } 35 CanUpdate(const RefPtr<Component> & newComponent)36 bool CanUpdate(const RefPtr<Component>& newComponent) override 37 { 38 if (Container::IsCurrentUsePartialUpdate()) { 39 return Element::CanUpdate(newComponent); 40 } 41 return (newComponent == customComponent_) && Element::CanUpdate(newComponent); 42 } 43 44 private: 45 WeakPtr<Component> customComponent_; 46 }; 47 48 } // namespace OHOS::Ace 49 50 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PROGRESS_PROGRESS_ELEMENT_H 51