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
FileChooser.cpp
Go to the documentation of this file.
1
9
10
#if !defined(__EMSCRIPTEN__) || defined(__DOXYGEN__)
11
12
#include "
FileChooser.hpp
"
13
14
#include "
../../utility/Logger.hpp
"
15
16
namespace
echomap
17
{
18
19
FileChooser::FileChooser
(
20
EchoMap
*
const
app,
21
RaiseFileChooserNotification::SuccessCallbackT&& success_callback,
22
RaiseFileChooserNotification::CancelledCallbackT&& cancelled_callback
23
) :
24
file_combo(app),
25
panel_name(
std
::string(
"Select File to Open"
) + get_imgui_stable_name()),
26
app(app),
27
success_callback(
std
::move(success_callback)),
28
cancelled_callback(
std
::move(cancelled_callback))
29
{
30
}
31
32
void
FileChooser::draw
() noexcept
33
{
34
if
(!
std::exchange
(is_open,
true
))
35
ImGui::OpenPopup(
get_imgui_name
());
36
37
ImGui::SetNextWindowSize(default_modal_size, ImGuiCond_Appearing);
38
39
if
(ImGui::BeginPopupModal(
get_imgui_name
(),
nullptr
, ImGuiWindowFlags_AlwaysAutoResize)) {
40
ImGui::PushID(
get_imgui_name
());
41
42
if
(file_combo(chosen_path))
43
LOG_F_DEBUG
(
"Changed: {}"
, chosen_path.c_str());
44
45
ImGui::Spacing();
46
ImGui::Separator();
47
ImGui::Spacing();
48
49
if
(ImGui::Button(
"Cancel"
, button_size)) {
50
ImGui::CloseCurrentPopup();
51
cancelled_callback();
52
}
53
54
ImGui::SameLine();
55
56
if
(chosen_path.extension() == expected_extension) {
57
if
(ImGui::Button(
"OK"
, button_size))
58
success_callback(chosen_path);
59
}
else
{
60
ImGui::BeginDisabled();
61
ImGui::Button(
"OK"
, button_size);
62
ImGui::SetItemTooltip(
"To continue, select a JSON EchoMap project file."
);
63
ImGui::EndDisabled();
64
}
65
66
ImGui::PopID();
67
ImGui::EndPopup();
68
}
69
}
70
71
const
char
*
FileChooser::get_imgui_name
() const noexcept
72
{
73
return
panel_name.c_str();
74
}
75
76
void
FileChooser::change_active_project
(
77
const
Project
*
const
new_project
78
)
79
{
80
std::ignore = new_project;
81
}
82
83
const
char
* FileChooser::get_imgui_stable_name() noexcept
84
{
85
return
"###FileChooser"
;
86
}
87
88
}
// namespace echomap
89
90
#endif
// __EMSCRIPTEN__
FileChooser.hpp
FileChooser specification.
Logger.hpp
EchoMap portable logger specification.
LOG_F_DEBUG
#define LOG_F_DEBUG(msg,...)
Conditionally logs a formatted debug-level message using echomap::Logger::log_f.
Definition
Logger.hpp:94
echomap::EchoMap
The EchoMap maintains state for the application including WebGPU and Dear ImGui context,...
Definition
EchoMap.hpp:35
echomap::FileChooser::change_active_project
void change_active_project(const Project *new_project) override
Updates the active Project being described by the IPanel.
Definition
FileChooser.cpp:76
echomap::FileChooser::FileChooser
FileChooser(EchoMap *app, RaiseFileChooserNotification::SuccessCallbackT &&success_callback, RaiseFileChooserNotification::CancelledCallbackT &&cancelled_callback)
Create a new FileChooser modal for the given EchoMap instance.
Definition
FileChooser.cpp:19
echomap::FileChooser::draw
void draw() noexcept override
Draw the panel to the active rendering context.
Definition
FileChooser.cpp:32
echomap::FileChooser::get_imgui_name
const char * get_imgui_name() const noexcept override
Retrieves the name of the IPanel for Dear ImGui API functions.
Definition
FileChooser.cpp:71
echomap::Project
Definition
Project.hpp:26
std::exchange
T exchange(T... args)
echomap
The main EchoMap outermost namespace for all non-exported symbols.
Definition
ActionController.hpp:20
std
STL namespace.
src
panels
native
FileChooser.cpp
Generated by
1.17.0