Sequencer - Moved existing view to separate file

This commit is contained in:
Emmanuel BENOîT 2017-11-20 17:01:09 +01:00
parent 0e8c95f27e
commit 037fea3101
6 changed files with 94 additions and 41 deletions

View file

@ -39,8 +39,9 @@ COMMON = \
# END COMMON
DEMO = \
main.cc \
demo.cc \
main.cc \
syncview.cc \
# END DEMO
PARSERCHECK = \

16
main.cc
View file

@ -9,6 +9,7 @@
#include "ops.hh"
#include "rendertarget.hh"
#include "sync.hh"
#include "syncview.hh"
using ebcl::T_Optional;
@ -34,6 +35,7 @@ struct T_Main
ImVec2 prevSize;
T_Optional< T_Demo > demo;
T_Optional< T_SyncView > sequencer;
void initDemo( );
@ -199,6 +201,7 @@ void T_Main::handleCapture( )
void T_Main::makeUI( )
{
using namespace ImGui;
bool eSequencer{ sequencer };
if ( BeginMainMenuBar( ) ) {
if ( BeginMenu( "File" ) ) {
if ( MenuItem( "Quit" ) ) {
@ -213,8 +216,7 @@ void T_Main::makeUI( )
&Globals::ODbg( ).uiEnabled( ) );
MenuItemCheckbox( "Profiler" ,
&Globals::Profiler( ).uiEnabled( ) );
MenuItemCheckbox( "Sequencer" ,
&Globals::Sync( ).sequencerWindowEnabled( ) );
MenuItemCheckbox( "Sequencer" , &eSequencer );
MenuItemCheckbox( "Shaders" ,
&Globals::Shaders( ).uiEnabled( ) );
EndMenu( );
@ -222,11 +224,19 @@ void T_Main::makeUI( )
EndMainMenuBar( );
}
if ( eSequencer && !sequencer ) {
sequencer.setNew( );
} else if ( !eSequencer && sequencer ) {
sequencer.clear( );
}
Globals::Profiler( ).makeUI( );
Globals::ODbg( ).makeUI( );
Globals::Shaders( ).makeUI( );
Globals::Sync( ).makeOverridesWindow( );
Globals::Sync( ).makeSequencerWindow( );
if ( sequencer && !sequencer->display( ) ) {
sequencer.clear( );
}
}
void T_Main::render( )

32
sync.cc
View file

@ -719,38 +719,6 @@ void T_SyncManager::setOverridesActive(
/*------------------------------------------------------------------------------*/
void T_SyncManager::makeSequencerWindow( )
{
if ( !tmWindow_ ) {
return;
}
using namespace ImGui;
auto const& dspSize( GetIO( ).DisplaySize );
SetNextWindowSize( ImVec2( dspSize.x , 150 ) , ImGuiSetCond_Appearing );
SetNextWindowPos( ImVec2( 0 , dspSize.y - 150 ) , ImGuiSetCond_Appearing );
Begin( "Sequencer" , &tmWindow_ , ImGuiWindowFlags_NoCollapse );
PushID( "playing" );
if ( Button( playing_ ? "Stop" : "Play" ) ) {
playing_ = !playing_;
}
PopID( );
const float d( duration( ) );
float tm( time( ) );
SameLine( );
PushID( "sequencer" );
PushItemWidth( -1 );
if ( SliderFloat( "" , &tm , 0 , d , "%.1fs" ) ) {
setTime( tm );
playing_ = playing_ && !finished( );
}
PopItemWidth( );
PopID( );
End( );
}
void T_SyncManager::makeOverridesWindow( )
{
if ( !ovWindow_ ) {

View file

@ -297,6 +297,9 @@ struct T_SyncManager : public virtual A_MouseCtrl
bool playing( ) const noexcept
{ return playing_; }
bool& playing( ) noexcept
{ return playing_; }
bool finished( ) const noexcept
{ return time_.time >= time_.duration( ); }
void updateTime( ) noexcept;
@ -352,10 +355,6 @@ struct T_SyncManager : public virtual A_MouseCtrl
// ---------------------------------------------------------------------
// User interface
bool& sequencerWindowEnabled( ) noexcept
{ return tmWindow_; }
void makeSequencerWindow( );
bool& overridesWindowEnabled( ) noexcept
{ return ovWindow_; }
void makeOverridesWindow( );
@ -389,7 +388,6 @@ struct T_SyncManager : public virtual A_MouseCtrl
float lastFrame_{ 0 }; // Time of last frame
T_SyncValues values_; // Value storage
T_SyncCurves curves_; // Curves storage
bool tmWindow_{ false }; // Sequencer window
T_Array< P_SyncCurveCache > curveCaches_; // Cache for curve segments
bool ovWindow_{ false }; // Overrides window
T_SyncOverrideSection soRoot_; // Root for overrides

65
syncview.cc Normal file
View file

@ -0,0 +1,65 @@
#include "externals.hh"
#include "syncview.hh"
#include "globals.hh"
using namespace ebcl;
/*= T_SyncViewImpl_ ============================================================*/
namespace {
struct T_SyncViewImpl_
{
bool display( ) noexcept;
};
bool T_SyncViewImpl_::display( ) noexcept
{
using namespace ImGui;
auto const& dspSize( GetIO( ).DisplaySize );
auto& sync( Globals::Sync( ) );
// Window set-up
SetNextWindowSize( ImVec2( dspSize.x , 150 ) , ImGuiSetCond_Appearing );
SetNextWindowPos( ImVec2( 0 , dspSize.y - 150 ) , ImGuiSetCond_Appearing );
bool displayed{ true };
Begin( "Sequencer" , &displayed , ImGuiWindowFlags_NoCollapse );
if ( !displayed ) {
return false;
}
PushID( "playing" );
if ( Button( sync.playing( ) ? "Stop" : "Play" ) ) {
sync.playing( ) = !sync.playing( ) && !sync.finished( );
}
PopID( );
const float d( sync.duration( ) );
float tm( sync.time( ) );
SameLine( );
PushID( "sequencer" );
PushItemWidth( -1 );
if ( SliderFloat( "" , &tm , 0 , d , "%.1fs" ) ) {
sync.setTime( tm );
sync.playing( ) = sync.playing( ) && !sync.finished( );
}
PopItemWidth( );
PopID( );
End( );
return true;
}
} // namespace
/*= T_SyncView =================================================================*/
T_SyncView::T_SyncView( ) noexcept
: A_PrivateImplementation( new T_SyncViewImpl_( ) )
{ }
bool T_SyncView::display( ) noexcept
{
return p< T_SyncViewImpl_ >( ).display( );
}

11
syncview.hh Normal file
View file

@ -0,0 +1,11 @@
#pragma once
#include "sync.hh"
class T_SyncView : public ebcl::A_PrivateImplementation
{
public:
T_SyncView( ) noexcept;
bool display( ) noexcept;
};