Ejemplo n.º 1
0
//--------------------------------------------------------------
/*public */bool ofxSimpleButton::setup(float x, float y, float w, float h, bool useEvent){
    
    setType(TYPE_BUTTON); //default type is button
    setShape(BUTTON_RECT); //defalut shape is rectangle
    
    b_rect.set(x, y, w, h); //set rectangle position and size
    
    if (w > 0 && h > 0 && !bAppear) {
        setAppear(true);
        setRender(true);
        if (useEvent) {
            if (ofGetTargetPlatform() == OF_TARGET_IOS || ofGetTargetPlatform() == OF_TARGET_ANDROID) {
                ofAddListener(ofEvents().touchDown, this, &ofxSimpleButton::touchDown);
                ofAddListener(ofEvents().touchUp, this, &ofxSimpleButton::touchUp);
                ofAddListener(ofEvents().touchMoved, this, &ofxSimpleButton::touchMoved);
                ofAddListener(ofEvents().touchDoubleTap, this, &ofxSimpleButton::touchDoubleTap);
            }else{
                ofAddListener(ofEvents().mousePressed , this, &ofxSimpleButton::mousePressed);
                ofAddListener(ofEvents().mouseReleased, this, &ofxSimpleButton::mouseReleased);
                ofAddListener(ofEvents().mouseMoved, this, &ofxSimpleButton::mouseMoved);
                ofAddListener(ofEvents().mouseDragged, this, &ofxSimpleButton::mouseDragged);
            }
            ofAddListener(ofEvents().draw, this, &ofxSimpleButton::render);
        }
        return bAppear;
    }
    ofLog(OF_LOG_ERROR, "Button's size is not correct. Button couldn't setup.");
    return bAppear;
}
Ejemplo n.º 2
0
//--------------------------------------------------------------
/*public */bool ofxSimpleButton::setup(float x, float y, float w, float h, bool useEvent, bool manualRender, TYPE_BUTTONS type, BUTTON_SHAPES shape, const ofColor &c)
{
    setType(type);
    setShape(shape);
    
    b_rect.set(x, y, w, h);
    
    if (w > 0 && h > 0 && !bAppear) {
        setAppear(true);
        b_c = c;
        if (useEvent) {
            if (ofGetTargetPlatform() == OF_TARGET_IOS || ofGetTargetPlatform() == OF_TARGET_ANDROID) {
                ofAddListener(ofEvents().touchDown, this, &ofxSimpleButton::touchDown);
                ofAddListener(ofEvents().touchMoved, this, &ofxSimpleButton::touchMoved);
                ofAddListener(ofEvents().touchDoubleTap, this, &ofxSimpleButton::touchDoubleTap);
                ofAddListener(ofEvents().touchUp, this, &ofxSimpleButton::touchUp);
            }else{
                ofAddListener(ofEvents().mousePressed , this, &ofxSimpleButton::mousePressed);
                ofAddListener(ofEvents().mouseReleased, this, &ofxSimpleButton::mouseReleased);
                ofAddListener(ofEvents().mouseMoved, this, &ofxSimpleButton::mouseMoved);
                ofAddListener(ofEvents().mouseDragged, this, &ofxSimpleButton::mouseDragged);
            }
        }
        
        if (!manualRender) {
            setRender(true);
            ofAddListener(ofEvents().draw, this, &ofxSimpleButton::render);
        }
        
        return bAppear;
    }
    
    ofLog(OF_LOG_ERROR, "Button's size is not correct. Button couldn't setup.");
    return bAppear;
}
Ejemplo n.º 3
0
void testApp::generateExamplesCB(bool & pressed){

#ifndef COMMAND_LINE_ONLY
	if (pressed == false) return; // don't do this again on the mouseup.

	targetsToMake.clear();
	if( osxToggle )		targetsToMake.push_back(OF_TARGET_OSX);
	if( iosToggle )		targetsToMake.push_back(OF_TARGET_IPHONE);
	if( wincbToggle )	targetsToMake.push_back(OF_TARGET_WINGCC);
	if( winvsToggle )	targetsToMake.push_back(OF_TARGET_WINVS);
	if( linuxcbToggle )	targetsToMake.push_back(OF_TARGET_LINUX);
	if( linux64cbToggle )	targetsToMake.push_back(OF_TARGET_LINUX64);

	if( targetsToMake.size() == 0 ){
		cout << "Error: generateExamplesCB - must specifiy a project to generate " <<endl;
	}

	for(int i = 0; i < (int)targetsToMake.size(); i++){
		setupForTarget(targetsToMake[i]);
		generateExamples();
	}

	int target = ofGetTargetPlatform();
    setupForTarget(target);
#endif

}
Ejemplo n.º 4
0
string ofxEyeTribe::startServer()
{
    string res;
    // TODO: support multi platform
    switch (ofGetTargetPlatform())
    {
        case OF_TARGET_OSX:
            res = ofSystem("open -n /Applications/EyeTribe/EyeTribe");
            break;
            
        default:
            ofLogError("ofxEyeTribe", "sorry, this addon is not supported your platform...");
            break;
    }
    ofLogNotice("ofxEyeTribe", res);
    return res;
}
Ejemplo n.º 5
0
void testApp::generateExamplesCB(bool & pressed){

	vector <int> targetsToMake;
	if( osxToggle )		targetsToMake.push_back(OF_TARGET_OSX);
	if( iosToggle )		targetsToMake.push_back(OF_TARGET_IPHONE);
	if( wincbToggle )	targetsToMake.push_back(OF_TARGET_WINGCC);
	if( winvsToggle )	targetsToMake.push_back(OF_TARGET_WINVS);
	if( linuxcbToggle )	targetsToMake.push_back(OF_TARGET_LINUX);

	if( targetsToMake.size() == 0 ){
		cout << "Error: generateExamplesCB - must specifiy a project to generate " <<endl;
	}

	for(int i = 0; i < (int)targetsToMake.size(); i++){
		setupForTarget(targetsToMake[i]);
		generateExamples();
	}

	int target = ofGetTargetPlatform();
    setupForTarget(target);
}
Ejemplo n.º 6
0
//--------------------------------------------------------------
/*public */bool ofxSimpleButton::setup(float x, float y, string imgRoute, bool useEvent, bool manualRender, TYPE_BUTTONS type)
{
    setType(type);
    setShape(BUTTON_IMAGE);
    b_img_route = imgRoute;
    //load image and add to vector
    b_img_fbo.clear();
    
    ofImage b;
    if(b.loadImage(b_img_route+".png")) {
        
        ofFbo img_fbo;
        img_fbo.allocate(b.getWidth(), b.getHeight());
        img_fbo.begin();
        ofClear(255,0);
        img_fbo.end();
        
        img_fbo.begin();
        ofSetColor(255);
        b.draw(0, 0);
        img_fbo.end();
        
        b_img_fbo.push_back(img_fbo);
    }else {
        ofLog(OF_LOG_ERROR, "couldn't load image");
        return false;
    }
    
    if(b.loadImage(b_img_route+"_.png")){
        
        ofFbo img_fbo;
        img_fbo.allocate(b.getWidth(), b.getHeight());
        img_fbo.begin();
        ofClear(255,0);
        img_fbo.end();
        
        img_fbo.begin();
        ofSetColor(255);
        b.draw(0, 0);
        img_fbo.end();
        
        b_img_fbo.push_back(img_fbo);
    }
    
    if (b_img_fbo.size() > 0 && !bAppear) {
        setAppear(true);
        
        float w = b_img_fbo[0].getWidth();
        float h = b_img_fbo[0].getHeight();
        b_rect.set(x, y, w, h);
        
        if (useEvent) {
            if (ofGetTargetPlatform() == OF_TARGET_IOS || ofGetTargetPlatform() == OF_TARGET_ANDROID) {
                ofAddListener(ofEvents().touchDown, this, &ofxSimpleButton::touchDown);
                ofAddListener(ofEvents().touchMoved, this, &ofxSimpleButton::touchMoved);
                ofAddListener(ofEvents().touchDoubleTap, this, &ofxSimpleButton::touchDoubleTap);
                ofAddListener(ofEvents().touchUp, this, &ofxSimpleButton::touchUp);
            }else{
                ofAddListener(ofEvents().mousePressed , this, &ofxSimpleButton::mousePressed);
                ofAddListener(ofEvents().mouseReleased, this, &ofxSimpleButton::mouseReleased);
                ofAddListener(ofEvents().mouseMoved, this, &ofxSimpleButton::mouseMoved);
                ofAddListener(ofEvents().mouseDragged, this, &ofxSimpleButton::mouseDragged);
            }
        }
        
        if (!manualRender) {
            setRender(true);
            ofAddListener(ofEvents().draw, this, &ofxSimpleButton::render);
        }
        
        return bAppear;
    }
    
    ofLog(OF_LOG_ERROR, "Button couldn't setup.");
    return bAppear;
}
//--------------------------------------------------------------
void testApp::setup(){
    ofEnableAlphaBlending();
    ofEnableSmoothing();
    ofSetLogLevel(OF_LOG_VERBOSE);
    ofSetVerticalSync(true);
    
    //  Default Settings
    //
    mode                = MODE_NORMAL;
    project             = NULL;
    statusEnergy        = 0;
    float   margin      = 64;
    string  sketchName  = "mySketch";
    
    ofBackground(230,230,230);
    logo.loadImage("images/ofw-logo.png");
    
    //  XML Settings
    //
    ofxXmlSettings XML;
    XML.loadFile("settings/projectGeneratorSettings.xml");
    appToRoot = XML.getValue("appToRoot", "../../../../");
    defaultLoc = XML.getValue("defaultNewProjectLocation", "apps/myApps");
    
    //-------------------------------------
    // calculate the bin path (../../../ on osx) and the sketch path (bin -> root - > defaultLoc)
    //-------------------------------------
    // if appToRoot is wrong, we have alot of issues.  all these paths are used in this project:
    //
#ifdef TARGET_OSX
    string binPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofFilePath::getCurrentWorkingDirectory(), "../../../"));
