diff options
author | Fox Caminiti <fox@foxcam.net> | 2023-02-17 17:20:18 -0500 |
---|---|---|
committer | Fox Caminiti <fox@foxcam.net> | 2023-02-17 17:20:18 -0500 |
commit | 02870398a99fab6351182fba407d7d733affa5a1 (patch) | |
tree | fb5f4744f46e9d7816072e4d01547034bca04bb2 /src/imgui_ui_timeline.cpp | |
parent | fffb3474ee0321d73a47db01dbc4b6b19670ddc5 (diff) |
blend mode rendering halfway implemented
Diffstat (limited to 'src/imgui_ui_timeline.cpp')
-rw-r--r-- | src/imgui_ui_timeline.cpp | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/src/imgui_ui_timeline.cpp b/src/imgui_ui_timeline.cpp index 40bc889..8b8ca36 100644 --- a/src/imgui_ui_timeline.cpp +++ b/src/imgui_ui_timeline.cpp @@ -12,6 +12,7 @@ ImGui_Timeline_BGElements(project_data *File, project_state *State, memory *Memo ImVec2 Region_Min = ImVec2(TimelineAbsolutePos.x + TimelineMoveSize.x + ((real32)MainComp.Frame_Start / MainComp.Frame_Count)*TimelineZoomSize.x, TimelineAbsolutePos.y); ImVec2 Region_Max = ImVec2(Region_Min.x + ((real32)(MainComp.Frame_End - MainComp.Frame_Start) / MainComp.Frame_Count)*TimelineZoomSize.x, Region_Min.y + TimelineSizeWithBorder.y); draw_list->AddRectFilled(Region_Min, Region_Max, PreviewAreaColor); +#if 0 // cache bar cache_entry *EntryArray = State->Render.Entry; int c = 0; @@ -29,6 +30,7 @@ ImGui_Timeline_BGElements(project_data *File, project_state *State, memory *Memo } c++; } +#endif } static void @@ -127,11 +129,11 @@ ImGui_Timeline_GraphInfo(project_data *File, project_state *State, memory *Memor sorted_property_array *InfoLocation = Property_GetSortedInfo(SortedPropertyStart, i, h); uint16 *ArrayLocation = Property_GetSortedArray(SortedKeyframeArray, i, h); ImGui::PushID(Property); - if (ImGui::Selectable(DefaultChannel[h], Property_IsGraphSelected(Memory, Property, ArrayLocation))) { + if (ImGui::Selectable(DefaultChannel[h], Property_IsGraphSelected(Memory, Property->Block_Bezier_Index, ArrayLocation, InfoLocation->KeyframeCount))) { File_DeselectAllKeyframes(File, State, Memory, SortedCompArray, SortedLayerArray, SortedPropertyStart, SortedKeyframeArray); - for (int p = 0; p < Property->Keyframe_Count; p++) { + for (int p = 0; p < InfoLocation->KeyframeCount; p++) { int k = ArrayLocation[p]; - bezier_point *Point = Bezier_LookupAddress(Memory, Property, k); + bezier_point *Point = Bezier_LookupAddress(Memory, Property->Block_Bezier_Index, k); Point->IsSelected = true; } State->RecentSelectionType = selection_type_keyframe; @@ -147,16 +149,16 @@ ImGui_Timeline_GraphInfo(project_data *File, project_state *State, memory *Memor } 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, +ImGui_Timeline_DrawKeySheet(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io, ImDrawList *draw_list, property_channel *Property, sorted_property_array *InfoLocation, uint16 *ArrayLocation, ImVec2 Increment, ImVec2 TimelineAbsolutePos, ImVec2 GraphPos, int Frame_Offset, ImVec2 TimelineMoveSize, ImVec2 TimelineZoomSize, ImVec2 TimelineSize, ImVec2 TimelineSizeWithBorder, real32 LayerIncrement, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, sorted_property_array *SortedPropertyStart, uint16 *SortedKeyframeArray) { ImGui::PushID(Property); - for (int p = 0; p < Property->Keyframe_Count; p++) { + for (int p = 0; p < InfoLocation->KeyframeCount; p++) { int k = ArrayLocation[p]; - bezier_point *PointAddress = Bezier_LookupAddress(Memory, Property, k); + bezier_point *PointAddress = Bezier_LookupAddress(Memory, Property->Block_Bezier_Index, k); v2 PointPos[3]; Bezier_Interact_Evaluate(State, PointAddress, PointPos); @@ -287,8 +289,8 @@ ImGui_Timeline_DrawGraph(project_data *File, project_state *State, memory *Memor if (Property->Block_Bezier_Count) { real32 MinY, MaxY; Property_MinMax_Y(Memory, State, Property, InfoLocation, &MinY, &MaxY, 0); - Assert(InfoLocation->MinYIndex < Property->Keyframe_Count); - Assert(InfoLocation->MaxYIndex < Property->Keyframe_Count); + Assert(InfoLocation->MinYIndex < InfoLocation->KeyframeCount); + Assert(InfoLocation->MaxYIndex < InfoLocation->KeyframeCount); Assert(MaxY >= MinY); real32 Y_Increment = (MaxY - MinY) ? (1 / (MaxY - MinY)) : 0.5; @@ -309,19 +311,19 @@ ImGui_Timeline_DrawGraph(project_data *File, project_state *State, memory *Memor real32 GraphMoveHeight = TimelineMoveSize.y + (TimelineZoomSize.y * GraphPos); real32 GraphZoomHeight = TimelineZoomSize.y * GraphScale; - bool32 IsGraphSelected = Property_IsGraphSelected(Memory, Property, ArrayLocation); + bool32 IsGraphSelected = Property_IsGraphSelected(Memory, Property->Block_Bezier_Index, ArrayLocation, InfoLocation->KeyframeCount); uint32 GraphCol = IsGraphSelected ? IM_COL32(255, 180, 150, 255) : IM_COL32(255, 255, 255, 70); bezier_point *PointAddress[2] = {}; ImVec2 Keyframe_ScreenPos[6] = {}; - for (int p = 0; p < Property->Keyframe_Count; p++) { + for (int p = 0; p < InfoLocation->KeyframeCount; p++) { int k = ArrayLocation[p]; - if (Property->Keyframe_Count == 1) + if (InfoLocation->KeyframeCount == 1) int b = 0; int Idx = (p % 2); int NewIdx = Idx * 3; int OldIdx = (NewIdx == 3) ? 0 : 3; - PointAddress[Idx] = Bezier_LookupAddress(Memory, Property, k); + PointAddress[Idx] = Bezier_LookupAddress(Memory, Property->Block_Bezier_Index, k); v2 PointPos[3]; Bezier_Interact_Evaluate(State, PointAddress[Idx], PointPos, GraphZoomHeight, Y_Increment); @@ -639,6 +641,13 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem if (ImGui::MenuItem("Duplicate layer")) { State->HotkeyInput = hotkey_duplicatelayer; } + ImGui::Button("Layer Offset"); + if (ImGui::IsItemActive()) { + Layer->Frame_Offset -= 120; + Layer->Frame_Start += 120; + Layer->Frame_End += 120; + State->UpdateFrame = true; + } if (ImGui::MenuItem("Delete layer")) { State->HotkeyInput = hotkey_deletelayer; State->UpdateKeyframes = true; @@ -683,7 +692,22 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem { const bool is_selected = (*item_current_idx == n); if (ImGui::Selectable(BlendmodeNames[n], is_selected)) { - *item_current_idx = n; + int h = 0, z = 0, i = 0; + bool32 Commit = false; + while (Block_Loop(Memory, F_Layers, File->Layer_Count, &h, &z, &i)) { + block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, i); + if (Layer->IsSelected & 0x01) { + if (!Commit) { + History_Entry_Commit(Memory, "Change layer blend mode"); + Commit = true; + } + History_Action_Swap(Memory, F_Layers, sizeof(Layer->BlendMode), &Layer->BlendMode); + Layer->BlendMode = (blend_mode)n; + } + } + if (Commit) { + History_Entry_End(Memory); + } State->UpdateFrame = true; } @@ -764,7 +788,7 @@ ImGui_Timeline_DrawPrecomp(project_data *File, project_state *State, memory *Mem ImVec2 GraphMaxBounds = GraphMinBounds + ImVec2(TimelineSizeWithBorder.x, Layer_ScreenSize.y); uint32 col = (Channel % 2) ? IM_COL32(50, 50, 50, 255) : IM_COL32(70, 70, 70, 255); draw_list->AddRectFilled(GraphMinBounds, GraphMaxBounds, col); - ImGui_Timeline_DrawKeySheet(File, State, Memory, UI, io, draw_list, Property, ArrayLocation, + ImGui_Timeline_DrawKeySheet(File, State, Memory, UI, io, draw_list, Property, InfoLocation, ArrayLocation, Increment, TimelineAbsolutePos, GraphPos, Frame_Offset, TimelineMoveSize, TimelineZoomSize, TimelineSize, TimelineSizeWithBorder, LayerIncrement, SortedCompArray, SortedLayerArray, SortedPropertyStart, SortedKeyframeArray); |