21MapSourcesModal::MapSourcesModal(
25 panel_name(std::string(
"Upload External Files") + get_imgui_stable_name()),
33 if (project->observe_unloaded_signals().empty())
39 ImGui::SetNextWindowSize(default_modal_size, ImGuiCond_Appearing);
41 if (ImGui::BeginPopupModal(
43 ImGuiWindowFlags_AlwaysAutoResize
45 ImGui::PushID(
"UploadExternalModal");
50 auto unmapped_count = project->observe_unloaded_signals().size();
52 if (ImGui::BeginTable(
"##UploadTable", 5, table_flags)) {
53 ImGui::TableSetupColumn(
"##UploadButton", ImGuiTableColumnFlags_WidthFixed, button_size.x);
54 ImGui::TableSetupColumn(
"Indicated Path", ImGuiTableColumnFlags_WidthStretch);
55 ImGui::TableSetupColumn(
"Signal Name", ImGuiTableColumnFlags_WidthStretch);
56 ImGui::TableSetupColumn(
"Channel Number", ImGuiTableColumnFlags_WidthStretch);
57 ImGui::TableSetupColumn(
"Given Path", ImGuiTableColumnFlags_WidthStretch);
58 ImGui::TableHeadersRow();
60 for (
const auto& [external_path, mapping_info] : project->observe_unloaded_signals())
74 draw_buttons(unmapped_count == 0);
83 return panel_name.c_str();
86void MapSourcesModal::reshow() noexcept
95 std::ignore = new_project;
98const char* MapSourcesModal::get_imgui_stable_name() noexcept
100 return "###IndividualUploadModal";
103void MapSourcesModal::draw_preamble() const noexcept
106 "%s contains references to externally sourced signals. Browser security requires that each externally "
107 "sourced file is uploaded separately.",
108 project->get_imgui_name()
115 "Upload all missing files to complete the mapping, and press Continue.\n\nCancelling the operation "
116 "will abort the load and revert back to the previously loaded project, if applicable."
124void MapSourcesModal::draw_buttons(
125 const bool are_all_mapped
132 if (ImGui::Button(
"Cancel", button_size)) {
133 app->notify(CancelProjectLoadNotification(project->get_id()));
134 ImGui::CloseCurrentPopup();
140 if (are_all_mapped) {
141 if (ImGui::Button(
"Continue", button_size)) {
142 app->notify(CompleteProjectLoadNotification(project->get_id()));
143 ImGui::CloseCurrentPopup();
146 ImGui::BeginDisabled();
147 ImGui::Button(
"Continue", button_size);
148 ImGui::SetItemTooltip(
"To continue, provide mappings for all unloaded externally sourced signals.");
149 ImGui::EndDisabled();
153bool MapSourcesModal::draw_table_entry(
156 SignalFactoryRange
auto&& factories
159 ImGui::PushID(external_path.c_str());
160 ImGui::TableNextRow();
161 ImGui::TableNextColumn();
163 const auto& padding = ImGui::GetStyle().CellPadding;
164 ImGui::SetCursorPos({ImGui::GetCursorPosX() - padding.x, ImGui::GetCursorPosY() - padding.y});
165 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, upload_button_frame_padding);
167 if (ImGui::Button(
"Upload", ImVec2(button_size.x + 2 * padding.x, button_size.y)))
168 ActionController::register_vfs_mapping(project->get_id(), external_path);
170 ImGui::PopStyleVar();
172 ImGui::TableNextColumn();
173 ImGui::TextUnformatted(external_path.c_str());
175 bool is_first =
true;
176 bool is_mapped =
false;
178 for (
const auto signal_factory : factories | std::views::filter([](
auto&& ptr) {
182 ImGui::TableNextRow();
184 ImGui::TableSetColumnIndex(2);
186 const auto&
signal = signal_factory->observe_signal();
187 ImGui::PushID(
signal.get_imgui_name());
189 ImGui::TextUnformatted(
signal.get_imgui_name());
190 ImGui::TableNextColumn();
192 ImGui::TextUnformatted(formatted_channel_num.c_str());
193 ImGui::TableNextColumn();
196 const auto& given_path = vfs_path;
197 if (given_path.has_value()) {
198 ImGui::TextUnformatted(given_path->c_str());
201 ImGui::TextUnformatted(
"Not provided");
ActionController specification.
AllNotifications specification.
EchoMap class specification.
IndividualUploadModal specification.
PartialProject specification.
The EchoMap maintains state for the application including WebGPU and Dear ImGui context,...
void draw() noexcept override
Draw the panel to the active rendering context.
void change_active_project(const PartialProject *new_project) override
Do nothing.
const char * get_imgui_name() const noexcept override
Retrieves the name of the IPanel for Dear ImGui API functions.
A Project with semantics for expressing an incomplete set of owned Signal objects.
The main EchoMap outermost namespace for all non-exported symbols.