#else
    string binPath = ofFilePath::getCurrentExeDir();
#endif
    
    string ofRoot = ofFilePath::getAbsolutePath(ofFilePath::join(binPath, appToRoot));
    addonsPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot,"addons"));
    string sketchPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot, defaultLoc));
    
    convertWindowsToUnixPath(ofRoot);
    convertWindowsToUnixPath(addonsPath);
    convertWindowsToUnixPath(sketchPath);
    
    // there's some issues internally in OF with non unix paths for OF root
    //
    setOFRoot(ofRoot);
    
    //------------------------------------- GUI
    //
    
    //  load font and setup the buttons
    //
    font.loadFont("fonts/Inconsolata.otf", 14, true,false,false,0.3,90);
    titleFont.loadFont("fonts/Inconsolata.otf", 28, true,false,false,0.3,90);
    secondFont.loadFont("fonts/Inconsolata.otf", 11, true,false,false,0.3,90);
    
    //  Sketch button
    //
    textButton  *buttonName = new textButton();
    buttonName->font = &font;
    buttonName->secondFont = &secondFont;
    buttonName->prefix = "Name: ";
    buttonName->enableEditing();
	buttonName->topLeftAnchor.set(margin+12, 160+40); //set top button position - others are set relative to this.
    buttonName->setText(sketchName);
    buttonName->secondaryText = "<< CLICK TO CHANGE THE NAME";
    buttons.push_back(buttonName);
    
    //  Path Button
    //
    textButton  *buttonPath = new textButton();
    buttonPath->font = &font;
    buttonPath->secondFont = &secondFont;
    buttonPath->topLeftAnchor.set(buttons[ buttons.size() -1 ]->topLeftAnchor.x, buttons[ buttons.size() -1 ]->topLeftAnchor.y + buttons[ buttons.size() -1 ]->height + 20);
    buttonPath->deliminater = "/";
    buttonPath->prefix = "Path: ";
    buttonPath->setText(sketchPath);
    buttonPath->secondaryText = "<< CLICK TO CHANGE THE DIRECTORY";
    buttons.push_back(buttonPath);
    
    //  Platform Button
    //
    textButton  *buttonPlat = new textButton();
    buttonPlat->font = &font;
    buttonPlat->secondFont = &secondFont;
    buttonPlat->topLeftAnchor.set(buttons[ buttons.size() -1 ]->topLeftAnchor.x, buttons[ buttons.size() -1 ]->topLeftAnchor.y + buttons[ buttons.size() -1 ]->height + 20);
    buttonPlat->deliminater = ", ";
    buttonPlat->prefix = "Platforms: ";
    buttonPlat->secondaryText = "<< CLICK TO CHANGE THE PLATFORM";
    buttonPlat->setText("");
    buttons.push_back(buttonPlat);
    
    //  Addons Button
    //
    textButton  *buttonAddon = new textButton();
    buttonAddon->font = &font;
    buttonAddon->secondFont = &secondFont;
    buttonAddon->topLeftAnchor.set(buttons[ buttons.size() -1 ]->topLeftAnchor.x, buttons[ buttons.size() -1 ]->topLeftAnchor.y + buttons[ buttons.size() -1 ]->height + 20);
    buttonAddon->deliminater = ", ";
    buttonAddon->prefix = "Addons: ";
    buttonAddon->secondaryText = "<< CLICK TO SELECT ADDONS";
    buttonAddon->setText("");
    buttons.push_back(buttonAddon);
    
    for (int i = 0; i < buttons.size(); i++){
        buttons[i]->calculateRect();
    }
    
    //  Generate Button
    //
    generateButton.font = &font;
    generateButton.secondFont = &secondFont;
    generateButton.deliminater = ",";
    generateButton.prefix = "GENERATE PROJECT";
    generateButton.setText("");
    generateButton.bDrawLong = false;
    generateButton.topLeftAnchor.set(ofGetWidth() - buttons[0]->x - generateButton.width + 10 , ofGetHeight() - generateButton.height - 40);
    generateButton.calculateRect();
    
    //  Addon Button
    //
    backButton = generateButton;
    backButton.prefix = "BACK >>";
    backButton.setText("");
    backButton.bDrawLong = false;
    backButton.calculateRect();
    
    //  LOAD ADDONS
    //
    loadAddons();
    
    //  LOAD PLATFORMS
    //
    platformsList.set(64,12,350,500);
    platformsList.font = &font;
    platformsList.title = "Platforms";
    platformsList.addElement("windows (codeblocks)",ofGetTargetPlatform()==OF_TARGET_WINGCC);
	platformsList.addElement("windows (visualStudio)", ofGetTargetPlatform()==OF_TARGET_WINVS);
	platformsList.addElement("linux (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX);
	platformsList.addElement("linux64 (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX64);

    //#define MAKE_IOS
#ifdef MAKE_IOS
	platformsList.addElement("osx (xcode)",false);
	platformsList.addElement("ios (xcode)",true);
#else
    platformsList.addElement("osx (xcode)",ofGetTargetPlatform()==OF_TARGET_OSX);
	platformsList.addElement("ios (xcode)",ofGetTargetPlatform()==OF_TARGET_IPHONE);
#endif
    
    // update the platforms text in the platform button
    //
    buttons[2]->setText( platformsList.getSelectedAsString() );
}
//========================================================================
int main(  int argc, char *argv[]  ){

   
#ifdef TARGET_LINUX
	if(argc==1){
		ofAppGlutWindow window;
		ofSetupOpenGL(&window, 1024,768, OF_WINDOW);
		ofRunApp( new testApp());
	}else{
		ofAppNoWindow window;
		ofSetupOpenGL(&window, 1024,768, OF_WINDOW);
		testApp * app = new testApp;
		app->buildAllExamples = false;
		for(int i=1;i<argc;i++){
			string arg = argv[i];
			if(arg.find("--")==0){
				arg = arg.substr(2);
				if(arg=="linux"){
					app->targetsToMake.push_back( OF_TARGET_LINUX );
				}else if(arg=="linux64"){
					app->targetsToMake.push_back( OF_TARGET_LINUX64 );
				}else if(arg=="win_cb"){
					app->targetsToMake.push_back( OF_TARGET_WINGCC );
				}else if(arg=="vs2010"){
					app->targetsToMake.push_back( OF_TARGET_WINVS );
				}else if(arg=="osx"){
					app->targetsToMake.push_back( OF_TARGET_OSX );
				}else if(arg=="ios"){
					app->targetsToMake.push_back( OF_TARGET_IPHONE );
				}else if(arg=="android"){
					ofLogError() << "platform not supported yet" << endl;
					std::exit(1);
				}else if(arg=="allplatforms"){
					app->targetsToMake.push_back( OF_TARGET_LINUX );
					app->targetsToMake.push_back( OF_TARGET_LINUX64 );
					app->targetsToMake.push_back( OF_TARGET_WINGCC );
					app->targetsToMake.push_back( OF_TARGET_WINVS );
					app->targetsToMake.push_back( OF_TARGET_OSX );
					app->targetsToMake.push_back( OF_TARGET_IPHONE );
				}else if(arg=="allexamples"){
					app->buildAllExamples = true;
				}else if(arg=="help"){
					cout << "OF Project Generator Usage:" << endl;
					cout << "projectGenerator [options] [pathToExample]" << endl;
					cout << "Options:" << endl;
					cout << "--osx: generate osx project files" << endl;
					cout << "--win_cb: generate windows codeblocks project files" << endl;
					cout << "--vs2010: generate windows vs2010 project files" << endl;
					cout << "--linux: generate linux project files" << endl;
					cout << "--linux64: generate linux 64bits project files" << endl;
					cout << "--ios: generate iOS project files" << endl;
					cout << "--allplatforms: generate all platforms project files" << endl;
					cout << "--allexamples: generate all examples project files" << endl;
					cout << endl;
					cout << "default: create project files for current platform for selected path" << endl;
					cout << "running over existing example updates project files for selected platforms" << endl;
					cout << "without parameters, shows gui" << endl;
					std::exit(0);
				}
			}else{
				app->projectPath = ofFilePath::removeTrailingSlash(ofFilePath::getPathForDirectory(ofFilePath::getAbsolutePath(arg,false)));
			}
		}

		if(app->targetsToMake.empty())
			app->targetsToMake.push_back( ofGetTargetPlatform() );
		ofRunApp( app );
	}
#else 
    ofAppGlutWindow window;
    ofSetupOpenGL(&window, 1024,768, OF_WINDOW);
    ofRunApp( new testApp());
    
#endif
    
    
}
Ejemplo n.º 9
0
//--------------------------------------------------------------
void testApp::setup(){
    ofEnableAlphaBlending();
    ofSetLogLevel(OF_LOG_VERBOSE);
    ofSetVerticalSync(true);

    
    statusEnergy = 0;
    
    mode = 0;
    bInited = false;
    project = NULL;
    sketchName = "mySketch";
	

    //-------------------------------------
    // get settings
    //-------------------------------------

    XML.loadFile("settings/projectGeneratorSettings.xml");
    appToRoot = XML.getValue("appToRoot", "../../../../");
    defaultLoc = XML.getValue("defaultNewProjectLocation", "apps/myApps");
       //-------------------------------------
    // calculate the bin path (../../../ on osx) and the sketch path (bin -> root - > defaultLoc)
    //-------------------------------------

    // if appToRoot is wrong, we have alot of issues.  all these paths are used in this project:

#ifdef TARGET_OSX
    string binPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofFilePath::getCurrentWorkingDirectory(), "../../../"));
