impr: Better 3D Visualizer error messages, wrap long visualizer errors (#1969)

### Problem description
Long error messages were forcing the width of the window to span the
entire screen.

### Implementation description
The fix was sending the long message to the log and outputting a short
message to the 3d visualizer window.

---------

Co-authored-by: WerWolv <werwolv98@gmail.com>
This commit is contained in:
paxcut
2024-12-15 02:12:14 -07:00
committed by GitHub
parent c6f1525f55
commit df5e01d4eb
2 changed files with 51 additions and 37 deletions

View File

@@ -27,8 +27,20 @@ namespace hex::ui {
ImGui::TextUnformatted("hex.ui.pattern_drawer.visualizer.unknown"_lang);
}
if (!m_lastVisualizerError.empty())
ImGui::TextUnformatted(m_lastVisualizerError.c_str());
if (!m_lastVisualizerError.empty()) {
auto windowWidth = ImGui::GetContentRegionAvail().x-2 * ImGuiStyleVar_WindowPadding;
auto errorMessageSize = ImGui::CalcTextSize(m_lastVisualizerError.c_str());
if (errorMessageSize.x > windowWidth)
errorMessageSize.y *= 2;
auto errorMessageWindowSize = ImVec2(windowWidth, errorMessageSize.y);
if (ImGui::BeginChild("##error_message", errorMessageWindowSize, 0, ImGuiWindowFlags_HorizontalScrollbar)) {
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0F, 0.0F, 0.0F, 1.0F));
ImGui::TextUnformatted(m_lastVisualizerError.c_str());
ImGui::PopStyleColor();
}
ImGui::EndChild();
}
}
}