2017-11-23 14:43:15 +01:00
|
|
|
#pragma once
|
2017-11-24 07:26:02 +01:00
|
|
|
#include "ui-mousectrl.hh"
|
|
|
|
|
2017-11-23 14:43:15 +01:00
|
|
|
|
|
|
|
/*= UI UTILITIES =============================================================*/
|
|
|
|
|
|
|
|
namespace ImGui {
|
|
|
|
|
|
|
|
// Disable next ImGui controls
|
|
|
|
void PushDisabled( ) noexcept;
|
|
|
|
// Re-enable ImGui buttons
|
|
|
|
void PopDisabled( ) noexcept;
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
// Display a menu item with a checkbox
|
|
|
|
bool MenuItemCheckbox(
|
|
|
|
char const* name ,
|
|
|
|
bool* checked ) noexcept;
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
// Display a separator for the toolbar
|
|
|
|
void ToolbarSeparator( ) noexcept;
|
|
|
|
|
|
|
|
// Display a toolbar button
|
|
|
|
bool ToolbarButton(
|
|
|
|
char const* const string ,
|
|
|
|
ImVec2 const& size ,
|
|
|
|
char const* const tooltip = nullptr ,
|
2017-11-30 09:28:20 +01:00
|
|
|
bool enabled = true ,
|
|
|
|
bool toggled = false ) noexcept;
|
2017-11-23 14:43:15 +01:00
|
|
|
|
2017-11-25 16:30:46 +01:00
|
|
|
/*--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
uint32_t ColorHSVAToU32(
|
|
|
|
float hue ,
|
|
|
|
float saturation ,
|
|
|
|
float value ,
|
|
|
|
float alpha ) noexcept;
|
|
|
|
|
2017-11-27 13:53:33 +01:00
|
|
|
/*--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* "User" scrollbar
|
|
|
|
*
|
|
|
|
* Code ripped from ImGui and modified so it can be used in other
|
|
|
|
* circumstances.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* horizontal Horizontal bar if true, vertical bar if false
|
|
|
|
* total Total size of the scrolled area
|
|
|
|
* display Size of the displayed area
|
|
|
|
* pos Pointer to the position, will be updated when
|
|
|
|
* scrolled
|
|
|
|
* topLeft Top-left corner of the scroll bar
|
|
|
|
* length Width of the scrollbar (if horizontal)
|
|
|
|
* Height of the scrollbar (if vertical)
|
|
|
|
* name Name of the widget; if NULL, #UserScrollX will
|
|
|
|
* be used by default for horizontal scrollbars,
|
|
|
|
* or #UserScrollY for vertical scrollbars
|
|
|
|
*/
|
|
|
|
bool UserScrollbar(
|
|
|
|
bool horizontal ,
|
|
|
|
float total ,
|
|
|
|
float display ,
|
|
|
|
float* pos ,
|
|
|
|
ImVec2 topLeft ,
|
|
|
|
float length ,
|
|
|
|
char const* name = nullptr ) noexcept;
|
|
|
|
|
2017-11-23 14:43:15 +01:00
|
|
|
} // namespace ImGui
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#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( ); \
|
|
|
|
})
|
2017-11-24 07:26:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*= CAMERA ===================================================================*/
|
|
|
|
|
|
|
|
struct T_Camera;
|
|
|
|
|
|
|
|
struct T_CameraMouseControl : public A_MouseCtrl
|
|
|
|
{
|
|
|
|
T_Camera& camera;
|
|
|
|
|
|
|
|
explicit T_CameraMouseControl( T_Camera& cam ) : camera( cam ) {}
|
|
|
|
|
|
|
|
void handleDragAndDrop(
|
|
|
|
ImVec2 const& move ,
|
2017-11-24 11:48:08 +01:00
|
|
|
T_KbdMods modifiers ,
|
2017-11-24 07:26:02 +01:00
|
|
|
T_MouseButtons buttons ) noexcept override;
|
|
|
|
void handleWheel(
|
|
|
|
float wheel ,
|
2017-11-24 11:48:08 +01:00
|
|
|
T_KbdMods modifiers ,
|
2017-11-24 07:26:02 +01:00
|
|
|
T_MouseButtons buttons ) noexcept override;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class E_CameraChange {
|
|
|
|
FOV ,
|
|
|
|
MATRIX
|
|
|
|
};
|
|
|
|
using T_CameraChanges = T_Flags< E_CameraChange >;
|
|
|
|
|
|
|
|
T_CameraChanges CameraUI( T_Camera& camera ) noexcept;
|