#pragma once #include "AftrConfig.h" #ifdef AFTR_CONFIG_USE_IMGUI #include "WOImGui_fwd_callbacks.h" #include #include #include #include namespace Aftr { class AftrImGui_MenuBar { private: //Stores the state for each menu item added to a particular menu struct menu_item_entry { std::string item; //When true, has checkmark next to this option. This is set to true by ImGui when the //user has clicked on this. This toggled between true/false. If this spawns another //window, and that window has a X in the upper right to close the window, this variable //will turn to false when the window is closed. //This let's one close and reopen windows to avoid clutter. bool isChecked = false; bool isEnabled = true; //When false, the option is gray'd out and disabled, ie, the user cannot toggle / click this item WOImGui_Callback_OnDrawImGui drawFunc; std::string toString() const; }; public: AftrImGui_MenuBar( std::string const& menu_bar_name = "Menu Bar" ); //Attach an ImGui draw call to a specific menu item for ease of organization. //This performs a specific draw call by navigating a MenuBar. //This let's one open and close //windows to ease organization when many windows appear. //For example "Edit" -> "Show WO Editor" -> woEditDrawFunc() //menu.attach( "Edit", "Show WO Editor", woEditFunc ); void attach( std::string const& menu_Name, std::string const& menu_Item, WOImGui_Callback_OnDrawImGui drawFunc, bool isVisibleOnStartUp = false ); // Add's a new menu to the top of the menu bar. Something like "File", "Edit", "My Options", etc. void add_menu( std::string const& menu_name ); //Returns an iterator to the menu_item_entry that either already exists or was just added. auto add_menu_item( std::string const& menu_name, std::string const& menu_item, bool isChecked = false, bool isEnabled = true ); void draw(); private: std::string name; std::map< std::string, std::vector > menu; }; } #endif