38 class TGUI_API MenuBar :
public MenuWidgetBase
42 using Ptr = std::shared_ptr<MenuBar>;
43 using ConstPtr = std::shared_ptr<const MenuBar>;
99 template <
typename Func,
typename... Args>
102 return connectMenuItem({menu, menuItem}, std::forward<Func>(handler), args...);
118 template <
typename Func,
typename... Args>
119 unsigned int connectMenuItem(
const std::vector<String>& hierarchy, Func&& handler,
const Args&... args)
121#if defined(__cpp_lib_invoke) && (__cpp_lib_invoke >= 201411L)
123 [=](
const std::vector<String>& clickedMenuItem)
125 if (clickedMenuItem == hierarchy)
126 std::invoke(handler, args...);
131 [f=std::function<
void(
const Args&...)>(handler),args...,hierarchy](
const std::vector<String>& clickedMenuItem)
133 if (clickedMenuItem == hierarchy)
221 bool addMenuItem(
const std::vector<String>& hierarchy,
bool createParents =
true);
280 bool removeMenuItem(
const std::vector<String>& hierarchy,
bool removeParentsWhenEmpty =
true);
387 TGUI_NODISCARD std::vector<GetMenusElement>
getMenus()
const;
409 void leftMouseReleased(Vector2f pos)
override;
414 void mouseMoved(Vector2f pos)
override;
437 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
442 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
470 TGUI_NODISCARD Vector2f calculateMenuOffset(std::size_t visibleMenuIdx)
const;
476 void emitMenuItemClick(
const std::vector<String>& hierarchy)
override;
482 void deselectDeepestItem()
override;
490 TGUI_NODISCARD
bool isMouseOnOpenMenu(Vector2f pos)
const override;
496 TGUI_NODISCARD
float getDefaultMenuItemHeight()
const override;
502 void leftMouseReleasedOnMenu()
override;
509 void mouseMovedOnMenu(Vector2f pos)
override;
522 std::vector<Menu> m_menus;
523 int m_visibleMenu = -1;
524 Sprite m_spriteBackground;