diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index a58feea87..dca41f17f 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -943,7 +943,7 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, ImU32 colorR=ImGui::GetColorU32(uiColors[GUI_COLOR_FM_ENVELOPE_RELEASE]); // Relsease triangle ImU32 colorS=ImGui::GetColorU32(uiColors[GUI_COLOR_FM_ENVELOPE_SUS_GUIDE]); // Sustain horiz/vert line color ImGui::ItemSize(size,style.FramePadding.y); - if (ImGui::ItemAdd(rect,ImGui::GetID("alg"))) { + if (ImGui::ItemAdd(rect,ImGui::GetID("fmEnv"))) { ImGui::RenderFrame(rect.Min,rect.Max,ImGui::GetColorU32(ImGuiCol_FrameBg),true,style.FrameRounding); //Adjust for OPLL global sustain setting @@ -1003,7 +1003,7 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, } void FurnaceGUI::drawGBEnv(unsigned char vol, unsigned char len, unsigned char sLen, bool dir, const ImVec2& size) { - //ImDrawList* dl=ImGui::GetWindowDrawList(); + ImDrawList* dl=ImGui::GetWindowDrawList(); ImGuiWindow* window=ImGui::GetCurrentWindow(); ImVec2 minArea=window->DC.CursorPos; @@ -1013,13 +1013,50 @@ void FurnaceGUI::drawGBEnv(unsigned char vol, unsigned char len, unsigned char s ); ImRect rect=ImRect(minArea,maxArea); ImGuiStyle& style=ImGui::GetStyle(); - //ImU32 color=ImGui::GetColorU32(uiColors[GUI_COLOR_FM_ENVELOPE]); + ImU32 color=ImGui::GetColorU32(uiColors[GUI_COLOR_FM_ENVELOPE]); //ImU32 colorS=ImGui::GetColorU32(uiColors[GUI_COLOR_FM_ENVELOPE_SUS_GUIDE]); // Sustain horiz/vert line color ImGui::ItemSize(size,style.FramePadding.y); - if (ImGui::ItemAdd(rect,ImGui::GetID("alg"))) { + if (ImGui::ItemAdd(rect,ImGui::GetID("gbEnv"))) { ImGui::RenderFrame(rect.Min,rect.Max,ImGui::GetColorU32(ImGuiCol_FrameBg),true,style.FrameRounding); + + float volY=1.0-((float)vol/15.0); + float lenPos=(sLen>62)?1.0:((float)sLen/384.0); + float envEndPoint=((float)len/7.0)*((float)(dir?(15-vol):vol)/15.0); - // TODO: this whole thing + ImVec2 pos1=ImLerp(rect.Min,rect.Max,ImVec2(0.0,volY)); + ImVec2 pos2; + if (dir) { + if (len>0) { + if (lenPos0) { + if (lenPos0 || sLen<63)?((dir && sLen>62)?0.0:1.0):volY)); + + addAALine(dl,pos1,pos2,color); + if (lenPos>=envEndPoint && sLen<63 && dir) { + pos3=ImLerp(rect.Min,rect.Max,ImVec2(lenPos,0.0)); + addAALine(dl,pos2,pos3,color); + ImVec2 pos4=ImLerp(rect.Min,rect.Max,ImVec2(lenPos,1.0)); + addAALine(dl,pos3,pos4,color); + } else { + addAALine(dl,pos2,pos3,color); + } } }