demotool/utilities.hh
Emmanuel BENOîT 2c97f3a52e UI overhaul
* Use menus instead of a silly window with checkboxes
* Windows can be closed, cannot be collapsed
* Left side windows have more vertical space
* Specific window for the sequencer
2017-11-19 10:21:08 +01:00

88 lines
2 KiB
C++

#pragma once
#ifndef REAL_BUILD
# include "externals.hh"
#endif
/*= Utilities ================================================================*/
// Disable next ImGui button(s)
void disableButton( );
// Re-enable ImGui buttons
inline void reenableButtons( )
{
ImGui::PopStyleColor( 3 );
}
/*----------------------------------------------------------------------------*/
#define GL_CHECK( FAIL ) \
do { \
auto err_( glGetError( ) ); \
if ( err_ != GL_NO_ERROR ) FAIL; \
} while ( 0 )
#define GL_ASSERT( ) \
GL_CHECK({ \
fprintf( stderr , "GL error %x in %s:%d\n" , \
err_ , __FILE__ , __LINE__ ); \
abort( ); \
})
/*----------------------------------------------------------------------------*/
// Add some value to an angle, keeping it in [-180;180]
void updateAngle(
float& initial ,
const float delta
);
// Make a rotation matrix from three YPR angles (in degrees)
void anglesToMatrix(
float const* angles ,
float* matrix );
/*----------------------------------------------------------------------------*/
// Helpers for finding entries in collections
template< typename T , typename I >
inline auto find(
T const& collection ,
I const& item )
{
return std::find( collection.begin( ) , collection.end( ) , item );
}
template< typename T , typename I >
inline auto find(
T& collection ,
I const& item )
{
return std::find( collection.begin( ) , collection.end( ) , item );
}
template< typename T , typename I >
inline bool Contains(
T const& collection ,
I const& item )
{
return std::find( collection.begin( ) , collection.end( ) , item ) != collection.end( );
}
/*----------------------------------------------------------------------------*/
// Get the absolute path
std::string GetAbsolutePath(
std::string const& path );
// Get the absolute parent path for a (possibly relative) path
std::string GetParentPath(
std::string const& path );
/*----------------------------------------------------------------------------*/
namespace ImGui {
bool MenuItemCheckbox(
char const* name ,
bool* checked );
} // namespace ImGui