Skip to content

Commit

Permalink
Merge pull request #55 from pankajp/tree_editor-drag_image_offset
Browse files Browse the repository at this point in the history
BUG: TreeEditor drag hotspot at wrong position in when scrolled.
  • Loading branch information
Jonathan March authored and Jonathan March committed Feb 1, 2012
2 parents ab7b36a + 531c32d commit a5ffecc
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions traitsui/qt4/tree_editor.py
Expand Up @@ -1721,24 +1721,21 @@ def startDrag(self, actions):
# Render the item being dragged as a pixmap.
nid_rect = self.visualItemRect(nid)
rect = nid_rect.intersected(self.viewport().rect())

pm = QtGui.QPixmap(rect.size())
pm.fill(self.palette().base().color())

painter = QtGui.QPainter(pm)

option = self.viewOptions()
option.state |= QtGui.QStyle.State_Selected
option.rect = QtCore.QRect(nid_rect.topLeft() - rect.topLeft(), nid_rect.size())

self.itemDelegate().paint(painter, option, self.indexFromItem(nid))

painter.end()

# Calculate the hotspot so that the pixmap appears on top of the
# original item.
rect.adjust(self.horizontalOffset(), self.verticalOffset(), 0, 0)
hspos = self.mapFromGlobal(QtGui.QCursor.pos()) - rect.topLeft()
hspos = self.mapFromGlobal(QtGui.QCursor.pos()) - nid_rect.topLeft()

# Start the drag.
drag = QtGui.QDrag(self)
Expand Down

0 comments on commit a5ffecc

Please sign in to comment.