Skip to content
Snippets Groups Projects

Resolves #343 GUI and Frame Refactor

Merged Nicolas Pope requested to merge feature/gui2 into master
3 files
+ 49
8
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -8,6 +8,7 @@
@@ -8,6 +8,7 @@
#include <nanogui/button.h>
#include <nanogui/button.h>
#include <nanogui/vscrollpanel.h>
#include <nanogui/vscrollpanel.h>
#include <nanogui/tabwidget.h>
#include <nanogui/tabwidget.h>
 
#include <nanogui/formhelper.h>
#include <loguru.hpp>
#include <loguru.hpp>
@@ -168,13 +169,38 @@ void AddSourceWindow::rebuild() {
@@ -168,13 +169,38 @@ void AddSourceWindow::rebuild() {
_addButton(s, tab_items_[2]);
_addButton(s, tab_items_[2]);
}
}
button = new Button(tab_items_[3], "Add Host", ENTYPO_ICON_PLUS);
auto *host_menu = new Widget(tab_items_[3]);
button->setIconPosition(Button::IconPosition::Left);
host_menu->setLayout(new BoxLayout(nanogui::Orientation::Horizontal, nanogui::Alignment::Maximum, 5,4));
button->setIconExtraScale(1.2);
 
button = new Button(host_menu, "Add", ENTYPO_ICON_PLUS);
button->setFontSize(18);
button->setFontSize(18);
button->setTooltip("Manually add a new connection URI");
button->setTooltip("Connect to a new machine");
button->setCallback([this]() {
button->setCallback([this]() {
 
FormHelper *fh = new FormHelper(screen());
 
auto *win = fh->addWindow(Vector2i(10,10), "Add Host");
 
win->center();
 
win->setTheme(dynamic_cast<ftl::gui2::Screen*>(win->screen())->getTheme("window_dark"));
 
//win->setWidth(200);
 
fh->addVariable<std::string>("URI", [this,win](const std::string &v) {
 
try {
 
ctrl_->add(v);
 
} catch (const ftl::exception &e) {
 
LOG(ERROR) << "Add failed: " << e.what();
 
}
 
win->dispose();
 
}, [this]() {
 
return "";
 
})->setFixedWidth(150);
 
win->screen()->performLayout();
 
delete fh;
 
});
 
button = new Button(host_menu, "Clear", ENTYPO_ICON_CYCLE);
 
button->setFontSize(18);
 
button->setTooltip("Clear host history");
 
button->setCallback([this]() {
 
ctrl_->feed()->clearHostHistory();
 
uptodate_.clear();
});
});
auto hostsrcs = ctrl_->getHosts();
auto hostsrcs = ctrl_->getHosts();
@@ -239,9 +265,7 @@ void AddSourceWindow::draw(NVGcontext *ctx) {
@@ -239,9 +265,7 @@ void AddSourceWindow::draw(NVGcontext *ctx) {
{
{
UNIQUE_LOCK(mutex_, lk);
UNIQUE_LOCK(mutex_, lk);
if (!uptodate_.test_and_set()) {
if (!uptodate_.test_and_set()) {
tabs_->requestFocus();
tabs_->requestFocus(); // Must ensure focus item not deleted
// Note the 1, first widget is the title bar buttons
//while(childCount() > 1) { removeChild(childCount()-1); }
rebuild();
rebuild();
screen()->performLayout();
screen()->performLayout();
}
}
Loading