mirror of https://github.com/WerWolv/ImHex
impr: Make most windows non-scrolling by default
This commit is contained in:
parent
e904cd749f
commit
858fe0384e
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <hex/api/tutorial_manager.hpp>
|
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
|
|
@ -27,7 +26,7 @@ namespace hex {
|
||||||
* @brief Draws the view
|
* @brief Draws the view
|
||||||
* @note Do not override this method. Override drawContent() instead
|
* @note Do not override this method. Override drawContent() instead
|
||||||
*/
|
*/
|
||||||
virtual void draw() = 0;
|
virtual void draw(ImGuiWindowFlags extraFlags = ImGuiWindowFlags_None) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Draws the content of the view
|
* @brief Draws the content of the view
|
||||||
|
|
@ -126,6 +125,7 @@ namespace hex {
|
||||||
class Window;
|
class Window;
|
||||||
class Special;
|
class Special;
|
||||||
class Floating;
|
class Floating;
|
||||||
|
class Scrolling;
|
||||||
class Modal;
|
class Modal;
|
||||||
class FullScreen;
|
class FullScreen;
|
||||||
|
|
||||||
|
|
@ -153,16 +153,10 @@ namespace hex {
|
||||||
*/
|
*/
|
||||||
virtual void drawHelpText() = 0;
|
virtual void drawHelpText() = 0;
|
||||||
|
|
||||||
void draw() final {
|
void draw(ImGuiWindowFlags extraFlags = ImGuiWindowFlags_None) override;
|
||||||
if (this->shouldDraw()) {
|
|
||||||
ImGui::SetNextWindowSizeConstraints(this->getMinSize(), this->getMaxSize());
|
virtual bool allowScroll() const {
|
||||||
const auto title = fmt::format("{} {}", this->getIcon(), View::toWindowName(this->getUnlocalizedName()));
|
return false;
|
||||||
if (ImGui::Begin(title.c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse | this->getWindowFlags())) {
|
|
||||||
TutorialManager::setLastItemInteractiveHelpPopup([this]{ this->drawHelpText(); });
|
|
||||||
this->drawContent();
|
|
||||||
}
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -174,12 +168,7 @@ namespace hex {
|
||||||
public:
|
public:
|
||||||
explicit Special(UnlocalizedString unlocalizedName) : View(std::move(unlocalizedName), "") {}
|
explicit Special(UnlocalizedString unlocalizedName) : View(std::move(unlocalizedName), "") {}
|
||||||
|
|
||||||
void draw() final {
|
void draw(ImGuiWindowFlags extraFlags = ImGuiWindowFlags_None) final;
|
||||||
if (this->shouldDraw()) {
|
|
||||||
ImGui::SetNextWindowSizeConstraints(this->getMinSize(), this->getMaxSize());
|
|
||||||
this->drawContent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -189,7 +178,24 @@ namespace hex {
|
||||||
public:
|
public:
|
||||||
explicit Floating(UnlocalizedString unlocalizedName, const char *icon) : Window(std::move(unlocalizedName), icon) {}
|
explicit Floating(UnlocalizedString unlocalizedName, const char *icon) : Window(std::move(unlocalizedName), icon) {}
|
||||||
|
|
||||||
[[nodiscard]] ImGuiWindowFlags getWindowFlags() const override { return ImGuiWindowFlags_NoDocking; }
|
void draw(ImGuiWindowFlags extraFlags = ImGuiWindowFlags_None) final;
|
||||||
|
|
||||||
|
[[nodiscard]] bool shouldStoreWindowState() const override { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A view that draws all its content at once without any scrolling being done by the window itself
|
||||||
|
*/
|
||||||
|
class View::Scrolling : public View::Window {
|
||||||
|
public:
|
||||||
|
explicit Scrolling(UnlocalizedString unlocalizedName, const char *icon) : Window(std::move(unlocalizedName), icon) {}
|
||||||
|
|
||||||
|
void draw(ImGuiWindowFlags extraFlags = ImGuiWindowFlags_None) final;
|
||||||
|
|
||||||
|
bool allowScroll() const final {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool shouldStoreWindowState() const override { return false; }
|
[[nodiscard]] bool shouldStoreWindowState() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -200,24 +206,7 @@ namespace hex {
|
||||||
public:
|
public:
|
||||||
explicit Modal(UnlocalizedString unlocalizedName, const char *icon) : View(std::move(unlocalizedName), icon) {}
|
explicit Modal(UnlocalizedString unlocalizedName, const char *icon) : View(std::move(unlocalizedName), icon) {}
|
||||||
|
|
||||||
void draw() final {
|
void draw(ImGuiWindowFlags extraFlags = ImGuiWindowFlags_None) final;
|
||||||
if (this->shouldDraw()) {
|
|
||||||
if (this->getWindowOpenState())
|
|
||||||
ImGui::OpenPopup(View::toWindowName(this->getUnlocalizedName()).c_str());
|
|
||||||
|
|
||||||
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5F, 0.5F));
|
|
||||||
ImGui::SetNextWindowSizeConstraints(this->getMinSize(), this->getMaxSize());
|
|
||||||
const auto title = fmt::format("{} {}", this->getIcon(), View::toWindowName(this->getUnlocalizedName()));
|
|
||||||
if (ImGui::BeginPopupModal(title.c_str(), this->hasCloseButton() ? &this->getWindowOpenState() : nullptr, ImGuiWindowFlags_NoCollapse | this->getWindowFlags())) {
|
|
||||||
this->drawContent();
|
|
||||||
|
|
||||||
ImGui::EndPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui::IsKeyPressed(ImGuiKey_Escape))
|
|
||||||
this->getWindowOpenState() = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] virtual bool hasCloseButton() const { return true; }
|
[[nodiscard]] virtual bool hasCloseButton() const { return true; }
|
||||||
[[nodiscard]] bool shouldStoreWindowState() const override { return false; }
|
[[nodiscard]] bool shouldStoreWindowState() const override { return false; }
|
||||||
|
|
@ -227,10 +216,7 @@ namespace hex {
|
||||||
public:
|
public:
|
||||||
explicit FullScreen() : View("FullScreen", "") {}
|
explicit FullScreen() : View("FullScreen", "") {}
|
||||||
|
|
||||||
void draw() final {
|
void draw(ImGuiWindowFlags extraFlags = ImGuiWindowFlags_None) final;
|
||||||
this->drawContent();
|
|
||||||
this->drawAlwaysVisibleContent();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
#include <hex/ui/view.hpp>
|
#include <hex/ui/view.hpp>
|
||||||
#include <hex/api/task_manager.hpp>
|
|
||||||
#include <hex/helpers/auto_reset.hpp>
|
#include <hex/helpers/auto_reset.hpp>
|
||||||
|
|
||||||
#include <hex/api/imhex_api/provider.hpp>
|
#include <hex/api/imhex_api/provider.hpp>
|
||||||
|
#include <hex/api/task_manager.hpp>
|
||||||
|
#include <hex/api/tutorial_manager.hpp>
|
||||||
|
|
||||||
#include <hex/providers/provider.hpp>
|
#include <hex/providers/provider.hpp>
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
@ -116,4 +118,63 @@ namespace hex {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void View::Window::draw(ImGuiWindowFlags extraFlags) {
|
||||||
|
if (this->shouldDraw()) {
|
||||||
|
if (!allowScroll())
|
||||||
|
extraFlags |= ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
|
||||||
|
|
||||||
|
ImGui::SetNextWindowSizeConstraints(this->getMinSize(), this->getMaxSize());
|
||||||
|
const auto title = fmt::format("{} {}", this->getIcon(), View::toWindowName(this->getUnlocalizedName()));
|
||||||
|
if (ImGui::Begin(title.c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse | extraFlags | this->getWindowFlags())) {
|
||||||
|
TutorialManager::setLastItemInteractiveHelpPopup([this]{ this->drawHelpText(); });
|
||||||
|
this->drawContent();
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::Special::draw(ImGuiWindowFlags extraFlags) {
|
||||||
|
std::ignore = extraFlags;
|
||||||
|
|
||||||
|
if (this->shouldDraw()) {
|
||||||
|
ImGui::SetNextWindowSizeConstraints(this->getMinSize(), this->getMaxSize());
|
||||||
|
this->drawContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::Floating::draw(ImGuiWindowFlags extraFlags) {
|
||||||
|
Window::draw(extraFlags | ImGuiWindowFlags_NoDocking);
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::Scrolling::draw(ImGuiWindowFlags extraFlags) {
|
||||||
|
Window::draw(extraFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::Modal::draw(ImGuiWindowFlags extraFlags) {
|
||||||
|
if (this->shouldDraw()) {
|
||||||
|
if (this->getWindowOpenState())
|
||||||
|
ImGui::OpenPopup(View::toWindowName(this->getUnlocalizedName()).c_str());
|
||||||
|
|
||||||
|
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5F, 0.5F));
|
||||||
|
ImGui::SetNextWindowSizeConstraints(this->getMinSize(), this->getMaxSize());
|
||||||
|
const auto title = fmt::format("{} {}", this->getIcon(), View::toWindowName(this->getUnlocalizedName()));
|
||||||
|
if (ImGui::BeginPopupModal(title.c_str(), this->hasCloseButton() ? &this->getWindowOpenState() : nullptr, ImGuiWindowFlags_NoCollapse | extraFlags | this->getWindowFlags())) {
|
||||||
|
this->drawContent();
|
||||||
|
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::IsKeyPressed(ImGuiKey_Escape))
|
||||||
|
this->getWindowOpenState() = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::FullScreen::draw(ImGuiWindowFlags extraFlags) {
|
||||||
|
std::ignore = extraFlags;
|
||||||
|
|
||||||
|
this->drawContent();
|
||||||
|
this->drawAlwaysVisibleContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -57,10 +57,6 @@ namespace hex::plugin::builtin {
|
||||||
void reloadCustomNodes();
|
void reloadCustomNodes();
|
||||||
void updateNodePositions();
|
void updateNodePositions();
|
||||||
|
|
||||||
[[nodiscard]] ImGuiWindowFlags getWindowFlags() const override {
|
|
||||||
return ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Workspace*> &getWorkspaceStack() { return *m_workspaceStack; }
|
std::vector<Workspace*> &getWorkspaceStack() { return *m_workspaceStack; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace hex::plugin::builtin {
|
||||||
|
|
||||||
void drawContent() override;
|
void drawContent() override;
|
||||||
[[nodiscard]] ImGuiWindowFlags getWindowFlags() const override {
|
[[nodiscard]] ImGuiWindowFlags getWindowFlags() const override {
|
||||||
return ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
|
return ImGuiWindowFlags_NoNavInputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldDefaultFocus() const override { return true; }
|
bool shouldDefaultFocus() const override { return true; }
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace hex::plugin::builtin {
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiWindowFlags getWindowFlags() const override {
|
ImGuiWindowFlags getWindowFlags() const override {
|
||||||
return View::Floating::getWindowFlags() | ImGuiWindowFlags_NoResize;
|
return ImGuiWindowFlags_NoResize;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
class ViewInformation : public View::Window {
|
class ViewInformation : public View::Scrolling {
|
||||||
public:
|
public:
|
||||||
explicit ViewInformation();
|
explicit ViewInformation();
|
||||||
~ViewInformation() override = default;
|
~ViewInformation() override = default;
|
||||||
|
|
|
||||||
|
|
@ -66,9 +66,6 @@ namespace hex::plugin::builtin {
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawContent() override;
|
void drawContent() override;
|
||||||
[[nodiscard]] ImGuiWindowFlags getWindowFlags() const override {
|
|
||||||
return ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPopupWindowHeight(u32 height) { m_popupWindowHeight = height; }
|
void setPopupWindowHeight(u32 height) { m_popupWindowHeight = height; }
|
||||||
u32 getPopupWindowHeight() const { return m_popupWindowHeight; }
|
u32 getPopupWindowHeight() const { return m_popupWindowHeight; }
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
class ViewTools : public View::Window {
|
class ViewTools : public View::Scrolling {
|
||||||
public:
|
public:
|
||||||
ViewTools();
|
ViewTools();
|
||||||
~ViewTools() override = default;
|
~ViewTools() override = default;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace hex::plugin::builtin {
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiWindowFlags getWindowFlags() const override {
|
ImGuiWindowFlags getWindowFlags() const override {
|
||||||
return Floating::getWindowFlags() | ImGuiWindowFlags_NoResize;
|
return ImGuiWindowFlags_NoResize;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include <hex/api/imhex_api/system.hpp>
|
#include <hex/api/imhex_api/system.hpp>
|
||||||
#include <hex/api/localization_manager.hpp>
|
#include <hex/api/localization_manager.hpp>
|
||||||
#include <hex/api/task_manager.hpp>
|
#include <hex/api/task_manager.hpp>
|
||||||
|
#include <hex/api/tutorial_manager.hpp>
|
||||||
|
|
||||||
#include <hex/api/events/events_provider.hpp>
|
#include <hex/api/events/events_provider.hpp>
|
||||||
#include <hex/api/events/events_gui.hpp>
|
#include <hex/api/events/events_gui.hpp>
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace hex::plugin::builtin {
|
||||||
|
|
||||||
using namespace hex::literals;
|
using namespace hex::literals;
|
||||||
|
|
||||||
ViewInformation::ViewInformation() : View::Window("hex.builtin.view.information.name", ICON_VS_GRAPH_LINE) {
|
ViewInformation::ViewInformation() : View::Scrolling("hex.builtin.view.information.name", ICON_VS_GRAPH_LINE) {
|
||||||
m_analysisData.setOnCreateCallback([](const prv::Provider *provider, AnalysisData &data) {
|
m_analysisData.setOnCreateCallback([](const prv::Provider *provider, AnalysisData &data) {
|
||||||
data.analyzedProvider = provider;
|
data.analyzedProvider = provider;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
ViewTools::ViewTools() : View::Window("hex.builtin.view.tools.name", ICON_VS_TOOLS) {
|
ViewTools::ViewTools() : View::Scrolling("hex.builtin.view.tools.name", ICON_VS_TOOLS) {
|
||||||
m_dragStartIterator = ContentRegistry::Tools::impl::getEntries().end();
|
m_dragStartIterator = ContentRegistry::Tools::impl::getEntries().end();
|
||||||
|
|
||||||
LayoutManager::registerLoadCallback([this](std::string_view line) {
|
LayoutManager::registerLoadCallback([this](std::string_view line) {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ namespace hex::plugin::diffing {
|
||||||
void drawContent() override;
|
void drawContent() override;
|
||||||
void drawAlwaysVisibleContent() override;
|
void drawAlwaysVisibleContent() override;
|
||||||
void drawHelpText() override;
|
void drawHelpText() override;
|
||||||
ImGuiWindowFlags getWindowFlags() const override { return ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse; }
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct Column {
|
struct Column {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue