|
|
@ -28,9 +28,7 @@ void ofxSourcesEditor::unregisterAppEvents() |
|
|
|
|
|
|
|
void ofxSourcesEditor::setup(ofEventArgs& args) |
|
|
|
{ |
|
|
|
gui = new ofxUICanvas(); |
|
|
|
gui->disable(); |
|
|
|
gui->disableAppDrawCallback(); |
|
|
|
gui = new ofxRadioList(); |
|
|
|
|
|
|
|
// read directory contents
|
|
|
|
ofDirectory imgDir; |
|
|
@ -44,11 +42,15 @@ void ofxSourcesEditor::setup(ofEventArgs& args) |
|
|
|
vnames.push_back(imgDir.getName(i)); |
|
|
|
} |
|
|
|
|
|
|
|
gui->addLabel(defImgDir, OFX_UI_FONT_SMALL); |
|
|
|
ofxUIRadio *radio = gui->addRadio("images", vnames, OFX_UI_ORIENTATION_VERTICAL); |
|
|
|
radio->activateToggle("image0.png"); |
|
|
|
gui->setup("Images", vnames); |
|
|
|
ofAddListener(gui->radioSelectedEvent, this, &ofxSourcesEditor::guiEvent); |
|
|
|
|
|
|
|
|
|
|
|
ofAddListener(gui->newGUIEvent,this,&ofxSourcesEditor::guiEvent); |
|
|
|
//gui->addLabel(defImgDir, OFX_UI_FONT_SMALL);
|
|
|
|
//ofxUIRadio *radio = gui->addRadio("images", vnames, OFX_UI_ORIENTATION_VERTICAL);
|
|
|
|
//radio->activateToggle("image0.png");
|
|
|
|
|
|
|
|
//ofAddListener(gui->newGUIEvent,this,&ofxSourcesEditor::guiEvent);
|
|
|
|
} |
|
|
|
|
|
|
|
void ofxSourcesEditor::draw() |
|
|
@ -83,29 +85,14 @@ void ofxSourcesEditor::setSurfaceManager(ofxSurfaceManager *newSurfaceManager) |
|
|
|
|
|
|
|
void ofxSourcesEditor::selectImageSourceRadioButton(string name) |
|
|
|
{ |
|
|
|
vector<ofxUIWidget*> widgets = gui->getWidgets(); |
|
|
|
|
|
|
|
// find radio list item
|
|
|
|
ofxUIRadio* radio; |
|
|
|
for ( int i=0; i<widgets.size(); i++ ) { |
|
|
|
int widgetKind = widgets[i]->getKind(); |
|
|
|
if ( widgetKind == OFX_UI_WIDGET_RADIO ){ |
|
|
|
radio = (ofxUIRadio*)widgets[i]; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (name == "none") { |
|
|
|
ofxUIToggle* toggle = (ofxUIToggle*)radio->getActive(); |
|
|
|
if ( toggle != NULL ) { |
|
|
|
toggle->setValue(false); |
|
|
|
} |
|
|
|
gui->unselectAll(); |
|
|
|
return; |
|
|
|
} else { |
|
|
|
for ( int i=0; i<widgets.size(); i++ ) { |
|
|
|
string widgetName = widgets[i]->getName(); |
|
|
|
if ( name == widgetName ) { |
|
|
|
radio->activateToggle(name); |
|
|
|
int i; |
|
|
|
for (i = 0; i < gui->size(); i++) { |
|
|
|
if (gui->getItemName(i) == name) { |
|
|
|
gui->selectItem(i); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -126,24 +113,14 @@ ofTexture* ofxSourcesEditor::getTexture(int index) |
|
|
|
return &images[index]->getTextureReference(); |
|
|
|
} |
|
|
|
|
|
|
|
void ofxSourcesEditor::guiEvent(ofxUIEventArgs &e) |
|
|
|
void ofxSourcesEditor::guiEvent(string &imageName) |
|
|
|
{ |
|
|
|
string name = e.widget->getName(); |
|
|
|
int kind = e.widget->getKind(); |
|
|
|
|
|
|
|
if(kind == OFX_UI_WIDGET_TOGGLE){ |
|
|
|
ofxUIToggle *toggle = (ofxUIToggle *) e.widget; |
|
|
|
cout << name << "\t value: " << toggle->getValue() << endl; |
|
|
|
} |
|
|
|
string name = imageName; |
|
|
|
|
|
|
|
if ( surfaceManager->getSelectedSurface() == NULL ) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (name == "images") { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
stringstream ss; |
|
|
|
ss << defImgDir << name; |
|
|
|
cout << "attempt to load image: " << ss.str() << endl; |
|
|
|