diff options
author | Fox Caminiti <fox@foxcam.net> | 2022-08-16 15:06:45 -0400 |
---|---|---|
committer | Fox Caminiti <fox@foxcam.net> | 2022-08-16 15:06:45 -0400 |
commit | e89dc91182a94e48ca9220a2fe075db680ddff04 (patch) | |
tree | a277c1e38293f92e635c981ad2f6b0d84d103e09 /my_imgui_widgets.cpp | |
parent | 04b7ccfd87d802e6b9a22b86c8d098979164b8ba (diff) |
undo functional
Diffstat (limited to 'my_imgui_widgets.cpp')
-rw-r--r-- | my_imgui_widgets.cpp | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp index d1d8d83..b924d55 100644 --- a/my_imgui_widgets.cpp +++ b/my_imgui_widgets.cpp @@ -70,6 +70,26 @@ ImGui_KeyframeDragging(project_data *File, project_state *State, ui *UI, propert } } +static void +ImGui_InteractSliderProperty(project_state *State, memory *Memory, property_channel *Property) +{ + ImGui::DragScalar(Property->Name, ImGuiDataType_Float, &Property->CurrentValue.f, + Property->ScrubVal.f, &Property->MinVal.f, &Property->MaxVal.f, "%f"); + if (ImGui::IsItemActivated()) { + Action_Entry_Begin(Memory, action_entry_default, "Tranforms interact"); + State->InteractCache[0] = Property->CurrentValue.f; + } + if (ImGui::IsItemActive()) { + State->UpdateFrame = true; + } + if (ImGui::IsItemDeactivated()) { + Action_Change_Commit(Memory, &Property->CurrentValue.f, &State->InteractCache[0], + &Property->CurrentValue.f, action_change_r32); + Action_Entry_End(Memory); + State->UpdateFrame = true; + } +} + // Returns a normalized UV position of the composition static v2 ImGui_ScreenPointToCompUV(ImVec2 ViewportMin, ImVec2 CompPos, ImVec2 CompZoom, ImVec2 MousePos) @@ -82,6 +102,19 @@ ImGui_ScreenPointToCompUV(ImVec2 ViewportMin, ImVec2 CompPos, ImVec2 CompZoom, I } static void +ImGui_DebugUndoTree(project_data *File, memory *Memory) +{ + ImGui::SetNextWindowSize(ImVec2(200, 800)); + ImGui::Begin("undotree"); + for (int i = 0; i < Memory->Action.NumberOfEntries; i++) { + action_entry Entry = Memory->Action.Entry[i]; + bool32 CurrentPos = (i < Memory->Action.Index); + ImGui::MenuItem(Entry.Name, NULL, CurrentPos); + } + ImGui::End(); +} + +static void ImGui_DebugMemoryViewer(project_data *File, memory *Memory) { ImGui::SetNextWindowSize(ImVec2(800, 200)); @@ -194,11 +227,7 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory * if (ImGui::Button("K")) ManualKeyframeInsertF(Property, Memory, File->CurrentFrame, Property->CurrentValue.f); ImGui::SameLine(); - if (ImGui::DragScalar(Property->Name, ImGuiDataType_Float, &Property->CurrentValue.f, - Property->ScrubVal.f, &Property->MinVal.f, &Property->MaxVal.f, "%f")) - { - State->UpdateFrame = true; - } + ImGui_InteractSliderProperty(State, Memory, Property); ImGui::PopID(); } for (int h = 0; h < Layer->NumberOfEffects; h++) { @@ -221,9 +250,9 @@ ImGui_PropertiesPanel(project_data *File, project_state *State, ui *UI, memory * for (int i = 0; i < Effect->NumberOfProperties; i++) { property_channel *Property = &Effect->Property[i]; ImGui::PushID(Property); - if (Property->VarType == type_real) - if (ImGui::DragScalar(Property->Name, ImGuiDataType_Float, &Property->CurrentValue.f, 0.005f, &Property->MaxVal.f, &Property->MaxVal.f, "%f")) - State->UpdateFrame = true; + if (Property->VarType == type_real) { + ImGui_InteractSliderProperty(State, Memory, Property); + } if (Property->VarType == type_color) if (ImGui::ColorEdit4("color 1", &Property->CurrentValue.f, ImGuiColorEditFlags_Float)) State->UpdateFrame = true; @@ -1493,6 +1522,15 @@ ImGui_ProcessInputs(project_data *File, project_state *State, comp_buffer *CompB State->UpdateKeyframes = true; } + if (ImGui::IsKeyPressed(ImGuiKey_Z)) { + if (io.KeyCtrl && io.KeyShift) { + Action_Redo(Memory); + } else if (io.KeyCtrl) { + Action_Undo(Memory); + } + State->UpdateFrame = true; + State->UpdateKeyframes = true; + } if (ImGui::IsKeyPressed(ImGuiKey_Space)) { if (io.KeyShift) { @@ -1510,13 +1548,13 @@ ImGui_ProcessInputs(project_data *File, project_state *State, comp_buffer *CompB } if (ImGui::IsKeyPressed(ImGuiKey_R) && State->NumberOfSelectedLayers) - TransformsInteract(File, State, UI, sliding_rotation); + TransformsInteract(File, State, Memory, UI, sliding_rotation); if (ImGui::IsKeyPressed(ImGuiKey_S) && State->NumberOfSelectedLayers) - TransformsInteract(File, State, UI, sliding_scale); + TransformsInteract(File, State, Memory, UI, sliding_scale); if (ImGui::IsKeyPressed(ImGuiKey_G) && State->NumberOfSelectedLayers) - TransformsInteract(File, State, UI, sliding_position); + TransformsInteract(File, State, Memory, UI, sliding_position); if (ImGui::IsKeyPressed(ImGuiKey_A) && State->NumberOfSelectedLayers) - TransformsInteract(File, State, UI, sliding_anchorpoint); + TransformsInteract(File, State, Memory, UI, sliding_anchorpoint); if (ImGui::IsKeyPressed(ImGuiKey_1)) LoadTestFootage(File, State, Memory); |