summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--createcalls.cpp204
-rw-r--r--effects_constructors.cpp11
-rw-r--r--imgui_helper_widgets.cpp5
-rw-r--r--main.cpp178
-rw-r--r--main.h256
-rw-r--r--my_imgui_widgets.cpp527
6 files changed, 558 insertions, 623 deletions
diff --git a/createcalls.cpp b/createcalls.cpp
index d6cfc6c..1e96c74 100644
--- a/createcalls.cpp
+++ b/createcalls.cpp
@@ -190,7 +190,8 @@ Bezier_EvaluateValue(project_state *State, bezier_point *PointAddress, v2 *Pos,
Pos[2] = PointAddress->Pos[2];
if (PointAddress->IsSelected) {
if (State->Interact_Active == interact_type_keyframe_move) {
- Pos[PointAddress->IsSelected - 1].x += (int32)State->Interact_Offset[0];
+ if (State->Interact_Modifier != 2)
+ Pos[PointAddress->IsSelected - 1].x += (int32)State->Interact_Offset[0];
if (State->Interact_Modifier != 1)
Pos[PointAddress->IsSelected - 1].y -= (State->Interact_Offset[1] / GraphZoomHeight / Y_Increment);
} else if (State->Interact_Active == interact_type_keyframe_scale) {
@@ -205,7 +206,7 @@ Bezier_EvaluateValue(project_state *State, bezier_point *PointAddress, v2 *Pos,
static void
-Bezier_Add(memory *Memory, property_channel *Property, bezier_point PointData)
+Bezier_Add(memory *Memory, property_channel *Property, bezier_point PointData, uint16 *ArrayLocation)
{
if (!Property->Block_Bezier_Count) {
Property->Block_Bezier_Index[0] = Memory_Block_AllocateNew(Memory, F_Bezier);
@@ -215,6 +216,18 @@ Bezier_Add(memory *Memory, property_channel *Property, bezier_point PointData)
History_Action_Swap(Memory, F_Layers, sizeof(Property->Block_Bezier_Count), &Property->Block_Bezier_Count);
Property->Block_Bezier_Count++;
}
+ // First check to see if the point to add overlaps an existing keyframe:
+ if (ArrayLocation) {
+ for (int p = 0; p < Property->Keyframe_Count; p++) {
+ int k = ArrayLocation[p];
+ bezier_point *Point = Bezier_LookupAddress(Memory, Property, k);
+ if (Point->Pos[0].x == PointData.Pos[0].x) {
+ History_Action_Swap(Memory, F_Bezier, sizeof(*Point), Point);
+ *Point = PointData;
+ return;
+ }
+ }
+ }
int k = 0;
for (;;) {
bezier_point *Point = Bezier_LookupAddress(Memory, Property, k, 0);
@@ -317,6 +330,19 @@ Effect_Init(project_state *State, memory *Memory, uint32 EffectEntryIndex, int E
return EffectAddressIndex;
}
+static void
+Effect_Add(project_data *File, project_state *State, memory *Memory, uint32 EffectEntryIndex)
+{
+ 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) {
+ Layer->Block_Effect_Index[Layer->Block_Effect_Count] = Effect_Init(State, Memory, EffectEntryIndex, Layer->Block_Effect_Count);
+ Layer->Block_Effect_Count++;
+ }
+ }
+}
static void
Layer_UpdateMasksEffects(project_state *State, block_layer *Layer, memory *Memory, void *EffectBitmapAddress,
@@ -384,7 +410,7 @@ Layer_Select(memory *Memory, project_state *State, int32 i)
block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, i);
Layer->IsSelected = true;
State->MostRecentlySelectedLayer = i;
- // State->RecentSelectionType = selection_layer;
+ State->RecentSelectionType = selection_type_layer;
}
void Layer_DeselectAll(project_data *File, project_state *State, memory *Memory) {
@@ -405,12 +431,59 @@ void Source_DeselectAll(project_data *File, memory *Memory)
}
}
+inline sorted_property_info *
+Property_GetSortedInfo(sorted_property_info *SortedPropertyInfo, int i, int h)
+{
+ return SortedPropertyInfo + (i * 8) + h;
+}
+inline uint16 *
+Property_GetSortedArray(uint16 *SortedPropertyArray, int i, int h)
+{
+ return SortedPropertyArray + (i * 8 * MAX_KEYFRAMES_PER_BLOCK) + (h * MAX_KEYFRAMES_PER_BLOCK);
+}
+
+static void
+Bezier_Commit(project_data *File, project_state *State, memory *Memory, uint16 *SortedPropertyArray) {
+ History_Entry_Commit(Memory, "Move keyframe");
+ 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 ((State->TimelineMode == timeline_mode_graph) && !Layer->IsSelected)
+ continue;
+ for (int h = 0; h < AmountOf(Layer->Property); h++) {
+ uint16 *ArrayLocation = Property_GetSortedArray(SortedPropertyArray, i, h);
+ property_channel *Property = &Layer->Property[h];
+ if ((State->TimelineMode != timeline_mode_graph) && !Property->IsToggled)
+ continue;
+ for (int p = 0; p < Property->Keyframe_Count; p++) {
+ int k = ArrayLocation[p];
+ bezier_point *PointAddress = Bezier_LookupAddress(Memory, Property, k);
+ if (PointAddress->IsSelected) {
+ v2 NewPos[3];
+ Bezier_EvaluateValue(State, PointAddress, NewPos);
+ History_Action_Swap(Memory, F_Bezier, sizeof(PointAddress->Pos), &PointAddress->Pos);
+ PointAddress->Pos[0] = NewPos[0];
+ PointAddress->Pos[1] = NewPos[1];
+ PointAddress->Pos[2] = NewPos[2];
+ }
+ }
+ }
+ }
+ History_Entry_End(Memory);
+ State->Interact_Offset[0] = 0;
+ State->Interact_Offset[1] = 0;
+ State->Interact_Offset[2] = 0;
+ State->Interact_Offset[3] = 0;
+ State->Interact_Active = interact_type_none;
+ State->Interact_Modifier = 0;
+}
+
// NOTE(fox): This won't work with precomps!
-void Clipboard_Paste(project_data *File, project_state *State, memory *Memory, sorted_comp_info *SortedCompInfo, sorted_layer *SortedLayerInfo)
+void Clipboard_Paste(project_data *File, project_state *State, memory *Memory, sorted_comp_info *SortedCompInfo, sorted_layer *SortedLayerInfo, uint16 *SortedPropertyArray)
{
clipboard_contents *Contents = (clipboard_contents *)State->ClipboardBuffer;
- if (Contents->Type == selection_none)
+ if (Contents->Type == selection_type_none)
return;
uint64 ClipboardPos = sizeof(clipboard_contents);
ClipboardPos = sizeof(clipboard_contents);
@@ -454,7 +527,8 @@ void Clipboard_Paste(project_data *File, project_state *State, memory *Memory, s
for (int p = 0; p < Channel->KeyframeCount; p++) {
bezier_point PointData = *(bezier_point *)((uint8 *)State->ClipboardBuffer + ClipboardPos);
PointData.Pos[0].x += State->Frame_Current;
- Bezier_Add(Memory, Property, PointData);
+ uint16 *ArrayLocation = Property_GetSortedArray(SortedPropertyArray, i, h);
+ Bezier_Add(Memory, Property, PointData, ArrayLocation);
ClipboardPos += sizeof(bezier_point);
}
b++;
@@ -471,94 +545,56 @@ void Clipboard_Paste(project_data *File, project_state *State, memory *Memory, s
}
}
-inline sorted_property_info *
-Property_GetSortedInfo(sorted_property_info *SortedPropertyInfo, int i, int h)
-{
- return SortedPropertyInfo + (i * 8) + h;
-}
-inline uint16 *
-Property_GetSortedArray(uint16 *SortedPropertyArray, int i, int h)
-{
- return SortedPropertyArray + (i * 8 * MAX_KEYFRAMES_PER_BLOCK) + (h * MAX_KEYFRAMES_PER_BLOCK);
-}
-
-static void
-Bezier_Commit(project_data *File, project_state *State, memory *Memory, uint16 *SortedPropertyArray) {
- History_Entry_Commit(Memory, "Move keyframe");
- 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)
- continue;
- for (int h = 0; h < AmountOf(Layer->Property); h++) {
- uint16 *ArrayLocation = Property_GetSortedArray(SortedPropertyArray, i, h);
- property_channel *Property = &Layer->Property[h];
- for (int p = 0; p < Property->Keyframe_Count; p++) {
- int k = ArrayLocation[p];
- bezier_point *PointAddress = Bezier_LookupAddress(Memory, Property, k);
- if (PointAddress->IsSelected) {
- v2 NewPos[3];
- Bezier_EvaluateValue(State, PointAddress, NewPos);
- History_Action_Swap(Memory, F_Bezier, sizeof(PointAddress->Pos), &PointAddress->Pos);
- PointAddress->Pos[0] = NewPos[0];
- PointAddress->Pos[1] = NewPos[1];
- PointAddress->Pos[2] = NewPos[2];
- }
- }
- }
- }
- History_Entry_End(Memory);
- State->Interact_Offset[0] = 0;
- State->Interact_Offset[1] = 0;
- State->Interact_Offset[2] = 0;
- State->Interact_Offset[3] = 0;
- State->Interact_Active = interact_type_none;
- State->Interact_Modifier = 0;
-}
-
void Clipboard_Store(project_data *File, project_state *State, memory *Memory, sorted_comp_info *SortedCompInfo, sorted_layer *SortedLayerInfo, sorted_property_info *SortedPropertyInfo, uint16 *SortedPropertyArray)
{
int LocalOffset = 0;
clipboard_contents *Contents = (clipboard_contents *)State->ClipboardBuffer;
*Contents = {};
+ Contents->Type = State->RecentSelectionType;
uint64 ClipboardPos = sizeof(clipboard_contents);
- for (int i = SortedCompInfo->LayerCount - 1; i >= 0; i--)
- {
- sorted_layer SortEntry = SortedLayerInfo[i];
- uint32 Index_Physical = SortEntry.Block_Layer_Index;
- block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Index_Physical);
- for (int h = 0; h < AmountOf(Layer->Property); h++) {
- property_channel *Property = &Layer->Property[h];
- if (Property->IsToggled || Layer->IsSelected) {
- sorted_property_info *InfoLocation = Property_GetSortedInfo(SortedPropertyInfo, i, h);
- uint16 *ArrayLocation = Property_GetSortedArray(SortedPropertyArray, i, h);
- clipboard_channel *Channel = &Contents->Channel[Contents->ChannelCount];
- bezier_point *FirstPoint = NULL;
- int TimeOffset = 0;
- for (int p = 0; p < Property->Keyframe_Count; p++) {
- bezier_point *PointAddress = Bezier_LookupAddress(Memory, Property, ArrayLocation[p]);
- if (PointAddress->IsSelected) {
- if (!FirstPoint) {
- FirstPoint = PointAddress;
- TimeOffset = FirstPoint->Pos[0].x;
+ if (Contents->Type == selection_type_none)
+ return;
+ else if (Contents->Type == selection_type_keyframe) {
+ for (int i = SortedCompInfo->LayerCount - 1; i >= 0; i--)
+ {
+ sorted_layer SortEntry = SortedLayerInfo[i];
+ uint32 Index_Physical = SortEntry.Block_Layer_Index;
+ block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Index_Physical);
+ for (int h = 0; h < AmountOf(Layer->Property); h++) {
+ property_channel *Property = &Layer->Property[h];
+ if (Property->IsToggled || Layer->IsSelected) {
+ sorted_property_info *InfoLocation = Property_GetSortedInfo(SortedPropertyInfo, i, h);
+ uint16 *ArrayLocation = Property_GetSortedArray(SortedPropertyArray, i, h);
+ clipboard_channel *Channel = &Contents->Channel[Contents->ChannelCount];
+ bezier_point *FirstPoint = NULL;
+ int TimeOffset = 0;
+ for (int p = 0; p < Property->Keyframe_Count; p++) {
+ bezier_point *PointAddress = Bezier_LookupAddress(Memory, Property, ArrayLocation[p]);
+ if (PointAddress->IsSelected) {
+ if (!FirstPoint) {
+ FirstPoint = PointAddress;
+ TimeOffset = FirstPoint->Pos[0].x;
+ }
+ bezier_point PointToCopy = *PointAddress;
+ PointToCopy.Pos[0].x -= TimeOffset;
+ Memory_Copy((uint8 *)State->ClipboardBuffer + ClipboardPos, (uint8 *)&PointToCopy, sizeof(bezier_point));
+ ClipboardPos += sizeof(bezier_point);
+ Channel->KeyframeCount++;
}
- bezier_point PointToCopy = *PointAddress;
- PointToCopy.Pos[0].x -= TimeOffset;
- Memory_Copy((uint8 *)State->ClipboardBuffer + ClipboardPos, (uint8 *)&PointToCopy, sizeof(bezier_point));
- ClipboardPos += sizeof(bezier_point);
- Channel->KeyframeCount++;
}
- }
- if (Channel->KeyframeCount) {
- if (!LocalOffset)
- LocalOffset = i;
- Contents->ChannelCount++;
- Channel->LayerOffset = LocalOffset - i;
- Channel->Name = Property->Name;
+ if (Channel->KeyframeCount) {
+ if (!LocalOffset)
+ LocalOffset = i;
+ Contents->ChannelCount++;
+ Channel->LayerOffset = LocalOffset - i;
+ Channel->Name = Property->Name;
+ }
}
}
}
}
+ else if (Contents->Type == selection_type_layer) {
+ }
}
static sorted_layer *
@@ -1072,8 +1108,8 @@ void Precomp_UICreateButton(project_data *File, project_state *State, memory *Me
block_layer *PrecompLayer = Layer_Init(File, Memory);
bezier_point Point0 = { 1, {0, 0, 1, 0, 1, 0}, interpolation_type_linear, 0, {0, 0, 0}, 0 };
bezier_point Point1 = { 1, {(real32)NewComp->Frame_End, (real32)NewComp->Frame_End, 1, 0, 1, 0}, interpolation_type_linear, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, &PrecompLayer->time, Point0);
- Bezier_Add(Memory, &PrecompLayer->time, Point1);
+ Bezier_Add(Memory, &PrecompLayer->time, Point0, NULL);
+ Bezier_Add(Memory, &PrecompLayer->time, Point1, NULL);
PrecompLayer->IsPrecomp = true;
Layer_Select(Memory, State, Memory_Block_LazyIndexAtAddress(Memory, F_Layers, PrecompLayer));
PrecompLayer->Block_Source_Index = File->Comp_Count - 1;
diff --git a/effects_constructors.cpp b/effects_constructors.cpp
index 04594b6..13fec9a 100644
--- a/effects_constructors.cpp
+++ b/effects_constructors.cpp
@@ -20,13 +20,14 @@ Effect_EndEntry(project_state *State)
}
static void
-Effect_AddProperty_Real(project_state *State, char *Name, real32 DefaultValue, real32 MinVal = -999999, real32 MaxVal = 999999)
+Effect_AddProperty_Real(project_state *State, char *Name, real32 DefaultValue, real32 MinVal = -999999, real32 MaxVal = 999999, property_display_type DisplayType = property_display_type_standard)
{
header_effect *Effect = &State->Effect[State->Playhead_Effect];
Effect->Property_Count++;
header_property *Property = &State->Property[State->Playhead_Property++];
Property->Name = Name;
Property->DefaultValue = DefaultValue;
+ Property->DisplayType = DisplayType;
Property->MinVal = MinVal;
Property->MaxVal = MaxVal;
}
@@ -34,10 +35,10 @@ Effect_AddProperty_Real(project_state *State, char *Name, real32 DefaultValue, r
static void
Effect_AddProperty_Col(project_state *State, char *Name, v4 DefaultValue)
{
- Effect_AddProperty_Real(State, "r", DefaultValue.r, 0, 1);
- Effect_AddProperty_Real(State, "g", DefaultValue.r, 0, 1);
- Effect_AddProperty_Real(State, "b", DefaultValue.r, 0, 1);
- Effect_AddProperty_Real(State, "a", DefaultValue.r, 0, 1);
+ Effect_AddProperty_Real(State, "r", DefaultValue.r, 0, 1, property_display_type_color);
+ Effect_AddProperty_Real(State, "g", DefaultValue.g, 0, 1, property_display_type_color);
+ Effect_AddProperty_Real(State, "b", DefaultValue.b, 0, 1, property_display_type_color);
+ Effect_AddProperty_Real(State, "a", DefaultValue.a, 0, 1, property_display_type_color);
}
static void
diff --git a/imgui_helper_widgets.cpp b/imgui_helper_widgets.cpp
index e55a5e7..231b4b9 100644
--- a/imgui_helper_widgets.cpp
+++ b/imgui_helper_widgets.cpp
@@ -85,9 +85,10 @@ ImGui_Brush_CalcMousePos(project_state *State, ImGuiIO &io, ImVec2 MouseDelta, i
return MousePos;
}
-static void
+static bool32
ImGui_TestBoxSelection_Point(ImVec2 Pos, ImGuiIO &io, bool32 *Test)
{
+ bool32 Result = 0;
real32 Y_Top = (io.MouseClickedPos[0].y < io.MousePos.y) ? io.MouseClickedPos[0].y : io.MousePos.y;
real32 Y_Bottom = (io.MouseClickedPos[0].y > io.MousePos.y) ? io.MouseClickedPos[0].y : io.MousePos.y;
real32 X_Left = (io.MouseClickedPos[0].x < io.MousePos.x) ? io.MouseClickedPos[0].x : io.MousePos.x;
@@ -98,8 +99,10 @@ ImGui_TestBoxSelection_Point(ImVec2 Pos, ImGuiIO &io, bool32 *Test)
{
if (!(*Test)) {
*Test = 1;
+ Result = 1;
}
} else if (!io.KeyShift) {
*Test = 0;
}
+ return Result;
}
diff --git a/main.cpp b/main.cpp
index a7788ad..e880d8c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -159,7 +159,7 @@ Main_InputTest(project_data *File, project_state *State, memory *Memory, ui *UI,
} break;
case hotkey_paste:
{
- Clipboard_Paste(File, State, Memory, Sorted.CompArray, Sorted.LayerArray);
+ Clipboard_Paste(File, State, Memory, Sorted.CompArray, Sorted.LayerArray, Sorted.PropertyArray);
} break;
}
State->HotkeyInput = hotkey_none;
@@ -176,21 +176,20 @@ Main_InputTest(project_data *File, project_state *State, memory *Memory, ui *UI,
}
#endif
- ImGui_Popups(File, State, UI, Memory, io);
if (State->FocusedWindow == focus_viewport && State->SetFocus) {
ImGui::SetNextWindowFocus();
State->SetFocus = false;
}
- ImGui_Viewport(File, State, UI, Memory, io, textureID, Sorted.CompArray, Sorted.LayerArray);
+ ImGui_Viewport(File, State, UI, Memory, io, textureID, Sorted.CompArray, Sorted.LayerArray, Sorted.PropertyArray);
if (State->FocusedWindow == focus_timeline && State->SetFocus) {
ImGui::SetNextWindowFocus();
State->SetFocus = false;
}
ImGui_Timeline(File, State, Memory, UI, io, Sorted.CompArray, Sorted.LayerArray, Sorted.PropertyInfo, Sorted.PropertyArray);
ImGui_File(File, State, Memory, io, Sorted.CompArray, Sorted.LayerArray);
- ImGui_PropertiesPanel(File, State, UI, Memory, io);
+ ImGui_PropertiesPanel(File, State, UI, Memory, io, Sorted.PropertyArray);
ImGui_ColorPanel(File, State, UI, Memory, io);
- // ImGui_EffectsPanel(File, State, Memory, UI, io);
+ ImGui_EffectsPanel(File, State, Memory, UI, io);
#if STABLE
if (UI->StableEnabled) {
ImGui_SD_Prompt(File, State, UI, Memory, io, Sorted.CompArray, Sorted.LayerArray);
@@ -198,6 +197,7 @@ Main_InputTest(project_data *File, project_state *State, memory *Memory, ui *UI,
}
#endif
ImGui_Menu(File, State, UI, Memory, io);
+ ImGui_Popups(File, State, UI, Memory, io); // NOTE(fox): If popup disappears unexpectedly it means something else took its focus!
File_Sort_Pop(Memory, Sorted.Layer_SortSize, Sorted.Property_SortSize, Sorted.Source_SortSize);
@@ -382,173 +382,6 @@ Render_Comp(project_data *File, project_state *State, memory *Memory, ImGuiIO io
return CompBuffer;
}
-static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]\n"
-"Pos=0,0\n"
-"Size=2133,1333\n"
-"Collapsed=0\n"
-"\n"
-"[Window][Debug##Default]\n"
-"Pos=122,442\n"
-"Size=400,400\n"
-"Collapsed=0\n"
-"\n"
-"[Window][Viewport]\n"
-"Pos=443,34\n"
-"Size=1165,738\n"
-"Collapsed=0\n"
-"DockId=0x00000010,0\n"
-"\n"
-"[Window][###Properties]\n"
-"Pos=0,34\n"
-"Size=441,738\n"
-"Collapsed=0\n"
-"DockId=0x0000000B,0\n"
-"\n"
-"[Window][Timeline]\n"
-"Pos=0,774\n"
-"Size=2133,559\n"
-"Collapsed=0\n"
-"DockId=0x0000000A,0\n"
-"\n"
-"[Window][Dear ImGui Demo]\n"
-"Pos=1610,34\n"
-"Size=523,267\n"
-"Collapsed=0\n"
-"DockId=0x00000011,1\n"
-"\n"
-"[Window][Files]\n"
-"Pos=1610,303\n"
-"Size=523,469\n"
-"Collapsed=0\n"
-"DockId=0x00000007,0\n"
-"\n"
-"[Window][Effects list]\n"
-"Pos=2677,1047\n"
-"Size=523,192\n"
-"Collapsed=0\n"
-"DockId=0x00000008,0\n"
-"\n"
-"[Window][Graph editor]\n"
-"Pos=0,949\n"
-"Size=3200,526\n"
-"Collapsed=0\n"
-"DockId=0x00000009,0\n"
-"\n"
-"[Window][undotree]\n"
-"Pos=2114,80\n"
-"Size=256,565\n"
-"Collapsed=0\n"
-"\n"
-"[Window][memoryviewer]\n"
-"Pos=50,273\n"
-"Size=800,200\n"
-"Collapsed=0\n"
-"\n"
-"[Window][Example: Custom rendering]\n"
-"Pos=758,789\n"
-"Size=485,414\n"
-"Collapsed=0\n"
-"\n"
-"[Window][Memory viewer]\n"
-"Pos=1610,303\n"
-"Size=523,469\n"
-"Collapsed=0\n"
-"DockId=0x00000007,1\n"
-"\n"
-"[Window][Graph info]\n"
-"Pos=2838,1265\n"
-"Size=235,353\n"
-"Collapsed=0\n"
-"\n"
-"[Window][Properties]\n"
-"Pos=0,34\n"
-"Size=495,1056\n"
-"Collapsed=0\n"
-"DockId=0x0000000F,0\n"
-"\n"
-"[Window][Colors]\n"
-"Pos=1610,34\n"
-"Size=523,267\n"
-"Collapsed=0\n"
-"DockId=0x00000011,0\n"
-"\n"
-"[Window][Menu]\n"
-"Pos=0,0\n"
-"Size=2133,32\n"
-"Collapsed=0\n"
-"DockId=0x0000000D,0\n"
-"\n"
-"[Window][Stable Diffusion]\n"
-"Pos=2206,684\n"
-"Size=421,462\n"
-"Collapsed=0\n"
-"\n"
-"[Window][SD prompt input]\n"
-"Pos=2677,473\n"
-"Size=523,541\n"
-"Collapsed=0\n"
-"DockId=0x00000007,2\n"
-"\n"
-"[Window][Example: Console]\n"
-"Pos=747,851\n"
-"Size=520,600\n"
-"Collapsed=0\n"
-"\n"
-"[Window][SD gallery]\n"
-"Pos=0,718\n"
-"Size=441,557\n"
-"Collapsed=0\n"
-"DockId=0x0000000C,0\n"
-"\n"
-"[Window][Save as]\n"
-"Pos=300,800\n"
-"Size=300,300\n"
-"Collapsed=0\n"
-"\n"
-"[Table][0x861D378E,3]\n"
-"Column 0 Weight=1.0000\n"
-"Column 1 Weight=1.0000\n"
-"Column 2 Weight=1.0000\n"
-"\n"
-"[Table][0x1F146634,3]\n"
-"RefScale=13\n"
-"Column 0 Width=63\n"
-"Column 1 Width=63\n"
-"Column 2 Width=63\n"
-"\n"
-"[Table][0x64418101,3]\n"
-"RefScale=13\n"
-"Column 0 Width=63\n"
-"Column 1 Width=63\n"
-"Column 2 Width=63\n"
-"\n"
-"[Table][0xC9935533,3]\n"
-"Column 0 Weight=1.0000\n"
-"Column 1 Weight=1.0000\n"
-"Column 2 Weight=1.0000\n"
-"\n"
-"[Docking][Data]\n"
-"DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,0 Size=2133,1333 Split=Y Selected=0x13926F0B\n"
-" DockNode ID=0x0000000D Parent=0x8B93E3BD SizeRef=3200,32 HiddenTabBar=1 Selected=0xA57AB2C6\n"
-" DockNode ID=0x0000000E Parent=0x8B93E3BD SizeRef=3200,1299 Split=Y\n"
-" DockNode ID=0x00000001 Parent=0x0000000E SizeRef=3200,1205 Split=X Selected=0x13926F0B\n"
-" DockNode ID=0x00000003 Parent=0x00000001 SizeRef=441,1171 Split=Y Selected=0xDBB8CEFA\n"
-" DockNode ID=0x0000000B Parent=0x00000003 SizeRef=521,425 Selected=0xDBB8CEFA\n"
-" DockNode ID=0x0000000C Parent=0x00000003 SizeRef=521,347 Selected=0x56290987\n"
-" DockNode ID=0x00000004 Parent=0x00000001 SizeRef=1690,1171 Split=X Selected=0x13926F0B\n"
-" DockNode ID=0x00000005 Parent=0x00000004 SizeRef=1165,1171 Split=X Selected=0x13926F0B\n"
-" DockNode ID=0x0000000F Parent=0x00000005 SizeRef=495,856 Selected=0x199AB496\n"
-" DockNode ID=0x00000010 Parent=0x00000005 SizeRef=2199,856 CentralNode=1 Selected=0x13926F0B\n"
-" DockNode ID=0x00000006 Parent=0x00000004 SizeRef=523,1171 Split=Y Selected=0x86FA2F90\n"
-" DockNode ID=0x00000011 Parent=0x00000006 SizeRef=483,437 Selected=0xBF7DFDC9\n"
-" DockNode ID=0x00000012 Parent=0x00000006 SizeRef=483,766 Split=Y Selected=0x59A2A092\n"
-" DockNode ID=0x00000007 Parent=0x00000012 SizeRef=523,572 Selected=0x86FA2F90\n"
-" DockNode ID=0x00000008 Parent=0x00000012 SizeRef=523,192 Selected=0x812F222D\n"
-" DockNode ID=0x00000002 Parent=0x0000000E SizeRef=3200,559 Split=Y Selected=0x0F18B61B\n"
-" DockNode ID=0x00000009 Parent=0x00000002 SizeRef=3250,526 Selected=0xA1F22F4D\n"
-" DockNode ID=0x0000000A Parent=0x00000002 SizeRef=3250,323 HiddenTabBar=1 Selected=0x0F18B61B\n"
-"\n";
-
static void
Main_Renderer(project_data *File, project_state *State, memory *Memory, SDL_Window *window, GLuint textureID, ImGuiIO io)
{
@@ -716,6 +549,7 @@ int main(int argc, char *argv[]) {
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
+ // SDL_RenderSetScale(renderer, 2, 2)
#if DEBUG
#if ARM
uint32 ScreenSize[2] = {(uint32)(2560/1.2), (uint32)(1600/1.2)};
diff --git a/main.h b/main.h
index 3b9cd38..ce7dac5 100644
--- a/main.h
+++ b/main.h
@@ -92,9 +92,9 @@ struct block_bezier {
enum selection_type
{
- selection_none,
- selection_layer,
- selection_keyframe
+ selection_type_none,
+ selection_type_layer,
+ selection_type_keyframe
};
struct clipboard_channel {
@@ -212,6 +212,7 @@ enum interact_type
{
interact_type_none,
interact_type_timeline_scrub,
+ interact_type_slider_scrub,
interact_type_layer_move,
interact_type_layer_timeadjust,
interact_type_viewport_transform,
@@ -367,7 +368,7 @@ struct project_state
// NOTE(fox): Try to use this only where you actually need it (the
// ambiguous case of copying keyframes versus layers), since this state
// transfer will get buggy if you expand it to everything.
- selection_type RecentSelectionType = selection_none;
+ selection_type RecentSelectionType = selection_type_none;
interact_type Interact_Active;
int32 Interact_Modifier;
@@ -662,250 +663,3 @@ struct render_entry {
rectangle RenderRegion;
};
-#if 0
-
-struct cached_bitmap {
- uint32 SourceIndex; // Which source it belongs to. Currently used to dereference the bitmap.
- void *Data; // Unpacked data loaded from the source file.
- uint32 Frame; // What frame it is.
-};
-
-struct gl_effect_layer {
- bool32 Initialized;
- GLuint Texture;
- GLuint FramebufferObject;
- uint32 Color_Renderbuffer;
- uint32 Stencil_Renderbuffer;
-};
-
-
-// Bitmaps from files are loaded into these temporary cache blocks.
-
-
-// NOTE(fox): I use the term "comp" (composition) to mean the canvas that is
-// being rendered to, since it's what I'm used to from AE.
-struct comp_buffer {
- uint16 Width;
- uint16 Height;
- uint16 BytesPerPixel;
- void *PackedBuffer;
- void *UnpackedBuffer;
-};
-
-struct mask_point {
- v2 Pos;
- bool32 HandleBezier;
- bool32 IsSelected;
- v2 TangentLeft;
- v2 TangentRight;
-};
-
-struct mask {
- mask_point Point[16];
- bool32 IsClosed;
- uint16 NumberOfPoints;
- uint16 NumberOfSelectedPoints;
- void *TriangulatedPointCache;
- uint32 NumberOfVerts;
-};
-
-
-struct main_sdl
-{
- SDL_Texture *Texture;
- SDL_Event Event;
- SDL_Window *Window;
- SDL_Renderer *Renderer;
-};
-
-char *ToolName[] {
- "Move",
- "Pen"
-};
-
-enum tool {
- tool_default,
- tool_pen,
- tool_count
-};
-
-struct pen_state {
- bool32 IsActive;
-};
-
-struct brush_tool
-{
- real32 Size;
- real32 Opacity;
- real32 Hardness;
-};
-
-enum focused_window
-{
- focus_viewport,
- focus_properties,
- focus_timeline
-};
-
-struct ui_graph {
- property_channel *ChannelViewed;
- real32 WindowYOffset = 300;
- real32 UpperVal;
- real32 LowerVal;
- uint16 GraphWindowHeight; // The size of the window enclosing the graph
-};
-
-struct ui
-{
- real32 TimelineSplit = 600;
- real32 GraphPropsSplit = 200;
- real32 TimelineZoom;
- real32 GraphZoom = 30;
-
- // Under 1 is zoomed in!
- real32 TimelinePercentZoomed = 1.0f;
- real32 TimelinePercentOffset = 0.3f;
-
- real32 Default_Y_TimelinePercentZoomed = 1.2f;
- real32 Default_Y_TimelinePercentOffset = 0.0f;
-
- real32 Y_TimelinePercentZoomed;
- real32 Y_TimelinePercentOffset;
-
- bool32 IsDragging;
- bool32 IsTransforming;
- int32 Wrap_X = 0;
- int32 Wrap_Y = 0;
- real32 TempVal;
- real32 TempVal_X;
- real32 OldVal[4];
-
- real32 Y_MaxVal;
- real32 Y_MinVal;
-
- real32 Display_Y_MaxVal;
- real32 Display_Y_MinVal;
-
- bool32 WantSetPos = false;
- ImVec2 SetPos;
- real32 InitPos;
- int32 WrapDirection;
-
- // Note that I don't use "zoom" to mean the scale in relation to the
- // original (i.e. default = 1.0f); it's the literal screen size in pixels
- // of the composition in the UI.
- ImVec2 CompZoom;
- ImVec2 CompPos;
-
- // Used to set UI values on the first frame. Some UI setup in Docking takes
- // more than 1 frame for some reason, so I'm temporarily extending it.
- bool32 Initializing = 4;
-
- // Custom scrolling for the timeline, as ImGui's didn't work well
- real32 ScrollXOffset;
- real32 ScrollYOffset;
-
- // Custom scrolling for the timeline, as ImGui's didn't work well
- real32 G_ScrollXOffset;
- real32 G_ScrollYOffset;
-
- // NOTE(fox): Keeping track of mouse delta myself since the ImGui threshold
- // dragging API doesn't let you do things like subtract the delta easily.
- real32 DraggingKeyframeThreshold;
- real32 DraggingLayerThreshold;
- real32 DraggingTimelineThreshold;
- real32 DraggingEffectThreshold;
- real32 KeyframeSpacing = 6;
-
- ImVec2 BoxStart = ImVec2(0,0);
- ImVec2 BoxEnd = ImVec2(0,0);
- bool32 BoxSelectActive = false;
-
- // Temporary varibles used when zooming in/out
- v2 TempZoomRatio = V2(1, 1);
- real32 TempZoomRatioTimeline = 0;
- real32 TempZoomRatioGraph = 0;
-
- focused_window FocusedWindow; // Convenience for adding window-specific hotkeys.
-
- ui_graph Graph[4];
- uint16 NumberOfGraphsEnabled;
-
- bool32 TemporaryUpdateOverride;
-};
-
-struct imgui_buttonstate
-{
- bool32 IsItemHovered;
- bool32 IsItemActive;
- bool32 IsItemActivated;
- bool32 IsItemDeactivated;
- bool32 LeftClick;
- bool32 RightClick;
-};
-
-struct timeline_properties
-{
- rectangle Timeline;
-
- v2i MainWindow;
- uint16 WindowPadding;
-
- rectangle EffectPanel;
-
- rectangle Toolbar;
- rectangle ColorPanel;
-
- bool32 RenderSlidingBrush;
-
- uint16 CompX;
- uint16 CompY;
- uint16 TimelineZoom;
- uint16 CompScale;
- uint16 FramePadding;
- uint16 LayerPadding;
- uint16 TimelineCurrentFrame;
- int16 TimelineCurrentLayer; // Signed as a shortcut for invalid on -1
- uint16 InfoTimelineSplit;
- bool32 DrawTimeline;
- bool32 DrawEffectPanel;
- bool32 DrawComp;
-};
-
-struct sdl_button
-{
- bool32 IsDown;
- bool32 SingleClick; // More precisely, when button is released and no dragging/selecting events are happening.
- int HeldLength;
-};
-
-struct sdl_input
-{
- v2i Mouse;
- sdl_button MouseButton[3];
- rectangle Selection;
-};
-
-struct render_queue
-{
- project_data *File;
- project_state *State;
- comp_buffer *CompBuffer;
-};
-
-struct thread_info
-{
- render_queue *RenderInfo;
- uint16 Index;
-};
-
-struct work_queue_entry {
- char *StringToPrint;
-};
-
-struct render_entry {
- rectangle RenderRegion;
-};
-
-#endif
-
diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp
index cd23b98..163a15f 100644
--- a/my_imgui_widgets.cpp
+++ b/my_imgui_widgets.cpp
@@ -4,33 +4,39 @@
#include "imgui_helper_widgets.cpp"
static void
-ImGui_InteractSliderProperty(project_state *State, memory *Memory, property_channel *Property, char *Name)
+ImGui_PropertyInteract_Slider(project_state *State, memory *Memory, property_channel *Property, ImGuiIO &io, ImVec2 WindowMinAbs, ImVec2 WindowMaxAbs, memory_table_list Table)
{
- ImGui::DragScalar(Name, ImGuiDataType_Float, &Property->CurrentValue,
- Property->ScrubVal, &Property->MinVal, &Property->MaxVal, "%f");
if (ImGui::IsItemActive()) {
State->UpdateFrame = true;
+ ImGui_WarpMouse(State, io.MousePos, WindowMinAbs, WindowMaxAbs, 1);
}
- /*
+
if (ImGui::IsItemActivated()) {
- State->InteractCache[0] = Property->CurrentValue.f;
+ State->Interact_Offset[0] = Property->CurrentValue;
+ State->Interact_Active = interact_type_slider_scrub;
}
if (ImGui::IsItemDeactivatedAfterEdit()) {
+ // Pressing Esc while dragging a slider conveniently stops the input in
+ // ImGui, so all we need to do is set it back:
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
- Property->CurrentValue.f = State->InteractCache[0];
- } else {
- History_Entry_Commit(Memory, action_entry_default, "Tranforms interact");
- History_Action_Change(Memory, &Property->CurrentValue.f, &State->InteractCache[0],
- &Property->CurrentValue.f, action_type_change_r32);
+ Property->CurrentValue = State->Interact_Offset[0];
+ } else if (!Property->Keyframe_Count) {
+ History_Entry_Commit(Memory, "Property interact");
+ real32 Temp = Property->CurrentValue;
+ Property->CurrentValue = State->Interact_Offset[0];
+ History_Action_Swap(Memory, Table, sizeof(Property->CurrentValue), &Property->CurrentValue);
+ Property->CurrentValue = Temp;
History_Entry_End(Memory);
}
+ State->Interact_Active = interact_type_none;
State->UpdateFrame = true;
+ State->Warp_X = 0;
+ State->Warp_Y = 0;
}
- */
}
static void
-ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io)
+ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io, uint16 *SortedPropertyArray)
{
bool32 Display = 1;
block_layer *Layer = NULL;
@@ -48,6 +54,9 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *
ImGui::Begin(buf);
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows))
State->FocusedWindow = focus_properties;
+ ImVec2 WindowSize = ImGui::GetWindowSize();
+ ImVec2 WindowMinAbs = ImGui::GetWindowPos();
+ ImVec2 WindowMaxAbs = WindowMinAbs + WindowSize;
ImGui::Text("Transform");
for (int h = 0; h < AmountOf(Layer->Property); h++) {
property_channel *Property = &Layer->Property[h];
@@ -55,12 +64,14 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *
if (ImGui::Button("K")) {
History_Entry_Commit(Memory, "Add keyframe");
bezier_point Point = { 1, {(real32)State->Frame_Current, Property->CurrentValue, -1, 0, 1, 0}, interpolation_type_linear, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, Property, Point);
+ uint16 *ArrayLocation = Property_GetSortedArray(SortedPropertyArray, State->MostRecentlySelectedLayer, h);
+ Bezier_Add(Memory, Property, Point, ArrayLocation);
History_Entry_End(Memory);
}
ImGui::SameLine();
char *Name = DefaultChannel[h];
- ImGui_InteractSliderProperty(State, Memory, Property, Name);
+ ImGui::DragScalar(Name, ImGuiDataType_Float, &Property->CurrentValue, Property->ScrubVal, &Property->MinVal, &Property->MaxVal, "%f");
+ ImGui_PropertyInteract_Slider(State, Memory, Property, io, WindowMinAbs, WindowMaxAbs, F_Layers);
ImGui::PopID();
}
for (int i = 0; i < Layer->Block_Effect_Count; i++)
@@ -76,14 +87,21 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory *
property_channel *Property = (property_channel *)Memory_Block_AddressAtIndex(Memory, F_Properties, Effect.Block_Property_Index[c]);
ImGui::PushID(Property);
if (ChannelHeader.DisplayType == property_display_type_standard) {
- ImGui_InteractSliderProperty(State, Memory, Property, ChannelHeader.Name);
+ ImGui::DragScalar(ChannelHeader.Name, ImGuiDataType_Float, &Property->CurrentValue, Property->ScrubVal, &Property->MinVal, &Property->MaxVal, "%f");
+ ImGui_PropertyInteract_Slider(State, Memory, Property, io, WindowMinAbs, WindowMaxAbs, F_Properties);
} else if (ChannelHeader.DisplayType == property_display_type_color) {
+ header_property LastHeader = State->Property[EffectHeader->PropertyStartIndex + c + 3];
+ Assert(ChannelHeader.DisplayType == property_display_type_color);
property_channel *Property1 = (property_channel *)Memory_Block_AddressAtIndex(Memory, F_Properties, Effect.Block_Property_Index[c+1]);
property_channel *Property2 = (property_channel *)Memory_Block_AddressAtIndex(Memory, F_Properties, Effect.Block_Property_Index[c+2]);
property_channel *Property3 = (property_channel *)Memory_Block_AddressAtIndex(Memory, F_Properties, Effect.Block_Property_Index[c+3]);
- real32 *Color[4] = { &Property->CurrentValue, &Property1->CurrentValue, &Property2->CurrentValue, &Property3->CurrentValue };
- if (ImGui::ColorEdit4("color", (real32 *)Color, ImGuiColorEditFlags_Float))
- State->UpdateFrame = true;
+ real32 Color[4] = { Property->CurrentValue, Property1->CurrentValue, Property2->CurrentValue, Property3->CurrentValue };
+ if (ImGui::ColorEdit4("color", (real32 *)Color, ImGuiColorEditFlags_Float)) {
+ Property->CurrentValue = Color[0];
+ Property1->CurrentValue = Color[1];
+ Property2->CurrentValue = Color[2];
+ Property3->CurrentValue = Color[3];
+ }
c += 3;
} else if (ChannelHeader.DisplayType == property_display_type_blendmode) {
uint32 *item_current_idx = (uint32 *)&(Property->CurrentValue); // Here we store our selection data as an index.
@@ -626,7 +644,8 @@ ImGui_RenderUIBrush(project_state *State, memory *Memory, ImVec2 ViewportMin, Im
}
static void
-ImGui_TransformUI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDrawList *draw_list, ImGuiIO &io, interact_transform *Interact, ImVec2 ViewportMin, uint32 CompWidth, uint32 CompHeight)
+ImGui_TransformUI(project_data *File, project_state *State, memory *Memory, ui *UI, ImDrawList *draw_list, ImGuiIO &io,
+ interact_transform *Interact, ImVec2 ViewportMin, uint32 CompWidth, uint32 CompHeight, uint16 *SortedPropertyArray)
{
v2 InteractMin = Interact->Min + Interact->Position;
v2 InteractMax = Interact->Max + Interact->Position;
@@ -852,6 +871,7 @@ ImGui_TransformUI(project_data *File, project_state *State, memory *Memory, ui *
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
State->Interact_Active = interact_type_none;
+ State->Interact_Modifier = 0;
State->UpdateFrame = true;
}
@@ -872,7 +892,8 @@ ImGui_TransformUI(project_data *File, project_state *State, memory *Memory, ui *
if (Property[a]->CurrentValue != Val[a]) {
History_Entry_Commit(Memory, "Add keyframe");
bezier_point Point = { 1, {(real32)State->Frame_Current, Val[a], -1, 0, 1, 0}, interpolation_type_linear, 0, {0, 0, 0}, 0 };
- Bezier_Add(Memory, Property[a], Point);
+ uint16 *ArrayLocation = Property_GetSortedArray(SortedPropertyArray, State->MostRecentlySelectedLayer, h);
+ Bezier_Add(Memory, Property[a], Point, ArrayLocation);
History_Entry_End(Memory);
}
}
@@ -888,6 +909,7 @@ ImGui_TransformUI(project_data *File, project_state *State, memory *Memory, ui *
if (!io.KeyCtrl)
History_Entry_End(Memory);
State->Interact_Active = interact_type_none;
+ State->Interact_Modifier = 0;
State->UpdateFrame = true;
}
@@ -999,7 +1021,7 @@ ImGui_LayerViewportUI(project_state *State, memory *Memory, ui *UI, ImDrawList *
static void
ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io, GLuint textureID,
- sorted_comp_info *SortedCompArray, sorted_layer *SortedLayerArray)
+ sorted_comp_info *SortedCompArray, sorted_layer *SortedLayerArray, uint16 *SortedPropertyArray)
{
bool open = true;
ImGui::Begin("Viewport", &open, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
@@ -1040,7 +1062,7 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory,
block_layer *ParentLayer[4];
ImGui_LayerViewportUI(State, Memory, UI, draw_list, MainComp, File->PrincipalCompIndex, ParentLayer, 0, SortedCompArray, SortedLayerArray);
if (State->Interact_Active == interact_type_viewport_transform) {
- ImGui_TransformUI(File, State, Memory, UI, draw_list, io, (interact_transform *)&State->Interact_Offset[0], ViewportMin, MainComp->Width, MainComp->Height);
+ ImGui_TransformUI(File, State, Memory, UI, draw_list, io, (interact_transform *)&State->Interact_Offset[0], ViewportMin, MainComp->Width, MainComp->Height, SortedPropertyArray);
}
}
@@ -1183,6 +1205,7 @@ ImGui_Viewport(project_data *File, project_state *State, ui *UI, memory *Memory,
State->Brush.LayerToPaint_Index = -1;
State->Interact_Active = interact_type_none;
+ State->Interact_Modifier = 0;
State->UpdateFrame = true;
}
}
@@ -1314,6 +1337,7 @@ ImGui_Timeline_HorizontalIncrementDraw(project_state *State, ui *UI, ImDrawList
}
if (IsItemDeactivated) {
State->Interact_Active = interact_type_none;
+ State->Interact_Modifier = 0;
}
}
@@ -1341,10 +1365,14 @@ ImGui_GraphInfo(project_data *File, project_state *State, memory *Memory, ui *UI
sorted_property_info *InfoLocation = Property_GetSortedInfo(SortedPropertyInfo, i, h);
uint16 *ArrayLocation = Property_GetSortedArray(SortedPropertyArray, i, h);
ImGui::PushID(Property);
- if (ImGui::Selectable(Property->Name, InfoLocation->IsGraphSelected)) {
+ if (ImGui::Selectable(DefaultChannel[h], InfoLocation->IsGraphSelected)) {
Property_DeselectAll(File, Memory, SortedPropertyArray);
- bezier_point *FirstPointAddress = Bezier_LookupAddress(Memory, Property, ArrayLocation[0]);
- FirstPointAddress->IsSelected = true;
+ for (int p = 0; p < Property->Keyframe_Count; p++) {
+ int k = ArrayLocation[p];
+ bezier_point *Point = Bezier_LookupAddress(Memory, Property, k);
+ Point->IsSelected = true;
+ }
+ State->RecentSelectionType = selection_type_keyframe;
}
ImGui::PopID();
}
@@ -1359,7 +1387,7 @@ ImGui_GraphInfo(project_data *File, project_state *State, memory *Memory, ui *UI
static void
ImGui_Timeline_DrawKeySheet(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io, ImDrawList *draw_list, property_channel *Property, uint16 *ArrayLocation,
ImVec2 Increment, ImVec2 TimelineAbsolutePos, ImVec2 GraphPos, ImVec2 TimelineMoveSize, ImVec2 TimelineZoomSize,
- ImVec2 TimelineSize, ImVec2 TimelineSizeWithBorder, real32 LayerIncrement)
+ ImVec2 TimelineSize, ImVec2 TimelineSizeWithBorder, real32 LayerIncrement, uint16 *SortedPropertyArray)
{
ImGui::PushID(Property);
@@ -1376,7 +1404,8 @@ ImGui_Timeline_DrawKeySheet(project_data *File, project_state *State, memory *Me
ImVec2 Keyframe_ScreenPos(Keyframe_ScreenPos_X, GraphPos.y);
if (State->BoxSelect) {
- ImGui_TestBoxSelection_Point(Keyframe_ScreenPos, io, &PointAddress->IsSelected);
+ if (ImGui_TestBoxSelection_Point(Keyframe_ScreenPos, io, &PointAddress->IsSelected))
+ State->RecentSelectionType = selection_type_keyframe;
}
ImVec2 ButtonSize(16, 16);
@@ -1408,9 +1437,10 @@ ImGui_Timeline_DrawKeySheet(project_data *File, project_state *State, memory *Me
State->Interact_Offset[2] = io.MousePos.x;
State->Interact_Offset[3] = io.MousePos.y;
State->Interact_Active = interact_type_keyframe_move;
+ State->Interact_Modifier = 1; // X axis movement only
} else {
Assert(State->Interact_Active == interact_type_keyframe_move);
- ImGui_WarpMouse(State, io.MousePos, TimelineAbsolutePos, TimelineAbsolutePos + TimelineSizeWithBorder);
+ ImGui_WarpMouse(State, io.MousePos, TimelineAbsolutePos, TimelineAbsolutePos + TimelineSizeWithBorder, 1);
ImVec2 DragDelta = io.MousePos - ImVec2(State->Interact_Offset[2], State->Interact_Offset[3]);
DragDelta = DragDelta + (ImVec2(State->Warp_X, State->Warp_Y) * TimelineSize);
if (io.MouseDelta.x || io.MouseDelta.y) {
@@ -1424,6 +1454,7 @@ ImGui_Timeline_DrawKeySheet(project_data *File, project_state *State, memory *Me
}
if (IsItemDeactivated) {
+ Bezier_Commit(File, State, Memory, SortedPropertyArray);
}
draw_list->AddCircleFilled(Keyframe_ScreenPos, 4, PointCol);
@@ -1529,7 +1560,8 @@ ImGui_Timeline_DrawGraph(project_data *File, project_state *State, memory *Memor
}
if (State->BoxSelect) {
- ImGui_TestBoxSelection_Point(Keyframe_ScreenPos[NewIdx], io, &PointAddress[Idx]->IsSelected);
+ if (ImGui_TestBoxSelection_Point(Keyframe_ScreenPos[NewIdx], io, &PointAddress[Idx]->IsSelected))
+ State->RecentSelectionType = selection_type_keyframe;
}
State->Test.SetCurrentChannel(draw_list, 1);
@@ -1713,7 +1745,6 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem
State->Interact_Offset[0] = (DragDelta.x / TimelineSizeWithBorder.x * UI->TimelinePercentZoomed.x) * Comp->Frame_Count;
State->Interact_Offset[1] = b;
- // DebugWatchVar("Offset1", &State->Interact_Offset[0], d_float);
}
}
if (ImGui::IsItemDeactivated()) {
@@ -1731,6 +1762,7 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem
}
History_Entry_End(Memory);
State->Interact_Active = interact_type_none;
+ State->Interact_Modifier = 0;
State->Interact_Offset[0] = 0;
State->Interact_Offset[1] = 0;
}
@@ -1862,6 +1894,7 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem
}
}
State->Interact_Active = interact_type_none;
+ State->Interact_Modifier = 0;
History_Entry_End(Memory);
}
}
@@ -1876,7 +1909,7 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem
ImVec2 GraphPos(TimelineAbsolutePos.x, Layer_ScreenPos_Min.y + (Layer_ScreenSize.y * 2) + (Layer_ScreenSize.y * Channel));
ImGui_Timeline_DrawKeySheet(File, State, Memory, UI, io, draw_list, Property, ArrayLocation,
Increment, TimelineAbsolutePos, GraphPos, TimelineMoveSize, TimelineZoomSize,
- TimelineSize, TimelineSizeWithBorder, LayerIncrement);
+ TimelineSize, TimelineSizeWithBorder, LayerIncrement, SortedPropertyArray);
Channel++;
}
}
@@ -1988,6 +2021,8 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI,
ImVec2 Val_Min(0, 0);
ImVec2 Val_Max(40, LayerIncrement);
+ DebugWatchVar("Selection", &State->RecentSelectionType, d_int);
+
// ImVec2 *ActivePercentZoomed = (UI->TimelineMode != timeline_mode_graph) ? &UI->TimelinePercentZoomed : &UI->GraphPercentZoomed;
// ImVec2 *ActivePercentOffset = (UI->TimelineMode != timeline_mode_graph) ? &UI->TimelinePercentOffset : &UI->GraphPercentOffset;
ImVec2 *ActivePercentZoomed = &UI->TimelinePercentZoomed;
@@ -2243,38 +2278,32 @@ struct key_entry {
real32 WidthRatio;
};
-struct shortcut_entry {
- ImGuiKey_ Key;
- ImGuiModFlags_ Mods;
- char *Name;
-};
-
-#if 0
+// dumb typing exercise
static key_entry KeyEntries[] {
{ ImGuiKey_Tab, "Tab", "\0", 0, ImVec2(0, 1), 1.5f },
- { ImGuiKey_LeftArrow, "<-", "\0", 2, ImVec2(0, 5), 1.0f },
- { ImGuiKey_RightArrow, "->", "", 2, ImVec2(2, 5), 1.0f },
- { ImGuiKey_UpArrow, "/\\", "", 2, ImVec2(1, 4), 1.0f },
- { ImGuiKey_DownArrow, "\\/", "", 2, ImVec2(1, 5), 1.0f },
- { ImGuiKey_PageUp, "Pg Up", "", 2, ImVec2(2, 0), 1.0f },
- { ImGuiKey_PageDown, "Pg Dn", "", 2, ImVec2(2, 1), 1.0f },
+ { ImGuiKey_LeftArrow, "<-", "\0", 2, ImVec2(0, 4), 1.0f },
+ { ImGuiKey_RightArrow, "->", "", 2, ImVec2(2, 4), 1.0f },
+ { ImGuiKey_UpArrow, "/\\", "", 2, ImVec2(1, 3), 1.0f },
+ { ImGuiKey_DownArrow, "\\/", "", 2, ImVec2(1, 4), 1.0f },
+ { ImGuiKey_PageUp, "Up", "", 2, ImVec2(2, 0), 1.0f },
+ { ImGuiKey_PageDown, "Dn", "", 2, ImVec2(2, 1), 1.0f },
{ ImGuiKey_Home, "Home", "", 2, ImVec2(1, 0), 1.0f },
- { ImGuiKey_End, "End", "", 2, ImVec2(0, 1), 1.0f },
+ { ImGuiKey_End, "End", "", 2, ImVec2(1, 1), 1.0f },
{ ImGuiKey_Insert, "Insert", "", 2, ImVec2(0, 0), 1.0f },
{ ImGuiKey_Delete, "Delete", "", 2, ImVec2(0, 1), 1.0f },
- { ImGuiKey_Backspace, "Backspace", "", 0, ImVec2(13, 1), 2.0f },
- { ImGuiKey_Space, "Space", "", 0, ImVec2(4, 3), 6.5f },
- { ImGuiKey_Enter, "Enter", "", 0, ImVec2(2, 12), 1.5f},
+ { ImGuiKey_Backspace, "Backspace", "", 0, ImVec2(13, 0), 2.0f },
+ { ImGuiKey_Space, "Space", "", 0, ImVec2(3.75, 4), 6.5f },
+ { ImGuiKey_Enter, "Enter", "", 0, ImVec2(12, 2), 2.25f},
{ ImGuiKey_Escape, "Esc", "", 1, ImVec2(0, 0), 1.0f },
- { ImGuiKey_LeftCtrl,
- { ImGuiKey_LeftShift, "L_Shift", "", 0,
- { ImGuiKey_LeftAlt,
- { ImGuiKey_LeftSuper,
- { ImGuiKey_RightCtrl,
- { ImGuiKey_RightShift,
- { ImGuiKey_RightAlt,
- { ImGuiKey_RightSuper,
- { ImGuiKey_Menu,
+ { ImGuiKey_LeftCtrl, "Ctrl", "", 0, ImVec2(0, 4), 1.25f },
+ { ImGuiKey_LeftShift, "Shift", "", 0, ImVec2(0, 3), 2.5f },
+ { ImGuiKey_LeftAlt, "Alt", "", 0, ImVec2(1.25, 4), 1.25 },
+ { ImGuiKey_LeftSuper, "Sp", "", 0, ImVec2(2.5, 4), 1.25f },
+ { ImGuiKey_RightCtrl, "Ctrl", "", 0, ImVec2(13.75, 4), 1.25f },
+ { ImGuiKey_RightShift, "Shift", "", 0, ImVec2(11, 3), 2.5f },
+ { ImGuiKey_RightAlt, "Alt", "", 0, ImVec2(11.25, 4), 1.25 },
+ { ImGuiKey_RightSuper, "Sp", "", 0, ImVec2(10.25, 4), 1.0f },
+ { ImGuiKey_Menu, "Menu", "", 0, ImVec2(12.5, 4), 1.25 },
{ ImGuiKey_0, "0", ")", 0, ImVec2(10, 0), 1.0f },
{ ImGuiKey_1, "1", "!", 0, ImVec2(1, 0), 1.0f },
{ ImGuiKey_2, "2", "@", 0, ImVec2(2, 0), 1.0f },
@@ -2289,27 +2318,27 @@ static key_entry KeyEntries[] {
{ ImGuiKey_B, "b", "B", 0, ImVec2(5, 3), 1.0f },
{ ImGuiKey_C, "c", "C", 0, ImVec2(3, 3), 1.0f },
{ ImGuiKey_D, "d", "D", 0, ImVec2(3, 2), 1.0f },
- { ImGuiKey_E, "e", "E", 0, ImVec2(0, 2), 1.0f },
+ { ImGuiKey_E, "e", "E", 0, ImVec2(3, 1), 1.0f },
{ ImGuiKey_F, "f", "F", 0, ImVec2(4, 2), 1.0f },
{ ImGuiKey_G, "g", "G", 0, ImVec2(5, 2), 1.0f },
{ ImGuiKey_H, "h", "H", 0, ImVec2(6, 2), 1.0f },
- { ImGuiKey_I, "i", "I", 0, ImVec2(0, 7), 1.0f },
+ { ImGuiKey_I, "i", "I", 0, ImVec2(8, 1), 1.0f },
{ ImGuiKey_J, "j", "J", 0, ImVec2(7, 2), 1.0f },
{ ImGuiKey_K, "k", "K", 0, ImVec2(8, 2), 1.0f },
{ ImGuiKey_L, "l", "L", 0, ImVec2(9, 2), 1.0f },
{ ImGuiKey_M, "m", "M", 0, ImVec2(7, 3), 1.0f },
{ ImGuiKey_N, "n", "N", 0, ImVec2(6, 3), 1.0f },
- { ImGuiKey_O, "o", "O", 0, ImVec2(8, 1), 1.0f },
- { ImGuiKey_P, "p", "P", 0, ImVec2(9, 1), 1.0f },
+ { ImGuiKey_O, "o", "O", 0, ImVec2(9, 1), 1.0f },
+ { ImGuiKey_P, "p", "P", 0, ImVec2(10, 1), 1.0f },
{ ImGuiKey_Q, "q", "Q", 0, ImVec2(1, 1), 1.0f },
- { ImGuiKey_R, "r", "R", 0, ImVec2(3, 1), 1.0f },
- { ImGuiKey_S, "s", "S", 0, ImVec2(2, 1), 1.0f },
- { ImGuiKey_T, "t", "T", 0, ImVec2(4, 1), 1.0f },
- { ImGuiKey_U, "u", "U", 0, ImVec2(6, 1), 1.0f },
+ { ImGuiKey_R, "r", "R", 0, ImVec2(4, 1), 1.0f },
+ { ImGuiKey_S, "s", "S", 0, ImVec2(2, 2), 1.0f },
+ { ImGuiKey_T, "t", "T", 0, ImVec2(5, 1), 1.0f },
+ { ImGuiKey_U, "u", "U", 0, ImVec2(7, 1), 1.0f },
{ ImGuiKey_V, "v", "V", 0, ImVec2(4, 3), 1.0f },
- { ImGuiKey_W, "w", "W", 0, ImVec2(1, 1), 1.0f },
+ { ImGuiKey_W, "w", "W", 0, ImVec2(2, 1), 1.0f },
{ ImGuiKey_X, "x", "X", 0, ImVec2(2, 3), 1.0f },
- { ImGuiKey_Y, "y", "Y", 0, ImVec2(0, 5), 1.0f },
+ { ImGuiKey_Y, "y", "Y", 0, ImVec2(6, 1), 1.0f },
{ ImGuiKey_Z, "z", "Z", 0, ImVec2(1, 3), 1.0f },
{ ImGuiKey_F1, "F1", "", 1, ImVec2(2, 0), 1.0f },
{ ImGuiKey_F2, "F2", "", 1, ImVec2(3, 0), 1.0f },
@@ -2320,52 +2349,129 @@ static key_entry KeyEntries[] {
{ ImGuiKey_F7, "F7", "", 1, ImVec2(8.5, 0), 1.0f },
{ ImGuiKey_F8, "F8", "", 1, ImVec2(9.5, 0), 1.0f },
{ ImGuiKey_F9, "F9", "", 1, ImVec2(11, 0), 1.0f },
- { ImGuiKey_F10 "F10","", 1, ImVec2(12, 0), 1.0f },
- { ImGuiKey_F11 "F11","", 1, ImVec2(13, 0), 1.0f },
- { ImGuiKey_F12 "F12","", 1, ImVec2(14, 0), 1.0f },
- { ImGuiKey_Apostrophe, "\'", "\"", 1, ImVec2(11, 2), 1.0f },
+ { ImGuiKey_F10, "F10","", 1, ImVec2(12, 0), 1.0f },
+ { ImGuiKey_F11, "F11","", 1, ImVec2(13, 0), 1.0f },
+ { ImGuiKey_F12, "F12","", 1, ImVec2(14, 0), 1.0f },
+ { ImGuiKey_Apostrophe, "'", "\"", 0, ImVec2(11, 2), 1.0f },
{ ImGuiKey_Comma, ",", "<", 0, ImVec2(8, 3), 1.0f },
- { ImGuiKey_Minus, "-", "_", 0, ImVec2(11, 1), 1.0f};
+ { ImGuiKey_Minus, "-", "_", 0, ImVec2(11, 0), 1.0f},
{ ImGuiKey_Period, ".", ">", 0, ImVec2(9, 3), 1.0f },
{ ImGuiKey_Slash, "/", "?", 0, ImVec2(10, 3), 1.0f },
{ ImGuiKey_Semicolon, ";", ":", 0, ImVec2(10, 2), 1.0f },
- { ImGuiKey_Equal, "=", "+", 0, ImVec2(12, 1), 1.0f },
- { ImGuiKey_LeftBracket, "[", "{", 0, ImVec2(0, 10), 1.0f },
- { ImGuiKey_Backslash, "\\","|", 0, ImVec2(0, 12), 1.5f },
- { ImGuiKey_RightBracket,"]", "}", 0, ImVec2(0, 11), 1.0f },
+ { ImGuiKey_Equal, "=", "+", 0, ImVec2(12, 0), 1.0f },
+ { ImGuiKey_LeftBracket, "[", "{", 0, ImVec2(11, 1), 1.0f },
+ { ImGuiKey_Backslash, "\\","|", 0, ImVec2(13, 1), 1.5f },
+ { ImGuiKey_RightBracket,"]", "}", 0, ImVec2(12, 1), 1.0f },
{ ImGuiKey_GraveAccent, "`", "~", 0, ImVec2(0, 0), 1.0f },
- { ImGuiKey_CapsLock, "Caps lock", "", 1, ImVec2(0, 2), 1.75f };
- { ImGuiKey_ScrollLock,
- { ImGuiKey_NumLock,
- { ImGuiKey_PrintScreen,
- { ImGuiKey_Pause,
- { ImGuiKey_Keypad0,
- { ImGuiKey_Keypad1,
- { ImGuiKey_Keypad2,
- { ImGuiKey_Keypad3,
- { ImGuiKey_Keypad4,
- { ImGuiKey_Keypad5,
- { ImGuiKey_Keypad6,
- { ImGuiKey_Keypad7,
- { ImGuiKey_Keypad8,
- { ImGuiKey_Keypad9,
- { ImGuiKey_KeypadDecimal,
- { ImGuiKey_KeypadDivide,
- { ImGuiKey_KeypadMultiply,
- { ImGuiKey_KeypadSubtract,
- { ImGuiKey_KeypadAdd,
- { ImGuiKey_KeypadEnter,
- { ImGuiKey_KeypadEqual,
+ { ImGuiKey_CapsLock, "Caps", "", 0, ImVec2(0, 2), 1.75f },
+ { ImGuiKey_ScrollLock, "\0", "", 0, ImVec2(0, 0), 1.0f }, // unused
+ { ImGuiKey_NumLock, "\0", "", 0, ImVec2(0, 0), 1.0f }, //
+ { ImGuiKey_PrintScreen, "\0", "", 0, ImVec2(0, 0), 1.0f }, //
+ { ImGuiKey_Pause, "\0", "", 0, ImVec2(0, 0), 1.0f }, //
+ { ImGuiKey_Keypad0, "0", "", 3, ImVec2(0, 4), 2.0f },
+ { ImGuiKey_Keypad1, "1", "", 3, ImVec2(0, 3), 1.0f },
+ { ImGuiKey_Keypad2, "2", "", 3, ImVec2(1, 3), 1.0f },
+ { ImGuiKey_Keypad3, "3", "", 3, ImVec2(2, 3), 1.0f },
+ { ImGuiKey_Keypad4, "4", "", 3, ImVec2(0, 2), 1.0f },
+ { ImGuiKey_Keypad5, "5", "", 3, ImVec2(1, 2), 1.0f },
+ { ImGuiKey_Keypad6, "6", "", 3, ImVec2(2, 2), 1.0f },
+ { ImGuiKey_Keypad7, "7", "", 3, ImVec2(0, 1), 1.0f },
+ { ImGuiKey_Keypad8, "8", "", 3, ImVec2(1, 1), 1.0f },
+ { ImGuiKey_Keypad9, "9", "", 3, ImVec2(2, 1), 1.0f },
+ { ImGuiKey_KeypadDecimal, ".", "", 3, ImVec2(2, 4), 1.0f },
+ { ImGuiKey_KeypadDivide, "/", "", 3, ImVec2(1, 0), 1.0f },
+ { ImGuiKey_KeypadMultiply, "*", "", 3, ImVec2(2, 0), 1.0f },
+ { ImGuiKey_KeypadSubtract, "-", "", 3, ImVec2(3, 0), 1.0f },
+ { ImGuiKey_KeypadAdd, "+", "", 3, ImVec2(3, 1), -2.0f }, // long keys!
+ { ImGuiKey_KeypadEnter, "Ent", "", 3, ImVec2(3, 3), -2.0f },
+ { ImGuiKey_KeypadEqual, "", "", 3, ImVec2(0, 0), 1.0f } // unused
+};
+
+enum key_mode {
+ key_mode_all,
+ key_mode_viewport,
+ key_mode_timeline,
+ key_mode_graph,
+ key_mode_brush,
+};
+
+static char *Modes[] = {
+ "All",
+ "Viewport",
+ "Timeline",
+ "Graph",
+ "Brush"
};
-#endif
+struct shortcut_entry {
+ ImGuiKey_ Key;
+ ImGuiModFlags_ Mods;
+ key_mode Mode;
+ char *Name;
+};
static shortcut_entry ShortcutArray[] {
- { ImGuiKey_1, ImGuiModFlags_None, "Enable debug UI" },
- { ImGuiKey_2, ImGuiModFlags_None, "Toggle precomp view" }
+ { ImGuiKey_None, ImGuiModFlags_None, key_mode_all, "Many actions/modes are escapable with the Esc key." },
+ { ImGuiKey_None, ImGuiModFlags_None, key_mode_all, "Undo isn't fully implemented yet; beware crashes." },
+ { ImGuiKey_Q, ImGuiModFlags_None, key_mode_all, "Quit (instantly!)" },
+ { ImGuiKey_W, ImGuiModFlags_None, key_mode_all, "Step back one frame" },
+ { ImGuiKey_E, ImGuiModFlags_None, key_mode_all, "Step forward one frame" },
+ { ImGuiKey_V, ImGuiModFlags_None, key_mode_all, "Move tool" },
+ { ImGuiKey_B, ImGuiModFlags_None, key_mode_all, "Brush tool" },
+ { ImGuiKey_Space, ImGuiModFlags_None, key_mode_all, "Play scene" },
+ { ImGuiKey_Delete, ImGuiModFlags_None, key_mode_all, "Delete selection (WIP)" },
+ { ImGuiKey_S, ImGuiModFlags_None, key_mode_all, "Save" },
+ { ImGuiKey_S, ImGuiModFlags_Shift, key_mode_all, "Save as" },
+ { ImGuiKey_C, ImGuiModFlags_None, key_mode_all, "Copy" },
+ { ImGuiKey_P, ImGuiModFlags_None, key_mode_all, "Paste" },
+ { ImGuiKey_Z, ImGuiModFlags_None, key_mode_all, "Undo" },
+ { ImGuiKey_Z, ImGuiModFlags_Shift, key_mode_all, "Redo" },
+
+ { ImGuiKey_None, ImGuiModFlags_None, key_mode_viewport, "Hold right click to pan." },
+ { ImGuiKey_None, ImGuiModFlags_None, key_mode_viewport, "Hold Z and drag left click to zoom." },
+ { ImGuiKey_None, ImGuiModFlags_None, key_mode_viewport, "Press Enter or ctrl+click to commit a transform." },
+ { ImGuiKey_T, ImGuiModFlags_None, key_mode_viewport, "Transform selected layers" },
+
+ { ImGuiKey_Tab, ImGuiModFlags_None, key_mode_timeline, "Switch between timeline and graph" },
+ { ImGuiKey_2, ImGuiModFlags_None, key_mode_timeline, "Toggle precomp view" },
+ { ImGuiKey_G, ImGuiModFlags_None, key_mode_timeline, "Toggle position keyframes" },
+ { ImGuiKey_A, ImGuiModFlags_None, key_mode_timeline, "Toggle anchor point keyframes" },
+ { ImGuiKey_R, ImGuiModFlags_None, key_mode_timeline, "Toggle roation keyframes" },
+ { ImGuiKey_S, ImGuiModFlags_None, key_mode_timeline, "Toggle scale keyframes" },
+ { ImGuiKey_T, ImGuiModFlags_None, key_mode_timeline, "Toggle time remapping keyframes" },
+ { ImGuiKey_T, ImGuiModFlags_Shift, key_mode_timeline, "Toggle opacity keyframes" },
+ { ImGuiKey_B, ImGuiModFlags_None, key_mode_timeline, "Mark frame start" },
+ { ImGuiKey_N, ImGuiModFlags_None, key_mode_timeline, "Mark frame end" },
+
+ { ImGuiKey_G, ImGuiModFlags_None, key_mode_graph, "Enter keyframe moving mode" },
+ { ImGuiKey_X, ImGuiModFlags_None, key_mode_graph, "Constrain to X axis" },
+ { ImGuiKey_Y, ImGuiModFlags_None, key_mode_graph, "Constrain to Y axis" },
+
+ { ImGuiKey_None, ImGuiModFlags_None, key_mode_brush, "Hold alt and drag to adjust size/hardness." },
+ { ImGuiKey_X, ImGuiModFlags_None, key_mode_brush, "Swap FG and BG colors" },
};
-static ImVec2 SectorOffset[] = { ImVec2(0, 1.5), ImVec2(0, 0) };
+static ImVec2 SectorOffset[4] = { ImVec2(0, 1.5), ImVec2(0, 0) , ImVec2(15.5, 1.5), ImVec2(19, 1.5) };
+
+static void
+ImGui_Key_GetUIInfo(key_entry KeyEntry, real32 KeySize, ImVec2 *Offset_ScreenPos, ImVec2 *KeyScreenSize) {
+ ImVec2 Extra(0, 0);
+ if (KeyEntry.Sector == 0) {
+ if (KeyEntry.Offset.x != 0) {
+ if (KeyEntry.Offset.y == 1) {
+ Extra.x += 0.5;
+ }
+ if (KeyEntry.Offset.y == 2) {
+ Extra.x += 0.75;
+ }
+ if (KeyEntry.Offset.y == 3) {
+ Extra.x += 1.5;
+ }
+ }
+ }
+ *Offset_ScreenPos = ImVec2(KeySize, KeySize) * (SectorOffset[KeyEntry.Sector] + Extra + KeyEntry.Offset);
+ *KeyScreenSize = (KeyEntry.WidthRatio > 0.0f) ? ImVec2(KeySize * KeyEntry.WidthRatio, KeySize) : ImVec2(KeySize, KeySize * -KeyEntry.WidthRatio);
+}
static void
ImGui_Popups(project_data *File, project_state *State, ui *UI, memory *Memory, ImGuiIO io)
@@ -2383,14 +2489,17 @@ ImGui_Popups(project_data *File, project_state *State, ui *UI, memory *Memory, I
ImGui::SetNextWindowPos(Viewport->GetCenter(), 0, ImVec2(0.5, 0.5));
ImGui::SetNextWindowSize(Size);
ImGui::SetKeyboardFocusHere();
+ State->SetFocus = 0;
} break;
case popup_keybinds:
{
ImGui::OpenPopup("Keybinds");
+ ImVec2 Size(500, 800);
ImGuiViewport *Viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(Viewport->GetCenter(), 0, ImVec2(0.5, 0.5));
- ImGui::SetNextWindowSize(ImVec2(500, 300));
+ ImGui::SetNextWindowSize(Size);
ImGui::SetKeyboardFocusHere();
+ State->SetFocus = 0;
} break;
default:
{
@@ -2413,13 +2522,34 @@ ImGui_Popups(project_data *File, project_state *State, ui *UI, memory *Memory, I
ImGui::EndPopup();
}
if (ImGui::BeginPopupModal("Keybinds")) {
-#if 0
- real32 KeySize = 20;
+ real32 KeySize = ImGui::GetFontSize()*2;
+ ImVec2 WindowSize = ImGui::GetWindowSize();
+ ImVec2 WindowMinAbs = ImGui::GetWindowPos();
+ ImVec2 WindowMaxAbs = WindowMinAbs + WindowSize;
+ ImDrawList* draw_list = ImGui::GetWindowDrawList();
+ ImVec2 SectorOffset[4] = { ImVec2(0, 1.25), ImVec2(0,0), ImVec2(15.25, 1.25), ImVec2(19.5, 1.25) };
for (int k = 0; k < AmountOf(KeyEntries); k++) {
- key_entry KeyEntry = KeyArray[k];
- ImVec2 Offset_ScreenPos = ImVec2(KeySize, KeySize) * (SectorOffset[KeyEntry.Sector] +
+ key_entry KeyEntry = KeyEntries[k];
+ ImVec2 Offset_ScreenPos(0,0);
+ ImVec2 KeyScreenSize(0,0);
+ ImGui_Key_GetUIInfo(KeyEntry, KeySize, &Offset_ScreenPos, &KeyScreenSize);
+ if (KeyEntry.Name[0] != '\0') {
+ ImGui::PushID(k);
+ ImGui::SetCursorScreenPos(ImVec2(KeySize*2, KeySize*2) + WindowMinAbs + Offset_ScreenPos);
+ ImGui::Button(KeyEntry.Name, KeyScreenSize);
+ // draw_list->AddRectFilled(WindowMinAbs + Offset_ScreenPos, WindowMinAbs + Offset_ScreenPos + KeyScreenSize, IM_COL32(255, 255, 255, 64));
+ ImGui::PopID();
+ }
}
-#endif
+ for (int a = 0; a < AmountOf(ShortcutArray); a++) {
+ shortcut_entry ShortcutEntry = ShortcutArray[a];
+ key_entry KeyEntry = KeyEntries[ShortcutEntry.Key - ImGuiKey_Tab];
+ ImGui::Text(ShortcutEntry.Name);
+ }
+ if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
+ ImGui::CloseCurrentPopup();
+ }
+ ImGui::EndPopup();
}
}
@@ -2446,7 +2576,7 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me
}
}
if (ImGui::IsKeyPressed(ImGuiKey_X)) {
- if (State->Interact_Active == interact_type_keyframe_move) {
+ if (State->TimelineMode == timeline_mode_graph && State->Interact_Active == interact_type_keyframe_move) {
if (State->Interact_Modifier != 1)
State->Interact_Modifier = 1;
else
@@ -2457,6 +2587,14 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me
UI->AltColor = Temp;
}
}
+ if (ImGui::IsKeyPressed(ImGuiKey_Y)) {
+ if (State->TimelineMode == timeline_mode_graph && State->Interact_Active == interact_type_keyframe_move) {
+ if (State->Interact_Modifier != 2)
+ State->Interact_Modifier = 2;
+ else
+ State->Interact_Modifier = 0;
+ }
+ }
if (ImGui::IsKeyPressed(ImGuiKey_V)) {
State->Tool = tool_default;
}
@@ -2529,6 +2667,7 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me
State->Interact_Offset[2] = 0;
State->Interact_Offset[3] = 0;
State->Interact_Active = interact_type_none;
+ State->Interact_Modifier = 0;
State->UpdateFrame = true;
}
}
@@ -2585,6 +2724,7 @@ ImGui_ProcessInputs(project_data *File, project_state *State, ui *UI, memory *Me
sprintf(State->DummyName, "test2");
File_Open(File, State, Memory, State->DummyName);
State->UpdateFrame = true;
+ State->MostRecentlySelectedLayer = 0;
}
if (ImGui::IsKeyPressed(ImGuiKey_0))
{
@@ -2737,7 +2877,7 @@ ImGui_EffectsPanel(project_data *File, project_state *State, memory *Memory, ui
ImGui::Selectable(EffectHeader->Name, &t);
if (ImGui::IsItemClicked()) {
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) && State->MostRecentlySelectedLayer != -1) {
- Assert(0);
+ Effect_Add(File, State, Memory, i);
State->UpdateFrame = true;
}
}
@@ -2746,3 +2886,170 @@ ImGui_EffectsPanel(project_data *File, project_state *State, memory *Memory, ui
}
ImGui::End();
}
+
+static char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]\n"
+"Pos=0,0\n"
+"Size=2133,1333\n"
+"Collapsed=0\n"
+"\n"
+"[Window][Debug##Default]\n"
+"Pos=122,442\n"
+"Size=400,400\n"
+"Collapsed=0\n"
+"\n"
+"[Window][Viewport]\n"
+"Pos=443,34\n"
+"Size=1165,738\n"
+"Collapsed=0\n"
+"DockId=0x00000010,0\n"
+"\n"
+"[Window][###Properties]\n"
+"Pos=0,34\n"
+"Size=441,738\n"
+"Collapsed=0\n"
+"DockId=0x0000000B,0\n"
+"\n"
+"[Window][Timeline]\n"
+"Pos=0,774\n"
+"Size=2133,559\n"
+"Collapsed=0\n"
+"DockId=0x0000000A,0\n"
+"\n"
+"[Window][Dear ImGui Demo]\n"
+"Pos=1610,34\n"
+"Size=523,267\n"
+"Collapsed=0\n"
+"DockId=0x00000011,1\n"
+"\n"
+"[Window][Files]\n"
+"Pos=1610,303\n"
+"Size=523,469\n"
+"Collapsed=0\n"
+"DockId=0x00000007,0\n"
+"\n"
+"[Window][Effects list]\n"
+"Pos=2677,1047\n"
+"Size=523,192\n"
+"Collapsed=0\n"
+"DockId=0x00000008,0\n"
+"\n"
+"[Window][Graph editor]\n"
+"Pos=0,949\n"
+"Size=3200,526\n"
+"Collapsed=0\n"
+"DockId=0x00000009,0\n"
+"\n"
+"[Window][undotree]\n"
+"Pos=2114,80\n"
+"Size=256,565\n"
+"Collapsed=0\n"
+"\n"
+"[Window][memoryviewer]\n"
+"Pos=50,273\n"
+"Size=800,200\n"
+"Collapsed=0\n"
+"\n"
+"[Window][Example: Custom rendering]\n"
+"Pos=758,789\n"
+"Size=485,414\n"
+"Collapsed=0\n"
+"\n"
+"[Window][Memory viewer]\n"
+"Pos=1610,303\n"
+"Size=523,469\n"
+"Collapsed=0\n"
+"DockId=0x00000007,1\n"
+"\n"
+"[Window][Graph info]\n"
+"Pos=2838,1265\n"
+"Size=235,353\n"
+"Collapsed=0\n"
+"\n"
+"[Window][Properties]\n"
+"Pos=0,34\n"
+"Size=495,1056\n"
+"Collapsed=0\n"
+"DockId=0x0000000F,0\n"
+"\n"
+"[Window][Colors]\n"
+"Pos=1610,34\n"
+"Size=523,267\n"
+"Collapsed=0\n"
+"DockId=0x00000011,0\n"
+"\n"
+"[Window][Menu]\n"
+"Pos=0,0\n"
+"Size=2133,32\n"
+"Collapsed=0\n"
+"DockId=0x0000000D,0\n"
+"\n"
+"[Window][Stable Diffusion]\n"
+"Pos=2206,684\n"
+"Size=421,462\n"
+"Collapsed=0\n"
+"\n"
+"[Window][SD prompt input]\n"
+"Pos=2677,473\n"
+"Size=523,541\n"
+"Collapsed=0\n"
+"DockId=0x00000007,2\n"
+"\n"
+"[Window][Example: Console]\n"
+"Pos=747,851\n"
+"Size=520,600\n"
+"Collapsed=0\n"
+"\n"
+"[Window][SD gallery]\n"
+"Pos=0,718\n"
+"Size=441,557\n"
+"Collapsed=0\n"
+"DockId=0x0000000C,0\n"
+"\n"
+"[Window][Save as]\n"
+"Pos=300,800\n"
+"Size=300,300\n"
+"Collapsed=0\n"
+"\n"
+"[Table][0x861D378E,3]\n"
+"Column 0 Weight=1.0000\n"
+"Column 1 Weight=1.0000\n"
+"Column 2 Weight=1.0000\n"
+"\n"
+"[Table][0x1F146634,3]\n"
+"RefScale=13\n"
+"Column 0 Width=63\n"
+"Column 1 Width=63\n"
+"Column 2 Width=63\n"
+"\n"
+"[Table][0x64418101,3]\n"
+"RefScale=13\n"
+"Column 0 Width=63\n"
+"Column 1 Width=63\n"
+"Column 2 Width=63\n"
+"\n"
+"[Table][0xC9935533,3]\n"
+"Column 0 Weight=1.0000\n"
+"Column 1 Weight=1.0000\n"
+"Column 2 Weight=1.0000\n"
+"\n"
+"[Docking][Data]\n"
+"DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,0 Size=2133,1333 Split=Y Selected=0x13926F0B\n"
+" DockNode ID=0x0000000D Parent=0x8B93E3BD SizeRef=3200,32 HiddenTabBar=1 Selected=0xA57AB2C6\n"
+" DockNode ID=0x0000000E Parent=0x8B93E3BD SizeRef=3200,1299 Split=Y\n"
+" DockNode ID=0x00000001 Parent=0x0000000E SizeRef=3200,1205 Split=X Selected=0x13926F0B\n"
+" DockNode ID=0x00000003 Parent=0x00000001 SizeRef=441,1171 Split=Y Selected=0xDBB8CEFA\n"
+" DockNode ID=0x0000000B Parent=0x00000003 SizeRef=521,425 Selected=0xDBB8CEFA\n"
+" DockNode ID=0x0000000C Parent=0x00000003 SizeRef=521,347 Selected=0x56290987\n"
+" DockNode ID=0x00000004 Parent=0x00000001 SizeRef=1690,1171 Split=X Selected=0x13926F0B\n"
+" DockNode ID=0x00000005 Parent=0x00000004 SizeRef=1165,1171 Split=X Selected=0x13926F0B\n"
+" DockNode ID=0x0000000F Parent=0x00000005 SizeRef=495,856 Selected=0x199AB496\n"
+" DockNode ID=0x00000010 Parent=0x00000005 SizeRef=2199,856 CentralNode=1 Selected=0x13926F0B\n"
+" DockNode ID=0x00000006 Parent=0x00000004 SizeRef=523,1171 Split=Y Selected=0x86FA2F90\n"
+" DockNode ID=0x00000011 Parent=0x00000006 SizeRef=483,437 Selected=0xBF7DFDC9\n"
+" DockNode ID=0x00000012 Parent=0x00000006 SizeRef=483,766 Split=Y Selected=0x59A2A092\n"
+" DockNode ID=0x00000007 Parent=0x00000012 SizeRef=523,572 Selected=0x86FA2F90\n"
+" DockNode ID=0x00000008 Parent=0x00000012 SizeRef=523,192 Selected=0x812F222D\n"
+" DockNode ID=0x00000002 Parent=0x0000000E SizeRef=3200,559 Split=Y Selected=0x0F18B61B\n"
+" DockNode ID=0x00000009 Parent=0x00000002 SizeRef=3250,526 Selected=0xA1F22F4D\n"
+" DockNode ID=0x0000000A Parent=0x00000002 SizeRef=3250,323 HiddenTabBar=1 Selected=0x0F18B61B\n"
+"\n";