void SplittableWaveDisplay::mouseDrag(const MouseEvent &e){ if (e.mods.isShiftDown()){ if (!e.mods.isAltDown()) { //Shift-Drag Set previous subsection's duration int i = subsections.getPreviousSubsection(PixelToSample(e.getMouseDownX())); if(i >= 0){} //Empty case prevents a call to getNearest if getPreviousSubsecion call was successful else {i = subsections.getNearestSubsection(PixelToSample(e.getMouseDownX()));} int64 duration = PixelToSample(e.x) - subsections[i].StartSample; if (!duration) duration = 0; subsections.SetSubsectionDuration(duration, i); } else{ int64 start = PixelToSample(e.x); int i = subsections.getNearestSubsection(start); if (i >= 0) subsections.SetSubsectionStart(start, i); } } else{ waveDisplay.mouseDrag(e); } }
void SplittableWaveDisplay::mouseDoubleClick(const MouseEvent &e){ //if (!e.mouseWasClicked()) mouseDrag(e); if (e.mods.isShiftDown()){ if (e.mods.isAltDown()){ int i = subsections.getNearestSubsection(PixelToSample(e.getMouseDownX())); if (i >= 0) subsections.removeSubsection(i); } else{ subsections.addSubsection(PixelToSample(e.getMouseDownX())); } } else{waveDisplay.mouseDoubleClick(e);} }
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 mouseUp (const MouseEvent& e) override { if (e.getMouseDownX() < titleHeight && e.x < titleHeight && e.getNumberOfClicks() != 2) mouseDoubleClick (e); }
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 mouseUp (const MouseEvent& e) { if (e.getMouseDownX() < titleHeight && e.x < titleHeight && e.y < titleHeight && e.getNumberOfClicks() != 2) { setOpen (! isOpen()); } }
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); }
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; } }
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 SampleStripControl::mouseDrag(const MouseEvent &e) { int mouseX = e.x; // Make sure we don't select outside the waveform if (mouseX > componentWidth) mouseX = componentWidth; else if (mouseX < 0) mouseX = 0; // CASE: traditional drag-to-select region of sample if (mouseDownMods == ModifierKeys::leftButtonModifier) { *selectionPointFixed = e.getMouseDownX(); *selectionPointToChange = mouseX; } // CASE: just moving one end of an existing selection else if (mouseDownMods == (ModifierKeys::ctrlModifier + ModifierKeys::leftButtonModifier)) { *selectionPointToChange = mouseX; } // CASE: RMB is held, see which hit zone it selects else if (e.mods == ModifierKeys::rightButtonModifier) { selectedHitZone = mouseX / (componentWidth / 4); } // CASE: ctrl-shift-LMB allows us to snap to specific intervals else if ((e.mods == (ModifierKeys::ctrlModifier + ModifierKeys::leftButtonModifier + ModifierKeys::shiftModifier))) { // TODO: have snapping interval as an option int eighth = componentWidth / 16; // round to the nearest snap point int newSeg = (int) floor(0.5 + mouseX / (float) eighth); // update the changing part of the selection to the snapped position *selectionPointToChange = (int)(newSeg * eighth); } // CASE: moving the entire selection (whilst retaining size) else if (mouseDownMods == ModifierKeys::middleButtonModifier) { int newStart = selectionStartBeforeDrag + e.getDistanceFromDragStartX(); int newEnd = newStart + visualSelectionLength; if(newStart < 0) { newStart = 0; newEnd = visualSelectionLength; } else if (newEnd > componentWidth) { newEnd = componentWidth; newStart = newEnd - visualSelectionLength; } visualSelectionStart = newStart; visualSelectionEnd = newEnd; } // Swap selection positions if inverse selection is made if (visualSelectionEnd < visualSelectionStart) { int temp = visualSelectionStart; visualSelectionStart = visualSelectionEnd; visualSelectionEnd = temp; // same for the pointers int *tempPointer = selectionPointFixed; selectionPointFixed = selectionPointToChange; selectionPointToChange = tempPointer; } visualSelectionLength = (visualSelectionEnd - visualSelectionStart); visualChunkSize = (visualSelectionLength / (float) numChunks); // send the new selection to the SampleStrips dataStrip->setSampleStripParam(SampleStrip::pVisualStart, &visualSelectionStart); dataStrip->setSampleStripParam(SampleStrip::pVisualEnd, &visualSelectionEnd); // update the play speed to account for new selection, // of course this doesn't change if we are just moving the // selection (i.e. using the middle mouse button) if (mouseDownMods != ModifierKeys::middleButtonModifier) processor->calcPlaySpeedForSelectionChange(sampleStripID); // repaint when we next get a timed update stripChanged = true; }
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(); } } } }