void PolycodeScreenEditor::handleDroppedFile(OSFileEntry file, Number x, Number y) { ScreenEntity *newEntity = NULL; if(file.extension == "png") { ScreenImage *newImage = new ScreenImage(file.fullPath); newImage->setPositionMode(ScreenEntity::POSITION_CENTER); baseEntity->addChild(newImage); newImage->setPosition(x-baseEntity->getPosition2D().x,y-baseEntity->getPosition2D().y); newEntity = newImage; newImage->processInputEvents = true; } if(newEntity) { newEntity->addEventListener(this, InputEvent::EVENT_MOUSEDOWN); newEntity->blockMouseInput = true; } }
HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() { core = new POLYCODE_CORE(view, 640,480,false,false,0,0,90); CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak"); CoreServices::getInstance()->getResourceManager()->addDirResource("default", false); Screen *screen = new Screen(); for(Number i=0; i < 10; i++) { ScreenImage *image = new ScreenImage("Resources/polycode_logo.png"); screen->addChild(image); image->setPosition(160+(42*i), 230); image->setPositionMode(ScreenEntity::POSITION_CENTER); image->setRotation(45*i); image->setScale(1.0-(0.1*i),1.0-(0.1*i)); } }
PolycodeFrame::PolycodeFrame() : ScreenEntity() { globalFrame = this; processInputEvents = true; willHideModal = false; showingConsole = true; modalChild = NULL; welcomeEntity = new ScreenEntity(); welcomeEntity->processInputEvents = true; addChild(welcomeEntity); welcomeImage = new ScreenImage("Images/welcome.png"); welcomeEntity->addChild(welcomeImage); welcomeEntity->snapToPixels = true; newProjectButton = new UIButton("Create A New Project!", 220); newProjectButton->setPosition(230,80); newProjectButton->addEventListener(this, UIEvent::CLICK_EVENT); examplesButton = new UIButton("Browse Example Projects!", 220); examplesButton->setPosition(460,80); examplesButton->addEventListener(this, UIEvent::CLICK_EVENT); welcomeEntity->addChild(newProjectButton); welcomeEntity->addChild(examplesButton); mainSizer = new UIHSizer(100,100,200,true); mainSizer->setPosition(0, 45); addChild(mainSizer); consoleSize = 200; consoleSizer = new UIVSizer(100,100,200, false); mainSizer->addRightChild(consoleSizer); projectBrowser = new PolycodeProjectBrowser(); mainSizer->addLeftChild(projectBrowser); editorHolder = new EditorHolder(); consoleSizer->addTopChild(editorHolder); console = new PolycodeConsole(); consoleSizer->addBottomChild(console); projectBrowser->treeContainer->getRootNode()->addEventListener(this, UITreeEvent::DRAG_START_EVENT); topBarBg = new ScreenShape(ScreenShape::SHAPE_RECT, 2,2); topBarBg->setColorInt(21, 18, 17, 255); topBarBg->setPositionMode(ScreenEntity::POSITION_TOPLEFT); topBarBg->processInputEvents = true; topBarBg->blockMouseInput = true; addChild(topBarBg); logo = new ScreenImage("Images/barlogo.png"); addChild(logo); playButton = new UIImageButton("Images/play_button.png"); addChild(playButton); playButton->setPosition(10,4); stopButton = new UIImageButton("Images/stop_button.png"); addChild(stopButton); stopButton->setPosition(10,4); currentProjectTitle = new ScreenLabel("", 32, "section"); addChild(currentProjectTitle); currentProjectTitle->color.a = 0.4; currentProjectTitle->setPosition(70, 0); currentFileSelector = new UIComboBox(globalMenu, 300); currentFileSelector->addEventListener(this, UIEvent::CHANGE_EVENT); addChild(currentFileSelector); resizer = new ScreenImage("Images/corner_resize.png"); addChild(resizer); resizer->setColor(0,0,0,0.4); modalBlocker = new ScreenShape(ScreenShape::SHAPE_RECT, 10,10); modalBlocker->setColor(0,0,0,0.4); modalBlocker->setPositionMode(ScreenEntity::POSITION_TOPLEFT); modalBlocker->enabled = false; modalBlocker->blockMouseInput = true; modalBlocker->processInputEvents = true; addChild(modalBlocker); assetBrowser = new AssetBrowser(); assetBrowser->visible = false; newProjectWindow = new NewProjectWindow(); newProjectWindow->visible = false; exampleBrowserWindow = new ExampleBrowserWindow(); exampleBrowserWindow->visible = false; newFileWindow = new NewFileWindow(); newFileWindow->visible = false; exportProjectWindow = new ExportProjectWindow(); exportProjectWindow->visible = false; textInputPopup = new TextInputPopup(); textInputPopup->visible = false; yesNoPopup = new YesNoPopup(); yesNoPopup->visible = false; yesNoCancelPopup = new YesNoCancelPopup(); yesNoCancelPopup->visible = false; aboutWindow = new UIWindow("", 800, 440); aboutWindow->closeOnEscape = true; ScreenImage *aboutImage = new ScreenImage("Images/about.png"); aboutWindow->addChild(aboutImage); aboutImage->setPosition(20, 40); aboutWindow->visible = false; aboutOKButton = new UIButton("OK", 100); aboutWindow->addChild(aboutOKButton); aboutOKButton->setPosition(700, 420); aboutOKButton->addEventListener(this, UIEvent::CLICK_EVENT); ScreenLabel *versionLabel = new ScreenLabel("version 0.8.2", 12, "mono"); aboutWindow->addChild(versionLabel); versionLabel->setPosition(20, 430); versionLabel->color.a = 0.4; isDragging = false; dragLabel = new ScreenLabel("NONE", 11, "sans"); dragLabel->setPosition(0,-15); dragEntity = new ScreenEntity(); dragEntity->addChild(dragLabel); addChild(dragEntity); dragEntity->visible = false; CoreServices::getInstance()->getCore()->getInput()->addEventListener(this, InputEvent::EVENT_MOUSEUP); CoreServices::getInstance()->getCore()->getInput()->addEventListener(this, InputEvent::EVENT_MOUSEMOVE); curveEditor = new CurveEditor(); addChild(curveEditor); curveEditor->setPosition(200,100); curveEditor->visible = false; curveEditor->enabled = false; globalColorPicker = new UIColorPicker(); globalColorPicker->setPosition(300,300); addChild(globalColorPicker); modalRoot = new UIElement(); addChild(modalRoot); fileDialogBlocker = new ScreenShape(ScreenShape::SHAPE_RECT, 100, 100); fileDialogBlocker->setPositionMode(ScreenEntity::POSITION_TOPLEFT); addChild(fileDialogBlocker); fileDialogBlocker->setColor(0.0, 0.0, 0.0, 0.5); fileDialogBlocker->processInputEvents = true; fileDialogBlocker->blockMouseInput = true; fileDialogBlocker->visible = false; fileDialogBlocker->enabled = false; fileBrowserRoot = new UIElement(); addChild(fileBrowserRoot); fileDialog = NULL; }