Skip to content
Snippets Groups Projects

Recording enhancements

Merged Iiro Rastas requested to merge feature/recording-enhancements into master
3 files
+ 75
45
Compare changes
  • Side-by-side
  • Inline
Files
3
  • b74a4cea
    Fix recording window functionality · b74a4cea
    Iiro Rastas authored
    - The file extension is now chosen based on the chosen recording type.
    - The record button is disabled while the recording window is open,
    preventing the user from attempting to start multiple recordings
    simultaneously.
    - The color of the record button is now also changed to red when the
    recording is started from the recording window.
    - The available channels are now set as the recording window is opened.
@@ -37,69 +37,70 @@ MediaPanel::MediaPanel(ftl::gui::Screen *screen, ftl::gui::SourceWindow *sourceW
virtualCameraRecording_ = std::optional<ftl::gui::Camera*>();
sceneRecording_ = std::optional<ftl::Configurable*>();
auto recordbutton = new PopupButton(this, "", ENTYPO_ICON_CONTROLLER_RECORD);
recordbutton->setTooltip("Record");
recordbutton->setSide(Popup::Side::Right);
recordbutton->setChevronIcon(0);
auto recordpopup = recordbutton->popup();
recordbutton_ = new PopupButton(this, "", ENTYPO_ICON_CONTROLLER_RECORD);
recordbutton_->setTooltip("Record");
recordbutton_->setSide(Popup::Side::Right);
recordbutton_->setChevronIcon(0);
auto recordpopup = recordbutton_->popup();
recordpopup->setLayout(new GroupLayout());
recordpopup->setTheme(screen->toolbuttheme);
recordpopup->setAnchorHeight(150);
auto itembutton = new Button(recordpopup, "2D snapshot (.png)");
itembutton->setCallback([this,recordbutton]() {
itembutton->setCallback([this]() {
char timestamp[18];
std::time_t t=std::time(NULL);
std::strftime(timestamp, sizeof(timestamp), "%F-%H%M%S", std::localtime(&t));
screen_->activeCamera()->snapshot(std::string(timestamp) + ".png");
recordbutton->setPushed(false);
recordbutton_->setPushed(false);
});
itembutton = new Button(recordpopup, "Virtual camera recording (.ftl)");
itembutton->setCallback([this,recordbutton]() {
itembutton->setCallback([this]() {
char timestamp[18];
std::time_t t=std::time(NULL);
std::strftime(timestamp, sizeof(timestamp), "%F-%H%M%S", std::localtime(&t));
auto filename = std::string(timestamp) + ".ftl";
toggleVirtualCameraRecording(screen_->activeCamera(), filename);
recordbutton->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f));
recordbutton->setPushed(false);
startRecording2D(screen_->activeCamera(), filename);
recordbutton_->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f));
recordbutton_->setPushed(false);
});
itembutton = new Button(recordpopup, "3D scene snapshot (.ftl)");
itembutton->setCallback([this,recordbutton]() {
itembutton->setCallback([this]() {
char timestamp[18];
std::time_t t=std::time(NULL);
std::strftime(timestamp, sizeof(timestamp), "%F-%H%M%S", std::localtime(&t));
snapshot3D(screen_->activeCamera(), std::string(timestamp) + ".ftl");
recordbutton->setPushed(false);
recordbutton_->setPushed(false);
});
itembutton = new Button(recordpopup, "3D scene recording (.ftl)");
itembutton->setCallback([this,recordbutton]() {
itembutton->setCallback([this]() {
char timestamp[18];
std::time_t t=std::time(NULL);
std::strftime(timestamp, sizeof(timestamp), "%F-%H%M%S", std::localtime(&t));
startRecording3D(screen_->activeCamera(), std::string(timestamp) + ".ftl");
recordbutton->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f));
recordbutton->setPushed(false);
recordbutton_->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f));
recordbutton_->setPushed(false);
});
itembutton = new Button(recordpopup, "Detailed recording options");
itembutton->setCallback([this,sourceWindow,recordbutton] {
itembutton->setCallback([this,sourceWindow] {
auto record_window = new RecordWindow(screen_, screen_, sourceWindow->getCameras(), this);
record_window->setTheme(screen_->windowtheme);
recordbutton->setPushed(false);
recordbutton_->setPushed(false);
recordbutton_->setEnabled(false);
});
recordbutton->setCallback([this,recordbutton](){
recordbutton_->setCallback([this](){
if (virtualCameraRecording_) {
virtualCameraRecording_.value()->stopVideoRecording();
recordbutton->setTextColor(nanogui::Color(1.0f,1.0f,1.0f,1.0f));
recordbutton_->setTextColor(nanogui::Color(1.0f,1.0f,1.0f,1.0f));
// Prevents the popup from being opened, though it is shown while the button
// is being pressed.
recordbutton->setPushed(false);
recordbutton_->setPushed(false);
virtualCameraRecording_ = std::nullopt;
} else if (sceneRecording_) {
sceneRecording_.value()->set("record", false);
recordbutton->setTextColor(nanogui::Color(1.0f,1.0f,1.0f,1.0f));
recordbutton->setPushed(false);
recordbutton_->setTextColor(nanogui::Color(1.0f,1.0f,1.0f,1.0f));
recordbutton_->setPushed(false);
sceneRecording_ = std::nullopt;
}
});
@@ -294,9 +295,10 @@ void MediaPanel::cameraChanged() {
}
}
void MediaPanel::toggleVirtualCameraRecording(ftl::gui::Camera *camera, const std::string &filename) {
void MediaPanel::startRecording2D(ftl::gui::Camera *camera, const std::string &filename) {
camera->startVideoRecording(filename);
virtualCameraRecording_ = std::optional<ftl::gui::Camera*>(camera);
recordbutton_->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f));
}
void MediaPanel::snapshot3D(ftl::gui::Camera *camera, const std::string &filename) {
@@ -321,6 +323,11 @@ void MediaPanel::startRecording3D(ftl::gui::Camera *camera, const std::string &f
configurable->set("record-name", filename);
configurable->set("record", true);
sceneRecording_ = std::optional<ftl::Configurable*>(configurable);
recordbutton_->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f));
}
}
}
void MediaPanel::recordWindowClosed() {
recordbutton_->setEnabled(true);
}
\ No newline at end of file
Loading