| 306 | } |
| 307 | |
| 308 | const String CtrlrPanel::exportPanel(CtrlrPanel *panel, const File &lastBrowsedDir, const File &destinationFile, MemoryBlock *outputPanelData, MemoryBlock *outputResourcesData, const bool isRestricted) |
| 309 | { |
| 310 | Image panelSnapshot (Image::ARGB, 400, 400, true); |
| 311 | CtrlrPanelCanvas *canvas = panel->getEditor()->getCanvas(); |
| 312 | // CtrlrPanelEditor *editor = panel->getEditor(); |
| 313 | |
| 314 | if (panel == 0 || panel == nullptr) |
| 315 | return ("Undefined panel passeed to exporter"); |
| 316 | |
| 317 | File exportedFile = File(); |
| 318 | |
| 319 | if (destinationFile == File()) |
| 320 | exportedFile = askForPanelFileToSave (panel, lastBrowsedDir, false, true); |
| 321 | else |
| 322 | exportedFile = destinationFile; |
| 323 | |
| 324 | if (exportedFile == File()) |
| 325 | return ("Destination file does not exist or is invalid"); |
| 326 | |
| 327 | panel->luaSavePanel (PanelFileExport, exportedFile); |
| 328 | |
| 329 | if (canvas) |
| 330 | { |
| 331 | Image snap = canvas->createComponentSnapshot (canvas->getBounds(), true); |
| 332 | Graphics g(panelSnapshot); |
| 333 | g.drawImageWithin (snap, 0, 0, 400, 400, RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, false); |
| 334 | } |
| 335 | |
| 336 | ValueTree resources(Ids::resourceExportList); |
| 337 | |
| 338 | for (int i=0; i<panel->getResourceManager().getNumResources(); i++) |
| 339 | { |
| 340 | CtrlrPanelResource *res = panel->getResourceManager().getResource(i); |
| 341 | if (res) |
| 342 | { |
| 343 | resources.addChild (res->createTree(), -1, 0); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | if (panel->getResourceManager().getNumResources() > 0) |
| 348 | { |
| 349 | const int ret = AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon, "License question", "Would you like to attach a license to this panel?", "Yes", "No"); |
| 350 | if (ret == 1) |
| 351 | { |
| 352 | AlertWindow licenseWindow("License content", "Paste your license below", AlertWindow::InfoIcon, 0); |
| 353 | TextEditor lic; |
| 354 | lic.setMultiLine (true, false); |
| 355 | lic.setSize (400,300); |
| 356 | licenseWindow.addCustomComponent (&lic); |
| 357 | licenseWindow.addButton ("OK", 1); |
| 358 | |
| 359 | if (licenseWindow.runModalLoop()) |
| 360 | { |
| 361 | ValueTree licTree(Ids::resourceLicense); |
| 362 | licTree.setProperty(Ids::resourceData, lic.getText(), 0); |
| 363 | resources.addChild (licTree, -1, 0); |
| 364 | } |
| 365 | } |
nothing calls this directly
no test coverage detected