void ProcessorList::mouseDrag(const MouseEvent& e) { if (e.getMouseDownX() < getWidth() && !(isDragging)) { ProcessorListItem* listItem = getListItemForYPos(e.getMouseDownY()); if (listItem != 0) { if (!listItem->hasSubItems()) { isDragging = true; String b = listItem->getName(); const String dragDescription = b; //std::cout << dragDescription << std::endl; if (dragDescription.isNotEmpty()) { DragAndDropContainer* const dragContainer = DragAndDropContainer::findParentDragContainerFor(this); if (dragContainer != 0) { //pos.setSize (pos.getWidth(), 10); Image dragImage(Image::ARGB, 100, 15, true); Graphics g(dragImage); g.setColour(findColour(listItem->colorId)); g.fillAll(); g.setColour(Colours::white); g.setFont(14); g.drawSingleLineText(listItem->getName(),10,12);//,75,15,Justification::centredRight,true); dragImage.multiplyAllAlphas(0.6f); Point<int> imageOffset(20,10); //See ProcessorGraph::createProcesorFromDescription for description info Array<var> dragData; dragData.add(true); dragData.add(dragDescription); dragData.add(listItem->processorType); dragData.add(listItem->processorId); dragData.add(listItem->getParentName()); dragContainer->startDragging(dragData, this, dragImage, true, &imageOffset); } } } } } }
void LfpDisplayCanvas::mouseDragInCanvas(const MouseEvent& e) { int ypos = e.getMouseDownY(); if (ypos <= headerHeight/2) { float scaleFactor = (float) e.getDistanceFromDragStartY(); if (scaleFactor < 60.0 && scaleFactor > -200.0f) { timebase = pow(10.0f, -scaleFactor/200.0f); } repaint(); } else if (ypos > headerHeight/2 && ypos < headerHeight) { float scaleFactor = (float) e.getDistanceFromDragStartX(); timeOffset = scaleFactor; repaint(); } }
void PMixInterpolationSpaceLayout::mouseDoubleClick (const MouseEvent& e) { if(graphEditor.getLassoSelection().getNumSelected() == 1) { NodeComponent* selectedItem = dynamic_cast<NodeComponent*>(graphEditor.getLassoSelection().getSelectedItem(0)); if (selectedItem) { AudioProcessor* proc = audioEngine.getDoc().getNodeForId(selectedItem->nodeID)->getProcessor(); bool hasParams = (proc->getNumParameters() > 0); if (hasParams) { if (!InternalPluginFormat::isInternalFormat(proc->getName())) { double x = (double) e.getMouseDownX()/getWidth(); double y = (double) e.getMouseDownY()/getHeight(); audioEngine.getDoc().addPreset(selectedItem->nodeID, x, y); } } } } }
void ProcessorList::mouseDrag(const MouseEvent& e) { if (e.getMouseDownX() < getWidth()-getScrollBarWidth() && !(isDragging)) { ProcessorListItem* fli = getListItemForYPos(e.getMouseDownY()); if (fli != 0) { if (!fli->hasSubItems()) { isDragging = true; String b = fli->getParentName(); b += "/"; b += fli->getName(); const String dragDescription = b; //std::cout << dragDescription << std::endl; if (dragDescription.isNotEmpty()) { DragAndDropContainer* const dragContainer = DragAndDropContainer::findParentDragContainerFor (this); if (dragContainer != 0) { //pos.setSize (pos.getWidth(), 10); Image dragImage (Image::ARGB, 100, 15, true); Graphics g(dragImage); g.setColour (fli->color); g.fillAll(); g.setColour(Colours::white); g.setFont(14); g.drawSingleLineText(fli->getName(),10,12);//,75,15,Justification::centredRight,true); dragImage.multiplyAllAlphas(0.6f); Point<int> imageOffset (20,10); dragContainer->startDragging(dragDescription, this, dragImage, true, &imageOffset); } } } } } mouseDragInCanvas(e); }
void PianoRoll::mouseDrag (const MouseEvent& e) { bool snap = snapToGrid != e.mods.isShiftDown(); double x = pixelsToPpq((float)e.x,false); if (snap) { lastDragTime = snapPpqToGrid(lastDragTime); } int n = (int)((float)(getHeight()-e.y)*128.f/(float)getHeight()); if(hoveringNoteIndex != No_Note) { double startTime = draggingNoteStartTime; double length = draggingNoteLength; double offset = lastDragTime-startTime; if (!e.mods.isAltDown()) { int noteDelta = n-draggingNoteNumber; double timeDelta = jmax(0.0,snap ? snapPpqToGrid(x-offset) : x-offset) - draggingNoteStartTime; draggingNoteNumber += noteDelta; draggingNoteStartTime += timeDelta; draggingNoteTransposition = n-hoveringNote->message.getNoteNumber(); draggingNoteTimeDelta = jmax(0.0,snap ? snapPpqToGrid(x-offset) : x-offset) - hoveringNote->message.getTimeStamp(); } else { wasResizing=true; length = x - startTime + draggingNoteEndOffset; double lengthDelta = snap ? snapPpqToGrid(length-draggingNoteLength,true) : length-draggingNoteLength; int velocityDelta = jlimit(1,127,originalNoteVelocity + (getHeight()-e.y) - draggingNoteNumber*getHeight()/128) - draggingNoteVelocity; for (int i=0;i<selectedNotes.size();i++) { if (selectedNotes.getUnchecked(i)->noteOffObject) { //set length and velocity when Alt is down double minWidth = snap ? stepLengthInPpq : 1.0; //if (lengthDelta!=0) selectedNotes.getUnchecked(i)->noteOffObject->message.setTimeStamp(jmax(selectedNotes.getUnchecked(i)->message.getTimeStamp()+minWidth,selectedNotes.getUnchecked(i)->message.getTimeStamp()+selectedNoteLengths.getUnchecked(i).length+lengthDelta)); selectedNotes.getUnchecked(i)->message.setVelocity((jlimit(1,127,selectedNotes.getUnchecked(i)->message.getVelocity()+velocityDelta))*midiScaler); } } draggingNoteVelocity += velocityDelta; } lastDragTime=x; noteLayer->repaint(); } else if (e.mods.isLeftButtonDown()) { lasso.setBounds(jmin(e.x,e.getMouseDownX()), jmin(e.y,e.getMouseDownY()), abs(e.getDistanceFromDragStartX()), abs(e.getDistanceFromDragStartY())); repaint(); } }
void ProgramListBox::mouseDown(const MouseEvent &event) { if ( ! hasContent ) return; int pos = programPosition(event.getMouseDownX(), event.getMouseDownY()); if ( event.mods.isRightButtonDown() || event.mods.isAnyModifierKeyDown() ) { listener->programRightClicked(this, pos); return; } listener->programSelected(this, pos); }
void ProgramListBox::mouseDown(const MouseEvent &event) { if ( ! hasContent ) return; int pos = programPosition(event.getMouseDownX(), event.getMouseDownY()); if ( event.mods.isPopupMenu()) { listener->programRightClicked(this, pos); return; } listener->programSelected(this, pos); }
void LfpDisplayCanvas::mouseMoveInCanvas(const MouseEvent &e) { int ypos = e.getMouseDownY(); if (ypos <= headerHeight/2) { cursorType = MouseCursor::UpDownResizeCursor; } else if (ypos > headerHeight/2 && ypos < headerHeight) { cursorType = MouseCursor::LeftRightResizeCursor; } else { cursorType = MouseCursor::NormalCursor; } }
void LfpDisplayCanvas::mouseDown(const MouseEvent& e) { Point<int> pos = e.getPosition(); int xcoord = pos.getX(); if (xcoord < getWidth()-getScrollBarWidth()) { int chan = (e.getMouseDownY() + getScrollAmount())/(yBuffer+plotHeight); selectedChan = chan; repaint(); } mouseDownInCanvas(e); }
void LfpDisplayCanvas::mouseDownInCanvas(const MouseEvent& e) { Point<int> pos = e.getPosition(); int xcoord = pos.getX(); int ycoord = pos.getY(); if (xcoord < getWidth()-getScrollBarWidth() && ycoord > headerHeight) { int ycoord = e.getMouseDownY() - headerHeight - interplotDistance/2;// - interplotDistance/2;// - interplotDistance; int chan = (ycoord + getScrollAmount())/(yBuffer+interplotDistance); selectedChan = chan; repaint(); } }
const bool ArrowCanvas::DrawableLine::intersects(const MouseEvent& e) { const Figure* startFigure = _lineFigure->getStartFigure(); const Figure* endFigure = _lineFigure->getEndFigure(); const Point* start = startFigure->getAnchorPointRelativeTo(endFigure); const Point* end = endFigure->getAnchorPointRelativeTo(startFigure); if (start && end) { juce::Line line(*start, *end); bool result = (line.getDistanceFromLine((float)e.getMouseDownX(), (float)e.getMouseDownY()) < 10.0f); delete start; delete end; return result; } else { return false; } }
bool PizKeyboardComponent::mouseDownOnKey(int midiNoteNumber, const MouseEvent &e) { midiKeyboardEditor* editor = ((midiKeyboardEditor*)(this->getParentComponent())); if (e.mods.isAltDown()) { editor->getFilter()->setParameter(kHidePanel,1.f-editor->getFilter()->getParameter(kHidePanel)); return false; } int l = isBlackKey(midiNoteNumber) ? this->getBlackNoteLength() : getHeight(); float velocity = editor->getFilter()->getParameter(kUseY)>=0.5f ? (float)e.getMouseDownY()/(float)l : editor->getFilter()->getParameter(kVelocity); if (e.mods.isCtrlDown() || e.mods.isMiddleButtonDown()) { s->allNotesOff(this->getMidiChannel()); _keysPressed.clear(); return false; } else if (e.mods.isShiftDown()) { if (!e.mods.isPopupMenu()) setKeyPressBaseOctave(midiNoteNumber/12); grabKeyboardFocus(); repaint(); return false; } else if (e.mods.isPopupMenu()!=toggle) { if (s->isNoteOn(this->getMidiChannel(),midiNoteNumber)) { s->noteOff(this->getMidiChannel(),midiNoteNumber); } else { s->noteOn(this->getMidiChannel(),midiNoteNumber,velocity); } return false; } else { if (!s->isNoteOn(this->getMidiChannel(),midiNoteNumber)) { //s->noteOn(this->getMidiChannel(),midiNoteNumber,velocity); this->setVelocity(velocity,false); return true; } else { s->noteOff(this->getMidiChannel(),midiNoteNumber); return false; } } return true; }
void PMixInterpolationSpaceLayout::mouseDown (const MouseEvent& e) { selectedItems.deselectAll(); if (e.mods.isPopupMenu()) { if(graphEditor.getLassoSelection().getNumSelected() == 1) { NodeComponent* selectedItem = dynamic_cast<NodeComponent*>(graphEditor.getLassoSelection().getSelectedItem(0)); if (selectedItem) { AudioProcessor* proc = audioEngine.getDoc().getNodeForId(selectedItem->nodeID)->getProcessor(); PopupMenu m; bool hasParams = (proc->getNumParameters() > 0); m.addItem (1, TRANS("Add preset for node"), hasParams); const int r = m.show(); if (r == 1) { if (!InternalPluginFormat::isInternalFormat(proc->getName())) { double x = (double) e.getMouseDownX()/getWidth(); double y = (double) e.getMouseDownY()/getHeight(); audioEngine.getDoc().addPreset(selectedItem->nodeID, x, y); } } } } } else { addChildComponent (lassoComp); lassoComp.beginLasso (e, this); } }
void ProgramListBox::mouseDrag(const MouseEvent &event) { if ( ! hasContent ) return; if ( dragCandidate != -1 ) return; if ( event.getDistanceFromDragStart() < 7 ) return; if (DragAndDropContainer* const dragContainer = DragAndDropContainer::findParentDragContainerFor(this)) { Image snapshot (Image::ARGB, cellWidth, cellHeight, true); int position = programPosition(event.getMouseDownX(), event.getMouseDownY()); Graphics g(snapshot); g.setColour(DXLookNFeel::lightBackground); g.fillRect(0,0,cellWidth, cellHeight); g.setColour(Colours::white); g.drawFittedText(programNames[position], 0, 0, cellWidth, cellHeight, Justification::centred, true); void *src = cartContent.getRawVoice() + (position*128); var description = var(src, 128); dragContainer->startDragging(description, this, snapshot, false); } }
void mouseDrag (const MouseEvent& e) { if (isEnabled() && ! (isDragging || e.mouseWasClicked() || e.getDistanceFromDragStart() < 5 || e.mods.isPopupMenu())) { isDragging = true; Rectangle<int> pos; TreeViewItem* const item = findItemAt (e.getMouseDownY(), pos); if (item != 0 && e.getMouseDownX() >= pos.getX()) { const String dragDescription (item->getDragSourceDescription()); if (dragDescription.isNotEmpty()) { DragAndDropContainer* const dragContainer = DragAndDropContainer::findParentDragContainerFor (this); if (dragContainer != 0) { pos.setSize (pos.getWidth(), item->itemHeight); Image dragImage (Component::createComponentSnapshot (pos, true)); dragImage.multiplyAllAlphas (0.6f); Point<int> imageOffset (pos.getPosition() - e.getPosition()); dragContainer->startDragging (dragDescription, &owner, dragImage, true, &imageOffset); } else { // to be able to do a drag-and-drop operation, the treeview needs to // be inside a component which is also a DragAndDropContainer. jassertfalse; } } } } }
void OpenGLCanvas::mouseDragInCanvas(const MouseEvent& e) { if (getTotalHeight() > getHeight()) { if (e.getMouseDownX() > getWidth()-scrollBarWidth) { if (float(e.getMouseDownY()/float(getHeight())) > scrollBarTop && float(e.getMouseDownY()/float(getHeight())) < scrollBarBottom) { if (scrollDiff == 0) { originalScrollPix = scrollPix; scrollDiff = 1; } } if (scrollDiff == 1) { scrollPix = originalScrollPix + float(e.getDistanceFromDragStartY())/float(getHeight()) * float(getTotalHeight()); if (scrollPix < 0) scrollPix = 0; if (scrollPix + getHeight() > getTotalHeight()) scrollPix = getTotalHeight() - getHeight(); scrollTime = timer->getMillisecondCounter(); showScrollTrack = true; repaint(); } } } }
void CabbageTableManager::mouseDown (const MouseEvent& e) { if(e.mods.isPopupMenu()) { PopupMenu pop, subMenu1, subMenu2; pop.setLookAndFeel(&getTopLevelComponent()->getLookAndFeel()); subMenu1.setLookAndFeel(&getTopLevelComponent()->getLookAndFeel()); subMenu2.setLookAndFeel(&getTopLevelComponent()->getLookAndFeel()); subMenu1.addItem(101, "1 segment"); subMenu1.addItem(102, "2 segments"); subMenu1.addItem(104, "4 segments"); subMenu1.addItem(108, "8 segments"); subMenu1.addItem(112, "12 segments"); subMenu1.addItem(116, "16 segments"); subMenu1.addItem(120, "20 segments"); subMenu1.addItem(124, "24 segments"); subMenu1.addItem(128, "28 segments"); subMenu1.addItem(132, "32 segments"); for(int i=0; i<tables.size(); i++) subMenu2.addColouredItem(200+i, "fTable:"+String(tables[i]->tableNumber), tables[i]->currColour); if(!readOnly) { pop.addSubMenu(TRANS("Edit..."), subMenu1); pop.addSubMenu(TRANS("Table to front..."), subMenu2); pop.addItem(300, "Replace existing table"); pop.addItem(301, "Add table to score"); } int choice; #if !defined(AndroidBuild) choice = pop.show(); #endif if((choice>=100) && (choice<200)) { for(int i=0; i<tables.size(); i++) { if(tables[i]->isCurrentlyOnTop) { //Logger::writeToLog("currentOnTop:"+String(tables[i]->tableNumber)); tables[i]->createHandlesFromTable(choice-100); tables[i]->drawOriginalTableData = false; } } } else if(choice>=200 && choice<300) { this->tableToTop(choice-200); } else if(choice==300) { for(int i=0; i<tables.size(); i++) { if(tables[i]->isCurrentlyOnTop) { tables[i]->changeMessage = "overwriteFunctionTable"; tables[i]->sendChangeMessage(); } } } else if(choice==301) { for(int i=0; i<tables.size(); i++) { if(tables[i]->isCurrentlyOnTop) { tables[i]->changeMessage = "writeNewFunctionTable"; tables[i]->sendChangeMessage(); } } } } //if left button is pressed.. else { for(int i=0; i<tables.size(); i++) { if(tables[i]->editMode) if(tables[i]->toggleMaxMin) { if(tables[i]->getBounds().contains(Point<int>(e.getMouseDownX(), e.getMouseDownY()))) { tables[i]->toggleMinMaxAmp(e.getMouseDownX()); tables[i]->changeMessage = "updateFunctionTable"; tables[i]->sendChangeMessage(); } } else if(tables[i]->isCurrentlyOnTop) { tables[i]->toggleMinMaxAmp(e.getMouseDownX()); tables[i]->changeMessage = "updateFunctionTable"; tables[i]->sendChangeMessage(); } } } }