[sim] Fix Field2D GUI crash when collapsed (#2786)

Collapsed windows result in a vertical content size of 0.
This commit is contained in:
Peter Johnson
2020-10-19 22:03:06 -07:00
committed by GitHub
parent 7fc48b75dd
commit b66fcdb3f7

View File

@@ -565,7 +565,10 @@ static void DisplayField2D() {
// for dragging to work, there needs to be a button (otherwise the window is
// dragged)
ImGui::InvisibleButton("field", ImGui::GetContentRegionAvail());
ImVec2 contentSize =
ImGui::GetWindowContentRegionMax() - ImGui::GetWindowContentRegionMin();
if (contentSize.x <= 0 || contentSize.y <= 0) return;
ImGui::InvisibleButton("field", contentSize);
// allow dragging the robot around
ImVec2 cursor = ImGui::GetIO().MousePos - windowPos;