From ef3bf8f92445b8ef8cd52d23a43f1be347ba7f2d Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 20 Mar 2022 18:31:25 -0500 Subject: [PATCH] GUI: display sample selection - NOT FINISHED --- src/gui/sampleEdit.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index f90f3d9c6..7594d1fe4 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -373,9 +373,10 @@ void FurnaceGUI::drawSampleEdit() { } } String statusBar=sampleDragMode?"Draw":"Select"; + bool drawSelection=false; if (!sampleDragMode) { - if (sampleSelStart>=0 && sampleSelEnd>=0) { + if (sampleSelStart>=0 && sampleSelEnd>=0 && sampleSelStart!=sampleSelEnd) { int start=sampleSelStart; int end=sampleSelEnd; if (start>end) { @@ -384,6 +385,7 @@ void FurnaceGUI::drawSampleEdit() { start^=end; } statusBar+=fmt::sprintf(" (%d-%d)",start,end); + drawSelection=true; } } @@ -403,6 +405,24 @@ void FurnaceGUI::drawSampleEdit() { statusBar+=fmt::sprintf(" | (%d, %d)",posX,posY); } } + + if (drawSelection) { + int start=sampleSelStart; + int end=sampleSelEnd; + if (start>end) { + start^=end; + end^=start; + start^=end; + } + ImDrawList* dl=ImGui::GetWindowDrawList(); + ImVec2 p1=ImGui::GetItemRectMin(); + p1.x+=start/sampleZoom-samplePos; + + ImVec2 p2=ImVec2(ImGui::GetItemRectMin().x+end/sampleZoom-samplePos,ImGui::GetItemRectMax().y); + + // TODO: color + dl->AddRectFilled(p1,p2,0xc0c0c0c0); + } ImGui::Text("%s",statusBar.c_str()); }