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 OHOS_ROSEN_WINDOW_LAYOUT_POLICY_CASCADE_H 17 #define OHOS_ROSEN_WINDOW_LAYOUT_POLICY_CASCADE_H 18 19 #include <map> 20 #include <refbase.h> 21 #include <set> 22 23 #include "window_layout_policy.h" 24 #include "window_node.h" 25 #include "wm_common.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 class WindowLayoutPolicyCascade : public WindowLayoutPolicy { 30 public: 31 WindowLayoutPolicyCascade() = delete; 32 WindowLayoutPolicyCascade(const Rect& displayRect, const uint64_t& screenId, 33 sptr<WindowNode>& belowAppNode, sptr<WindowNode>& appNode, sptr<WindowNode>& aboveAppNode); 34 ~WindowLayoutPolicyCascade() = default; 35 void Launch() override; 36 void Clean() override; 37 void Reset() override; 38 void Reorder() override; 39 void UpdateDisplayInfo() override; 40 void AddWindowNode(sptr<WindowNode>& node) override; 41 void UpdateWindowNode(sptr<WindowNode>& node, bool isAddWindow = false) override; 42 void UpdateLayoutRect(sptr<WindowNode>& node) override; 43 44 private: 45 // Rects for split screen 46 Rect primaryRect_ = {0, 0, 0, 0}; 47 Rect secondaryRect_ = {0, 0, 0, 0}; 48 Rect dividerRect_ = {0, 0, 0, 0}; 49 Rect primaryLimitRect_ = {0, 0, 0, 0}; 50 Rect secondaryLimitRect_ = {0, 0, 0, 0}; 51 // cascade mode rect 52 Rect firstCascadeRect_ = {0, 0, 0, 0}; 53 54 void InitSplitRects(); 55 void SetSplitRectByRatio(float ratio); 56 void SetSplitRect(const Rect& rect); 57 void UpdateSplitLimitRect(const Rect& limitRect, Rect& limitSplitRect); 58 void LayoutWindowNode(sptr<WindowNode>& node) override; 59 void LayoutWindowTree() override; 60 void InitLimitRects(); 61 void LimitMoveBounds(Rect& rect); 62 void InitCascadeRect(); 63 void SetCascadeRect(const sptr<WindowNode>& node); 64 65 Rect GetRectByWindowMode(const WindowMode& mode) const; 66 Rect GetLimitRect(const WindowMode mode) const; 67 Rect GetDisplayRect(const WindowMode mode) const; 68 Rect GetCurCascadeRect(const sptr<WindowNode>& node) const; 69 Rect StepCascadeRect(Rect rect) const; 70 }; 71 } 72 } 73 #endif // OHOS_ROSEN_WINDOW_LAYOUT_POLICY_CASCADE_H 74