1 /* 2 * Copyright (c) 2021 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_PANEL_SLIDING_PANEL_COMPONENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PANEL_SLIDING_PANEL_COMPONENT_H 18 19 #include "core/components/box/box_component.h" 20 #include "core/components/common/layout/constants.h" 21 #include "core/components/common/properties/decoration.h" 22 #include "core/components/panel/panel_component.h" 23 #include "core/pipeline/base/sole_child_component.h" 24 25 namespace OHOS::Ace { 26 27 class ACE_EXPORT SlidingPanelComponent : public SoleChildComponent { 28 DECLARE_ACE_TYPE(SlidingPanelComponent, SoleChildComponent); 29 30 public: 31 static RefPtr<Component> Create(const RefPtr<PanelComponent>& component); 32 33 RefPtr<Element> CreateElement() override; 34 35 RefPtr<RenderNode> CreateRenderNode() override; 36 GetMode()37 PanelMode GetMode() const 38 { 39 return mode_; 40 } 41 SetMode(PanelMode mode)42 void SetMode(PanelMode mode) 43 { 44 mode_ = mode; 45 } 46 SetHasBoxStyle(bool hasBoxStyle)47 void SetHasBoxStyle(bool hasBoxStyle) 48 { 49 hasBoxStyle_ = hasBoxStyle; 50 } 51 HasBoxStyle()52 bool HasBoxStyle() const 53 { 54 return hasBoxStyle_; 55 } 56 GetOnSizeChanged()57 const EventMarker& GetOnSizeChanged() const 58 { 59 return onSizeChanged_; 60 } 61 SetOnSizeChanged(const EventMarker & value)62 void SetOnSizeChanged(const EventMarker& value) 63 { 64 onSizeChanged_ = value; 65 } 66 GetMiniHeight()67 const std::pair<Dimension, bool>& GetMiniHeight() const 68 { 69 return miniHeight_; 70 } 71 SetMiniHeight(const std::pair<Dimension,bool> & miniHeight)72 void SetMiniHeight(const std::pair<Dimension, bool>& miniHeight) 73 { 74 miniHeight_ = miniHeight; 75 } 76 GetHalfHeight()77 const std::pair<Dimension, bool>& GetHalfHeight() const 78 { 79 return halfHeight_; 80 } 81 SetHalfHeight(const std::pair<Dimension,bool> & halfHeight)82 void SetHalfHeight(const std::pair<Dimension, bool>& halfHeight) 83 { 84 halfHeight_ = halfHeight; 85 } 86 GetFullHeight()87 const std::pair<Dimension, bool>& GetFullHeight() const 88 { 89 return fullHeight_; 90 } 91 SetFullHeight(const std::pair<Dimension,bool> & fullHeight)92 void SetFullHeight(const std::pair<Dimension, bool>& fullHeight) 93 { 94 fullHeight_ = fullHeight; 95 } 96 GetType()97 PanelType GetType() const 98 { 99 return type_; 100 } 101 SetType(PanelType type)102 void SetType(PanelType type) 103 { 104 type_ = type; 105 } 106 107 // used for inspector node in PC preview GetPanelId()108 int32_t GetPanelId() const 109 { 110 return panelId_; 111 } 112 SetPanelId(int32_t panelId)113 void SetPanelId(int32_t panelId) 114 { 115 panelId_ = panelId; 116 } 117 SetHasDragBar(bool hasDrag)118 void SetHasDragBar(bool hasDrag) 119 { 120 hasDragBar_ = hasDrag; 121 } 122 HasDragBar()123 bool HasDragBar() const 124 { 125 return hasDragBar_; 126 } 127 GetOnHeightChanged()128 const std::function<void(int32_t)>& GetOnHeightChanged() const 129 { 130 return onHeightChanged_; 131 } 132 SetOnHeightChanged(const std::function<void (int32_t)> & func)133 void SetOnHeightChanged(const std::function<void(int32_t)>& func) 134 { 135 onHeightChanged_ = func; 136 } 137 Visible()138 bool Visible() const 139 { 140 return visible_; 141 } 142 SetVisible(bool visible)143 void SetVisible(bool visible) 144 { 145 visible_ = visible; 146 } 147 148 149 protected: 150 void BuildInnerChild(const RefPtr<BoxComponent>& boxStyle, const RefPtr<PanelComponent>& panel); 151 152 PanelMode mode_ = PanelMode::HALF; 153 PanelType type_ = PanelType::FOLDABLE_BAR; 154 bool hasBoxStyle_ = false; 155 // used for inspector node in PC preview 156 int32_t panelId_ = -1; 157 EventMarker onSizeChanged_; 158 std::function<void(int32_t)> onHeightChanged_; 159 bool visible_ = false; 160 bool hasDragBar_ = false; 161 std::pair<Dimension, bool> miniHeight_ = { 0.0_vp, false }; 162 std::pair<Dimension, bool> halfHeight_ = { 0.0_vp, false }; 163 std::pair<Dimension, bool> fullHeight_ = { 0.0_vp, false }; 164 }; 165 166 } // namespace OHOS::Ace 167 168 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PANEL_SLIDING_PANEL_COMPONENT_H 169