From 7d27f0aa44bbc9735cdfa662c9e6d318c920c8fc Mon Sep 17 00:00:00 2001 From: vooku Date: Sat, 28 Mar 2020 20:26:49 +0100 Subject: [PATCH] Display show name part of #38 --- skinny/src/Gui.cpp | 9 ++++++++- skinny/src/Gui.h | 1 + skinny/src/main.cpp | 1 + skinny/src/ofApp.cpp | 6 +++++- skinny/src/ofApp.h | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/skinny/src/Gui.cpp b/skinny/src/Gui.cpp index 80a82d2..8380844 100755 --- a/skinny/src/Gui.cpp +++ b/skinny/src/Gui.cpp @@ -1,6 +1,8 @@ #include "Gui.h" #include "Status.h" +#include + namespace skinny { const std::string Gui::Btn::NEXT = "Next scene"; @@ -121,6 +123,10 @@ void Gui::update() if (!show_) return; + if (!configName_.empty()) { + ofSetWindowTitle(configName_); + } + masterAlphaInput_->setLabel(std::to_string(static_cast(show_->getAlpha() * 127))); const auto& layers = show_->getCurrentScene()->getLayers(); @@ -140,7 +146,6 @@ void Gui::update() showDescription_.effects_[i].param = show_->effects_[i]->param_; } } - } void Gui::setShow(std::shared_ptr show) @@ -209,6 +214,7 @@ void Gui::onControlButton(ofxDatGuiButtonEvent e) displayMessage("Cannot save config file to " + path, 1000); } else { configPath_ = path; + configName_ = std::filesystem::path(configPath_).filename().string(); displayMessage("Saved!", 1000); } }; @@ -226,6 +232,7 @@ void Gui::onControlButton(ofxDatGuiButtonEvent e) ofxXmlSettings config; if (config.loadFile(openFileResult.filePath) && showDescription_.fromXml(config)) { configPath_ = openFileResult.filePath; + configName_ = std::filesystem::path(configPath_).filename().string(); } else { ofLog(OF_LOG_WARNING, "Cannot load config file %s, creating default scene instead.", openFileResult.fileName.c_str()); diff --git a/skinny/src/Gui.h b/skinny/src/Gui.h index a0fedbf..db30dfd 100755 --- a/skinny/src/Gui.h +++ b/skinny/src/Gui.h @@ -127,6 +127,7 @@ class Gui { ShowDescription& showDescription_; std::string configPath_; + std::string configName_; struct Message { std::string msg; diff --git a/skinny/src/main.cpp b/skinny/src/main.cpp index 0958157..4c0f81f 100755 --- a/skinny/src/main.cpp +++ b/skinny/src/main.cpp @@ -20,6 +20,7 @@ int main(int argc, char *argv[]) { shared_ptr mainApp(new skinny::ofApp(args.get())); mainApp->setupGui(); ofAddListener(guiWindow->events().draw, mainApp.get(), &skinny::ofApp::drawGui); + ofAddListener(guiWindow->events().update, mainApp.get(), &skinny::ofApp::updateGui); ofAddListener(guiWindow->events().exit, mainApp.get(), &skinny::ofApp::exitGui); ofAddListener(guiWindow->events().keyReleased, mainApp.get(), &skinny::ofApp::keyReleasedGui); diff --git a/skinny/src/ofApp.cpp b/skinny/src/ofApp.cpp index 62bdfba..f1cf819 100755 --- a/skinny/src/ofApp.cpp +++ b/skinny/src/ofApp.cpp @@ -74,13 +74,17 @@ void ofApp::update() } show_->update(); - gui_.update(); if (ofGetFrameNum() % 300 == 0) { ofLog(OF_LOG_NOTICE, "fps: %f", ofGetFrameRate()); } } +void ofApp::updateGui(ofEventArgs& args) +{ + gui_.update(); +} + //-------------------------------------------------------------- void ofApp::draw() { diff --git a/skinny/src/ofApp.h b/skinny/src/ofApp.h index b286fc2..b5bf94b 100755 --- a/skinny/src/ofApp.h +++ b/skinny/src/ofApp.h @@ -18,6 +18,7 @@ class ofApp : public ofBaseApp, public ofxMidiListener { void setup() override; void setupGui(); void update() override; + void updateGui(ofEventArgs& args); void draw() override; void drawGui(ofEventArgs& args); void exit() override;