diff options
Diffstat (limited to 'src/createcalls.cpp')
-rw-r--r-- | src/createcalls.cpp | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/src/createcalls.cpp b/src/createcalls.cpp index 800dd49..adb6ff5 100644 --- a/src/createcalls.cpp +++ b/src/createcalls.cpp @@ -450,6 +450,46 @@ void Clipboard_Store(project_data *File, project_state *State, memory *Memory, s } } +void Slide_Init(project_data *File, project_state *State, memory *Memory) +{ + // It's impossible to use the brush while this is active, so for now we can + // just use its buffer to store our data: + uint8 *InteractBuffer = (uint8 *)State->Brush.TransientBitmap; + State->Interact_Count = 0; + int h = 0, c = 0, i = 0; + while (Block_Loop(Memory, F_Layers, File->Layer_Count, &h, &c, &i)) { + block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, i); + if (Layer->IsSelected) { + interact_slide_layer *Interact_Layer = (interact_slide_layer *)InteractBuffer; + *Interact_Layer = {0}; + Interact_Layer->Index = i; + InteractBuffer += sizeof(interact_slide_layer); + State->Interact_Count++; + } + } +} + +void Slide_Test(project_data *File, project_state *State, memory *Memory, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray) +{ + block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, File->PrincipalCompIndex); + v2 CompDimensions = V2(MainComp->Width, MainComp->Height); + real32 Threshold = 5; + uint8 *InteractBuffer = (uint8 *)State->Brush.TransientBitmap; + for (int i = 0; i < State->Interact_Count; i++) { + interact_slide_layer *Interact_Layer = (interact_slide_layer *)InteractBuffer; + InteractBuffer += sizeof(interact_slide_layer); + 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); + int Width, Height; + Layer_GetDimensions(Memory, Layer, &Width, &Height); + if (abs(CompPos.x - LayerPos.x) > Threshold && + abs(CompPos.y - LayerPos.y) > Threshold) + Assert(0); + } +} + void Property_MinMax_X(memory *Memory, project_state *State, property_channel *Property, uint16 *ArrayLocation, real32 *Min, real32 *Max) { @@ -687,10 +727,25 @@ Project_ShapeLayer_New(project_data *File, project_state *State, memory *Memory) Layer_Select(Memory, State, Memory_Block_LazyIndexAtAddress(Memory, F_Layers, Layer)); shape_layer *Shape = &File->UI.Shape; + + if (State->Interact_Modifier == 1) { + v2 *CompPoint = (v2 *)&State->Interact_Offset[0]; + for (int i = 0; i < 4; i++) { + bezier_point PointData = { 1, { CompPoint[i], V2(0, 0), V2(0, 0) }, interpolation_type_linear, 0 }; + Bezier_Add(Memory, F_File, Shape->Block_Bezier_Index, &Shape->Block_Bezier_Count, &Shape->Point_Count, PointData); + CompPoint[i] = {0}; + } + Shape->IsClosed = true; + State->Interact_Modifier = 0; + } + + shape_options ShapeOpt = File->UI.ShapeOpt; + ShapeOpt.FillCol = File->UI.Color; + ShapeOpt.StrokeCol = File->UI.AltColor; v2 Min = {}, Max = {}; void *Data = Memory_PushScratch(Memory, sizeof(nvg_point) * 128); layer_transforms T = {}; - NVG_FlattenPath(Memory, Shape, (nvg_point *)Data, State, T, 0, 0, 0, 0, 0, &Min, &Max); + NVG_FlattenPath(Memory, Shape, ShapeOpt, (nvg_point *)Data, State, T, 0, 0, 0, 0, 0, &Min, &Max); Memory_PopScratch(Memory, sizeof(nvg_point) * 128); Shape->Width = Max.x - Min.x; Shape->Height = Max.y - Min.y; @@ -726,6 +781,8 @@ Project_ShapeLayer_New(project_data *File, project_state *State, memory *Memory) History_Action_Swap(Memory, F_Layers, sizeof(Layer->Shape), &Layer->Shape); Layer->Shape = File->UI.Shape; + History_Action_Swap(Memory, F_Layers, sizeof(Layer->ShapeOpt), &Layer->ShapeOpt); + Layer->ShapeOpt = ShapeOpt; History_Action_Swap(Memory, F_File, sizeof(File->UI.Shape), &File->UI.Shape); File->UI.Shape = {}; |