summaryrefslogtreecommitdiff
path: root/src/layer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/layer.cpp')
-rw-r--r--src/layer.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/layer.cpp b/src/layer.cpp
index 3686d75..dfe91a4 100644
--- a/src/layer.cpp
+++ b/src/layer.cpp
@@ -340,7 +340,7 @@ Layer_GetDimensions(memory *Memory, block_layer *Layer, int *Width, int *Height)
}
static v2
-Layer_TraverseForPoint(project_data *File, project_state *State, memory *Memory, v2 PrincipalCompUV, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray)
+Layer_TraverseForPoint(project_data *File, project_state *State, memory *Memory, v2 PrincipalCompUV, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, uint16 LayerIndex)
{
int16 RecursionIdx[MAX_PRECOMP_RECURSIONS] = {};
RecursionIdx[0] = -1;
@@ -348,12 +348,12 @@ Layer_TraverseForPoint(project_data *File, project_state *State, memory *Memory,
sorted_layer_array *SortedLayerStart = Sorted_GetLayerStart(SortedLayerArray, SortedCompArray, File->PrincipalCompIndex);
sorted_comp_array SortedCompStart = SortedCompArray[File->PrincipalCompIndex];
block_composition *Comp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, File->PrincipalCompIndex);
- Layer_Select_Traverse(File->PrincipalCompIndex, Memory, State, State->Brush.LayerToPaint_Index, SortedCompArray, SortedLayerArray, RecursionIdx, &Recursions);
+ Layer_Select_Traverse(File->PrincipalCompIndex, Memory, State, LayerIndex, SortedCompArray, SortedLayerArray, RecursionIdx, &Recursions);
v2 PointUV = {0, 0};
int OuterWidth = Comp->Width, OuterHeight = Comp->Height;
int InnerWidth = 0, InnerHeight = 0;
if (Recursions == 0) {
- block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, State->Brush.LayerToPaint_Index);
+ block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, LayerIndex);
layer_transforms T = Layer_GetTransforms(Layer);
Layer_GetDimensions(Memory, Layer, &InnerWidth, &InnerHeight);
PointUV = T_CompUVToLayerUV(T, OuterWidth, OuterHeight, InnerWidth, InnerHeight, PrincipalCompUV);
@@ -393,9 +393,11 @@ Layer_TestForPoint(memory *Memory, project_state *State, ui *UI, sorted_comp_arr
return 0;
}
+// NOTE(fox): We loop twice to allow for convenient down-travelling when only
+// one layer is selected, toggleable by the BelowOnly bool (i.e. shift held).
// TODO(fox): Precomps?
static int32
-Layer_TestSelection(memory *Memory, project_state *State, ui *UI, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, uint16 PrincipalIndex)
+Layer_TestSelection(memory *Memory, project_state *State, ui *UI, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, uint16 PrincipalIndex, bool32 BelowOnly)
{
block_composition *Comp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, PrincipalIndex);
sorted_comp_array SortedCompStart = SortedCompArray[PrincipalIndex];
@@ -425,9 +427,9 @@ Layer_TestSelection(memory *Memory, project_state *State, ui *UI, sorted_comp_ar
Layer_GetDimensions(Memory, Layer, &Width, &Height);
layer_transforms T = Layer_GetTransforms(Layer);
v2 UV = T_CompUVToLayerUV(T, Comp->Width, Comp->Height, Width, Height, State->LastClickedPoint);
- if (UV.x <= 1.0f && UV.x >= 0.0f && UV.y <= 1.0f && UV.y >= 0.0f && !Layer->IsSelected)
+ if (UV.x <= 1.0f && UV.x >= 0.0f && UV.y <= 1.0f && UV.y >= 0.0f && !Layer->IsSelected && !Layer->IsLocked)
{
- if (SelectionCount == 1) {
+ if (!BelowOnly && SelectionCount == 1) {
if (i < SelectedLayerIndex) {
LayerIndex = Index_Physical;
break;
@@ -566,6 +568,8 @@ Layer_TestBoxSelect(memory *Memory, project_state *State, ui *UI, sorted_comp_ar
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->IsLocked)
+ continue;
if (Layer->IsShapeLayer) {
shape_layer *Shape = &Layer->Shape;
int Width = Shape->Width, Height = Shape->Height;
@@ -585,7 +589,7 @@ Layer_TestBoxSelect(memory *Memory, project_state *State, ui *UI, sorted_comp_ar
int Width, Height;
Layer_GetDimensions(Memory, Layer, &Width, &Height);
if (Transform_TestBox(Layer, Width, Height, MinPos, MaxPos))
- Layer->IsSelected = true;
+ Layer_Select(Memory, State, Index_Physical);
}
}
}