diff -r d9ed42e44a50 -r 18cd1357e8d3 dialogs/BlockPreviewDialog.py --- a/dialogs/BlockPreviewDialog.py Wed Jun 12 11:32:44 2013 +0200 +++ b/dialogs/BlockPreviewDialog.py Wed Jun 12 22:23:57 2013 +0200 @@ -269,21 +269,24 @@ height = max(self.MinElementSize[1], min_height) self.Element.SetSize(width, height) + # Get element bounding box to center in preview + bbox = self.Element.GetBoundingBox() + # Get Preview panel size client_size = self.Preview.GetClientSize() # If graphic element is too big to be displayed in preview panel, # calculate preview panel scale so that graphic element fit inside - scale = (max(float(width) / client_size.width, - float(height) / client_size.height) * 1.2 - if width * 1.2 > client_size.width or - height * 1.2 > client_size.height + scale = (max(float(bbox.width) / client_size.width, + float(bbox.height) / client_size.height) * 1.2 + if bbox.width * 1.1 > client_size.width or + bbox.height * 1.1 > client_size.height else 1.0) dc.SetUserScale(1.0 / scale, 1.0 / scale) # Center graphic element in preview panel - x = int(client_size.width * scale - width) / 2 - y = int(client_size.height * scale - height) / 2 + x = int(client_size.width * scale - bbox.width) / 2 + y = int(client_size.height * scale - bbox.height) / 2 self.Element.SetPosition(x, y) # Draw graphic element