impr: Better UI for the settings view

This commit is contained in:
WerWolv
2023-11-15 22:22:57 +01:00
parent e32def409a
commit a51f9fd90c
4 changed files with 27 additions and 10 deletions

View File

@@ -269,6 +269,9 @@ namespace ImGui {
bool BeginBox();
void EndBox();
void BeginSubWindow(const char *label, ImVec2 size = ImVec2(0, 0));
void EndSubWindow();
template<typename T>
constexpr ImGuiDataType getImGuiDataType() {
if constexpr (std::same_as<T, u8>) return ImGuiDataType_U8;

View File

@@ -834,4 +834,21 @@ namespace ImGui {
ImGui::PopStyleVar();
}
void BeginSubWindow(const char *label, ImVec2 size) {
const bool hasMenuBar = !std::string_view(label).empty();
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f);
if (ImGui::BeginChild(label, size, ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeY, hasMenuBar ? ImGuiWindowFlags_MenuBar : ImGuiWindowFlags_None)) {
if (hasMenuBar && ImGui::BeginMenuBar()) {
ImGui::TextUnformatted(label);
ImGui::EndMenuBar();
}
}
}
void EndSubWindow() {
ImGui::EndChild();
ImGui::PopStyleVar();
}
}