Skip to content

Commit

Permalink
Refactor setup to have a clearer interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Smith-Heisters committed Nov 26, 2011
1 parent 62777fd commit bdc5fc8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
10 changes: 7 additions & 3 deletions exampleCanvas/src/testApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@

//--------------------------------------------------------------
void testApp::setup() {
ofSetLogLevel(OF_LOG_VERBOSE);

// setup a canvas comprised of three columns in two rows, with the
// resolutions automatically detected from the displays.
//canvas.setup(this, 3, 2);
// ... which is equivalent to:
//canvas.setup(this, 3, 2, 0, 0);
// or, if you want to force the resolutions of the screens:
canvas.setup(this, 2, 1, 640, 480, false);
//canvas.setup(this, 2, 1, 640, 480);
// and, if you want to force the resolutions of the screens, and put them
// all on one display (eg. for testing):
ofxDisplay * display = ofxDisplayManager::get()->getDisplays().front();
canvas.setup(this, 2, 1, 640, 480, display);

// set the backgrounds of all the screens
list<Screen *>::iterator sit;
Expand Down
21 changes: 12 additions & 9 deletions src/ofxFensterCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,27 @@ void ofxFensterCanvas::setScreenIndices(Screen * screen, int index){
screen->index.y = floor(index / columns);
}

void ofxFensterCanvas::setup(ofxFensterListener * listener, int _columns, int _rows, bool autoSetup){
setup(listener, _columns, _rows, 0, 0, autoSetup);
void ofxFensterCanvas::setup(ofxFensterListener * listener, int _columns, int _rows){
setup(listener, _columns, _rows, 0, 0);
}

void ofxFensterCanvas::setup(ofxFensterListener * listener, int _columns, int _rows, int width, int height, bool autoSetup){
void ofxFensterCanvas::setup(ofxFensterListener * listener, int _columns, int _rows, int width, int height){
setup(listener, _columns, _rows, width, height, NULL);
}

void ofxFensterCanvas::setup(ofxFensterListener * listener, int _columns, int _rows, int width, int height, ofxDisplay * display){
columns = _columns, rows = _rows;

ofxFenster * bootstrapWin = ofxFensterManager::get()->getActiveWindow();

if(autoSetup){
autoSetupScreensOnDisplays(listener, width, height);
} else {
ofxDisplay * display = ofxDisplayManager::get()->getDisplays().front();
if(display){
setupScreensOnDisplay(listener, display, width, height);
} else {
autoSetupScreensOnDisplays(listener, width, height);
}

ofxFensterManager::get()->deleteFenster(bootstrapWin);

verifyAndLogScreenSetup();
}

Expand Down
5 changes: 3 additions & 2 deletions src/ofxFensterCanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ class ofxFensterCanvas {
int getHeight();
ofPoint getCanvasPosition();

void setup(ofxFensterListener * listener, int _columns, int _rows, bool autoSetup=true);
void setup(ofxFensterListener * listener, int _columns, int _rows, int width, int height, bool autoSetup=true);
void setup(ofxFensterListener * listener, int _columns, int _rows);
void setup(ofxFensterListener * listener, int _columns, int _rows, int width, int height);
void setup(ofxFensterListener * listener, int _columns, int _rows, int width, int height, ofxDisplay * display);

Screen * getActiveScreen();
void setupPerspectiveForActiveScreen();
Expand Down

0 comments on commit bdc5fc8

Please sign in to comment.