Skip to content
Snippets Groups Projects
Commit 68b5318d authored by Iiro Rastas's avatar Iiro Rastas
Browse files

Fix record button popup toggling

The recording popup window now closes when one of the options is chosen.
When recording is active, it is stopped automatically when the recording button is pressed. The popup remains visible while the button is being pressed, though it is hidden once the button is no longer being pressed.
parent 0b0a353a
No related branches found
No related tags found
1 merge request!179Feature/219/gui record options
Pipeline #16544 passed
......@@ -516,6 +516,7 @@ void ftl::gui::Camera::toggleVideoRecording() {
src_->removeRawCallback(recorder_);
writer_->end();
fileout_->close();
recording_ = false;
} else {
char timestamp[18];
std::time_t t=std::time(NULL);
......@@ -527,6 +528,7 @@ void ftl::gui::Camera::toggleVideoRecording() {
src_->inject(Channel::Calibration, src_->parameters(), Channel::Left, src_->getCapabilities());
src_->inject(src_->getPose());
recording_ = true;
}
}
......
......@@ -44,7 +44,7 @@ class Camera {
void togglePause();
void isPaused();
const ftl::codecs::Channels &availableChannels();
const ftl::codecs::Channels &availableChannels() { return channels_; }
const GLTexture &captureFrame();
const GLTexture &getLeft() const { return texture1_; }
......
......@@ -2,7 +2,6 @@
#include <nanogui/layout.h>
#include <nanogui/label.h>
#include <nanogui/combobox.h>
#include <nanogui/button.h>
#include <nanogui/entypo.h>
#include <nanogui/formhelper.h>
......
......@@ -42,47 +42,47 @@ MediaPanel::MediaPanel(ftl::gui::Screen *screen) : nanogui::Window(screen, ""),
recordpopup->setLayout(new GroupLayout());
recordpopup->setTheme(screen->toolbuttheme);
recordpopup->setAnchorHeight(150);
auto itembutton = new Button(recordpopup, "Snapshot");
itembutton->setCallback([this](){
auto itembutton = new Button(recordpopup, "2D snapshot (.png)");
itembutton->setCallback([this,recordbutton]() {
screen_->activeCamera()->snapshot();
recordbutton->setPushed(false);
});
itembutton = new Button(recordpopup, "2D video recording");
itembutton->setFlags(Button::ToggleButton);
itembutton->setChangeCallback([this,recordbutton](bool state) {
itembutton = new Button(recordpopup, "Virtual camera recording (.ftl)");
itembutton->setCallback([this,recordbutton]() {
std::cout << "Toggling video recording in itembutton callback." << '\n';
screen_->activeCamera()->toggleVideoRecording();
if (state) {
recordbutton->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f));
} else {
recordbutton->setCallback([this,recordbutton]() {
std::cout << "Toggling video recording in recordbutton callback." << '\n';
screen_->activeCamera()->toggleVideoRecording();
recordbutton->setCallback([]() {});
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->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f));
recordbutton->setPushed(false);
});
itembutton = new Button(recordpopup, "Depth video recording");
itembutton->setFlags(Button::ToggleButton);
itembutton->setChangeCallback([this,recordbutton](bool state) {
itembutton = new Button(recordpopup, "3D scene recording (.ftl)");
itembutton->setCallback([this,recordbutton]() {
auto tag = screen_->activeCamera()->source()->get<std::string>("uri");
if (tag) {
auto tagvalue = tag.value();
auto configurables = ftl::config::findByTag(tagvalue);
if (configurables.size() > 0) {
ftl::Configurable *configurable = configurables[0];
if (state){
configurable->set("record", true);
recordbutton->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f));
} else {
recordbutton->setTextColor(nanogui::Color(1.0f,1.0f,1.0f,1.0f));
configurable->set("record", true);
recordbutton->setTextColor(nanogui::Color(1.0f,0.1f,0.1f,1.0f));
recordbutton->setCallback([this,recordbutton,configurable]() {
configurable->set("record", false);
}
recordbutton->setCallback([]() {});
recordbutton->setTextColor(nanogui::Color(1.0f,1.0f,1.0f,1.0f));
recordbutton->setPushed(false);
});
}
}
});
itembutton = new Button(recordpopup, "3D scene recording");
itembutton->setFlags(Button::ToggleButton);
itembutton->setChangeCallback([this,recordbutton](bool state) {
if (state) {
std::cout << "Starting 3D scene recording." << '\n';
} else {
std::cout << "Finishing 3D scene recording." << '\n';
}
recordbutton->setPushed(false);
});
itembutton = new Button(recordpopup, "Detailed recording options");
......
......@@ -6,7 +6,6 @@
#include <nanogui/window.h>
#include <nanogui/layout.h>
#include <nanogui/imageview.h>
#include <nanogui/combobox.h>
#include <nanogui/label.h>
#include <nanogui/toolbutton.h>
#include <nanogui/popupbutton.h>
......
......@@ -74,6 +74,14 @@ SourceWindow::SourceWindow(ftl::gui::Screen *screen)
_updateCameras(screen_->control()->getNet()->findAll<string>("list_streams"));
}
std::vector<ftl::gui::Camera*> SourceWindow::getCameras() {
auto cameras = std::vector<ftl::gui::Camera*>(cameras_.size());
for (const auto &kv : cameras_) {
cameras.push_back(kv.second);
}
return cameras;
}
void SourceWindow::_updateCameras(const vector<string> &netcams) {
for (auto s : netcams) {
if (cameras_.find(s) == cameras_.end()) {
......
......@@ -25,7 +25,7 @@ class SourceWindow : public nanogui::Window {
explicit SourceWindow(ftl::gui::Screen *screen);
~SourceWindow();
const std::vector<ftl::gui::Camera*> &getCameras();
std::vector<ftl::gui::Camera*> getCameras();
virtual void draw(NVGcontext *ctx);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment