void PointEditor::mouseDrag (const MouseEvent& e) { if (selectedPoint > -1 && e.getDistanceFromDragStart() > 0) { int x, y; x = e.x; y = e.y; // y constraint if (y <= 0) y = 0; else if (y >= getBounds().getHeight()) y = getBounds().getHeight(); // x constraint if (x <= 0) x = 0; else if (x >= getBounds().getWidth()) x = getBounds().getWidth(); if (points.size() > 2) { int prevX, nextX; if (selectedPoint == 0) prevX = -1; else prevX = points.at(selectedPoint - 1).x; if (selectedPoint == points.size() - 1) nextX = getBounds().getWidth() + 1; else nextX = points.at(selectedPoint + 1).x; if (e.x <= prevX) x = prevX + 1; else if (e.x >= nextX) x = nextX - 1; } sendChangeMessage(); points[selectedPoint].x = x; points[selectedPoint].y = y; repaint(); } }
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; } } } } }