impr: Better UI for the settings view
This commit is contained in:
parent
e32def409a
commit
a51f9fd90c
@ -269,6 +269,9 @@ namespace ImGui {
|
|||||||
bool BeginBox();
|
bool BeginBox();
|
||||||
void EndBox();
|
void EndBox();
|
||||||
|
|
||||||
|
void BeginSubWindow(const char *label, ImVec2 size = ImVec2(0, 0));
|
||||||
|
void EndSubWindow();
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr ImGuiDataType getImGuiDataType() {
|
constexpr ImGuiDataType getImGuiDataType() {
|
||||||
if constexpr (std::same_as<T, u8>) return ImGuiDataType_U8;
|
if constexpr (std::same_as<T, u8>) return ImGuiDataType_U8;
|
||||||
|
@ -834,4 +834,21 @@ namespace ImGui {
|
|||||||
ImGui::PopStyleVar();
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -4,6 +4,7 @@
|
|||||||
#include <hex/api/theme_manager.hpp>
|
#include <hex/api/theme_manager.hpp>
|
||||||
|
|
||||||
#include <hex/helpers/http_requests.hpp>
|
#include <hex/helpers/http_requests.hpp>
|
||||||
|
#include <hex/helpers/utils.hpp>
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <hex/ui/imgui_imhex_extensions.h>
|
#include <hex/ui/imgui_imhex_extensions.h>
|
||||||
@ -86,7 +87,7 @@ namespace hex::plugin::builtin {
|
|||||||
bool draw(const std::string &) override {
|
bool draw(const std::string &) override {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if (!ImGui::BeginListBox("", ImVec2(-38, -10))) {
|
if (!ImGui::BeginListBox("", ImVec2(-40_scaled, 280_scaled))) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
for (size_t n = 0; n < this->m_paths.size(); n++) {
|
for (size_t n = 0; n < this->m_paths.size(); n++) {
|
||||||
|
@ -53,8 +53,6 @@ namespace hex::plugin::builtin {
|
|||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool firstSubCategory = true;
|
|
||||||
|
|
||||||
// Draw all settings of that category
|
// Draw all settings of that category
|
||||||
for (auto &subCategory : category.subCategories) {
|
for (auto &subCategory : category.subCategories) {
|
||||||
|
|
||||||
@ -62,15 +60,13 @@ namespace hex::plugin::builtin {
|
|||||||
if (subCategory.entries.empty())
|
if (subCategory.entries.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!subCategory.unlocalizedName.empty())
|
ImGui::BeginSubWindow(LangEntry(subCategory.unlocalizedName));
|
||||||
ImGui::Header(LangEntry(subCategory.unlocalizedName), firstSubCategory);
|
{
|
||||||
|
|
||||||
firstSubCategory = false;
|
|
||||||
|
|
||||||
if (ImGui::BeginBox()) {
|
|
||||||
for (auto &setting : subCategory.entries) {
|
for (auto &setting : subCategory.entries) {
|
||||||
ImGui::BeginDisabled(!setting.widget->isEnabled());
|
ImGui::BeginDisabled(!setting.widget->isEnabled());
|
||||||
|
ImGui::PushItemWidth(-200_scaled);
|
||||||
bool settingChanged = setting.widget->draw(LangEntry(setting.unlocalizedName));
|
bool settingChanged = setting.widget->draw(LangEntry(setting.unlocalizedName));
|
||||||
|
ImGui::PopItemWidth();
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
|
|
||||||
if (auto tooltip = setting.widget->getTooltip(); tooltip.has_value() && ImGui::IsItemHovered())
|
if (auto tooltip = setting.widget->getTooltip(); tooltip.has_value() && ImGui::IsItemHovered())
|
||||||
@ -98,8 +94,8 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndBox();
|
|
||||||
}
|
}
|
||||||
|
ImGui::EndSubWindow();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user