From 7c263994529ab3de95c3c72b7b15e5cabc5ed757 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Thu, 15 May 2014 16:28:21 +0200 Subject: [PATCH] Fix joints not redrawn on new surface selection while in projection editor --- src/ofxProjectionEditor.cpp | 12 ++++++++++++ src/ofxProjectionEditor.h | 1 + src/ofxSurfaceManager.cpp | 3 +++ 3 files changed, 16 insertions(+) diff --git a/src/ofxProjectionEditor.cpp b/src/ofxProjectionEditor.cpp index 23d76f0..75d7990 100644 --- a/src/ofxProjectionEditor.cpp +++ b/src/ofxProjectionEditor.cpp @@ -13,16 +13,19 @@ ofxProjectionEditor::~ofxProjectionEditor() surfaceManager = NULL; unregisterAppEvents(); unregisterMouseEvents(); + } void ofxProjectionEditor::registerAppEvents() { ofAddListener(ofEvents().update, this, &ofxProjectionEditor::update); + ofAddListener(ofEvents().messageEvent, this, &ofxProjectionEditor::gotMessage); } void ofxProjectionEditor::unregisterAppEvents() { ofRemoveListener(ofEvents().update, this, &ofxProjectionEditor::update); + ofRemoveListener(ofEvents().messageEvent, this, &ofxProjectionEditor::gotMessage); } void ofxProjectionEditor::registerMouseEvents() @@ -60,6 +63,15 @@ void ofxProjectionEditor::mouseDragged(ofMouseEventArgs &args) // } +void ofxProjectionEditor::gotMessage(ofMessage& msg) +{ + if (msg.message == "surfaceSelected") { + // refresh gui + clearJoints(); + createJoints(); + } +} + void ofxProjectionEditor::setSurfaceManager(ofxSurfaceManager *newSurfaceManager) { surfaceManager = newSurfaceManager; diff --git a/src/ofxProjectionEditor.h b/src/ofxProjectionEditor.h index ae72597..f4a806d 100644 --- a/src/ofxProjectionEditor.h +++ b/src/ofxProjectionEditor.h @@ -18,6 +18,7 @@ public: void update(ofEventArgs& args); void draw(); void mouseDragged(ofMouseEventArgs& args); + void gotMessage(ofMessage& msg); void setSurfaceManager(ofxSurfaceManager* newSurfaceManager); void clearJoints(); void createJoints(); diff --git a/src/ofxSurfaceManager.cpp b/src/ofxSurfaceManager.cpp index f01e532..d2db214 100644 --- a/src/ofxSurfaceManager.cpp +++ b/src/ofxSurfaceManager.cpp @@ -272,6 +272,9 @@ ofxBaseSurface* ofxSurfaceManager::selectSurface(int index) } selectedSurface = surfaces[index]; + + // notify that a new surface has been selected + ofSendMessage("surfaceSelected"); } ofxBaseSurface* ofxSurfaceManager::getSelectedSurface()