Double clicking a pending import zooms to its center

This commit is contained in:
David Vierra 2015-01-21 23:31:28 -10:00
parent 1878917b12
commit 93bd771575
3 changed files with 9 additions and 1 deletions

View File

@ -48,6 +48,10 @@ class PendingImport(object):
def __repr__(self):
return "%s(%r, %r)" % (self.__class__.__name__, self.schematic, self.pos)
@property
def bounds(self):
return BoundingBox(self.pos, self.schematic.getDimension().bounds.size)
class PasteImportCommand(QtGui.QUndoCommand):
def __init__(self, editorSession, pendingImport, text, *args, **kwargs):
super(PasteImportCommand, self).__init__(*args, **kwargs)

View File

@ -253,7 +253,7 @@ class MoveTool(EditorTool):
def listDoubleClicked(self, index):
item = self.importsListModel.itemFromIndex(index)
pendingImport = item.data(Qt.UserRole)
self.editorSession.editorTab.currentView().centerOnPoint(pendingImport.pos)
self.editorSession.editorTab.currentView().centerOnPoint(pendingImport.bounds.center)
_currentImport = None

View File

@ -386,6 +386,10 @@ class BoundingBox(SelectionBox):
"""
return self._size
@property
def center(self):
return self.origin + self.size * 0.5
@property
def width(self):
"""The dimension along the X axis"""