コード例 #1
0
ファイル: assignicons.py プロジェクト: markedel/python-g
 def calcLayouts(self):
     bodyWidth, bodyHeight = self.bodySize
     valueListLayouts = self.valuesList.calcLayouts()
     targetIcon = self.sites.targetIcon.att
     tgtLayouts = [None] if targetIcon is None else targetIcon.calcLayouts()
     layouts = []
     for valueListLayout, tgtLayout in iconlayout.allCombinations(
         (valueListLayouts, tgtLayouts)):
         layout = iconlayout.Layout(self, bodyWidth, bodyHeight, 1)
         layout.addSubLayout(tgtLayout, 'targetIcon', 0, 0)
         tgtWidth = icon.EMPTY_ARG_WIDTH if tgtLayout is None else tgtLayout.width
         valuesXOffset = tgtWidth - 1 + bodyWidth - 1
         valueListLayout.mergeInto(layout, valuesXOffset, 0)
         layout.width = valuesXOffset + valueListLayout.width - 1
         layout.targetWidth = tgtWidth
         layouts.append(layout)
     return self.debugLayoutFilter(layouts)
コード例 #2
0
 def calcLayouts(self):
     opWidth, opHeight = self.opImg.size
     lArg = self.leftArg()
     lArgLayouts = [None] if lArg is None else lArg.calcLayouts()
     rArg = self.rightArg()
     rArgLayouts = [None] if rArg is None else rArg.calcLayouts()
     layouts = []
     for lArgLayout, rArgLayout in iconlayout.allCombinations(
         (lArgLayouts, rArgLayouts)):
         layout = iconlayout.Layout(self, opWidth, opHeight, opHeight // 2)
         layout.addSubLayout(lArgLayout, "leftArg", 0, 0)
         lArgWidth = icon.EMPTY_ARG_WIDTH if lArgLayout is None else lArgLayout.width
         layout.lArgWidth = lArgWidth
         rArgSiteX = lArgWidth - 1 + opWidth - 1
         layout.addSubLayout(rArgLayout, "rightArg", rArgSiteX, 0)
         rArgWidth = icon.EMPTY_ARG_WIDTH if rArgLayout is None else rArgLayout.width
         layout.width = rArgSiteX + rArgWidth
         layouts.append(layout)
     return self.debugLayoutFilter(layouts)
コード例 #3
0
ファイル: assignicons.py プロジェクト: markedel/python-g
 def calcLayouts(self):
     opWidth, opHeight = self.opSize
     tgtListsLayouts = [tgtList.calcLayouts() for tgtList in self.tgtLists]
     valueLayouts = self.valueList.calcLayouts()
     layouts = []
     for valueLayout, *tgtLayouts in iconlayout.allCombinations(
         (valueLayouts, *tgtListsLayouts)):
         layout = iconlayout.Layout(self, opWidth, opHeight, opHeight // 2)
         # Calculate for assignment target lists (each clause of =)
         if tgtLayouts[0] is not None and len(tgtLayouts[0].rowWidths) >= 2:
             x = 0  # If first target group includes spine, don't offset
         else:
             x = inpSeqImage.width - 1
         for i, tgtLayout in enumerate(tgtLayouts):
             tgtLayout.mergeInto(layout, x, 0)
             x += tgtLayout.width + opWidth - 2
         # Calculate layout for assignment value(s)
         layout.width = x + 1
         valueLayout.mergeInto(layout, x, 0)
         layouts.append(layout)
     return self.debugLayoutFilter(layouts)
コード例 #4
0
 def calcLayouts(self):
     singleParenWidth, height = self.bodySize
     argIcon = self.sites.argIcon.att
     argLayouts = [None] if argIcon is None else argIcon.calcLayouts()
     if self.closed and self.sites.attrIcon.att is not None:
         attrLayouts = self.sites.attrIcon.att.calcLayouts()
     else:
         attrLayouts = [None]
     layouts = []
     for argLayout, attrLayout in iconlayout.allCombinations(
         (argLayouts, attrLayouts)):
         width = singleParenWidth
         layout = iconlayout.Layout(self, width, height, height // 2)
         layout.addSubLayout(argLayout, 'argIcon', singleParenWidth - 1, 0)
         width += icon.EMPTY_ARG_WIDTH if argLayout is None else argLayout.width - 1
         if self.closed:
             width += singleParenWidth - 1
             layout.width = width
             layout.addSubLayout(attrLayout, 'attrIcon',
                                 width - icon.ATTR_SITE_DEPTH,
                                 icon.ATTR_SITE_OFFSET)
         layouts.append(layout)
     return self.debugLayoutFilter(layouts)
コード例 #5
0
 def calcLayouts(self):
     indexLayouts = stepLayouts = upperLayouts = attrLayouts = [None]
     if self.sites.indexIcon.att is not None:
         indexLayouts = self.sites.indexIcon.att.calcLayouts()
     if hasattr(self.sites,
                'upperIcon') and self.sites.upperIcon.att is not None:
         upperLayouts = self.sites.upperIcon.att.calcLayouts()
     if hasattr(self.sites,
                'stepIcon') and self.sites.stepIcon.att is not None:
         stepLayouts = self.sites.stepIcon.att.calcLayouts()
     if self.closed and self.sites.attrIcon.att is not None:
         attrLayouts = self.sites.attrIcon.att.calcLayouts()
     layouts = []
     for indexLayout, upperLayout, stepLayout, attrLayout in iconlayout.allCombinations(
         (indexLayouts, upperLayouts, stepLayouts, attrLayouts)):
         if indexLayout is None:
             if hasattr(self.sites, 'upperIcon'):
                 indexWidth = SLICE_EMPTY_ARG_WIDTH
             else:
                 indexWidth = icon.LIST_EMPTY_ARG_WIDTH  # Emphasize missing argument(s)
         else:
             indexWidth = indexLayout.width - 1
         if upperLayout is None:
             if hasattr(self.sites, 'upperIcon'):
                 upperWidth = icon.colonImage.width + SLICE_EMPTY_ARG_WIDTH - 2
             else:
                 upperWidth = 0
         else:
             upperWidth = icon.colonImage.width + upperLayout.width - 2
         if stepLayout is None:
             if hasattr(self.sites, 'stepIcon'):
                 stepWidth = icon.colonImage.width + SLICE_EMPTY_ARG_WIDTH - 2
             else:
                 stepWidth = 0
         else:
             stepWidth = icon.colonImage.width + stepLayout.width - 2
         rBrktWidth = subscriptRBktImage.width - 1 if self.closed else 0
         totalWidth = subscriptLBktImage.width + indexWidth + upperWidth + \
                      stepWidth + rBrktWidth - 1 + icon.ATTR_SITE_DEPTH
         x, height = subscriptLBktImage.size
         x -= 1  # Icon overlap
         layout = iconlayout.Layout(self, totalWidth, height,
                                    height // 2 + icon.ATTR_SITE_OFFSET)
         layout.addSubLayout(indexLayout, 'indexIcon', x,
                             -icon.ATTR_SITE_OFFSET)
         x += indexWidth
         if upperWidth > 0:
             layout.addSubLayout(upperLayout, 'upperIcon',
                                 x + icon.colonImage.width - 1,
                                 -icon.ATTR_SITE_OFFSET)
             x += upperWidth
         if stepWidth > 0:
             layout.addSubLayout(stepLayout, 'stepIcon',
                                 x + icon.colonImage.width - 1,
                                 -icon.ATTR_SITE_OFFSET)
         if self.closed:
             layout.addSubLayout(attrLayout, 'attrIcon', layout.width - 1,
                                 0)
         layout.argWidths = [indexWidth, upperWidth, stepWidth]
         layouts.append(layout)
     return self.debugLayoutFilter(layouts)