• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_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/pattern.h"
21 #include "core/pipeline_ng/pipeline_context.h"
22 
23 namespace OHOS::Ace::NG {
24 
25 class ACE_EXPORT ContainerModalPattern : public Pattern {
26     DECLARE_ACE_TYPE(ContainerModalPattern, Pattern);
27 
28 public:
29     ContainerModalPattern() = default;
30     ~ContainerModalPattern() override = default;
31 
IsMeasureBoundary()32     bool IsMeasureBoundary() const override
33     {
34         return true;
35     }
36 
IsAtomicNode()37     bool IsAtomicNode() const override
38     {
39         return false;
40     }
41 
OnAttachToFrameNode()42     void OnAttachToFrameNode() override
43     {
44         auto pipeline = PipelineContext::GetCurrentContext();
45         CHECK_NULL_VOID(pipeline);
46         auto host = GetHost();
47         CHECK_NULL_VOID(host);
48         pipeline->AddWindowFocusChangedCallback(host->GetId());
49     }
50 
51     void OnWindowFocused() override;
52 
53     void OnWindowUnfocused() override;
54 
55     void InitContainerEvent();
56 
57     void ShowTitle(bool isShow);
58 
59     void SetAppTitle(const std::string& title);
60 
61     void SetAppIcon(const RefPtr<PixelMap>& icon);
62 
63 private:
64     void OnModifyDone() override;
65 
66     void WindowFocus(bool isFocus);
67 
68     void ChangeFloatingTitle(const RefPtr<FrameNode>& floatingNode, bool isFocus = true);
69 
70     static void ChangeTitle(const RefPtr<FrameNode>& titleNode, bool isFocus = true);
71 
72     static void ChangeTitleButtonIcon(
73         const RefPtr<FrameNode>& buttonNode, InternalResource::ResourceId icon, bool isFocus = true);
74 
75     bool CanShowFloatingTitle();
76 
77     WindowMode windowMode_;
78     float moveX_ = 0.0f;
79     float moveY_ = 0.0f;
80 };
81 
82 } // namespace OHOS::Ace::NG
83 
84 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_CONTAINER_MODAL_CONTAINER_MODAL_PATTERN_H
85