From 551bd56982ed15b546200c9f8e4bca0514ecf47c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= <tseeker@nocternity.net>
Date: Wed, 29 Nov 2017 16:36:18 +0100
Subject: [PATCH] Sequencer - Override data copy/paste

---
 ui-sequencer.cc | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/ui-sequencer.cc b/ui-sequencer.cc
index 6ce193c..0e0653c 100644
--- a/ui-sequencer.cc
+++ b/ui-sequencer.cc
@@ -435,9 +435,11 @@ struct T_SyncViewImpl_
 	T_TempCurveStorage_ selUpdatingOriginals;
 	T_TempCurveStorage_ selUpdatingCopies;
 
-	// Override edition
+	// Override edition and copypasta
 	T_PointData_ selEditor{ selId , selSegment , selPoint ,
 		selUpdatingOriginals , selUpdatingCopies };
+	T_String cpType;
+	T_AutoArray< float , 16 > cpData;
 
 	// Sub-windows
 	E_SubWindow sub{ SW_NONE };
@@ -2056,6 +2058,33 @@ void T_SyncViewImpl_::displayPointWindow( ) noexcept
 		uint32_t i{ 0 };
 		changed = (UI::Sync( ).uiFor( *ovr ))(
 				*ovr , selEditor , i , stringBuffer );
+		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( );
+		}
+
 	} else {
 		Text( "Value:" );
 		SameLine( 110 );
@@ -2068,8 +2097,6 @@ void T_SyncViewImpl_::displayPointWindow( ) noexcept
 
 	const bool canUseButtons{ !changed && selUpdate == E_ChangeType::NONE };
 	if ( canDelete ) {
-		Separator( );
-		Text( " " );
 		SameLine( 110 );
 		if ( Button( "Delete point" , ImVec2{ -1 , 0 } ) && canUseButtons ) {
 			SyncEditor::DeletePoint( *selId , sid , pid );
@@ -2081,16 +2108,12 @@ void T_SyncViewImpl_::displayPointWindow( ) noexcept
 	if ( canInsertAfter || canInsertBefore ) {
 		Separator( );
 		if ( canInsertBefore ) {
-			Text( " " );
-			SameLine( 110 );
 			if ( Button( "Insert before" , ImVec2{ -1 , 0 } ) && canUseButtons ) {
 				SyncEditor::InsertPoint( *selId , sid , pid );
 				(*selPoint) ++;
 			}
 		}
 		if ( canInsertAfter ) {
-			Text( " " );
-			SameLine( 110 );
 			if ( Button( "Insert after" , ImVec2{ -1 , 0 } ) && canUseButtons ) {
 				SyncEditor::InsertPoint( *selId , sid , pid + 1 );
 			}