3#include <imgui_includes.h>
74 MsgBox(
const std::string& title,
const std::string& message,
int buttons,
94 auto CalculateButtonLayout() -> void;
95 auto DrawIcon() -> void;
96 auto DrawMessage() -> void;
97 auto DrawButtons() -> void;
98 auto UpdateAnimation() -> void;
99 auto GetTypeIcon() const -> const
char*;
100 auto GetTypeColor() const -> ImVec4;
101 auto GetAnimationAlpha() const ->
float;
104 std::
string message_;
112 std::chrono::steady_clock::time_point animation_start_;
113 float animation_progress_;
117 ImVec2 content_size_;
120 const
char* custom_icon_;
122 bool open_requested_{
false};
125 static int next_id_counter_;
137 const std::string& title,
138 const std::string& message,
141 std::function<void(
ModalResult)> callback =
nullptr) -> std::shared_ptr<MsgBox>;
154 auto CleanupClosedBoxes() -> void;
156 std::vector<std::shared_ptr<MsgBox>> active_boxes_;
162auto ShowInfo(
const std::string& title,
const std::string& message,
163 std::function<
void(
ModalResult)> callback =
nullptr) -> std::shared_ptr<MsgBox>;
166auto ShowWarning(
const std::string& title,
const std::string& message,
167 std::function<
void(
ModalResult)> callback =
nullptr) -> std::shared_ptr<MsgBox>;
170auto ShowError(
const std::string& title,
const std::string& message,
171 std::function<
void(
ModalResult)> callback =
nullptr) -> std::shared_ptr<MsgBox>;
174auto ShowSuccess(
const std::string& title,
const std::string& message,
175 std::function<
void(
ModalResult)> callback =
nullptr) -> std::shared_ptr<MsgBox>;
178auto ShowQuestion(
const std::string& title,
const std::string& message,
179 std::function<
void(
ModalResult)> callback =
nullptr) -> std::shared_ptr<MsgBox>;
183 std::function<
void(
ModalResult)> callback =
nullptr) -> std::shared_ptr<MsgBox>;
187 std::function<
void(
ModalResult)> callback =
nullptr) -> std::shared_ptr<MsgBox>;
191 std::function<
void(
ModalResult)> callback =
nullptr) -> std::shared_ptr<MsgBox>;
Individual message box instance.
auto SetCustomIcon(const char *icon) -> void
Set custom icon (overrides type-based icon)
auto IsOpen() const -> bool
Check if the message box is open.
auto OpenPopup(std::function< void(ModalResult)> callback) -> void
Open the popup with callback.
MsgBox(const std::string &title, const std::string &message, int buttons, const MsgBoxConfig &config=MsgBoxConfig{})
Constructor with configuration.
auto Draw() -> bool
Draw the message box (returns true if still open)
Message box manager for handling multiple popups.
auto RenderAll() -> void
Render all active message boxes.
auto ShowMessageBox(const std::string &title, const std::string &message, int buttons=ModalResult::Ok, const MsgBoxConfig &config=MsgBoxConfig{}, std::function< void(ModalResult)> callback=nullptr) -> std::shared_ptr< MsgBox >
Create and show a message box.
static auto GetInstance() -> MsgBoxManager &
Get the singleton instance.
auto GetActiveCount() const -> size_t
Get count of active message boxes.
auto CloseAll() -> void
Close all message boxes.
ModalResult
Modal result flags for message box buttons.
auto ShowDeleteConfirmation(const std::string &title, const std::string &message, std::function< void(ModalResult)> callback) -> std::shared_ptr< MsgBox >
Show a delete confirmation dialog with Delete/Cancel buttons.
MessageType
Message box types that determine appearance and icon.
auto ShowInfo(const std::string &title, const std::string &message, std::function< void(ModalResult)> callback) -> std::shared_ptr< MsgBox >
Show an information message box.
auto ShowSaveConfirmation(const std::string &title, const std::string &message, std::function< void(ModalResult)> callback) -> std::shared_ptr< MsgBox >
Show a save confirmation dialog with Save/Don't Save/Cancel buttons.
auto ShowSuccess(const std::string &title, const std::string &message, std::function< void(ModalResult)> callback) -> std::shared_ptr< MsgBox >
Show a success message box.
auto ShowWarning(const std::string &title, const std::string &message, std::function< void(ModalResult)> callback) -> std::shared_ptr< MsgBox >
Show a warning message box.
auto ShowQuestion(const std::string &title, const std::string &message, std::function< void(ModalResult)> callback) -> std::shared_ptr< MsgBox >
Show a question message box with Yes/No buttons.
auto ShowConfirmation(const std::string &title, const std::string &message, std::function< void(ModalResult)> callback) -> std::shared_ptr< MsgBox >
Show a confirmation dialog with OK/Cancel buttons.
auto ShowError(const std::string &title, const std::string &message, std::function< void(ModalResult)> callback) -> std::shared_ptr< MsgBox >
Show an error message box.
AnimationState
Animation state for smooth transitions.
auto RenderMessageBoxes() -> void
Render all message boxes (call this in your main render loop)
Configuration for message box appearance and behavior.