### Problem description This PR addresses issue #2013 that described a cluttered Event Manager. This is a DX issue and should not impact the users whatsoever. ### Implementation description The changes revolve around three main points: 1. the Event Manager (`event_manager.hpp`) was split into four categories: GUI, Interaction, Lifecycle, and Provider, and two types: Events, and Requests. This results in the following files: - `events_gui.hpp` - `events_interaction.hpp` - `events_lifecycle.hpp` - `events_provider.hpp` - `requests_gui.hpp` - `requests_interaction.hpp` - `requests_lifecycle.hpp` - `requests_provider.hpp` 2. Every event and request now has its own piece of documentation, with a `@brief`, accompanied by a longer comment if needed, and gets its `@param`s described. 3. The old `event_manager.hpp` import was removed and replaced by the correct imports wherever needed, as to reduce spread of those files only to where they are truly useful. ### Additional things The commits have been split into (chrono-)logical steps: - `feat`: split the Event Manager, and replace the imports - `refactor`, `chore`: make various small changes to match the required structure - `docs`: add documentation for events and requests Hopefully, this will help to review the PR. *Note: Beware of very long rebuild times in between the commits, use them sparingly! The Actions will ensure this PR builds anyways* Closes #2013 --------- Signed-off-by: BioTheWolff <47079795+BioTheWolff@users.noreply.github.com> Co-authored-by: Nik <werwolv98@gmail.com>
121 lines
3.6 KiB
C++
121 lines
3.6 KiB
C++
#pragma once
|
|
|
|
#include <hex/api/event_manager.hpp>
|
|
|
|
/* Forward declarations */
|
|
struct GLFWwindow;
|
|
namespace hex { class View; }
|
|
|
|
/* GUI events definitions */
|
|
namespace hex {
|
|
|
|
/**
|
|
* @brief Signals a newly opened window
|
|
*
|
|
* This event is sent when the window has just been opened and docked by the Window manager.
|
|
*
|
|
* FIXME: In the event that a newly created window is already docked, this will not be sent.
|
|
*
|
|
* FIXME: This is currently only used for the introduction tutorial.
|
|
* If the event's only purpose is this, maybe rename it?
|
|
*
|
|
* @param view the new view reference
|
|
*/
|
|
EVENT_DEF(EventViewOpened, View*);
|
|
|
|
/**
|
|
* @brief Signals a change in the DPI scale.
|
|
*
|
|
* This event is called once at startup to signal native scale definition (by passing the same value twice).
|
|
* On Windows OS, this event can also be posted if the window DPI has been changed.
|
|
*
|
|
* @param oldScale the old scale
|
|
* @param newScale the current scale that's now in use
|
|
*/
|
|
EVENT_DEF(EventDPIChanged, float, float);
|
|
|
|
/**
|
|
* @brief Signals the focus of the ImHex main window.
|
|
*
|
|
* This is directly tied as a GLFW window focus callback, and will be called accordingly when GLFW detects
|
|
* a change in focus.
|
|
*
|
|
* @param isFocused true if the window is focused
|
|
*/
|
|
EVENT_DEF(EventWindowFocused, bool);
|
|
|
|
/**
|
|
* @brief Signals a window being closed.
|
|
*
|
|
* Allows reactive clean up of running tasks, and prevents ImHex from closing
|
|
* by displaying an exit confirmation popup.
|
|
*
|
|
* @param window The window reference
|
|
*/
|
|
EVENT_DEF(EventWindowClosing, GLFWwindow*);
|
|
|
|
/**
|
|
* @brief Informs that the main window is initialized
|
|
*
|
|
* On Windows OS, it is used to initialize system theme, if ImHex's theme is following it.
|
|
*
|
|
* FIXME: Change event name to reflect Theme detection, if it's only used for that purpose?
|
|
*/
|
|
EVENT_DEF(EventWindowInitialized);
|
|
|
|
/**
|
|
* @brief Informs that the main window is deinitializing
|
|
*
|
|
* Allows for lifecycle cleanup before ImHex shutdown.
|
|
*
|
|
* @param window The window reference
|
|
*/
|
|
EVENT_DEF(EventWindowDeinitializing, GLFWwindow*);
|
|
|
|
/**
|
|
* @brief Signals a theme change in the host OS
|
|
*
|
|
* Allows ImHex to react to OS theme changes dynamically during execution.
|
|
*/
|
|
EVENT_DEF(EventOSThemeChanged);
|
|
|
|
}
|
|
|
|
/* silent (no-logging) GUI events definitions */
|
|
namespace hex {
|
|
|
|
/**
|
|
* @brief Signals the start of a new ImGui frame
|
|
*/
|
|
EVENT_DEF_NO_LOG(EventFrameBegin);
|
|
|
|
/**
|
|
* @brief Signals the end of an ImGui frame
|
|
*/
|
|
EVENT_DEF_NO_LOG(EventFrameEnd);
|
|
|
|
/**
|
|
* @brief Windows OS: Sets the taskbar icon state
|
|
*
|
|
* This event is used on Windows OS to display progress through the taskbar icon (the famous "green loading bar"
|
|
* in the taskbar).
|
|
*
|
|
* @param progressState the progress state (converted from the TaskProgressState enum)
|
|
* @param progressType the type of progress (converted from the TaskProgressType enum)
|
|
* @param percentage actual progress percentage (expected from 0 to 100)
|
|
*
|
|
* @see hex::ImHexApi::System::TaskProgressState
|
|
* @see hex::ImHexApi::System::TaskProgressType
|
|
*/
|
|
EVENT_DEF_NO_LOG(EventSetTaskBarIconState, u32, u32, u32);
|
|
|
|
/**
|
|
* @brief Informs of an ImGui element being rendered
|
|
*
|
|
* @param elementId the element's ID
|
|
* @param boundingBox the bounding box (composed of 4 floats)
|
|
*/
|
|
EVENT_DEF_NO_LOG(EventImGuiElementRendered, ImGuiID, const std::array<float, 4>&);
|
|
|
|
}
|