FuncDoodle
Loading...
Searching...
No Matches
PopupRegistry.h
Go to the documentation of this file.
1
19
20#pragma once
21
22#include <functional>
23#include <string_view>
24#include <unordered_map>
25
26#include "UI/Gui.h"
27
28namespace FuncDoodle {
36 struct PopupEntry {
41 double AnimationProgress = -1;
42
47 bool IsOpen = false;
48
53 bool SizeReady = false;
54
59 ImVec2 FullSize = {-1, -1};
60
65 ImVec2 Pos = {-1, -1};
66 };
67
77 public:
78 PopupRegistry() = default;
79 ~PopupRegistry() = default;
80
87 void Register(std::string_view id);
94 void Open(std::string_view id);
101 void Close(std::string_view id);
102
112 void Popup(std::string_view humanReadable, std::string_view id,
113 double dt, std::function<void()> popup);
114
126 void Modal(std::string_view humanReadable, std::string_view id,
127 double dt, std::function<void()> popup);
128
136 [[nodiscard]] bool IsOpen(std::string_view id) const;
137
145 bool* Get(std::string_view id);
150 void CloseAll();
157 void CloseAllExcept(std::string_view exception);
158
159 private:
160 std::unordered_map<std::string_view, PopupEntry> m_Popups;
161 };
162} // namespace FuncDoodle
ImGui/OpenGL/GLFW integration utilities and file dialog wrapper.
std::unordered_map< std::string_view, PopupEntry > m_Popups
Definition PopupRegistry.h:160
void Open(std::string_view id)
Marks a popup as open.
Definition PopupRegistry.cc:14
void CloseAllExcept(std::string_view exception)
Closes every popup except one.
Definition PopupRegistry.cc:150
void Popup(std::string_view humanReadable, std::string_view id, double dt, std::function< void()> popup)
Renders a popup using a lambda.
Definition PopupRegistry.cc:22
void Modal(std::string_view humanReadable, std::string_view id, double dt, std::function< void()> popup)
Renders a popup MODAL using a lambda.
Definition PopupRegistry.cc:77
bool * Get(std::string_view id)
Returns direct access to a popup open-state flag.
Definition PopupRegistry.cc:140
void Register(std::string_view id)
Registers a popup identifier in the registry.
Definition PopupRegistry.cc:9
void Close(std::string_view id)
Marks a popup as closed.
Definition PopupRegistry.cc:18
void CloseAll()
Closes every registered popup.
Definition PopupRegistry.cc:144
bool IsOpen(std::string_view id) const
Returns whether a popup is currently open.
Definition PopupRegistry.cc:132
The FuncDoodle C++ namespace.
Definition Common.h:12
Struct to store popup state like animation progress and if its open.
Definition PopupRegistry.h:36
bool SizeReady
Whether or not size is ready to get.
Definition PopupRegistry.h:53
ImVec2 FullSize
Full size of the popup, (-1, -1) if none.
Definition PopupRegistry.h:59
ImVec2 Pos
Position of popup, (-1, -1) if none.
Definition PopupRegistry.h:65
double AnimationProgress
Progress of opening/closing animations, -1 if none is present.
Definition PopupRegistry.h:41
bool IsOpen
Whether or not the popup is open.
Definition PopupRegistry.h:47