UI - Refactoring progress

(see previous log message)
This commit is contained in:
Emmanuel BENOîT 2017-11-23 23:05:14 +01:00
parent c8b673c51a
commit 8fc496b15a
22 changed files with 170 additions and 152 deletions

View file

@ -15,13 +15,14 @@ FILEDUMPS =
IMGUI = imgui.cpp imgui_draw.cpp IMGUI = imgui.cpp imgui_draw.cpp
COMMON = \ COMMON = \
common.cc \
c-filewatcher.cc \
\
utilities.cc \ utilities.cc \
texture.cc \ texture.cc \
rendertarget.cc \ rendertarget.cc \
camera.cc \ camera.cc \
\ \
filewatcher.cc \
globals.cc \
profiling.cc \ profiling.cc \
shaders.cc \ shaders.cc \
odbg.cc \ odbg.cc \

View file

@ -1,5 +1,5 @@
#include "externals.hh" #include "externals.hh"
#include "filewatcher.hh" #include "c-filewatcher.hh"
#include "utilities.hh" #include "utilities.hh"

56
common.cc Normal file
View file

@ -0,0 +1,56 @@
#include "externals.hh"
#include "common.hh"
#include "c-filewatcher.hh"
#include "opcomp.hh"
#include "ops.hh"
#include "profiling.hh"
#include "sync.hh"
#include "undo.hh"
namespace {
struct CommonData_
{
T_FilesWatcher watcher;
T_Profiler profiler;
T_SyncManager sync;
T_ScriptManager ops;
T_UndoManager undo;
};
std::aligned_storage_t< sizeof( CommonData_ ) , alignof( CommonData_ ) > Instance_;
} // namespace <anon>
/*----------------------------------------------------------------------------*/
void Common::Init( ) noexcept
{
new ((char*)&Instance_) CommonData_( );
}
void Common::Shutdown( ) noexcept
{
((CommonData_*)(char*)&Instance_)->~CommonData_( );
}
/*----------------------------------------------------------------------------*/
#define M_GET_( P ) ((CommonData_*)(char*)&Instance_)->P
T_FilesWatcher& Common::Watcher( ) noexcept
{ return M_GET_( watcher ); }
T_Profiler& Common::Profiler( ) noexcept
{ return M_GET_( profiler ); }
T_SyncManager& Common::Sync( ) noexcept
{ return M_GET_( sync ); }
T_ScriptManager& Common::Ops( ) noexcept
{ return M_GET_( ops ); }
T_UndoManager& Common::Undo( ) noexcept
{ return M_GET_( undo ); }

29
common.hh Normal file
View file

@ -0,0 +1,29 @@
#pragma once
#ifndef REAL_BUILD
# include "externals.hh"
#endif
struct T_FilesWatcher;
struct T_Profiler;
struct T_SyncManager;
struct T_ScriptManager;
class T_UndoManager;
struct Common
{
static void Init( ) noexcept;
static void Shutdown( ) noexcept;
static T_FilesWatcher& Watcher( ) noexcept;
static T_Profiler& Profiler( ) noexcept;
static T_SyncManager& Sync( ) noexcept;
static T_ScriptManager& Ops( ) noexcept;
static T_UndoManager& Undo( ) noexcept;
private:
Common( ) = delete;
NO_COPY( Common );
NO_MOVE( Common );
};

20
demo.cc
View file

