Files
spice2x.github.io/src/spice2x/overlay/window.h
T
bicarus-dev 7301cdaa6c imgui: reorganize imgui library files to mirror what's in the imgui releases (#285)
## Link to GitHub Issue, if one exists
n/a

## Description of change
Functionally, no change.

Move ImGui library files around so that they mirror how they are
structured in imgui releases. This will make it easier to migrate to a
future version of ImGui.

Add a handful of static asserts to check that we have the necessary
features enabled / disabled in imgui header.

## Compiling
👍 

## Testing
Tested 32-bit overlay, 64-bit overlay, TDJ, and UFC overlays, and
spicecfg.

Interesting finds during ImGui testing (not part of this PR, but for
future reference when upgrading imgui version):
* Updating dx9 backend to the newest causes TDJ to stop rendering the
overlay completely (fine in UFC or any other game)
* Omitting `IMGUI_USE_BGRA_PACKED_COLOR` causes spicecfg software
renderer to use the wrong color (RGB format parsing error probably)
* At some point - v1.90? the `About` and `Licenses` buttons in spicecfg
stop responding after an upgrade, maybe our improper usage of MenuItem?
* Using the docking branch of ImGui is not required but we should just
stick to it for multi-viewport functionality which we may want to use
later.
2025-04-02 22:56:52 -07:00

53 lines
1.3 KiB
C++

#pragma once
#include <string>
#include "external/imgui/imgui.h"
#include "external/imgui/misc/cpp/imgui_stdlib.h"
#include "overlay.h"
namespace overlay {
class Window {
public:
virtual ~Window();
// an opportunity to calculate initial window position and size within the ImGui
// window context, since it may not be possible in the Window constructor
virtual void calculate_initial_window() {}
virtual void build_content() = 0;
virtual void update();
virtual void after_render() {};
void build();
void toggle_active();
void set_active(bool active);
bool get_active();
protected:
// state
SpiceOverlay *overlay;
bool active = false;
std::vector<Window*> children;
// settings
bool remove_window_padding = false;
bool draws_window = true;
ImGuiSizeCallback resize_callback = nullptr;
std::string title = "Title";
ImGuiWindowFlags flags = 0;
size_t toggle_button = ~0u;
bool toggle_button_state = false;
// init settings
ImVec2 init_pos = ImVec2(0, 0);
ImVec2 init_size = ImVec2(0, 0);
ImVec2 size_min = ImVec2(0, 0);
ImVec2 size_max = ImVec2(-1, -1);
float bg_alpha = 0.8f;
Window(SpiceOverlay *overlay);
};
}