Skip to content

Commit

Permalink
adapted to new ofxGui implementation introduced by arturoc/openFramew…
Browse files Browse the repository at this point in the history
  • Loading branch information
frauzufall committed Aug 12, 2015
1 parent 1fa366e commit 81efd25
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 36 deletions.
2 changes: 1 addition & 1 deletion example/src/SomeScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void SomeScene::setup(float w, float h) {
ofClear(0,0,0,0);
fbo->end();

myfont.loadFont("arial.ttf", 112);
myfont.load("arial.ttf", 112);
}

void SomeScene::update() {
Expand Down
1 change: 0 additions & 1 deletion example/src/ofApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class ofApp : public ofBaseApp{
private:

ofx2DMapping mapping;
ofPtr<ofx2DMappingContentShape> cshape;

SomeScene scene;

Expand Down
8 changes: 4 additions & 4 deletions src/ofx2DFormMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ bool ofx2DFormMapping::mouseDragged(ofMouseEventArgs &args) {
}

obj->newpos = true;
parent_list->getListItems().at(shapes.size()-1-i)->setBackgroundColor(ofColor(0,200,210));
// Visuals::get().reloadLinesFromRaw();
ofColor c = parent_list->getControl(shapes.size()-1-i)->getFillColor();
parent_list->getControl(shapes.size()-1-i)->setBackgroundColor(c);
}
}