#else
    string binPath = ofFilePath::getCurrentExeDir();
#endif

    string ofRoot = ofFilePath::getAbsolutePath(ofFilePath::join(binPath, appToRoot));

    addonsPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot,"addons"));
    sketchPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot, defaultLoc));


    convertWindowsToUnixPath(ofRoot);
    convertWindowsToUnixPath(addonsPath);
    convertWindowsToUnixPath(sketchPath);

    // there's some issues internally in OF with non unix paths for OF root
    setOFRoot(ofRoot);



    //-------------------------------------
    // get settings
    //-------------------------------------


    //-------------------------------------
    // load font and setup the buttons
    font.loadFont("fonts/Inconsolata.otf", 14, true,false,false,0.3,90);
    titleFont.loadFont("fonts/Inconsolata.otf", 28, true,false,false,0.3,90);
    secondFont.loadFont("fonts/Inconsolata.otf", 11, true,false,false,0.3,90);
    
    //  Sketch button
    //
    button.font = &font;
    button.secondFont = &secondFont;
    button.prefix = "Name: ";
	button.topLeftAnchor.set(76, 160+40); //set top button position - others are set relative to this.
    button.setText(sketchName);
    
    button.secondaryText = "<< CLICK TO CHANGE THE NAME";
    buttons.push_back(button);

    //  Path button
    //
    button.deliminater = "/";
    button.prefix = "Path: ";
    button.setText(sketchPath);
    button.secondaryText = "<< CLICK TO CHANGE THE DIRECTORY";
	button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20);
    buttons.push_back(button);

    //  Platform text
    //
    button.deliminater = ", ";
    button.prefix = "Platforms: ";
    button.secondaryText = "";
    button.bDrawLong = false;
    button.secondaryText = "";
    button.bSelectable = false;
    button.setText(platform);

    button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20);
    buttons.push_back(button);

    //  Addons button
    //
    button.deliminater = ", ";
    button.bDrawLong = true;
    button.prefix = "Addons: ";
    button.secondaryText = "<< CLICK TO SELECT ADDONS";
    button.bSelectable = true;
    button.setText(addons);

    button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20);
    buttons.push_back(button);

    //  Generate
    //
    generateButton = button;
    generateButton.topLeftAnchor.set(906, 535);
	//generateButton.setColor(ofColor(50, 150, 255));
    generateButton.deliminater = ",";
    generateButton.prefix = "GENERATE PROJECT";
    generateButton.bSelectable = true;
    generateButton.setText("");
    generateButton.bDrawLong = false;
    
    addonButton = button;
    addonButton.topLeftAnchor.set(906, 535);
    addonButton.prefix = "<< BACK";
    addonButton.setText("");
    addonButton.bDrawLong = false;
    

    for (int i = 0; i < buttons.size(); i++){
        buttons[i].calculateRect();
    }
    addonButton.calculateRect();
    generateButton.calculateRect();

    //-------------------------------------
    // addons panels:
    //-------------------------------------

    panelCoreAddons.setup();
    panelOtherAddons.setup();

    ofDirectory addons(addonsPath);

    addons.listDir();
    for(int i=0;i<(int)addons.size();i++){
    	string addon = addons.getName(i);

    	if(addon.find("ofx")==0){

            if (isAddonCore(addon)){
                ofxToggle * toggle = new ofxToggle();
                panelCoreAddons.add(toggle->setup(addon,false,300));
            } else {
                bHaveNonCoreAddons = true;
                ofxToggle * toggle = new ofxToggle();
                panelOtherAddons.add(toggle->setup(addon,false,300));
            }


    	}
    }

    //-------------------------------------
    // platform panel (not used, really, but here just in case)
    //-------------------------------------
    panelPlatforms.setup();
    panelPlatforms.add(wincbToggle.setup("windows (codeblocks)",ofGetTargetPlatform()==OF_TARGET_WINGCC));
	panelPlatforms.add(winvsToggle.setup("windows (visual studio)", ofGetTargetPlatform()==OF_TARGET_WINVS));
	panelPlatforms.add(linuxcbToggle.setup("linux (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX));
	panelPlatforms.add(linux64cbToggle.setup("linux64 (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX64));

//for ios, we need to fake that the target is ios (since we're compiling w/ osx OF)

//#define MAKE_IOS
    
#ifdef MAKE_IOS
	panelPlatforms.add(osxToggle.setup("osx (xcode)",false));
	panelPlatforms.add(iosToggle.setup("ios (xcode)",true));
#else
    panelPlatforms.add(osxToggle.setup("osx (xcode)",ofGetTargetPlatform()==OF_TARGET_OSX));
	panelPlatforms.add(iosToggle.setup("ios (xcode)",ofGetTargetPlatform()==OF_TARGET_IPHONE));
#endif
    
    
    // update the platforms text in the platform button
    string platforms = "";
    for (int i = 0; i < panelPlatforms.getNumControls(); i++){
        if (*((ofxToggle *)panelPlatforms.getControl(i))){
            if (platforms.length() > 0) platforms+=", ";
            platforms += ((ofxToggle *)panelPlatforms.getControl(i))->getName();

        };
    }
    buttons[2].setText(platforms);


    panelPlatforms.setPosition(10,40);
    panelCoreAddons.setPosition(10,40);
    panelOtherAddons.setPosition(330,40);
   

    logo.loadImage("images/ofw-logo.png");

    ofBackground(230,230,230);
    
    
    generateButton.topLeftAnchor.set(ofGetWidth() - buttons[0].rect.x - generateButton.rect.width + 10 ,
                                     ofGetHeight() - generateButton.rect.height - 40);// 535);
    generateButton.calculateRect();
    
    addonButton.topLeftAnchor.set(ofGetWidth() - buttons[0].rect.x - addonButton.rect.width + 10 ,
                                  ofGetHeight() - addonButton.rect.height - 40);// 535);
    addonButton.calculateRect();

}
Ejemplo n.º 10
0
//--------------------------------------------------------------
void testApp::setup(){
    //ofSetLogLevel(OF_LOG_NOTICE);
	project = NULL;

	while(!checkConfigExists()){
		askOFRoot();
	}

	setOFRoot(getOFRootFromConfig());

	setupDrawableOFPath();

	int targ = ofGetTargetPlatform();
	//plat = OF_TARGET_IPHONE;

    setupForTarget(targ);
    if(projectPath!="" || buildAllExamples){
    	for(int i = 0; i < (int)targetsToMake.size(); i++){
			setupForTarget(targetsToMake[i]);
			if(buildAllExamples){
				generateExamples();
			}else{
				project->setup(target);
				project->create(projectPath);
				vector < string > addons;
				parseAddonsDotMake(project->getPath() + "addons.make", addons);
				for (int i = 0; i < (int)addons.size(); i++){
					ofAddon addon;
					addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addons[i]),target);
					project->addAddon(addon);
				}
				project->save(false);
			}
    	}
        std::exit(0);
    }

#ifndef COMMAND_LINE_ONLY
    panelAddons.setup();
    ofDirectory addons(ofFilePath::join(getOFRoot(),"addons"));
    addons.listDir();
    for(int i=0;i<(int)addons.size();i++){
    	string addon = addons.getName(i);
    	if(addon.find("ofx")==0){
    		ofxToggle * toggle = new ofxToggle();
    		panelAddons.add(toggle->setup(addon,false,300));
    	}
    }

    panelOptions.setup("","settings.xml",ofGetWidth()-panelAddons.getWidth()-10,120);
    panelOptions.add(createProject.setup("create project",300));
    panelOptions.add(updateProject.setup("update project",300));
    panelOptions.add(createAndOpen.setup("create and open project",300));
    panelOptions.add(changeOFRoot.setup("change OF path",300));

    createProject.addListener(this,&testApp::createProjectPressed);
    updateProject.addListener(this,&testApp::updateProjectPressed);
    createAndOpen.addListener(this,&testApp::createAndOpenPressed);
    changeOFRoot.addListener(this,&testApp::changeOFRootPressed);

	examplesPanel.setup("generate examples", "examples.xml", 400, 10);
	examplesPanel.add(generateButton.setup("<--Generate"));
	examplesPanel.add(wincbToggle.setup("win CB projects",ofGetTargetPlatform()==OF_TARGET_WINGCC));
	examplesPanel.add(winvsToggle.setup("win VS projects", ofGetTargetPlatform()==OF_TARGET_WINVS));
	examplesPanel.add(linuxcbToggle.setup("linux CB projects",ofGetTargetPlatform()==OF_TARGET_LINUX));
	examplesPanel.add(linux64cbToggle.setup("linux64 CB projects",ofGetTargetPlatform()==OF_TARGET_LINUX64));
	examplesPanel.add(osxToggle.setup("osx projects",ofGetTargetPlatform()==OF_TARGET_OSX));
	examplesPanel.add(iosToggle.setup("ios projects",ofGetTargetPlatform()==OF_TARGET_IPHONE));

	generateButton.addListener(this,&testApp::generateExamplesCB);

    ofSetVerticalSync(true);
    ofEnableAlphaBlending();
	ofSetFrameRate(60);
#else
	std::exit(0);
#endif
}
Ejemplo n.º 11
0
//--------------------------------------------------------------
void testApp::setup(){
    ofSetLogLevel(OF_LOG_VERBOSE);
    ofSetVerticalSync(true);


    mode = 0;
    bInited = false;
    project = NULL;
    sketchName = "mySketch";


    //-------------------------------------
    // get settings
    //-------------------------------------

    XML.loadFile("projectGeneratorSettings.xml");
    appToRoot = XML.getValue("appToRoot", "../../../../");
    defaultLoc = XML.getValue("defaultNewProjectLocation", "apps/myApps");
       //-------------------------------------
    // calculate the bin path (../../../ on osx) and the sketch path (bin -> root - > defaultLoc)
    //-------------------------------------

    // if appToRoot is wrong, we have alot of issues.  all these paths are used in this project:

#ifdef TARGET_OSX
    string binPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofFilePath::getCurrentWorkingDirectory(), "../../../"));
