2017-11-16 12:20:21 +01:00
|
|
|
#include "externals.hh"
|
|
|
|
#include "globals.hh"
|
|
|
|
#include "syncoverrides.hh"
|
|
|
|
|
|
|
|
using namespace sov;
|
|
|
|
|
|
|
|
#define M_SETOPT_( FIELD , VAR ) \
|
|
|
|
if ( FIELD ) { return false; } \
|
|
|
|
FIELD = (VAR); \
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
2017-11-16 23:15:44 +01:00
|
|
|
/*= A_Float ====================================================================*/
|
2017-11-16 12:20:21 +01:00
|
|
|
|
2017-11-16 23:15:44 +01:00
|
|
|
bool A_Float::setMin(
|
2017-11-16 12:20:21 +01:00
|
|
|
const float v ) noexcept
|
|
|
|
{
|
|
|
|
M_SETOPT_( min_ , v );
|
|
|
|
}
|
|
|
|
|
2017-11-16 23:15:44 +01:00
|
|
|
bool A_Float::setMax(
|
2017-11-16 12:20:21 +01:00
|
|
|
const float v ) noexcept
|
|
|
|
{
|
|
|
|
M_SETOPT_( max_ , v );
|
|
|
|
}
|
|
|
|
|
2017-11-16 23:15:44 +01:00
|
|
|
bool A_Float::setStep(
|
2017-11-16 12:20:21 +01:00
|
|
|
const float v ) noexcept
|
|
|
|
{
|
|
|
|
assert( v > 0 );
|
|
|
|
M_SETOPT_( step_ , v );
|
|
|
|
}
|
|
|
|
|
2017-11-16 23:15:44 +01:00
|
|
|
bool A_Float::setDecimals(
|
2017-11-16 12:20:21 +01:00
|
|
|
const uint32_t n ) noexcept
|
|
|
|
{
|
|
|
|
assert( n <= 100 );
|
|
|
|
if ( decimals_ ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
T_StringBuilder sb;
|
|
|
|
sb << "%." << n << 'f' << '\0';
|
|
|
|
assert( sb.size( ) < 12 );
|
|
|
|
decimals_.setNew( );
|
|
|
|
for ( auto i = 0u ; i < sb.size( ) ; i ++ ) {
|
|
|
|
decimals_->add( sb.data( )[ i ] );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-16 23:15:44 +01:00
|
|
|
bool A_Float::setPower(
|
2017-11-16 12:20:21 +01:00
|
|
|
const float v ) noexcept
|
|
|
|
{
|
|
|
|
assert( v > 0 );
|
|
|
|
M_SETOPT_( power_ , v );
|
|
|
|
}
|
|
|
|
|
2017-11-16 23:15:44 +01:00
|
|
|
void A_Float::setSlider( ) noexcept
|
|
|
|
{
|
|
|
|
slider_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*= T_Float ====================================================================*/
|
|
|
|
|
|
|
|
T_Float::T_Float(
|
|
|
|
T_String const& input ,
|
|
|
|
T_String const& title ) noexcept
|
|
|
|
: A_Float( "float" , title )
|
|
|
|
{
|
|
|
|
inputs_.add( input );
|
|
|
|
}
|
2017-11-16 12:20:21 +01:00
|
|
|
|
|
|
|
void T_Float::makeEditWidgets( ) noexcept
|
|
|
|
{
|
2017-11-16 23:15:44 +01:00
|
|
|
using namespace ImGui;
|
2017-11-16 12:20:21 +01:00
|
|
|
float v[ 1 ] = {
|
|
|
|
Globals::Sync( ).inputs( )[ inputPos_[ 0 ] ]
|
|
|
|
};
|
2017-11-16 23:15:44 +01:00
|
|
|
|
|
|
|
const bool changed( slider( )
|
|
|
|
? SliderFloat( "" , v , min( ) , max( ) , decimals( ) , power( ) )
|
|
|
|
: DragFloat( "" , v , step( ) , min( ) , max( ) , decimals( ) , power( ) ) );
|
|
|
|
if ( changed ) {
|
|
|
|
Globals::Sync( ).inputs( )[ inputPos_[ 0 ] ] = v[ 0 ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*= T_Float2 ===================================================================*/
|
|
|
|
|
|
|
|
T_Float2::T_Float2(
|
|
|
|
T_String const& input0 ,
|
|
|
|
T_String const& input1 ,
|
|
|
|
T_String const& title ) noexcept
|
|
|
|
: A_Float( "float" , title )
|
|
|
|
{
|
|
|
|
inputs_.add( input0 );
|
|
|
|
inputs_.add( input1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_Float2::makeEditWidgets( ) noexcept
|
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
auto& sinp( Globals::Sync( ).inputs( ) );
|
|
|
|
float v[ 2 ];
|
|
|
|
for ( auto i = 0 ; i < 2 ; i ++ ) {
|
|
|
|
v[ i ] = sinp[ inputPos_[ i ] ];
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool changed( slider( )
|
|
|
|
? SliderFloat2( "" , v , min( ) , max( ) , decimals( ) , power( ) )
|
|
|
|
: DragFloat2( "" , v , step( ) , min( ) , max( ) , decimals( ) , power( ) ) );
|
|
|
|
if ( changed ) {
|
|
|
|
for ( auto i = 0 ; i < 2 ; i ++ ) {
|
|
|
|
sinp[ inputPos_[ i ] ] = v[ i ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*= T_Float3 ===================================================================*/
|
|
|
|
|
|
|
|
T_Float3::T_Float3(
|
|
|
|
T_String const& input0 ,
|
|
|
|
T_String const& input1 ,
|
|
|
|
T_String const& input2 ,
|
|
|
|
T_String const& title ) noexcept
|
|
|
|
: A_Float( "float" , title )
|
|
|
|
{
|
|
|
|
inputs_.add( input0 );
|
|
|
|
inputs_.add( input1 );
|
|
|
|
inputs_.add( input2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_Float3::makeEditWidgets( ) noexcept
|
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
auto& sinp( Globals::Sync( ).inputs( ) );
|
|
|
|
float v[ 3 ];
|
|
|
|
for ( auto i = 0 ; i < 3 ; i ++ ) {
|
|
|
|
v[ i ] = sinp[ inputPos_[ i ] ];
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool changed( slider( )
|
|
|
|
? SliderFloat3( "" , v , min( ) , max( ) , decimals( ) , power( ) )
|
|
|
|
: DragFloat3( "" , v , step( ) , min( ) , max( ) , decimals( ) , power( ) ) );
|
|
|
|
if ( changed ) {
|
|
|
|
for ( auto i = 0 ; i < 3 ; i ++ ) {
|
|
|
|
sinp[ inputPos_[ i ] ] = v[ i ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*= T_Float4 ===================================================================*/
|
|
|
|
|
|
|
|
T_Float4::T_Float4(
|
|
|
|
T_String const& input0 ,
|
|
|
|
T_String const& input1 ,
|
|
|
|
T_String const& input2 ,
|
|
|
|
T_String const& input3 ,
|
|
|
|
T_String const& title ) noexcept
|
|
|
|
: A_Float( "float" , title )
|
|
|
|
{
|
|
|
|
inputs_.add( input0 );
|
|
|
|
inputs_.add( input1 );
|
|
|
|
inputs_.add( input2 );
|
|
|
|
inputs_.add( input3 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_Float4::makeEditWidgets( ) noexcept
|
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
auto& sinp( Globals::Sync( ).inputs( ) );
|
|
|
|
float v[ 4 ];
|
|
|
|
for ( auto i = 0 ; i < 4 ; i ++ ) {
|
|
|
|
v[ i ] = sinp[ inputPos_[ i ] ];
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool changed( slider( )
|
|
|
|
? SliderFloat4( "" , v , min( ) , max( ) , decimals( ) , power( ) )
|
|
|
|
: DragFloat4( "" , v , step( ) , min( ) , max( ) , decimals( ) , power( ) ) );
|
|
|
|
if ( changed ) {
|
|
|
|
for ( auto i = 0 ; i < 4 ; i ++ ) {
|
|
|
|
sinp[ inputPos_[ i ] ] = v[ i ];
|
|
|
|
}
|
2017-11-16 12:20:21 +01:00
|
|
|
}
|
|
|
|
}
|