1
0
mirror of synced 2024-12-15 01:01:15 +01:00
ImHex/lib/libimhex/source/ui/view.cpp

71 lines
1.7 KiB
C++
Raw Normal View History

#include <hex/ui/view.hpp>
#include <imgui.h>
#include <functional>
#include <string>
namespace hex {
View::View(std::string unlocalizedName) : m_unlocalizedViewName(std::move(unlocalizedName)) { }
bool View::shouldDraw() const {
return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isAvailable();
2021-02-03 00:56:33 +01:00
}
bool View::shouldProcess() const {
return this->shouldDraw() && this->getWindowOpenState();
}
2022-01-10 21:05:37 +01:00
bool View::hasViewMenuItemEntry() const {
return true;
}
2022-01-10 21:05:37 +01:00
ImVec2 View::getMinSize() const {
return scaled({ 300, 400 });
}
2022-01-10 21:05:37 +01:00
ImVec2 View::getMaxSize() const {
return { FLT_MAX, FLT_MAX };
}
ImGuiWindowFlags View::getWindowFlags() const {
return ImGuiWindowFlags_None;
}
bool &View::getWindowOpenState() {
return this->m_windowOpen;
}
const bool &View::getWindowOpenState() const {
2022-01-10 21:05:37 +01:00
return this->m_windowOpen;
}
const std::string &View::getUnlocalizedName() const {
return this->m_unlocalizedViewName;
}
std::string View::getName() const {
return View::toWindowName(this->m_unlocalizedViewName);
}
bool View::didWindowJustOpen() {
return std::exchange(this->m_windowJustOpened, false);
}
void View::setWindowJustOpened(bool state) {
this->m_windowJustOpened = state;
}
void View::discardNavigationRequests() {
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows))
ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_NavEnableKeyboard;
}
std::string View::toWindowName(const std::string &unlocalizedName) {
return Lang(unlocalizedName) + "###" + unlocalizedName;
}
}