EchoMap
2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
Toggle main menu visibility
Loading...
Searching...
No Matches
ErrorModal.cpp
Go to the documentation of this file.
1
7
8
#include "
ErrorModal.hpp
"
9
10
#include <imgui.h>
11
12
#include "
../utility/Logger.hpp
"
13
14
namespace
echomap
15
{
16
17
ErrorModal::ErrorModal
(
18
const
std::string_view
message,
19
DismissedCallbackT&& dismissed_callback
20
) :
21
panel_name(
std
::string(
"Error!"
) + get_imgui_stable_name()),
22
dismissed_callback(
std
::move(dismissed_callback))
23
{
24
try
{
25
prefix = message;
26
}
catch
(
const
std::exception
&) {
27
LOG_ERROR
(
"Could not allocate memory to display modal on UI."
);
28
return
;
29
}
30
}
31
32
ErrorModal::ErrorModal
(
33
const
std::string_view
new_prefix,
34
const
std::runtime_error
& exception,
35
DismissedCallbackT&& dismissed_callback
36
) :
37
panel_name(
std
::string(
"Error!"
) + get_imgui_stable_name()),
38
dismissed_callback(
std
::move(dismissed_callback))
39
{
40
try
{
41
detail = exception.
what
();
42
prefix = new_prefix;
43
}
catch
(
const
std::exception
&) {
44
LOG_ERROR
(
"Could not allocate memory to display modal on UI."
);
45
return
;
46
}
47
}
48
49
void
ErrorModal::draw
() noexcept
50
{
51
ImGui::OpenPopup(
get_imgui_name
());
52
if
(ImGui::BeginPopupModal(
get_imgui_name
(),
nullptr
, ImGuiWindowFlags_AlwaysAutoResize)) {
53
ImGui::TextUnformatted(prefix.c_str());
54
ImGui::Separator();
55
56
if
(detail.has_value()) {
57
ImGui::TextWrapped(
"%s"
, detail->c_str());
58
ImGui::Separator();
59
}
60
61
if
(ImGui::Button(
"Dismiss"
, button_size)) {
62
ImGui::CloseCurrentPopup();
63
dismissed_callback();
64
}
65
66
ImGui::EndPopup();
67
}
68
}
69
70
const
char
*
ErrorModal::get_imgui_name
() const noexcept
71
{
72
return
panel_name.c_str();
73
}
74
75
const
char
* ErrorModal::get_imgui_stable_name() noexcept
76
{
77
return
"###ErrorModal"
;
78
}
79
80
}
// namespace echomap
ErrorModal.hpp
EchoMap modal error panel specification.
Logger.hpp
EchoMap portable logger specification.
LOG_ERROR
#define LOG_ERROR(msg)
Logs an unformatted error-level message using echomap::Logger::log.
Definition
Logger.hpp:172
std::string_view
echomap::ErrorModal::draw
void draw() noexcept override
Draw the panel to the active rendering context.
Definition
ErrorModal.cpp:49
echomap::ErrorModal::ErrorModal
ErrorModal(std::string_view message, DismissedCallbackT &&dismissed_callback)
Raise the modal given a simple unformatted message.
Definition
ErrorModal.cpp:17
echomap::ErrorModal::get_imgui_name
const char * get_imgui_name() const noexcept override
Retrieves the name of the IPanel for Dear ImGui API functions.
Definition
ErrorModal.cpp:70
std::exception
echomap
The main EchoMap outermost namespace for all non-exported symbols.
Definition
ActionController.hpp:20
std
STL namespace.
std::runtime_error
std::runtime_error::what
T what(T... args)
src
panels
ErrorModal.cpp
Generated by
1.17.0