void ChildAlias::mouseDown (const MouseEvent& e) { toFront (true); if (e.eventComponent == resizer) { } else { dragger.startDraggingComponent (this,0); } userAdjusting = true; startBounds = getBounds (); userStartedChangingBounds (); }
//=========================================================================== void ComponentOverlay::mouseDown (const MouseEvent& e) { layoutEditor->updateSelectedComponentBounds(); mouseDownSelectStatus = layoutEditor->getLassoSelection().addToSelectionOnMouseDown (this, e.mods); if (e.eventComponent != resizer) { //added a constrainer so that components can't be dragged off-screen constrainer->setMinimumOnscreenAmounts (getHeight(), getWidth(), getHeight(), getWidth()); dragger.startDraggingComponent (this, e); } setBoundsForChildren(); userAdjusting = true; startBounds = getBounds (); userStartedChangingBounds (); layoutEditor->updateCodeEditor(); if (layoutEditor->getLassoSelection().getNumSelected() == 1) layoutEditor->resetAllInterest(); interest = "selected"; repaint(); if (e.mods.isPopupMenu()) { PopupMenu menu; menu.setLookAndFeel (&this->getLookAndFeel()); menu.addItem (100, "Delete"); const int r = menu.show(); if (r == 100) { if (layoutEditor->getLassoSelection().getNumSelected() > 1) { CabbageUtilities::showMessage ("Multiple widgets cannot be deleted. Either deselect and delete one by one, or delete the widgets from the Cabbage code section of your .csd file", &this->getPluginEditor()->getLookAndFeel());; } else layoutEditor->getPluginEditor()->sendActionMessage ("delete:" + target->getProperties().getWithDefault ("linenumber", -1).toString()); } } }
void ChildAlias::mouseDown (const MouseEvent& e) { //if (e.mods.isLeftButtonDown()){ ((CabbageMainPanel*)(getTarget()->getParentComponent()))->setMouseState("down"); toFront (true); if (e.eventComponent == resizer) { } else { //added a constrainer so that components can't be dragged off-screen constrainer->setMinimumOnscreenAmounts(getHeight(), getWidth(), getHeight(), getWidth()); dragger.startDraggingComponent (this,e); } userAdjusting = true; startBounds = getBounds (); userStartedChangingBounds (); //get the bounds of each of the child components if we are dealing with a plant Component* c = (Component*) target.getComponent (); origBounds.clear(); for(int i=0;i<c->getNumChildComponents();i++){ origBounds.add(c->getChildComponent(i)->getBounds()); } //update dimensions int offX = getProperties().getWithDefault(var::identifier("plantX"), 0); int offY = getProperties().getWithDefault(var::identifier("plantY"), 0); ((CabbageMainPanel*)(getTarget()->getParentComponent()))->setIndex(index); ((CabbageMainPanel*)(getTarget()->getParentComponent()))->currentBounds.setBounds(getPosition().getX()-offX, getPosition().getY()-offY, getWidth(), getHeight()); ((CabbageMainPanel*)(getTarget()->getParentComponent()))->sendActionMessage("Message sent from CabbageMainPanel:Down"); #ifdef Cabbage_Build_Standalone if(e.mods.isRightButtonDown()){ PopupMenu m; m.setLookAndFeel(&getParentComponent()->getLookAndFeel()); m.addItem(2, "Delete"); m.addItem(1, "Add to repository"); int choice = m.show(); if(choice==1){ this->getTopLevelComponent()->setAlwaysOnTop(false); AlertWindow alert("Add to Repository", "Enter a name and hit 'escape'", AlertWindow::NoIcon, this->getTopLevelComponent()); CabbageLookAndFeel basicLookAndFeel; alert.setLookAndFeel(&basicLookAndFeel); alert.setColour(TextEditor::textColourId, Colours::white); //alert.addTextBlock("Enter a name and hit 'escape'(The following symbols not premitted in names:"" $ % ^ & * ( ) - + )"); alert.addTextEditor("textEditor", "name", ""); alert.runModalLoop(); this->getTopLevelComponent()->setAlwaysOnTop(true); bool clashingNames=false; int result; String plantDir = appProperties->getUserSettings()->getValue("PlantFileDir", ""); Logger::writeToLog(plantDir); Array<File> tempfiles; StringArray plants; addFileToPpopupMenu(m, tempfiles, plantDir, "*.plant"); for(int i=0;i<tempfiles.size();i++){ Logger::outputDebugString(tempfiles[i].getFullPathName()); plants.add(tempfiles[i].getFileNameWithoutExtension()); } for(int i=0;i<plants.size();i++) if(plants[i]==alert.getTextEditorContents("textEditor")) clashingNames = true; if(clashingNames==true){ result = CabbageUtils::showYesNoMessage("Do you wish to overwrite the existing plant?", &getLookAndFeel()); if(result == 0) ((CabbageMainPanel*)(getTarget()->getParentComponent()))->sendActionMessage("Message sent from CabbageMainPanel:AddingPlant:"+alert.getTextEditorContents("textEditor")); else showMessage("Nothing written to repository", &getLookAndFeel()); } else ((CabbageMainPanel*)(getTarget()->getParentComponent()))->sendActionMessage("Message sent from CabbageMainPanel:AddingPlant:"+alert.getTextEditorContents("textEditor")); } else if(choice==2){ ((CabbageMainPanel*)(getTarget()->getParentComponent()))->sendActionMessage("Message sent from CabbageMainPanel:delete:"); } } #endif }