Skip to content

Commit

Permalink
Display show name
Browse files Browse the repository at this point in the history
part of #38
  • Loading branch information
vooku committed Mar 28, 2020
1 parent 70fcc16 commit 7d27f0a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion skinny/src/Gui.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "Gui.h"
#include "Status.h"

#include <filesystem>

namespace skinny {

const std::string Gui::Btn::NEXT = "Next scene";
Expand Down Expand Up @@ -121,6 +123,10 @@ void Gui::update()
if (!show_)
return;

if (!configName_.empty()) {
ofSetWindowTitle(configName_);
}

masterAlphaInput_->setLabel(std::to_string(static_cast<int>(show_->getAlpha() * 127)));

const auto& layers = show_->getCurrentScene()->getLayers();
Expand All @@ -140,7 +146,6 @@ void Gui::update()
showDescription_.effects_[i].param = show_->effects_[i]->param_;
}
}

}

void Gui::setShow(std::shared_ptr<Show> show)
Expand Down Expand Up @@ -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);
}
};
Expand All @@ -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());
Expand Down
1 change: 1 addition & 0 deletions skinny/src/Gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class Gui {
ShowDescription& showDescription_;

std::string configPath_;
std::string configName_;

struct Message {
std::string msg;
Expand Down
1 change: 1 addition & 0 deletions skinny/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ int main(int argc, char *argv[]) {
shared_ptr<skinny::ofApp> 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);

Expand Down
6 changes: 5 additions & 1 deletion skinny/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
1 change: 1 addition & 0 deletions skinny/src/ofApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7d27f0a

Please sign in to comment.