Skip to content

Commit f3271a2

Browse files
committed
Added popup when exporting
1 parent 3f015c0 commit f3271a2

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/graphics/ui.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,34 @@ void render_and_update(FunctionState& state, ViewState& view_state, unsigned int
308308
view_state.wants_export = true;
309309
}
310310
}
311+
if (view_state.show_export_success) {
312+
ImGui::OpenPopup("Export Successful!");
313+
view_state.show_export_success = false;
314+
}
315+
316+
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
317+
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
318+
319+
if (ImGui::BeginPopupModal("Export Successful!", NULL, ImGuiWindowFlags_AlwaysAutoResize)) {
320+
ImGui::Text("Your plot has been saved.");
321+
ImGui::Spacing();
322+
ImGui::Separator();
323+
ImGui::Spacing();
324+
#ifndef __EMSCRIPTEN__
325+
ImGui::TextDisabled("Check the folder where your executable is located.");
326+
#else
327+
ImGui::TextDisabled("Check your browser's downloads folder.");
328+
#endif
329+
ImGui::Spacing();
330+
331+
ImGui::SetCursorPosX((ImGui::GetWindowSize().x - 120.0f) * 0.5f);
332+
if (UI::Button("Awesome", ImVec2(120, 0))) {
333+
ImGui::CloseCurrentPopup();
334+
}
335+
ImGui::SetItemDefaultFocus();
336+
337+
ImGui::EndPopup();
338+
}
311339

312340
ImGui::End();
313341
}

src/interactions/interactions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ typedef struct ViewState {
2323
bool wants_export = false;
2424
int export_height = 1080;
2525
int export_width = 1920;
26+
bool show_export_success = false;
2627
} ViewState;
2728

2829

src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ void export_to_png(AppContext* ctx, int target_width, int target_height, const c
156156
#else
157157
std::cout << "Successfully exported " << target_width << "x" << target_height << " plot to " << filename << std::endl;
158158
#endif
159+
ctx->view_state->show_export_success = true;
159160
}
160161

161162

0 commit comments

Comments
 (0)