@ -2,7 +2,7 @@
#include "demo.hh" #include "demo.hh"
#include "sync.hh" #include "sync.hh"
#include "rendertarget.hh" #include "rendertarget.hh"
#include "globals.hh" #include "common.hh"
#include "opemu.hh" #include "opemu.hh"
#include "opcomp.hh" #include "opcomp.hh"
#include <ebcl/Files.hh> #include <ebcl/Files.hh>
@ -20,14 +20,14 @@ bool T_Demo::initialise(
void T_Demo::render( ) void T_Demo::render( )
{ {
if ( Globals::Ops( ).hasNewProgram( ) ) { if ( Common::Ops( ).hasNewProgram( ) ) {
auto nProgram{ Globals::Ops( ).program( ) }; auto nProgram{ Common::Ops( ).program( ) };
if ( runInit( *nProgram ) ) { if ( runInit( *nProgram ) ) {
program = std::move( nProgram ); program = std::move( nProgram );
} }
} }
auto& sync( Globals::Sync( ) ); auto& sync( Common::Sync( ) );
sync.updateTime( ); sync.updateTime( );
if ( context && !context->aborted ) { if ( context && !context->aborted ) {
@ -55,23 +55,23 @@ bool T_Demo::runInit(
} }
context = std::move( nContext ); context = std::move( nContext );
Globals::Sync( ).clearInputs( ); Common::Sync( ).clearInputs( );
Globals::Sync( ).clearOverrides( ); Common::Sync( ).clearOverrides( );
const auto n( context->initialInputs.size( ) ); const auto n( context->initialInputs.size( ) );
assert( n == p.inputs.size( ) ); assert( n == p.inputs.size( ) );
for ( auto i = 0u ; i < n ; i ++ ) { for ( auto i = 0u ; i < n ; i ++ ) {
Globals::Sync( ).addInput( p.inputs[ i ] , Common::Sync( ).addInput( p.inputs[ i ] ,
context->initialInputs[ i ] ); context->initialInputs[ i ] );
#ifdef INVASIVE_TRACES #ifdef INVASIVE_TRACES
printf( "#%d %s pos %d\n" , i , p.inputs[ i ].toOSString( ).data( ) , printf( "#%d %s pos %d\n" , i , p.inputs[ i ].toOSString( ).data( ) ,
Globals::Sync( ).inputPos( p.inputs[ i ] ) ); Common::Sync( ).inputPos( p.inputs[ i ] ) );
#endif //INVASIVE_TRACES #endif //INVASIVE_TRACES
} }
Globals::Sync( ).updateCurveCaches( ); Common::Sync( ).updateCurveCaches( );
if ( context->installOverrides ) { if ( context->installOverrides ) {
Globals::Sync( ).mergeOverrides( *( context->installOverrides ) ); Common::Sync( ).mergeOverrides( *( context->installOverrides ) );
context->installOverrides.clear( ); context->installOverrides.clear( );
} }

View file

@ -1,35 +0,0 @@
#include "externals.hh"
#include "globals.hh"
#include "filewatcher.hh"
#include "opcomp.hh"
#include "ops.hh"
#include "profiling.hh"
#include "sync.hh"
#include "undo.hh"
T_OwnPtr< T_FilesWatcher > Globals::watcher_;
T_OwnPtr< T_Profiler > Globals::profiler_;
T_OwnPtr< T_SyncManager > Globals::sync_;
T_OwnPtr< T_ScriptManager > Globals::ops_;
T_OwnPtr< T_UndoManager > Globals::undo_;
void Globals::Init( )
{
watcher_ = NewOwned< T_FilesWatcher >( );
profiler_ = NewOwned< T_Profiler >( );
sync_ = NewOwned< T_SyncManager >( );
ops_ = NewOwned< T_ScriptManager >( );
undo_ = NewOwned< T_UndoManager >( );
}
void Globals::Shutdown( )
{
undo_.clear( );
ops_.clear( );
sync_.clear( );
profiler_.clear( );
watcher_.clear( );
}

View file

@ -1,31 +0,0 @@
#pragma once
#ifndef REAL_BUILD
# include "externals.hh"
#endif
struct T_FilesWatcher;
struct T_Profiler;
struct T_SyncManager;
struct T_ScriptManager;
class T_UndoManager;
struct Globals
{
static void Init( );
static void Shutdown( );
static T_FilesWatcher& Watcher( ) { return *watcher_; }
static T_Profiler& Profiler( ) { return *profiler_; }
static T_SyncManager& Sync( ) { return *sync_; }
static T_ScriptManager& Ops( ) { return *ops_; }
static T_UndoManager& Undo( ) { return *undo_; }
private:
static T_OwnPtr< T_FilesWatcher > watcher_;
static T_OwnPtr< T_Profiler > profiler_;
static T_OwnPtr< T_SyncManager > sync_;
static T_OwnPtr< T_ScriptManager > ops_;
static T_OwnPtr< T_UndoManager > undo_;
};

22
main.cc
View file

@ -1,7 +1,7 @@
#include "externals.hh" #include "externals.hh"
#include "ui-imgui-sdl.hh" #include "ui-imgui-sdl.hh"
#include "demo.hh" #include "demo.hh"
#include "globals.hh" #include "common.hh"
#include "profiling.hh" #include "profiling.hh"
#include "shaders.hh" #include "shaders.hh"
#include "odbg.hh" #include "odbg.hh"
@ -51,14 +51,14 @@ struct T_Main
T_Main::T_Main( ) T_Main::T_Main( )
{ {
Globals::Init( ); Common::Init( );
UI::Init( ); UI::Init( );
prevSize = ImVec2( -1 , -1 ); prevSize = ImVec2( -1 , -1 );
} }
void T_Main::mainLoop( ) void T_Main::mainLoop( )
{ {
auto& p( Globals::Profiler( ) ); auto& p( Common::Profiler( ) );
while ( !done ) { while ( !done ) {
auto const& dspSize( ImGui::GetIO( ).DisplaySize ); auto const& dspSize( ImGui::GetIO( ).DisplaySize );
if ( prevSize.x != dspSize.x || prevSize.y != dspSize.y ) { if ( prevSize.x != dspSize.x || prevSize.y != dspSize.y ) {
@ -84,7 +84,7 @@ void T_Main::mainLoop( )
sequencer.setNew( ); sequencer.setNew( );
} }
Globals::Watcher( ).check( ); Common::Watcher( ).check( );
UI::Shaders( ).update( ); UI::Shaders( ).update( );
glFinish( ); glFinish( );
@ -106,7 +106,7 @@ T_Main::~T_Main( )
{ {
demo.clear( ); demo.clear( );
UI::Shutdown( ); UI::Shutdown( );
Globals::Shutdown( ); Common::Shutdown( );
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -124,7 +124,7 @@ void T_Main::initDemo( )
printf( "init w/ dspsize %dx%d\n" , int( dspSize.x ) , int( dspSize.y ) ); printf( "init w/ dspsize %dx%d\n" , int( dspSize.x ) , int( dspSize.y ) );
if ( demo->initialise( (uint32_t) dspSize.x , (uint32_t) dspSize.y ) ) { if ( demo->initialise( (uint32_t) dspSize.x , (uint32_t) dspSize.y ) ) {
Globals::Profiler( ).clear( ); Common::Profiler( ).clear( );
} }
} }
@ -208,7 +208,7 @@ void T_Main::handleCapture( )
void T_Main::makeUI( ) void T_Main::makeUI( )
{ {
using namespace ImGui; using namespace ImGui;
auto& undo( Globals::Undo( ) ); auto& undo( Common::Undo( ) );
bool eSequencer{ sequencer }; bool eSequencer{ sequencer };
if ( BeginMainMenuBar( ) ) { if ( BeginMainMenuBar( ) ) {
if ( BeginMenu( "File" ) ) { if ( BeginMenu( "File" ) ) {
@ -233,7 +233,7 @@ void T_Main::makeUI( )
MenuItemCheckbox( "Output debugger" , MenuItemCheckbox( "Output debugger" ,
&UI::ODbg( ).uiEnabled( ) ); &UI::ODbg( ).uiEnabled( ) );
MenuItemCheckbox( "Profiler" , MenuItemCheckbox( "Profiler" ,
&Globals::Profiler( ).uiEnabled( ) ); &Common::Profiler( ).uiEnabled( ) );
MenuItemCheckbox( "Sequencer" , &eSequencer ); MenuItemCheckbox( "Sequencer" , &eSequencer );
MenuItemCheckbox( "Shaders" , MenuItemCheckbox( "Shaders" ,
&UI::Shaders( ).uiEnabled( ) ); &UI::Shaders( ).uiEnabled( ) );
@ -248,7 +248,7 @@ void T_Main::makeUI( )
sequencer.clear( ); sequencer.clear( );
} }
Globals::Profiler( ).makeUI( ); Common::Profiler( ).makeUI( );
UI::ODbg( ).makeUI( ); UI::ODbg( ).makeUI( );
UI::Shaders( ).makeUI( ); UI::Shaders( ).makeUI( );
UI::Sync( ).makeOverridesWindow( ); UI::Sync( ).makeOverridesWindow( );
@ -262,12 +262,12 @@ void T_Main::render( )
if ( demo ) { if ( demo ) {
demo->render( ); demo->render( );
Globals::Profiler( ).start( "Debug" ); Common::Profiler( ).start( "Debug" );
T_Rendertarget::MainOutput( ); T_Rendertarget::MainOutput( );
if ( UI::ODbg( ).isActive( ) ) { if ( UI::ODbg( ).isActive( ) ) {
UI::ODbg( ).debugOutput( ); UI::ODbg( ).debugOutput( );
} }
glFinish( ); Globals::Profiler( ).end( "Debug" ); glFinish( ); Common::Profiler( ).end( "Debug" );
} else { } else {
T_Rendertarget::MainOutput( ); T_Rendertarget::MainOutput( );

View file

@ -1,5 +1,5 @@
#pragma once #pragma once
#include "filewatcher.hh" #include "c-filewatcher.hh"
#include "opast.hh" #include "opast.hh"
#include <ebcl/SRDData.hh> #include <ebcl/SRDData.hh>

View file

@ -1,6 +1,6 @@
#include "externals.hh" #include "externals.hh"
#include "opemu.hh" #include "opemu.hh"
#include "globals.hh" #include "common.hh"
#include "ui.hh" #include "ui.hh"
#include "profiling.hh" #include "profiling.hh"
#include "rendertarget.hh" #include "rendertarget.hh"
@ -64,7 +64,7 @@ struct T_RunGuard
~T_RunGuard( ) ~T_RunGuard( )
{ {
while ( !context.profiling.empty( ) ) { while ( !context.profiling.empty( ) ) {
Globals::Profiler( ).end( context.profiling.last( ) ); Common::Profiler( ).end( context.profiling.last( ) );
context.profiling.removeLast( ); context.profiling.removeLast( );
} }
glUseProgram( 0 ); glUseProgram( 0 );
@ -205,7 +205,7 @@ void T_OpContext::run(
case OP_GET_INPUT: case OP_GET_INPUT:
ensureFpuStack( instr , 0 , 1 ); ensureFpuStack( instr , 0 , 1 );
x87stack[ x87sp ++ ] = Globals::Sync( ).inputs( )[ instr.args[ 0 ] ]; x87stack[ x87sp ++ ] = Common::Sync( ).inputs( )[ instr.args[ 0 ] ];
break; break;
case OP_FP_LOAD: case OP_FP_LOAD:
@ -681,14 +681,14 @@ void T_OpContext::run(
case OP_UI_PENTER: case OP_UI_PENTER:
{ {
T_String const& section( program.uiStrings[ instr.args[ 0 ] ] ); T_String const& section( program.uiStrings[ instr.args[ 0 ] ] );
Globals::Profiler( ).start( section ); Common::Profiler( ).start( section );
profiling.add( section ); profiling.add( section );
break; break;
} }
case OP_UI_PEXIT: case OP_UI_PEXIT:
glFinish( ); glFinish( );
Globals::Profiler( ).end( profiling.last( ) ); Common::Profiler( ).end( profiling.last( ) );
profiling.removeLast( ); profiling.removeLast( );
break; break;

View file

@ -1,5 +1,5 @@
#include "externals.hh" #include "externals.hh"
#include "globals.hh" #include "common.hh"
#include "opcomp.hh" #include "opcomp.hh"
#include "ops.hh" #include "ops.hh"
@ -40,7 +40,7 @@ void DumpSRDErrors(
/*= T_ScriptManager ============================================================*/ /*= T_ScriptManager ============================================================*/
T_ScriptManager::T_ScriptManager( ) noexcept T_ScriptManager::T_ScriptManager( ) noexcept
: watcher_( Globals::Watcher( ) , [this](){ : watcher_( Common::Watcher( ) , [this](){
loadScript( ); loadScript( );
} ) , } ) ,
parser_( ) , compiler_( ) parser_( ) , compiler_( )

View file

@ -1,6 +1,6 @@
#include "externals.hh" #include "externals.hh"
#include "shaders.hh" #include "shaders.hh"
#include "globals.hh" #include "common.hh"
#include "ui.hh" #include "ui.hh"
#include "ui-utilities.hh" #include "ui-utilities.hh"
@ -973,7 +973,7 @@ void T_ShaderManager::initProgram(
}.buildCode( ) ); }.buildCode( ) );
// Initialise file watcher + missing files // Initialise file watcher + missing files
program.watch = T_WatchedFiles{ Globals::Watcher( ) , program.watch = T_WatchedFiles{ Common::Watcher( ) ,
[this,name]() { [this,name]() {
programUpdated( name ); programUpdated( name );
} }; } };

View file

@ -1,5 +1,5 @@
#pragma once #pragma once
#include "filewatcher.hh" #include "c-filewatcher.hh"
#include "utilities.hh" #include "utilities.hh"

View file

@ -1,10 +1,9 @@
#include "externals.hh" #include "externals.hh"
#include "globals.hh" #include "common.hh"
#include "sync.hh" #include "sync.hh"
#include "syncedit.hh" #include "syncedit.hh"
#include "undo.hh" #include "undo.hh"
#include <imgui_internal.h>
#include <ebcl/Files.hh> #include <ebcl/Files.hh>
#include <ebcl/SRDText.hh> #include <ebcl/SRDText.hh>
#include <ebcl/SRDParser.hh> #include <ebcl/SRDParser.hh>
@ -411,7 +410,7 @@ void A_SyncOverride::setup( ) noexcept
// FIXME: insufficient; the manager should be made aware of // FIXME: insufficient; the manager should be made aware of
// the presence of an override for that value (and it should // the presence of an override for that value (and it should
// fail for missing values). // fail for missing values).
inputPos_.add( Globals::Sync( ).inputPos( inputs_[ i ] ) ); inputPos_.add( Common::Sync( ).inputPos( inputs_[ i ] ) );
if ( sb.size( ) ) { if ( sb.size( ) ) {
sb << ';'; sb << ';';
} }
@ -490,7 +489,7 @@ T_SyncOverrideVisitor::T_OpElement T_SyncOverrideVisitor::nodeBrowser(
T_SyncManager::T_SyncManager( ) T_SyncManager::T_SyncManager( )
: pConfig_( MakeCurvesParser_( ) ) , : pConfig_( MakeCurvesParser_( ) ) ,
watcher_{ Globals::Watcher( ) , [this](){ curvesChanged_( ); } } , watcher_{ Common::Watcher( ) , [this](){ curvesChanged_( ); } } ,
soRoot_( "*root*" ) soRoot_( "*root*" )
{ {
watcher_.watch( "curves.srd" ); watcher_.watch( "curves.srd" );
@ -671,7 +670,7 @@ void T_SyncManager::addReloadUndoData_(
void* const data ) const noexcept void* const data ) const noexcept
{ {
T_ParserOutput_& p{ *(T_ParserOutput_*)data }; T_ParserOutput_& p{ *(T_ParserOutput_*)data };
auto& undo{ Globals::Undo( ).add< T_UndoDurationChanges >( auto& undo{ Common::Undo( ).add< T_UndoDurationChanges >(
p.time ? p.time->iDuration : 3600 , p.time ? p.time->iDuration : 3600 ,
time_.iDuration , time_.iDuration ,
p.time ? p.time->uDuration : ( 1.f / 60.f ) , p.time ? p.time->uDuration : ( 1.f / 60.f ) ,

View file

@ -1,5 +1,5 @@
#pragma once #pragma once
#include "filewatcher.hh" #include "c-filewatcher.hh"
#include "utilities.hh" #include "utilities.hh"
#include <ebcl/SRDParserConfig.hh> #include <ebcl/SRDParserConfig.hh>

View file

@ -1,13 +1,13 @@
#include "externals.hh" #include "externals.hh"
#include "syncedit.hh" #include "syncedit.hh"
#include "globals.hh" #include "common.hh"
/*= T_UndoSyncChanges ========================================================*/ /*= T_UndoSyncChanges ========================================================*/
void T_UndoSyncChanges::undo( ) const noexcept void T_UndoSyncChanges::undo( ) const noexcept
{ {
auto& sync{ Globals::Sync( ) }; auto& sync{ Common::Sync( ) };
const auto n{ changes_.size( ) }; const auto n{ changes_.size( ) };
for ( auto i = 0u ; i < n ; i ++ ) { for ( auto i = 0u ; i < n ; i ++ ) {
auto const& c( changes_[ i ] ); auto const& c( changes_[ i ] );
@ -21,7 +21,7 @@ void T_UndoSyncChanges::undo( ) const noexcept
void T_UndoSyncChanges::redo( ) const noexcept void T_UndoSyncChanges::redo( ) const noexcept
{ {
auto& sync{ Globals::Sync( ) }; auto& sync{ Common::Sync( ) };
const auto n{ changes_.size( ) }; const auto n{ changes_.size( ) };
for ( auto i = 0u ; i < n ; i ++ ) { for ( auto i = 0u ; i < n ; i ++ ) {
auto const& c( changes_[ i ] ); auto const& c( changes_[ i ] );
@ -99,13 +99,13 @@ T_UndoDurationChanges::T_UndoDurationChanges(
void T_UndoDurationChanges::undo( ) const noexcept void T_UndoDurationChanges::undo( ) const noexcept
{ {
Globals::Sync( ).setDuration( uSizeBefore_ , unitsBefore_ ); Common::Sync( ).setDuration( uSizeBefore_ , unitsBefore_ );
T_UndoSyncChanges::undo( ); T_UndoSyncChanges::undo( );
} }
void T_UndoDurationChanges::redo( ) const noexcept void T_UndoDurationChanges::redo( ) const noexcept
{ {
Globals::Sync( ).setDuration( uSizeAfter_ , unitsAfter_ ); Common::Sync( ).setDuration( uSizeAfter_ , unitsAfter_ );
T_UndoSyncChanges::redo( ); T_UndoSyncChanges::redo( );
} }
@ -145,7 +145,7 @@ void SyncEditor::SetDuration(
const float uSize , const float uSize ,
const bool scaleCurves ) noexcept const bool scaleCurves ) noexcept
{ {
auto& sync{ Globals::Sync( ) }; auto& sync{ Common::Sync( ) };
const float oldUnitSize{ sync.durationUnitSize( ) }; const float oldUnitSize{ sync.durationUnitSize( ) };
const uint32_t oldUnits{ sync.durationUnits( ) }; const uint32_t oldUnits{ sync.durationUnits( ) };
if ( oldUnits == units && oldUnitSize == uSize ) { if ( oldUnits == units && oldUnitSize == uSize ) {
@ -153,7 +153,7 @@ void SyncEditor::SetDuration(
} }
auto& undo{ dynamic_cast< T_UndoDurationChanges& >( auto& undo{ dynamic_cast< T_UndoDurationChanges& >(
Globals::Undo( ).add< T_UndoDurationChanges >( Common::Undo( ).add< T_UndoDurationChanges >(
units , oldUnits , units , oldUnits ,
uSize , oldUnitSize ) ) }; uSize , oldUnitSize ) ) };
sync.setDuration( uSize , units ); sync.setDuration( uSize , units );

View file

@ -1,5 +1,4 @@
#include "externals.hh" #include "externals.hh"
#include "globals.hh"
#include "syncoverrides.hh" #include "syncoverrides.hh"
#include "ui-colorgrading.hh" #include "ui-colorgrading.hh"

View file

@ -1,5 +1,5 @@
#include "externals.hh" #include "externals.hh"
#include "globals.hh" #include "common.hh"
#include "ui.hh" #include "ui.hh"
#include "ui-colorgrading.hh" #include "ui-colorgrading.hh"
#include "ui-overrides.hh" #include "ui-overrides.hh"
@ -31,7 +31,7 @@ M_DECL_SOVUI( Float )
using namespace ImGui; using namespace ImGui;
auto& ov{ dynamic_cast< T_Float& >( ovp ) }; auto& ov{ dynamic_cast< T_Float& >( ovp ) };
float v[ 1 ] = { float v[ 1 ] = {
Globals::Sync( ).inputs( )[ ov.inputPositions( )[ 0 ] ] Common::Sync( ).inputs( )[ ov.inputPositions( )[ 0 ] ]
}; };
char const* const label( BuildLabel_( counter , sb ) ); char const* const label( BuildLabel_( counter , sb ) );
@ -41,7 +41,7 @@ M_DECL_SOVUI( Float )
: DragFloat( label , v , ov.step( ) , ov.min( ) , : DragFloat( label , v , ov.step( ) , ov.min( ) ,
ov.max( ) , ov.decimals( ) , ov.power( ) ) ); ov.max( ) , ov.decimals( ) , ov.power( ) ) );
if ( changed ) { if ( changed ) {
Globals::Sync( ).inputs( )[ ov.inputPositions( )[ 0 ] ] = v[ 0 ]; Common::Sync( ).inputs( )[ ov.inputPositions( )[ 0 ] ] = v[ 0 ];
} }
} }
@ -49,7 +49,7 @@ M_DECL_SOVUI( Float2 )
{ {
using namespace ImGui; using namespace ImGui;
auto& ov{ dynamic_cast< T_Float2& >( ovp ) }; auto& ov{ dynamic_cast< T_Float2& >( ovp ) };
auto& sinp( Globals::Sync( ).inputs( ) ); auto& sinp( Common::Sync( ).inputs( ) );
auto const& ovip{ ov.inputPositions( ) }; auto const& ovip{ ov.inputPositions( ) };
float v[ 2 ]; float v[ 2 ];
for ( auto i = 0 ; i < 2 ; i ++ ) { for ( auto i = 0 ; i < 2 ; i ++ ) {
@ -73,7 +73,7 @@ M_DECL_SOVUI( Float3 )
{ {
using namespace ImGui; using namespace ImGui;
auto& ov{ dynamic_cast< T_Float3& >( ovp ) }; auto& ov{ dynamic_cast< T_Float3& >( ovp ) };
auto& sinp( Globals::Sync( ).inputs( ) ); auto& sinp( Common::Sync( ).inputs( ) );
auto const& ovip{ ov.inputPositions( ) }; auto const& ovip{ ov.inputPositions( ) };
float v[ 3 ]; float v[ 3 ];
for ( auto i = 0 ; i < 3 ; i ++ ) { for ( auto i = 0 ; i < 3 ; i ++ ) {
@ -97,7 +97,7 @@ M_DECL_SOVUI( Float4 )
{ {
using namespace ImGui; using namespace ImGui;
auto& ov{ dynamic_cast< T_Float4& >( ovp ) }; auto& ov{ dynamic_cast< T_Float4& >( ovp ) };
auto& sinp( Globals::Sync( ).inputs( ) ); auto& sinp( Common::Sync( ).inputs( ) );
auto const& ovip{ ov.inputPositions( ) }; auto const& ovip{ ov.inputPositions( ) };
float v[ 4 ]; float v[ 4 ];
for ( auto i = 0 ; i < 4 ; i ++ ) { for ( auto i = 0 ; i < 4 ; i ++ ) {
@ -124,7 +124,7 @@ M_DECL_SOVUI( Integer )
{ {
using namespace ImGui; using namespace ImGui;
auto& ov{ dynamic_cast< T_Integer& >( ovp ) }; auto& ov{ dynamic_cast< T_Integer& >( ovp ) };
auto& sinp( Globals::Sync( ).inputs( ) ); auto& sinp( Common::Sync( ).inputs( ) );
auto const& ovip{ ov.inputPositions( ) }; auto const& ovip{ ov.inputPositions( ) };
int32_t v[ 1 ] = { int32_t v[ 1 ] = {
int32_t( sinp[ ovip[ 0 ] ] ) int32_t( sinp[ ovip[ 0 ] ] )
@ -143,7 +143,7 @@ M_DECL_SOVUI( Integer2 )
{ {
using namespace ImGui; using namespace ImGui;
auto& ov{ dynamic_cast< T_Integer2& >( ovp ) }; auto& ov{ dynamic_cast< T_Integer2& >( ovp ) };
auto& sinp( Globals::Sync( ).inputs( ) ); auto& sinp( Common::Sync( ).inputs( ) );
auto const& ovip{ ov.inputPositions( ) }; auto const& ovip{ ov.inputPositions( ) };
int32_t v[ 2 ]; int32_t v[ 2 ];
for ( auto i = 0 ; i < 2 ; i ++ ) { for ( auto i = 0 ; i < 2 ; i ++ ) {
@ -165,7 +165,7 @@ M_DECL_SOVUI( Integer3 )
{ {
using namespace ImGui; using namespace ImGui;
auto& ov{ dynamic_cast< T_Integer3& >( ovp ) }; auto& ov{ dynamic_cast< T_Integer3& >( ovp ) };
auto& sinp( Globals::Sync( ).inputs( ) ); auto& sinp( Common::Sync( ).inputs( ) );
auto const& ovip{ ov.inputPositions( ) }; auto const& ovip{ ov.inputPositions( ) };
int32_t v[ 3 ]; int32_t v[ 3 ];
for ( auto i = 0 ; i < 3 ; i ++ ) { for ( auto i = 0 ; i < 3 ; i ++ ) {
@ -187,7 +187,7 @@ M_DECL_SOVUI( Integer4 )
{ {
using namespace ImGui; using namespace ImGui;
auto& ov{ dynamic_cast< T_Integer4& >( ovp ) }; auto& ov{ dynamic_cast< T_Integer4& >( ovp ) };
auto& sinp( Globals::Sync( ).inputs( ) ); auto& sinp( Common::Sync( ).inputs( ) );
auto const& ovip{ ov.inputPositions( ) }; auto const& ovip{ ov.inputPositions( ) };
int32_t v[ 4 ]; int32_t v[ 4 ];
for ( auto i = 0 ; i < 4 ; i ++ ) { for ( auto i = 0 ; i < 4 ; i ++ ) {
@ -212,7 +212,7 @@ M_DECL_SOVUI( ColorGrading )
{ {
using namespace ImGui; using namespace ImGui;
auto& ov{ dynamic_cast< T_ColorGrading& >( ovp ) }; auto& ov{ dynamic_cast< T_ColorGrading& >( ovp ) };
auto& sinp{ Globals::Sync( ).inputs( ) }; auto& sinp{ Common::Sync( ).inputs( ) };
auto const& ovip{ ov.inputPositions( ) }; auto const& ovip{ ov.inputPositions( ) };
float v[ 3 ]; float v[ 3 ];
for ( auto i = 0 ; i < 3 ; i ++ ) { for ( auto i = 0 ; i < 3 ; i ++ ) {
@ -241,7 +241,7 @@ glm::vec3 VectorFromInputs_(
T_CamOverride::T_VectorConfig const& vc , T_CamOverride::T_VectorConfig const& vc ,
T_AutoArray< uint32_t , 8 > const& ovip ) noexcept T_AutoArray< uint32_t , 8 > const& ovip ) noexcept
{ {
auto& sinp( Globals::Sync( ).inputs( ) ); auto& sinp( Common::Sync( ).inputs( ) );
return glm::vec3{ return glm::vec3{
sinp[ ovip[ vc.x ] ] , sinp[ ovip[ vc.x ] ] ,
sinp[ ovip[ vc.y ] ] , sinp[ ovip[ vc.y ] ] ,
@ -253,7 +253,7 @@ void InputsFromVector_(
T_AutoArray< uint32_t , 8 > const& ovip , T_AutoArray< uint32_t , 8 > const& ovip ,
glm::vec3 const& v ) noexcept glm::vec3 const& v ) noexcept
{ {
auto& sinp( Globals::Sync( ).inputs( ) ); auto& sinp( Common::Sync( ).inputs( ) );
sinp[ ovip[ vc.x ] ] = v.x; sinp[ ovip[ vc.x ] ] = v.x;
sinp[ ovip[ vc.y ] ] = v.y; sinp[ ovip[ vc.y ] ] = v.y;
sinp[ ovip[ vc.z ] ] = v.z; sinp[ ovip[ vc.z ] ] = v.z;
@ -289,7 +289,7 @@ void T_MouseCam_::handleDragAndDrop(
T_KeyboardModifiers modifiers , T_KeyboardModifiers modifiers ,
T_MouseButtons buttons ) noexcept T_MouseButtons buttons ) noexcept
{ {
auto& sync( Globals::Sync( ) ); auto& sync( Common::Sync( ) );
if ( !ov.enabled( ) ) { if ( !ov.enabled( ) ) {
UI::Sync( ).clearMouseDelegate( ); UI::Sync( ).clearMouseDelegate( );
return; return;
@ -314,7 +314,7 @@ void T_MouseCam_::handleWheel(
T_KeyboardModifiers modifiers , T_KeyboardModifiers modifiers ,
T_MouseButtons buttons ) noexcept T_MouseButtons buttons ) noexcept
{ {
auto& sync( Globals::Sync( ) ); auto& sync( Common::Sync( ) );
if ( !ov.enabled( ) ) { if ( !ov.enabled( ) ) {
UI::Sync( ).clearMouseDelegate( ); UI::Sync( ).clearMouseDelegate( );
return; return;
@ -348,7 +348,7 @@ void T_MouseCam_::handleWheel(
M_DECL_SOVUI( Camera ) M_DECL_SOVUI( Camera )
{ {
auto& ov{ dynamic_cast< T_CamOverride& >( ovp ) }; auto& ov{ dynamic_cast< T_CamOverride& >( ovp ) };
auto& sync{ Globals::Sync( ) }; auto& sync{ Common::Sync( ) };
auto& sinp{ sync.inputs( ) }; auto& sinp{ sync.inputs( ) };
auto& camera{ ov.camData( ) }; auto& camera{ ov.camData( ) };
auto const& ovip{ ov.inputPositions( ) }; auto const& ovip{ ov.inputPositions( ) };

View file

@ -1,7 +1,7 @@
#include "externals.hh" #include "externals.hh"
#include "ui-sequencer.hh" #include "ui-sequencer.hh"
#include "sync.hh" #include "sync.hh"
#include "globals.hh" #include "common.hh"
#include "syncedit.hh" #include "syncedit.hh"
#include "ui.hh" #include "ui.hh"
#include "ui-app.hh" #include "ui-app.hh"
@ -246,7 +246,7 @@ bool T_SyncViewImpl_::display( ) noexcept
void T_SyncViewImpl_::checkSelectedCurves( ) noexcept void T_SyncViewImpl_::checkSelectedCurves( ) noexcept
{ {
auto& sync{ Globals::Sync( ) }; auto& sync{ Common::Sync( ) };
// Check for "dead" overrides // Check for "dead" overrides
{ {
@ -289,7 +289,7 @@ void T_SyncViewImpl_::checkSelectedCurves( ) noexcept
void T_SyncViewImpl_::displayToolbar( ) noexcept void T_SyncViewImpl_::displayToolbar( ) noexcept
{ {
using namespace ImGui; using namespace ImGui;
auto& sync( Globals::Sync( ) ); auto& sync( Common::Sync( ) );
if ( ToolbarButton( sync.playing( ) ? ICON_FA_STOP : ICON_FA_PLAY , BtSize , if ( ToolbarButton( sync.playing( ) ? ICON_FA_STOP : ICON_FA_PLAY , BtSize ,
sync.playing( ) ? "Stop" : "Play" ) ) { sync.playing( ) ? "Stop" : "Play" ) ) {
@ -396,8 +396,8 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept
} else if ( active ) { } else if ( active ) {
if ( io.MouseDown[ 0 ] ) { if ( io.MouseDown[ 0 ] ) {
const float p{ io.MousePos.x - bbAll.Min.x + startPixel }; const float p{ io.MousePos.x - bbAll.Min.x + startPixel };
auto& sync( Globals::Sync( ) ); auto& sync( Common::Sync( ) );
sync.setTime( p * Globals::Sync( ).duration( ) / totalPixels ); sync.setTime( p * Common::Sync( ).duration( ) / totalPixels );
} }
if ( io.MouseDown[ 1 ] ) { if ( io.MouseDown[ 1 ] ) {
const float p{ io.MousePos.x - bbAll.Min.x + startPixel }; const float p{ io.MousePos.x - bbAll.Min.x + startPixel };
@ -413,7 +413,7 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept
zMax{ std::max( firstZoomPixel , curZoomPixel ) } , zMax{ std::max( firstZoomPixel , curZoomPixel ) } ,
diff{ zMax - zMin }; diff{ zMax - zMin };
if ( diff > 4 ) { if ( diff > 4 ) {
auto& sync( Globals::Sync( ) ); auto& sync( Common::Sync( ) );
const float u( sync.durationUnits( ) ); const float u( sync.durationUnits( ) );
startPos = zMin * u / totalPixels; startPos = zMin * u / totalPixels;
if ( ( width - 2.f ) / u >= BarWidth ) { if ( ( width - 2.f ) / u >= BarWidth ) {
@ -436,7 +436,7 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept
void T_SyncViewImpl_::computeMetrics( void T_SyncViewImpl_::computeMetrics(
const float innerWidth ) noexcept const float innerWidth ) noexcept
{ {
auto& sync( Globals::Sync( ) ); auto& sync( Common::Sync( ) );
const uint32_t units{ sync.durationUnits( ) }; const uint32_t units{ sync.durationUnits( ) };
zoomLevel = ImSaturate( zoomLevel ); zoomLevel = ImSaturate( zoomLevel );
const float zoom1Pixels{ std::max( units * BarWidth , innerWidth ) }; const float zoom1Pixels{ std::max( units * BarWidth , innerWidth ) };
@ -576,7 +576,7 @@ void T_SyncViewImpl_::sequencerBody(
void T_SyncViewImpl_::sequencerCurves( ) noexcept void T_SyncViewImpl_::sequencerCurves( ) noexcept
{ {
auto& sync{ Globals::Sync( ) }; auto& sync{ Common::Sync( ) };
const auto nc{ sCurves.size( ) }; const auto nc{ sCurves.size( ) };
for ( auto i = 0u ; i < nc ; i ++ ) { for ( auto i = 0u ; i < nc ; i ++ ) {
if ( sCurves.values( )[ i ] ) { if ( sCurves.values( )[ i ] ) {
@ -646,7 +646,7 @@ void T_SyncViewImpl_::displayCurveSelectorWindow( ) noexcept
void T_SyncViewImpl_::displayCurveSelector( ) noexcept void T_SyncViewImpl_::displayCurveSelector( ) noexcept
{ {
using namespace ImGui; using namespace ImGui;
T_Array< T_String > names{ Globals::Sync( ).inputNames( ) }; T_Array< T_String > names{ Common::Sync( ).inputNames( ) };
// Search box; FIXME, this is utterly hacky // Search box; FIXME, this is utterly hacky
stringBuffer.clear( ) << curveFinder; stringBuffer.clear( ) << curveFinder;
@ -706,7 +706,7 @@ void T_SyncViewImpl_::displayOverrideSelector( ) noexcept
using namespace ImGui; using namespace ImGui;
BeginChild( "content" ); BeginChild( "content" );
Globals::Sync( ).visitOverrides( [&]( T_SyncOverrideVisitor::T_Element element , const bool exit ) { Common::Sync( ).visitOverrides( [&]( T_SyncOverrideVisitor::T_Element element , const bool exit ) {
if ( element.hasType< T_SyncOverrideSection* >( ) ) { if ( element.hasType< T_SyncOverrideSection* >( ) ) {
auto const& sos{ *element.value< T_SyncOverrideSection* >( ) }; auto const& sos{ *element.value< T_SyncOverrideSection* >( ) };
if ( sos.title == "*root*" ) { if ( sos.title == "*root*" ) {

View file

@ -1,5 +1,5 @@
#include "externals.hh" #include "externals.hh"
#include "globals.hh" #include "common.hh"
#include "ui.hh" #include "ui.hh"
#include "ui-actions.hh" #include "ui-actions.hh"
#include "ui-app.hh" #include "ui-app.hh"
@ -13,7 +13,7 @@
T_UISync::T_UISync( ) T_UISync::T_UISync( )
{ {
UI::Main( ).newAction( "Save curves" , []() { UI::Main( ).newAction( "Save curves" , []() {
if ( Globals::Sync( ).curvesFileChanged( ) ) { if ( Common::Sync( ).curvesFileChanged( ) ) {
UI::Main( ).msgbox( UI::Main( ).msgbox(
"Curves file changed" , "Curves file changed" ,
"The file containing the curves has been modified " "The file containing the curves has been modified "
@ -21,14 +21,14 @@ T_UISync::T_UISync( )
"Do you want to continue?" , "Do you want to continue?" ,
[]( auto b ) { []( auto b ) {
if ( b == T_MessageBox::BT_YES ) { if ( b == T_MessageBox::BT_YES ) {
Globals::Sync( ).saveCurves( ); Common::Sync( ).saveCurves( );
} }
} , { T_MessageBox::BT_YES , T_MessageBox::BT_NO } ); } , { T_MessageBox::BT_YES , T_MessageBox::BT_NO } );
} else { } else {
Globals::Sync( ).saveCurves( ); Common::Sync( ).saveCurves( );
} }
} ).setEnabledCheck( []() { } ).setEnabledCheck( []() {
return Globals::Sync( ).curvesModified( ); return Common::Sync( ).curvesModified( );
} ).setIcon( ICON_FA_FLOPPY_O ) } ).setIcon( ICON_FA_FLOPPY_O )
.setShortcut( T_KeyboardShortcut{ 's' , E_KeyboardModifier::CTRL } ); .setShortcut( T_KeyboardShortcut{ 's' , E_KeyboardModifier::CTRL } );
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -39,11 +39,11 @@ T_UISync::T_UISync( )
"want to continue?" , "want to continue?" ,
[]( auto b ) { []( auto b ) {
if ( b == T_MessageBox::BT_YES ) { if ( b == T_MessageBox::BT_YES ) {
Globals::Sync( ).loadCurves( ); Common::Sync( ).loadCurves( );
} }
} , { T_MessageBox::BT_YES , T_MessageBox::BT_NO } ); } , { T_MessageBox::BT_YES , T_MessageBox::BT_NO } );
} ).setEnabledCheck( []() { } ).setEnabledCheck( []() {
return Globals::Sync( ).curvesModified( ); return Common::Sync( ).curvesModified( );
} ).setIcon( ICON_FA_DOWNLOAD ) } ).setIcon( ICON_FA_DOWNLOAD )
.setShortcut( T_KeyboardShortcut{ 'r' , .setShortcut( T_KeyboardShortcut{ 'r' ,
{ E_KeyboardModifier::CTRL , E_KeyboardModifier::SHIFT } } ); { E_KeyboardModifier::CTRL , E_KeyboardModifier::SHIFT } } );
@ -99,7 +99,7 @@ void HandleOverride_(
bool& enabled{ ov.enabled( ) }; bool& enabled{ ov.enabled( ) };
if ( Checkbox( &ov.title( )[ 0 ] , &enabled ) ) { if ( Checkbox( &ov.title( )[ 0 ] , &enabled ) ) {
auto const& ipos( ov.inputPositions( ) ); auto const& ipos( ov.inputPositions( ) );
Globals::Sync( ).setOverridesActive( ov.enabled( ) , Common::Sync( ).setOverridesActive( ov.enabled( ) ,
ipos.size( ) , &ipos[ 0 ] ); ipos.size( ) , &ipos[ 0 ] );
} }
if ( !enabled ) { if ( !enabled ) {
@ -144,7 +144,7 @@ void T_UISync::makeOverridesWindow( )
T_AutoArray< bool , 32 > stack; T_AutoArray< bool , 32 > stack;
bool found{ false }; bool found{ false };
using T_Ove_ = T_SyncOverrideVisitor::T_Element; using T_Ove_ = T_SyncOverrideVisitor::T_Element;
Globals::Sync( ).visitOverrides( [&]( T_Ove_ element , bool exit ) { Common::Sync( ).visitOverrides( [&]( T_Ove_ element , bool exit ) {
// Display sections // Display sections
if ( element.hasType< T_SyncOverrideSection* >( ) ) { if ( element.hasType< T_SyncOverrideSection* >( ) ) {
auto& sos( *element.value< T_SyncOverrideSection* >( ) ); auto& sos( *element.value< T_SyncOverrideSection* >( ) );

4
ui.hh
View file

@ -10,7 +10,7 @@ struct T_OutputDebugger;
struct T_UISync; struct T_UISync;
struct UI : public ebcl::A_PrivateImplementation struct UI
{ {
public: public:
static void Init( ) noexcept; static void Init( ) noexcept;
@ -23,7 +23,7 @@ struct UI : public ebcl::A_PrivateImplementation
static T_UISync& Sync( ) noexcept; static T_UISync& Sync( ) noexcept;
private: private:
UI( ) noexcept; UI( ) = delete;
NO_COPY( UI ); NO_COPY( UI );
NO_MOVE( UI ); NO_MOVE( UI );
}; };