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_CONTAINER_MODAL_CONTAINER_MODAL_ELEMENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CONTAINER_MODAL_CONTAINER_MODAL_ELEMENT_H
18 
19 #include "core/components/container_modal/container_modal_component.h"
20 #include "core/components/flex/flex_component.h"
21 #include "core/components/overlay/overlay_element.h"
22 #include "core/components/stage/stage_element.h"
23 #include "core/components/text/render_text.h"
24 #include "core/pipeline/base/sole_child_element.h"
25 
26 namespace OHOS::Ace {
27 
28 class ContainerModalElement : public SoleChildElement {
29     DECLARE_ACE_TYPE(ContainerModalElement, SoleChildElement);
30 
31 public:
32     RefPtr<OverlayElement> GetOverlayElement() const;
33     RefPtr<StageElement> GetStageElement() const;
34     void ShowTitle(bool isShow, bool hasDeco = true, bool needUpdate = false);
35     void WindowFocus(bool isFocus);
36     void SetAppBgColor(const Color& color);
37     void SetTitleButtonHide(bool hideSplit, bool hideMaximize, bool hideMinimize, bool hideClose);
38     void Update() override;
39     void PerformBuild() override;
40     void FlushReload();
41     void SetAppTitle(const std::string& title);
42     void SetAppIcon(const RefPtr<PixelMap>& icon);
43 
44 private:
45     RefPtr<StackElement> GetStackElement() const;
46     bool CanShowFloatingTitle();
47     bool CanHideFloatingTitle();
48     void ChangeFloatingTitleIcon(bool isFocus = true);
49     void ChangeTitleIcon(bool isFocus = true);
50     void SetTitleAccessibilityNodeOffset();
51     RefPtr<RenderText> GetTitleRender(bool isFloatingTitle);
52     RefPtr<RenderImage> GetIconRender(bool isFloatingTitle);
53     WindowMode windowMode_;
54     RefPtr<Animator> controller_;
55     RefPtr<RenderDisplay> floatingTitleDisplay_;
56     RefPtr<BoxElement> floatingTitleBox_;
57     RefPtr<BoxElement> titleBox_;
58     RefPtr<BoxElement> contentBox_;
59     RefPtr<ContainerModalComponent> containerModalComponent_;
60     float density_ = 1.0f;
61     float moveX_ = 0.0f;
62     float moveY_ = 0.0f;
63     bool windowFocus_ = true;
64     bool hasDeco_ = true;
65 };
66 
67 } // namespace OHOS::Ace
68 
69 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CONTAINER_MODAL_CONTAINER_MODAL_ELEMENT_H
70