Wt::WApplication *createApplication(const Wt::WEnvironment& env) { Wt::WApplication* app = new Wt::WApplication(env); if (app->appRoot().empty()) { std::cerr << "!!!!!!!!!!" << std::endl << "!! Warning: read the README.md file for hints on deployment," << " the approot looks suspect!" << std::endl << "!!!!!!!!!!" << std::endl; } // app->setLayoutDirection(Wt::RightToLeft); // Choice of theme: defaults to bootstrap3 but can be overridden using // a theme parameter (for testing) const std::string *themePtr = env.getParameter("theme"); std::string theme; if (!themePtr) theme = "bootstrap3"; else theme = *themePtr; if (theme == "bootstrap3") { Wt::WBootstrapTheme *bootstrapTheme = new Wt::WBootstrapTheme(app); bootstrapTheme->setVersion(Wt::WBootstrapTheme::Version3); bootstrapTheme->setResponsive(true); app->setTheme(bootstrapTheme); // load the default bootstrap3 (sub-)theme app->useStyleSheet("resources/themes/bootstrap/3/bootstrap-theme.min.css"); } else if (theme == "bootstrap2") { Wt::WBootstrapTheme *bootstrapTheme = new Wt::WBootstrapTheme(app); bootstrapTheme->setResponsive(true); app->setTheme(bootstrapTheme); } else app->setTheme(new Wt::WCssTheme(theme)); // load text bundles (for the tr() function) app->messageResourceBundle().use(app->appRoot() + "report"); app->messageResourceBundle().use(app->appRoot() + "text"); app->messageResourceBundle().use(app->appRoot() + "src"); Wt::WHBoxLayout *layout = new Wt::WHBoxLayout(app->root()); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(new WidgetGallery()); app->setTitle("Wt Widget Gallery"); app->useStyleSheet("style/everywidget.css"); app->useStyleSheet("style/dragdrop.css"); app->useStyleSheet("style/combostyle.css"); app->useStyleSheet("style/pygments.css"); app->useStyleSheet("style/layout.css"); app->useStyleSheet("style/filedrop.css"); return app; }
EarMobileUI::EarMobileUI(const Wt::WEnvironment& env) : Wt::WApplication(env) { setTitle("Ear Mobile interface"); this->log("notice")<<"Making mobile UI"; Wt::WBootstrapTheme *theme = new Wt::WBootstrapTheme(); /// theme->setResponsive(true); theme->setVersion(Wt::WBootstrapTheme::Version3); // this->removeMetaHeader(Wt::MetaHeaderType::MetaName,"viewport"); //this->addMetaHeader("viewport", // "width=device-width, height=device-height, initial-scale=2"); // this->addMetaHeader("viewport", // "width=1024"); setTheme(theme); Wt::WTemplate *html = new Wt::WTemplate(Wt::WString( "<div width='device-width' scale='4' >" "<div>" "${start-button} ${stop-button} ${play-time}" "</div>" "<div>" "${fragment-tree}" "</div>" "</div>" ),root()); this->log("notice")<<"Making button container"; //Wt::WContainerWidget *buttonContainer = new Wt::WContainerWidget(root()); //buttonContainer->setMaximumSize(500,Wt::WLength::Auto); //Wt::WHBoxLayout *buttonBox = new Wt::WHBoxLayout(); //buttonContainer->setLayout(buttonBox); playPauseButton = new Wt::WPushButton("Play from start"); //buttonBox->addWidget(playPauseButton); playPauseButton->clicked().connect(std::bind([=] () { this->log("notice")<<"interactnig to pause"; zmq_conn::interact(std::string("event:pause")); })); html->bindWidget("start-button",playPauseButton); Wt::WPushButton *stopButton = new Wt::WPushButton("Stop"); //buttonBox->addWidget(stopButton); html->bindWidget("stop-button",stopButton); stopButton->clicked().connect(std::bind([=] () { this->log("notice")<<"interactnig to stop"; zmq_conn::interact(std::string("event:stop")); })); stopButton->setMargin(5, Wt::Left); posText = new TimeWidget(); posText->setMargin(5, Wt::Left); html->bindWidget("play-time",posText); //buttonBox->addWidget(posText); // Wt::WContainerWidget *fragmentContainer = new Wt::WContainerWidget(root()); fragmentTree = new Wt::WTreeTable(); html->bindWidget("fragment-tree",fragmentTree); // fragmentTree->addColumn("",500); // fragmentTree->resize( // Wt::WLength(100,Wt::WLength::Unit::Percentage), //Width // Wt::WLength(80,Wt::WLength::Unit::Percentage)); //Heigth /* Wt::WTimer *inputtimer = new Wt::WTimer(); inputtimer->setInterval(2500); //For some reason, this actually segfaults (on a RPi) when it fires, before calling updateInputs. Calling updateInputs from any other place works, including the other timer. I'll try and find out the cause later, now it runs inputtimer->timeout().connect(std::bind([=] () { std::cout<< "updating inputs " <<std::endl; updateInputs(); })); inputtimer->start(); */ updateInputs(); Wt::WTimer *timer = new Wt::WTimer(); timer->setInterval(100); timer->timeout().connect(std::bind([=] () { Wt::Json::Object posj ; bool playing; Wt::Json::Object playingj; zmq::socket_t *socket = zmq_conn::connect(); posj = zmq_conn::interact(std::string("pos?"),socket); playingj = zmq_conn::interact(std::string("playing?"),socket); zmq_conn::disconnect(socket); Wt::Json::Value posjv = posj.get("pos"); const long long track_time = posjv; posText->setTime(track_time); mark_current_fragment(fragmentTree,track_time); playing = playingj.get("playing"); if (playing) { playPauseButton->setText("Pause"); } else { if(track_time > 0) { playPauseButton->setText("Continue"); } else { playPauseButton->setText("Play from start"); } } updateInputs(); })); timer->start(); }