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); } } } } } }
NS_IMETHODIMP nsDragServiceProxy::InvokeDragSession(nsIDOMNode* aDOMNode, nsISupportsArray* aArrayTransferables, nsIScriptableRegion* aRegion, uint32_t aActionType) { nsresult rv = nsBaseDragService::InvokeDragSession(aDOMNode, aArrayTransferables, aRegion, aActionType); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDOMDocument> sourceDocument; aDOMNode->GetOwnerDocument(getter_AddRefs(sourceDocument)); nsCOMPtr<nsIDocument> doc = do_QueryInterface(sourceDocument); NS_ENSURE_STATE(doc->GetDocShell()); mozilla::dom::TabChild* child = mozilla::dom::TabChild::GetFrom(doc->GetDocShell()); NS_ENSURE_STATE(child); nsTArray<mozilla::dom::IPCDataTransfer> dataTransfers; nsContentUtils::TransferablesToIPCTransferables(aArrayTransferables, dataTransfers, child->Manager(), nullptr); if (mHasImage || mSelection) { nsIntRect dragRect; nsPresContext* pc; mozilla::RefPtr<mozilla::gfx::SourceSurface> surface; DrawDrag(mSourceNode, aRegion, mScreenX, mScreenY, &dragRect, &surface, &pc); if (surface) { mozilla::RefPtr<mozilla::gfx::DataSourceSurface> dataSurface = surface->GetDataSurface(); mozilla::gfx::IntSize size = dataSurface->GetSize(); size_t length; int32_t stride; mozilla::UniquePtr<char[]> surfaceData = nsContentUtils::GetSurfaceData(dataSurface, &length, &stride); nsDependentCString dragImage(surfaceData.get(), length); mozilla::unused << child->SendInvokeDragSession(dataTransfers, aActionType, dragImage, size.width, size.height, stride, static_cast<uint8_t>(dataSurface->GetFormat()), dragRect.x, dragRect.y); StartDragSession(); return NS_OK; } } mozilla::unused << child->SendInvokeDragSession(dataTransfers, aActionType, nsCString(), 0, 0, 0, 0, 0, 0); StartDragSession(); return NS_OK; }
void ProcessorList::mouseDragInCanvas(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(findColour(fli->colorId)); 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); } } } } } }