| 1191 | template <vkb::BindingType bindingType> |
| 1192 | inline void Gui<bindingType>::show_debug_window(DebugInfo &debug_info, const ImVec2 &position) |
| 1193 | { |
| 1194 | auto &io = ImGui::GetIO(); |
| 1195 | auto &style = ImGui::GetStyle(); |
| 1196 | auto &font = get_font(default_window_font); |
| 1197 | |
| 1198 | // Calculate only once |
| 1199 | if (debug_view.label_column_width == 0) |
| 1200 | { |
| 1201 | debug_view.label_column_width = style.ItemInnerSpacing.x + debug_info.get_longest_label() * font.size / debug_view.scale; |
| 1202 | } |
| 1203 | |
| 1204 | ImGui::SetNextWindowBgAlpha(overlay_alpha); |
| 1205 | ImGui::SetNextWindowPos(position, ImGuiCond_FirstUseEver); |
| 1206 | ImGui::SetNextWindowContentSize(ImVec2{io.DisplaySize.x, 0.0f}); |
| 1207 | |
| 1208 | bool is_open = true; |
| 1209 | const ImGuiWindowFlags flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | |
| 1210 | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav; |
| 1211 | |
| 1212 | ImGui::Begin("Debug Window", &is_open, flags); |
| 1213 | ImGui::PushFont(font.handle); |
| 1214 | |
| 1215 | auto field_count = debug_info.get_fields().size() > debug_view.max_fields ? debug_view.max_fields : debug_info.get_fields().size(); |
| 1216 | |
| 1217 | ImGui::BeginChild("Table", ImVec2(0, field_count * (font.size + style.ItemSpacing.y)), false); |
| 1218 | ImGui::Columns(2); |
| 1219 | ImGui::SetColumnWidth(0, debug_view.label_column_width); |
| 1220 | ImGui::SetColumnWidth(1, io.DisplaySize.x - debug_view.label_column_width); |
| 1221 | for (auto &field : debug_info.get_fields()) |
| 1222 | { |
| 1223 | const std::string &label = field->label; |
| 1224 | const std::string &value = field->to_string(); |
| 1225 | ImGui::Text("%s", label.c_str()); |
| 1226 | ImGui::NextColumn(); |
| 1227 | ImGui::Text(" %s", value.c_str()); |
| 1228 | ImGui::NextColumn(); |
| 1229 | } |
| 1230 | ImGui::Columns(1); |
| 1231 | ImGui::EndChild(); |
| 1232 | |
| 1233 | ImGui::PopFont(); |
| 1234 | ImGui::End(); |
| 1235 | } |
| 1236 | |
| 1237 | template <vkb::BindingType bindingType> |
| 1238 | inline void Gui<bindingType>::show_options_window(std::function<void()> body, const uint32_t lines) |
| 1239 | { |
nothing calls this directly
no test coverage detected