Skip to content

Commit

Permalink
🤏 Quick export image with CTRL+E
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFouchy committed Nov 22, 2024
1 parent 42b0a2a commit f1869ab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
33 changes: 21 additions & 12 deletions src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "Commands/Command_OpenVideoExporter.h"
#include "Common/Path.h"
#include "Cool/DebugOptions/debug_options_windows.h"
#include "Cool/Exporter/ExporterU.h"
#include "Cool/ImGui/IcoMoonCodepoints.h"
#include "Cool/ImGui/ImGuiExtras.h"
#include "Cool/Input/MouseCoordinates.h"
Expand Down Expand Up @@ -369,21 +370,23 @@ void App::imgui_window_view()
});
}

void App::on_image_exported(std::filesystem::path const& exported_image_path)
{
auto folder_path = exported_image_path;
folder_path.replace_extension(); // Give project folder the same name as the image.
command_executor().execute(Command_PackageProjectInto{
.folder_path = folder_path,
});
}

void App::imgui_window_exporter()
{
_project.exporter.imgui_windows({
.polaroid = polaroid(),
.time = _project.clock.time(),
.delta_time = _project.clock.delta_time(),
.time_speed = _project.clock.time_speed().value(),
.on_image_exported = [&](std::filesystem::path const& exported_image_path) {
auto folder_path = exported_image_path;
folder_path.replace_extension(); // Give project folder the same name as the image.
command_executor().execute(Command_PackageProjectInto{
.folder_path = folder_path,
});
//
},
.polaroid = polaroid(),
.time = _project.clock.time(),
.delta_time = _project.clock.delta_time(),
.time_speed = _project.clock.time_speed().value(),
.on_image_exported = [&](std::filesystem::path const& exported_image_path) { on_image_exported(exported_image_path); },
.on_video_export_start = [&]() { on_time_reset(); },
.widgets_in_window_video_export_in_progress = [&]() {
ImGui::NewLine();
Expand Down Expand Up @@ -633,6 +636,12 @@ void App::check_inputs()
{
_wants_view_in_fullscreen = false;
}
if (ImGui::GetIO().KeyCtrl && ImGui::IsKeyReleased(ImGuiKey_E))
{
_project.exporter.export_image_immediately(_project.clock.time(), _project.clock.delta_time(), polaroid(), [&](std::filesystem::path const& exported_image_path) {

Check failure on line 641 in src/App.cpp

View workflow job for this annotation

GitHub Actions / Linux GCC Debug

ignoring return value of ‘bool Cool::Exporter::export_image_immediately(Cool::Time, Cool::Time, const Cool::Polaroid&, const std::function<void(const std::filesystem::__cxx11::path&)>&)’, declared with attribute ‘nodiscard’ [-Werror=unused-result]

Check failure on line 641 in src/App.cpp

View workflow job for this annotation

GitHub Actions / Linux GCC Release

ignoring return value of ‘bool Cool::Exporter::export_image_immediately(Cool::Time, Cool::Time, const Cool::Polaroid&, const std::function<void(const std::filesystem::__cxx11::path&)>&)’, declared with attribute ‘nodiscard’ [-Werror=unused-result]

Check failure on line 641 in src/App.cpp

View workflow job for this annotation

GitHub Actions / Windows MSVC Debug

the following warning is treated as an error

Check warning on line 641 in src/App.cpp

View workflow job for this annotation

GitHub Actions / Windows MSVC Debug

discarding return value of function with [[nodiscard]] attribute

Check failure on line 641 in src/App.cpp

View workflow job for this annotation

GitHub Actions / Windows MSVC Release

the following warning is treated as an error

Check warning on line 641 in src/App.cpp

View workflow job for this annotation

GitHub Actions / Windows MSVC Release

discarding return value of function with [[nodiscard]] attribute

Check failure on line 641 in src/App.cpp

View workflow job for this annotation

GitHub Actions / MacOS Clang Release

ignoring return value of function declared with 'nodiscard' attribute [-Werror,-Wunused-result]
on_image_exported(exported_image_path);
});
}
}

void App::check_inputs__history()
Expand Down
1 change: 1 addition & 0 deletions src/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class App : public Cool::IApp {
void on_time_changed();
void on_time_reset();
auto render_view() -> Cool::TextureView&;
void on_image_exported(std::filesystem::path const& exported_image_path);

void check_inputs();
void check_inputs__history();
Expand Down

0 comments on commit f1869ab

Please sign in to comment.