1 /*
2  * Copyright (c) 2021-2022 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_V2_GRID_GRID_ELEMENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_GRID_GRID_ELEMENT_H
18 
19 #include "base/utils/noncopyable.h"
20 #include "core/components_v2/common/element_proxy.h"
21 #include "core/focus/focus_node.h"
22 #include "core/pipeline/base/render_element.h"
23 
24 namespace OHOS::Ace::V2 {
25 
26 class GridElement : public RenderElement, public FocusGroup, public FlushEvent, private V2::ElementProxyHost {
27     DECLARE_ACE_TYPE(GridElement, RenderElement, FocusGroup, FlushEvent);
28 
29 public:
30     void PerformBuild() override;
31     bool RequestNextFocus(bool vertical, bool reverse, const Rect& rect) override;
32 
33     bool BuildChildByIndex(int32_t index);
34     void DeleteChildByIndex(int32_t index);
35     bool GetItemSpanByIndex(int32_t index, bool isHorizontal, int32_t& itemMain, int32_t& itemCross,
36         int32_t& itemMainSpan, int32_t& itemCrossSpan);
37     size_t GetReloadedCheckNum() override;
38     void OnPostFlush() override;
39     void Dump() override;
40 
41 private:
42     RefPtr<RenderNode> CreateRenderNode() override;
43     void ApplyRenderChild(const RefPtr<RenderElement>& renderChild) override;
44 
45     RefPtr<Element> OnUpdateElement(const RefPtr<Element>& element, const RefPtr<Component>& component) override;
46     RefPtr<Component> OnMakeEmptyComponent() override;
47     void OnDataSourceUpdated(size_t startIndex) override;
48 };
49 
50 } // namespace OHOS::Ace::V2
51 
52 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_GRID_GRID_ELEMENT_H
53