diff --git a/lib/libimhex/CMakeLists.txt b/lib/libimhex/CMakeLists.txt index 1bdfe8467..c01f95df4 100644 --- a/lib/libimhex/CMakeLists.txt +++ b/lib/libimhex/CMakeLists.txt @@ -41,6 +41,7 @@ set(LIBIMHEX_SOURCES source/helpers/semantic_version.cpp source/helpers/keys.cpp source/helpers/udp_server.cpp + source/helpers/scaling.cpp source/test/tests.cpp diff --git a/lib/libimhex/include/hex.cppm b/lib/libimhex/include/hex.cppm index 73baed9ca..8f63982f6 100644 --- a/lib/libimhex/include/hex.cppm +++ b/lib/libimhex/include/hex.cppm @@ -39,9 +39,16 @@ module; export module hex; #define HEX_MODULE_EXPORT + +#include +#include +#include +#include +#include +#include + #include #include -#include #include #include #include diff --git a/lib/libimhex/include/hex/api/content_registry/background_services.hpp b/lib/libimhex/include/hex/api/content_registry/background_services.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/command_palette.hpp b/lib/libimhex/include/hex/api/content_registry/command_palette.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/communication_interface.hpp b/lib/libimhex/include/hex/api/content_registry/communication_interface.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/data_formatter.hpp b/lib/libimhex/include/hex/api/content_registry/data_formatter.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/data_information.hpp b/lib/libimhex/include/hex/api/content_registry/data_information.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/data_inspector.hpp b/lib/libimhex/include/hex/api/content_registry/data_inspector.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/data_processor.hpp b/lib/libimhex/include/hex/api/content_registry/data_processor.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/diffing.hpp b/lib/libimhex/include/hex/api/content_registry/diffing.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/disassemblers.hpp b/lib/libimhex/include/hex/api/content_registry/disassemblers.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/experiments.hpp b/lib/libimhex/include/hex/api/content_registry/experiments.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/file_type_handler.hpp b/lib/libimhex/include/hex/api/content_registry/file_type_handler.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/hashes.hpp b/lib/libimhex/include/hex/api/content_registry/hashes.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/hex_editor.hpp b/lib/libimhex/include/hex/api/content_registry/hex_editor.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/interface.hpp b/lib/libimhex/include/hex/api/content_registry/interface.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/pattern_language.hpp b/lib/libimhex/include/hex/api/content_registry/pattern_language.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/provider.hpp b/lib/libimhex/include/hex/api/content_registry/provider.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/reports.hpp b/lib/libimhex/include/hex/api/content_registry/reports.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/settings.hpp b/lib/libimhex/include/hex/api/content_registry/settings.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/tools.hpp b/lib/libimhex/include/hex/api/content_registry/tools.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/content_registry/views.hpp b/lib/libimhex/include/hex/api/content_registry/views.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libimhex/include/hex/api/events/events_interaction.hpp b/lib/libimhex/include/hex/api/events/events_interaction.hpp index a7433cc4b..01d6b3d00 100644 --- a/lib/libimhex/include/hex/api/events/events_interaction.hpp +++ b/lib/libimhex/include/hex/api/events/events_interaction.hpp @@ -1,6 +1,7 @@ #pragma once -#include +#include +#include #include #include diff --git a/lib/libimhex/include/hex/api/events/requests_interaction.hpp b/lib/libimhex/include/hex/api/events/requests_interaction.hpp index d818d170e..87f20a8ab 100644 --- a/lib/libimhex/include/hex/api/events/requests_interaction.hpp +++ b/lib/libimhex/include/hex/api/events/requests_interaction.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include /* Forward declarations */ diff --git a/lib/libimhex/include/hex/api/imhex_api.hpp b/lib/libimhex/include/hex/api/imhex_api.hpp deleted file mode 100644 index ac222a6c0..000000000 --- a/lib/libimhex/include/hex/api/imhex_api.hpp +++ /dev/null @@ -1,841 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "imgui_internal.h" - -#if !defined(HEX_MODULE_EXPORT) - using ImGuiID = unsigned int; - struct ImVec2; - struct ImFontAtlas; - struct ImFont; -#endif -struct GLFWwindow; - -EXPORT_MODULE namespace hex { - - #if !defined(HEX_MODULE_EXPORT) - namespace impl { - class AutoResetBase; - } - - namespace prv { - class Provider; - } - #endif - - namespace ImHexApi { - - /* Functions to query information from the Hex Editor and interact with it */ - namespace HexEditor { - - using TooltipFunction = std::function; - - class Highlighting { - public: - Highlighting() = default; - Highlighting(Region region, color_t color); - - [[nodiscard]] const Region& getRegion() const { return m_region; } - [[nodiscard]] const color_t& getColor() const { return m_color; } - - private: - Region m_region = {}; - color_t m_color = 0x00; - }; - - class Tooltip { - public: - Tooltip() = default; - Tooltip(Region region, std::string value, color_t color); - - [[nodiscard]] const Region& getRegion() const { return m_region; } - [[nodiscard]] const color_t& getColor() const { return m_color; } - [[nodiscard]] const std::string& getValue() const { return m_value; } - - private: - Region m_region = {}; - std::string m_value; - color_t m_color = 0x00; - }; - - struct ProviderRegion : Region { - prv::Provider *provider; - - [[nodiscard]] prv::Provider *getProvider() const { return this->provider; } - - [[nodiscard]] Region getRegion() const { return { this->address, this->size }; } - }; - - namespace impl { - - using HighlightingFunction = std::function(u64, const u8*, size_t, bool)>; - using HoveringFunction = std::function(const prv::Provider *, u64, size_t)>; - - const std::map& getBackgroundHighlights(); - const std::map& getBackgroundHighlightingFunctions(); - const std::map& getForegroundHighlights(); - const std::map& getForegroundHighlightingFunctions(); - const std::map& getHoveringFunctions(); - const std::map& getTooltips(); - const std::map& getTooltipFunctions(); - - void setCurrentSelection(const std::optional ®ion); - void setHoveredRegion(const prv::Provider *provider, const Region ®ion); - } - - /** - * @brief Adds a background color highlighting to the Hex Editor - * @param region The region to highlight - * @param color The color to use for the highlighting - * @return Unique ID used to remove the highlighting again later - */ - u32 addBackgroundHighlight(const Region ®ion, color_t color); - - /** - * @brief Removes a background color highlighting from the Hex Editor - * @param id The ID of the highlighting to remove - */ - void removeBackgroundHighlight(u32 id); - - - /** - * @brief Adds a foreground color highlighting to the Hex Editor - * @param region The region to highlight - * @param color The color to use for the highlighting - * @return Unique ID used to remove the highlighting again later - */ - u32 addForegroundHighlight(const Region ®ion, color_t color); - - /** - * @brief Removes a foreground color highlighting from the Hex Editor - * @param id The ID of the highlighting to remove - */ - void removeForegroundHighlight(u32 id); - - /** - * @brief Adds a hover tooltip to the Hex Editor - * @param region The region to add the tooltip to - * @param value Text to display in the tooltip - * @param color The color of the tooltip - * @return Unique ID used to remove the tooltip again later - */ - u32 addTooltip(Region region, std::string value, color_t color); - - /** - * @brief Removes a hover tooltip from the Hex Editor - * @param id The ID of the tooltip to remove - */ - void removeTooltip(u32 id); - - - /** - * @brief Adds a background color highlighting to the Hex Editor using a callback function - * @param function Function that draws the highlighting based on the hovered region - * @return Unique ID used to remove the highlighting again later - */ - u32 addTooltipProvider(TooltipFunction function); - - /** - * @brief Removes a background color highlighting from the Hex Editor - * @param id The ID of the highlighting to remove - */ - void removeTooltipProvider(u32 id); - - - /** - * @brief Adds a background color highlighting to the Hex Editor using a callback function - * @param function Function that draws the highlighting based on the hovered region - * @return Unique ID used to remove the highlighting again later - */ - u32 addBackgroundHighlightingProvider(const impl::HighlightingFunction &function); - - /** - * @brief Removes a background color highlighting from the Hex Editor - * @param id The ID of the highlighting to remove - */ - void removeBackgroundHighlightingProvider(u32 id); - - - /** - * @brief Adds a foreground color highlighting to the Hex Editor using a callback function - * @param function Function that draws the highlighting based on the hovered region - * @return Unique ID used to remove the highlighting again later - */ - u32 addForegroundHighlightingProvider(const impl::HighlightingFunction &function); - - /** - * @brief Removes a foreground color highlighting from the Hex Editor - * @param id The ID of the highlighting to remove - */ - void removeForegroundHighlightingProvider(u32 id); - - /** - * @brief Adds a hovering provider to the Hex Editor using a callback function - * @param function Function that draws the highlighting based on the hovered region - * @return Unique ID used to remove the highlighting again later - */ - u32 addHoverHighlightProvider(const impl::HoveringFunction &function); - - /** - * @brief Removes a hovering color highlighting from the Hex Editor - * @param id The ID of the highlighting to remove - */ - void removeHoverHighlightProvider(u32 id); - - /** - * @brief Checks if there's a valid selection in the Hex Editor right now - */ - bool isSelectionValid(); - - /** - * @brief Clears the current selection in the Hex Editor - */ - void clearSelection(); - - /** - * @brief Gets the current selection in the Hex Editor - * @return The current selection - */ - std::optional getSelection(); - - /** - * @brief Sets the current selection in the Hex Editor - * @param region The region to select - * @param provider The provider to select the region in - */ - void setSelection(const Region ®ion, prv::Provider *provider = nullptr); - - /** - * @brief Sets the current selection in the Hex Editor - * @param region The region to select - */ - void setSelection(const ProviderRegion ®ion); - - /** - * @brief Sets the current selection in the Hex Editor - * @param address The address to select - * @param size The size of the selection - * @param provider The provider to select the region in - */ - void setSelection(u64 address, size_t size, prv::Provider *provider = nullptr); - - /** - * @brief Adds a virtual file to the list in the Hex Editor - * @param path The path of the file - * @param data The data of the file - * @param region The location of the file in the Hex Editor if available - */ - void addVirtualFile(const std::fs::path &path, std::vector data, Region region = Region::Invalid()); - - /** - * @brief Gets the currently hovered cell region in the Hex Editor - * @return - */ - const std::optional& getHoveredRegion(const prv::Provider *provider); - - } - - /* Functions to interact with Bookmarks */ - namespace Bookmarks { - - struct Entry { - Region region; - - std::string name; - std::string comment; - u32 color; - bool locked; - u64 id; - }; - - /** - * @brief Adds a new bookmark - * @param address The address of the bookmark - * @param size The size of the bookmark - * @param name The name of the bookmark - * @param comment The comment of the bookmark - * @param color The color of the bookmark or 0x00 for the default color - * @return Bookmark ID - */ - u64 add(u64 address, size_t size, const std::string &name, const std::string &comment, color_t color = 0x00000000); - - /** - * @brief Adds a new bookmark - * @param region The region of the bookmark - * @param name The name of the bookmark - * @param comment The comment of the bookmark - * @param color The color of the bookmark or 0x00 for the default color - * @return Bookmark ID - */ - u64 add(Region region, const std::string &name, const std::string &comment, color_t color = 0x00000000); - - /** - * @brief Removes a bookmark - * @param id The ID of the bookmark to remove - */ - void remove(u64 id); - - } - - /** - * Helper methods about the providers - * @note the "current provider" or "currently selected provider" refers to the currently selected provider in the UI; - * the provider the user is actually editing. - */ - namespace Provider { - - namespace impl { - - void resetClosingProvider(); - std::set getClosingProviders(); - - } - - /** - * @brief Gets the currently selected data provider - * @return The currently selected data provider, or nullptr is there is none - */ - prv::Provider *get(); - - /** - * @brief Gets a list of all currently loaded data providers - * @return The currently loaded data providers - */ - std::vector getProviders(); - - /** - * @brief Sets the currently selected data provider - * @param index Index of the provider to select - */ - void setCurrentProvider(i64 index); - - /** - * @brief Sets the currently selected data provider - * @param provider The provider to select - */ - void setCurrentProvider(NonNull provider); - - /** - * @brief Gets the index of the currently selected data provider - * @return Index of the selected provider - */ - i64 getCurrentProviderIndex(); - - /** - * @brief Checks whether the currently selected data provider is valid - * @return Whether the currently selected data provider is valid - */ - bool isValid(); - - - /** - * @brief Marks the **currently selected** data provider as dirty - */ - void markDirty(); - - /** - * @brief Marks **all data providers** as clean - */ - void resetDirty(); - - /** - * @brief Checks whether **any of the data providers** is dirty - * @return Whether any data provider is dirty - */ - bool isDirty(); - - - /** - * @brief Adds a newly created provider to the list of providers, and mark it as the selected one. - * @param provider The provider to add - * @param skipLoadInterface Whether to skip the provider's loading interface (see property documentation) - * @param select Whether to select the provider after adding it - */ - void add(std::unique_ptr &&provider, bool skipLoadInterface = false, bool select = true); - - /** - * @brief Creates a new provider and adds it to the list of providers - * @tparam T The type of the provider to create - * @param args Arguments to pass to the provider's constructor - */ - template T> - void add(auto &&...args) { - add(std::make_unique(std::forward(args)...)); - } - - /** - * @brief Removes a provider from the list of providers - * @param provider The provider to remove - * @param noQuestions Whether to skip asking the user for confirmation - */ - void remove(prv::Provider *provider, bool noQuestions = false); - - /** - * @brief Creates a new provider using its unlocalized name and add it to the list of providers - * @param unlocalizedName The unlocalized name of the provider to create - * @param skipLoadInterface Whether to skip the provider's loading interface (see property documentation) - * @param select Whether to select the provider after adding it - */ - prv::Provider* createProvider( - const UnlocalizedString &unlocalizedName, - bool skipLoadInterface = false, - bool select = true - ); - - } - - /* Functions to interact with various ImHex system settings */ - namespace System { - - struct ProgramArguments { - int argc; - char **argv; - char **envp; - }; - - struct InitialWindowProperties { - i32 x, y; - u32 width, height; - bool maximized; - }; - - enum class TaskProgressState { - Reset, - Progress, - Flash - }; - - enum class TaskProgressType { - Normal, - Warning, - Error - }; - - namespace impl { - - void setMainInstanceStatus(bool status); - - void setMainWindowPosition(i32 x, i32 y); - void setMainWindowSize(u32 width, u32 height); - void setMainDockSpaceId(ImGuiID id); - void setMainWindowHandle(GLFWwindow *window); - - void setGlobalScale(float scale); - void setNativeScale(float scale); - - void setBorderlessWindowMode(bool enabled); - void setMultiWindowMode(bool enabled); - void setInitialWindowProperties(InitialWindowProperties properties); - - void setGPUVendor(const std::string &vendor); - void setGLRenderer(const std::string &renderer); - void setGLVersion(SemanticVersion version); - - void addInitArgument(const std::string &key, const std::string &value = { }); - - void setLastFrameTime(double time); - - bool isWindowResizable(); - - void addAutoResetObject(hex::impl::AutoResetBase *object); - void removeAutoResetObject(hex::impl::AutoResetBase *object); - - void cleanup(); - - bool frameRateUnlockRequested(); - void resetFrameRateUnlockRequested(); - - } - - /** - * @brief Closes ImHex - * @param noQuestions Whether to skip asking the user for confirmation - */ - void closeImHex(bool noQuestions = false); - - /** - * @brief Restarts ImHex - */ - void restartImHex(); - - /** - * @brief Sets the progress bar in the task bar - * @param state The state of the progress bar - * @param type The type of the progress bar progress - * @param progress The progress of the progress bar - */ - void setTaskBarProgress(TaskProgressState state, TaskProgressType type, u32 progress); - - - /** - * @brief Gets the current target FPS - * @return The current target FPS - */ - float getTargetFPS(); - - /** - * @brief Sets the target FPS - * @param fps The target FPS - */ - void setTargetFPS(float fps); - - - /** - * @brief Gets the current global scale - * @return The current global scale - */ - float getGlobalScale(); - - /** - * @brief Gets the current native scale - * @return The current native scale - */ - float getNativeScale(); - - float getBackingScaleFactor(); - - /** - * @brief Gets the current main window position - * @return Position of the main window - */ - ImVec2 getMainWindowPosition(); - - /** - * @brief Gets the current main window size - * @return Size of the main window - */ - ImVec2 getMainWindowSize(); - - /** - * @brief Gets the current main dock space ID - * @return ID of the main dock space - */ - ImGuiID getMainDockSpaceId(); - - /** - * @brief Gets the main window's GLFW window handle - * @return GLFW window handle - */ - GLFWwindow* getMainWindowHandle(); - - /** - * @brief Checks if borderless window mode is enabled currently - * @return Whether borderless window mode is enabled - */ - bool isBorderlessWindowModeEnabled(); - - /** - * @brief Checks if multi-window mode is enabled currently - * @return Whether multi-window mode is enabled - */ - bool isMutliWindowModeEnabled(); - - /** - * @brief Gets the init arguments passed to ImHex from the splash screen - * @return Init arguments - */ - const std::map& getInitArguments(); - - /** - * @brief Gets a init arguments passed to ImHex from the splash screen - * @param key The key of the init argument - * @return Init argument - */ - std::string getInitArgument(const std::string &key); - - /** - * @brief Sets if ImHex should follow the system theme - * @param enabled Whether to follow the system theme - */ - void enableSystemThemeDetection(bool enabled); - - /** - * @brief Checks if ImHex follows the system theme - * @return Whether ImHex follows the system theme - */ - bool usesSystemThemeDetection(); - - - /** - * @brief Gets the currently set additional folder paths - * @return The currently set additional folder paths - */ - const std::vector& getAdditionalFolderPaths(); - - /** - * @brief Sets the additional folder paths - * @param paths The additional folder paths - */ - void setAdditionalFolderPaths(const std::vector &paths); - - - /** - * @brief Gets the current GPU vendor - * @return The current GPU vendor - */ - const std::string& getGPUVendor(); - - /** - * @brief Gets the current GPU vendor - * @return The current GPU vendor - */ - const std::string& getGLRenderer(); - - /** - * @brief Gets the current OpenGL version - * @return The current OpenGL version - */ - const SemanticVersion& getGLVersion(); - - /** - * @brief Checks if ImHex is being run in a "Corporate Environment" - * This function simply checks for common telltale signs such as if the machine is joined a - * domain. It's not super accurate, but it's still useful for statistics - * @return True if it is - */ - bool isCorporateEnvironment(); - - /** - * @brief Checks if ImHex is running in portable mode - * @return Whether ImHex is running in portable mode - */ - bool isPortableVersion(); - - /** - * @brief Gets the current Operating System name - * @return Operating System name - */ - std::string getOSName(); - - /** - * @brief Gets the current Operating System version - * @return Operating System version - */ - std::string getOSVersion(); - - /** - * @brief Gets the current CPU architecture - * @return CPU architecture - */ - std::string getArchitecture(); - - - struct LinuxDistro { - std::string name; - std::string version; - }; - /** - * @brief Gets information related to the Linux distribution, if running on Linux - */ - std::optional getLinuxDistro(); - - /** - * @brief Gets the current ImHex version - * @return ImHex version - */ - SemanticVersion getImHexVersion(); - - /** - * @brief Gets the current git commit hash - * @param longHash Whether to return the full hash or the shortened version - * @return Git commit hash - */ - std::string getCommitHash(bool longHash = false); - - /** - * @brief Gets the current git commit branch - * @return Git commit branch - */ - std::string getCommitBranch(); - - /** - * @brief Gets the time ImHex was built - * @return The time ImHex was built - */ - std::optional getBuildTime(); - - /** - * @brief Checks if ImHex was built in debug mode - * @return True if ImHex was built in debug mode, false otherwise - */ - bool isDebugBuild(); - - /** - * @brief Checks if this version of ImHex is a nightly build - * @return True if this version is a nightly, false if it's a release - */ - bool isNightlyBuild(); - - /** - * @brief Checks if there's an update available for the current version of ImHex - * @return Optional string returning the version string of the new version, or std::nullopt if no update is available - */ - std::optional checkForUpdate(); - - enum class UpdateType { - Stable, - Nightly - }; - - /** - * @brief Triggers the update process - * @param updateType The update channel - * @return If the update process was successfully started - */ - bool updateImHex(UpdateType updateType); - - /** - * @brief Add a new startup task that will be run while ImHex's splash screen is shown - * @param name Name to be shown in the UI - * @param async Whether to run the task asynchronously - * @param function The function to run - */ - void addStartupTask(const std::string &name, bool async, const std::function &function); - - /** - * @brief Gets the time the previous frame took - * @return Previous frame time - */ - double getLastFrameTime(); - - /** - * @brief Sets the window resizable - * @param resizable Whether the window should be resizable - */ - void setWindowResizable(bool resizable); - - /** - * @brief Checks if this window is the main instance of ImHex - * @return True if this is the main instance, false if another instance is already running - */ - bool isMainInstance(); - - /** - * @brief Gets the initial window properties - * @return Initial window properties - */ - std::optional getInitialWindowProperties(); - - /** - * @brief Gets the module handle of libimhex - * @return Module handle - */ - void* getLibImHexModuleHandle(); - - /** - * Adds a new migration routine that will be executed when upgrading from a lower version than specified in migrationVersion - * @param migrationVersion Upgrade point version - * @param function Function to run - */ - void addMigrationRoutine(SemanticVersion migrationVersion, std::function function); - - /** - * @brief Unlocks the frame rate temporarily, allowing animations to run smoothly - */ - void unlockFrameRate(); - - /** - * @brief Sets the current post-processing shader to use - * @param vertexShader The vertex shader to use - * @param fragmentShader The fragment shader to use - */ - void setPostProcessingShader(const std::string &vertexShader, const std::string &fragmentShader); - - } - - /** - * @brief Cross-instance messaging system - * This allows you to send messages to the "main" instance of ImHex running, from any other instance - */ - namespace Messaging { - - namespace impl { - - using MessagingHandler = std::function &)>; - - const std::map& getHandlers(); - void runHandler(const std::string &eventName, const std::vector &args); - - } - - /** - * @brief Register the handler for this specific event name - */ - void registerHandler(const std::string &eventName, const impl::MessagingHandler &handler); - } - - namespace Fonts { - - struct Offset { float x, y; }; - - struct MergeFont { - std::string name; - std::span fontData; - Offset offset; - std::optional fontSizeMultiplier; - }; - - class Font { - public: - explicit Font(UnlocalizedString fontName); - - void push(float size = 0.0F) const; - void pushBold(float size = 0.0F) const; - void pushItalic(float size = 0.0F) const; - - void pop() const; - - [[nodiscard]] operator ImFont*() const; - [[nodiscard]] const UnlocalizedString& getUnlocalizedName() const { return m_fontName; } - - private: - void push(float size, ImFont *font) const; - - private: - UnlocalizedString m_fontName; - }; - - struct FontDefinition { - ImFont* regular; - ImFont* bold; - ImFont* italic; - }; - - namespace impl { - - const std::vector& getMergeFonts(); - std::map& getFontDefinitions(); - - } - - void registerMergeFont(const std::string &name, const std::span &data, Offset offset = {}, std::optional fontSizeMultiplier = std::nullopt); - - void registerFont(const Font& font); - FontDefinition getFont(const UnlocalizedString &fontName); - - void setDefaultFont(const Font& font); - const Font& getDefaultFont(); - - float getDpi(); - float pixelsToPoints(float pixels); - float pointsToPixels(float points); - - } - - } - -} diff --git a/lib/libimhex/include/hex/api/imhex_api/bookmarks.hpp b/lib/libimhex/include/hex/api/imhex_api/bookmarks.hpp new file mode 100644 index 000000000..203dbedf8 --- /dev/null +++ b/lib/libimhex/include/hex/api/imhex_api/bookmarks.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include + +#include + +EXPORT_MODULE namespace hex { + + /* Functions to interact with Bookmarks */ + namespace ImHexApi::Bookmarks { + + struct Entry { + Region region; + + std::string name; + std::string comment; + u32 color; + bool locked; + u64 id; + }; + + /** + * @brief Adds a new bookmark + * @param address The address of the bookmark + * @param size The size of the bookmark + * @param name The name of the bookmark + * @param comment The comment of the bookmark + * @param color The color of the bookmark or 0x00 for the default color + * @return Bookmark ID + */ + u64 add(u64 address, size_t size, const std::string &name, const std::string &comment, color_t color = 0x00000000); + + /** + * @brief Adds a new bookmark + * @param region The region of the bookmark + * @param name The name of the bookmark + * @param comment The comment of the bookmark + * @param color The color of the bookmark or 0x00 for the default color + * @return Bookmark ID + */ + u64 add(Region region, const std::string &name, const std::string &comment, color_t color = 0x00000000); + + /** + * @brief Removes a bookmark + * @param id The ID of the bookmark to remove + */ + void remove(u64 id); + + } + + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/imhex_api/fonts.hpp b/lib/libimhex/include/hex/api/imhex_api/fonts.hpp new file mode 100644 index 000000000..61ff495c8 --- /dev/null +++ b/lib/libimhex/include/hex/api/imhex_api/fonts.hpp @@ -0,0 +1,77 @@ +#pragma once + +#include + +#include + +#include +#include +#include + +#if !defined(HEX_MODULE_EXPORT) + struct ImFont; +#endif + +EXPORT_MODULE namespace hex { + + /* Functions for adding new font types */ + namespace ImHexApi::Fonts { + + struct Offset { float x, y; }; + + struct MergeFont { + std::string name; + std::span fontData; + Offset offset; + std::optional fontSizeMultiplier; + }; + + class Font { + public: + explicit Font(UnlocalizedString fontName); + + void push(float size = 0.0F) const; + void pushBold(float size = 0.0F) const; + void pushItalic(float size = 0.0F) const; + + void pop() const; + + [[nodiscard]] operator ImFont*() const; + [[nodiscard]] const UnlocalizedString& getUnlocalizedName() const { return m_fontName; } + + private: + void push(float size, ImFont *font) const; + + private: + UnlocalizedString m_fontName; + }; + + struct FontDefinition { + ImFont* regular; + ImFont* bold; + ImFont* italic; + }; + + namespace impl { + + const std::vector& getMergeFonts(); + std::map& getFontDefinitions(); + + } + + void registerMergeFont(const std::string &name, const std::span &data, Offset offset = {}, std::optional fontSizeMultiplier = std::nullopt); + + void registerFont(const Font& font); + FontDefinition getFont(const UnlocalizedString &fontName); + + void setDefaultFont(const Font& font); + const Font& getDefaultFont(); + + float getDpi(); + float pixelsToPoints(float pixels); + float pointsToPixels(float points); + + } + + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/imhex_api/hex_editor.hpp b/lib/libimhex/include/hex/api/imhex_api/hex_editor.hpp new file mode 100644 index 000000000..9147c8fb7 --- /dev/null +++ b/lib/libimhex/include/hex/api/imhex_api/hex_editor.hpp @@ -0,0 +1,228 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include +#include + +EXPORT_MODULE namespace hex { + + #if !defined(HEX_MODULE_EXPORT) + namespace prv { class Provider; } + #endif + + /* Functions to query information from the Hex Editor and interact with it */ + namespace ImHexApi::HexEditor { + + using TooltipFunction = std::function; + + class Highlighting { + public: + Highlighting() = default; + Highlighting(Region region, color_t color); + + [[nodiscard]] const Region& getRegion() const { return m_region; } + [[nodiscard]] const color_t& getColor() const { return m_color; } + + private: + Region m_region = {}; + color_t m_color = 0x00; + }; + + class Tooltip { + public: + Tooltip() = default; + Tooltip(Region region, std::string value, color_t color); + + [[nodiscard]] const Region& getRegion() const { return m_region; } + [[nodiscard]] const color_t& getColor() const { return m_color; } + [[nodiscard]] const std::string& getValue() const { return m_value; } + + private: + Region m_region = {}; + std::string m_value; + color_t m_color = 0x00; + }; + + struct ProviderRegion : Region { + prv::Provider *provider; + + [[nodiscard]] prv::Provider *getProvider() const { return this->provider; } + + [[nodiscard]] Region getRegion() const { return { this->address, this->size }; } + }; + + namespace impl { + + using HighlightingFunction = std::function(u64, const u8*, size_t, bool)>; + using HoveringFunction = std::function(const prv::Provider *, u64, size_t)>; + + const std::map& getBackgroundHighlights(); + const std::map& getBackgroundHighlightingFunctions(); + const std::map& getForegroundHighlights(); + const std::map& getForegroundHighlightingFunctions(); + const std::map& getHoveringFunctions(); + const std::map& getTooltips(); + const std::map& getTooltipFunctions(); + + void setCurrentSelection(const std::optional ®ion); + void setHoveredRegion(const prv::Provider *provider, const Region ®ion); + } + + /** + * @brief Adds a background color highlighting to the Hex Editor + * @param region The region to highlight + * @param color The color to use for the highlighting + * @return Unique ID used to remove the highlighting again later + */ + u32 addBackgroundHighlight(const Region ®ion, color_t color); + + /** + * @brief Removes a background color highlighting from the Hex Editor + * @param id The ID of the highlighting to remove + */ + void removeBackgroundHighlight(u32 id); + + + /** + * @brief Adds a foreground color highlighting to the Hex Editor + * @param region The region to highlight + * @param color The color to use for the highlighting + * @return Unique ID used to remove the highlighting again later + */ + u32 addForegroundHighlight(const Region ®ion, color_t color); + + /** + * @brief Removes a foreground color highlighting from the Hex Editor + * @param id The ID of the highlighting to remove + */ + void removeForegroundHighlight(u32 id); + + /** + * @brief Adds a hover tooltip to the Hex Editor + * @param region The region to add the tooltip to + * @param value Text to display in the tooltip + * @param color The color of the tooltip + * @return Unique ID used to remove the tooltip again later + */ + u32 addTooltip(Region region, std::string value, color_t color); + + /** + * @brief Removes a hover tooltip from the Hex Editor + * @param id The ID of the tooltip to remove + */ + void removeTooltip(u32 id); + + + /** + * @brief Adds a background color highlighting to the Hex Editor using a callback function + * @param function Function that draws the highlighting based on the hovered region + * @return Unique ID used to remove the highlighting again later + */ + u32 addTooltipProvider(TooltipFunction function); + + /** + * @brief Removes a background color highlighting from the Hex Editor + * @param id The ID of the highlighting to remove + */ + void removeTooltipProvider(u32 id); + + + /** + * @brief Adds a background color highlighting to the Hex Editor using a callback function + * @param function Function that draws the highlighting based on the hovered region + * @return Unique ID used to remove the highlighting again later + */ + u32 addBackgroundHighlightingProvider(const impl::HighlightingFunction &function); + + /** + * @brief Removes a background color highlighting from the Hex Editor + * @param id The ID of the highlighting to remove + */ + void removeBackgroundHighlightingProvider(u32 id); + + + /** + * @brief Adds a foreground color highlighting to the Hex Editor using a callback function + * @param function Function that draws the highlighting based on the hovered region + * @return Unique ID used to remove the highlighting again later + */ + u32 addForegroundHighlightingProvider(const impl::HighlightingFunction &function); + + /** + * @brief Removes a foreground color highlighting from the Hex Editor + * @param id The ID of the highlighting to remove + */ + void removeForegroundHighlightingProvider(u32 id); + + /** + * @brief Adds a hovering provider to the Hex Editor using a callback function + * @param function Function that draws the highlighting based on the hovered region + * @return Unique ID used to remove the highlighting again later + */ + u32 addHoverHighlightProvider(const impl::HoveringFunction &function); + + /** + * @brief Removes a hovering color highlighting from the Hex Editor + * @param id The ID of the highlighting to remove + */ + void removeHoverHighlightProvider(u32 id); + + /** + * @brief Checks if there's a valid selection in the Hex Editor right now + */ + bool isSelectionValid(); + + /** + * @brief Clears the current selection in the Hex Editor + */ + void clearSelection(); + + /** + * @brief Gets the current selection in the Hex Editor + * @return The current selection + */ + std::optional getSelection(); + + /** + * @brief Sets the current selection in the Hex Editor + * @param region The region to select + * @param provider The provider to select the region in + */ + void setSelection(const Region ®ion, prv::Provider *provider = nullptr); + + /** + * @brief Sets the current selection in the Hex Editor + * @param region The region to select + */ + void setSelection(const ProviderRegion ®ion); + + /** + * @brief Sets the current selection in the Hex Editor + * @param address The address to select + * @param size The size of the selection + * @param provider The provider to select the region in + */ + void setSelection(u64 address, size_t size, prv::Provider *provider = nullptr); + + /** + * @brief Adds a virtual file to the list in the Hex Editor + * @param path The path of the file + * @param data The data of the file + * @param region The location of the file in the Hex Editor if available + */ + void addVirtualFile(const std::string &path, std::vector data, Region region = Region::Invalid()); + + /** + * @brief Gets the currently hovered cell region in the Hex Editor + * @return + */ + const std::optional& getHoveredRegion(const prv::Provider *provider); + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/imhex_api/messaging.hpp b/lib/libimhex/include/hex/api/imhex_api/messaging.hpp new file mode 100644 index 000000000..0f81146bf --- /dev/null +++ b/lib/libimhex/include/hex/api/imhex_api/messaging.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include + +#include +#include +#include +#include + +EXPORT_MODULE namespace hex { + + /** + * Cross-instance messaging system + * This allows you to send messages to the "main" instance of ImHex running, from any other instance + */ + namespace ImHexApi::Messaging { + + namespace impl { + + using MessagingHandler = std::function &)>; + + const std::map& getHandlers(); + void runHandler(const std::string &eventName, const std::vector &args); + + } + + /** + * @brief Register the handler for this specific event name + */ + void registerHandler(const std::string &eventName, const impl::MessagingHandler &handler); + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/imhex_api/provider.hpp b/lib/libimhex/include/hex/api/imhex_api/provider.hpp new file mode 100644 index 000000000..570f854e1 --- /dev/null +++ b/lib/libimhex/include/hex/api/imhex_api/provider.hpp @@ -0,0 +1,122 @@ +#pragma once + +#include + +#include +#include + +#include +#include +#include +#include + +EXPORT_MODULE namespace hex { + + /** + * Helper methods about the providers + * @note the "current provider" or "currently selected provider" refers to the currently selected provider in the UI; + * the provider the user is actually editing. + */ + namespace ImHexApi::Provider { + + namespace impl { + + void resetClosingProvider(); + std::set getClosingProviders(); + + } + + /** + * @brief Gets the currently selected data provider + * @return The currently selected data provider, or nullptr is there is none + */ + prv::Provider *get(); + + /** + * @brief Gets a list of all currently loaded data providers + * @return The currently loaded data providers + */ + std::vector getProviders(); + + /** + * @brief Sets the currently selected data provider + * @param index Index of the provider to select + */ + void setCurrentProvider(i64 index); + + /** + * @brief Sets the currently selected data provider + * @param provider The provider to select + */ + void setCurrentProvider(NonNull provider); + + /** + * @brief Gets the index of the currently selected data provider + * @return Index of the selected provider + */ + i64 getCurrentProviderIndex(); + + /** + * @brief Checks whether the currently selected data provider is valid + * @return Whether the currently selected data provider is valid + */ + bool isValid(); + + + /** + * @brief Marks the **currently selected** data provider as dirty + */ + void markDirty(); + + /** + * @brief Marks **all data providers** as clean + */ + void resetDirty(); + + /** + * @brief Checks whether **any of the data providers** is dirty + * @return Whether any data provider is dirty + */ + bool isDirty(); + + + /** + * @brief Adds a newly created provider to the list of providers, and mark it as the selected one. + * @param provider The provider to add + * @param skipLoadInterface Whether to skip the provider's loading interface (see property documentation) + * @param select Whether to select the provider after adding it + */ + void add(std::unique_ptr &&provider, bool skipLoadInterface = false, bool select = true); + + /** + * @brief Creates a new provider and adds it to the list of providers + * @tparam T The type of the provider to create + * @param args Arguments to pass to the provider's constructor + */ + template T> + void add(auto &&...args) { + add(std::make_unique(std::forward(args)...)); + } + + /** + * @brief Removes a provider from the list of providers + * @param provider The provider to remove + * @param noQuestions Whether to skip asking the user for confirmation + */ + void remove(prv::Provider *provider, bool noQuestions = false); + + /** + * @brief Creates a new provider using its unlocalized name and add it to the list of providers + * @param unlocalizedName The unlocalized name of the provider to create + * @param skipLoadInterface Whether to skip the provider's loading interface (see property documentation) + * @param select Whether to select the provider after adding it + */ + prv::Provider* createProvider( + const UnlocalizedString &unlocalizedName, + bool skipLoadInterface = false, + bool select = true + ); + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/imhex_api/system.hpp b/lib/libimhex/include/hex/api/imhex_api/system.hpp new file mode 100644 index 000000000..ac8012f6d --- /dev/null +++ b/lib/libimhex/include/hex/api/imhex_api/system.hpp @@ -0,0 +1,389 @@ +#pragma once + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#if !defined(HEX_MODULE_EXPORT) + using ImGuiID = unsigned int; + struct ImVec2; + struct ImFontAtlas; +#endif + +struct GLFWwindow; + +EXPORT_MODULE namespace hex { + + #if !defined(HEX_MODULE_EXPORT) + namespace impl { + class AutoResetBase; + } + #endif + + /* Functions to interact with various ImHex system settings */ + namespace ImHexApi::System { + + struct ProgramArguments { + int argc; + char **argv; + char **envp; + }; + + struct InitialWindowProperties { + i32 x, y; + u32 width, height; + bool maximized; + }; + + enum class TaskProgressState { + Reset, + Progress, + Flash + }; + + enum class TaskProgressType { + Normal, + Warning, + Error + }; + + namespace impl { + + void setMainInstanceStatus(bool status); + + void setMainWindowPosition(i32 x, i32 y); + void setMainWindowSize(u32 width, u32 height); + void setMainDockSpaceId(ImGuiID id); + void setMainWindowHandle(GLFWwindow *window); + + void setGlobalScale(float scale); + void setNativeScale(float scale); + + void setBorderlessWindowMode(bool enabled); + void setMultiWindowMode(bool enabled); + void setInitialWindowProperties(InitialWindowProperties properties); + + void setGPUVendor(const std::string &vendor); + void setGLRenderer(const std::string &renderer); + void setGLVersion(SemanticVersion version); + + void addInitArgument(const std::string &key, const std::string &value = { }); + + void setLastFrameTime(double time); + + bool isWindowResizable(); + + void addAutoResetObject(hex::impl::AutoResetBase *object); + void removeAutoResetObject(hex::impl::AutoResetBase *object); + + void cleanup(); + + bool frameRateUnlockRequested(); + void resetFrameRateUnlockRequested(); + + } + + /** + * @brief Closes ImHex + * @param noQuestions Whether to skip asking the user for confirmation + */ + void closeImHex(bool noQuestions = false); + + /** + * @brief Restarts ImHex + */ + void restartImHex(); + + /** + * @brief Sets the progress bar in the task bar + * @param state The state of the progress bar + * @param type The type of the progress bar progress + * @param progress The progress of the progress bar + */ + void setTaskBarProgress(TaskProgressState state, TaskProgressType type, u32 progress); + + + /** + * @brief Gets the current target FPS + * @return The current target FPS + */ + float getTargetFPS(); + + /** + * @brief Sets the target FPS + * @param fps The target FPS + */ + void setTargetFPS(float fps); + + + /** + * @brief Gets the current global scale + * @return The current global scale + */ + float getGlobalScale(); + + /** + * @brief Gets the current native scale + * @return The current native scale + */ + float getNativeScale(); + + float getBackingScaleFactor(); + + /** + * @brief Gets the current main window position + * @return Position of the main window + */ + ImVec2 getMainWindowPosition(); + + /** + * @brief Gets the current main window size + * @return Size of the main window + */ + ImVec2 getMainWindowSize(); + + /** + * @brief Gets the current main dock space ID + * @return ID of the main dock space + */ + ImGuiID getMainDockSpaceId(); + + /** + * @brief Gets the main window's GLFW window handle + * @return GLFW window handle + */ + GLFWwindow* getMainWindowHandle(); + + /** + * @brief Checks if borderless window mode is enabled currently + * @return Whether borderless window mode is enabled + */ + bool isBorderlessWindowModeEnabled(); + + /** + * @brief Checks if multi-window mode is enabled currently + * @return Whether multi-window mode is enabled + */ + bool isMutliWindowModeEnabled(); + + /** + * @brief Gets the init arguments passed to ImHex from the splash screen + * @return Init arguments + */ + const std::map& getInitArguments(); + + /** + * @brief Gets a init arguments passed to ImHex from the splash screen + * @param key The key of the init argument + * @return Init argument + */ + std::string getInitArgument(const std::string &key); + + /** + * @brief Sets if ImHex should follow the system theme + * @param enabled Whether to follow the system theme + */ + void enableSystemThemeDetection(bool enabled); + + /** + * @brief Checks if ImHex follows the system theme + * @return Whether ImHex follows the system theme + */ + bool usesSystemThemeDetection(); + + + /** + * @brief Gets the currently set additional folder paths + * @return The currently set additional folder paths + */ + const std::vector& getAdditionalFolderPaths(); + + /** + * @brief Sets the additional folder paths + * @param paths The additional folder paths + */ + void setAdditionalFolderPaths(const std::vector &paths); + + + /** + * @brief Gets the current GPU vendor + * @return The current GPU vendor + */ + const std::string& getGPUVendor(); + + /** + * @brief Gets the current GPU vendor + * @return The current GPU vendor + */ + const std::string& getGLRenderer(); + + /** + * @brief Gets the current OpenGL version + * @return The current OpenGL version + */ + const SemanticVersion& getGLVersion(); + + /** + * @brief Checks if ImHex is being run in a "Corporate Environment" + * This function simply checks for common telltale signs such as if the machine is joined a + * domain. It's not super accurate, but it's still useful for statistics + * @return True if it is + */ + bool isCorporateEnvironment(); + + /** + * @brief Checks if ImHex is running in portable mode + * @return Whether ImHex is running in portable mode + */ + bool isPortableVersion(); + + /** + * @brief Gets the current Operating System name + * @return Operating System name + */ + std::string getOSName(); + + /** + * @brief Gets the current Operating System version + * @return Operating System version + */ + std::string getOSVersion(); + + /** + * @brief Gets the current CPU architecture + * @return CPU architecture + */ + std::string getArchitecture(); + + + struct LinuxDistro { + std::string name; + std::string version; + }; + /** + * @brief Gets information related to the Linux distribution, if running on Linux + */ + std::optional getLinuxDistro(); + + /** + * @brief Gets the current ImHex version + * @return ImHex version + */ + SemanticVersion getImHexVersion(); + + /** + * @brief Gets the current git commit hash + * @param longHash Whether to return the full hash or the shortened version + * @return Git commit hash + */ + std::string getCommitHash(bool longHash = false); + + /** + * @brief Gets the current git commit branch + * @return Git commit branch + */ + std::string getCommitBranch(); + + /** + * @brief Gets the time ImHex was built + * @return The time ImHex was built + */ + std::optional getBuildTime(); + + /** + * @brief Checks if ImHex was built in debug mode + * @return True if ImHex was built in debug mode, false otherwise + */ + bool isDebugBuild(); + + /** + * @brief Checks if this version of ImHex is a nightly build + * @return True if this version is a nightly, false if it's a release + */ + bool isNightlyBuild(); + + /** + * @brief Checks if there's an update available for the current version of ImHex + * @return Optional string returning the version string of the new version, or std::nullopt if no update is available + */ + std::optional checkForUpdate(); + + enum class UpdateType { + Stable, + Nightly + }; + + /** + * @brief Triggers the update process + * @param updateType The update channel + * @return If the update process was successfully started + */ + bool updateImHex(UpdateType updateType); + + /** + * @brief Add a new startup task that will be run while ImHex's splash screen is shown + * @param name Name to be shown in the UI + * @param async Whether to run the task asynchronously + * @param function The function to run + */ + void addStartupTask(const std::string &name, bool async, const std::function &function); + + /** + * @brief Gets the time the previous frame took + * @return Previous frame time + */ + double getLastFrameTime(); + + /** + * @brief Sets the window resizable + * @param resizable Whether the window should be resizable + */ + void setWindowResizable(bool resizable); + + /** + * @brief Checks if this window is the main instance of ImHex + * @return True if this is the main instance, false if another instance is already running + */ + bool isMainInstance(); + + /** + * @brief Gets the initial window properties + * @return Initial window properties + */ + std::optional getInitialWindowProperties(); + + /** + * @brief Gets the module handle of libimhex + * @return Module handle + */ + void* getLibImHexModuleHandle(); + + /** + * Adds a new migration routine that will be executed when upgrading from a lower version than specified in migrationVersion + * @param migrationVersion Upgrade point version + * @param function Function to run + */ + void addMigrationRoutine(SemanticVersion migrationVersion, std::function function); + + /** + * @brief Unlocks the frame rate temporarily, allowing animations to run smoothly + */ + void unlockFrameRate(); + + /** + * @brief Sets the current post-processing shader to use + * @param vertexShader The vertex shader to use + * @param fragmentShader The fragment shader to use + */ + void setPostProcessingShader(const std::string &vertexShader, const std::string &fragmentShader); + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/localization_manager.hpp b/lib/libimhex/include/hex/api/localization_manager.hpp index e89ddee5a..77e8ddc19 100644 --- a/lib/libimhex/include/hex/api/localization_manager.hpp +++ b/lib/libimhex/include/hex/api/localization_manager.hpp @@ -10,28 +10,27 @@ #include #include -#include EXPORT_MODULE namespace hex { namespace LocalizationManager { struct PathEntry { - std::filesystem::path path; - std::function callback; + std::string path; + std::function callback; }; struct LanguageDefinition { std::string id; std::string name, nativeName; std::string flag; - std::fs::path filePath; + std::string filePath; std::string fallbackLanguageId; std::vector languageFilePaths; }; - void addLanguages(const std::string_view &languageList, std::function callback); + void addLanguages(const std::string_view &languageList, std::function callback); void setLanguage(const std::string &languageId); [[nodiscard]] const std::string& getSelectedLanguageId(); [[nodiscard]] const std::string& get(const std::string &unlocalizedString); diff --git a/lib/libimhex/include/hex/helpers/auto_reset.hpp b/lib/libimhex/include/hex/helpers/auto_reset.hpp index 7a8628fb4..626462ced 100644 --- a/lib/libimhex/include/hex/helpers/auto_reset.hpp +++ b/lib/libimhex/include/hex/helpers/auto_reset.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace hex { diff --git a/lib/libimhex/include/hex/helpers/scaling.hpp b/lib/libimhex/include/hex/helpers/scaling.hpp new file mode 100644 index 000000000..9d0609e1a --- /dev/null +++ b/lib/libimhex/include/hex/helpers/scaling.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace hex { + + [[nodiscard]] float operator""_scaled(long double value); + [[nodiscard]] float operator""_scaled(unsigned long long value); + [[nodiscard]] ImVec2 scaled(const ImVec2 &vector); + [[nodiscard]] ImVec2 scaled(float x, float y); + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/helpers/utils.hpp b/lib/libimhex/include/hex/helpers/utils.hpp index d1520f656..37d9ae868 100644 --- a/lib/libimhex/include/hex/helpers/utils.hpp +++ b/lib/libimhex/include/hex/helpers/utils.hpp @@ -73,10 +73,6 @@ namespace hex { return result; } - [[nodiscard]] float operator""_scaled(long double value); - [[nodiscard]] float operator""_scaled(unsigned long long value); - [[nodiscard]] ImVec2 scaled(const ImVec2 &vector); - template [[nodiscard]] std::vector operator|(const std::vector &lhs, const std::vector &rhs) { std::vector result; diff --git a/lib/libimhex/include/hex/providers/provider.hpp b/lib/libimhex/include/hex/providers/provider.hpp index 766a18b6f..d9c9a047d 100644 --- a/lib/libimhex/include/hex/providers/provider.hpp +++ b/lib/libimhex/include/hex/providers/provider.hpp @@ -3,7 +3,6 @@ #include #include -#include #include #include #include diff --git a/lib/libimhex/include/hex/providers/provider_data.hpp b/lib/libimhex/include/hex/providers/provider_data.hpp index 41d6c9120..39a651214 100644 --- a/lib/libimhex/include/hex/providers/provider_data.hpp +++ b/lib/libimhex/include/hex/providers/provider_data.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/lib/libimhex/include/hex/ui/banner.hpp b/lib/libimhex/include/hex/ui/banner.hpp index f6af6fa90..87bea2ad4 100644 --- a/lib/libimhex/include/hex/ui/banner.hpp +++ b/lib/libimhex/include/hex/ui/banner.hpp @@ -3,12 +3,11 @@ #include #include #include -#include +#include #include #include #include -#include "hex/api/localization_manager.hpp" namespace hex { diff --git a/lib/libimhex/include/hex/ui/popup.hpp b/lib/libimhex/include/hex/ui/popup.hpp index afaee1edf..2cbb26a6b 100644 --- a/lib/libimhex/include/hex/ui/popup.hpp +++ b/lib/libimhex/include/hex/ui/popup.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include namespace hex { diff --git a/lib/libimhex/include/hex/ui/view.hpp b/lib/libimhex/include/hex/ui/view.hpp index d2d8ba70a..e7fe147fb 100644 --- a/lib/libimhex/include/hex/ui/view.hpp +++ b/lib/libimhex/include/hex/ui/view.hpp @@ -3,17 +3,14 @@ #include #include -#include #include -#include #include #include -#include #include -#include +#include #include #include diff --git a/lib/libimhex/source/api/content_registry.cpp b/lib/libimhex/source/api/content_registry.cpp index acf1d4e30..0aa6d60af 100644 --- a/lib/libimhex/source/api/content_registry.cpp +++ b/lib/libimhex/source/api/content_registry.cpp @@ -6,10 +6,13 @@ #include #include #include +#include #include #include +#include + #include #include #include diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index 65478bcd1..04670f585 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -1,4 +1,9 @@ -#include +#include +#include +#include +#include +#include +#include #include #include @@ -255,7 +260,7 @@ namespace hex { setSelection({ { address, size }, provider == nullptr ? Provider::get() : provider }); } - void addVirtualFile(const std::fs::path &path, std::vector data, Region region) { + void addVirtualFile(const std::string &path, std::vector data, Region region) { RequestAddVirtualFile::post(path, std::move(data), region); } diff --git a/lib/libimhex/source/api/localization_manager.cpp b/lib/libimhex/source/api/localization_manager.cpp index 1aae25ac4..b499ac054 100644 --- a/lib/libimhex/source/api/localization_manager.cpp +++ b/lib/libimhex/source/api/localization_manager.cpp @@ -18,7 +18,7 @@ namespace hex { } - void addLanguages(const std::string_view &languageList, std::function callback) { + void addLanguages(const std::string_view &languageList, std::function callback) { const auto json = nlohmann::json::parse(languageList); for (const auto &item : json) { @@ -41,7 +41,7 @@ namespace hex { definition.fallbackLanguageId = item["fallback"].get(); } - definition.languageFilePaths.emplace_back(PathEntry{ item["path"].get(), callback }); + definition.languageFilePaths.emplace_back(PathEntry{ item["path"].get(), std::move(callback) }); } } diff --git a/lib/libimhex/source/api/plugin_manager.cpp b/lib/libimhex/source/api/plugin_manager.cpp index 0787fe251..108ad0e97 100644 --- a/lib/libimhex/source/api/plugin_manager.cpp +++ b/lib/libimhex/source/api/plugin_manager.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/lib/libimhex/source/api/theme_manager.cpp b/lib/libimhex/source/api/theme_manager.cpp index 7851cb855..b76c9ec00 100644 --- a/lib/libimhex/source/api/theme_manager.cpp +++ b/lib/libimhex/source/api/theme_manager.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include diff --git a/lib/libimhex/source/api/tutorial_manager.cpp b/lib/libimhex/source/api/tutorial_manager.cpp index b45522542..f664dcb83 100644 --- a/lib/libimhex/source/api/tutorial_manager.cpp +++ b/lib/libimhex/source/api/tutorial_manager.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/lib/libimhex/source/helpers/default_paths.cpp b/lib/libimhex/source/helpers/default_paths.cpp index b3793ab8a..a3040b3a8 100644 --- a/lib/libimhex/source/helpers/default_paths.cpp +++ b/lib/libimhex/source/helpers/default_paths.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #if defined(OS_WINDOWS) diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index 0a1ef026e..31a9c23f3 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -1,7 +1,5 @@ #include -#include -#include #include #include #include diff --git a/lib/libimhex/source/helpers/scaling.cpp b/lib/libimhex/source/helpers/scaling.cpp new file mode 100644 index 000000000..7f9bda650 --- /dev/null +++ b/lib/libimhex/source/helpers/scaling.cpp @@ -0,0 +1,23 @@ +#include + +#include + +namespace hex { + + float operator""_scaled(long double value) { + return value * ImHexApi::System::getGlobalScale(); + } + + float operator""_scaled(unsigned long long value) { + return value * ImHexApi::System::getGlobalScale(); + } + + ImVec2 scaled(const ImVec2 &vector) { + return vector * ImHexApi::System::getGlobalScale(); + } + + ImVec2 scaled(float x, float y) { + return ImVec2(x, y) * ImHexApi::System::getGlobalScale(); + } + +} \ No newline at end of file diff --git a/lib/libimhex/source/helpers/utils.cpp b/lib/libimhex/source/helpers/utils.cpp index 5fec4e561..3bdd11833 100644 --- a/lib/libimhex/source/helpers/utils.cpp +++ b/lib/libimhex/source/helpers/utils.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include @@ -37,21 +37,6 @@ #endif namespace hex { - float operator""_scaled(long double value) { - return value * ImHexApi::System::getGlobalScale(); - } - - float operator""_scaled(unsigned long long value) { - return value * ImHexApi::System::getGlobalScale(); - } - - ImVec2 scaled(const ImVec2 &vector) { - return vector * ImHexApi::System::getGlobalScale(); - } - - ImVec2 scaled(float x, float y) { - return ImVec2(x, y) * ImHexApi::System::getGlobalScale(); - } std::string to_string(u128 value) { char data[45] = { 0 }; diff --git a/lib/libimhex/source/subcommands/subcommands.cpp b/lib/libimhex/source/subcommands/subcommands.cpp index 33b8a17cf..3841ec137 100644 --- a/lib/libimhex/source/subcommands/subcommands.cpp +++ b/lib/libimhex/source/subcommands/subcommands.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index faef35f90..c51e4d397 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -18,13 +18,11 @@ #include #include -#include +#include #include #include #include -#include - namespace ImGuiExt { diff --git a/lib/libimhex/source/ui/view.cpp b/lib/libimhex/source/ui/view.cpp index 74fc978dc..fee0ff517 100644 --- a/lib/libimhex/source/ui/view.cpp +++ b/lib/libimhex/source/ui/view.cpp @@ -2,6 +2,9 @@ #include #include +#include +#include + #include #include diff --git a/main/gui/source/init/run/common.cpp b/main/gui/source/init/run/common.cpp index c2d1fced1..e64da3291 100644 --- a/main/gui/source/init/run/common.cpp +++ b/main/gui/source/init/run/common.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/main/gui/source/init/run/desktop.cpp b/main/gui/source/init/run/desktop.cpp index bb83167cc..a9b0714a3 100644 --- a/main/gui/source/init/run/desktop.cpp +++ b/main/gui/source/init/run/desktop.cpp @@ -1,6 +1,7 @@ #if !defined(OS_WEB) #include + #include #include #include diff --git a/main/gui/source/init/run/web.cpp b/main/gui/source/init/run/web.cpp index 1dae30c25..11809a9d3 100644 --- a/main/gui/source/init/run/web.cpp +++ b/main/gui/source/init/run/web.cpp @@ -4,7 +4,6 @@ #include #include - #include #include #include diff --git a/main/gui/source/init/splash_window.cpp b/main/gui/source/init/splash_window.cpp index 21c2addf3..f626e2f8f 100644 --- a/main/gui/source/init/splash_window.cpp +++ b/main/gui/source/init/splash_window.cpp @@ -1,13 +1,12 @@ #include "window.hpp" #include "init/splash_window.hpp" -#include +#include #include #include #include #include -#include #include diff --git a/main/gui/source/messaging/common.cpp b/main/gui/source/messaging/common.cpp index 1e31ab33c..ff4d399a4 100644 --- a/main/gui/source/messaging/common.cpp +++ b/main/gui/source/messaging/common.cpp @@ -1,6 +1,7 @@ #include -#include +#include +#include #include #include #include @@ -30,10 +31,10 @@ namespace hex::messaging { EventNativeMessageReceived::subscribe([](const std::vector &rawData) { i64 nullIndex = -1; - auto messageData = reinterpret_cast(rawData.data()); - size_t messageSize = rawData.size(); + const auto messageData = reinterpret_cast(rawData.data()); + const std::size_t messageSize = rawData.size(); - for (size_t i = 0; i < messageSize; i++) { + for (std::size_t i = 0; i < messageSize; i++) { if (messageData[i] == '\0') { nullIndex = i; break; @@ -45,8 +46,8 @@ namespace hex::messaging { return; } - std::string eventName(messageData, nullIndex); - std::vector eventData(messageData + nullIndex + 1, messageData + messageSize); + const std::string eventName(messageData, nullIndex); + const std::vector eventData(messageData + nullIndex + 1, messageData + messageSize); messageReceived(eventName, eventData); }); diff --git a/main/gui/source/window/platform/linux.cpp b/main/gui/source/window/platform/linux.cpp index 091974746..902463e67 100644 --- a/main/gui/source/window/platform/linux.cpp +++ b/main/gui/source/window/platform/linux.cpp @@ -2,7 +2,7 @@ #if defined(OS_LINUX) - #include + #include #include #include #include diff --git a/main/gui/source/window/platform/macos.cpp b/main/gui/source/window/platform/macos.cpp index d72ed4a11..54eff9e00 100644 --- a/main/gui/source/window/platform/macos.cpp +++ b/main/gui/source/window/platform/macos.cpp @@ -3,7 +3,8 @@ #if defined(OS_MACOS) #include - #include + #include + #include #include #include #include diff --git a/main/gui/source/window/platform/windows.cpp b/main/gui/source/window/platform/windows.cpp index 9825f25b9..db1c9f66e 100644 --- a/main/gui/source/window/platform/windows.cpp +++ b/main/gui/source/window/platform/windows.cpp @@ -4,6 +4,7 @@ #include "messaging.hpp" + #include #include #include diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index 327b40794..4e001f30c 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include @@ -18,6 +18,8 @@ #include #include +#include + #include #include #include diff --git a/main/updater/source/main.cpp b/main/updater/source/main.cpp index 0a1ee6201..92e417af5 100644 --- a/main/updater/source/main.cpp +++ b/main/updater/source/main.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/plugins/builtin/include/content/helpers/diagrams.hpp b/plugins/builtin/include/content/helpers/diagrams.hpp index 10e0ffb44..53b1de249 100644 --- a/plugins/builtin/include/content/helpers/diagrams.hpp +++ b/plugins/builtin/include/content/helpers/diagrams.hpp @@ -5,8 +5,9 @@ #include #include -#include +#include #include +#include #include #include diff --git a/plugins/builtin/include/content/popups/popup_blocking_task.hpp b/plugins/builtin/include/content/popups/popup_blocking_task.hpp index 19898f8c3..874a31d6a 100644 --- a/plugins/builtin/include/content/popups/popup_blocking_task.hpp +++ b/plugins/builtin/include/content/popups/popup_blocking_task.hpp @@ -1,9 +1,10 @@ #pragma once #include - #include +#include + #include namespace hex::plugin::builtin { diff --git a/plugins/builtin/include/content/popups/popup_tasks_waiting.hpp b/plugins/builtin/include/content/popups/popup_tasks_waiting.hpp index 23b8291d4..7d703a28f 100644 --- a/plugins/builtin/include/content/popups/popup_tasks_waiting.hpp +++ b/plugins/builtin/include/content/popups/popup_tasks_waiting.hpp @@ -4,7 +4,7 @@ #include -#include +#include namespace hex::plugin::builtin { diff --git a/plugins/builtin/include/content/providers/null_provider.hpp b/plugins/builtin/include/content/providers/null_provider.hpp index 4aadb7f91..f2cca2019 100644 --- a/plugins/builtin/include/content/providers/null_provider.hpp +++ b/plugins/builtin/include/content/providers/null_provider.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include diff --git a/plugins/builtin/include/content/views/view_bookmarks.hpp b/plugins/builtin/include/content/views/view_bookmarks.hpp index 0ac2e5a6e..bac57e129 100644 --- a/plugins/builtin/include/content/views/view_bookmarks.hpp +++ b/plugins/builtin/include/content/views/view_bookmarks.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include @@ -36,4 +37,4 @@ namespace hex::plugin::builtin { PerProvider m_currBookmarkId; }; -} \ No newline at end of file +} diff --git a/plugins/builtin/include/content/views/view_command_palette.hpp b/plugins/builtin/include/content/views/view_command_palette.hpp index 1975b0fd1..7aea4e025 100644 --- a/plugins/builtin/include/content/views/view_command_palette.hpp +++ b/plugins/builtin/include/content/views/view_command_palette.hpp @@ -5,7 +5,9 @@ #include #include +#include #include +#include namespace hex::plugin::builtin { diff --git a/plugins/builtin/source/content/background_services.cpp b/plugins/builtin/source/content/background_services.cpp index 96148643a..6e6ebe5b7 100644 --- a/plugins/builtin/source/content/background_services.cpp +++ b/plugins/builtin/source/content/background_services.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/plugins/builtin/source/content/command_line_interface.cpp b/plugins/builtin/source/content/command_line_interface.cpp index e4b81d4c5..2426776d5 100644 --- a/plugins/builtin/source/content/command_line_interface.cpp +++ b/plugins/builtin/source/content/command_line_interface.cpp @@ -1,7 +1,8 @@ #include #include -#include +#include +#include #include #include #include diff --git a/plugins/builtin/source/content/command_palette_commands.cpp b/plugins/builtin/source/content/command_palette_commands.cpp index b5ca1b5e4..6d0644585 100644 --- a/plugins/builtin/source/content/command_palette_commands.cpp +++ b/plugins/builtin/source/content/command_palette_commands.cpp @@ -1,8 +1,7 @@ #include -#include +#include #include -#include #include diff --git a/plugins/builtin/source/content/communication_interface.cpp b/plugins/builtin/source/content/communication_interface.cpp index f4849741f..e765fb0e0 100644 --- a/plugins/builtin/source/content/communication_interface.cpp +++ b/plugins/builtin/source/content/communication_interface.cpp @@ -1,3 +1,4 @@ +#include #include #include diff --git a/plugins/builtin/source/content/data_inspector.cpp b/plugins/builtin/source/content/data_inspector.cpp index 9f8edb2d9..e158bcecd 100644 --- a/plugins/builtin/source/content/data_inspector.cpp +++ b/plugins/builtin/source/content/data_inspector.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include #include diff --git a/plugins/builtin/source/content/data_processor_nodes/basic_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/basic_nodes.cpp index 772b8a270..2a5f793b5 100644 --- a/plugins/builtin/source/content/data_processor_nodes/basic_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/basic_nodes.cpp @@ -2,11 +2,10 @@ #include #include #include +#include #include #include -#include - #include #include diff --git a/plugins/builtin/source/content/data_processor_nodes/decode_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/decode_nodes.cpp index b1b7d228f..7a099dc28 100644 --- a/plugins/builtin/source/content/data_processor_nodes/decode_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/decode_nodes.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include diff --git a/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp index ecd3d9bb4..30799b9c4 100644 --- a/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/plugins/builtin/source/content/data_processor_nodes/visual_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/visual_nodes.cpp index 1858597b5..6f597eb1e 100644 --- a/plugins/builtin/source/content/data_processor_nodes/visual_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/visual_nodes.cpp @@ -1,9 +1,12 @@ -#include -#include -#include #include + +#include + #include +#include +#include + namespace hex::plugin::builtin { class NodeDisplayInteger : public dp::Node { diff --git a/plugins/builtin/source/content/differing_byte_searcher.cpp b/plugins/builtin/source/content/differing_byte_searcher.cpp index 1ec978e63..39288abdc 100644 --- a/plugins/builtin/source/content/differing_byte_searcher.cpp +++ b/plugins/builtin/source/content/differing_byte_searcher.cpp @@ -1,5 +1,6 @@ #include -#include +#include +#include namespace hex::plugin::builtin { diff --git a/plugins/builtin/source/content/init_tasks.cpp b/plugins/builtin/source/content/init_tasks.cpp index cbbb5d3aa..a507d52a6 100644 --- a/plugins/builtin/source/content/init_tasks.cpp +++ b/plugins/builtin/source/content/init_tasks.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -14,9 +14,7 @@ #include #include -#include #include -#include namespace hex::fonts { bool setupFonts(); } diff --git a/plugins/builtin/source/content/main_menu_items.cpp b/plugins/builtin/source/content/main_menu_items.cpp index 78c3e6ac4..065320c81 100644 --- a/plugins/builtin/source/content/main_menu_items.cpp +++ b/plugins/builtin/source/content/main_menu_items.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -9,17 +10,17 @@ #include #include #include -#include +#include +#include #include #include -#include +#include #include #include #include -#include -#include + #include #include diff --git a/plugins/builtin/source/content/minimap_visualizers.cpp b/plugins/builtin/source/content/minimap_visualizers.cpp index a753a392f..de435b52b 100644 --- a/plugins/builtin/source/content/minimap_visualizers.cpp +++ b/plugins/builtin/source/content/minimap_visualizers.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include diff --git a/plugins/builtin/source/content/out_of_box_experience.cpp b/plugins/builtin/source/content/out_of_box_experience.cpp index 0481b6fad..612ae7dcd 100644 --- a/plugins/builtin/source/content/out_of_box_experience.cpp +++ b/plugins/builtin/source/content/out_of_box_experience.cpp @@ -1,23 +1,24 @@ -#include -#include -#include -#include - #include #include #include #include #include #include + #include #include +#include + +#include +#include +#include +#include #include #include #include #include -#include #include #include diff --git a/plugins/builtin/source/content/pl_builtin_functions.cpp b/plugins/builtin/source/content/pl_builtin_functions.cpp index 7a34ce1ec..31fd4ecc8 100644 --- a/plugins/builtin/source/content/pl_builtin_functions.cpp +++ b/plugins/builtin/source/content/pl_builtin_functions.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include #include diff --git a/plugins/builtin/source/content/pl_builtin_types.cpp b/plugins/builtin/source/content/pl_builtin_types.cpp index 16a4b89e8..790663a54 100644 --- a/plugins/builtin/source/content/pl_builtin_types.cpp +++ b/plugins/builtin/source/content/pl_builtin_types.cpp @@ -1,4 +1,3 @@ -#include #include #include diff --git a/plugins/builtin/source/content/pl_pragmas.cpp b/plugins/builtin/source/content/pl_pragmas.cpp index d75b49bd7..8ff9066b1 100644 --- a/plugins/builtin/source/content/pl_pragmas.cpp +++ b/plugins/builtin/source/content/pl_pragmas.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/plugins/builtin/source/content/pl_visualizers.cpp b/plugins/builtin/source/content/pl_visualizers.cpp index f6cbefc07..a6f3978c2 100644 --- a/plugins/builtin/source/content/pl_visualizers.cpp +++ b/plugins/builtin/source/content/pl_visualizers.cpp @@ -1,4 +1,3 @@ -#include #include #include diff --git a/plugins/builtin/source/content/project.cpp b/plugins/builtin/source/content/project.cpp index 1b15bf345..669133a38 100644 --- a/plugins/builtin/source/content/project.cpp +++ b/plugins/builtin/source/content/project.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include diff --git a/plugins/builtin/source/content/providers/disk_provider.cpp b/plugins/builtin/source/content/providers/disk_provider.cpp index 731e74927..764a96970 100644 --- a/plugins/builtin/source/content/providers/disk_provider.cpp +++ b/plugins/builtin/source/content/providers/disk_provider.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index d5e813008..1e782d0ad 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -2,7 +2,7 @@ #include "content/providers/memory_file_provider.hpp" #include -#include +#include #include #include #include diff --git a/plugins/builtin/source/content/providers/memory_file_provider.cpp b/plugins/builtin/source/content/providers/memory_file_provider.cpp index 063ef8a58..8d45cb480 100644 --- a/plugins/builtin/source/content/providers/memory_file_provider.cpp +++ b/plugins/builtin/source/content/providers/memory_file_provider.cpp @@ -4,7 +4,7 @@ #include -#include +#include #include #include #include diff --git a/plugins/builtin/source/content/providers/process_memory_provider.cpp b/plugins/builtin/source/content/providers/process_memory_provider.cpp index d706448b7..a735b926d 100644 --- a/plugins/builtin/source/content/providers/process_memory_provider.cpp +++ b/plugins/builtin/source/content/providers/process_memory_provider.cpp @@ -1,6 +1,7 @@ #if defined(OS_WINDOWS) || defined(OS_MACOS) || (defined(OS_LINUX) && !defined(OS_FREEBSD)) #include +#include #if defined(OS_WINDOWS) #include diff --git a/plugins/builtin/source/content/providers/view_provider.cpp b/plugins/builtin/source/content/providers/view_provider.cpp index 549034f3c..69deffe95 100644 --- a/plugins/builtin/source/content/providers/view_provider.cpp +++ b/plugins/builtin/source/content/providers/view_provider.cpp @@ -2,6 +2,7 @@ #include +#include #include #include #include diff --git a/plugins/builtin/source/content/recent.cpp b/plugins/builtin/source/content/recent.cpp index 0e3b89278..3f5a60eb4 100644 --- a/plugins/builtin/source/content/recent.cpp +++ b/plugins/builtin/source/content/recent.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index a8a0ff526..a1f2e66b8 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/plugins/builtin/source/content/tools/color_picker.cpp b/plugins/builtin/source/content/tools/color_picker.cpp index ef48bc370..ff1146147 100644 --- a/plugins/builtin/source/content/tools/color_picker.cpp +++ b/plugins/builtin/source/content/tools/color_picker.cpp @@ -1,4 +1,5 @@ #include +#include #include #include diff --git a/plugins/builtin/source/content/tools/demangler.cpp b/plugins/builtin/source/content/tools/demangler.cpp index 399a918ea..ef220a9db 100644 --- a/plugins/builtin/source/content/tools/demangler.cpp +++ b/plugins/builtin/source/content/tools/demangler.cpp @@ -1,11 +1,10 @@ -#include #include +#include #include -#include #include #include - +#include namespace hex::plugin::builtin { diff --git a/plugins/builtin/source/content/tools/http_requests.cpp b/plugins/builtin/source/content/tools/http_requests.cpp index 63e30b13e..8dde6b6a2 100644 --- a/plugins/builtin/source/content/tools/http_requests.cpp +++ b/plugins/builtin/source/content/tools/http_requests.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include diff --git a/plugins/builtin/source/content/tools/ieee_decoder.cpp b/plugins/builtin/source/content/tools/ieee_decoder.cpp index 1daa83eff..d325ddf5e 100644 --- a/plugins/builtin/source/content/tools/ieee_decoder.cpp +++ b/plugins/builtin/source/content/tools/ieee_decoder.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include diff --git a/plugins/builtin/source/content/tools/math_eval.cpp b/plugins/builtin/source/content/tools/math_eval.cpp index d31aedcae..1de142ee0 100644 --- a/plugins/builtin/source/content/tools/math_eval.cpp +++ b/plugins/builtin/source/content/tools/math_eval.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/plugins/builtin/source/content/tools/multiplication_decoder.cpp b/plugins/builtin/source/content/tools/multiplication_decoder.cpp index 7f4070350..c1331f4bd 100644 --- a/plugins/builtin/source/content/tools/multiplication_decoder.cpp +++ b/plugins/builtin/source/content/tools/multiplication_decoder.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include #include diff --git a/plugins/builtin/source/content/tools/regex_replacer.cpp b/plugins/builtin/source/content/tools/regex_replacer.cpp index 50c972e1d..081ac36c5 100644 --- a/plugins/builtin/source/content/tools/regex_replacer.cpp +++ b/plugins/builtin/source/content/tools/regex_replacer.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/plugins/builtin/source/content/tools/tcp_client_server.cpp b/plugins/builtin/source/content/tools/tcp_client_server.cpp index cfd50e83f..0a5094f3d 100644 --- a/plugins/builtin/source/content/tools/tcp_client_server.cpp +++ b/plugins/builtin/source/content/tools/tcp_client_server.cpp @@ -1,5 +1,9 @@ #include -#include +#include + +#include +#include + #include #include @@ -7,8 +11,6 @@ #include #include #include -#include -#include #include #include diff --git a/plugins/builtin/source/content/ui_items.cpp b/plugins/builtin/source/content/ui_items.cpp index 577b6273e..d5cc68058 100644 --- a/plugins/builtin/source/content/ui_items.cpp +++ b/plugins/builtin/source/content/ui_items.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/plugins/builtin/source/content/views/fullscreen/view_fullscreen_save_editor.cpp b/plugins/builtin/source/content/views/fullscreen/view_fullscreen_save_editor.cpp index 055dfd5dd..204f8edc6 100644 --- a/plugins/builtin/source/content/views/fullscreen/view_fullscreen_save_editor.cpp +++ b/plugins/builtin/source/content/views/fullscreen/view_fullscreen_save_editor.cpp @@ -1,10 +1,15 @@ #include -#include + #include + +#include #include +#include + #include #include -#include + +#include namespace hex::plugin::builtin { diff --git a/plugins/builtin/source/content/views/view_achievements.cpp b/plugins/builtin/source/content/views/view_achievements.cpp index 5a29b0906..4cc36e022 100644 --- a/plugins/builtin/source/content/views/view_achievements.cpp +++ b/plugins/builtin/source/content/views/view_achievements.cpp @@ -6,6 +6,7 @@ #include #include +#include #include diff --git a/plugins/builtin/source/content/views/view_command_palette.cpp b/plugins/builtin/source/content/views/view_command_palette.cpp index e243c342b..6aae2e851 100644 --- a/plugins/builtin/source/content/views/view_command_palette.cpp +++ b/plugins/builtin/source/content/views/view_command_palette.cpp @@ -6,6 +6,7 @@ #include #include "imstb_textedit.h" +#include namespace hex::plugin::builtin { diff --git a/plugins/builtin/source/content/views/view_data_inspector.cpp b/plugins/builtin/source/content/views/view_data_inspector.cpp index 5568b6e66..09bdccc33 100644 --- a/plugins/builtin/source/content/views/view_data_inspector.cpp +++ b/plugins/builtin/source/content/views/view_data_inspector.cpp @@ -7,10 +7,12 @@ #include #include -#include #include #include +#include +#include + #include #include diff --git a/plugins/builtin/source/content/views/view_find.cpp b/plugins/builtin/source/content/views/view_find.cpp index 0150dd6a3..8cdd7143f 100644 --- a/plugins/builtin/source/content/views/view_find.cpp +++ b/plugins/builtin/source/content/views/view_find.cpp @@ -1,16 +1,16 @@ #include "content/views/view_find.hpp" -#include #include +#include #include #include #include #include +#include #include -#include #include #include diff --git a/plugins/builtin/source/content/views/view_highlight_rules.cpp b/plugins/builtin/source/content/views/view_highlight_rules.cpp index 07b8c9e96..fed815fdc 100644 --- a/plugins/builtin/source/content/views/view_highlight_rules.cpp +++ b/plugins/builtin/source/content/views/view_highlight_rules.cpp @@ -5,6 +5,8 @@ #include #include +#include + #include #include diff --git a/plugins/builtin/source/content/views/view_pattern_data.cpp b/plugins/builtin/source/content/views/view_pattern_data.cpp index 30f57cf1c..69c1edac0 100644 --- a/plugins/builtin/source/content/views/view_pattern_data.cpp +++ b/plugins/builtin/source/content/views/view_pattern_data.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include diff --git a/plugins/builtin/source/content/views/view_provider_settings.cpp b/plugins/builtin/source/content/views/view_provider_settings.cpp index 6e79f2d37..dfc9a3e3d 100644 --- a/plugins/builtin/source/content/views/view_provider_settings.cpp +++ b/plugins/builtin/source/content/views/view_provider_settings.cpp @@ -1,8 +1,10 @@ #include "content/views/view_provider_settings.hpp" +#include #include #include #include +#include #include diff --git a/plugins/builtin/source/plugin_builtin.cpp b/plugins/builtin/source/plugin_builtin.cpp index cee30def9..b18b9f7e1 100644 --- a/plugins/builtin/source/plugin_builtin.cpp +++ b/plugins/builtin/source/plugin_builtin.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/plugins/builtin/tests/source/main.cpp b/plugins/builtin/tests/source/main.cpp index e13618cba..9a645124e 100644 --- a/plugins/builtin/tests/source/main.cpp +++ b/plugins/builtin/tests/source/main.cpp @@ -3,6 +3,7 @@ #include #include #include +#include using namespace hex; using namespace hex::plugin::builtin; @@ -10,22 +11,22 @@ using namespace hex::plugin::builtin; TEST_SEQUENCE("Providers/ReadWrite") { INIT_PLUGIN("Built-in"); - auto &pr = *ImHexApi::Provider::createProvider("hex.builtin.provider.mem_file", true); + auto &provider = *ImHexApi::Provider::createProvider("hex.builtin.provider.mem_file", true); - TEST_ASSERT(pr.getSize() == 0); - TEST_ASSERT(!pr.isDirty()); + TEST_ASSERT(provider.getSize() == 0); + TEST_ASSERT(!provider.isDirty()); - pr.resize(50); - TEST_ASSERT(pr.getSize() == 50); - TEST_ASSERT(pr.isDirty()); + provider.resize(50); + TEST_ASSERT(provider.getSize() == 50); + TEST_ASSERT(provider.isDirty()); char buf[] = "\x99\x99"; // temporary value that should be overwriten - pr.read(0, buf, 2); + provider.read(0, buf, 2); TEST_ASSERT(std::equal(buf, buf+2, "\x00\x00")); - pr.write(0, "\xFF\xFF", 2); + provider.write(0, "\xFF\xFF", 2); char buf2[] = "\x99\x99"; // temporary value that should be overwriten - pr.read(0, buf2, 2); + provider.read(0, buf2, 2); TEST_ASSERT(std::equal(buf2, buf2+2, "\xFF\xFF")); TEST_SUCCESS(); diff --git a/plugins/diffing/source/content/views/view_diff.cpp b/plugins/diffing/source/content/views/view_diff.cpp index 1b8a9b05c..a585b4c39 100644 --- a/plugins/diffing/source/content/views/view_diff.cpp +++ b/plugins/diffing/source/content/views/view_diff.cpp @@ -1,6 +1,6 @@ #include "content/views/view_diff.hpp" -#include +#include #include #include diff --git a/plugins/disassembler/source/content/pl_builtin_types.cpp b/plugins/disassembler/source/content/pl_builtin_types.cpp index 1ae24623a..a01c780d0 100644 --- a/plugins/disassembler/source/content/pl_builtin_types.cpp +++ b/plugins/disassembler/source/content/pl_builtin_types.cpp @@ -1,4 +1,3 @@ -#include #include #include diff --git a/plugins/disassembler/source/content/pl_visualizers/disassembler.cpp b/plugins/disassembler/source/content/pl_visualizers/disassembler.cpp index 970208bc4..4ba77618a 100644 --- a/plugins/disassembler/source/content/pl_visualizers/disassembler.cpp +++ b/plugins/disassembler/source/content/pl_visualizers/disassembler.cpp @@ -1,4 +1,9 @@ -#include +#include + +#include + +#include +#include #include #include @@ -6,10 +11,6 @@ #include #include -#include - -#include -#include namespace hex::plugin::disasm { diff --git a/plugins/disassembler/source/content/views/view_disassembler.cpp b/plugins/disassembler/source/content/views/view_disassembler.cpp index f3ceae792..623d895c7 100644 --- a/plugins/disassembler/source/content/views/view_disassembler.cpp +++ b/plugins/disassembler/source/content/views/view_disassembler.cpp @@ -1,5 +1,6 @@ -#include "content/views/view_disassembler.hpp" -#include "hex/api/content_registry.hpp" +#include +#include +#include #include #include diff --git a/plugins/fonts/include/font_settings.hpp b/plugins/fonts/include/font_settings.hpp index e6fcd7d7c..19949264a 100644 --- a/plugins/fonts/include/font_settings.hpp +++ b/plugins/fonts/include/font_settings.hpp @@ -1,6 +1,7 @@ #pragma once -#include +#include +#include #include namespace hex::fonts { diff --git a/plugins/fonts/include/fonts/fonts.hpp b/plugins/fonts/include/fonts/fonts.hpp index 2dff2152a..276bbb739 100644 --- a/plugins/fonts/include/fonts/fonts.hpp +++ b/plugins/fonts/include/fonts/fonts.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace hex::fonts { diff --git a/plugins/fonts/source/font_settings.cpp b/plugins/fonts/source/font_settings.cpp index 9ff0a38d1..1a7b6b581 100644 --- a/plugins/fonts/source/font_settings.cpp +++ b/plugins/fonts/source/font_settings.cpp @@ -6,13 +6,10 @@ #include #include -#include #include #include #include -#include "hex/api/imhex_api.hpp" - namespace hex::fonts { constexpr static auto PixelPerfectFontName = "Pixel-Perfect Default Font (Proggy Clean)"; constexpr static auto SmoothFontName = "Smooth Default Font (JetBrains Mono)"; diff --git a/plugins/fonts/source/fonts.cpp b/plugins/fonts/source/fonts.cpp index 23571742a..37a1806dd 100644 --- a/plugins/fonts/source/fonts.cpp +++ b/plugins/fonts/source/fonts.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/plugins/hashes/source/content/views/view_hashes.cpp b/plugins/hashes/source/content/views/view_hashes.cpp index 1476765ba..8ec5f7b2e 100644 --- a/plugins/hashes/source/content/views/view_hashes.cpp +++ b/plugins/hashes/source/content/views/view_hashes.cpp @@ -10,6 +10,8 @@ #include #include +#include + #include namespace hex::plugin::hashes { diff --git a/plugins/script_loader/support/c/source/script_api/v1/bookmarks.cpp b/plugins/script_loader/support/c/source/script_api/v1/bookmarks.cpp index ac5083a7e..2226f62c0 100644 --- a/plugins/script_loader/support/c/source/script_api/v1/bookmarks.cpp +++ b/plugins/script_loader/support/c/source/script_api/v1/bookmarks.cpp @@ -1,6 +1,6 @@ #include -#include +#include #define VERSION V1 diff --git a/plugins/script_loader/support/c/source/script_api/v1/logger.cpp b/plugins/script_loader/support/c/source/script_api/v1/logger.cpp index 8cd2dfb04..7e70cde2b 100644 --- a/plugins/script_loader/support/c/source/script_api/v1/logger.cpp +++ b/plugins/script_loader/support/c/source/script_api/v1/logger.cpp @@ -1,6 +1,5 @@ #include -#include #include #define VERSION V1 diff --git a/plugins/script_loader/support/c/source/script_api/v1/mem.cpp b/plugins/script_loader/support/c/source/script_api/v1/mem.cpp index c11403760..2e3a54cb3 100644 --- a/plugins/script_loader/support/c/source/script_api/v1/mem.cpp +++ b/plugins/script_loader/support/c/source/script_api/v1/mem.cpp @@ -1,7 +1,8 @@ #include #include +#include +#include -#include #include #define VERSION V1 diff --git a/plugins/script_loader/support/c/source/script_api/v1/ui.cpp b/plugins/script_loader/support/c/source/script_api/v1/ui.cpp index 56f6a8d59..f7cc4e170 100644 --- a/plugins/script_loader/support/c/source/script_api/v1/ui.cpp +++ b/plugins/script_loader/support/c/source/script_api/v1/ui.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include diff --git a/plugins/ui/CMakeLists.txt b/plugins/ui/CMakeLists.txt index 1bf2df5a1..ecebb3385 100644 --- a/plugins/ui/CMakeLists.txt +++ b/plugins/ui/CMakeLists.txt @@ -13,6 +13,7 @@ add_imhex_plugin( source/ui/visualizer_drawer.cpp source/ui/menu_items.cpp source/ui/pattern_value_editor.cpp + source/ui/widgets.cpp source/ui/text_editor/editor.cpp source/ui/text_editor/highlighter.cpp source/ui/text_editor/navigate.cpp diff --git a/plugins/ui/include/banners/banner_button.hpp b/plugins/ui/include/banners/banner_button.hpp index f37c039d4..48e93a4fb 100644 --- a/plugins/ui/include/banners/banner_button.hpp +++ b/plugins/ui/include/banners/banner_button.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include diff --git a/plugins/ui/include/popups/popup_notification.hpp b/plugins/ui/include/popups/popup_notification.hpp index faea7fe2f..2e1f3ce4a 100644 --- a/plugins/ui/include/popups/popup_notification.hpp +++ b/plugins/ui/include/popups/popup_notification.hpp @@ -2,8 +2,9 @@ #include +#include #include -#include +#include #include #include diff --git a/plugins/ui/include/popups/popup_question.hpp b/plugins/ui/include/popups/popup_question.hpp index f5795cbe9..050f7f882 100644 --- a/plugins/ui/include/popups/popup_question.hpp +++ b/plugins/ui/include/popups/popup_question.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include diff --git a/plugins/ui/include/popups/popup_text_input.hpp b/plugins/ui/include/popups/popup_text_input.hpp index d7c103921..7a1263028 100644 --- a/plugins/ui/include/popups/popup_text_input.hpp +++ b/plugins/ui/include/popups/popup_text_input.hpp @@ -2,7 +2,7 @@ #include -#include +#include #include #include diff --git a/plugins/ui/include/ui/hex_editor.hpp b/plugins/ui/include/ui/hex_editor.hpp index 7df562629..eb35e6824 100644 --- a/plugins/ui/include/ui/hex_editor.hpp +++ b/plugins/ui/include/ui/hex_editor.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include #include diff --git a/plugins/ui/include/ui/widgets.hpp b/plugins/ui/include/ui/widgets.hpp index 8ceea72ea..fcc6aef2a 100644 --- a/plugins/ui/include/ui/widgets.hpp +++ b/plugins/ui/include/ui/widgets.hpp @@ -1,7 +1,6 @@ #pragma once -#include -#include +#include namespace pl::ptrn { class Pattern; } namespace hex::prv { class Provider; } @@ -15,53 +14,6 @@ namespace hex::ui { Region }; - inline void regionSelectionPicker(Region *region, prv::Provider *provider, RegionType *type, bool showHeader = true, bool firstEntry = false) { - ImGui::BeginGroup(); - if (showHeader) - ImGuiExt::Header("hex.ui.common.range"_lang, firstEntry); - - if (ImGui::RadioButton("hex.ui.common.range.entire_data"_lang, *type == RegionType::EntireData)) - *type = RegionType::EntireData; - if (ImGui::RadioButton("hex.ui.common.range.selection"_lang, *type == RegionType::Selection)) - *type = RegionType::Selection; - if (ImGui::RadioButton("hex.ui.common.region"_lang, *type == RegionType::Region)) - *type = RegionType::Region; - - switch (*type) { - case RegionType::EntireData: - *region = { provider->getBaseAddress(), provider->getActualSize() }; - break; - case RegionType::Selection: - *region = ImHexApi::HexEditor::getSelection().value_or( - ImHexApi::HexEditor::ProviderRegion { - { 0, 1 }, - provider } - ).getRegion(); - break; - case RegionType::Region: - ImGui::SameLine(); - - const auto width = ImGui::GetContentRegionAvail().x / 2 - ImGui::CalcTextSize(" - ").x / 2; - u64 start = region->getStartAddress(), end = region->getEndAddress(); - - if (end < start) - end = start; - - ImGui::PushItemWidth(width); - ImGuiExt::InputHexadecimal("##start", &start); - ImGui::PopItemWidth(); - ImGui::SameLine(0, 0); - ImGui::TextUnformatted(" - "); - ImGui::SameLine(0, 0); - ImGui::PushItemWidth(width); - ImGuiExt::InputHexadecimal("##end", &end); - ImGui::PopItemWidth(); - - *region = { start, (end - start) + 1 }; - break; - } - - ImGui::EndGroup(); - } + void regionSelectionPicker(Region *region, prv::Provider *provider, RegionType *type, bool showHeader = true, bool firstEntry = false); } \ No newline at end of file diff --git a/plugins/ui/source/ui/hex_editor.cpp b/plugins/ui/source/ui/hex_editor.cpp index 8bfaf4b02..1784254b4 100644 --- a/plugins/ui/source/ui/hex_editor.cpp +++ b/plugins/ui/source/ui/hex_editor.cpp @@ -14,6 +14,8 @@ #include #include +#include + namespace hex::ui { /* Data Visualizer */ diff --git a/plugins/ui/source/ui/pattern_drawer.cpp b/plugins/ui/source/ui/pattern_drawer.cpp index 14f3a84c6..ee790773e 100644 --- a/plugins/ui/source/ui/pattern_drawer.cpp +++ b/plugins/ui/source/ui/pattern_drawer.cpp @@ -20,12 +20,12 @@ #include -#include +#include #include #include #include -#include +#include #include #include diff --git a/plugins/ui/source/ui/widgets.cpp b/plugins/ui/source/ui/widgets.cpp new file mode 100644 index 000000000..cc01a77bf --- /dev/null +++ b/plugins/ui/source/ui/widgets.cpp @@ -0,0 +1,59 @@ +#include + +#include +#include + +#include + +namespace hex::ui { + + void regionSelectionPicker(Region *region, prv::Provider *provider, RegionType *type, bool showHeader, bool firstEntry) { + ImGui::BeginGroup(); + if (showHeader) + ImGuiExt::Header("hex.ui.common.range"_lang, firstEntry); + + if (ImGui::RadioButton("hex.ui.common.range.entire_data"_lang, *type == RegionType::EntireData)) + *type = RegionType::EntireData; + if (ImGui::RadioButton("hex.ui.common.range.selection"_lang, *type == RegionType::Selection)) + *type = RegionType::Selection; + if (ImGui::RadioButton("hex.ui.common.region"_lang, *type == RegionType::Region)) + *type = RegionType::Region; + + switch (*type) { + case RegionType::EntireData: + *region = { provider->getBaseAddress(), provider->getActualSize() }; + break; + case RegionType::Selection: + *region = ImHexApi::HexEditor::getSelection().value_or( + ImHexApi::HexEditor::ProviderRegion { + { 0, 1 }, + provider } + ).getRegion(); + break; + case RegionType::Region: + ImGui::SameLine(); + + const auto width = ImGui::GetContentRegionAvail().x / 2 - ImGui::CalcTextSize(" - ").x / 2; + u64 start = region->getStartAddress(), end = region->getEndAddress(); + + if (end < start) + end = start; + + ImGui::PushItemWidth(width); + ImGuiExt::InputHexadecimal("##start", &start); + ImGui::PopItemWidth(); + ImGui::SameLine(0, 0); + ImGui::TextUnformatted(" - "); + ImGui::SameLine(0, 0); + ImGui::PushItemWidth(width); + ImGuiExt::InputHexadecimal("##end", &end); + ImGui::PopItemWidth(); + + *region = { start, (end - start) + 1 }; + break; + } + + ImGui::EndGroup(); + } + +} \ No newline at end of file diff --git a/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp b/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp index 6b03b5780..96c79cf4d 100644 --- a/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/3d_model.cpp @@ -1,6 +1,9 @@ -#include -#include +#include +#include +#include +#include +#include #include #include @@ -11,15 +14,12 @@ #include #include +#include #include - -#include -#include -#include +#include #include -#include -#include + namespace hex::plugin::visualizers { diff --git a/plugins/visualizers/source/content/pl_visualizers/coordinates.cpp b/plugins/visualizers/source/content/pl_visualizers/coordinates.cpp index 72dba299c..e175d6a70 100644 --- a/plugins/visualizers/source/content/pl_visualizers/coordinates.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/coordinates.cpp @@ -1,14 +1,15 @@ -#include - #include -#include #include #include #include -#include +#include + +#include #include + +#include #include namespace hex::plugin::visualizers { diff --git a/plugins/visualizers/source/content/pl_visualizers/digital_signal.cpp b/plugins/visualizers/source/content/pl_visualizers/digital_signal.cpp index 92079775f..c8110d386 100644 --- a/plugins/visualizers/source/content/pl_visualizers/digital_signal.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/digital_signal.cpp @@ -1,11 +1,11 @@ -#include - #include +#include + #include #include - #include + #include namespace hex::plugin::visualizers { diff --git a/plugins/visualizers/source/content/pl_visualizers/image.cpp b/plugins/visualizers/source/content/pl_visualizers/image.cpp index 4ef1a0a8e..c3204a416 100644 --- a/plugins/visualizers/source/content/pl_visualizers/image.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/image.cpp @@ -1,10 +1,9 @@ -#include - #include -#include +#include #include +#include #include namespace hex::plugin::visualizers { diff --git a/plugins/visualizers/source/content/pl_visualizers/sound.cpp b/plugins/visualizers/source/content/pl_visualizers/sound.cpp index b73b368bb..cd6f1be5d 100644 --- a/plugins/visualizers/source/content/pl_visualizers/sound.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/sound.cpp @@ -1,14 +1,15 @@ -#include - #include #include #include #include #include + #include #include +#include +#include namespace hex::plugin::visualizers { diff --git a/plugins/visualizers/source/content/pl_visualizers/timestamp.cpp b/plugins/visualizers/source/content/pl_visualizers/timestamp.cpp index c0286eedd..06cf7f3f2 100644 --- a/plugins/visualizers/source/content/pl_visualizers/timestamp.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/timestamp.cpp @@ -2,13 +2,12 @@ #include -#include +#include #include -#include - #include +#include #include #include diff --git a/plugins/yara_rules/source/content/views/view_yara.cpp b/plugins/yara_rules/source/content/views/view_yara.cpp index 44cfeef81..dc3d43de8 100644 --- a/plugins/yara_rules/source/content/views/view_yara.cpp +++ b/plugins/yara_rules/source/content/views/view_yara.cpp @@ -1,5 +1,6 @@ #include "content/views/view_yara.hpp" +#include #include #include