Skip to content
Snippets Groups Projects
Commit 488f980e authored by Nicolas Pope's avatar Nicolas Pope
Browse files

WIP Add sources module

parent bd677e32
Branches
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
Pipeline #28122 passed
......@@ -34,6 +34,7 @@ add_gui_module("config")
add_gui_module("camera")
add_gui_module("camera3d")
add_gui_module("thumbnails")
add_gui_module("addsource")
add_gui_module("calibration")
list(APPEND GUI2SRC
......
......@@ -74,6 +74,7 @@ FTLGui::FTLGui(int argc, char **argv) {
loadModule<ConfigCtrl>("configwindow");
loadModule<Statistics>("statistics");
loadModule<Calibration>("calibration");
auto *adder = loadModule<AddCtrl>("adder");
for (int c = 1; c < argc; c++) {
std::string path(argv[c]);
......@@ -85,6 +86,10 @@ FTLGui::FTLGui(int argc, char **argv) {
LOG(ERROR) << "Could not add: " << path;
}
}
if (io_->feed()->listSources().size() == 0) {
adder->show();
}
}
FTLGui::~FTLGui() {
......
......@@ -6,3 +6,4 @@
#include "modules/themes.hpp"
#include "modules/statistics.hpp"
#include "modules/calibration.hpp"
#include "modules/addsource.hpp"
#include "addsource.hpp"
using ftl::gui2::AddCtrl;
void AddCtrl::init() {
button = screen->addButton(ENTYPO_ICON_PLUS);
button->setCallback([this](){
button->setPushed(false);
show();
});
button->setVisible(true);
}
void AddCtrl::show() {
if (screen->childIndex(window) == -1) {
window = new ftl::gui2::AddSourceWindow(screen, this);
}
window->requestFocus();
window->setVisible(true);
screen->performLayout();
}
ftl::Configurable *AddCtrl::addDevice(const std::string &uri) {
io->feed()->add(uri);
return nullptr;
}
AddCtrl::~AddCtrl() {
// remove window?
}
#pragma once
#include "../module.hpp"
#include "../screen.hpp"
#include "../views/addsource.hpp"
namespace ftl {
namespace gui2 {
/**
* Controller for adding sources etc.
*/
class AddCtrl : public Module {
public:
using Module::Module;
virtual ~AddCtrl();
virtual void init() override;
virtual void show();
ftl::Configurable *addDevice(const std::string &uri);
private:
nanogui::ToolButton *button;
ftl::gui2::AddSourceWindow *window = nullptr;
};
}
}
#include "addsource.hpp"
#include "../modules/addsource.hpp"
#include <nanogui/layout.h>
#include <nanogui/button.h>
#include <nanogui/combobox.h>
using ftl::gui2::AddSourceWindow;
AddSourceWindow::AddSourceWindow(nanogui::Widget* parent, AddCtrl *ctrl) :
nanogui::Window(parent, "Add Source"), ctrl_(ctrl) {
using namespace nanogui;
setFixedWidth(300);
setLayout(new GroupLayout(15, 6, 14, 10));
setPosition(Vector2i(parent->width()/2.0f - 100.0f, parent->height()/2.0f - 100.0f));
auto *type_select = new ComboBox(this, {
"Stereo Camera", "Pylon Camera", "Screen Capture", "Virtual Camera", "FTL File", "Network Stream"
});
type_select->setCallback([this, type_select](int ix) {
switch (ix) {
case 0 : ctrl_->addDevice("device:camera"); close(); break;
case 1 : ctrl_->addDevice("device:pylon"); close(); break;
case 2 : ctrl_->addDevice("device:screen"); close(); break;
case 3 : ctrl_->addDevice("device:render"); close(); break;
case 4 : break;
}
});
}
AddSourceWindow::~AddSourceWindow() {
}
void AddSourceWindow::close() {
setVisible(false);
dispose();
}
//void AddSourceWindow::draw(NVGcontext *ctx) {
//}
#pragma once
#include <nanogui/window.h>
namespace ftl {
namespace gui2 {
class AddCtrl;
/**
* Add source dialog
*/
class AddSourceWindow : public nanogui::Window {
public:
AddSourceWindow(nanogui::Widget *parent, AddCtrl *ctrl);
virtual ~AddSourceWindow();
//virtual void draw(NVGcontext *ctx);
private:
AddCtrl *ctrl_;
void close();
public:
// EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment