• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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_NG_PATTERNS_CONTAINER_MODAL_CONTAINER_MODAL_PATTERN_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_CONTAINER_MODAL_CONTAINER_MODAL_PATTERN_H
18 
19 #include "core/components/container_modal/container_modal_constants.h"
20 #include "core/components_ng/pattern/container_modal/container_modal_accessibility_property.h"
21 #include "core/components_ng/pattern/pattern.h"
22 #include "core/pipeline_ng/pipeline_context.h"
23 
24 namespace OHOS::Ace::NG {
25 class ACE_EXPORT ContainerModalPattern : public Pattern {
26     DECLARE_ACE_TYPE(ContainerModalPattern, Pattern);
27 
28 public:
29     ContainerModalPattern() = default;
30     ~ContainerModalPattern() override = default;
31 
CreateAccessibilityProperty()32     RefPtr<AccessibilityProperty> CreateAccessibilityProperty() override
33     {
34         return MakeRefPtr<ContainerModalAccessibilityProperty>();
35     }
36 
IsMeasureBoundary()37     bool IsMeasureBoundary() const override
38     {
39         return true;
40     }
41 
IsAtomicNode()42     bool IsAtomicNode() const override
43     {
44         return false;
45     }
46 
OnAttachToFrameNode()47     void OnAttachToFrameNode() override
48     {
49         auto pipeline = PipelineContext::GetCurrentContext();
50         CHECK_NULL_VOID(pipeline);
51         auto host = GetHost();
52         CHECK_NULL_VOID(host);
53         pipeline->AddWindowFocusChangedCallback(host->GetId());
54     }
55 
56     void OnWindowFocused() override;
57 
58     void OnWindowUnfocused() override;
59 
60     void InitContainerEvent();
61 
62     void ShowTitle(bool isShow, bool hasDeco = true);
63 
64     void SetAppTitle(const std::string& title);
65 
66     void SetAppIcon(const RefPtr<PixelMap>& icon);
67 
68     void SetContainerButtonHide(bool hideSplit, bool hideMaximize, bool hideMinimize);
69 
70     void SetCloseButtonStatus(bool isEnabled);
71 
72 protected:
GetTitleItemByIndex(const RefPtr<FrameNode> & titleNode,int32_t originIndex)73     virtual RefPtr<UINode> GetTitleItemByIndex(const RefPtr<FrameNode>& titleNode, int32_t originIndex)
74     {
75         return titleNode->GetChildAtIndex(originIndex);
76     }
77 
78     virtual void ChangeFloatingTitle(const RefPtr<FrameNode>& floatingNode, bool isFocus);
79 
80     virtual void ChangeTitle(const RefPtr<FrameNode>& titleNode, bool isFocus);
81 
82     virtual void ChangeTitleButtonIcon(
83         const RefPtr<FrameNode>& buttonNode, InternalResource::ResourceId icon, bool isFocus);
84 
85     WindowMode windowMode_;
86 
87 private:
88     void WindowFocus(bool isFocus);
89 
90     void SetTitleButtonHide(
91         const RefPtr<FrameNode>& titleNode, bool hideSplit, bool hideMaximize, bool hideMinimize);
92 
93     bool CanShowFloatingTitle();
94 
95     float moveX_ = 0.0f;
96     float moveY_ = 0.0f;
97     bool hasDeco_ = true;
98     bool isFocus_ = true;
99     bool hideSplitButton_ = false;
100 };
101 
102 } // namespace OHOS::Ace::NG
103 
104 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_CONTAINER_MODAL_CONTAINER_MODAL_PATTERN_H
105