#pragma once #include "ui-dialogs.hh" #include "ui-mousectrl.hh" #include "ui-actions.hh" /*= WINDOW MANAGEMENT ========================================================*/ struct T_UIApp { T_UIApp( ); ~T_UIApp( ); //---------------------------------------------------------------------- void pushDialog( P_ModalDialog dialog ) noexcept { modals_.add( std::move( dialog ) ); } void msgbox( char const* title , char const* text , T_MessageBox::F_Handler handler = { } , T_MessageBox::T_Buttons buttons = T_MessageBox::BT_OK ) { pushDialog( NewOwned< T_MessageBox >( title , text , handler , buttons ) ); } void msgbox( T_String const& title , T_String const& text , T_MessageBox::F_Handler handler = { } , T_MessageBox::T_Buttons buttons = T_MessageBox::BT_OK ) { pushDialog( NewOwned< T_MessageBox >( title , text , handler , buttons ) ); } //---------------------------------------------------------------------- void addAction( T_UIAction action ) noexcept; void actionMenu( T_String const& id ) const noexcept; void actionButton( T_String const& id ) const noexcept; template< typename... Args > T_UIAction& newAction( Args&&... args ) { T_UIAction a{ std::forward< Args >( args ) ... }; T_String id{ a.id }; addAction( std::move( a ) ); return *actions_.get( id ); } //---------------------------------------------------------------------- ImFont* defaultFont( ) const noexcept { return defaultFont_; } ImFont* smallFont( ) const noexcept { return smallFont_; } //---------------------------------------------------------------------- void startFrame( const bool capture , ImVec2 const& mouseInitial ) const; void warpMouse( ImVec2 const& pos ) const; void swap( ) const; void handleDialogs( ) noexcept; private: SDL_Window * window; SDL_GLContext gl; ImFont* defaultFont_; ImFont* smallFont_; T_AutoArray< P_ModalDialog , 8 > modals_; T_ObjectTable< T_String , T_UIAction > actions_{ []( T_UIAction const& a ) -> T_String { return a.id; } }; };