26#ifndef TGUI_MENU_BAR_HPP 
   27#define TGUI_MENU_BAR_HPP 
   30#include <TGUI/Widget.hpp> 
   31#include <TGUI/Renderers/MenuBarRenderer.hpp> 
   32#include <TGUI/Text.hpp> 
   45        typedef std::shared_ptr<MenuBar> 
Ptr; 
 
   46        typedef std::shared_ptr<const MenuBar> 
ConstPtr; 
 
   48    #ifndef TGUI_REMOVE_DEPRECATED_CODE 
   55            std::vector<std::unique_ptr<GetAllMenusElement>> menuItems;
 
   64            std::vector<GetMenuListElement> menuItems;
 
   72            int selectedMenuItem = -1;
 
   73            std::vector<Menu> menuItems;
 
  132        template <
typename Func, 
typename... Args>
 
  133        unsigned int connectMenuItem(
const sf::String& menu, 
const sf::String& menuItem, Func&& handler, 
const Args&... args)
 
  135            return connectMenuItem({menu, menuItem}, std::forward<Func>(handler), args...);
 
  152        template <
typename Func, 
typename... Args>
 
  153        unsigned int connectMenuItem(
const std::vector<sf::String>& hierarchy, Func&& handler, 
const Args&... args)
 
  155#if defined(__cpp_lib_invoke) && (__cpp_lib_invoke >= 201411L) 
  156            return connect(
"MenuItemClicked",
 
  157                [=](
const std::vector<sf::String>& clickedMenuItem)
 
  159                    if (clickedMenuItem == hierarchy)
 
  160                        std::invoke(handler, args...);
 
  164            return connect(
"MenuItemClicked",
 
  165                [f=std::function<
void(
const Args&...)>(handler),args...,hierarchy](
const std::vector<sf::String>& clickedMenuItem)
 
  167                    if (clickedMenuItem == hierarchy)
 
  257        bool addMenuItem(
const std::vector<sf::String>& hierarchy, 
bool createParents = 
true);
 
  304        bool removeMenuItem(
const std::vector<sf::String>& hierarchy, 
bool removeParentsWhenEmpty = 
true);
 
  433    #ifndef TGUI_REMOVE_DEPRECATED_CODE 
  439        TGUI_DEPRECATED(
"This function doesn't work with submenus, use getMenuList instead")
 
  440        std::vector<std::pair<sf::
String, std::vector<sf::
String>>> getMenus() const;
 
  448        TGUI_DEPRECATED("This function is deprecated, use getMenuList instead")
 
  457        std::vector<GetMenuListElement> getMenuList() 
const;
 
  478        void leftMousePressed(
Vector2f pos) 
override;
 
  483        void leftMouseReleased(
Vector2f pos) 
override;
 
  488        void mouseMoved(
Vector2f pos) 
override;
 
  493        void leftMouseButtonNoLongerDown() 
override;
 
  502        void mouseLeftWidget() 
override;
 
  512        void draw(sf::RenderTarget& target, sf::RenderStates states) 
const override;
 
  542        std::unique_ptr<DataIO::Node> 
save(SavingRenderersMap& renderers) 
const override;
 
  548        void load(
const std::unique_ptr<DataIO::Node>& node, 
const LoadingRenderersMap& renderers) 
override;
 
  556            return std::make_shared<MenuBar>(*
this);
 
  561        void createMenu(std::vector<Menu>& menus, 
const sf::String& text);
 
  566        Menu* findMenu(
const std::vector<sf::String>& hierarchy, 
unsigned int parentIndex, std::vector<Menu>& menus, 
bool createParents);
 
  571        const Menu* findMenu(
const std::vector<sf::String>& hierarchy, 
unsigned int parentIndex, 
const std::vector<Menu>& menus) 
const;
 
  575        const Menu* findMenuItem(
const std::vector<sf::String>& hierarchy) 
const;
 
  579        void loadMenus(
const std::unique_ptr<DataIO::Node>& node, std::vector<Menu>& menus);
 
  583        void closeSubMenus(std::vector<Menu>& menus, 
int& selectedMenu);
 
  586        void deselectBottomItem();
 
  589        void updateMenuTextColor(Menu& menu, 
bool selected);
 
  592        void updateTextColors(std::vector<Menu>& menus, 
int selectedMenu);
 
  595        void updateTextOpacity(std::vector<Menu>& menus);
 
  598        void updateTextFont(std::vector<Menu>& menus);
 
  602        float calculateMenuWidth(
const Menu& menu) 
const;
 
  605        Vector2f calculateSubmenuOffset(
const Menu& menu, 
float globalLeftPos, 
float menuWidth, 
float subMenuWidth, 
bool& openSubMenuToRight) 
const;
 
  608        bool isMouseOnTopOfMenu(
Vector2f menuPos, 
Vector2f mousePos, 
bool openSubMenuToRight, 
const Menu& menu, 
float menuWidth) 
const;
 
  611        bool findMenuItemBelowMouse(
Vector2f menuPos, 
Vector2f mousePos, 
bool openSubMenuToRight, Menu& menu, 
float menuWidth, Menu** resultMenu, 
int* resultSelectedMenuItem);
 
  615        void drawMenusOnBar(sf::RenderTarget& target, sf::RenderStates states, 
Sprite& backgroundSprite) 
const;
 
  619        void drawMenu(sf::RenderTarget& target, sf::RenderStates states, 
const Menu& menu, 
float menuWidth, 
Sprite& backgroundSprite, 
float globalLeftPos, 
bool openSubMenuToRight) 
const;
 
  635        std::vector<Menu> m_menus;
 
  637        int m_visibleMenu = -1;
 
  639        float m_minimumSubMenuWidth = 125;
 
  641        bool m_invertedMenuDirection = 
false;
 
  643        Sprite m_spriteBackground;
 
  644        Sprite m_spriteItemBackground;
 
  645        Sprite m_spriteSelectedItemBackground;
 
  648        Color m_backgroundColorCached;
 
  649        Color m_selectedBackgroundColorCached;
 
  650        Color m_textColorCached;
 
  651        Color m_selectedTextColorCached;
 
  652        Color m_textColorDisabledCached;
 
  653        float m_distanceToSideCached = 0;
 
Wrapper for colors.
Definition: Color.hpp:49
 
Class to store the position or size of a widget.
Definition: Layout.hpp:260
 
Signal to which the user can subscribe to get callbacks from.
Definition: Signal.hpp:739
 
Signal to which the user can subscribe to get callbacks from.
Definition: Signal.hpp:231
 
Definition: Sprite.hpp:46
 
Wrapper class to store strings.
Definition: String.hpp:119
 
Definition: Vector2f.hpp:39
 
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:37