impr: Clean up old layout stuff
This commit is contained in:
parent
0b21e30e44
commit
0649e0dcd3
@ -493,14 +493,8 @@ namespace hex {
|
|||||||
using DrawCallback = std::function<void()>;
|
using DrawCallback = std::function<void()>;
|
||||||
using MenuCallback = std::function<void()>;
|
using MenuCallback = std::function<void()>;
|
||||||
using EnabledCallback = std::function<bool()>;
|
using EnabledCallback = std::function<bool()>;
|
||||||
using LayoutFunction = std::function<void(u32)>;
|
|
||||||
using ClickCallback = std::function<void()>;
|
using ClickCallback = std::function<void()>;
|
||||||
|
|
||||||
struct Layout {
|
|
||||||
std::string unlocalizedName;
|
|
||||||
LayoutFunction callback;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MainMenuItem {
|
struct MainMenuItem {
|
||||||
std::string unlocalizedName;
|
std::string unlocalizedName;
|
||||||
};
|
};
|
||||||
@ -535,8 +529,6 @@ namespace hex {
|
|||||||
std::vector<impl::SidebarItem> &getSidebarItems();
|
std::vector<impl::SidebarItem> &getSidebarItems();
|
||||||
std::vector<impl::TitleBarButton> &getTitleBarButtons();
|
std::vector<impl::TitleBarButton> &getTitleBarButtons();
|
||||||
|
|
||||||
std::vector<impl::Layout> &getLayouts();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -608,14 +600,6 @@ namespace hex {
|
|||||||
*/
|
*/
|
||||||
void addTitleBarButton(const std::string &icon, const std::string &unlocalizedTooltip, const impl::ClickCallback &function);
|
void addTitleBarButton(const std::string &icon, const std::string &unlocalizedTooltip, const impl::ClickCallback &function);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Adds a new layout definition to the Layout menu
|
|
||||||
* @param unlocalizedName The unlocalized name of the layout
|
|
||||||
* @param function The function to call to setup the layout
|
|
||||||
*/
|
|
||||||
void addLayout(const std::string &unlocalizedName, const impl::LayoutFunction &function);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Provider Registry. Allows adding new data providers to be created from the UI */
|
/* Provider Registry. Allows adding new data providers to be created from the UI */
|
||||||
|
@ -26,6 +26,7 @@ namespace hex {
|
|||||||
|
|
||||||
static void process();
|
static void process();
|
||||||
static void reload();
|
static void reload();
|
||||||
|
static void reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LayoutManager() = default;
|
LayoutManager() = default;
|
||||||
|
@ -581,12 +581,6 @@ namespace hex {
|
|||||||
impl::getTitleBarButtons().push_back({ icon, unlocalizedTooltip, function });
|
impl::getTitleBarButtons().push_back({ icon, unlocalizedTooltip, function });
|
||||||
}
|
}
|
||||||
|
|
||||||
void addLayout(const std::string &unlocalizedName, const impl::LayoutFunction &function) {
|
|
||||||
log::debug("Added new layout: {}", unlocalizedName);
|
|
||||||
|
|
||||||
impl::getLayouts().push_back({ unlocalizedName, function });
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace impl {
|
namespace impl {
|
||||||
|
|
||||||
std::multimap<u32, impl::MainMenuItem> &getMainMenuItems() {
|
std::multimap<u32, impl::MainMenuItem> &getMainMenuItems() {
|
||||||
@ -626,12 +620,6 @@ namespace hex {
|
|||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<impl::Layout> &getLayouts() {
|
|
||||||
static std::vector<impl::Layout> layouts;
|
|
||||||
|
|
||||||
return layouts;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
namespace hex {
|
namespace hex {
|
||||||
|
|
||||||
std::optional<std::fs::path> LayoutManager::s_layoutPathToLoad;
|
std::optional<std::fs::path> LayoutManager::s_layoutPathToLoad;
|
||||||
@ -72,4 +74,10 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LayoutManager::reset() {
|
||||||
|
s_layoutPathToLoad.reset();
|
||||||
|
s_layoutStringToLoad.reset();
|
||||||
|
s_layouts.clear();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,13 +3,17 @@
|
|||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <romfs/romfs.hpp>
|
#include <romfs/romfs.hpp>
|
||||||
|
|
||||||
|
#include <hex/helpers/http_requests.hpp>
|
||||||
|
#include <hex/helpers/fs.hpp>
|
||||||
|
#include <hex/helpers/logger.hpp>
|
||||||
|
|
||||||
#include <hex/api_urls.hpp>
|
#include <hex/api_urls.hpp>
|
||||||
#include <hex/api/content_registry.hpp>
|
#include <hex/api/content_registry.hpp>
|
||||||
#include <hex/api/project_file_manager.hpp>
|
#include <hex/api/project_file_manager.hpp>
|
||||||
#include <hex/api/theme_manager.hpp>
|
#include <hex/api/theme_manager.hpp>
|
||||||
#include <hex/helpers/http_requests.hpp>
|
#include <hex/api/plugin_manager.hpp>
|
||||||
#include <hex/helpers/fs.hpp>
|
#include <hex/api/layout_manager.hpp>
|
||||||
#include <hex/helpers/logger.hpp>
|
|
||||||
#include <hex/ui/view.hpp>
|
#include <hex/ui/view.hpp>
|
||||||
#include <hex/ui/popup.hpp>
|
#include <hex/ui/popup.hpp>
|
||||||
|
|
||||||
@ -17,8 +21,6 @@
|
|||||||
#include <fonts/codicons_font.h>
|
#include <fonts/codicons_font.h>
|
||||||
#include <fonts/unifont_font.h>
|
#include <fonts/unifont_font.h>
|
||||||
|
|
||||||
#include <hex/api/plugin_manager.hpp>
|
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
@ -312,7 +314,6 @@ namespace hex::init {
|
|||||||
ContentRegistry::Interface::impl::getMenuItems().clear();
|
ContentRegistry::Interface::impl::getMenuItems().clear();
|
||||||
ContentRegistry::Interface::impl::getSidebarItems().clear();
|
ContentRegistry::Interface::impl::getSidebarItems().clear();
|
||||||
ContentRegistry::Interface::impl::getTitleBarButtons().clear();
|
ContentRegistry::Interface::impl::getTitleBarButtons().clear();
|
||||||
ContentRegistry::Interface::impl::getLayouts().clear();
|
|
||||||
|
|
||||||
ShortcutManager::clearShortcuts();
|
ShortcutManager::clearShortcuts();
|
||||||
|
|
||||||
@ -324,6 +325,8 @@ namespace hex::init {
|
|||||||
ContentRegistry::FileHandler::impl::getEntries().clear();
|
ContentRegistry::FileHandler::impl::getEntries().clear();
|
||||||
ContentRegistry::Hashes::impl::getHashes().clear();
|
ContentRegistry::Hashes::impl::getHashes().clear();
|
||||||
|
|
||||||
|
LayoutManager::reset();
|
||||||
|
|
||||||
ThemeManager::reset();
|
ThemeManager::reset();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,6 @@ add_library(${PROJECT_NAME} SHARED
|
|||||||
source/content/providers.cpp
|
source/content/providers.cpp
|
||||||
source/content/views.cpp
|
source/content/views.cpp
|
||||||
source/content/data_formatters.cpp
|
source/content/data_formatters.cpp
|
||||||
source/content/layouts.cpp
|
|
||||||
source/content/main_menu_items.cpp
|
source/content/main_menu_items.cpp
|
||||||
source/content/welcome_screen.cpp
|
source/content/welcome_screen.cpp
|
||||||
source/content/data_visualizers.cpp
|
source/content/data_visualizers.cpp
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
#include <hex/api/content_registry.hpp>
|
|
||||||
|
|
||||||
#include <hex/ui/view.hpp>
|
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
|
||||||
|
|
||||||
static void openViewAndDockTo(const std::string &unlocalizedName, ImGuiID dockId) {
|
|
||||||
auto view = ContentRegistry::Views::getViewByName(unlocalizedName);
|
|
||||||
|
|
||||||
if (view != nullptr) {
|
|
||||||
view->getWindowOpenState() = true;
|
|
||||||
ImGui::DockBuilderDockWindow(view->getName().c_str(), dockId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void registerLayouts() {
|
|
||||||
|
|
||||||
ContentRegistry::Interface::addLayout("hex.builtin.layouts.default", [](ImGuiID dockMain) {
|
|
||||||
ImGuiID hexEditor = ImGui::DockBuilderSplitNode(dockMain, ImGuiDir_Left, 0.7F, nullptr, &dockMain);
|
|
||||||
ImGuiID utils = ImGui::DockBuilderSplitNode(dockMain, ImGuiDir_Right, 0.8F, nullptr, &dockMain);
|
|
||||||
ImGuiID patternData = ImGui::DockBuilderSplitNode(hexEditor, ImGuiDir_Down, 0.3F, nullptr, &hexEditor);
|
|
||||||
ImGuiID inspector = ImGui::DockBuilderSplitNode(hexEditor, ImGuiDir_Right, 0.3F, nullptr, &hexEditor);
|
|
||||||
|
|
||||||
openViewAndDockTo("hex.builtin.view.hex_editor.name", hexEditor);
|
|
||||||
openViewAndDockTo("hex.builtin.view.data_inspector.name", inspector);
|
|
||||||
openViewAndDockTo("hex.builtin.view.pattern_data.name", patternData);
|
|
||||||
|
|
||||||
openViewAndDockTo("hex.builtin.view.pattern_editor.name", utils);
|
|
||||||
openViewAndDockTo("hex.builtin.view.hashes.name", utils);
|
|
||||||
openViewAndDockTo("hex.builtin.view.data_information.name", utils);
|
|
||||||
openViewAndDockTo("hex.builtin.view.find.name", utils);
|
|
||||||
openViewAndDockTo("hex.builtin.view.bookmarks.name", utils);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -22,7 +22,6 @@ namespace hex::plugin::builtin {
|
|||||||
void registerHashes();
|
void registerHashes();
|
||||||
void registerProviders();
|
void registerProviders();
|
||||||
void registerDataFormatters();
|
void registerDataFormatters();
|
||||||
void registerLayouts();
|
|
||||||
void registerMainMenuEntries();
|
void registerMainMenuEntries();
|
||||||
void createWelcomeScreen();
|
void createWelcomeScreen();
|
||||||
void registerViews();
|
void registerViews();
|
||||||
@ -70,7 +69,6 @@ IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
|
|||||||
addToolbarItems();
|
addToolbarItems();
|
||||||
addGlobalUIItems();
|
addGlobalUIItems();
|
||||||
|
|
||||||
registerLayouts();
|
|
||||||
registerMainMenuEntries();
|
registerMainMenuEntries();
|
||||||
|
|
||||||
handleBorderlessWindowMode();
|
handleBorderlessWindowMode();
|
||||||
|
Loading…
Reference in New Issue
Block a user