MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / show_debug_window

Method show_debug_window

framework/gui.h:1193–1236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1191template <vkb::BindingType bindingType>
1192inline 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
1237template <vkb::BindingType bindingType>
1238inline void Gui<bindingType>::show_options_window(std::function<void()> body, const uint32_t lines)
1239{

Callers

nothing calls this directly

Calls 3

get_longest_labelMethod · 0.80
sizeMethod · 0.80
to_stringMethod · 0.45

Tested by

no test coverage detected