Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Vector of ofxGui & vector listener callbacks

$
0
0

@fresla wrote:

I am trying to make an expandable ofxGui. I think I may have done this all wrong. I dont know how many cameras I will have but I want to control them all.

I used this in ofApp.h

ofxPanel gui;
vector<ofxToggle*>  drawcams;

and this in my setup in ofApp.cpp

    for (int i = 0; i < deviceList.size(); i++) {
    
    
    ofxToggle *  drawcam = new ofxToggle();
    drawcams.push_back(drawcam);
    gui.add(drawcams[i]->setup("Draw Cam " + ofToString(i+1), true));

}

This seems to be problematic as my settings are going on and off sometimes.

I would also like to use listener callbacks like this

drawcam[i].addListener(this, &ofApp::camDrawToggled);

But I guess I am on the wrong track- I would have to make a method like this for every element in my vector right?

void ofApp::camDrawToggled(){
	//Do cool stuff here when the GUI is changed
}

I think I am out of my league and I am guessing there is a good way to solve this but I searched for a while and cannot find anything.

Fred

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles