2017-10-04 11:20:27 +02:00
|
|
|
#pragma once
|
|
|
|
#ifndef REAL_BUILD
|
|
|
|
# include "externals.hh"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2017-11-22 14:13:02 +01:00
|
|
|
// Base class for a modal dialog that can be pushed to the window's modal
|
|
|
|
// stack.
|
|
|
|
class A_ModalDialog
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
const T_String id_;
|
|
|
|
bool open_{ false };
|
|
|
|
T_Optional< ImVec2 > initialSize_;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
A_ModalDialog( char const* id ) noexcept;
|
|
|
|
|
|
|
|
void setInitialSize( const float width ,
|
|
|
|
const float height ) noexcept
|
|
|
|
{ initialSize_.setNew( width , height ); }
|
|
|
|
|
|
|
|
// Initialisation, called right before the window is opened.
|
|
|
|
// Does nothing by default.
|
|
|
|
virtual void initDialog( ) noexcept;
|
|
|
|
|
|
|
|
// Draw the dialog box's contents, returns true if the OK button
|
|
|
|
// should be enabled.
|
|
|
|
virtual bool drawDialog( ) noexcept = 0;
|
|
|
|
|
|
|
|
// Handlers for both OK and Cancel. The former must be overridden,
|
|
|
|
// the latter defaults to "do nothing".
|
|
|
|
virtual void onOK( ) noexcept = 0;
|
|
|
|
virtual void onCancel( ) noexcept;
|
|
|
|
|
|
|
|
public:
|
|
|
|
NO_COPY( A_ModalDialog );
|
|
|
|
NO_MOVE( A_ModalDialog );
|
|
|
|
virtual ~A_ModalDialog( );
|
|
|
|
|
|
|
|
// Draw and handle the dialog box. Returns true if it must be kept,
|
|
|
|
// or false if it must be removed from the stack.
|
|
|
|
bool draw( ) noexcept;
|
|
|
|
};
|
|
|
|
using P_ModalDialog = T_OwnPtr< A_ModalDialog >;
|
|
|
|
|
|
|
|
|
2017-10-04 11:20:27 +02:00
|
|
|
struct T_Window
|
|
|
|
{
|
|
|
|
T_Window( );
|
|
|
|
~T_Window( );
|
|
|
|
|
2017-11-03 09:08:19 +01:00
|
|
|
void startFrame( const bool capture ,
|
|
|
|
ImVec2 const& mouseInitial ) const;
|
|
|
|
void warpMouse( ImVec2 const& pos ) const;
|
2017-10-04 11:20:27 +02:00
|
|
|
|
|
|
|
void swap( ) const;
|
|
|
|
|
2017-11-22 14:13:02 +01:00
|
|
|
void pushDialog( P_ModalDialog dialog ) noexcept
|
|
|
|
{ modals_.add( std::move( dialog ) ); }
|
|
|
|
void handleDialogs( ) noexcept;
|
|
|
|
|
2017-11-20 21:54:46 +01:00
|
|
|
ImFont* defaultFont( ) const noexcept
|
|
|
|
{ return defaultFont_; }
|
|
|
|
ImFont* smallFont( ) const noexcept
|
|
|
|
{ return smallFont_; }
|
|
|
|
|
2017-10-04 11:20:27 +02:00
|
|
|
private:
|
|
|
|
SDL_Window * window;
|
|
|
|
SDL_GLContext gl;
|
2017-11-20 21:54:46 +01:00
|
|
|
ImFont* defaultFont_;
|
|
|
|
ImFont* smallFont_;
|
2017-11-22 14:13:02 +01:00
|
|
|
T_AutoArray< P_ModalDialog , 8 > modals_;
|
2017-10-04 11:20:27 +02:00
|
|
|
};
|
|
|
|
|