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_LIST_LIST_ITEM_GROUP_ELEMENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_LIST_LIST_ITEM_GROUP_ELEMENT_H
18 
19 #include "core/components/list/list_item_element.h"
20 #include "core/components/list/render_list_item_group.h"
21 
22 namespace OHOS::Ace {
23 
24 class ListItemGroupElement : public ListItemElement {
25     DECLARE_ACE_TYPE(ListItemGroupElement, ListItemElement);
26 
27 public:
28     void PerformBuild() override;
29     void ApplyRenderChild(const RefPtr<RenderElement>& renderChild) override;
30 
31     bool RequestNextFocus(bool vertical, bool reverse, const Rect& rect) override;
32     void HandleOnFocus() override;
33     void HandleOnBlur() override;
34     RefPtr<Component> GetPrimary();
35 
36     bool OnKeyEvent(const KeyEvent& keyEvent) override;
37     int32_t GetItemGroupFocusIndex();
38     void ItemFocus(int32_t itemIndex);
39 
40 private:
41     void OnFocus() override;
42     RefPtr<RenderNode> CreateRenderNode() override;
43     void MoveItemToViewPort(const RefPtr<Element>& listItem, bool reverse);
44     bool TraverseFocusNode(int32_t currentFocusIndex, bool reverse);
45     void AddItemGroupFocusIndex(int32_t groupFocusIndex);
46     int32_t GetNextFocusIndex(bool vertical, bool reverse);
47     RefPtr<RenderListItemGroup> renderItemGroup_;
48     double size_ = 0.0;
49 };
50 
51 } // namespace OHOS::Ace
52 
53 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_LIST_LIST_ITEM_GROUP_ELEMENT_H
54