summaryrefslogtreecommitdiff
path: root/src/createcalls.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/createcalls.cpp')
-rw-r--r--src/createcalls.cpp78
1 files changed, 43 insertions, 35 deletions
diff --git a/src/createcalls.cpp b/src/createcalls.cpp
index ffb4c0f..c082bda 100644
--- a/src/createcalls.cpp
+++ b/src/createcalls.cpp
@@ -789,9 +789,46 @@ Property_IsGraphSelected(memory *Memory, uint16 *Block_Bezier_Index, uint16 *Arr
}
static void
-Sort_OffsetDupes(memory *Memory, sorted_layer_array *SortedLayerStart, block_layer *StartLayer,
- int i, int FauxIncrement, int LayerCount, int Mode)
+Sort_OffsetDupes(project_state *State, memory *Memory, sorted_layer_array *SortedLayerStart,
+ int Direction, int FirstDupeIdx, int LayerCount, int FakeLayerCount)
{
+ int FauxIncrement = 0;
+ int FurthestMark = -1;
+ {
+ sorted_layer_array SortEntry = SortedLayerStart[FirstDupeIdx];
+ uint32 Index_Physical = SortEntry.Block_Layer_Index;
+ block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Index_Physical);
+ FurthestMark = Layer->Vertical_Offset;
+ }
+ // TODO(fox): make this less ghetto
+ if (State->DuplicateMode & sortflag_furthest && !(State->DuplicateMode & sortflag_up))
+ {
+ FauxIncrement = -FakeLayerCount;
+ }
+ int i = (Direction > 0) ? 0 : LayerCount - 1;
+ int Test = 0;
+ for (;;)
+ {
+ 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);
+ if (Layer->IsSelected)
+ Test = 1;
+ if (Test)
+ History_Action_Swap(Memory, F_Layers, sizeof(Layer->Vertical_Offset), &Layer->Vertical_Offset);
+ if (Layer->IsSelected) {
+ if (State->DuplicateMode & sortflag_furthest)
+ Layer->Vertical_Offset = FurthestMark;
+ FauxIncrement += Direction;
+ if (State->DuplicateMode & sortflag_furthest && !(State->DuplicateMode & sortflag_up))
+ Layer->Vertical_Offset += 1;
+ }
+ Layer->Vertical_Offset -= FauxIncrement;
+ int a = 0;
+ i += Direction;
+ if ((Direction > 0) ? (i >= LayerCount) : (i < 0))
+ break;
+ }
}
// NOTE(fox): PrecompLayer is assumed to be untouched from the layer it was duplicated from!
@@ -853,7 +890,7 @@ Project_Layer_Duplicate(project_data *File, project_state *State, memory *Memory
int LayerCount = SortedCompStart.LayerCount + SortedCompStart.FakeLayerCount;
int FirstDupe = -1;
int DupeCount = 0;
- int Direction = (State->DuplicateMode & sortflag_up) ? 1 : -1;
+ int Direction = (State->DuplicateMode & sortflag_up) ? -1 : -1;
if (State->DuplicateMode & sortflag_furthest && !(State->DuplicateMode & sortflag_up))
Direction *= -1;
int i = (Direction > 0) ? 0 : LayerCount - 1;
@@ -905,39 +942,10 @@ Project_Layer_Duplicate(project_data *File, project_state *State, memory *Memory
break;
i += Direction;
}
+ if (State->DuplicateMode & sortflag_up)
+ Direction *= -1;
if (FirstDupe > -1) {
- int FauxIncrement = 0;
- int FurthestMark = -1;
- {
- sorted_layer_array SortEntry = SortedLayerStart[FirstDupe];
- uint32 Index_Physical = SortEntry.Block_Layer_Index;
- block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Index_Physical);
- FurthestMark = Layer->Vertical_Offset;
- }
- if (State->DuplicateMode & sortflag_furthest && !(State->DuplicateMode & sortflag_up))
- {
- FauxIncrement = -SortedCompStart.FakeLayerCount;
- }
- int i = (Direction > 0) ? 0 : LayerCount - 1;
- for (;;)
- {
- 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);
- History_Action_Swap(Memory, F_Layers, sizeof(Layer->Vertical_Offset), &Layer->Vertical_Offset);
- if (Layer->IsSelected) {
- if (State->DuplicateMode & sortflag_furthest)
- Layer->Vertical_Offset = FurthestMark;
- FauxIncrement += Direction;
- if (State->DuplicateMode & sortflag_furthest && !(State->DuplicateMode & sortflag_up))
- Layer->Vertical_Offset += 1;
- }
- Layer->Vertical_Offset -= FauxIncrement;
- int a = 0;
- if ((Direction > 0) ? !(i < LayerCount) : (i <= 0))
- break;
- i += Direction;
- }
+ Sort_OffsetDupes(State, Memory, SortedLayerStart, Direction, FirstDupe, LayerCount, SortedCompArray->FakeLayerCount);
}
}
}