FlLayoutGroup ::FlLayoutGroup (int x, int y, int w, int h, const char* l) :Fl_Group(x,y,w,h,l) { #ifndef NO_GUI box(FL_THIN_UP_FRAME); #endif layouts.resize(1); layouts[0]=new FlLayout(x,y,w,h); #ifndef NO_GUI resizable(NULL); #endif end(); mCurrLayout=0; showLayout(0); }
FlLayoutGroup ::FlLayoutGroup (int x, int y, int w, int h, std::vector<FlLayout*> const& layout, const char* l) :Fl_Group(x,y,w,h,l) { #ifndef NO_GUI box(FL_THIN_UP_FRAME); #endif layouts.resize(layout.size()); for(int i=0; i<layouts.size(); i++) { layouts[i]=layout[i]; #ifndef NO_GUI insert(*layout[i], 0); #endif } #ifndef NO_GUI resizable(NULL); #endif end(); mCurrLayout=0; showLayout(0); }
void JucerDocumentEditor::addComponent (const int index) { showLayout(); if (ComponentLayoutPanel* const panel = dynamic_cast <ComponentLayoutPanel*> (tabbedComponent.getCurrentContentComponent())) { const Rectangle<int> area (panel->getComponentArea()); document->beginTransaction ("Add new " + ObjectTypes::componentTypeHandlers [index]->getTypeName()); const int randomness = jmin (80, area.getWidth() / 2, area.getHeight() / 2); int x = area.getWidth() / 2 + Random::getSystemRandom().nextInt (randomness) - randomness / 2; int y = area.getHeight() / 2 + Random::getSystemRandom().nextInt (randomness) - randomness / 2; x = document->snapPosition (x); y = document->snapPosition (y); panel->xyToTargetXY (x, y); if (Component* newOne = panel->layout.addNewComponent (ObjectTypes::componentTypeHandlers [index], x, y)) panel->layout.getSelectedSet().selectOnly (newOne); document->beginTransaction(); } }
bool JucerDocumentEditor::perform (const InvocationInfo& info) { ComponentLayout* const currentLayout = getCurrentLayout(); PaintRoutine* const currentPaintRoutine = getCurrentPaintRoutine(); document->beginTransaction(); if (info.commandID >= JucerCommandIDs::newComponentBase && info.commandID < JucerCommandIDs::newComponentBase + ObjectTypes::numComponentTypes) { addComponent (info.commandID - JucerCommandIDs::newComponentBase); return true; } if (info.commandID >= JucerCommandIDs::newElementBase && info.commandID < JucerCommandIDs::newElementBase + ObjectTypes::numElementTypes) { addElement (info.commandID - JucerCommandIDs::newElementBase); return true; } switch (info.commandID) { case StandardApplicationCommandIDs::undo: document->getUndoManager().undo(); document->dispatchPendingMessages(); break; case StandardApplicationCommandIDs::redo: document->getUndoManager().redo(); document->dispatchPendingMessages(); break; case JucerCommandIDs::test: TestComponent::showInDialogBox (*document); break; case JucerCommandIDs::enableSnapToGrid: document->setSnappingGrid (document->getSnappingGridSize(), ! document->isSnapActive (false), document->isSnapShown()); break; case JucerCommandIDs::showGrid: document->setSnappingGrid (document->getSnappingGridSize(), document->isSnapActive (false), ! document->isSnapShown()); break; case JucerCommandIDs::editCompLayout: showLayout(); break; case JucerCommandIDs::editCompGraphics: showGraphics (0); break; case JucerCommandIDs::zoomIn: setZoom (snapToIntegerZoom (getZoom() * 2.0)); break; case JucerCommandIDs::zoomOut: setZoom (snapToIntegerZoom (getZoom() / 2.0)); break; case JucerCommandIDs::zoomNormal: setZoom (1.0); break; case JucerCommandIDs::spaceBarDrag: if (EditingPanelBase* panel = dynamic_cast <EditingPanelBase*> (tabbedComponent.getCurrentContentComponent())) panel->dragKeyHeldDown (info.isKeyDown); break; case JucerCommandIDs::compOverlay0: case JucerCommandIDs::compOverlay33: case JucerCommandIDs::compOverlay66: case JucerCommandIDs::compOverlay100: { int amount = 0; if (info.commandID == JucerCommandIDs::compOverlay33) amount = 33; else if (info.commandID == JucerCommandIDs::compOverlay66) amount = 66; else if (info.commandID == JucerCommandIDs::compOverlay100) amount = 100; document->setComponentOverlayOpacity (amount * 0.01f); } break; case JucerCommandIDs::bringBackLostItems: if (EditingPanelBase* panel = dynamic_cast <EditingPanelBase*> (tabbedComponent.getCurrentContentComponent())) { int w = panel->getComponentArea().getWidth(); int h = panel->getComponentArea().getHeight(); if (currentPaintRoutine != nullptr) currentPaintRoutine->bringLostItemsBackOnScreen (panel->getComponentArea()); else if (currentLayout != nullptr) currentLayout->bringLostItemsBackOnScreen (w, h); } break; case JucerCommandIDs::toFront: if (currentLayout != nullptr) currentLayout->selectedToFront(); else if (currentPaintRoutine != nullptr) currentPaintRoutine->selectedToFront(); break; case JucerCommandIDs::toBack: if (currentLayout != nullptr) currentLayout->selectedToBack(); else if (currentPaintRoutine != nullptr) currentPaintRoutine->selectedToBack(); break; case JucerCommandIDs::group: if (currentPaintRoutine != nullptr) currentPaintRoutine->groupSelected(); break; case JucerCommandIDs::ungroup: if (currentPaintRoutine != nullptr) currentPaintRoutine->ungroupSelected(); break; case StandardApplicationCommandIDs::cut: if (currentLayout != nullptr) { currentLayout->copySelectedToClipboard(); currentLayout->deleteSelected(); } else if (currentPaintRoutine != nullptr) { currentPaintRoutine->copySelectedToClipboard(); currentPaintRoutine->deleteSelected(); } break; case StandardApplicationCommandIDs::copy: if (currentLayout != nullptr) currentLayout->copySelectedToClipboard(); else if (currentPaintRoutine != nullptr) currentPaintRoutine->copySelectedToClipboard(); break; case StandardApplicationCommandIDs::paste: { ScopedPointer<XmlElement> doc (XmlDocument::parse (SystemClipboard::getTextFromClipboard())); if (doc != nullptr) { if (doc->hasTagName (ComponentLayout::clipboardXmlTag)) { if (currentLayout != nullptr) currentLayout->paste(); } else if (doc->hasTagName (PaintRoutine::clipboardXmlTag)) { if (currentPaintRoutine != nullptr) currentPaintRoutine->paste(); } } } break; case StandardApplicationCommandIDs::del: if (currentLayout != nullptr) currentLayout->deleteSelected(); else if (currentPaintRoutine != nullptr) currentPaintRoutine->deleteSelected(); break; case StandardApplicationCommandIDs::selectAll: if (currentLayout != nullptr) currentLayout->selectAll(); else if (currentPaintRoutine != nullptr) currentPaintRoutine->selectAll(); break; case StandardApplicationCommandIDs::deselectAll: if (currentLayout != nullptr) { currentLayout->getSelectedSet().deselectAll(); } else if (currentPaintRoutine != nullptr) { currentPaintRoutine->getSelectedElements().deselectAll(); currentPaintRoutine->getSelectedPoints().deselectAll(); } break; default: return false; } document->beginTransaction(); return true; }