sys: Improved view const-correctness
This commit is contained in:
parent
e1fb0a5d72
commit
e35ea13f60
@ -11,8 +11,6 @@
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
namespace prv { class Provider; }
|
||||
|
||||
class ViewCommandPalette : public View {
|
||||
public:
|
||||
ViewCommandPalette();
|
||||
@ -20,12 +18,12 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
bool isAvailable() override { return true; }
|
||||
bool shouldProcess() override { return true; }
|
||||
[[nodiscard]] bool isAvailable() const override { return true; }
|
||||
[[nodiscard]] bool shouldProcess() const override { return true; }
|
||||
|
||||
bool hasViewMenuItemEntry() override { return false; }
|
||||
ImVec2 getMinSize() override { return ImVec2(400, 100); }
|
||||
ImVec2 getMaxSize() override { return ImVec2(400, 100); }
|
||||
[[nodiscard]] bool hasViewMenuItemEntry() const override { return false; }
|
||||
[[nodiscard]] ImVec2 getMinSize() const override { return ImVec2(400, 100); }
|
||||
[[nodiscard]] ImVec2 getMaxSize() const override { return ImVec2(400, 100); }
|
||||
|
||||
private:
|
||||
enum class MatchType {
|
||||
|
@ -20,11 +20,11 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
bool isAvailable() override { return true; }
|
||||
bool isAvailable() const override { return true; }
|
||||
|
||||
bool hasViewMenuItemEntry() override { return false; }
|
||||
bool hasViewMenuItemEntry() const override { return false; }
|
||||
|
||||
ImVec2 getMinSize() override {
|
||||
ImVec2 getMinSize() const override {
|
||||
return ImVec2(400, 300);
|
||||
}
|
||||
|
||||
|
@ -13,14 +13,14 @@ namespace hex::plugin::builtin {
|
||||
class ViewProviderSettings : public hex::View {
|
||||
public:
|
||||
ViewProviderSettings();
|
||||
~ViewProviderSettings();
|
||||
~ViewProviderSettings() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawAlwaysVisible() override;
|
||||
|
||||
bool hasViewMenuItemEntry() override;
|
||||
[[nodiscard]] bool hasViewMenuItemEntry() const override;
|
||||
|
||||
bool isAvailable();
|
||||
[[nodiscard]] bool isAvailable() const override;
|
||||
};
|
||||
|
||||
}
|
@ -14,12 +14,12 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
bool isAvailable() override { return true; }
|
||||
[[nodiscard]] bool isAvailable() const override { return true; }
|
||||
|
||||
bool hasViewMenuItemEntry() override { return false; }
|
||||
[[nodiscard]] bool hasViewMenuItemEntry() const override { return false; }
|
||||
|
||||
ImVec2 getMinSize() {
|
||||
return ImVec2(0, 0);
|
||||
[[nodiscard]] ImVec2 getMinSize() const override {
|
||||
return ImVec2(500, 300) * SharedData::globalScale;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -35,8 +35,8 @@ namespace hex::plugin::builtin {
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
bool isAvailable() override { return true; }
|
||||
bool hasViewMenuItemEntry() override { return false; }
|
||||
[[nodiscard]] bool isAvailable() const override { return true; }
|
||||
[[nodiscard]] bool hasViewMenuItemEntry() const override { return false; }
|
||||
|
||||
private:
|
||||
Net m_net;
|
||||
|
@ -52,11 +52,11 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderSettings::hasViewMenuItemEntry() {
|
||||
bool ViewProviderSettings::hasViewMenuItemEntry() const {
|
||||
return this->isAvailable();
|
||||
}
|
||||
|
||||
bool ViewProviderSettings::isAvailable() {
|
||||
bool ViewProviderSettings::isAvailable() const {
|
||||
auto provider = hex::ImHexApi::Provider::get();
|
||||
|
||||
return provider != nullptr && provider->hasInterface();
|
||||
|
@ -21,7 +21,6 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void ViewSettings::drawContent() {
|
||||
|
||||
ImGui::SetNextWindowSize(ImVec2(500, 300) * SharedData::globalScale, ImGuiCond_Always);
|
||||
if (ImGui::BeginPopupModal(View::toWindowName("hex.builtin.view.settings.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoResize)) {
|
||||
if (ImGui::BeginTabBar("settings")) {
|
||||
for (auto &[category, entries] : ContentRegistry::Settings::getEntries()) {
|
||||
|
@ -33,8 +33,8 @@ namespace hex {
|
||||
virtual void drawContent() = 0;
|
||||
virtual void drawAlwaysVisible() { }
|
||||
virtual void drawMenu();
|
||||
virtual bool isAvailable();
|
||||
virtual bool shouldProcess() { return this->isAvailable() && this->getWindowOpenState(); }
|
||||
virtual bool isAvailable() const;
|
||||
virtual bool shouldProcess() const { return this->isAvailable() && this->getWindowOpenState(); }
|
||||
|
||||
static void doLater(std::function<void()> &&function);
|
||||
static std::vector<std::function<void()>>& getDeferedCalls();
|
||||
@ -45,11 +45,12 @@ namespace hex {
|
||||
static void showErrorPopup(const std::string &errorMessage);
|
||||
static void showFatalPopup(const std::string &errorMessage);
|
||||
|
||||
virtual bool hasViewMenuItemEntry();
|
||||
virtual ImVec2 getMinSize();
|
||||
virtual ImVec2 getMaxSize();
|
||||
virtual bool hasViewMenuItemEntry() const;
|
||||
virtual ImVec2 getMinSize() const;
|
||||
virtual ImVec2 getMaxSize() const;
|
||||
|
||||
bool& getWindowOpenState();
|
||||
const bool& getWindowOpenState() const;
|
||||
|
||||
[[nodiscard]] const std::string& getUnlocalizedName() const;
|
||||
|
||||
|
@ -14,7 +14,7 @@ namespace hex {
|
||||
|
||||
void View::drawMenu() { }
|
||||
|
||||
bool View::isAvailable() {
|
||||
bool View::isAvailable() const {
|
||||
return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isAvailable();
|
||||
}
|
||||
|
||||
@ -80,15 +80,15 @@ namespace hex {
|
||||
View::doLater([] { ImGui::OpenPopup("hex.common.fatal"_lang); });
|
||||
}
|
||||
|
||||
bool View::hasViewMenuItemEntry() {
|
||||
bool View::hasViewMenuItemEntry() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
ImVec2 View::getMinSize() {
|
||||
ImVec2 View::getMinSize() const {
|
||||
return ImVec2(480, 720) * SharedData::globalScale;
|
||||
}
|
||||
|
||||
ImVec2 View::getMaxSize() {
|
||||
ImVec2 View::getMaxSize() const {
|
||||
return { FLT_MAX, FLT_MAX };
|
||||
}
|
||||
|
||||
@ -97,6 +97,10 @@ namespace hex {
|
||||
return this->m_windowOpen;
|
||||
}
|
||||
|
||||
const bool& View::getWindowOpenState() const {
|
||||
return this->m_windowOpen;
|
||||
}
|
||||
|
||||
const std::string& View::getUnlocalizedName() const {
|
||||
return this->m_unlocalizedViewName;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user