1 /* 2 * Copyright (c) 2021-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_SPLIT_CONTAINER_RENDER_SPLIT_CONTAINER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SPLIT_CONTAINER_RENDER_SPLIT_CONTAINER_H 18 19 #include "base/memory/referenced.h" 20 #include "core/components/flex/render_flex.h" 21 #include "core/components/split_container/split_container_component.h" 22 #include "core/gestures/drag_recognizer.h" 23 #include "core/pipeline/base/render_node.h" 24 25 namespace OHOS::Ace { 26 27 class RenderSplitContainer : public RenderNode { 28 DECLARE_ACE_TYPE(RenderSplitContainer, RenderNode); 29 30 public: 31 RenderSplitContainer() = default; 32 ~RenderSplitContainer() override = default; 33 34 void LayoutChildren(); 35 virtual void HandleDragStart(const Offset& startPoint) = 0; 36 virtual void HandleDragUpdate(const Offset& currentPoint) = 0; 37 virtual void HandleDragEnd(const Offset& endPoint, double velocity) = 0; 38 void Update(const RefPtr<Component>& component) override; 39 void PerformLayout() override; 40 void InitializeRecognizer(); 41 GetResizable()42 bool GetResizable() const 43 { 44 return resizable_; 45 } 46 47 bool HandleMouseEvent(const MouseEvent& event) override; 48 void HandleMouseHoverEvent(MouseState mouseState) override; 49 50 protected: 51 void OnTouchTestHit( 52 const Offset& coordinateOffset, const TouchRestrict& touchRestrict, TouchTestResult& result) override; 53 virtual void ResetComponentMember(); 54 RefPtr<DragRecognizer> dragDetector_; 55 bool resizable_ = false; 56 double layoutWidth_ = 0.0; 57 double layoutHeight_ = 0.0; 58 bool preIsDraged_ = false; 59 bool isDraged_ = false; 60 bool isDragedMoving_ = false; 61 std::map<int32_t, std::list<MagicLayoutNode>> magicNodes_; 62 std::set<RefPtr<RenderNode>> displayNodes_; 63 std::set<RefPtr<RenderNode>> disableHideNodes_; 64 std::vector<Rect> splitRects_; 65 std::vector<double> dragSplitOffset_; 66 67 private: 68 void UpdateComponentAttr(const RefPtr<Component>& component); 69 void InitProperties(); 70 double GetMainSize(const RefPtr<RenderNode>& renderNode) const; 71 double GetMainMinSize(const RefPtr<RenderNode>& renderNode) const; 72 void UpdateDisplayNode(); 73 74 SplitType splitType_ = SplitType::ROW_SPLIT; 75 }; 76 77 } // namespace OHOS::Ace 78 79 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SPLIT_CONTAINER_RENDER_SPLIT_CONTAINER_H