Correct element size, if block type or variable name is wider than block width.
authorSurkov Sergey <surkovsv93@gmail.com>
Thu, 26 Jan 2017 17:16:54 +0300
changeset 1644 976ce8c6195d
parent 1643 fc39d658bd2f
child 1645 91b7cc4b0d44
Correct element size, if block type or variable name is wider than block width.
Previously, if size corrected, element changed position to the right (or down, if height is corrected). Now upper-left corner is fixed.
editors/Viewer.py
--- a/editors/Viewer.py	Thu Jan 26 15:38:21 2017 +0300
+++ b/editors/Viewer.py	Thu Jan 26 17:16:54 2017 +0300
@@ -972,6 +972,16 @@
                 return connector.GetEdge()
         return "none"
 
+    def CorrectElementSize(self, element, width, height):
+        min_width, min_height = element.GetMinSize()
+        if width < min_width:
+            width = min_width
+        if height < min_height:
+            height = min_height
+        if element.Size != (width, height):
+            element.SetSize(width, height)
+            element.RefreshModel()
+
 #-------------------------------------------------------------------------------
 #                              Reset functions
 #-------------------------------------------------------------------------------
@@ -1384,6 +1394,7 @@
                 if not self.CreateWires(connector, instance.id, input_connector.links, remaining_instances, selection):
                     element.RefreshModel()
         element.RefreshConnectors()
+        self.CorrectElementSize(element, instance.width, instance.height)
         if selection is not None and selection[0].get(instance.id, False):
             self.SelectInGroup(element)