Browse Source

Add image loading and unloading and events

master
Krisjanis Rijnieks 11 years ago
parent
commit
4e93dc8f3b
  1. 2
      src/MediaServer/MediaServer.cpp
  2. 2
      src/MediaServer/MediaServer.h
  3. 24
      src/SourcesEditor.cpp
  4. 2
      src/SourcesEditor.h

2
src/MediaServer/MediaServer.cpp

@ -37,6 +37,7 @@ namespace piMapper {
if (image.loadImage(path)) {
loadedImages.push_back(image);
loadedImagePaths.push_back(path); // Save also path
ofNotifyEvent(onImageLoaded, path, this);
}
}
@ -49,6 +50,7 @@ namespace piMapper {
loadedImagePaths.erase(loadedImagePaths.begin() + i);
loadedImages[i].clear();
loadedImages.erase(loadedImages.begin() + i);
ofNotifyEvent(onImageUnloaded, path, this);
break;
}
}

2
src/MediaServer/MediaServer.h

@ -36,6 +36,8 @@ class MediaServer {
ofEvent<string> onImageRemoved;
ofEvent<string> onVideoAdded;
ofEvent<string> onVideoRemoved;
ofEvent<string> onImageLoaded;
ofEvent<string> onImageUnloaded;
private:
// Directory Watchers

24
src/SourcesEditor.cpp

@ -27,6 +27,14 @@ namespace piMapper {
*/
addMediaServerListeners();
// Test media server onImageLoaded event
/*
if (mediaServer->getNumImages()) {
mediaServer->loadImage(mediaServer->getImagePaths()[0]);
}
*/
}
SourcesEditor::SourcesEditor(MediaServer* externalMediaServer) {
@ -171,6 +179,9 @@ namespace piMapper {
ofAddListener(mediaServer->onImageRemoved, this, &SourcesEditor::handleImageRemoved);
ofAddListener(mediaServer->onVideoAdded, this, &SourcesEditor::handleVideoAdded);
ofAddListener(mediaServer->onVideoRemoved, this, &SourcesEditor::handleVideoRemoved);
ofAddListener(mediaServer->onImageLoaded, this, &SourcesEditor::handleImageLoaded);
ofAddListener(mediaServer->onImageUnloaded, this, &SourcesEditor::handleImageUnloaded);
}
void SourcesEditor::removeMediaServerListeners() {
@ -185,6 +196,8 @@ namespace piMapper {
ofRemoveListener(mediaServer->onImageRemoved, this, &SourcesEditor::handleImageRemoved);
ofRemoveListener(mediaServer->onVideoAdded, this, &SourcesEditor::handleVideoAdded);
ofRemoveListener(mediaServer->onVideoRemoved, this, &SourcesEditor::handleVideoRemoved);
ofRemoveListener(mediaServer->onImageLoaded, this, &SourcesEditor::handleImageLoaded);
ofRemoveListener(mediaServer->onImageUnloaded, this, &SourcesEditor::handleImageUnloaded);
}
void SourcesEditor::guiEvent(string& imageName) {
@ -231,5 +244,16 @@ namespace piMapper {
void SourcesEditor::handleVideoRemoved(string& path) {
cout << "video removed: " << path << endl;
}
void SourcesEditor::handleImageLoaded(string& path) {
cout << "Image loaded: " << path << endl;
// Test image unload
// mediaServer->unloadImage(path);
}
void SourcesEditor::handleImageUnloaded(string& path) {
cout << "Image unloaded: " << path << endl;
}
}
}

2
src/SourcesEditor.h

@ -66,6 +66,8 @@ class SourcesEditor {
void handleImageRemoved(string& path);
void handleVideoAdded(string& path);
void handleVideoRemoved(string& path);
void handleImageLoaded(string& path);
void handleImageUnloaded(string& path);
};
}
}
Loading…
Cancel
Save