From b39c7374009d03d448e47e08ddabc30abeee5247 Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Thu, 25 Aug 2022 18:55:59 -0400 Subject: minor fixes --- my_imgui_widgets.cpp | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'my_imgui_widgets.cpp') diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp index 1ef4d31..d2fa7c0 100644 --- a/my_imgui_widgets.cpp +++ b/my_imgui_widgets.cpp @@ -425,7 +425,7 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, memory *Memory, ImVec2 ViewportMin = ImGui::GetCursorScreenPos(); ImVec2 ViewportScale = ImGui::GetContentRegionAvail(); - ViewportScale.y -= ImGui::GetFontSize(); + ViewportScale.y -= ImGui::GetFontSize()*0.5; if (ViewportScale.x < 50.0f) ViewportScale.x = 50.0f; if (ViewportScale.y < 50.0f) ViewportScale.y = 50.0f; ImVec2 ViewportMax = ImVec2(ViewportMin.x + ViewportScale.x, ViewportMin.y + ViewportScale.y); @@ -705,36 +705,32 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, memory *Memory, } IsDeactivated = false; // just in case escape and mouse release happen simultaneously } + mask *Mask = &Layer->Mask[Layer->NumberOfMasks-1]; if (IsDeactivated) { mask *Mask = &Layer->Mask[Layer->NumberOfMasks-1]; if (Mask->NumberOfPoints == 1) { + // NOTE(fox): We have to use this slightly janky way of writing to + // the history tree since we can only create entries/actions once we + // know the user is committed to them. Might write an escapable + // entry mode if we do this often. uint16 PreviousNumberOfMasks = Layer->NumberOfMasks - 1; uint16 PreviousNumberOfPoints = Mask->NumberOfPoints - 1; + bool32 NotActive = false; History_Entry_Commit(Memory, action_entry_default, "Create mask"); + History_Action_Change(Memory, &State->Pen.IsActive, &NotActive, + &State->Pen.IsActive, action_type_change_u32); History_Action_Change(Memory, &Layer->NumberOfMasks, &PreviousNumberOfMasks, - &Layer->NumberOfMasks, action_type_change_u16); + &Layer->NumberOfMasks, action_type_change_u16); History_Action_Change(Memory, &Mask->NumberOfPoints, &PreviousNumberOfPoints, - &Mask->NumberOfPoints, action_type_change_u16); + &Mask->NumberOfPoints, action_type_change_u16); History_Entry_End(Memory); } else { uint16 PreviousNumberOfPoints = Mask->NumberOfPoints - 1; - uint16 Empty = 0; mask_point *CurrentPoint = &Mask->Point[Mask->NumberOfPoints-1]; History_Entry_Commit(Memory, action_entry_default, "Add point"); History_Action_Change(Memory, &Mask->NumberOfPoints, &PreviousNumberOfPoints, &Mask->NumberOfPoints, action_type_change_u16); - History_Action_Change(Memory, &CurrentPoint->Pos.x, &Empty, - &CurrentPoint->Pos.x, action_type_change_r32); - History_Action_Change(Memory, &CurrentPoint->Pos.y, &Empty, - &CurrentPoint->Pos.y, action_type_change_r32); - History_Action_Change(Memory, &CurrentPoint->TangentLeft.x, &Empty, - &CurrentPoint->TangentLeft.x, action_type_change_r32); - History_Action_Change(Memory, &CurrentPoint->TangentLeft.y, &Empty, - &CurrentPoint->TangentLeft.y, action_type_change_r32); - History_Action_Change(Memory, &CurrentPoint->TangentRight.x, &Empty, - &CurrentPoint->TangentRight.x, action_type_change_r32); - History_Action_Change(Memory, &CurrentPoint->TangentRight.y, &Empty, - &CurrentPoint->TangentRight.y, action_type_change_r32); + History_Action_StoreData(Memory, &CurrentPoint, sizeof(mask_point)); History_Entry_End(Memory); } } @@ -791,6 +787,8 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, memory *Memory, UI->CompPos.y -= Distance*UI->TempZoomRatio.y; } + ImGui::SetCursorScreenPos(ImVec2(ViewportMin.x, ViewportMin.y + ViewportScale.y - ImGui::GetFontSize()*1.5)); + ImGui::Text("%.1f", 100.0f * (UI->CompZoom.x / CompBuffer.Width)); if (State->MsgTime > 0) { ImGui::SameLine(); @@ -846,6 +844,7 @@ ImGui_File(project_data *File, project_state *State, memory *Memory, ui *UI, ImG { ImGui::Begin("Files"); ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); +#if DEBUG if (State->DemoButton) { if (ImGui::Button("Generate demo scene")) { CreateDemoScene(File, State, Memory); @@ -863,6 +862,7 @@ ImGui_File(project_data *File, project_state *State, memory *Memory, ui *UI, ImG State->GridButton = false; } } +#endif ImGui::Text("Sources:"); for (int i = 0; i < File->NumberOfSources; i++) { bool32 Test = false; @@ -881,12 +881,11 @@ ImGui_File(project_data *File, project_state *State, memory *Memory, ui *UI, ImG } ImGui::EndPopup(); } - // static char Input[1024]; - // ImGui::InputText("##sourceinput", Input, STRING_SIZE); - // ImGui::SameLine(); - // if (ImGui::Button("Create Layer")) { - // // AddSource(File, State, Memory, Input); - // } + static char Input[1024]; + ImGui::InputTextWithHint("##sourceinput", "Input file path of source...", Input, STRING_SIZE); + if (ImGui::IsItemDeactivated() && ImGui::IsKeyPressed(ImGuiKey_Enter)) { + Source_Generate(File, State, Memory, Input); + } #if DEBUG for (int i = 0; i < Debug.Temp.WatchedProperties; i++) { if (Debug.Temp.DebugPropertyType[i] == d_float) { -- cgit v1.2.3