2017-11-20 17:01:09 +01:00
|
|
|
#include "externals.hh"
|
2017-11-23 23:37:52 +01:00
|
|
|
|
2017-11-23 23:05:14 +01:00
|
|
|
#include "common.hh"
|
2017-11-23 23:37:52 +01:00
|
|
|
#include "c-sync.hh"
|
|
|
|
#include "c-syncedit.hh"
|
|
|
|
|
2017-11-23 22:44:20 +01:00
|
|
|
#include "ui.hh"
|
2017-11-23 22:51:50 +01:00
|
|
|
#include "ui-app.hh"
|
2017-11-29 16:07:20 +01:00
|
|
|
#include "ui-overrides.hh"
|
2017-11-23 23:37:52 +01:00
|
|
|
#include "ui-sequencer.hh"
|
2017-11-29 16:07:20 +01:00
|
|
|
#include "ui-sync.hh"
|
2017-11-23 14:43:15 +01:00
|
|
|
#include "ui-utilities.hh"
|
2017-11-20 21:54:46 +01:00
|
|
|
|
2017-11-28 07:12:43 +01:00
|
|
|
#include "ui-imgui-sdl.hh"
|
|
|
|
|
2017-11-20 21:54:46 +01:00
|
|
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
|
|
|
#include <imgui_internal.h>
|
2017-11-20 17:01:09 +01:00
|
|
|
|
|
|
|
using namespace ebcl;
|
|
|
|
|
2017-11-21 22:23:34 +01:00
|
|
|
namespace {
|
2017-11-22 14:14:49 +01:00
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
/*= VARIOUS HELPERS ==========================================================*/
|
2017-11-22 14:14:49 +01:00
|
|
|
|
|
|
|
bool FakeTab_(
|
|
|
|
char const* const name ,
|
|
|
|
const bool disabled ,
|
|
|
|
const float width = 0.f )
|
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
if ( disabled ) {
|
2017-11-23 14:43:15 +01:00
|
|
|
PushDisabled( );
|
2017-11-21 22:23:34 +01:00
|
|
|
}
|
2017-11-22 14:14:49 +01:00
|
|
|
const bool rv( Button( name , ImVec2{ width , 0.f } ) );
|
|
|
|
if ( disabled ) {
|
2017-11-23 14:43:15 +01:00
|
|
|
PopDisabled( );
|
2017-11-22 16:17:24 +01:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
void TimeToString_(
|
|
|
|
char* const buffer ,
|
|
|
|
const size_t bSize ,
|
|
|
|
const float time ) noexcept
|
|
|
|
{
|
|
|
|
const float msf{ fmod( time , 1.f ) };
|
|
|
|
const float sf{ fmod( time - msf , 60.f ) };
|
|
|
|
snprintf( buffer , bSize , "%02d:%02d.%03d" ,
|
|
|
|
uint32_t( ( time - msf - sf ) / 60.f ) ,
|
|
|
|
uint32_t( sf ) , uint32_t( msf * 1000.f ) );
|
|
|
|
}
|
|
|
|
|
2017-11-20 17:01:09 +01:00
|
|
|
|
2017-11-22 14:14:49 +01:00
|
|
|
/*= T_ChangeDurationDialog_ ==================================================*/
|
|
|
|
|
|
|
|
class T_ChangeDurationDialog_ : public A_ModalDialog
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
const uint32_t units0_;
|
|
|
|
const float uSize0_;
|
|
|
|
const uint32_t uPerMinute0_;
|
|
|
|
uint32_t units_;
|
|
|
|
float uSize_;
|
|
|
|
uint32_t uPerMinute_;
|
|
|
|
bool scale_{ true };
|
|
|
|
|
|
|
|
protected:
|
2017-11-23 12:24:40 +01:00
|
|
|
uint8_t drawDialog( ) noexcept override;
|
|
|
|
bool onButton( uint8_t id ) noexcept override;
|
2017-11-22 14:14:49 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
T_ChangeDurationDialog_(
|
|
|
|
uint32_t units ,
|
|
|
|
float uSize ) noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
T_ChangeDurationDialog_::T_ChangeDurationDialog_(
|
|
|
|
const uint32_t units ,
|
|
|
|
const float uSize ) noexcept
|
|
|
|
: A_ModalDialog{ "Set demo duration...##duration-dialog" } ,
|
|
|
|
units0_{ units } , uSize0_{ std::max( 1.f / 60.f , uSize ) } ,
|
|
|
|
uPerMinute0_{ uint32_t( ImClamp( roundf( 60.f / uSize0_ ) , 1.f , 3600.f ) ) } ,
|
|
|
|
units_{ units0_ } , uSize_{ uSize0_ } , uPerMinute_{ uPerMinute0_ }
|
|
|
|
{
|
|
|
|
setInitialSize( 300.f , 180.f );
|
2017-11-23 12:24:40 +01:00
|
|
|
addButton( "OK" );
|
|
|
|
addButton( "Cancel" );
|
2017-11-22 14:14:49 +01:00
|
|
|
}
|
|
|
|
|
2017-11-23 12:24:40 +01:00
|
|
|
uint8_t T_ChangeDurationDialog_::drawDialog( ) noexcept
|
2017-11-22 14:14:49 +01:00
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
|
|
|
|
int tUnits( units_ );
|
|
|
|
if ( DragInt( "Duration##units" , &tUnits , .1f , 1 , INT32_MAX , "%.0f unit(s)" ) ) {
|
|
|
|
units_ = uint32_t( std::min( INT32_MAX , std::max( 1 , tUnits ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
float tDuration( units_ * uSize_ );
|
|
|
|
if ( DragFloat( "##seconds" , &tDuration , 1.f , .001f , FLT_MAX , "%.3f second(s)" ) ) {
|
|
|
|
units_ = std::min( uint32_t( INT32_MAX ) , std::max( 1u ,
|
|
|
|
uint32_t( roundf( tDuration / uSize_ ) ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
Separator( );
|
|
|
|
|
|
|
|
int tUsize( floorf( uSize_ * 1000.f ) );
|
|
|
|
if ( SliderInt( "Units" , &tUsize , 16 , 2000 , "%.0f ms" ) ) {
|
|
|
|
const float pDur{ uSize_ * units_ };
|
|
|
|
uSize_ = std::min( 2.f , std::max( 1.f / 60.f ,
|
|
|
|
.001f * tUsize ) );
|
|
|
|
uPerMinute_ = roundf( 60.f / uSize_ );
|
|
|
|
units_ = uint32_t( roundf( pDur / uSize_ ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
int tPerMin( uPerMinute_ );
|
|
|
|
if ( SliderInt( "Units/minute" , &tPerMin , 30 , 3600 ) ) {
|
|
|
|
const float pDur{ uSize_ * units_ };
|
|
|
|
uPerMinute_ = std::max( 30u , std::min( 3600u , uint32_t( tPerMin ) ) );
|
|
|
|
uSize_ = 60.f / uPerMinute_;
|
|
|
|
units_ = uint32_t( roundf( pDur / uSize_ ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( uPerMinute0_ == uPerMinute_ ) {
|
2017-11-23 14:43:15 +01:00
|
|
|
PushDisabled( );
|
2017-11-22 14:14:49 +01:00
|
|
|
}
|
|
|
|
Checkbox( "Scale curves" , &scale_ );
|
|
|
|
if ( uPerMinute0_ == uPerMinute_ ) {
|
2017-11-23 14:43:15 +01:00
|
|
|
PopDisabled( );
|
2017-11-22 14:14:49 +01:00
|
|
|
}
|
|
|
|
|
2017-11-23 12:24:40 +01:00
|
|
|
const bool eo{ units_ != units0_ || uPerMinute_ != uPerMinute0_ };
|
|
|
|
return eo ? 3 : 2;
|
2017-11-22 14:14:49 +01:00
|
|
|
}
|
|
|
|
|
2017-11-23 12:24:40 +01:00
|
|
|
bool T_ChangeDurationDialog_::onButton(
|
|
|
|
const uint8_t button ) noexcept
|
2017-11-22 14:14:49 +01:00
|
|
|
{
|
2017-11-23 12:24:40 +01:00
|
|
|
if ( button == 0 ) {
|
|
|
|
SyncEditor::SetDuration( units_ ,
|
|
|
|
uPerMinute_ != uPerMinute0_ ? uSize_ : uSize0_ ,
|
|
|
|
scale_ );
|
|
|
|
}
|
|
|
|
return true;
|
2017-11-22 14:14:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-29 16:07:20 +01:00
|
|
|
/*= T_PointData_ =============================================================*/
|
|
|
|
|
|
|
|
using T_TempCurveStorage_ = T_AutoArray< T_SyncCurve , 16 >;
|
|
|
|
|
|
|
|
class T_PointData_ : public sov::A_SyncData
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
T_Optional< T_SyncTrackId > const& selId_;
|
|
|
|
T_Optional< uint32_t > const& selSegment_;
|
|
|
|
T_Optional< uint32_t > const& selPoint_;
|
|
|
|
T_TempCurveStorage_& cOriginals_;
|
|
|
|
T_TempCurveStorage_& cCopies_;
|
|
|
|
|
|
|
|
T_String useId_;
|
|
|
|
uint32_t useSegment_;
|
|
|
|
uint32_t usePoint_;
|
|
|
|
|
|
|
|
A_SyncOverride* ovr_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
T_PointData_( T_Optional< T_SyncTrackId > const& selId ,
|
|
|
|
T_Optional< uint32_t > const& selSegment ,
|
|
|
|
T_Optional< uint32_t > const& selPoint ,
|
|
|
|
T_TempCurveStorage_& cOriginals ,
|
|
|
|
T_TempCurveStorage_& cCopies ) noexcept
|
|
|
|
: selId_( selId ) , selSegment_( selSegment ) ,
|
|
|
|
selPoint_( selPoint ) , cOriginals_( cOriginals ) ,
|
|
|
|
cCopies_( cCopies )
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void use( ) noexcept;
|
|
|
|
|
|
|
|
float operator[]( uint32_t index ) const noexcept override;
|
|
|
|
bool set( uint32_t index , float value ) noexcept override;
|
|
|
|
|
|
|
|
T_OwnPtr< sov::A_SyncData > clone( ) const noexcept override;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
void T_PointData_::use( ) noexcept
|
|
|
|
{
|
|
|
|
assert( selId_ && selSegment_ && selPoint_ );
|
|
|
|
assert( selId_->isOverride );
|
|
|
|
|
|
|
|
useId_ = selId_->id;
|
|
|
|
useSegment_ = *selSegment_;
|
|
|
|
usePoint_ = *selPoint_;
|
|
|
|
ovr_ = Common::Sync( ).getOverride( useId_ );
|
|
|
|
}
|
|
|
|
|
|
|
|
float T_PointData_::operator[](
|
|
|
|
const uint32_t index ) const noexcept
|
|
|
|
{
|
|
|
|
if ( !( selId_ && selSegment_ && selPoint_ && selId_->isOverride )
|
|
|
|
|| useId_ != selId_->id || useSegment_ != *selSegment_
|
|
|
|
|| usePoint_ != *selPoint_ ) {
|
|
|
|
return 0.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto const& iNames{ ovr_->inputNames( ) };
|
|
|
|
if ( cCopies_.size( ) != iNames.size( )
|
|
|
|
|| cCopies_[ 0 ].name != iNames[ 0 ] ) {
|
|
|
|
auto const& curve{ *Common::Sync( ).getCurve( iNames[ index ] ) };
|
|
|
|
return curve.segments[ useSegment_ ].values[ usePoint_ ];
|
|
|
|
}
|
|
|
|
return cCopies_[ index ].segments[ useSegment_ ].values[ usePoint_ ];
|
|
|
|
}
|
|
|
|
|
|
|
|
bool T_PointData_::set(
|
|
|
|
const uint32_t index ,
|
|
|
|
const float value ) noexcept
|
|
|
|
{
|
|
|
|
if ( !( selId_ && selSegment_ && selPoint_ && selId_->isOverride )
|
|
|
|
|| useId_ != selId_->id || useSegment_ != *selSegment_
|
|
|
|
|| usePoint_ != *selPoint_ ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto const& iNames{ ovr_->inputNames( ) };
|
|
|
|
const auto nn{ iNames.size( ) };
|
|
|
|
auto& sync{ Common::Sync( ) };
|
|
|
|
if ( cCopies_.size( ) != nn || cCopies_[ 0 ].name != iNames[ 0 ] ) {
|
|
|
|
cOriginals_.clear( );
|
|
|
|
cCopies_.clear( );
|
|
|
|
for ( auto i = 0u ; i < nn ; i ++ ) {
|
|
|
|
auto const* const c{ sync.getCurve( iNames[ i ] ) };
|
|
|
|
cOriginals_.add( *c );
|
|
|
|
cCopies_.add( *c );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cCopies_[ index ].segments[ useSegment_ ].values[ usePoint_ ] = value;
|
|
|
|
sync.setCurve( cCopies_[ index ] );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
T_OwnPtr< sov::A_SyncData > T_PointData_::clone( ) const noexcept
|
|
|
|
{
|
|
|
|
auto ptr{ NewOwned< T_PointData_ >( selId_ , selSegment_ ,
|
|
|
|
selPoint_ , cOriginals_ , cCopies_ ) };
|
|
|
|
ptr->useId_ = useId_;
|
|
|
|
ptr->useSegment_ = useSegment_;
|
|
|
|
ptr->usePoint_ = usePoint_;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-22 14:14:49 +01:00
|
|
|
/*= T_SyncViewImpl_ ==========================================================*/
|
2017-11-20 17:01:09 +01:00
|
|
|
|
|
|
|
struct T_SyncViewImpl_
|
|
|
|
{
|
2017-11-25 16:30:46 +01:00
|
|
|
static constexpr float SeqHeaderHeight = 24.f;
|
|
|
|
static constexpr float BarWidth = 40.f;
|
|
|
|
static constexpr float TrackHeight = 15.f;
|
|
|
|
static constexpr float TrackPadding = 2.f;
|
2017-11-30 09:18:13 +01:00
|
|
|
static constexpr float TrackLabelHeight = 15.f;
|
2017-11-25 22:02:17 +01:00
|
|
|
static constexpr float PointRadius = ( TrackHeight - 2.f ) * .5f;
|
|
|
|
static constexpr float PointRadiusSqr = PointRadius * PointRadius;
|
2017-11-20 21:54:46 +01:00
|
|
|
|
2017-11-20 17:01:09 +01:00
|
|
|
bool display( ) noexcept;
|
2017-11-21 22:23:34 +01:00
|
|
|
|
2017-11-22 17:24:22 +01:00
|
|
|
private:
|
2017-11-28 16:47:35 +01:00
|
|
|
|
|
|
|
// Track display data
|
|
|
|
struct T_TrackDisplay
|
|
|
|
{
|
2017-11-29 07:20:22 +01:00
|
|
|
T_SyncTrackId id;
|
2017-11-25 22:02:17 +01:00
|
|
|
ImRect area;
|
|
|
|
uint32_t dispSegs;
|
|
|
|
uint32_t firstSeg;
|
|
|
|
};
|
|
|
|
struct T_TrackSegDisplay
|
|
|
|
{
|
|
|
|
uint32_t track;
|
|
|
|
uint32_t seg;
|
|
|
|
ImRect area;
|
|
|
|
uint32_t dispPoints;
|
|
|
|
uint32_t firstPoint;
|
|
|
|
};
|
|
|
|
struct T_TrackPointDisplay
|
|
|
|
{
|
|
|
|
uint32_t seg;
|
|
|
|
uint32_t index;
|
|
|
|
ImVec2 center;
|
|
|
|
enum {
|
|
|
|
START ,
|
|
|
|
MIDDLE ,
|
|
|
|
END
|
|
|
|
} mode;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Description for mouse locations in the sequencer window
|
|
|
|
enum class E_MousePosType
|
|
|
|
{
|
|
|
|
NONE ,
|
|
|
|
TRACK ,
|
|
|
|
SEGMENT ,
|
|
|
|
POINT
|
|
|
|
};
|
|
|
|
struct T_MousePos
|
|
|
|
{
|
|
|
|
E_MousePosType type;
|
|
|
|
uint32_t index;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Type of sub-windows
|
|
|
|
enum E_SubWindow {
|
|
|
|
SW_NONE ,
|
2017-11-25 23:37:07 +01:00
|
|
|
SW_INPUT_SELECTOR ,
|
2017-11-25 22:02:17 +01:00
|
|
|
SW_OVERRIDE_SELECTOR ,
|
2017-11-26 10:14:00 +01:00
|
|
|
SW_TRACK ,
|
2017-11-25 23:37:07 +01:00
|
|
|
SW_SEGMENT ,
|
2017-11-26 17:39:17 +01:00
|
|
|
SW_POINT ,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Type of change in progress
|
|
|
|
enum class E_ChangeType {
|
|
|
|
NONE ,
|
|
|
|
POINT_DND ,
|
|
|
|
POINT_VALUE ,
|
2017-11-25 22:02:17 +01:00
|
|
|
};
|
|
|
|
|
2017-11-30 12:10:47 +01:00
|
|
|
// Type of drag-and-drop operation in progress
|
|
|
|
enum class E_DNDType {
|
|
|
|
NONE , // No drag'n'drop
|
|
|
|
CLICK , // Clicked in an area that will not
|
|
|
|
// cause drag'n'drop to happen
|
|
|
|
TIME , // Time being adjusted
|
|
|
|
ZOOM , // Zoom region being selected
|
|
|
|
POINT , // Point being moved
|
|
|
|
};
|
|
|
|
|
2017-11-27 07:12:04 +01:00
|
|
|
// Make sure all displayed inputs/overrides still exist
|
|
|
|
void checkTracks( ) noexcept;
|
|
|
|
// Make sure the currently selected track/segment/point is still valid
|
|
|
|
void checkSelection( ) noexcept;
|
|
|
|
// Display the toolbar
|
2017-11-22 16:17:24 +01:00
|
|
|
void displayToolbar( ) noexcept;
|
|
|
|
|
2017-11-25 23:37:07 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Sequencer widget methods
|
|
|
|
|
2017-11-20 21:54:46 +01:00
|
|
|
void sequencerWidget( ) noexcept;
|
2017-11-26 10:14:00 +01:00
|
|
|
void computeMetrics( float innerWidth ) noexcept;
|
2017-11-20 21:54:46 +01:00
|
|
|
void sequencerHeader( ImRect const& bb ) noexcept;
|
2017-11-25 22:02:17 +01:00
|
|
|
void sequencerBody( ImRect const& bb ) noexcept;
|
|
|
|
void sequencerTracks(
|
2017-11-25 16:30:46 +01:00
|
|
|
ImRect const& container ) noexcept;
|
2017-11-25 22:02:17 +01:00
|
|
|
void sequencerTrack(
|
2017-11-25 16:30:46 +01:00
|
|
|
float& hue ,
|
|
|
|
ImRect const& bb ,
|
|
|
|
ImRect const& container ,
|
2017-11-29 07:20:22 +01:00
|
|
|
T_SyncTrackId const& id ,
|
2017-11-25 16:30:46 +01:00
|
|
|
T_SyncCurve const* curve ) noexcept;
|
2017-11-21 13:43:01 +01:00
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
void displayTooltips(
|
|
|
|
const float time ) noexcept;
|
2017-11-26 13:46:46 +01:00
|
|
|
bool handlePointDrag(
|
|
|
|
const float mPixels ,
|
2017-11-30 12:36:22 +01:00
|
|
|
bool mouseDown ,
|
|
|
|
bool shiftPressed ) noexcept;
|
2017-11-25 22:02:17 +01:00
|
|
|
|
|
|
|
T_MousePos getMousePos( ) const noexcept;
|
|
|
|
|
2017-11-25 23:37:07 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Track selector
|
|
|
|
void displayTrackSelectorWindow( ) noexcept;
|
|
|
|
void displayInputSelector( ) noexcept;
|
2017-11-22 07:38:27 +01:00
|
|
|
void displayOverrideSelector( ) noexcept;
|
2017-11-21 22:23:34 +01:00
|
|
|
|
2017-11-30 10:13:37 +01:00
|
|
|
void clearSelectedTracks( ) noexcept;
|
|
|
|
void autoselectTracks( ) noexcept;
|
|
|
|
|
2017-11-28 15:04:28 +01:00
|
|
|
// Helpers for selecting overrides
|
|
|
|
static bool areOverrideInputsConsistent(
|
|
|
|
A_SyncOverride const& ov ) noexcept;
|
2017-11-30 10:13:37 +01:00
|
|
|
static bool wouldInputsNeedAdjustment(
|
|
|
|
A_SyncOverride const& ov ) noexcept;
|
2017-11-28 15:04:28 +01:00
|
|
|
bool areOverrideInputsDisplayed(
|
|
|
|
A_SyncOverride const& ov ) const noexcept;
|
|
|
|
void overrideTrackToggled(
|
|
|
|
A_SyncOverride const& ov ,
|
|
|
|
bool selected ) noexcept;
|
|
|
|
|
2017-11-28 10:42:04 +01:00
|
|
|
// Selection display/edition windows
|
2017-11-26 10:14:00 +01:00
|
|
|
void displayTrackWindow( ) noexcept;
|
2017-11-25 23:37:07 +01:00
|
|
|
void displaySegmentWindow( ) noexcept;
|
2017-11-26 17:39:17 +01:00
|
|
|
void displayPointWindow( ) noexcept;
|
2017-11-25 23:37:07 +01:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2017-11-22 17:24:22 +01:00
|
|
|
// Colors, sizes, etc.
|
|
|
|
const uint32_t ColFrame{ ImGui::GetColorU32( ImVec4{ 0 , 0 , 0 , .8 } ) };
|
|
|
|
const uint32_t ColHeader{ ImGui::GetColorU32( ImVec4{ .5 , .5 , .5 , .8 } ) };
|
|
|
|
const uint32_t ColHeaderText{ ImGui::GetColorU32( ImVec4{ 0 , 0 , 0 , 1 } ) };
|
|
|
|
const uint32_t ColMain{ ImGui::GetColorU32( ImVec4{ .4 , .4 , .4 , .8 } ) };
|
|
|
|
const uint32_t ColSelection{ ImGui::GetColorU32( ImVec4{ .8 , 1 , .8 , .2 } ) };
|
2017-11-26 13:46:46 +01:00
|
|
|
const uint32_t ColPointNormal{ ImGui::GetColorU32( ImVec4{ 0 , 0 , 0 , .25 } ) };
|
2017-11-30 07:12:58 +01:00
|
|
|
const uint32_t ColPointHovered{ ImGui::GetColorU32( ImVec4{ 1 , 1 , 1 , .75 } ) };
|
2017-11-26 13:46:46 +01:00
|
|
|
const uint32_t ColPointSelected{ ImGui::GetColorU32( ImVec4{ 0 , 0 , 0 , .75 } ) };
|
2017-11-22 17:24:22 +01:00
|
|
|
const ImVec2 BtSize{ 20 , 0 };
|
|
|
|
|
|
|
|
// Sequencer settings
|
|
|
|
float zoomLevel{ 0.f };
|
|
|
|
float startPos{ 0.f };
|
|
|
|
bool followTime{ true };
|
2017-11-30 09:18:13 +01:00
|
|
|
bool showLabels{ true };
|
2017-11-22 17:24:22 +01:00
|
|
|
|
2017-11-21 22:23:34 +01:00
|
|
|
// Misc stuff
|
|
|
|
T_StringBuilder stringBuffer; // XXX damn this shit to fucking hell
|
2017-11-30 12:10:47 +01:00
|
|
|
E_DNDType dnd{ E_DNDType::NONE };
|
2017-11-21 22:23:34 +01:00
|
|
|
|
2017-11-21 13:43:01 +01:00
|
|
|
// Computed metrics
|
2017-11-27 13:54:06 +01:00
|
|
|
bool checkLockMode{ false };
|
|
|
|
float vScroll{ 0 };
|
2017-11-21 13:43:01 +01:00
|
|
|
float barWidth;
|
|
|
|
float cursorPos;
|
|
|
|
uint32_t startBar;
|
|
|
|
float startBarPos;
|
|
|
|
float timePerBar;
|
2017-11-21 15:48:34 +01:00
|
|
|
float totalPixels;
|
|
|
|
float startPixel;
|
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
// Track display
|
|
|
|
T_Array< T_TrackDisplay > dspTracks;
|
|
|
|
T_Array< T_TrackSegDisplay > dspSegments;
|
|
|
|
T_Array< T_TrackPointDisplay > dspPoints;
|
|
|
|
|
2017-11-21 15:48:34 +01:00
|
|
|
// Zoom area selection
|
|
|
|
float firstZoomPixel;
|
|
|
|
float curZoomPixel;
|
2017-11-21 22:23:34 +01:00
|
|
|
|
2017-11-25 23:37:07 +01:00
|
|
|
// Selected item
|
2017-11-29 07:20:22 +01:00
|
|
|
T_Optional< T_SyncTrackId > selId{ };
|
2017-11-26 10:14:00 +01:00
|
|
|
T_Optional< uint32_t > selSegment;
|
2017-11-25 23:37:07 +01:00
|
|
|
T_Optional< uint32_t > selPoint;
|
2017-11-26 13:46:46 +01:00
|
|
|
float selPointDnDStart , selPointDnDCur;
|
2017-11-26 17:39:17 +01:00
|
|
|
|
|
|
|
// Original and copy of curve being modified
|
|
|
|
E_ChangeType selUpdate{ E_ChangeType::NONE };
|
2017-11-29 16:07:20 +01:00
|
|
|
T_TempCurveStorage_ selUpdatingOriginals;
|
|
|
|
T_TempCurveStorage_ selUpdatingCopies;
|
|
|
|
|
2017-11-29 16:36:18 +01:00
|
|
|
// Override edition and copypasta
|
2017-11-29 16:07:20 +01:00
|
|
|
T_PointData_ selEditor{ selId , selSegment , selPoint ,
|
|
|
|
selUpdatingOriginals , selUpdatingCopies };
|
2017-11-29 16:36:18 +01:00
|
|
|
T_String cpType;
|
|
|
|
T_AutoArray< float , 16 > cpData;
|
2017-11-25 23:37:07 +01:00
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
// Sub-windows
|
2017-11-21 22:23:34 +01:00
|
|
|
E_SubWindow sub{ SW_NONE };
|
2017-11-30 09:35:47 +01:00
|
|
|
E_SubWindow tsSelectedTab{ SW_OVERRIDE_SELECTOR };
|
2017-11-25 22:02:17 +01:00
|
|
|
|
2017-11-28 18:57:27 +01:00
|
|
|
// Track selection
|
|
|
|
T_KeyValueTable< T_String , bool > sInputs;
|
2017-11-29 07:20:22 +01:00
|
|
|
T_Set< T_SyncTrackId > sTracks;
|
2017-11-21 22:23:34 +01:00
|
|
|
T_String curveFinder;
|
2017-11-20 17:01:09 +01:00
|
|
|
};
|
|
|
|
|
2017-11-21 15:48:34 +01:00
|
|
|
constexpr float T_SyncViewImpl_::BarWidth;
|
|
|
|
|
2017-11-22 14:14:49 +01:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2017-11-20 17:01:09 +01:00
|
|
|
|
|
|
|
bool T_SyncViewImpl_::display( ) noexcept
|
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
auto const& dspSize( GetIO( ).DisplaySize );
|
|
|
|
|
|
|
|
// Window set-up
|
2017-11-21 16:30:15 +01:00
|
|
|
SetNextWindowSize( ImVec2( dspSize.x , dspSize.y * .34f ) , ImGuiSetCond_Appearing );
|
|
|
|
SetNextWindowPos( ImVec2( 0 , dspSize.y * .66f ) , ImGuiSetCond_Appearing );
|
2017-11-20 17:01:09 +01:00
|
|
|
bool displayed{ true };
|
2017-11-20 21:54:46 +01:00
|
|
|
Begin( "Sequencer" , &displayed , ImGuiWindowFlags_NoCollapse
|
|
|
|
| ImGuiWindowFlags_NoScrollWithMouse );
|
2017-11-20 17:01:09 +01:00
|
|
|
if ( !displayed ) {
|
2017-11-20 21:54:46 +01:00
|
|
|
End( );
|
2017-11-20 17:01:09 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-27 07:12:04 +01:00
|
|
|
checkTracks( );
|
|
|
|
checkSelection( );
|
2017-11-22 16:17:24 +01:00
|
|
|
displayToolbar( );
|
|
|
|
|
2017-11-27 07:12:04 +01:00
|
|
|
// Sequencer widget
|
2017-11-22 16:17:24 +01:00
|
|
|
PushItemWidth( -1 );
|
|
|
|
sequencerWidget( );
|
|
|
|
PopItemWidth( );
|
|
|
|
End( );
|
|
|
|
|
2017-11-27 07:12:04 +01:00
|
|
|
// Close sub-window if e.g. selection has changed
|
|
|
|
switch( sub ) {
|
|
|
|
case SW_POINT:
|
|
|
|
if ( !selPoint ) {
|
|
|
|
sub = SW_SEGMENT;
|
|
|
|
}
|
|
|
|
// fallthrough
|
|
|
|
case SW_SEGMENT:
|
|
|
|
if ( !selSegment ) {
|
|
|
|
sub = SW_TRACK;
|
|
|
|
}
|
|
|
|
// fallthrough
|
|
|
|
case SW_TRACK:
|
|
|
|
if ( !selId ) {
|
|
|
|
sub = SW_NONE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Display selected sub-window
|
2017-11-22 16:17:24 +01:00
|
|
|
switch ( sub ) {
|
|
|
|
case SW_NONE:
|
|
|
|
break;
|
|
|
|
|
2017-11-25 23:37:07 +01:00
|
|
|
case SW_INPUT_SELECTOR:
|
2017-11-22 16:17:24 +01:00
|
|
|
case SW_OVERRIDE_SELECTOR:
|
2017-11-25 23:37:07 +01:00
|
|
|
displayTrackSelectorWindow( );
|
|
|
|
break;
|
|
|
|
|
2017-11-26 10:14:00 +01:00
|
|
|
case SW_TRACK:
|
|
|
|
displayTrackWindow( );
|
|
|
|
break;
|
|
|
|
|
2017-11-25 23:37:07 +01:00
|
|
|
case SW_SEGMENT:
|
|
|
|
displaySegmentWindow( );
|
2017-11-22 16:17:24 +01:00
|
|
|
break;
|
2017-11-26 17:39:17 +01:00
|
|
|
|
|
|
|
case SW_POINT:
|
|
|
|
displayPointWindow( );
|
|
|
|
break;
|
2017-11-21 17:32:52 +01:00
|
|
|
}
|
2017-11-22 16:17:24 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-27 07:12:04 +01:00
|
|
|
void T_SyncViewImpl_::checkTracks( ) noexcept
|
2017-11-22 17:24:22 +01:00
|
|
|
{
|
2017-11-23 23:05:14 +01:00
|
|
|
auto& sync{ Common::Sync( ) };
|
2017-11-22 17:24:22 +01:00
|
|
|
|
2017-11-28 18:57:27 +01:00
|
|
|
// Check for overrides that have gone missing or that have become
|
|
|
|
// inconsistent.
|
2017-11-22 17:24:22 +01:00
|
|
|
{
|
|
|
|
bool ovRemoved{ false };
|
2017-11-28 18:57:27 +01:00
|
|
|
for ( auto i = 0u ; i < sTracks.size( ) ; ) {
|
|
|
|
const auto& t{ sTracks[ i ] };
|
|
|
|
if ( !t.isOverride ) {
|
2017-11-22 17:24:22 +01:00
|
|
|
i ++;
|
2017-11-28 18:57:27 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
A_SyncOverride const* const ovr{ sync.getOverride( t.id ) };
|
|
|
|
if ( ovr && areOverrideInputsConsistent( *ovr ) ) {
|
|
|
|
i++;
|
|
|
|
continue;
|
2017-11-22 17:24:22 +01:00
|
|
|
}
|
2017-11-28 18:57:27 +01:00
|
|
|
|
|
|
|
sTracks.remove( t );
|
|
|
|
ovRemoved = true;
|
2017-11-22 17:24:22 +01:00
|
|
|
}
|
|
|
|
if ( !ovRemoved ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove all curves that come from overrides
|
2017-11-28 18:57:27 +01:00
|
|
|
for ( auto i = 0u ; i < sInputs.size( ) ; ) {
|
|
|
|
if ( sInputs.values( )[ i ] ) {
|
|
|
|
sInputs.remove( sInputs.keys( )[ i ] );
|
2017-11-22 17:24:22 +01:00
|
|
|
} else {
|
|
|
|
i ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Re-add curves for the remaining overrides
|
2017-11-28 18:57:27 +01:00
|
|
|
const auto no{ sTracks.size( ) };
|
2017-11-22 17:24:22 +01:00
|
|
|
for ( auto i = 0u ; i < no ; i ++ ) {
|
2017-11-28 18:57:27 +01:00
|
|
|
auto const& t{ sTracks[ i ] };
|
|
|
|
auto const* const od{ sync.getOverride( t.id ) };
|
2017-11-22 17:24:22 +01:00
|
|
|
assert( od );
|
|
|
|
const auto ni{ od->inputNames( ).size( ) };
|
|
|
|
for ( auto j = 0u ; j < ni ; j ++ ) {
|
2017-11-28 18:57:27 +01:00
|
|
|
const bool ok{ sInputs.add( od->inputNames( )[ j ] , true ) };
|
2017-11-22 17:24:22 +01:00
|
|
|
assert( ok ); (void) ok;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-27 07:12:04 +01:00
|
|
|
void T_SyncViewImpl_::checkSelection( ) noexcept
|
|
|
|
{
|
|
|
|
if ( !selId ) {
|
|
|
|
return;
|
|
|
|
}
|
2017-11-28 22:10:10 +01:00
|
|
|
auto& sync{ Common::Sync( ) };
|
2017-11-30 13:52:50 +01:00
|
|
|
auto const* const ovr{ selId->isOverride ? sync.getOverride( selId->id ) : nullptr };
|
|
|
|
auto const* const curve{ sync.getCurve( ovr ? ovr->inputNames( )[ 0 ] : selId->id ) };
|
2017-11-27 07:12:04 +01:00
|
|
|
|
|
|
|
// Missing curve
|
2017-11-30 13:52:50 +01:00
|
|
|
if ( !curve ) {
|
2017-11-27 07:12:04 +01:00
|
|
|
// Remove segment/point selection
|
|
|
|
if ( selSegment ) {
|
|
|
|
selSegment.clear( );
|
|
|
|
selPoint.clear( );
|
|
|
|
}
|
|
|
|
// If there's no matching input, unselect the track
|
2017-11-30 13:52:50 +01:00
|
|
|
if ( !( ovr || sync.hasInput( selId->id ) ) ) {
|
2017-11-28 16:47:35 +01:00
|
|
|
selId.clear( );
|
2017-11-27 07:12:04 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// No segment selected? We're ok.
|
|
|
|
if ( !selSegment ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check segment and point
|
|
|
|
if ( *selSegment >= curve->segments.size( ) ) {
|
|
|
|
selSegment.clear( );
|
|
|
|
selPoint.clear( );
|
|
|
|
} else if ( selPoint && *selPoint >= curve->segments[
|
|
|
|
*selSegment ].values.size( ) ) {
|
|
|
|
selPoint.clear( );
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// If we were doing something with the curve, get rid of that too
|
|
|
|
if ( selUpdate != E_ChangeType::NONE ) {
|
|
|
|
selUpdate = E_ChangeType::NONE;
|
2017-11-29 12:44:36 +01:00
|
|
|
selUpdatingCopies.clear( );
|
|
|
|
selUpdatingOriginals.clear( );
|
2017-11-27 07:12:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-22 16:17:24 +01:00
|
|
|
void T_SyncViewImpl_::displayToolbar( ) noexcept
|
|
|
|
{
|
|
|
|
using namespace ImGui;
|
2017-11-28 22:10:10 +01:00
|
|
|
auto& sync{ Common::Sync( ) };
|
2017-11-22 16:17:24 +01:00
|
|
|
|
2017-11-30 09:18:13 +01:00
|
|
|
UI::Main( ).actionButton( sync.playing( ) ? "Stop" : "Play" );
|
2017-11-21 12:27:23 +01:00
|
|
|
SameLine( );
|
2017-11-23 14:43:15 +01:00
|
|
|
if ( ToolbarButton( ICON_FA_BACKWARD , BtSize , "Rewind to 00:00.000" ) ) {
|
2017-11-21 17:32:52 +01:00
|
|
|
sync.setTime( 0 );
|
|
|
|
}
|
2017-11-30 09:18:13 +01:00
|
|
|
SameLine( );
|
|
|
|
{
|
|
|
|
char tBuffer[ 12 ];
|
|
|
|
TimeToString_( tBuffer , sizeof( tBuffer ) , sync.time( ) );
|
|
|
|
Text( "%s" , tBuffer );
|
|
|
|
}
|
2017-11-30 09:31:55 +01:00
|
|
|
SameLine( );
|
|
|
|
if ( ToolbarButton( ICON_FA_CLOCK_O , BtSize , "Change duration and time units." ) ) {
|
|
|
|
UI::Main( ).pushDialog( NewOwned< T_ChangeDurationDialog_ >(
|
|
|
|
sync.durationUnits( ) , sync.durationUnitSize( ) ) );
|
|
|
|
}
|
2017-11-21 17:32:52 +01:00
|
|
|
|
2017-11-23 14:43:15 +01:00
|
|
|
ToolbarSeparator( );
|
2017-11-21 12:27:23 +01:00
|
|
|
|
2017-11-21 17:32:52 +01:00
|
|
|
Text( ICON_FA_SEARCH );
|
|
|
|
bool zoomHovered{ IsItemHovered( ) };
|
|
|
|
SameLine( );
|
|
|
|
PushItemWidth( 100 );
|
|
|
|
SliderFloat( "##zoom" , &zoomLevel , 0 , 1 , "%.2f" );
|
|
|
|
if ( zoomHovered || IsItemHovered( ) ) {
|
|
|
|
BeginTooltip( );
|
|
|
|
Text( "Zoom level" );
|
|
|
|
EndTooltip( );
|
|
|
|
}
|
|
|
|
PopItemWidth( );
|
|
|
|
|
|
|
|
SameLine( );
|
|
|
|
|
2017-11-23 14:43:15 +01:00
|
|
|
if ( ToolbarButton( followTime ? ICON_FA_LOCK : ICON_FA_UNLOCK , BtSize ,
|
2017-11-22 16:17:24 +01:00
|
|
|
followTime ? "Follows the current position.\nClick to untie."
|
2017-11-30 09:31:55 +01:00
|
|
|
: "Not tied to the current position.\nClick to follow." ,
|
|
|
|
true , followTime ) ) {
|
2017-11-21 17:32:52 +01:00
|
|
|
followTime = !followTime;
|
|
|
|
}
|
2017-11-20 17:01:09 +01:00
|
|
|
|
2017-11-23 14:43:15 +01:00
|
|
|
ToolbarSeparator( );
|
2017-11-21 22:23:34 +01:00
|
|
|
|
2017-11-30 09:31:55 +01:00
|
|
|
if ( ToolbarButton( ICON_FA_TAGS , BtSize , "Toggle track labels." , true , showLabels ) ) {
|
2017-11-30 09:18:13 +01:00
|
|
|
showLabels = !showLabels;
|
|
|
|
}
|
|
|
|
SameLine( );
|
2017-11-30 10:13:37 +01:00
|
|
|
if ( ToolbarButton( ICON_FA_LIST , BtSize ,
|
2017-11-30 09:18:13 +01:00
|
|
|
"Select inputs or sets thereof to display & edit." ) ) {
|
2017-11-25 23:37:07 +01:00
|
|
|
const bool displaySelector{ sub == SW_INPUT_SELECTOR
|
2017-11-21 22:23:34 +01:00
|
|
|
|| sub == SW_OVERRIDE_SELECTOR };
|
2017-11-30 09:35:47 +01:00
|
|
|
sub = displaySelector ? SW_NONE : tsSelectedTab;
|
2017-11-21 22:23:34 +01:00
|
|
|
curveFinder = T_String{};
|
|
|
|
}
|
2017-11-30 09:41:27 +01:00
|
|
|
SameLine( );
|
|
|
|
if ( ToolbarButton( ICON_FA_BAN , BtSize , "Clear selected tracks." ,
|
|
|
|
sTracks.size( ) != 0 ) ) {
|
2017-11-30 10:13:37 +01:00
|
|
|
clearSelectedTracks( );
|
|
|
|
}
|
|
|
|
SameLine( );
|
|
|
|
if ( ToolbarButton( ICON_FA_COG , BtSize , "Select tracks automatically." ) ) {
|
|
|
|
autoselectTracks( );
|
2017-11-30 09:41:27 +01:00
|
|
|
}
|
2017-11-30 10:23:53 +01:00
|
|
|
|
|
|
|
ToolbarSeparator( );
|
|
|
|
if ( ToolbarButton( ICON_FA_MINUS , BtSize , "Show track info." ,
|
|
|
|
selId && sub != SW_TRACK ) ) {
|
|
|
|
sub = SW_TRACK;
|
|
|
|
}
|
|
|
|
SameLine( );
|
|
|
|
if ( ToolbarButton( ICON_FA_ARROWS_H , BtSize , "Show segment info." ,
|
|
|
|
selId && selSegment && sub != SW_SEGMENT ) ) {
|
|
|
|
sub = SW_SEGMENT;
|
|
|
|
}
|
|
|
|
SameLine( );
|
|
|
|
if ( ToolbarButton( ICON_FA_CIRCLE , BtSize , "Show point info." ,
|
|
|
|
selId && selSegment && selPoint && sub != SW_POINT ) ) {
|
|
|
|
sub = SW_POINT;
|
|
|
|
}
|
2017-11-20 17:01:09 +01:00
|
|
|
}
|
|
|
|
|
2017-11-21 22:23:34 +01:00
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
2017-11-20 21:54:46 +01:00
|
|
|
void T_SyncViewImpl_::sequencerWidget( ) noexcept
|
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
|
|
|
|
const auto width{ CalcItemWidth( ) };
|
2017-11-27 13:54:06 +01:00
|
|
|
auto* const win{ GetCurrentWindow( ) };
|
2017-11-20 21:54:46 +01:00
|
|
|
const auto seqId{ win->GetID( "##sequencer" ) };
|
|
|
|
|
2017-11-27 13:54:06 +01:00
|
|
|
const ImVec2 cPos{ win->DC.CursorPos };
|
|
|
|
const ImVec2 ws{ GetWindowContentRegionMax( ) };
|
2017-11-20 21:54:46 +01:00
|
|
|
|
|
|
|
auto& style( ImGui::GetStyle( ) );
|
2017-11-27 13:54:06 +01:00
|
|
|
const float widgetWidth{ width - style.ScrollbarSize };
|
|
|
|
const ImRect bbHeader{
|
|
|
|
cPos ,
|
|
|
|
cPos + ImVec2( widgetWidth , SeqHeaderHeight )
|
|
|
|
};
|
|
|
|
const ImRect bbDisplay{
|
|
|
|
ImVec2{ cPos.x , bbHeader.Max.y } ,
|
|
|
|
ImVec2{ cPos.x + widgetWidth ,
|
|
|
|
GetWindowPos( ).y + ws.y
|
|
|
|
- style.FramePadding.y * 2
|
|
|
|
- style.ScrollbarSize }
|
|
|
|
};
|
2017-11-20 21:54:46 +01:00
|
|
|
const ImRect bbAll{ bbHeader.Min , bbDisplay.Max };
|
|
|
|
|
|
|
|
ItemSize( bbAll , style.FramePadding.y );
|
|
|
|
if ( !ItemAdd( bbAll , seqId ) ) {
|
|
|
|
return;
|
|
|
|
}
|
2017-11-21 15:48:34 +01:00
|
|
|
const bool hovered{ ItemHoverable( bbAll , seqId ) };
|
2017-11-27 13:54:06 +01:00
|
|
|
computeMetrics( std::max( 0.f , widgetWidth - 2.f ) );
|
2017-11-20 21:54:46 +01:00
|
|
|
|
2017-11-21 13:43:01 +01:00
|
|
|
BeginGroup( );
|
|
|
|
const auto hdrId{ win->GetID( "##header" ) };
|
|
|
|
const auto dspId{ win->GetID( "##display" ) };
|
2017-11-21 15:48:34 +01:00
|
|
|
PushID( seqId );
|
2017-11-27 13:54:06 +01:00
|
|
|
|
2017-11-21 13:43:01 +01:00
|
|
|
if ( ItemAdd( bbHeader , hdrId ) ) {
|
|
|
|
PushID( hdrId );
|
|
|
|
sequencerHeader( bbHeader );
|
|
|
|
PopID( );
|
|
|
|
}
|
|
|
|
if ( bbDisplay.Min.y < bbDisplay.Max.y && ItemAdd( bbDisplay , dspId ) ) {
|
|
|
|
PushID( dspId );
|
2017-11-25 22:02:17 +01:00
|
|
|
sequencerBody( bbDisplay );
|
2017-11-21 13:43:01 +01:00
|
|
|
PopID( );
|
|
|
|
}
|
2017-11-27 13:54:06 +01:00
|
|
|
|
|
|
|
// Vertical scrollbar - tracks
|
2017-11-30 09:18:13 +01:00
|
|
|
const float thMul{ ( showLabels ? ( TrackLabelHeight + TrackPadding ) : 0 )
|
|
|
|
+ TrackHeight + TrackPadding * 2.f };
|
|
|
|
const float totalHeight{ sTracks.size( ) * thMul + TrackPadding };
|
2017-11-27 13:54:06 +01:00
|
|
|
if ( vScroll > totalHeight - bbDisplay.GetHeight( ) ) {
|
|
|
|
vScroll = ImMax( 0.f , totalHeight - bbDisplay.GetHeight( ) );
|
|
|
|
}
|
|
|
|
UserScrollbar( false , totalHeight , bbDisplay.GetHeight( ) , &vScroll ,
|
|
|
|
bbHeader.GetTR( ) , bbAll.GetHeight( ) );
|
|
|
|
|
|
|
|
// Horizontal scrollbar - time
|
|
|
|
auto& sync( Common::Sync( ) );
|
|
|
|
float rsPos = startPixel;
|
|
|
|
if ( UserScrollbar( true , totalPixels , widgetWidth , &rsPos ,
|
|
|
|
bbDisplay.GetBL( ) , bbDisplay.GetWidth( ) ) ) {
|
|
|
|
startPos = sync.durationUnits( ) * rsPos / totalPixels;
|
|
|
|
checkLockMode = true;
|
|
|
|
}
|
|
|
|
|
2017-11-21 15:48:34 +01:00
|
|
|
PopID( );
|
2017-11-25 22:02:17 +01:00
|
|
|
EndGroup( );
|
2017-11-21 15:48:34 +01:00
|
|
|
|
|
|
|
auto& io( GetIO( ) );
|
|
|
|
if ( hovered && ( io.MouseDown[ 0 ] || io.MouseDown[ 1 ] ) ) {
|
|
|
|
SetActiveID( seqId , win );
|
|
|
|
FocusWindow( win );
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool active( GetCurrentContext( )->ActiveId == seqId );
|
2017-11-25 22:02:17 +01:00
|
|
|
const float mPixels{ io.MousePos.x - bbAll.Min.x + startPixel };
|
|
|
|
const float mTime{ mPixels * sync.duration( ) / totalPixels };
|
|
|
|
|
|
|
|
if ( !active ) {
|
|
|
|
if ( !hovered ) {
|
|
|
|
return;
|
2017-11-21 15:48:34 +01:00
|
|
|
}
|
2017-11-25 22:02:17 +01:00
|
|
|
if ( io.MouseWheel != 0 ) {
|
2017-11-27 18:42:08 +01:00
|
|
|
if ( io.KeyShift ) {
|
|
|
|
zoomLevel = ImSaturate( zoomLevel + .025 * io.MouseWheel );
|
|
|
|
} else {
|
2017-11-28 07:12:43 +01:00
|
|
|
vScroll = ImClamp( vScroll - 3.f * io.MouseWheel ,
|
|
|
|
0.f ,
|
|
|
|
ImMax( 0.f , totalHeight - bbDisplay.GetHeight( ) ) );
|
2017-11-27 18:42:08 +01:00
|
|
|
}
|
2017-11-21 15:48:34 +01:00
|
|
|
}
|
2017-11-25 22:02:17 +01:00
|
|
|
if ( bbDisplay.Contains( io.MousePos ) ) {
|
|
|
|
displayTooltips( mTime );
|
2017-11-21 15:48:34 +01:00
|
|
|
}
|
2017-11-28 07:12:43 +01:00
|
|
|
if ( ImGuiIO_MouseHorizWheel != 0 ) {
|
|
|
|
startPos = ImClamp(
|
|
|
|
sync.durationUnits( )
|
|
|
|
* ( startPixel - 20.f * ImGuiIO_MouseHorizWheel )
|
|
|
|
/ totalPixels ,
|
|
|
|
0.f , sync.durationUnits( ) );
|
|
|
|
checkLockMode = true;
|
|
|
|
}
|
2017-11-25 22:02:17 +01:00
|
|
|
return;
|
2017-11-21 15:48:34 +01:00
|
|
|
}
|
2017-11-21 13:43:01 +01:00
|
|
|
|
2017-11-30 12:10:47 +01:00
|
|
|
if ( dnd == E_DNDType::ZOOM ) {
|
|
|
|
if ( io.MouseDown[ 1 ] ) {
|
|
|
|
curZoomPixel = mPixels;
|
|
|
|
return;
|
|
|
|
}
|
2017-11-27 13:54:06 +01:00
|
|
|
checkLockMode = true;
|
2017-11-25 22:02:17 +01:00
|
|
|
const auto zMin{ std::min( firstZoomPixel , curZoomPixel ) } ,
|
|
|
|
zMax{ std::max( firstZoomPixel , curZoomPixel ) } ,
|
|
|
|
diff{ zMax - zMin };
|
|
|
|
if ( diff > 4 ) {
|
|
|
|
const float u( sync.durationUnits( ) );
|
2017-11-30 06:59:36 +01:00
|
|
|
startPos = ImClamp( zMin * u / totalPixels , 0.f , u );
|
2017-11-25 22:02:17 +01:00
|
|
|
if ( ( width - 2.f ) / u >= BarWidth ) {
|
|
|
|
zoomLevel = 0;
|
|
|
|
} else {
|
|
|
|
const auto length{ std::min( u , diff * u / totalPixels ) };
|
|
|
|
const auto ppu{ std::min( ( width - 2 ) / length , BarWidth ) };
|
|
|
|
zoomLevel = ( ppu - BarWidth ) / ( BarWidth - width / u ) + 1;
|
|
|
|
}
|
|
|
|
}
|
2017-11-30 12:36:22 +01:00
|
|
|
} else if ( dnd == E_DNDType::POINT
|
|
|
|
&& handlePointDrag( mPixels , io.MouseDown[ 0 ] , io.KeyShift ) ) {
|
2017-11-28 07:12:43 +01:00
|
|
|
return;
|
2017-11-30 12:10:47 +01:00
|
|
|
} else if ( dnd == E_DNDType::CLICK && ( io.MouseDown[ 0 ] || io.MouseDown[ 1 ] ) ) {
|
|
|
|
return;
|
|
|
|
} else if ( dnd == E_DNDType::TIME && io.MouseDown[ 0 ] ) {
|
|
|
|
sync.setTime( mTime );
|
2017-11-26 13:46:46 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-30 12:10:47 +01:00
|
|
|
if ( dnd != E_DNDType::NONE && !( io.MouseDown[ 0 ] || io.MouseDown[ 1 ] ) ) {
|
|
|
|
dnd = E_DNDType::NONE;
|
2017-11-25 22:02:17 +01:00
|
|
|
ClearActiveID( );
|
2017-11-25 23:37:07 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto mp{ getMousePos( ) };
|
|
|
|
if ( mp.type == E_MousePosType::NONE ) {
|
|
|
|
if ( io.MouseDown[ 0 ] ) {
|
|
|
|
sync.setTime( mTime );
|
2017-11-30 12:10:47 +01:00
|
|
|
dnd = E_DNDType::TIME;
|
|
|
|
} else if ( io.MouseDown[ 1 ] ) {
|
2017-11-28 07:12:43 +01:00
|
|
|
firstZoomPixel = mPixels;
|
2017-11-30 12:10:47 +01:00
|
|
|
dnd = E_DNDType::ZOOM;
|
2017-11-25 23:37:07 +01:00
|
|
|
curZoomPixel = mPixels;
|
|
|
|
|
|
|
|
}
|
2017-11-26 10:14:00 +01:00
|
|
|
} else if ( mp.type == E_MousePosType::TRACK ) {
|
|
|
|
auto const& dTrack{ dspTracks[ mp.index ] };
|
|
|
|
if ( io.MouseDown[ 0 ] || io.MouseDown[ 1 ] ) {
|
|
|
|
selId = dTrack.id;
|
2017-11-26 11:57:26 +01:00
|
|
|
selSegment = decltype( selSegment ){};
|
|
|
|
selPoint = decltype( selPoint ){};
|
2017-11-26 10:14:00 +01:00
|
|
|
sub = E_SubWindow::SW_TRACK;
|
2017-11-30 12:10:47 +01:00
|
|
|
dnd = E_DNDType::CLICK;
|
2017-11-26 10:14:00 +01:00
|
|
|
}
|
2017-11-25 23:37:07 +01:00
|
|
|
} else if ( mp.type == E_MousePosType::SEGMENT ) {
|
|
|
|
auto const& dSeg{ dspSegments[ mp.index ] };
|
|
|
|
auto const& dTrack{ dspTracks[ dSeg.track ] };
|
|
|
|
if ( io.MouseDown[ 0 ] || io.MouseDown[ 1 ] ) {
|
|
|
|
selId = dTrack.id;
|
|
|
|
selSegment = dSeg.seg;
|
2017-11-26 11:57:26 +01:00
|
|
|
selPoint = decltype( selPoint ){};
|
2017-11-25 23:37:07 +01:00
|
|
|
sub = E_SubWindow::SW_SEGMENT;
|
2017-11-30 12:10:47 +01:00
|
|
|
dnd = E_DNDType::CLICK;
|
2017-11-25 23:37:07 +01:00
|
|
|
}
|
2017-11-26 13:46:46 +01:00
|
|
|
} else if ( mp.type == E_MousePosType::POINT ) {
|
|
|
|
auto const& dPoint{ dspPoints[ mp.index ] };
|
|
|
|
auto const& dSeg{ dspSegments[ dPoint.seg ] };
|
|
|
|
auto const& dTrack{ dspTracks[ dSeg.track ] };
|
|
|
|
if ( io.MouseDown[ 0 ] || io.MouseDown[ 1 ] ) {
|
|
|
|
selId = dTrack.id;
|
|
|
|
selSegment = dSeg.seg;
|
|
|
|
selPoint = dPoint.index;
|
2017-11-30 12:36:22 +01:00
|
|
|
const bool pdnd{ io.MouseDown[ 0 ]
|
|
|
|
&& ( dPoint.index != 0 || dSeg.seg != 0 ) };
|
2017-11-30 12:10:47 +01:00
|
|
|
if ( pdnd ) {
|
2017-11-26 17:39:17 +01:00
|
|
|
assert( selUpdate == E_ChangeType::NONE );
|
2017-11-26 13:46:46 +01:00
|
|
|
selPointDnDStart = selPointDnDCur = mPixels;
|
2017-11-29 12:44:36 +01:00
|
|
|
if ( selId->isOverride ) {
|
|
|
|
auto const& names{ sync.getOverride( selId->id )->inputNames( ) };
|
|
|
|
const auto ni{ names.size( ) };
|
|
|
|
for ( auto i = 0u ; i < ni ; i ++ ) {
|
|
|
|
selUpdatingOriginals.add( *sync.getCurve( names[ i ] ) );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
selUpdatingOriginals.add( *sync.getCurve( selId->id ) );
|
|
|
|
}
|
2017-11-26 17:39:17 +01:00
|
|
|
selUpdate = E_ChangeType::POINT_DND;
|
2017-11-30 12:10:47 +01:00
|
|
|
dnd = E_DNDType::POINT;
|
|
|
|
} else {
|
|
|
|
dnd = E_DNDType::CLICK;
|
2017-11-26 13:46:46 +01:00
|
|
|
}
|
2017-11-26 17:39:17 +01:00
|
|
|
sub = E_SubWindow::SW_POINT;
|
2017-11-26 13:46:46 +01:00
|
|
|
}
|
2017-11-25 22:02:17 +01:00
|
|
|
}
|
2017-11-21 13:43:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void T_SyncViewImpl_::computeMetrics(
|
|
|
|
const float innerWidth ) noexcept
|
|
|
|
{
|
2017-11-23 23:05:14 +01:00
|
|
|
auto& sync( Common::Sync( ) );
|
2017-11-20 21:54:46 +01:00
|
|
|
const uint32_t units{ sync.durationUnits( ) };
|
2017-11-21 12:27:23 +01:00
|
|
|
zoomLevel = ImSaturate( zoomLevel );
|
|
|
|
const float zoom1Pixels{ std::max( units * BarWidth , innerWidth ) };
|
2017-11-21 15:48:34 +01:00
|
|
|
totalPixels = zoomLevel * ( zoom1Pixels - innerWidth ) + innerWidth;
|
2017-11-21 12:27:23 +01:00
|
|
|
const uint32_t totalBars{ [=](){
|
|
|
|
const float b{ std::max( std::min( totalPixels / BarWidth , float( units ) ) , 1.f ) };
|
|
|
|
const float mod{ fmod( b , 1.f ) };
|
|
|
|
return uint32_t( b + ( mod ? ( 1 - mod ) : 0 ) );
|
|
|
|
}() };
|
|
|
|
const float unitsPerBar{ float( units ) / totalBars };
|
2017-11-21 13:43:01 +01:00
|
|
|
barWidth = totalPixels / totalBars;
|
2017-11-21 12:27:23 +01:00
|
|
|
const float absCursorPos{ sync.time( ) * totalPixels / sync.duration( ) };
|
|
|
|
if ( followTime ) {
|
|
|
|
const float dispUnits{ innerWidth * units / totalPixels };
|
|
|
|
const float uSize{ sync.durationUnitSize( ) };
|
|
|
|
const float endPos{ std::min( startPos + dispUnits , float( units ) ) };
|
|
|
|
startPos = endPos - dispUnits;
|
|
|
|
const float spp{ startPos * totalPixels / units };
|
|
|
|
const float epp{ endPos * totalPixels / units };
|
|
|
|
if ( absCursorPos < spp || absCursorPos > epp ) {
|
2017-11-27 13:54:06 +01:00
|
|
|
if ( checkLockMode ) {
|
2017-11-21 15:48:34 +01:00
|
|
|
followTime = false;
|
|
|
|
} else {
|
|
|
|
startPos = std::max( 0.f , sync.time( ) / uSize - unitsPerBar * .5f );
|
|
|
|
}
|
2017-11-21 12:27:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
const float unadjustedStartPixel{ totalPixels * startPos / units };
|
|
|
|
if ( unadjustedStartPixel + innerWidth > totalPixels ) {
|
2017-11-28 07:33:57 +01:00
|
|
|
startPos = std::max( 0.f , units * ( totalPixels - innerWidth ) / totalPixels );
|
2017-11-21 12:27:23 +01:00
|
|
|
}
|
2017-11-21 15:48:34 +01:00
|
|
|
startPixel = totalPixels * startPos / units;
|
2017-11-21 13:43:01 +01:00
|
|
|
startBar = [=](){
|
2017-11-21 12:27:23 +01:00
|
|
|
const float b{ startPixel * totalBars / totalPixels };
|
|
|
|
const float mod{ fmod( b , 1.f ) };
|
|
|
|
return uint32_t( std::max( 0 , int32_t( b - ( mod ? mod : 1 ) ) ) );
|
2017-11-21 13:43:01 +01:00
|
|
|
}();
|
|
|
|
startBarPos = startBar * barWidth - startPixel;
|
|
|
|
cursorPos = absCursorPos - startPixel;
|
|
|
|
timePerBar = unitsPerBar * sync.durationUnitSize( );
|
2017-11-21 12:27:23 +01:00
|
|
|
assert( startBarPos <= 0 );
|
|
|
|
assert( totalPixels >= innerWidth );
|
2017-11-21 15:48:34 +01:00
|
|
|
|
2017-11-27 13:54:06 +01:00
|
|
|
checkLockMode = false;
|
2017-11-20 21:54:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void T_SyncViewImpl_::sequencerHeader(
|
|
|
|
ImRect const& bb ) noexcept
|
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
auto* const dl( GetWindowDrawList( ) );
|
2017-11-21 13:43:01 +01:00
|
|
|
const ImRect inner{ bb.Min + ImVec2{ 1 , 1 } , bb.Max - ImVec2{ 1 , 1 } };
|
2017-11-20 21:54:46 +01:00
|
|
|
|
2017-11-21 13:43:01 +01:00
|
|
|
dl->AddRectFilled( inner.Min , inner.Max , ColHeader );
|
2017-11-20 21:54:46 +01:00
|
|
|
dl->AddRect( bb.Min , bb.Max , ColFrame );
|
|
|
|
|
2017-11-21 13:43:01 +01:00
|
|
|
if ( cursorPos >= 0 && cursorPos <= inner.GetWidth( ) ) {
|
|
|
|
auto* const dl( GetWindowDrawList( ) );
|
|
|
|
dl->AddLine( inner.Min + ImVec2{ cursorPos , 0 } ,
|
|
|
|
ImVec2{ inner.Min.x + cursorPos , inner.Max.y - 1 } ,
|
|
|
|
GetColorU32( ImVec4{ 1 , 1 , 1 , .5 } ) );
|
|
|
|
}
|
|
|
|
|
2017-11-23 22:51:50 +01:00
|
|
|
PushFont( UI::Main( ).smallFont( ) );
|
2017-11-21 13:43:01 +01:00
|
|
|
PushStyleColor( ImGuiCol_Text , ColHeaderText );
|
|
|
|
auto pos{ startBarPos };
|
|
|
|
auto bar{ startBar };
|
|
|
|
const auto max{ bb.GetWidth( ) + barWidth - 2.f };
|
|
|
|
char buffer[ 12 ];
|
|
|
|
while ( pos < max ) {
|
|
|
|
const ImVec2 taStart{ inner.Min + ImVec2{ pos - barWidth * .5f , 0 } };
|
|
|
|
const ImVec2 taEnd{ taStart + ImVec2{ barWidth , inner.Max.y - inner.Min.y } };
|
|
|
|
|
|
|
|
const float time{ bar * timePerBar };
|
2017-11-25 22:02:17 +01:00
|
|
|
TimeToString_( buffer , sizeof( buffer ) , time );
|
2017-11-21 13:43:01 +01:00
|
|
|
RenderTextClipped( taStart , taEnd , buffer , nullptr , nullptr ,
|
2017-11-25 09:31:08 +01:00
|
|
|
ImVec2{ .5f , .05f + ( ( bar % 2 ) ? .9f : 0.f ) } , &inner );
|
2017-11-21 13:43:01 +01:00
|
|
|
pos += barWidth;
|
|
|
|
bar ++;
|
|
|
|
}
|
2017-11-20 21:54:46 +01:00
|
|
|
PopStyleColor( );
|
|
|
|
PopFont( );
|
|
|
|
}
|
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
void T_SyncViewImpl_::sequencerBody(
|
2017-11-21 12:27:23 +01:00
|
|
|
ImRect const& bb ) noexcept
|
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
auto* const dl( GetWindowDrawList( ) );
|
2017-11-21 13:43:01 +01:00
|
|
|
const ImRect inner{ bb.Min + ImVec2{ 1 , 1 } , bb.Max - ImVec2{ 1 , 1 } };
|
2017-11-21 12:27:23 +01:00
|
|
|
|
2017-11-21 13:43:01 +01:00
|
|
|
dl->AddRectFilled( inner.Min , inner.Max , ColMain );
|
|
|
|
dl->AddRect( bb.Min , bb.Max , ColFrame );
|
2017-11-30 12:10:47 +01:00
|
|
|
if ( dnd == E_DNDType::ZOOM ) {
|
2017-11-21 15:48:34 +01:00
|
|
|
const float z0{ ImClamp( firstZoomPixel - startPixel + inner.Min.x , inner.Min.x , inner.Max.x ) } ,
|
|
|
|
z1{ ImClamp( curZoomPixel - startPixel + bb.Min.x , inner.Min.x , inner.Max.x ) };
|
|
|
|
const float zMin{ std::min( z0 , z1 ) } , zMax{ std::max( z0 , z1 ) };
|
|
|
|
if ( zMin != zMax ) {
|
|
|
|
dl->AddRectFilled( ImVec2{ zMin , inner.Min.y } ,
|
|
|
|
ImVec2{ zMax , inner.Max.y } ,
|
|
|
|
ColSelection );
|
|
|
|
}
|
|
|
|
}
|
2017-11-21 13:43:01 +01:00
|
|
|
|
|
|
|
auto pos{ startBarPos };
|
|
|
|
auto bar{ startBar };
|
|
|
|
const auto max{ bb.GetWidth( ) + barWidth - 2.f };
|
|
|
|
while ( pos < max ) {
|
|
|
|
if ( pos >= 0 && pos < inner.GetWidth( ) ) {
|
|
|
|
dl->AddLine( bb.Min + ImVec2{ pos , 0 } ,
|
|
|
|
ImVec2{ inner.Min.x + pos , inner.Max.y } ,
|
|
|
|
0xff000000 );
|
|
|
|
}
|
|
|
|
pos += barWidth;
|
|
|
|
bar ++;
|
|
|
|
}
|
|
|
|
|
2017-11-22 20:28:12 +01:00
|
|
|
// Display the curve / override controls
|
2017-11-25 23:37:07 +01:00
|
|
|
dspTracks.clear( );
|
|
|
|
dspSegments.clear( );
|
|
|
|
dspPoints.clear( );
|
2017-11-28 18:57:27 +01:00
|
|
|
if ( sTracks.size( ) != 0 ) {
|
2017-11-30 09:18:13 +01:00
|
|
|
sequencerTracks( inner );
|
2017-11-22 20:28:12 +01:00
|
|
|
}
|
|
|
|
|
2017-11-21 13:43:01 +01:00
|
|
|
if ( cursorPos >= 0 && cursorPos <= inner.GetWidth( ) ) {
|
|
|
|
auto* const dl( GetWindowDrawList( ) );
|
|
|
|
dl->AddLine( inner.Min + ImVec2{ cursorPos , -1 } ,
|
|
|
|
ImVec2{ inner.Min.x + cursorPos , inner.Max.y - 1 } ,
|
|
|
|
0xffffffff );
|
|
|
|
}
|
2017-11-21 12:27:23 +01:00
|
|
|
}
|
2017-11-28 22:10:10 +01:00
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
void T_SyncViewImpl_::sequencerTracks(
|
2017-11-25 16:30:46 +01:00
|
|
|
ImRect const& container ) noexcept
|
2017-11-22 20:28:12 +01:00
|
|
|
{
|
2017-11-30 09:18:13 +01:00
|
|
|
ImRect bb{ container };
|
|
|
|
bb.Min.y += TrackPadding - vScroll;
|
|
|
|
bb.Max.y = bb.Min.y + TrackHeight;
|
|
|
|
|
2017-11-28 18:57:27 +01:00
|
|
|
float hue{ 0.12f };
|
2017-11-23 23:05:14 +01:00
|
|
|
auto& sync{ Common::Sync( ) };
|
2017-11-28 18:57:27 +01:00
|
|
|
|
|
|
|
const auto nc{ sTracks.size( ) };
|
2017-11-22 20:28:12 +01:00
|
|
|
for ( auto i = 0u ; i < nc ; i ++ ) {
|
2017-11-28 22:10:10 +01:00
|
|
|
auto const& id{ sTracks[ i ] };
|
|
|
|
auto* const curve{ sync.getCurve(
|
|
|
|
sTracks[ i ].isOverride
|
|
|
|
? sync.getOverride( id.id )->inputNames( )[ 0 ]
|
|
|
|
: id.id ) };
|
2017-11-30 09:18:13 +01:00
|
|
|
|
|
|
|
if ( showLabels ) {
|
|
|
|
using namespace ImGui;
|
|
|
|
stringBuffer.clear( );
|
|
|
|
if ( id.isOverride ) {
|
|
|
|
stringBuffer << "[O] "
|
2017-11-30 11:25:20 +01:00
|
|
|
<< sync.getOverride( id.id )->fullTitle( );
|
2017-11-30 09:18:13 +01:00
|
|
|
} else {
|
|
|
|
stringBuffer << "[I] " << id.id;
|
|
|
|
}
|
|
|
|
PushStyleColor( ImGuiCol_Text ,
|
|
|
|
ColorHSVAToU32( hue , .05f , 1.f , 1.f ) );
|
|
|
|
char const* const tStart{ stringBuffer.data( ) };
|
|
|
|
char const* const taEnd{ tStart + stringBuffer.size( ) };
|
|
|
|
const ImVec2 ts{ CalcTextSize( tStart , taEnd ) };
|
|
|
|
RenderTextClipped( bb.Min + ImVec2{ 20 , 0 } ,
|
|
|
|
bb.Min + ImVec2{ 20 + ts.x , TrackLabelHeight } ,
|
|
|
|
tStart , taEnd , &ts , ImVec2{ 0.f , .5f } ,
|
|
|
|
&container );
|
|
|
|
PopStyleColor( );
|
|
|
|
bb.Min.y += TrackLabelHeight + TrackPadding;
|
|
|
|
bb.Max.y += TrackLabelHeight + TrackPadding;
|
|
|
|
}
|
|
|
|
|
|
|
|
sequencerTrack( hue , bb , container , id , curve );
|
|
|
|
bb.Min.y += TrackHeight + 2 * TrackPadding;
|
|
|
|
bb.Max.y += TrackHeight + 2 * TrackPadding;
|
2017-11-25 16:30:46 +01:00
|
|
|
hue = fmodf( hue + .17f , 1.f );
|
2017-11-22 20:28:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
void T_SyncViewImpl_::sequencerTrack(
|
2017-11-25 16:30:46 +01:00
|
|
|
float& hue ,
|
|
|
|
ImRect const& bb ,
|
|
|
|
ImRect const& container ,
|
2017-11-29 07:20:22 +01:00
|
|
|
T_SyncTrackId const& id ,
|
2017-11-25 16:30:46 +01:00
|
|
|
T_SyncCurve const* curve ) noexcept
|
2017-11-22 20:28:12 +01:00
|
|
|
{
|
2017-11-25 22:02:17 +01:00
|
|
|
// Don't display if the track is fully hidden
|
2017-11-25 16:30:46 +01:00
|
|
|
if ( !container.Overlaps( bb ) ) {
|
2017-11-25 22:02:17 +01:00
|
|
|
return;
|
2017-11-25 16:30:46 +01:00
|
|
|
}
|
2017-11-30 07:12:58 +01:00
|
|
|
const ImRect bar{
|
|
|
|
ImVec2{ ImFloor( bb.Min.x ) ,
|
|
|
|
ImFloor( ImMax( container.Min.y , bb.Min.y ) ) } ,
|
|
|
|
ImVec2{ ImFloor( bb.Max.x ) - 1 ,
|
|
|
|
ImFloor( ImMin( container.Max.y , bb.Max.y ) ) }
|
|
|
|
};
|
2017-11-25 22:02:17 +01:00
|
|
|
|
|
|
|
// Add track display record
|
|
|
|
const auto dTrackIdx{ dspTracks.size( ) };
|
|
|
|
auto& dTrack{ dspTracks.addNew( ) };
|
2017-11-28 22:10:10 +01:00
|
|
|
dTrack.id = id;
|
2017-11-25 22:02:17 +01:00
|
|
|
dTrack.dispSegs = 0;
|
|
|
|
dTrack.firstSeg = dspSegments.size( );
|
|
|
|
dTrack.area = bb;
|
2017-11-25 16:30:46 +01:00
|
|
|
|
|
|
|
// Compute colors
|
2017-11-25 22:02:17 +01:00
|
|
|
using namespace ImGui;
|
2017-11-30 07:12:58 +01:00
|
|
|
auto const& mp{ GetIO( ).MousePos };
|
2017-11-28 22:10:10 +01:00
|
|
|
const bool sCurve{ selId && id == *selId };
|
2017-11-30 09:18:13 +01:00
|
|
|
const bool barHovered{ bar.Contains( mp ) };
|
|
|
|
const float scv{ sCurve ? 1.f : ( barHovered ? .85f : .7f ) };
|
2017-11-26 11:57:26 +01:00
|
|
|
const auto bgColor{ ColorHSVAToU32( hue , .25f , scv , .25f ) } ,
|
|
|
|
borderColor{ ColorHSVAToU32( hue , .5f , scv , 1.f ) };
|
|
|
|
const uint32_t segColors[] = {
|
|
|
|
ColorHSVAToU32( hue - .03f , .4f , .7f , 1.f ) ,
|
|
|
|
ColorHSVAToU32( hue + .03f , .4f , .7f , 1.f ) ,
|
2017-11-30 07:12:58 +01:00
|
|
|
ColorHSVAToU32( hue - .03f , .4f , .85f , 1.f ) ,
|
|
|
|
ColorHSVAToU32( hue + .03f , .4f , .85f , 1.f ) ,
|
2017-11-25 16:30:46 +01:00
|
|
|
ColorHSVAToU32( hue - .03f , .4f , 1.f , 1.f ) ,
|
|
|
|
ColorHSVAToU32( hue + .03f , .4f , 1.f , 1.f ) ,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Draw the bar itself
|
2017-11-25 22:02:17 +01:00
|
|
|
auto* const dl{ GetWindowDrawList( ) };
|
2017-11-25 16:30:46 +01:00
|
|
|
dl->AddRectFilled( bar.Min , bar.Max , bgColor );
|
|
|
|
if ( container.Contains( bb.GetTL( ) ) ) {
|
|
|
|
dl->AddLine( bar.GetTL( ) , bar.GetTR( ) , borderColor );
|
|
|
|
}
|
|
|
|
if ( container.Contains( bb.GetBL( ) ) ) {
|
|
|
|
dl->AddLine( bar.GetBL( ) , bar.GetBR( ) , borderColor );
|
|
|
|
}
|
|
|
|
// Left only has a border if this is the start
|
|
|
|
if ( startPos == 0.f ) {
|
|
|
|
dl->AddLine( bar.GetTL( ) , bar.GetBL( ) , borderColor );
|
|
|
|
}
|
|
|
|
// Right has a border if the end is being displayed.
|
|
|
|
if ( startPixel + container.GetWidth( ) >= totalPixels ) {
|
|
|
|
dl->AddLine( bar.GetTR( ) , bar.GetBR( ) , borderColor );
|
|
|
|
}
|
|
|
|
dl->PushClipRect( bar.Min , bar.Max );
|
|
|
|
|
|
|
|
// If there's a curve, go through all segments
|
|
|
|
const auto units{ Common::Sync( ).durationUnits( ) };
|
2017-11-29 12:44:36 +01:00
|
|
|
const bool useCopy{ sCurve && curve && !selUpdatingCopies.empty( ) };
|
2017-11-26 13:46:46 +01:00
|
|
|
const auto nSeg{ curve
|
2017-11-29 12:44:36 +01:00
|
|
|
? ( useCopy ? selUpdatingCopies[ 0 ] : *curve ).segments.size( )
|
2017-11-26 13:46:46 +01:00
|
|
|
: 0u };
|
2017-11-25 16:30:46 +01:00
|
|
|
uint32_t segStart{ 0 };
|
|
|
|
for ( auto i = 0u ; i < nSeg ; i ++ ) {
|
2017-11-29 12:44:36 +01:00
|
|
|
auto const& seg{ ( useCopy ? selUpdatingCopies[ 0 ] : *curve ).segments[ i ] };
|
2017-11-25 16:30:46 +01:00
|
|
|
const auto segDur{ [&](){
|
|
|
|
auto t{ 0u };
|
|
|
|
for ( auto d : seg.durations ) {
|
|
|
|
t += d;
|
|
|
|
}
|
|
|
|
return t;
|
|
|
|
}() };
|
|
|
|
const float xStart{ ImFloor( container.Min.x + ( segStart - startPos ) * totalPixels / units ) };
|
|
|
|
const float xEnd{ xStart + ImFloor( segDur * totalPixels / units ) };
|
|
|
|
const ImRect segFull{
|
|
|
|
ImVec2{ xStart , bar.Min.y + 1 } ,
|
|
|
|
ImVec2{ xEnd , bar.Max.y }
|
|
|
|
};
|
|
|
|
segStart += segDur;
|
|
|
|
if ( !segFull.Overlaps( bar ) ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
// Add segment to displayed list
|
2017-11-26 11:57:26 +01:00
|
|
|
const bool sSegment{ sCurve && selSegment && *selSegment == i };
|
2017-11-30 09:18:13 +01:00
|
|
|
const bool segHovered{ segFull.Contains( mp ) };
|
2017-11-30 07:12:58 +01:00
|
|
|
const auto color{ segColors[ i % 2 + ( sSegment ? 4
|
2017-11-30 09:18:13 +01:00
|
|
|
: ( segHovered ? 2 : 0 ) ) ] };
|
2017-11-25 22:02:17 +01:00
|
|
|
auto dSegIdx{ dspSegments.size( ) };
|
|
|
|
auto& dSeg{ dspSegments.addNew( ) };
|
|
|
|
dSeg.area = segFull;
|
|
|
|
dSeg.track = dTrackIdx;
|
|
|
|
dSeg.seg = i;
|
|
|
|
dSeg.dispPoints = 0;
|
|
|
|
dSeg.firstPoint = dspPoints.size( );
|
|
|
|
dTrack.dispSegs ++;
|
|
|
|
|
|
|
|
// Draw segment
|
2017-11-25 16:30:46 +01:00
|
|
|
const ImRect segBar{
|
|
|
|
ImVec2{ ImMax( bar.Min.x , segFull.Min.x ) , segFull.Min.y } ,
|
|
|
|
ImVec2{ ImMin( bar.Max.x , segFull.Max.x ) , segFull.Max.y }
|
|
|
|
};
|
|
|
|
dl->AddRectFilled( segBar.Min , segBar.Max , color );
|
|
|
|
dl->PushClipRect( segBar.Min , segBar.Max );
|
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
// Handle points
|
2017-11-25 16:30:46 +01:00
|
|
|
const auto nd{ seg.durations.size( ) };
|
2017-11-25 22:02:17 +01:00
|
|
|
const auto ym{ bb.Min.y + PointRadius + 1 };
|
2017-11-25 16:30:46 +01:00
|
|
|
auto cDur{ 0 };
|
|
|
|
for ( auto j = 0u ; j < nd + 1 ; j ++ ) {
|
|
|
|
const ImVec2 ctr{
|
|
|
|
std::roundf( xStart + cDur * totalPixels / units ) ,
|
|
|
|
ym
|
|
|
|
};
|
2017-11-26 13:46:46 +01:00
|
|
|
const bool sPoint{ sSegment && selPoint && *selPoint == j };
|
2017-11-30 09:18:13 +01:00
|
|
|
const bool hpt{ !sPoint && segHovered
|
2017-11-30 07:12:58 +01:00
|
|
|
&& ImLengthSqr( mp - ctr ) <= 2.25 * PointRadiusSqr };
|
2017-11-26 13:46:46 +01:00
|
|
|
dl->AddCircleFilled( ctr , PointRadius ,
|
2017-11-30 07:12:58 +01:00
|
|
|
sPoint ? ColPointSelected
|
|
|
|
: ( hpt ? ColPointHovered : ColPointNormal ) );
|
2017-11-25 16:30:46 +01:00
|
|
|
cDur += j < nd ? seg.durations[ j ] : 0;
|
2017-11-25 22:02:17 +01:00
|
|
|
|
|
|
|
// Add point record
|
|
|
|
auto& dPoint{ dspPoints.addNew( ) };
|
|
|
|
dPoint.center = ctr;
|
|
|
|
dPoint.index = j;
|
|
|
|
dPoint.mode =
|
|
|
|
j == 0 ? T_TrackPointDisplay::START : (
|
|
|
|
j == nd ? T_TrackPointDisplay::END :
|
|
|
|
T_TrackPointDisplay::MIDDLE );
|
|
|
|
dPoint.seg = dSegIdx;
|
|
|
|
dSeg.dispPoints ++;
|
2017-11-25 16:30:46 +01:00
|
|
|
}
|
|
|
|
dl->PopClipRect( );
|
2017-11-25 22:02:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
dl->PopClipRect( );
|
|
|
|
}
|
2017-11-25 16:30:46 +01:00
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
void T_SyncViewImpl_::displayTooltips(
|
|
|
|
const float time ) noexcept
|
|
|
|
{
|
|
|
|
auto mp{ getMousePos( ) };
|
|
|
|
if ( mp.type == E_MousePosType::NONE ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Track / segment / point from mouse info
|
|
|
|
auto const& track( [&](){
|
|
|
|
if ( mp.type == E_MousePosType::POINT ) {
|
|
|
|
return dspTracks[ dspSegments[
|
|
|
|
dspPoints[ mp.index ].seg ].track ];
|
|
|
|
}
|
|
|
|
if ( mp.type == E_MousePosType::SEGMENT ) {
|
|
|
|
return dspTracks[ dspSegments[ mp.index ].track ];
|
|
|
|
}
|
|
|
|
return dspTracks[ mp.index ];
|
|
|
|
}() );
|
|
|
|
auto const* const seg( [&]() -> T_TrackSegDisplay const* {
|
|
|
|
if ( mp.type == E_MousePosType::TRACK ) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
if ( mp.type == E_MousePosType::SEGMENT ) {
|
|
|
|
return &dspSegments[ mp.index ];
|
|
|
|
}
|
|
|
|
return &dspSegments[ dspPoints[ mp.index ].seg ];
|
|
|
|
}() );
|
|
|
|
auto const* const point( [&]() -> T_TrackPointDisplay const* {
|
|
|
|
if ( mp.type != E_MousePosType::POINT ) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return &dspPoints[ mp.index ];
|
|
|
|
}() );
|
|
|
|
|
|
|
|
// Curve from track
|
2017-11-27 09:12:51 +01:00
|
|
|
auto& sync{ Common::Sync( ) };
|
2017-11-28 22:10:10 +01:00
|
|
|
auto const* const ovr{ track.id.isOverride
|
|
|
|
? sync.getOverride( track.id.id )
|
|
|
|
: nullptr
|
|
|
|
};
|
|
|
|
auto const* const curve{ sync.getCurve(
|
|
|
|
track.id.isOverride
|
|
|
|
? ovr->inputNames( )[ 0 ]
|
|
|
|
: track.id.id ) };
|
2017-11-25 22:02:17 +01:00
|
|
|
assert( mp.type == E_MousePosType::TRACK || curve != nullptr );
|
|
|
|
|
|
|
|
// Time offset
|
|
|
|
const float dTime( [&](){
|
|
|
|
if ( point ) {
|
|
|
|
auto tDur{ .0f };
|
|
|
|
for ( auto i = 0u ; i <= seg->seg ; i ++ ) {
|
|
|
|
auto const& s{ curve->segments[ i ] };
|
|
|
|
auto const nd{ i == seg->seg
|
|
|
|
? point->index
|
|
|
|
: s.durations.size( ) };
|
|
|
|
for ( auto j = 0u ; j < nd ; j ++ ) {
|
|
|
|
tDur += s.durations[ j ];
|
|
|
|
}
|
|
|
|
}
|
2017-11-27 09:12:51 +01:00
|
|
|
return tDur * sync.durationUnitSize( );
|
2017-11-25 22:02:17 +01:00
|
|
|
}
|
|
|
|
return time;
|
|
|
|
}() );
|
2017-11-27 09:12:51 +01:00
|
|
|
const float dUTime{ dTime / sync.durationUnitSize( ) };
|
2017-11-25 22:02:17 +01:00
|
|
|
char buffer[ 12 ];
|
|
|
|
TimeToString_( buffer , sizeof( buffer ) , dTime );
|
|
|
|
|
2017-11-28 22:10:10 +01:00
|
|
|
stringBuffer.clear( )
|
|
|
|
<< ( track.id.isOverride ? ovr->title( ) : track.id.id )
|
|
|
|
<< ' '
|
|
|
|
<< ( track.id.isOverride ? "(override)" : "(input)" )
|
|
|
|
<< '\n';
|
2017-11-25 22:02:17 +01:00
|
|
|
if ( mp.type == E_MousePosType::TRACK ) {
|
|
|
|
stringBuffer << "No segment";
|
2017-11-29 10:23:24 +01:00
|
|
|
} else if ( ovr ) {
|
|
|
|
if ( mp.type == E_MousePosType::SEGMENT ) {
|
|
|
|
int cType{ -1 };
|
|
|
|
for ( auto i = 0u ; i < ovr->inputNames( ).size( ) ; i ++ ) {
|
|
|
|
auto const& iName{ ovr->inputNames( )[ i ] };
|
|
|
|
auto const* const c{ sync.getCurve( iName ) };
|
|
|
|
if ( i == 0 ) {
|
|
|
|
cType = c->segments[ seg->seg ].type;
|
|
|
|
} else if ( cType != c->segments[ seg->seg ].type ) {
|
|
|
|
cType = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( cType == -1 ) {
|
|
|
|
stringBuffer << "Various segment types";
|
|
|
|
} else {
|
|
|
|
stringBuffer << "Segment type: "
|
|
|
|
<< T_SyncSegment::E_SegmentType( cType );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
stringBuffer << "Point index " << point->index;
|
|
|
|
}
|
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
} else {
|
|
|
|
auto const& s{ curve->segments[ seg->seg ] };
|
|
|
|
if ( mp.type == E_MousePosType::SEGMENT ) {
|
|
|
|
stringBuffer << "Segment type: " << s.type;
|
|
|
|
} else {
|
|
|
|
stringBuffer << "On " << s.type << " segment, index " << point->index;
|
2017-11-25 16:30:46 +01:00
|
|
|
}
|
|
|
|
}
|
2017-11-28 22:10:10 +01:00
|
|
|
stringBuffer << "\nTime: " << buffer << '\n';
|
|
|
|
if ( track.id.isOverride ) {
|
2017-11-29 10:23:24 +01:00
|
|
|
stringBuffer << "\nInput values:";
|
2017-11-28 22:10:10 +01:00
|
|
|
for ( auto i = 0u ; i < ovr->inputNames( ).size( ) ; i ++ ) {
|
|
|
|
auto const& iName{ ovr->inputNames( )[ i ] };
|
|
|
|
auto const* const c{ sync.getCurve( iName ) };
|
|
|
|
const float value{ point
|
|
|
|
? c->segments[ seg->seg ].values[ point->index ]
|
|
|
|
: ( c ? c->computeValue( dUTime )
|
|
|
|
: sync.inputs( )[ ovr->inputPositions( )[ i ] ] ) };
|
|
|
|
stringBuffer << "\n - " << iName << ": " << value;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
const float value{ point
|
|
|
|
? curve->segments[ seg->seg ].values[ point->index ]
|
|
|
|
: ( curve ? curve->computeValue( dUTime )
|
|
|
|
: sync.inputs( )[ sync.inputPos( track.id.id ) ] ) };
|
|
|
|
stringBuffer << "Value: " << value;
|
|
|
|
}
|
2017-11-25 16:30:46 +01:00
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
using namespace ImGui;
|
|
|
|
stringBuffer << '\0';
|
|
|
|
BeginTooltip( );
|
|
|
|
Text( "%s" , stringBuffer.data( ) );
|
|
|
|
EndTooltip( );
|
|
|
|
}
|
|
|
|
|
2017-11-26 13:46:46 +01:00
|
|
|
bool T_SyncViewImpl_::handlePointDrag(
|
|
|
|
const float mPixels ,
|
2017-11-30 12:36:22 +01:00
|
|
|
bool mouseDown ,
|
|
|
|
bool shiftPressed ) noexcept
|
2017-11-26 13:46:46 +01:00
|
|
|
{
|
|
|
|
auto& sync( Common::Sync( ) );
|
|
|
|
|
|
|
|
selPointDnDCur = mPixels;
|
|
|
|
const float diff{ selPointDnDCur - selPointDnDStart };
|
|
|
|
const int32_t diffUnits{ int32_t( round( diff * sync.durationUnits( ) / totalPixels ) ) };
|
|
|
|
const bool moved{ fabsf( diff ) >= 2 && abs( diffUnits ) > 0 };
|
2017-11-29 12:44:36 +01:00
|
|
|
const auto ni{ selUpdatingCopies.size( ) };
|
2017-11-30 12:36:22 +01:00
|
|
|
const auto sid{ *selSegment };
|
|
|
|
const auto pid{ *selPoint };
|
|
|
|
assert( pid > 0 || sid > 0 );
|
|
|
|
const bool isLastPoint{ [&](){
|
|
|
|
auto const& s{ selUpdatingOriginals[ 0 ].segments };
|
|
|
|
return sid == s.size( ) - 1 && pid == s[ sid ].durations.size( );
|
|
|
|
}( ) };
|
|
|
|
|
|
|
|
if ( moved && ( shiftPressed || isLastPoint ) ) {
|
|
|
|
// Increase/decrease duration
|
|
|
|
selUpdatingCopies = selUpdatingOriginals;
|
|
|
|
for ( auto i = 0u ; i < ni ; i ++ ) {
|
|
|
|
auto& copy{ selUpdatingCopies[ i ] };
|
|
|
|
auto& seg{ copy.segments[ sid ] };
|
|
|
|
auto& d{ pid == 0
|
|
|
|
? copy.segments[ sid - 1 ].durations.last( )
|
|
|
|
: seg.durations[ pid - 1 ] };
|
|
|
|
d = std::max( 1 , diffUnits + int32_t( d ) );
|
|
|
|
sync.setCurve( copy );
|
|
|
|
}
|
2017-11-26 13:46:46 +01:00
|
|
|
|
2017-11-30 12:36:22 +01:00
|
|
|
} else if ( moved ) {
|
|
|
|
// Move the point but keep the sum of before/after durations
|
|
|
|
// a constant
|
2017-11-29 12:44:36 +01:00
|
|
|
selUpdatingCopies = selUpdatingOriginals;
|
|
|
|
for ( auto i = 0u ; i < ni ; i ++ ) {
|
|
|
|
auto& copy{ selUpdatingCopies[ i ] };
|
2017-11-30 12:36:22 +01:00
|
|
|
auto& seg{ copy.segments[ sid ] };
|
|
|
|
|
|
|
|
auto& d0{ pid == 0
|
|
|
|
? copy.segments[ sid - 1 ].durations.last( )
|
|
|
|
: seg.durations[ pid - 1 ] };
|
|
|
|
auto& d1{ pid == seg.durations.size( )
|
|
|
|
? copy.segments[ sid + 1 ].durations[ 0 ]
|
|
|
|
: seg.durations[ pid ]
|
|
|
|
};
|
|
|
|
|
|
|
|
const int32_t mmNeg( 1 - d0 ) , mmPos( d1 - 1 );
|
|
|
|
const int32_t diff{ diffUnits < mmNeg ? mmNeg
|
|
|
|
: ( diffUnits > mmPos ? mmPos : diffUnits ) };
|
|
|
|
d0 += diff;
|
|
|
|
d1 -= diff;
|
2017-11-29 12:44:36 +01:00
|
|
|
sync.setCurve( copy );
|
|
|
|
}
|
2017-11-30 12:36:22 +01:00
|
|
|
|
2017-11-26 13:46:46 +01:00
|
|
|
} else {
|
2017-11-29 12:44:36 +01:00
|
|
|
selUpdatingCopies.clear( );
|
|
|
|
for ( auto i = 0u ; i < ni ; i ++ ) {
|
|
|
|
sync.setCurve( selUpdatingOriginals[ i ] );
|
|
|
|
}
|
2017-11-26 13:46:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( mouseDown ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-26 17:39:17 +01:00
|
|
|
assert( selUpdate == E_ChangeType::POINT_DND );
|
|
|
|
selUpdate = E_ChangeType::NONE;
|
2017-11-26 13:46:46 +01:00
|
|
|
if ( moved ) {
|
2017-11-29 12:44:36 +01:00
|
|
|
auto& undo{ dynamic_cast< T_UndoSyncChanges& >(
|
|
|
|
Common::Undo( ).add< T_UndoSyncChanges >( ) ) };
|
|
|
|
for ( auto i = 0u ; i < ni ; i ++ ) {
|
|
|
|
undo.curveReplacement( std::move( selUpdatingOriginals[ i ] ) ,
|
|
|
|
std::move( selUpdatingCopies[ i ] ) );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for ( auto i = 0u ; i < ni ; i ++ ) {
|
|
|
|
sync.setCurve( std::move( selUpdatingOriginals[ i ] ) );
|
|
|
|
}
|
2017-11-26 13:46:46 +01:00
|
|
|
}
|
2017-11-29 12:44:36 +01:00
|
|
|
selUpdatingOriginals.clear( );
|
|
|
|
selUpdatingCopies.clear( );
|
2017-11-26 13:46:46 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-25 22:02:17 +01:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
T_SyncViewImpl_::T_MousePos T_SyncViewImpl_::getMousePos( ) const noexcept
|
|
|
|
{
|
|
|
|
auto const& mp{ ImGui::GetIO( ).MousePos };
|
|
|
|
for ( auto i = 0u ; i < dspTracks.size( ) ; i ++ ) {
|
|
|
|
auto const& track{ dspTracks[ i ] };
|
|
|
|
if ( !track.area.Contains( mp ) ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for ( auto j = 0u ; j < track.dispSegs ; j ++ ) {
|
|
|
|
auto const& seg{ dspSegments[ track.firstSeg + j ] };
|
|
|
|
if ( !seg.area.Contains( mp ) ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for ( auto k = 0u ; k < seg.dispPoints ; k ++ ) {
|
|
|
|
auto const& p{ dspPoints[ seg.firstPoint + k ] };
|
2017-11-29 11:37:47 +01:00
|
|
|
if ( ImLengthSqr( mp - p.center ) <= PointRadiusSqr * 2.25 ) {
|
2017-11-25 22:02:17 +01:00
|
|
|
return T_MousePos{ E_MousePosType::POINT ,
|
|
|
|
seg.firstPoint + k };
|
|
|
|
}
|
|
|
|
}
|
2017-11-25 23:37:07 +01:00
|
|
|
return T_MousePos{ E_MousePosType::SEGMENT ,
|
|
|
|
track.firstSeg + j };
|
2017-11-25 22:02:17 +01:00
|
|
|
}
|
|
|
|
return T_MousePos{ E_MousePosType::TRACK , i };
|
|
|
|
}
|
|
|
|
return T_MousePos{ E_MousePosType::NONE , 0 };
|
2017-11-22 20:28:12 +01:00
|
|
|
}
|
|
|
|
|
2017-11-22 14:14:49 +01:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2017-11-21 22:23:34 +01:00
|
|
|
|
2017-11-25 23:37:07 +01:00
|
|
|
void T_SyncViewImpl_::displayTrackSelectorWindow( ) noexcept
|
2017-11-21 22:23:34 +01:00
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
auto const& dspSize( GetIO( ).DisplaySize );
|
|
|
|
|
|
|
|
// Window set-up
|
|
|
|
SetNextWindowSize( ImVec2( dspSize.x * .25f , dspSize.y * .66f - 20 ) , ImGuiSetCond_Appearing );
|
|
|
|
SetNextWindowPos( ImVec2( dspSize.x * .75f , 20 ) , ImGuiSetCond_Appearing );
|
|
|
|
bool displayed{ true };
|
|
|
|
Begin( "Display curves" , &displayed , ImGuiWindowFlags_NoCollapse );
|
|
|
|
if ( !displayed ) {
|
|
|
|
End( );
|
|
|
|
sub = SW_NONE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// "Tabs"
|
|
|
|
const ImVec2 ws( GetWindowContentRegionMax( ) );
|
|
|
|
auto const& style( GetStyle( ) );
|
|
|
|
const float innerWidth{ ws.x - 2 * style.FramePadding.x };
|
|
|
|
constexpr float nButtons{ 2.f };
|
|
|
|
const float buttonWidth{ std::max( 50.f ,
|
|
|
|
( innerWidth - nButtons * style.FramePadding.x ) / nButtons ) };
|
|
|
|
|
2017-11-30 09:35:47 +01:00
|
|
|
if ( FakeTab_( "Overrides" , sub == SW_OVERRIDE_SELECTOR , buttonWidth ) ) {
|
|
|
|
sub = tsSelectedTab = SW_OVERRIDE_SELECTOR;
|
2017-11-21 22:23:34 +01:00
|
|
|
}
|
|
|
|
SameLine( 0 );
|
2017-11-30 09:35:47 +01:00
|
|
|
if ( FakeTab_( "Individual inputs" , sub == SW_INPUT_SELECTOR , buttonWidth ) ) {
|
|
|
|
sub = tsSelectedTab = SW_INPUT_SELECTOR;
|
2017-11-21 22:23:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Content
|
|
|
|
switch ( sub ) {
|
2017-11-25 23:37:07 +01:00
|
|
|
case SW_INPUT_SELECTOR:
|
|
|
|
displayInputSelector( );
|
2017-11-21 22:23:34 +01:00
|
|
|
break;
|
|
|
|
case SW_OVERRIDE_SELECTOR:
|
2017-11-22 07:38:27 +01:00
|
|
|
displayOverrideSelector( );
|
2017-11-21 22:23:34 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fprintf( stderr , "unexpected bullshit in sync view\n" );
|
|
|
|
std::abort( );
|
|
|
|
}
|
|
|
|
End( );
|
|
|
|
}
|
|
|
|
|
2017-11-25 23:37:07 +01:00
|
|
|
void T_SyncViewImpl_::displayInputSelector( ) noexcept
|
2017-11-21 22:23:34 +01:00
|
|
|
{
|
|
|
|
using namespace ImGui;
|
2017-11-23 23:05:14 +01:00
|
|
|
T_Array< T_String > names{ Common::Sync( ).inputNames( ) };
|
2017-11-21 22:23:34 +01:00
|
|
|
|
|
|
|
// Search box; FIXME, this is utterly hacky
|
|
|
|
stringBuffer.clear( ) << curveFinder;
|
|
|
|
while ( stringBuffer.size( ) < 100 ) {
|
|
|
|
stringBuffer << '\0';
|
|
|
|
}
|
|
|
|
Text( ICON_FA_SEARCH );
|
|
|
|
SameLine( );
|
|
|
|
PushItemWidth( -1 );
|
|
|
|
if ( InputText( "##find" , const_cast< char* >( stringBuffer.data( ) ) ,
|
|
|
|
stringBuffer.size( ) ) ) {
|
|
|
|
curveFinder = T_String{ stringBuffer.data( ) ,
|
|
|
|
uint32_t( strlen( stringBuffer.data( ) ) ) };
|
|
|
|
}
|
|
|
|
PopItemWidth( );
|
|
|
|
if ( curveFinder ) {
|
|
|
|
for ( auto i = 0u ; i < names.size( ) ; ) {
|
|
|
|
auto const& n( names[ i ] );
|
|
|
|
if ( n.find( curveFinder ) == -1 ) {
|
|
|
|
names.removeSwap( i );
|
|
|
|
} else {
|
|
|
|
i ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
names.sort( );
|
|
|
|
|
|
|
|
// The list
|
|
|
|
ImGui::BeginChild( "content" );
|
|
|
|
for ( auto const& n : names ) {
|
2017-11-29 07:23:36 +01:00
|
|
|
const bool present{ sInputs.contains( n ) };
|
2017-11-28 18:57:27 +01:00
|
|
|
const bool overriden{ present && *sInputs.get( n ) };
|
2017-11-21 22:23:34 +01:00
|
|
|
|
|
|
|
if ( overriden ) {
|
2017-11-23 14:43:15 +01:00
|
|
|
PushDisabled( );
|
2017-11-21 22:23:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool select{ present };
|
|
|
|
stringBuffer.clear( ) << n << '\0';
|
|
|
|
if ( Checkbox( stringBuffer.data( ) , &select ) ) {
|
2017-11-29 07:23:36 +01:00
|
|
|
const T_SyncTrackId id{ n , false };
|
2017-11-21 22:23:34 +01:00
|
|
|
if ( select ) {
|
2017-11-28 18:57:27 +01:00
|
|
|
sTracks.add( id );
|
|
|
|
sInputs.add( n , false );
|
2017-11-21 22:23:34 +01:00
|
|
|
} else {
|
2017-11-28 18:57:27 +01:00
|
|
|
sTracks.remove( id );
|
|
|
|
sInputs.remove( n );
|
2017-11-21 22:23:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( overriden ) {
|
2017-11-23 14:43:15 +01:00
|
|
|
PopDisabled( );
|
2017-11-21 22:23:34 +01:00
|
|
|
}
|
|
|
|
}
|
2017-11-22 07:38:27 +01:00
|
|
|
EndChild( );
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_SyncViewImpl_::displayOverrideSelector( ) noexcept
|
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
|
2017-11-28 10:42:04 +01:00
|
|
|
/*
|
|
|
|
* An override can be selected directly if the inputs that are part of
|
|
|
|
* it are consistent.
|
|
|
|
*
|
|
|
|
* If the inputs are not consistent, it will be necessary to reset
|
|
|
|
* some of their curves; best option would be to try and be clever, but
|
|
|
|
* a temporary measure (resetting all curves to match the structure of
|
|
|
|
* the first longest curve) would work.
|
|
|
|
*/
|
|
|
|
|
2017-11-22 07:38:27 +01:00
|
|
|
BeginChild( "content" );
|
2017-11-23 23:05:14 +01:00
|
|
|
Common::Sync( ).visitOverrides( [&]( T_SyncOverrideVisitor::T_Element element , const bool exit ) {
|
2017-11-22 07:38:27 +01:00
|
|
|
if ( element.hasType< T_SyncOverrideSection* >( ) ) {
|
|
|
|
auto const& sos{ *element.value< T_SyncOverrideSection* >( ) };
|
|
|
|
if ( sos.title == "*root*" ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if ( exit ) {
|
|
|
|
TreePop( );
|
2017-11-28 10:42:04 +01:00
|
|
|
return true;
|
2017-11-22 07:38:27 +01:00
|
|
|
}
|
2017-11-28 10:42:04 +01:00
|
|
|
return TreeNodeEx( &sos.cTitle[ 0 ] ,
|
|
|
|
ImGuiTreeNodeFlags_DefaultOpen );
|
|
|
|
}
|
|
|
|
if ( ! exit ) {
|
|
|
|
return false;
|
|
|
|
}
|
2017-11-22 07:38:27 +01:00
|
|
|
|
2017-11-28 10:42:04 +01:00
|
|
|
auto const& ov{ *element.value< A_SyncOverride* >( ) };
|
|
|
|
auto const& id{ ov.id( ) };
|
2017-11-29 07:20:22 +01:00
|
|
|
const bool present{ sTracks.contains( T_SyncTrackId{ id , true } ) };
|
2017-11-28 15:04:28 +01:00
|
|
|
const bool hasCurves{ !present && areOverrideInputsDisplayed( ov ) };
|
|
|
|
const bool consistent{ areOverrideInputsConsistent( ov ) };
|
2017-11-22 07:38:27 +01:00
|
|
|
|
2017-11-28 10:42:04 +01:00
|
|
|
if ( hasCurves ) {
|
|
|
|
PushDisabled( );
|
|
|
|
}
|
2017-11-28 15:04:28 +01:00
|
|
|
if ( !consistent ) {
|
2017-11-28 10:42:04 +01:00
|
|
|
PushStyleColor( ImGuiCol_Text , 0xff0000ff );
|
|
|
|
}
|
|
|
|
|
2017-11-28 15:04:28 +01:00
|
|
|
bool selected{ present };
|
|
|
|
if ( Checkbox( ov.title( ) , &selected ) ) {
|
|
|
|
overrideTrackToggled( ov , selected );
|
2017-11-22 07:38:27 +01:00
|
|
|
}
|
2017-11-28 10:42:04 +01:00
|
|
|
|
2017-11-28 15:04:28 +01:00
|
|
|
if ( !consistent ) {
|
2017-11-28 10:42:04 +01:00
|
|
|
PopStyleColor( );
|
|
|
|
}
|
|
|
|
if ( hasCurves ) {
|
|
|
|
PopDisabled( );
|
|
|
|
}
|
|
|
|
|
2017-11-22 07:38:27 +01:00
|
|
|
return true;
|
|
|
|
} );
|
|
|
|
EndChild( );
|
2017-11-21 22:23:34 +01:00
|
|
|
}
|
|
|
|
|
2017-11-28 15:04:28 +01:00
|
|
|
bool T_SyncViewImpl_::areOverrideInputsConsistent(
|
|
|
|
A_SyncOverride const& ov ) noexcept
|
|
|
|
{
|
|
|
|
/* A pair of inputs are consistent if
|
|
|
|
* - one or both inputs do not have curve information attached;
|
|
|
|
* - the durations and segment boundaries of the shortest curve
|
|
|
|
* attached to the inputs match the boundaries and durations from the
|
|
|
|
* other input's curve OR the last segment is shorter but its end
|
|
|
|
* matches the location of one of the points in the corresponding
|
|
|
|
* segment of the other curve.
|
|
|
|
*/
|
|
|
|
auto const& in{ ov.inputNames( ) };
|
|
|
|
for ( auto i = 0u ; i < in.size( ) - 1 ; i ++ ) {
|
|
|
|
T_SyncCurve const* const c0{
|
|
|
|
Common::Sync( ).getCurve( in[ i ] )
|
|
|
|
};
|
|
|
|
if ( !c0 ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for ( auto j = i + 1 ; j < in.size( ) ; j ++ ) {
|
|
|
|
T_SyncCurve const* const c1{
|
|
|
|
Common::Sync( ).getCurve( in[ j ] )
|
|
|
|
};
|
|
|
|
if ( !c1 ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const auto res{ c0->matches( *c1 ) };
|
|
|
|
if ( res == E_SyncCurveMatch::MISMATCH ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-30 10:13:37 +01:00
|
|
|
bool T_SyncViewImpl_::wouldInputsNeedAdjustment(
|
|
|
|
A_SyncOverride const& ov ) noexcept
|
|
|
|
{
|
|
|
|
auto& sync{ Common::Sync( ) };
|
|
|
|
auto const& in{ ov.inputNames( ) };
|
|
|
|
auto nNulls{ 0u };
|
|
|
|
for ( auto i = 0u ; i < in.size( ) - 1 ; i ++ ) {
|
|
|
|
T_SyncCurve const* const c0{ sync.getCurve( in[ i ] ) };
|
|
|
|
if ( !c0 ) {
|
|
|
|
nNulls ++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for ( auto j = i + 1 ; j < in.size( ) ; j ++ ) {
|
|
|
|
T_SyncCurve const* const c1{ sync.getCurve( in[ j ] ) };
|
|
|
|
if ( !c1 || c0->matches( *c1 ) != E_SyncCurveMatch::IDENTICAL ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !sync.getCurve( in[ in.size( ) - 1 ] ) ) {
|
|
|
|
nNulls ++;
|
|
|
|
}
|
|
|
|
return nNulls != 0 && nNulls != in.size( );
|
|
|
|
}
|
|
|
|
|
2017-11-28 15:04:28 +01:00
|
|
|
bool T_SyncViewImpl_::areOverrideInputsDisplayed(
|
|
|
|
A_SyncOverride const& ov ) const noexcept
|
|
|
|
{
|
|
|
|
auto const& in{ ov.inputNames( ) };
|
|
|
|
for ( auto i = 0u ; i < in.size( ) ; i ++ ) {
|
2017-11-29 07:23:36 +01:00
|
|
|
if ( sInputs.contains( in[ i ] ) ) {
|
2017-11-28 15:04:28 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_SyncViewImpl_::overrideTrackToggled(
|
|
|
|
A_SyncOverride const& ov ,
|
|
|
|
const bool selected ) noexcept
|
|
|
|
{
|
|
|
|
auto const& in{ ov.inputNames( ) };
|
2017-11-29 07:20:22 +01:00
|
|
|
const T_SyncTrackId id{ ov.id( ) , true };
|
2017-11-28 15:04:28 +01:00
|
|
|
|
|
|
|
// Handle de-selection
|
|
|
|
if ( !selected ) {
|
2017-11-28 18:57:27 +01:00
|
|
|
sTracks.remove( id );
|
2017-11-28 15:04:28 +01:00
|
|
|
for ( auto i = 0u ; i < in.size( ) ; i ++ ) {
|
2017-11-28 18:57:27 +01:00
|
|
|
sInputs.remove( in[ i ] );
|
2017-11-28 15:04:28 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the override is not consistent, we need to make it so
|
|
|
|
SyncEditor::MakeOverrideConsistent( ov.id( ) );
|
|
|
|
|
2017-11-28 18:57:27 +01:00
|
|
|
sTracks.add( id );
|
2017-11-28 15:04:28 +01:00
|
|
|
for ( auto i = 0u ; i < in.size( ) ; i ++ ) {
|
2017-11-28 18:57:27 +01:00
|
|
|
sInputs.add( in[ i ] , true );
|
2017-11-28 15:04:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-25 23:37:07 +01:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2017-11-30 10:13:37 +01:00
|
|
|
|
|
|
|
void T_SyncViewImpl_::clearSelectedTracks( ) noexcept
|
|
|
|
{
|
|
|
|
sTracks.clear( );
|
|
|
|
sInputs.clear( );
|
|
|
|
selId.clear( );
|
|
|
|
selSegment.clear( );
|
|
|
|
selPoint.clear( );
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_SyncViewImpl_::autoselectTracks( ) noexcept
|
|
|
|
{
|
|
|
|
clearSelectedTracks( );
|
|
|
|
|
|
|
|
auto& sync{ Common::Sync( ) };
|
|
|
|
sync.visitOverrides( [&]( T_SyncOverrideVisitor::T_Element element , const bool exit ) {
|
|
|
|
if ( element.hasType< T_SyncOverrideSection* >( ) || !exit ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto const& ov{ *element.value< A_SyncOverride* >( ) };
|
|
|
|
if ( !areOverrideInputsConsistent( ov ) ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if ( wouldInputsNeedAdjustment( ov ) ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto const& in{ ov.inputNames( ) };
|
|
|
|
sTracks.add( T_SyncTrackId{ ov.id( ) , true } );
|
|
|
|
for ( auto i = 0u ; i < in.size( ) ; i ++ ) {
|
|
|
|
sInputs.add( in[ i ] , true );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} );
|
|
|
|
|
|
|
|
for ( auto const& n : sync.inputNames( ) ) {
|
|
|
|
if ( !sInputs.contains( n ) ) {
|
|
|
|
sTracks.add( T_SyncTrackId{ n , false } );
|
|
|
|
sInputs.add( n , false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2017-11-25 23:37:07 +01:00
|
|
|
|
2017-11-26 10:14:00 +01:00
|
|
|
void T_SyncViewImpl_::displayTrackWindow( ) noexcept
|
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
auto const& dspSize( GetIO( ).DisplaySize );
|
|
|
|
|
|
|
|
// Window set-up
|
|
|
|
SetNextWindowSize( ImVec2( dspSize.x * .25f , dspSize.y * .66f - 20 ) , ImGuiSetCond_Appearing );
|
|
|
|
SetNextWindowPos( ImVec2( dspSize.x * .75f , 20 ) , ImGuiSetCond_Appearing );
|
|
|
|
bool displayed{ true };
|
|
|
|
Begin( "Selected track" , &displayed , ImGuiWindowFlags_NoCollapse );
|
|
|
|
if ( !displayed ) {
|
|
|
|
End( );
|
|
|
|
sub = SW_NONE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-28 22:10:10 +01:00
|
|
|
// Get the curve (or the first curve from the set)
|
2017-11-26 10:14:00 +01:00
|
|
|
auto& sync{ Common::Sync( ) };
|
2017-11-28 22:10:10 +01:00
|
|
|
auto const* const ovr{ selId->isOverride
|
|
|
|
? sync.getOverride( selId->id )
|
|
|
|
: nullptr };
|
|
|
|
auto const* const curve{ sync.getCurve( selId->isOverride
|
|
|
|
? ovr->inputNames( )[ 0 ]
|
|
|
|
: selId->id ) };
|
|
|
|
|
|
|
|
if ( selId->isOverride ) {
|
|
|
|
Text( "Override:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%s" , ovr->title( ) );
|
2017-11-26 10:14:00 +01:00
|
|
|
|
2017-11-28 22:10:10 +01:00
|
|
|
for ( auto i = 0u ; i < ovr->inputNames( ).size( ) ; i ++ ) {
|
|
|
|
Text( i == 0 ? "Curve(s):" : "" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%s" , ovr->inputNames( )[ i ].toOSString( ).data( ) );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Text( "Curve:" );
|
2017-11-26 10:14:00 +01:00
|
|
|
SameLine( 110 );
|
2017-11-28 22:10:10 +01:00
|
|
|
Text( "%s" , selId->id.toOSString( ).data( ) );
|
|
|
|
if ( !sync.hasInput( selId->id ) ) {
|
|
|
|
Text( " " );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "No matching input" );
|
|
|
|
}
|
2017-11-26 10:14:00 +01:00
|
|
|
}
|
|
|
|
|
2017-11-28 22:10:10 +01:00
|
|
|
Separator( );
|
2017-11-26 10:14:00 +01:00
|
|
|
Text( "Segments:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%d" , curve ? curve->segments.size( ) : 0 );
|
|
|
|
Separator( );
|
|
|
|
|
|
|
|
// Compute total duration
|
|
|
|
const uint32_t duration{ [&](){
|
|
|
|
uint32_t t{ 0 };
|
|
|
|
if ( !curve ) {
|
|
|
|
return 0u;
|
|
|
|
}
|
|
|
|
for ( auto const& s : curve->segments ) {
|
|
|
|
for ( auto const& d : s.durations ) {
|
|
|
|
t += d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return t;
|
|
|
|
}() };
|
|
|
|
const float tDuration{ duration * sync.durationUnitSize( ) };
|
|
|
|
|
|
|
|
Text( "Duration:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%d units" , duration );
|
|
|
|
|
|
|
|
Text( " " );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%.3f seconds" , tDuration );
|
|
|
|
|
|
|
|
const float dDuration{ sync.duration( ) };
|
|
|
|
if ( tDuration == 0.f ) {
|
|
|
|
Text( " " );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "Empty track" );
|
|
|
|
} else if ( tDuration == dDuration ) {
|
|
|
|
Text( " " );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "Covers the whole demo" );
|
|
|
|
} else if ( tDuration > dDuration ) {
|
|
|
|
Text( " " );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "Longer than the demo" );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ( curve && !curve->segments.empty( ) ) || tDuration < dDuration ) {
|
|
|
|
Separator( );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( curve && !curve->segments.empty( ) ) {
|
|
|
|
Text( " " );
|
|
|
|
SameLine( 110 );
|
|
|
|
if ( Button( "Clear" , ImVec2{ -1 , 0 } ) ) {
|
2017-11-29 07:20:22 +01:00
|
|
|
SyncEditor::DeleteCurve( *selId );
|
2017-11-26 10:14:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( tDuration < dDuration ) {
|
|
|
|
Text( " " );
|
|
|
|
SameLine( 110 );
|
|
|
|
if ( Button( "Append segment" , ImVec2{ -1 , 0 } ) ) {
|
|
|
|
const uint32_t ns{ std::max( 1u ,
|
|
|
|
( sync.durationUnits( ) - duration ) / 2 ) };
|
2017-11-29 07:20:22 +01:00
|
|
|
SyncEditor::AppendSegment( *selId , ns );
|
2017-11-26 10:14:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
End( );
|
|
|
|
}
|
|
|
|
|
2017-11-25 23:37:07 +01:00
|
|
|
void T_SyncViewImpl_::displaySegmentWindow( ) noexcept
|
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
auto const& dspSize( GetIO( ).DisplaySize );
|
|
|
|
|
|
|
|
// Window set-up
|
|
|
|
SetNextWindowSize( ImVec2( dspSize.x * .25f , dspSize.y * .66f - 20 ) , ImGuiSetCond_Appearing );
|
|
|
|
SetNextWindowPos( ImVec2( dspSize.x * .75f , 20 ) , ImGuiSetCond_Appearing );
|
|
|
|
bool displayed{ true };
|
|
|
|
Begin( "Selected segment" , &displayed , ImGuiWindowFlags_NoCollapse );
|
|
|
|
if ( !displayed ) {
|
|
|
|
End( );
|
|
|
|
sub = SW_NONE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-26 10:14:00 +01:00
|
|
|
const uint32_t sid{ *selSegment };
|
2017-11-28 22:10:10 +01:00
|
|
|
auto& sync{ Common::Sync( ) };
|
|
|
|
auto const* const ovr{ selId->isOverride
|
|
|
|
? sync.getOverride( selId->id )
|
|
|
|
: nullptr };
|
2017-11-26 10:14:00 +01:00
|
|
|
|
2017-11-28 22:10:10 +01:00
|
|
|
if ( selId->isOverride ) {
|
|
|
|
Text( "Override:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%s" , ovr->title( ) );
|
|
|
|
} else {
|
|
|
|
Text( "Curve:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%s" , selId->id.toOSString( ).data( ) );
|
|
|
|
}
|
2017-11-25 23:37:07 +01:00
|
|
|
|
|
|
|
Text( "Index:" );
|
|
|
|
SameLine( 110 );
|
2017-11-26 10:14:00 +01:00
|
|
|
Text( "%d" , sid );
|
2017-11-25 23:37:07 +01:00
|
|
|
|
|
|
|
Separator( );
|
|
|
|
|
2017-11-26 10:14:00 +01:00
|
|
|
// Access curve and segment
|
2017-11-28 22:10:10 +01:00
|
|
|
auto const* const curve{ sync.getCurve( selId->isOverride
|
|
|
|
? ovr->inputNames( )[ 0 ]
|
|
|
|
: selId->id ) };
|
2017-11-26 10:14:00 +01:00
|
|
|
auto const& segment{ curve->segments[ sid ] };
|
2017-11-25 23:37:07 +01:00
|
|
|
|
|
|
|
// Find start and duration
|
|
|
|
uint32_t start{ 0 } , duration{ 0 };
|
2017-11-26 10:14:00 +01:00
|
|
|
for ( auto i = 0u ; i <= sid ; i ++ ) {
|
2017-11-25 23:37:07 +01:00
|
|
|
auto const& s{ curve->segments[ i ] };
|
2017-11-26 10:14:00 +01:00
|
|
|
auto& tgt{ i == sid ? duration : start };
|
2017-11-25 23:37:07 +01:00
|
|
|
for ( auto d : s.durations ) {
|
|
|
|
tgt += d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const float tStart{ sync.durationUnitSize( ) * start } ,
|
|
|
|
tDuration{ sync.durationUnitSize( ) * duration };
|
|
|
|
|
|
|
|
Text( "Start:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%d units" , start );
|
|
|
|
|
|
|
|
Text( " " );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%.3f seconds" , tStart );
|
|
|
|
|
|
|
|
Text( "End:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%d units" , start + duration );
|
|
|
|
|
|
|
|
Text( " " );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%.3f seconds" , tStart + tDuration );
|
|
|
|
|
|
|
|
Text( "Duration:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%d units" , duration );
|
|
|
|
|
|
|
|
Text( " " );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%.3f seconds" , tDuration );
|
|
|
|
|
2017-11-29 10:23:24 +01:00
|
|
|
// Generate the combo box's data
|
|
|
|
static constexpr T_SyncSegment::E_SegmentType types[] = {
|
|
|
|
T_SyncSegment::LINEAR , T_SyncSegment::RAMP , T_SyncSegment::SMOOTH
|
|
|
|
};
|
|
|
|
stringBuffer.clear( ) << "various types" << '\0';
|
|
|
|
const auto ts{ stringBuffer.size( ) };
|
|
|
|
for ( auto t : types ) {
|
|
|
|
stringBuffer << t << '\0';
|
|
|
|
}
|
|
|
|
stringBuffer << '\0';
|
2017-11-25 23:37:07 +01:00
|
|
|
|
2017-11-29 10:23:24 +01:00
|
|
|
// Display segment type selectors
|
|
|
|
auto const nc{ ovr ? ovr->inputNames( ).size( ) : 1u };
|
|
|
|
int change;
|
|
|
|
int sTypes[ nc + 1 ];
|
|
|
|
Separator( );
|
|
|
|
if ( !ovr ) {
|
2017-11-28 22:10:10 +01:00
|
|
|
Text( "Type:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
PushItemWidth( -1 );
|
2017-11-29 10:23:24 +01:00
|
|
|
sTypes[ 0 ] = int( segment.type );
|
|
|
|
change = Combo( "##type" , &sTypes[ 0 ] , stringBuffer.data( ) + ts ) ? 0 : -1;
|
|
|
|
PopItemWidth( );
|
|
|
|
} else if ( TreeNode( "Segment types" ) ) {
|
|
|
|
change = -1;
|
|
|
|
const uint32_t sblen{ stringBuffer.size( ) };
|
|
|
|
PushItemWidth( -1 );
|
|
|
|
int common{ -1 };
|
|
|
|
for ( auto i = 0u ; i < nc ; i ++ ) {
|
|
|
|
auto const& iName{ ovr->inputNames( )[ i ] };
|
|
|
|
sTypes[ i ] = int( sync.getCurve( iName )->segments[ sid ].type );
|
|
|
|
if ( i == 0 ) {
|
|
|
|
common = sTypes[ i ];
|
|
|
|
} else if ( common != sTypes[ i ] ) {
|
|
|
|
common = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
stringBuffer << iName << '\0';
|
|
|
|
Text( "%s" , stringBuffer.data( ) + sblen );
|
|
|
|
SameLine( 200 );
|
|
|
|
|
|
|
|
stringBuffer.truncate( sblen ) << "##type" << i << '\0';
|
|
|
|
if ( Combo( stringBuffer.data( ) + sblen , &sTypes[ i ] ,
|
|
|
|
stringBuffer.data( ) + ts ) ) {
|
|
|
|
change = i;
|
|
|
|
}
|
|
|
|
stringBuffer.truncate( sblen );
|
|
|
|
}
|
|
|
|
Separator( );
|
|
|
|
|
|
|
|
const auto cOffset{ common == -1 ? 0 : ts };
|
|
|
|
if ( common == -1 ) {
|
|
|
|
common ++;
|
|
|
|
}
|
|
|
|
Text( "All inputs" );
|
|
|
|
SameLine( 200 );
|
|
|
|
if ( Combo( "##type-all" , &common , stringBuffer.data( ) + cOffset ) ) {
|
|
|
|
sTypes[ nc ] = common - ( cOffset == 0 ? 1 : 0 );
|
|
|
|
change = nc;
|
|
|
|
}
|
|
|
|
|
2017-11-28 22:10:10 +01:00
|
|
|
PopItemWidth( );
|
2017-11-29 10:23:24 +01:00
|
|
|
TreePop( );
|
2017-11-28 22:10:10 +01:00
|
|
|
} else {
|
2017-11-29 10:23:24 +01:00
|
|
|
change = -1;
|
2017-11-25 23:37:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Separator( );
|
|
|
|
|
|
|
|
Text( "Points:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%d" , segment.values.size( ) );
|
|
|
|
|
2017-11-28 22:10:10 +01:00
|
|
|
if ( !ovr ) {
|
|
|
|
// Find min/max
|
|
|
|
float sMin{ FLT_MAX } , sMax{ -FLT_MAX };
|
|
|
|
for ( auto v : segment.values ) {
|
|
|
|
sMin = ImMin( sMin , v );
|
|
|
|
sMax = ImMax( sMax , v );
|
|
|
|
}
|
2017-11-25 23:37:07 +01:00
|
|
|
|
2017-11-28 22:10:10 +01:00
|
|
|
Text( "Min. value:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%f" , sMin );
|
2017-11-25 23:37:07 +01:00
|
|
|
|
2017-11-28 22:10:10 +01:00
|
|
|
Text( "Max. value:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%f" , sMax );
|
|
|
|
}
|
2017-11-25 23:37:07 +01:00
|
|
|
|
2017-11-26 10:14:00 +01:00
|
|
|
Separator( );
|
|
|
|
|
|
|
|
Text( " " );
|
|
|
|
SameLine( 110 );
|
|
|
|
if ( Button( "Delete segment" , ImVec2{ -1 , 0 } ) ) {
|
|
|
|
if ( curve->segments.size( ) > 1 ) {
|
|
|
|
selSegment = ( sid == 0 ? 0 : ( sid - 1 ) );
|
|
|
|
} else {
|
2017-11-26 11:57:26 +01:00
|
|
|
selSegment = decltype( selSegment ){};
|
2017-11-26 10:14:00 +01:00
|
|
|
}
|
2017-11-29 10:23:24 +01:00
|
|
|
SyncEditor::DeleteSegment( *selId , sid );
|
2017-11-26 10:14:00 +01:00
|
|
|
}
|
|
|
|
|
2017-11-29 10:23:24 +01:00
|
|
|
if ( change >= 0 && change < int32_t( nc ) ) {
|
|
|
|
SyncEditor::SetSegmentType(
|
|
|
|
*( ovr ? sync.getCurve( ovr->inputNames( )[ change ] ) : curve ) ,
|
|
|
|
sid , T_SyncSegment::E_SegmentType( sTypes[ change ] ) );
|
|
|
|
} else if ( change == int32_t( nc ) && sTypes[ nc ] != -1 ) {
|
|
|
|
assert( ovr );
|
|
|
|
SyncEditor::SetSegmentTypes( *ovr , sid ,
|
|
|
|
T_SyncSegment::E_SegmentType( sTypes[ nc ] ) );
|
2017-11-25 23:37:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
End( );
|
|
|
|
}
|
|
|
|
|
2017-11-26 17:39:17 +01:00
|
|
|
void T_SyncViewImpl_::displayPointWindow( ) noexcept
|
|
|
|
{
|
|
|
|
using namespace ImGui;
|
|
|
|
auto const& dspSize( GetIO( ).DisplaySize );
|
|
|
|
|
|
|
|
// Window set-up
|
|
|
|
SetNextWindowSize( ImVec2( dspSize.x * .25f , dspSize.y * .66f - 20 ) , ImGuiSetCond_Appearing );
|
|
|
|
SetNextWindowPos( ImVec2( dspSize.x * .75f , 20 ) , ImGuiSetCond_Appearing );
|
|
|
|
bool displayed{ true };
|
|
|
|
Begin( "Selected point" , &displayed , ImGuiWindowFlags_NoCollapse );
|
|
|
|
if ( !displayed ) {
|
|
|
|
End( );
|
|
|
|
sub = SW_NONE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Access curve, segment and point
|
|
|
|
const uint32_t sid{ *selSegment };
|
|
|
|
const uint32_t pid{ *selPoint };
|
|
|
|
auto& sync{ Common::Sync( ) };
|
2017-11-29 16:07:20 +01:00
|
|
|
auto* const ovr{ selId->isOverride
|
2017-11-29 11:37:47 +01:00
|
|
|
? sync.getOverride( selId->id )
|
|
|
|
: nullptr };
|
2017-11-29 12:44:36 +01:00
|
|
|
auto const* const curve{ selUpdatingCopies.size( )
|
|
|
|
? &selUpdatingCopies[ 0 ]
|
2017-11-29 11:37:47 +01:00
|
|
|
: sync.getCurve( ovr ? ovr->inputNames( )[ 0 ] : selId->id ) };
|
2017-11-26 17:39:17 +01:00
|
|
|
auto const& segment{ curve->segments[ sid ] };
|
|
|
|
|
2017-11-29 11:37:47 +01:00
|
|
|
if ( selId->isOverride ) {
|
|
|
|
Text( "Override:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%s" , ovr->title( ) );
|
|
|
|
} else {
|
|
|
|
Text( "Curve:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%s" , selId->id.toOSString( ).data( ) );
|
|
|
|
}
|
2017-11-26 17:39:17 +01:00
|
|
|
|
|
|
|
Text( "Segment index:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%d" , sid );
|
|
|
|
|
|
|
|
Text( "Point index:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%d / %d" , pid , segment.durations.size( ) );
|
|
|
|
|
|
|
|
Separator( );
|
|
|
|
|
|
|
|
// Find start and duration
|
|
|
|
uint32_t segStart{ 0 } , pointPosRel{ 0 };
|
|
|
|
for ( auto i = 0u ; i <= sid ; i ++ ) {
|
|
|
|
auto const& s{ curve->segments[ i ] };
|
|
|
|
auto& tgt{ i == sid ? pointPosRel : segStart };
|
|
|
|
const auto end{ i == sid ? pid : s.durations.size( ) };
|
|
|
|
for ( auto j = 0u ; j < end ; j ++ ) {
|
|
|
|
tgt += s.durations[ j ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const uint32_t pointPosAbs{ segStart + pointPosRel };
|
|
|
|
const float tPointPosAbs{ sync.durationUnitSize( ) * pointPosAbs } ,
|
|
|
|
tPointPosRel{ sync.durationUnitSize( ) * pointPosRel };
|
|
|
|
|
|
|
|
Text( "Absolute:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%d units" , pointPosAbs );
|
|
|
|
|
|
|
|
Text( " " );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%.3f seconds" , tPointPosAbs );
|
|
|
|
|
|
|
|
Text( "Relative:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%d units" , pointPosRel );
|
|
|
|
|
|
|
|
Text( " " );
|
|
|
|
SameLine( 110 );
|
|
|
|
Text( "%.3f seconds" , tPointPosRel );
|
|
|
|
|
|
|
|
Separator( );
|
|
|
|
|
2017-11-29 16:07:20 +01:00
|
|
|
// This is here because the curve pointer might get fucked over by
|
|
|
|
// the override control
|
|
|
|
const auto canInsertBefore{ pid != 0
|
|
|
|
&& segment.durations[ pid - 1 ] > 1 };
|
|
|
|
const auto canInsertAfter{ pid != segment.durations.size( )
|
|
|
|
&& segment.durations[ pid ] > 1 };
|
|
|
|
const auto canDelete{ pid != 0 && pid != segment.durations.size( ) };
|
|
|
|
|
2017-11-29 11:37:47 +01:00
|
|
|
bool changed;
|
2017-11-29 16:07:20 +01:00
|
|
|
float value{ 0 };
|
2017-11-29 11:37:47 +01:00
|
|
|
if ( ovr ) {
|
2017-11-29 16:07:20 +01:00
|
|
|
selEditor.use( );
|
|
|
|
uint32_t i{ 0 };
|
|
|
|
changed = (UI::Sync( ).uiFor( *ovr ))(
|
|
|
|
*ovr , selEditor , i , stringBuffer );
|
2017-11-29 16:36:18 +01:00
|
|
|
if ( Button( "Copy data" , ImVec2{ -1 , 0 } ) && !changed ) {
|
|
|
|
auto const& iNames{ ovr->inputNames( ) };
|
|
|
|
cpType = ovr->type( );
|
|
|
|
cpData.clear( );
|
|
|
|
for ( auto i = 0u ; i < iNames.size( ) ; i ++ ) {
|
|
|
|
cpData.add( sync.getCurve( iNames[ i ] )->segments[ sid ].values[ pid ] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( cpType != ovr->type( ) ) {
|
|
|
|
PushDisabled( );
|
|
|
|
}
|
|
|
|
if ( Button( "Paste data" , ImVec2{ -1 , 0 } ) && !changed ) {
|
|
|
|
auto const& iNames{ ovr->inputNames( ) };
|
|
|
|
for ( auto i = 0u ; i < iNames.size( ) ; i ++ ) {
|
|
|
|
auto c{ *sync.getCurve( iNames[ i ] ) };
|
|
|
|
selUpdatingOriginals.add( c );
|
|
|
|
c.segments[ sid ].values[ pid ] = cpData[ i ];
|
|
|
|
selUpdatingCopies.add( c );
|
|
|
|
sync.setCurve( std::move( c ) );
|
|
|
|
}
|
|
|
|
selUpdate = E_ChangeType::POINT_VALUE;
|
|
|
|
}
|
|
|
|
if ( cpType != ovr->type( ) ) {
|
|
|
|
PopDisabled( );
|
|
|
|
}
|
|
|
|
|
2017-11-29 11:37:47 +01:00
|
|
|
} else {
|
|
|
|
Text( "Value:" );
|
|
|
|
SameLine( 110 );
|
|
|
|
PushItemWidth( -1 );
|
2017-11-29 16:07:20 +01:00
|
|
|
value = segment.values[ pid ];
|
2017-11-29 11:37:47 +01:00
|
|
|
DragFloat( "##value" , &value , .01f , 0 , 0 , "%.6f" );
|
|
|
|
changed = IsItemActive( );
|
|
|
|
PopItemWidth( );
|
|
|
|
}
|
2017-11-26 17:39:17 +01:00
|
|
|
|
|
|
|
const bool canUseButtons{ !changed && selUpdate == E_ChangeType::NONE };
|
2017-11-29 16:07:20 +01:00
|
|
|
if ( canDelete ) {
|
2017-11-26 17:39:17 +01:00
|
|
|
SameLine( 110 );
|
|
|
|
if ( Button( "Delete point" , ImVec2{ -1 , 0 } ) && canUseButtons ) {
|
2017-11-29 11:37:47 +01:00
|
|
|
SyncEditor::DeletePoint( *selId , sid , pid );
|
2017-11-26 17:39:17 +01:00
|
|
|
selPoint.clear( );
|
|
|
|
sub = SW_SEGMENT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( canInsertAfter || canInsertBefore ) {
|
|
|
|
Separator( );
|
|
|
|
if ( canInsertBefore ) {
|
|
|
|
if ( Button( "Insert before" , ImVec2{ -1 , 0 } ) && canUseButtons ) {
|
2017-11-29 11:37:47 +01:00
|
|
|
SyncEditor::InsertPoint( *selId , sid , pid );
|
2017-11-26 17:39:17 +01:00
|
|
|
(*selPoint) ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( canInsertAfter ) {
|
|
|
|
if ( Button( "Insert after" , ImVec2{ -1 , 0 } ) && canUseButtons ) {
|
2017-11-29 11:37:47 +01:00
|
|
|
SyncEditor::InsertPoint( *selId , sid , pid + 1 );
|
2017-11-26 17:39:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-29 16:07:20 +01:00
|
|
|
if ( ovr && changed ) {
|
2017-11-26 17:39:17 +01:00
|
|
|
if ( selUpdate == E_ChangeType::NONE ) {
|
2017-11-29 16:07:20 +01:00
|
|
|
selUpdate = E_ChangeType::POINT_VALUE;
|
|
|
|
} else {
|
|
|
|
assert( selUpdate == E_ChangeType::POINT_VALUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ( changed ) {
|
|
|
|
if ( selUpdate == E_ChangeType::NONE ) {
|
|
|
|
assert( selUpdatingOriginals.empty( ) );
|
|
|
|
assert( selUpdatingCopies.empty( ) );
|
2017-11-29 12:44:36 +01:00
|
|
|
selUpdatingOriginals.add( *curve );
|
|
|
|
selUpdatingCopies.add( *curve );
|
2017-11-26 17:39:17 +01:00
|
|
|
selUpdate = E_ChangeType::POINT_VALUE;
|
|
|
|
} else {
|
|
|
|
assert( selUpdate == E_ChangeType::POINT_VALUE );
|
|
|
|
}
|
2017-11-29 12:44:36 +01:00
|
|
|
selUpdatingCopies[ 0 ].segments[ sid ].values[ pid ] = value;
|
|
|
|
sync.setCurve( selUpdatingCopies[ 0 ] );
|
2017-11-29 16:07:20 +01:00
|
|
|
|
2017-11-26 17:39:17 +01:00
|
|
|
} else if ( selUpdate == E_ChangeType::POINT_VALUE ) {
|
|
|
|
selUpdate = E_ChangeType::NONE;
|
2017-11-29 16:07:20 +01:00
|
|
|
auto& undo{ dynamic_cast< T_UndoSyncChanges& >(
|
|
|
|
Common::Undo( ).add< T_UndoSyncChanges >( ) ) };
|
|
|
|
for ( auto i = 0u ; i < selUpdatingCopies.size( ) ; i ++ ) {
|
|
|
|
undo.curveReplacement( std::move( selUpdatingOriginals[ i ] ) ,
|
|
|
|
std::move( selUpdatingCopies[ i ] ) );
|
|
|
|
}
|
2017-11-29 12:44:36 +01:00
|
|
|
selUpdatingCopies.clear( );
|
|
|
|
selUpdatingOriginals.clear( );
|
2017-11-26 17:39:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
End( );
|
|
|
|
}
|
|
|
|
|
2017-11-22 14:14:49 +01:00
|
|
|
} // namespace <anon>
|
|
|
|
|
2017-11-20 17:01:09 +01:00
|
|
|
|
2017-11-22 14:14:49 +01:00
|
|
|
/*= T_SyncView ===============================================================*/
|
2017-11-20 17:01:09 +01:00
|
|
|
|
|
|
|
T_SyncView::T_SyncView( ) noexcept
|
|
|
|
: A_PrivateImplementation( new T_SyncViewImpl_( ) )
|
|
|
|
{ }
|
|
|
|
|
|
|
|
bool T_SyncView::display( ) noexcept
|
|
|
|
{
|
|
|
|
return p< T_SyncViewImpl_ >( ).display( );
|
|
|
|
}
|