Skip to content

Commit

Permalink
🤏 [VideoExportOverwriteBehavior] Tweak text in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFouchy committed Nov 30, 2024
1 parent fdcb8b9 commit 16b6019
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 21 deletions.
22 changes: 11 additions & 11 deletions src/Cool/Exporter/ExporterGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,32 +84,32 @@ auto ExporterGui::user_accepted_our_frames_overwrite_behaviour() -> bool
auto const new_folder_name = File::find_available_name("", folder_path_for_video(), "");
if (user_settings().video_export_overwrite_behaviour == VideoExportOverwriteBehaviour::AskBeforeCreatingNewFolder)
{
if (boxer::show(fmt::format("There are already some frames in {}.\nDo you want to export in another folder? {}", folder_path_for_video(), new_folder_name).c_str(), "Creating a new export folder", boxer::Style::Warning, boxer::Buttons::OKCancel)
if (boxer::show(fmt::format("There are already some frames in {}.\nDo you want to export in this folder instead? {}", folder_path_for_video(), new_folder_name).c_str(), "Creating a new export folder", boxer::Style::Warning, boxer::Buttons::OKCancel)
!= boxer::Selection::OK)
{
return false;
}
}

_folder_path_for_video = new_folder_name;
break;
return true;
}
case VideoExportOverwriteBehaviour::AskBeforeOverwritingPreviousFrames:
{
if (boxer::show(fmt::format("You are about to overwrite the frames in {}.\nDo you want to continue?", folder_path_for_video()).c_str(), "Overwriting previous export", boxer::Style::Warning, boxer::Buttons::OKCancel)
!= boxer::Selection::OK)
{
return false;
}
break;
return boxer::show(fmt::format("You are about to overwrite the frames in {}.\nDo you want to continue?", folder_path_for_video()).c_str(), "Overwriting previous export", boxer::Style::Warning, boxer::Buttons::OKCancel)
== boxer::Selection::OK;
}
case VideoExportOverwriteBehaviour::AlwaysOverwritePreviousFrames:
{
break; // Nothing to do
// Nothing to do
return true;
}
default:
{
assert(false);
return true;
}
}

return true;
}

void ExporterGui::begin_video_export(std::optional<VideoExportProcess>& video_export_process, TimeSpeed time_speed, std::function<void()> const& on_video_export_start)
Expand Down
11 changes: 8 additions & 3 deletions src/Cool/Exporter/ExporterU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ void notification_after_export_failure()
});
}

void notification_after_export_interrupted()
void notification_after_export_interrupted(std::filesystem::path const& path)
{
ImGuiNotify::send({
.type = ImGuiNotify::Type::Warning,
.title = "Export Cancelled",
.type = ImGuiNotify::Type::Warning,
.title = "Export Cancelled",
.custom_imgui_content = [=]() {
ImGui::TextUnformatted(Cool::File::file_name(path).string().c_str());
if (ImGui::Button("Open folder"))
Cool::open(path);
},
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cool/Exporter/ExporterU.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ auto export_image(img::Size size, Time time, Time delta_time, Polaroid const& po

void notification_after_export_success(std::filesystem::path const& path, bool is_video);
void notification_after_export_failure();
void notification_after_export_interrupted();
void notification_after_export_interrupted(std::filesystem::path const& path);

} // namespace Cool::ExporterU
26 changes: 26 additions & 0 deletions src/Cool/Exporter/VideoExportOverwriteBehaviour.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "VideoExportOverwriteBehaviour.h"
#include "Cool/ImGui/ImGuiExtras.h"

namespace Cool {

auto imgui_widget(VideoExportOverwriteBehaviour& behaviour) -> bool
{
bool const b = ImGui::Combo(
"Overwrite mode",
reinterpret_cast<int*>(&behaviour), // NOLINT(*reinterpret-cast)
"Ask before creating a new folder\0"
"Ask before overwriting the previous frames\0"
"Always create a new folder\0"
"Always overwrite the previous frames\0"
"\0"
);
ImGuiExtras::help_marker(
R"STR(What happens when trying to export in a folder that already contains some frames.
You can either:
- Create a new empty folder and export your frames there
- Reuse the same folder, in which case the existing frames will get overwritten as new frames get exported)STR"
);
return b;
}

} // namespace Cool
5 changes: 1 addition & 4 deletions src/Cool/Exporter/VideoExportOverwriteBehaviour.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ enum class VideoExportOverwriteBehaviour {
AlwaysOverwritePreviousFrames,
};

inline auto imgui_widget(VideoExportOverwriteBehaviour& behaviour) -> bool
{
return ImGui::Combo("When export folder is not empty", reinterpret_cast<int*>(&behaviour), "Ask before creating a new folder\0Ask before overwriting the previous frames\0Always create a new folder\0Always overwrite the previous frames\0\0"); // NOLINT(*reinterpret-cast)
}
auto imgui_widget(VideoExportOverwriteBehaviour& behaviour) -> bool;

} // namespace Cool
2 changes: 1 addition & 1 deletion src/Cool/Exporter/VideoExportProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool VideoExportProcess::update(Polaroid const& polaroid)
}
if (_should_stop_asap)
{
ExporterU::notification_after_export_interrupted();
ExporterU::notification_after_export_interrupted(_folder_path);
return true; // The export has been cancelled
}
if (_nb_frames_which_finished_exporting.load() == _total_nb_of_frames_in_sequence)
Expand Down
2 changes: 1 addition & 1 deletion src/Cool/Time/ClockU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void imgui_timeline(Cool::Clock& clock, std::function<void()> const& extra_widge
on_time_reset();
}
ImGui::PopStyleVar();
ImGui::SetItemTooltip("%s", "Reset time to 0.");
ImGui::SetItemTooltip("%s", "Reset time to 0");

ImGuiExtras::join_buttons();

Expand Down

0 comments on commit 16b6019

Please sign in to comment.