Skip to content

Commit 24642d2

Browse files
committed
Fixed some incorrectly calculated waveform area heights causing assertion failures in newest imgui, plus occasional spurious scrollbars
1 parent 7170fc7 commit 24642d2

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/ngscopeclient/WaveformArea.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,14 @@ bool WaveformArea::Render(int iArea, int numAreas, ImVec2 clientArea)
646646

647647
ImGui::PushID(to_string(iArea).c_str());
648648

649-
float totalHeightAvailable = floor(clientArea.y - ImGui::GetFrameHeightWithSpacing());
650-
totalHeightAvailable -= 5; //fudge factor, need to figure out root cause
649+
float totalHeightAvailable = floor(clientArea.y - 2*ImGui::GetFrameHeightWithSpacing());
651650
float spacing = m_group->GetSpacing();
652651
float heightPerArea = totalHeightAvailable / numAreas;
653-
float unspacedHeightPerArea = floor(heightPerArea - spacing);
652+
float totalSpacing = (numAreas-1)*spacing;
653+
float unspacedHeightPerArea = floor( (totalHeightAvailable - totalSpacing) / numAreas);
654+
unspacedHeightPerArea -= ImGui::GetStyle().FramePadding.y;
655+
if(numAreas == 1)
656+
unspacedHeightPerArea = heightPerArea;
654657

655658
//Update cached scale
656659
m_height = unspacedHeightPerArea;
@@ -746,14 +749,19 @@ bool WaveformArea::Render(int iArea, int numAreas, ImVec2 clientArea)
746749
RenderYAxis(ImVec2(yAxisWidth, unspacedHeightPerArea), gridmap, vbot, vtop);
747750

748751
//Render the Y axis cursors (if we have any) over the top of everything else
749-
auto oldpos = ImGui::GetCursorPos();
750752
{
751753
auto csize = ImGui::GetContentRegionAvail();
752754
auto pos = ImGui::GetWindowPos();
753755
ImGui::SetCursorPos(cpos);
754756
RenderYAxisCursors(pos, csize, yAxisWidth);
755757
}
756-
ImGui::SetCursorPos(oldpos);
758+
759+
//Cursor should now be at end of window
760+
ImGui::SetCursorPos(ImVec2(cpos.x, cpos.y + unspacedHeightPerArea));
761+
762+
//Add spacing
763+
if(iArea != numAreas-1)
764+
ImGui::Dummy(ImVec2(0, spacing));
757765

758766
ImGui::PopID();
759767

src/ngscopeclient/WaveformGroup.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ bool WaveformGroup::Render()
162162
TitleHoverHelp();
163163

164164
auto pos = ImGui::GetCursorScreenPos();
165-
ImVec2 clientArea = ImGui::GetContentRegionMax();
165+
ImVec2 clientArea = ImGui::GetContentRegionAvail();
166166
m_width = clientArea.x;
167167

168168
float yAxisWidthSpaced = GetYAxisWidth() + GetSpacing();
@@ -200,7 +200,6 @@ bool WaveformGroup::Render()
200200

201201
//Render the timeline
202202
m_timelineHeight = 2.5 * ImGui::GetFontSize();
203-
clientArea.y -= m_timelineHeight;
204203
RenderTimeline(plotWidth, m_timelineHeight);
205204

206205
//Close any areas that we destroyed last frame

0 commit comments

Comments
 (0)