7#ifndef MYGUI_MENU_CONTROL_H_
8#define MYGUI_MENU_CONTROL_H_
40 MenuControl* _submenu,
68 using VectorMenuItemInfo = std::vector<ItemInfo>;
72 void setVisible(
bool _visible)
override;
75 void setVisibleSmooth(
bool _visible);
80 size_t getItemCount()
const;
83 MenuItem* insertItemAt(
86 MenuItemType _type = MenuItemType::Normal,
87 std::string_view _id = {},
88 Any _data = Any::Null);
93 MenuItemType _type = MenuItemType::Normal,
94 std::string_view _id = {},
95 Any _data = Any::Null);
100 MenuItemType _type = MenuItemType::Normal,
101 std::string_view _id = {},
102 Any _data = Any::Null);
105 void removeItemAt(
size_t _index);
107 void removeItem(MenuItem* _item);
110 void removeAllItems();
113 MenuItem* getItemAt(
size_t _index)
const;
116 size_t getItemIndex(
const MenuItem* _item)
const;
119 size_t findItemIndex(MenuItem* _item);
122 MenuItem* findItemWith(
const UString& _name);
127 void setItemDataAt(
size_t _index, Any _data);
129 void setItemData(MenuItem* _item, Any _data);
132 void clearItemDataAt(
size_t _index);
134 void clearItemData(MenuItem* _item);
137 template<
typename ValueType>
138 ValueType* getItemDataAt(
size_t _index,
bool _throw =
true)
141 return mItemsInfo[_index].data.castType<ValueType>(_throw);
144 template<
typename ValueType>
145 ValueType* getItemData(MenuItem* _item,
bool _throw =
true)
147 return getItemDataAt<ValueType>(getItemIndex(_item), _throw);
151 void setItemIdAt(
size_t _index, std::string_view _id);
153 void setItemId(MenuItem* _item, std::string_view _id);
156 const std::string& getItemIdAt(
size_t _index)
const;
158 const std::string& getItemId(
const MenuItem* _item)
const;
161 MenuItem* getItemById(std::string_view _id)
const;
164 MenuItem* findItemById(std::string_view _id,
bool _recursive =
false);
167 size_t getItemIndexById(std::string_view _id)
const;
171 void setItemNameAt(
size_t _index,
const UString& _name);
173 void setItemName(MenuItem* _item,
const UString& _name);
176 const UString& getItemNameAt(
size_t _index)
const;
178 const UString& getItemName(
const MenuItem* _item)
const;
181 size_t findItemIndexWith(
const UString& _name);
184 void setItemChildVisibleAt(
size_t _index,
bool _visible);
186 void setItemChildVisible(MenuItem* _item,
bool _visible);
191 template<
typename Type>
192 Type* createItemChildTAt(
size_t _index)
194 return static_cast<Type*
>(createItemChildByType(_index, Type::getClassTypeName()));
198 template<
typename Type>
199 Type* createItemChildT(MenuItem* _item)
201 return createItemChildTAt<Type>(getItemIndex(_item));
205 MenuControl* getItemChildAt(
size_t _index)
const;
208 MenuControl* getItemChild(
const MenuItem* _item)
const;
211 MenuControl* createItemChildAt(
size_t _index);
214 MenuControl* createItemChild(MenuItem* _item);
217 void removeItemChildAt(
size_t _index);
220 void removeItemChild(MenuItem* _item);
224 MenuItemType getItemTypeAt(
size_t _index)
const;
227 MenuItemType getItemType(
const MenuItem* _item)
const;
230 void setItemTypeAt(
size_t _index, MenuItemType _type);
232 void setItemType(MenuItem* _item, MenuItemType _type);
235 void setPopupAccept(
bool _value);
237 bool getPopupAccept()
const;
240 MenuItem* getMenuItemParent()
const;
243 void setVerticalAlignment(
bool _value);
245 bool getVerticalAlignment()
const;
264 void _notifyDeleteItem(MenuItem* _item);
265 void _notifyDeletePopup(MenuItem* _item);
266 void _notifyUpdateName(MenuItem* _item);
267 void _wrapItemChild(MenuItem* _item, MenuControl* _widget);
270 size_t _getItemCount()
const override;
271 void _addItem(
const MyGUI::UString& _name)
override;
272 void _removeItemAt(
size_t _index)
override;
273 Widget* _getItemAt(
size_t _index)
const override;
274 void _setItemNameAt(
size_t _index,
const UString& _name)
override;
275 const UString& _getItemNameAt(
size_t _index)
const override;
276 void _setItemSelected(IItem* _item)
override;
278 void _updateItems(
size_t _index);
279 void _updateSizeForEmpty();
282 void initialiseOverride()
override;
283 void shutdownOverride()
override;
285 void onKeyChangeRootFocus(
bool _focus)
override;
287 void onWidgetCreated(Widget* _widget)
override;
289 void setPropertyOverride(std::string_view _key, std::string_view _value)
override;
292 void notifyRootKeyChangeFocus(Widget* _sender,
bool _focus)
const;
293 void notifyMouseButtonClick(Widget* _sender);
294 void notifyMouseSetFocus(Widget* _sender, Widget* _new);
295 void notifyChangeCoord(Widget* _sender);
296 void updateSubmenuPosition(
size_t _index);
298 const std::string& getSkinByType(MenuItemType _type)
const;
299 std::string_view getIconIndexByType(MenuItemType _type)
const;
303 MenuItemType getItemType(
bool _submenu,
bool _separator)
const;
305 void notifyMenuCtrlAccept(MenuItem* _item);
307 Widget* createItemChildByType(
size_t _index, std::string_view _type);
312 const UString& _name,
314 std::string_view _id,
317 ControllerFadeAlpha* createControllerFadeAlpha(
float _alpha,
float _coef,
bool _enable);
319 void _setItemChildVisibleAt(
size_t _index,
bool _visible,
bool _smooth);
322 bool mHideByAccept{
true};
323 bool mMenuDropMode{
false};
324 bool mIsMenuDrop{
true};
325 bool mHideByLostKey{
false};
326 bool mResizeToContent{
true};
329 VectorMenuItemInfo mItemsInfo;
331 std::string mItemNormalSkin;
332 std::string mItemPopupSkin;
333 std::string mItemSeparatorSkin;
335 std::string mSubMenuSkin;
336 std::string mSubMenuLayer;
339 bool mShutdown{
false};
341 bool mVerticalAlignment{
true};
342 int mDistanceButton{0};
343 bool mPopupAccept{
false};
344 MenuItem* mOwner{
nullptr};
345 bool mAnimateSmooth{
false};
347 bool mChangeChildSkin{
false};
348 bool mInternalCreateChild{
false};
#define MYGUI_ASSERT_RANGE(index, size, owner)
#define MYGUI_RTTI_DERIVED(DerivedType)
delegates::MultiDelegate< MenuControl * > EventHandle_MenuCtrlPtr
delegates::MultiDelegate< MenuControl *, MenuItem * > EventHandle_MenuCtrlPtrMenuItemPtr