|
@ -17,9 +17,12 @@ RadioList::RadioList(string title, vector<string>& labels, vector<string>& value |
|
|
setup(title, labels, values); |
|
|
setup(title, labels, values); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
RadioList::~RadioList() { clear(); } |
|
|
RadioList::~RadioList(){ |
|
|
|
|
|
clear(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void RadioList::setup(vector<string> & labels, vector<string> & values){ |
|
|
void RadioList::setup(vector<string> & labels, vector<string> & values){ |
|
|
|
|
|
|
|
|
// Copy incomming labels for later use
|
|
|
// Copy incomming labels for later use
|
|
|
storedLabels = labels; |
|
|
storedLabels = labels; |
|
|
storedValues = values; |
|
|
storedValues = values; |
|
@ -39,22 +42,29 @@ void RadioList::setup(vector<string>& labels, vector<string>& values) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void RadioList::setup(string title, vector<string> & labels, vector<string> & values){ |
|
|
void RadioList::setup(string title, vector<string> & labels, vector<string> & values){ |
|
|
|
|
|
|
|
|
// Store title for later use
|
|
|
// Store title for later use
|
|
|
storedTitle = title; |
|
|
storedTitle = title; |
|
|
guiGroup.setName(title); |
|
|
guiGroup.setName(title); |
|
|
setup(labels, values); |
|
|
setup(labels, values); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void RadioList::draw() { guiGroup.draw(); } |
|
|
void RadioList::draw(){ |
|
|
|
|
|
guiGroup.draw(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void RadioList::setTitle(string title){ |
|
|
void RadioList::setTitle(string title){ |
|
|
storedTitle = title; |
|
|
storedTitle = title; |
|
|
guiGroup.setName(title); |
|
|
guiGroup.setName(title); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void RadioList::setPosition(ofPoint p) { guiGroup.setPosition(p); } |
|
|
void RadioList::setPosition(ofPoint p){ |
|
|
|
|
|
guiGroup.setPosition(p); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void RadioList::setPosition(float x, float y) { guiGroup.setPosition(x, y); } |
|
|
void RadioList::setPosition(float x, float y){ |
|
|
|
|
|
guiGroup.setPosition(x, y); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void RadioList::selectItem(int index){ |
|
|
void RadioList::selectItem(int index){ |
|
|
if(index >= guiGroup.getNumControls()){ |
|
|
if(index >= guiGroup.getNumControls()){ |
|
@ -99,7 +109,7 @@ void RadioList::selectItem(int index) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void RadioList::enable(){ |
|
|
void RadioList::enable(){ |
|
|
if (guiGroup.getNumControls() >= 0) { |
|
|
if(guiGroup.getNumControls() > 0){ |
|
|
clear(); |
|
|
clear(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -107,8 +117,7 @@ void RadioList::enable() { |
|
|
setup(storedTitle, storedLabels, storedValues); |
|
|
setup(storedTitle, storedLabels, storedValues); |
|
|
|
|
|
|
|
|
// Select the stored selected item without throwing an event
|
|
|
// Select the stored selected item without throwing an event
|
|
|
ofxToggle* toggle = |
|
|
ofxToggle * toggle = static_cast<ofxToggle *>(guiGroup.getControl(storedSelectedItem)); |
|
|
static_cast<ofxToggle*>(guiGroup.getControl(storedSelectedItem)); |
|
|
|
|
|
toggle->removeListener(this, &RadioList::onToggleClicked); |
|
|
toggle->removeListener(this, &RadioList::onToggleClicked); |
|
|
*toggle = true; |
|
|
*toggle = true; |
|
|
toggle->addListener(this, &RadioList::onToggleClicked); |
|
|
toggle->addListener(this, &RadioList::onToggleClicked); |
|
@ -135,21 +144,28 @@ void RadioList::unselectAll() { |
|
|
int i; |
|
|
int i; |
|
|
for(i = 0; i < guiGroup.getNumControls(); i++){ |
|
|
for(i = 0; i < guiGroup.getNumControls(); i++){ |
|
|
ofxToggle * toggle = static_cast<ofxToggle *>(guiGroup.getControl(i)); |
|
|
ofxToggle * toggle = static_cast<ofxToggle *>(guiGroup.getControl(i)); |
|
|
ofParameter<bool>* paramPtr = |
|
|
ofParameter<bool> * paramPtr = static_cast<ofParameter<bool> *>(&toggle->getParameter()); |
|
|
static_cast<ofParameter<bool>*>(&toggle->getParameter()); |
|
|
|
|
|
toggle->removeListener(this, &RadioList::onToggleClicked); |
|
|
toggle->removeListener(this, &RadioList::onToggleClicked); |
|
|
*toggle = false; |
|
|
*toggle = false; |
|
|
toggle->addListener(this, &RadioList::onToggleClicked); |
|
|
toggle->addListener(this, &RadioList::onToggleClicked); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ofPoint RadioList::getPosition() { return guiGroup.getPosition(); } |
|
|
ofPoint RadioList::getPosition(){ |
|
|
|
|
|
return guiGroup.getPosition(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
float RadioList::getWidth() { return guiGroup.getWidth(); } |
|
|
float RadioList::getWidth(){ |
|
|
|
|
|
return guiGroup.getWidth(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
float RadioList::getHeight() { return guiGroup.getHeight(); } |
|
|
float RadioList::getHeight(){ |
|
|
|
|
|
return guiGroup.getHeight(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
string RadioList::getTitle() { return guiGroup.getName(); } |
|
|
string RadioList::getTitle(){ |
|
|
|
|
|
return guiGroup.getName(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
string RadioList::getItemName(int index){ |
|
|
string RadioList::getItemName(int index){ |
|
|
if(index >= guiGroup.getNumControls()){ |
|
|
if(index >= guiGroup.getNumControls()){ |
|
@ -160,18 +176,18 @@ string RadioList::getItemName(int index) { |
|
|
return toggle->getName(); |
|
|
return toggle->getName(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int RadioList::size() { return storedValues.size(); } |
|
|
int RadioList::size(){ |
|
|
|
|
|
return storedValues.size(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void RadioList::onToggleClicked(bool& toggleValue) |
|
|
void RadioList::onToggleClicked(bool & toggleValue){ |
|
|
{ |
|
|
|
|
|
unselectAll(); |
|
|
unselectAll(); |
|
|
|
|
|
|
|
|
// Search for the actual toggle triggering the event
|
|
|
// Search for the actual toggle triggering the event
|
|
|
int i; |
|
|
int i; |
|
|
for(i = 0; i < guiGroup.getNumControls(); i++){ |
|
|
for(i = 0; i < guiGroup.getNumControls(); i++){ |
|
|
ofxToggle * toggle = static_cast<ofxToggle *>(guiGroup.getControl(i)); |
|
|
ofxToggle * toggle = static_cast<ofxToggle *>(guiGroup.getControl(i)); |
|
|
ofParameter<bool>* paramPtr = |
|
|
ofParameter<bool> * paramPtr = static_cast<ofParameter<bool> *>(&toggle->getParameter()); |
|
|
static_cast<ofParameter<bool>*>(&toggle->getParameter()); |
|
|
|
|
|
|
|
|
|
|
|
if(&(paramPtr->get()) == &toggleValue){ |
|
|
if(&(paramPtr->get()) == &toggleValue){ |
|
|
selectItem(i); |
|
|
selectItem(i); |
|
@ -179,5 +195,5 @@ void RadioList::onToggleClicked(bool& toggleValue) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} // namespace piMapper
|
|
|
} |
|
|
} // namespace ofx
|
|
|