From 7d3dcee5b370c05065eb409ad5c21d0bc64790b1 Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Thu, 28 Jul 2022 17:28:13 -0400 Subject: blend modes implemented in renderers --- my_imgui_widgets.cpp | 117 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 96 insertions(+), 21 deletions(-) (limited to 'my_imgui_widgets.cpp') diff --git a/my_imgui_widgets.cpp b/my_imgui_widgets.cpp index 440694b..f94e47c 100644 --- a/my_imgui_widgets.cpp +++ b/my_imgui_widgets.cpp @@ -202,9 +202,9 @@ ImGui_Viewport(project_data File, project_state *State, ui *UI, pixel_buffer Com // } ImGui::OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonMiddle); if (ImGui::BeginPopup("context")) { - if (ImGui::MenuItem("Scalar", NULL, false, InstructionMode != scalar_only)) { InstructionMode = scalar_only; } - if (ImGui::MenuItem("SSE", NULL, false, InstructionMode != sse_enabled)) { InstructionMode = sse_enabled; } - if (ImGui::MenuItem("AVX2", NULL, false, InstructionMode != avx_enabled)) { InstructionMode = avx_enabled; } + if (ImGui::MenuItem("Scalar", NULL, false, InstructionMode != scalar_only)) { InstructionMode = scalar_only; State->UpdateFrame = true; } + if (ImGui::MenuItem("SSE", NULL, false, InstructionMode != sse_enabled)) { InstructionMode = sse_enabled; State->UpdateFrame = true; } + if (ImGui::MenuItem("AVX2", NULL, false, InstructionMode != avx_enabled)) { InstructionMode = avx_enabled; State->UpdateFrame = true; } ImGui::EndPopup(); } if (IsActive && ImGui::IsMouseDragging(ImGuiMouseButton_Left, -1.0f) && ImGui::IsKeyDown(ImGuiKey_Z)) @@ -327,6 +327,43 @@ ImGui_File(project_data *File, project_state *State, memory *Memory, ui *UI, ImG ImGui::End(); } +internal void +ImGui_EffectsPanel(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io) +{ + ImGui::Begin("Effects list", NULL); + if (State->RerouteEffects) { + ImGui::SetKeyboardFocusHere(); + State->RerouteEffects = 0; + } + int value_changed = ImGui::InputText("Effect name...", State->filter.InputBuf, IM_ARRAYSIZE(State->filter.InputBuf), + ImGuiInputTextFlags_CallbackCompletion, EffectConsoleCallback); + + if (Hacko) { + if (!io.KeyShift) + EffectSel++; + else + EffectSel--; + Hacko = 0; + } + if (value_changed) { + State->filter.Build(); + EffectSel = -1; + } + for (int32 i = 0; i < AmountOf(EffectList); i++) { + if (State->filter.PassFilter(EffectList[i].Name)) { + if (EffectSel == i) { + bool t = true; + ImGui::Selectable(EffectList[i].Name, &t); + } else { + bool s = false; + ImGui::Selectable(EffectList[i].Name, &s); + } + // ImGui::Text(EffectList[i].Name); + } + } + ImGui::End(); +} + internal void ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, ImGuiIO io) @@ -458,6 +495,24 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, ImGui::Button("V"); ImGui::SameLine(); ImGui::Button("I"); ImGui::SameLine(); ImGui::Text(Layer->Name); ImGui::SameLine(); + ImGui::Button(BlendmodeNames[Layer->BlendMode]); + ImGui::OpenPopupOnItemClick("blendmode_picker", ImGuiPopupFlags_MouseButtonLeft); + if (ImGui::BeginPopup("blendmode_picker")) { + for (int16 b = 0; b < AmountOf(BlendmodeNames); b++) { + if (ImGui::MenuItem(BlendmodeNames[b], NULL, false, Layer->BlendMode != b)) { + Layer->BlendMode = (blend_mode)b; + State->UpdateFrame = true; + } + // using IsActivated here instead of above loop doesn't seem to + // work; the popup gets closed instead + if (ImGui::IsItemHovered() && io.KeyCtrl) { + Layer->BlendMode = (blend_mode)b; + State->UpdateFrame = true; + } + } + ImGui::EndPopup(); + } + ImGui::SameLine(); ImGui::SetCursorScreenPos(ImVec2(SidebarStartingPos.x, ImGui::GetCursorScreenPos().y)); ImGui::Button("##mover", ImVec2(SidebarSizeWithBorder.x, FontHeight + FramePadding.y*2)); @@ -534,6 +589,9 @@ ImGui_Timeline(project_data *File, project_state *State, memory *Memory, ui *UI, ImGui::SetCursorScreenPos(ImVec2(WindowMinAbs.x + UI->TimelineSplit - TimelineBorderPadding.x, TimelineAbsolutePos.y)); ImGui::InvisibleButton("##SplitMove", ImVec2(TimelineBorderPadding.x, SidebarSizeWithBorder.y), ImGuiButtonFlags_MouseButtonLeft); + if (ImGui::IsItemHovered()) { + ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW); + } if (ImGui::IsItemActive() && ImGui::IsMouseDragging(ImGuiMouseButton_Left, -1)) { UI->TimelineSplit += io.MouseDelta.x; @@ -980,9 +1038,14 @@ ImGui_ProcessInputs(project_data *File, project_state *State, pixel_buffer *Comp if (ImGui::IsKeyPressed(ImGuiKey_Space)) { - SwitchBool(State->IsPlaying); + if (io.KeyShift) { + State->RerouteEffects = true; + } else { + SwitchBool(State->IsPlaying); + } } + if (State->IsPlaying && !IsRendering) { IncrementFrame(File, 1); State->UpdateFrame = true; @@ -1024,6 +1087,10 @@ ImGui_ProcessInputs(project_data *File, project_state *State, pixel_buffer *Comp } #if DEBUG + if (ImGui::IsKeyPressed(ImGuiKey_W)) + { + SwitchBool(Debug.ToggleWindow); + } if (ImGui::IsKeyPressed(ImGuiKey_M)) { Debug.Markers[Debug.MarkerIndex] = File->CurrentFrame; @@ -1065,9 +1132,9 @@ ImGui_ProcessInputs(project_data *File, project_state *State, pixel_buffer *Comp } } - global_variable char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]" -"\nSize=3153,1837" +"\nPos=0,0" +"\nSize=3200,1800" "\nCollapsed=0" "\n" "\n[Window][Debug##Default]" @@ -1077,18 +1144,19 @@ global_variable char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]" "\n" "\n[Window][Viewport]" "\nPos=528,0" -"\nSize=2121,1208" +"\nSize=2168,1171" "\nCollapsed=0" "\nDockId=0x00000005,0" "\n" "\n[Window][###Properties]" -"\nSize=526,1208" +"\nPos=0,0" +"\nSize=526,1171" "\nCollapsed=0" "\nDockId=0x00000003,0" "\n" "\n[Window][Timeline]" -"\nPos=0,1210" -"\nSize=3153,627" +"\nPos=0,1173" +"\nSize=3200,627" "\nCollapsed=0" "\nDockId=0x00000002,0" "\n" @@ -1098,17 +1166,24 @@ global_variable char ImGuiPrefs[] = "[Window][DockSpaceViewport_11111111]" "\nCollapsed=0" "\n" "\n[Window][Files]" -"\nPos=2651,0" -"\nSize=502,1208" +"\nPos=2698,0" +"\nSize=502,913" +"\nCollapsed=0" +"\nDockId=0x00000007,0" +"\n" +"\n[Window][Effects list]" +"\nPos=2698,915" +"\nSize=502,256" "\nCollapsed=0" -"\nDockId=0x00000006,0" +"\nDockId=0x00000008,0" "\n" "\n[Docking][Data]" -"\nDockSpace ID=0x8B93E3BD Pos=0,0 Size=3153,1837 Split=Y Selected=0x13926F0B" -"\n DockNode ID=0x00000001 Parent=0x8B93E3BD SizeRef=3200,1171 Split=X Selected=0x13926F0B" -"\n DockNode ID=0x00000003 Parent=0x00000001 SizeRef=526,1171 Selected=0xDBB8CEFA" -"\n DockNode ID=0x00000004 Parent=0x00000001 SizeRef=2672,1171 Split=X Selected=0x13926F0B" -"\n DockNode ID=0x00000005 Parent=0x00000004 SizeRef=2115,1171 CentralNode=1 Selected=0x13926F0B" -"\n DockNode ID=0x00000006 Parent=0x00000004 SizeRef=502,1171 Selected=0x86FA2F90" -"\n DockNode ID=0x00000002 Parent=0x8B93E3BD SizeRef=3200,627 HiddenTabBar=1 Selected=0x0F18B61B" -"\n"; +"\nDockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,0 Size=3200,1800 Split=Y Selected=0x13926F0B" +"\n DockNode ID=0x00000001 Parent=0x8B93E3BD SizeRef=3200,1171 Split=X Selected=0x13926F0B" +"\n DockNode ID=0x00000003 Parent=0x00000001 SizeRef=526,1171 Selected=0xDBB8CEFA" +"\n DockNode ID=0x00000004 Parent=0x00000001 SizeRef=2672,1171 Split=X Selected=0x13926F0B" +"\n DockNode ID=0x00000005 Parent=0x00000004 SizeRef=2115,1171 CentralNode=1 Selected=0x13926F0B" +"\n DockNode ID=0x00000006 Parent=0x00000004 SizeRef=502,1171 Split=Y Selected=0x86FA2F90" +"\n DockNode ID=0x00000007 Parent=0x00000006 SizeRef=502,913 Selected=0x86FA2F90" +"\n DockNode ID=0x00000008 Parent=0x00000006 SizeRef=502,256 Selected=0x812F222D" +"\n DockNode ID=0x00000002 Parent=0x8B93E3BD SizeRef=3200,627 HiddenTabBar=1 Selected=0x0F18B61B"; -- cgit v1.2.3