1 /* 2 * Copyright (c) 2024 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_MENU_PROPERTY_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MENU_PROPERTY_H 18 19 #include "base/geometry/dimension.h" 20 #include "core/components/common/properties/placement.h" 21 #include "core/components_ng/event/gesture_event_hub.h" 22 #include "core/components_ng/property/transition_property.h" 23 24 namespace OHOS::Ace::NG { 25 26 enum class MenuType { 27 // ----- Menu Containers ------ 28 MENU, // corresponds to .bindMenu attribute 29 CONTEXT_MENU, // corresponds to .bindContextMenu attribute, lives in a SubWindow 30 SUB_MENU, // secondary menu container in a multi-level menu 31 32 // ----- innerMenu Node, corersponds to <Menu> tag in the frontend ------ 33 MULTI_MENU, // called multi because it's a multi-leveled menu, its MenuItems can trigger subMenus 34 DESKTOP_MENU, // menu specialized for desktop UI, enabled when multiple sibiling <Menu> nodes are present 35 36 // ----- special menu used in other components ------ 37 NAVIGATION_MENU, // menu used in a Navigation component 38 SELECT_OVERLAY_EXTENSION_MENU, // menu used in SelectOverlay Extension of text component,skip menu layout algorithm 39 SELECT_OVERLAY_CUSTOM_MENU, // menu used in SelectOverlay for custom menu 40 // click menu item whill not trigger close menu 41 SELECT_OVERLAY_SUB_MENU, // menu type used for select overlay sub menu 42 SELECT_OVERLAY_RIGHT_CLICK_MENU, // menu type used for select overlay menu triggered by right-click 43 }; 44 45 enum class ContextMenuRegisterType : char { 46 NORMAL_TYPE = 0, 47 CUSTOM_TYPE = 1, 48 }; 49 50 struct MenuParam { 51 std::string title; 52 OffsetF positionOffset; 53 bool setShow = false; 54 bool isShow = false; 55 MenuBindingType menuBindType = MenuBindingType::LONG_PRESS; 56 ContextMenuRegisterType contextMenuRegisterType = ContextMenuRegisterType::NORMAL_TYPE; 57 std::function<void(const std::string&)> onStateChange; 58 std::optional<Placement> placement; 59 bool enableHoverMode = false; 60 std::function<void()> onAppear; 61 std::function<void()> onDisappear; 62 std::function<void()> aboutToAppear; 63 std::function<void()> aboutToDisappear; 64 std::optional<bool> enableArrow; 65 std::optional<Dimension> arrowOffset; 66 bool isShowInSubWindow = true; 67 bool hasTransitionEffect = false; 68 RefPtr<NG::ChainedTransitionEffect> transition; 69 bool hasPreviewTransitionEffect = false; 70 RefPtr<NG::ChainedTransitionEffect> previewTransition; 71 MenuType type = MenuType::MENU; 72 MenuPreviewMode previewMode = MenuPreviewMode::NONE; 73 MenuPreviewAnimationOptions previewAnimationOptions; 74 bool isShowHoverImage = false; 75 MenuPreviewAnimationOptions hoverImageAnimationOptions; 76 std::optional<EffectOption> backgroundEffectOption; 77 std::optional<Color> backgroundColor; 78 std::optional<int32_t> backgroundBlurStyle; 79 std::optional<BlurStyleOption> backgroundBlurStyleOption; 80 std::optional<NG::BorderRadiusProperty> borderRadius; 81 std::optional<NG::BorderRadiusProperty> previewBorderRadius; 82 std::optional<NG::MarginProperty> layoutRegionMargin; 83 bool isPreviewContainScale = false; 84 std::optional<BlurStyleOption> blurStyleOption; 85 std::optional<EffectOption> effectOption; 86 HapticFeedbackMode hapticFeedbackMode = HapticFeedbackMode::DISABLED; 87 bool disappearScaleToTarget = false; 88 }; 89 90 } // namespace OHOS::Ace::NG 91 92 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MENU_PROPERTY_H 93