Expand Down Expand Up @@ -557,8 +557,8 @@ bool ofx2DFormMapping::mouseReleased(ofMouseEventArgs &args) {
for (uint i = 0; i < shapes.size(); i++){
for (uint j = 0; j < shapes[i].polyline.size(); j++){
shapes[i].polyline[j].bBeingDragged = false;
if(shapes.size()-1-i < parent_list->getListItems().size() && parent_list->getListItems().size() > 0 && shapes.size() == parent_list->getListItems().size())
parent_list->getListItems().at(shapes.size()-1-i)->setBackgroundColor(parent_list->getBackgroundColor());
if(shapes.size()-1-i < parent_list->getNumControls() && parent_list->getNumControls() > 0 && shapes.size() == parent_list->getNumControls())
parent_list->getControl(shapes.size()-1-i)->setBackgroundColor(parent_list->getBackgroundColor());
}
for (uint j = 0; j < shapes[i].src.size(); j++){
shapes[i].src[j].bBeingDragged = false;
Expand Down
8 changes: 8 additions & 0 deletions src/ofx2DMappingController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ ofPtr<ofx2DMappingObject> ofx2DMappingController::createShape(ofx2DMappingProjec

void ofx2DMappingController::update() {

//check if any object template wants to be copied to stage
for(auto &e: getOptions()){
if(e->pleaseCopyMe.get()){
e->pleaseCopyMe.set(false);
getProjector(0)->copyShape(e);
}
}

for(uint i = 0; i < projectors.size(); i++) {
projectors[i].update();
}
Expand Down
2 changes: 1 addition & 1 deletion src/ofx2DMappingController.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ofx2DMappingController {
ofRectangle getOutputRectangle();
void setOutputRectangle(ofRectangle r);

private:
protected:

ofPtr<ofx2DMappingObject> createShape(ofx2DMappingProjector* projector, string type, string name);

Expand Down
1 change: 1 addition & 0 deletions src/ofx2DMappingObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class ofx2DMappingObject {
bool newpos;
bool newitem;
ofParameter<bool> editable;
ofParameter<bool> pleaseCopyMe;

~ofx2DMappingObject(){}

Expand Down
1 change: 1 addition & 0 deletions src/ofx2DMappingProjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ofx2DMappingProjector::~ofx2DMappingProjector() {
}

void ofx2DMappingProjector::update() {

ofPtr<ofx2DMappingObject> mq;
for(uint i = 0; i < shapeCount(); i++) {
mq = getMappingObject(i);
Expand Down
59 changes: 33 additions & 26 deletions src/ofx2DMappingView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ void ofx2DMappingView::setup(float x, float y, float w, float h) {

save_btn.addListener(ctrl, &ofx2DMappingController::saveMappingDefault);
save_btn.setup("save");
main_panel.add(&save_btn);
main_panel.add(save_btn);

import_btn.addListener(this, &ofx2DMappingView::importSvg);
import_btn.setup("import svg");
main_panel.add(&import_btn);
main_panel.add(import_btn);

edit_mode_btn.addListener(this, &ofx2DMappingView::setEditMode);
edit_mode_btn.setup("direct edit", direct_edit);
main_panel.add(&edit_mode_btn);
main_panel.add(edit_mode_btn);

//CALIBRATION OPTIONS

Expand All @@ -50,49 +50,53 @@ void ofx2DMappingView::setup(float x, float y, float w, float h) {
calibration_options.add(ctrl->getCalBorder());
calibration_options.add(ctrl->getCalGrey());

main_panel.add(&calibration_options);
main_panel.add(calibration_options);

//OBJECT LIST PANEL

list_panel.setup("MAPPING OBJECTS");

add_buttons_panel.setup("ADD MAPPING OBJECTS");

add_button_params.clear();
vector<ofPtr<ofx2DMappingObject>> options = ctrl->getOptions();
for(uint i = 0; i < options.size(); i++) {
add_button_params.push_back(ofParameter<bool>("add " + options.at(i)->name, false));
add_buttons_panel.add(add_button_params.at(i));
ofxToggle::Config config;
ofColor c = options.at(i)->color;
if(c.getBrightness() < 200){
c.setBrightness(200);
}
config.textColor = c;
add_buttons_panel.add(options.at(i)->pleaseCopyMe.set("add " + options.at(i)->name, false), config);
options.at(i)->pleaseCopyMe.addListener(this, &ofx2DMappingView::addedObject);
}

list_panel.add(&add_buttons_panel);
list_panel.add(add_buttons_panel);

//LIST MANIPULATION OPTIONS

list_options.setup("OBJECT MANIPULATION");

select_all_btn.addListener(this, &ofx2DMappingView::selectAllObjects);
select_all_btn.setup("select all");
list_options.add(&select_all_btn);
list_options.add(select_all_btn);

deselect_all_btn.addListener(this, &ofx2DMappingView::deselectAllObjects);
deselect_all_btn.setup("deselect all");
list_options.add(&deselect_all_btn);
list_options.add(deselect_all_btn);

delete_all_btn.addListener(this, &ofx2DMappingView::removeAllObjects);
delete_all_btn.setup("delete all");
list_options.add(&delete_all_btn);
list_options.add(delete_all_btn);

list_panel.add(&list_options);
list_panel.add(list_options);

//OBJECT LIST

object_list.setup("MAPPING OBJECT LIST");
ofAddListener(object_list.elementRemoved, this, &ofx2DMappingView::removeForm);
ofAddListener(object_list.elementMovedStepByStep, this, &ofx2DMappingView::reorderForm);
object_list.setHeaderBackgroundColor(ofColor::black);

list_panel.add(&object_list);
list_panel.add(object_list);

setSubpanelPositions();

Expand All @@ -105,15 +109,6 @@ void ofx2DMappingView::update() {

mapping_forms.update();

for(uint i = 0; i < add_button_params.size(); i++) {
if(add_button_params.at(i)) {
ctrl->getProjector(0)->copyShape(ctrl->getOptions().at(i));
mapping_forms.updateForms();
updateObjectList();
add_button_params.at(i) = false;
}
}

}

void ofx2DMappingView::draw() {
Expand All @@ -140,6 +135,14 @@ void ofx2DMappingView::draw(ofPoint pos) {

}

void ofx2DMappingView::addedObject(bool & clickstart){
if(clickstart){
ctrl->update();
mapping_forms.updateForms();
updateObjectList();
}
}

void ofx2DMappingView::updateObjectList() {

object_list.clear();
Expand All @@ -150,11 +153,15 @@ void ofx2DMappingView::updateObjectList() {

ofPtr<ofx2DMappingObject> mq = p->getMappingObject(i);
if(mq) {
// string objname = mq->name;
//insert toggles at beginning of list
mq->editable.setName(mq->name);
object_list.add(mq->editable,false);
object_list.getListItems().at(0)->setBorderColor(mq->color);
ofColor c = mq->color;
if(c.getBrightness() < 200){
c.setBrightness(200);
}
ofxToggle::Config config;
config.textColor = c;
object_list.add(mq->editable, config, false);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/ofx2DMappingView.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ofx2DMappingView {
void setShape(ofRectangle shape);
ofRectangle getShape();

private:
protected:

ofx2DMappingController* ctrl;

Expand All @@ -35,6 +35,8 @@ class ofx2DMappingView {
void deselectAllObjects();
void removeAllObjects();

void addedObject(bool&clickstart);

bool show_source, direct_edit;

ofRectangle control_rect;
Expand All @@ -53,10 +55,8 @@ class ofx2DMappingView {

ofxButton save_btn, import_btn, select_all_btn, deselect_all_btn, delete_all_btn;
ofxToggle edit_mode_btn;
vector<ofParameter<bool>> add_button_params;

float zoom;
ofPoint zoom_pos;


};

0 comments on commit 81efd25

Please sign in to comment.