summaryrefslogtreecommitdiff
path: root/src/createcalls.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/createcalls.cpp')
-rw-r--r--src/createcalls.cpp54
1 files changed, 45 insertions, 9 deletions
diff --git a/src/createcalls.cpp b/src/createcalls.cpp
index fd60b4e..54dd376 100644
--- a/src/createcalls.cpp
+++ b/src/createcalls.cpp
@@ -473,7 +473,7 @@ void Slide_Test(project_data *File, project_state *State, memory *Memory, sorted
{
block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, File->PrincipalCompIndex);
v2 CompDimensions = V2(MainComp->Width, MainComp->Height);
- real32 Threshold = 5;
+ real32 Threshold = 10;
uint8 *InteractBuffer = (uint8 *)State->Brush.TransientBitmap;
for (int i = 0; i < State->Interact_Count; i++) {
interact_slide_layer *Interact_Layer = (interact_slide_layer *)InteractBuffer;
@@ -481,11 +481,14 @@ void Slide_Test(project_data *File, project_state *State, memory *Memory, sorted
block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Interact_Layer->Index);
v2 CompUV = V2(State->Interact_Offset[0], State->Interact_Offset[1]);
v2 CompPos = CompUV * CompDimensions;
- v2 LayerPos = Layer_TraverseForPoint(File, State, Memory, CompUV, SortedCompArray, SortedLayerArray);
+ // v2 LayerPos = Layer_TraverseForPoint(File, State, Memory, CompUV, SortedCompArray, SortedLayerArray, Interact_Layer->Index);
+ v2 LayerPos = V2(Layer->x.CurrentValue, Layer->y.CurrentValue);
int Width, Height;
Layer_GetDimensions(Memory, Layer, &Width, &Height);
- if (abs(CompPos.x - LayerPos.x) > Threshold &&
- abs(CompPos.y - LayerPos.y) > Threshold)
+ v2 Difference = V2(abs(CompPos.x - LayerPos.x), abs(CompPos.y - LayerPos.y));
+ printf("Diff: %.1f, %.1f\n", Difference.x, Difference.y);
+ if (Difference.x < Threshold &&
+ Difference.y < Threshold)
Assert(0);
}
}
@@ -572,6 +575,33 @@ void Effect_Curves_Sort(memory *Memory, block_effect *Effect, uint16 *SortedPoin
}
static void
+Layer_Nudge(project_data *File, project_state *State, memory *Memory,
+ sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray)
+{
+ sorted_comp_array SortedCompStart = SortedCompArray[File->PrincipalCompIndex];
+ sorted_layer_array *SortedLayerStart = Sorted_GetLayerStart(SortedLayerArray, SortedCompArray, File->PrincipalCompIndex);
+ State->Interact_Active = interact_type_layer_move;
+ State->Interact_Offset[0] = 1;
+ History_Entry_Commit(Memory, "Move layer stack down");
+ for (int i = 0; i < SortedCompStart.LayerCount; i++)
+ {
+ sorted_layer_array SortEntry = SortedLayerStart[i];
+ uint32 Index_Physical = SortEntry.Block_Layer_Index;
+ block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Index_Physical);
+ // NOTE(fox): Some data on the tree could be saved here.
+ History_Action_Swap(Memory, F_Layers, sizeof(Layer->Vertical_Offset), &Layer->Vertical_Offset);
+ Layer->Vertical_Offset = SortEntry.SortedOffset;
+ if (Layer->IsSelected) {
+ History_Action_Swap(Memory, F_Layers, sizeof(Layer->Frame_Offset), &Layer->Frame_Offset);
+ Interact_Evaluate_Layer(Memory, State, Index_Physical, SortedCompStart, SortedLayerStart, &Layer->Frame_Start, &Layer->Frame_End, &Layer->Frame_Offset);
+ }
+ }
+ State->Interact_Active = interact_type_none;
+ State->Interact_Modifier = 0;
+ History_Entry_End(Memory);
+}
+
+static void
Interact_Evaluate_Layer(memory *Memory, project_state *State, uint16 Layer_Index_Physical, sorted_comp_array SortedCompStart, sorted_layer_array *SortedLayerStart,
int32 *Frame_Start, int32 *Frame_End, int *Frame_Offset)
{
@@ -678,14 +708,20 @@ Project_Layer_Duplicate(project_data *File, project_state *State, memory *Memory
Assert(Layer->Block_Effect_Count == 0);
- NewLayer->IsSelected = true;
+ Layer_Select(Memory, State, Memory_Block_LazyIndexAtAddress(Memory, F_Layers, NewLayer));
NewLayer->Vertical_Offset--;
- for (int a = i+2; a < LayerCount; a++) {
+ for (int a = i+1; a < LayerCount; a++) {
+ sorted_layer_array PrevSortEntry = SortedLayerStart[a-1];
+ uint32 PrevIndex_Physical = PrevSortEntry.Block_Layer_Index;
+ block_layer *PrevLayer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, PrevIndex_Physical);
sorted_layer_array NextSortEntry = SortedLayerStart[a];
uint32 NextIndex_Physical = NextSortEntry.Block_Layer_Index;
block_layer *NextLayer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, NextIndex_Physical);
- NextLayer->Vertical_Offset--;
+ if (NextLayer->Vertical_Offset == PrevLayer->Vertical_Offset)
+ NextLayer->Vertical_Offset -= 1;
+ else
+ break;
}
Assert(!NewLayer->x.Keyframe_Count);
@@ -704,8 +740,8 @@ Project_Layer_Duplicate(project_data *File, project_state *State, memory *Memory
Increment++;
} else {
- // History_Action_Swap(Memory, F_File, sizeof(Layer->Vertical_Offset), &Layer->Vertical_Offset);
- Layer->IsSelected = false;
+ // History_Action_Swap(Memory, F_Layers, sizeof(Layer->Vertical_Offset), &Layer->Vertical_Offset);
+ Layer->IsSelected = false;
}
}
}