diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 13aa4385c..b63ec927a 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -148,6 +148,11 @@ void FurnaceGUI::updateScroll(int amount) { nextScroll=lineHeight*amount; } +void FurnaceGUI::addScroll(int amount) { + float lineHeight=(ImGui::GetTextLineHeight()+2*dpiScale); + nextAddScroll=lineHeight*amount; +} + void FurnaceGUI::updateWindowTitle() { if (e->song.name.empty()) { SDL_SetWindowTitle(sdlWin,fmt::sprintf("Furnace (%s)",e->getSystemName(e->song.system)).c_str()); @@ -988,7 +993,9 @@ void FurnaceGUI::drawPattern() { } ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding,ImVec2(0.0f,0.0f)); if (ImGui::Begin("Pattern",&patternOpen)) { - ImGui::SetWindowSize(ImVec2(scrW*dpiScale,scrH*dpiScale)); + //ImGui::SetWindowSize(ImVec2(scrW*dpiScale,scrH*dpiScale)); + patWindowPos=ImGui::GetWindowPos(); + patWindowSize=ImGui::GetWindowSize(); char id[32]; ImGui::PushFont(patFont); unsigned char ord=e->isPlaying()?oldOrder:e->getOrder(); @@ -1007,6 +1014,12 @@ void FurnaceGUI::drawPattern() { if (nextScroll>-0.5f) { ImGui::SetScrollY(nextScroll); nextScroll=-1.0f; + nextAddScroll=0.0f; + } + if (nextAddScroll!=0.0f) { + ImGui::SetScrollY(ImGui::GetScrollY()+nextAddScroll); + nextScroll=-1.0f; + nextAddScroll=0.0f; } ImGui::TableSetupScrollFreeze(1,1); for (int i=0; ipatWindowPos.y+patWindowSize.y) { + addScroll(1); + } } if (macroDragActive) { if (macroDragLen>0) { @@ -2477,7 +2495,8 @@ FurnaceGUI::FurnaceGUI(): macroDragMin(0), macroDragMax(0), macroDragActive(false), - nextScroll(-1.0f) { + nextScroll(-1.0f), + nextAddScroll(0.0f) { uiColors[GUI_COLOR_BACKGROUND]=ImVec4(0.1f,0.1f,0.1f,1.0f); uiColors[GUI_COLOR_FRAME_BACKGROUND]=ImVec4(0.0f,0.0f,0.0f,0.85f); uiColors[GUI_COLOR_CHANNEL_FM]=ImVec4(0.2f,0.8f,1.0f,1.0f); diff --git a/src/gui/gui.h b/src/gui/gui.h index 8a82517a0..e01365909 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -151,7 +151,9 @@ class FurnaceGUI { int waveDragMin, waveDragMax; bool waveDragActive; - float nextScroll; + float nextScroll, nextAddScroll; + + ImVec2 patWindowPos, patWindowSize; void updateWindowTitle(); void prepareLayout(); @@ -197,6 +199,7 @@ class FurnaceGUI { bool decodeNote(const char* what, short& note, short& octave); void bindEngine(DivEngine* eng); void updateScroll(int amount); + void addScroll(int amount); bool loop(); bool finish(); bool init();