summaryrefslogtreecommitdiff
path: root/src/sorted.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sorted.cpp')
-rw-r--r--src/sorted.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/sorted.cpp b/src/sorted.cpp
index 394c82f..9f2e135 100644
--- a/src/sorted.cpp
+++ b/src/sorted.cpp
@@ -73,6 +73,49 @@ void Property_SortAll(memory *Memory, project_state *State, property_channel *Pr
}
}
+static real32
+Layer_Sort_DisplayOffset(project_state *State, memory *Memory,
+ sorted_property_array *SortedPropertyArray, uint16 *SortedKeyframeArray,
+ sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray,
+ sorted_comp_array *SortedCompStart, sorted_layer_array *SortedLayerStart)
+{
+ int32 DisplayOffset = 0;
+ for (int i = SortedCompStart->LayerCount - 1; i >= 0; i--)
+ {
+ sorted_layer_array *SortEntry = &SortedLayerStart[i];
+ SortEntry->DisplayOffset = DisplayOffset;
+ uint32 Index_Physical = SortEntry->Block_Layer_Index;
+ block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Index_Physical);
+ sorted_property_array *SortedPropertyStart = SortedPropertyArray + SortedLayerStart->SortedPropertyStart;
+ uint16 *SortedKeyframeStart = SortedKeyframeArray + SortedLayerStart->SortedKeyframeStart;
+ int h = 0, c = 0, p = 0;
+ property_channel *Property = NULL;
+ block_effect *Effect = NULL;
+ while (Layer_LoopChannels(State, Memory, &SortedPropertyStart, &SortedKeyframeStart, Layer, &Property, &Effect, &h, &c, &p))
+ {
+ if (Property->IsToggled) {
+ DisplayOffset++;
+ }
+ }
+ if (Layer->Precomp_Toggled) {
+ Assert(Layer->IsPrecomp);
+ sorted_comp_array *InnerSortedCompStart = &SortedCompArray[Layer->Block_Source_Index];
+ sorted_layer_array *InnerSortedLayerStart = Sorted_GetLayerStart(SortedLayerArray, SortedCompArray, Layer->Block_Source_Index);
+ real32 InnerCompOffset = Layer_Sort_DisplayOffset(State, Memory, SortedPropertyArray, SortedKeyframeArray, SortedCompArray, SortedLayerArray,
+ InnerSortedCompStart, InnerSortedLayerStart);
+ InnerSortedCompStart->DisplaySize = InnerCompOffset;
+ DisplayOffset += InnerCompOffset;
+ }
+ }
+ if (SortedCompStart->LayerCount > 1) {
+ block_layer *Layer_Top = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, SortedLayerStart[SortedCompStart->LayerCount - 1].Block_Layer_Index);
+ block_layer *Layer_Bottom = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, SortedLayerStart[0].Block_Layer_Index);
+ real32 SmallestY = Layer_Top->Vertical_Offset;
+ real32 LargestY = Layer_Bottom->Vertical_Offset;
+ DisplayOffset = LargestY - SmallestY + 2 + DisplayOffset;
+ }
+ return DisplayOffset;
+}
static void
Layer_Sort_CheckPrev(memory *Memory, int i, int Direction, sorted_layer_array *SortedLayerStart, sorted_comp_array SortedCompStart, int *EntriesPassed, sorted_layer_array *LayerEntry, bool32 AltMethod)
@@ -324,6 +367,14 @@ File_Sort_Push(project_data *File, project_state *State, memory *Memory)
Sorted.PropertyArray = (uint16 *)((uint8 *)Property_SortedArray + PropertyStartSize);
LayerProperty_SortAll(File, State, Memory, Sorted.LayerArray, Sorted.CompArray, Sorted.PropertyStart, Sorted.PropertyArray, File->Layer_Count, File->Comp_Count);
+
+ sorted_comp_array *MainSortedCompStart = &Sorted.CompArray[File->PrincipalCompIndex];
+ sorted_layer_array *MainSortedLayerStart = Sorted_GetLayerStart(Sorted.LayerArray, Sorted.CompArray, File->PrincipalCompIndex);
+ Layer_Sort_DisplayOffset(State, Memory,
+ Sorted.PropertyStart, Sorted.PropertyArray,
+ Sorted.CompArray, Sorted.LayerArray,
+ MainSortedCompStart, Sorted.LayerArray);
+
return Sorted;
}