#else
    string binPath = ofFilePath::getCurrentExeDir();
#endif

    string ofRoot = ofFilePath::getAbsolutePath(ofFilePath::join(binPath, appToRoot));
    setOFRoot(ofRoot);

    addonsPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot,"addons"));
    sketchPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot, defaultLoc));




    //-------------------------------------
    // get settings
    //-------------------------------------


    //-------------------------------------
    // load font and setup the buttons
    font.loadFont("frabk.ttf", 12, false, false);

    // sketch button
    button.font = &font;
    button.prefix = "name: ";
    button.setText(sketchName);
    buttons.push_back(button);

    // path button
    button.deliminater = "/";
    button.prefix = "path: ";
    button.setText(sketchPath);
    buttons.push_back(button);

    button.deliminater = ", ";
    button.prefix = "platforms: ";
    button.bSelectable = false;
    button.setText(platform);

    button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20);
    buttons.push_back(button);


    button.deliminater = ", ";
    button.prefix = "addons: ";
    button.bSelectable = true;
    button.setText(addons);

    button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20);
    buttons.push_back(button);

    button.deliminater = ",";
    button.prefix = "generate";
    button.bSelectable = true;
    button.setText("");
    button.topLeftAnchor.set(50,ofGetHeight()-80);
    buttons.push_back(button);

    addonButton = button;
    addonButton.prefix = "< back";
    addonButton.setText("");

     for (int i = 0; i < buttons.size(); i++){
         buttons[i].calculateRect();
     }

    addonButton.calculateRect();

    //-------------------------------------
    // addons panels:
    //-------------------------------------

    panelCoreAddons.setup();
    panelOtherAddons.setup();

    ofDirectory addons(addonsPath);

    addons.listDir();
    for(int i=0;i<(int)addons.size();i++){
    	string addon = addons.getName(i);
    	cout << "adding addon " << addon << endl;
    	if(addon.find("ofx")==0){

            if (isAddonCore(addon)){
                ofxToggle * toggle = new ofxToggle();
                panelCoreAddons.add(toggle->setup(addon,false,300));
            } else {
                ofxToggle * toggle = new ofxToggle();
                panelOtherAddons.add(toggle->setup(addon,false,300));
            }


    	}
    }

    //-------------------------------------
    // platform panel (not used, really, but here just in case)
    //-------------------------------------

    panelPlatforms.setup();
    panelPlatforms.add(wincbToggle.setup("windows (codeblocks)",ofGetTargetPlatform()==OF_TARGET_WINGCC));
	panelPlatforms.add(winvsToggle.setup("windows (visualStudio)", ofGetTargetPlatform()==OF_TARGET_WINVS));
	panelPlatforms.add(linuxcbToggle.setup("linux (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX));
	panelPlatforms.add(linux64cbToggle.setup("linux64 (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX64));
	panelPlatforms.add(osxToggle.setup("osx (xcode)",ofGetTargetPlatform()==OF_TARGET_OSX));
	panelPlatforms.add(iosToggle.setup("ios (xcode)",ofGetTargetPlatform()==OF_TARGET_IPHONE));

    // update the platforms text in the platform button
    string platforms = "";
    for (int i = 0; i < panelPlatforms.getNumControls(); i++){
        if (*((ofxToggle *)panelPlatforms.getControl(i))){
            if (platforms.length() > 0) platforms+=", ";
            platforms += ((ofxToggle *)panelPlatforms.getControl(i))->getName();

        };
    }
    buttons[2].setText(platforms);


    panelPlatforms.setPosition(300,0);
    panelCoreAddons.setPosition(300,0);
    panelOtherAddons.setPosition(750,0);




}