2023-05-11 18:44:50 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
#include <hex/helpers/fs.hpp>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <variant>
|
|
|
|
|
|
|
|
#include <nlohmann/json_fwd.hpp>
|
|
|
|
#include <imgui.h>
|
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
|
|
|
class LayoutManager {
|
|
|
|
public:
|
|
|
|
struct Layout {
|
|
|
|
std::string name;
|
|
|
|
std::fs::path path;
|
|
|
|
};
|
|
|
|
|
2023-08-26 12:54:52 +02:00
|
|
|
/**
|
|
|
|
* @brief Save the current layout
|
|
|
|
* @param name Name of the layout
|
|
|
|
*/
|
2023-05-11 18:44:50 +02:00
|
|
|
static void save(const std::string &name);
|
2023-08-26 12:54:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Load a layout from a file
|
|
|
|
* @param path Path to the layout file
|
|
|
|
*/
|
2023-05-11 18:44:50 +02:00
|
|
|
static void load(const std::fs::path &path);
|
2023-08-26 12:54:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Load a layout from a string
|
|
|
|
* @param content Layout string
|
|
|
|
*/
|
2023-05-11 18:44:50 +02:00
|
|
|
static void loadString(const std::string &content);
|
|
|
|
|
2023-08-26 12:54:52 +02:00
|
|
|
/**
|
|
|
|
* @brief Get a list of all layouts
|
|
|
|
* @return List of all added layouts
|
|
|
|
*/
|
2023-05-11 18:44:50 +02:00
|
|
|
static std::vector<Layout> getLayouts();
|
|
|
|
|
2023-08-26 12:54:52 +02:00
|
|
|
/**
|
|
|
|
* @brief Handles loading of layouts if needed
|
|
|
|
* @note This function should only be called by ImHex
|
|
|
|
*/
|
2023-05-11 18:44:50 +02:00
|
|
|
static void process();
|
2023-08-26 12:54:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Reload all layouts
|
|
|
|
*/
|
2023-05-11 18:44:50 +02:00
|
|
|
static void reload();
|
2023-08-26 12:54:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Reset the layout manager
|
|
|
|
*/
|
2023-05-11 23:21:52 +02:00
|
|
|
static void reset();
|
2023-05-11 18:44:50 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
LayoutManager() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|