예제 #1
0
파일: editor.py 프로젝트: cheery/essence
 def layout_star(self, obj, index, context, plac="*"):
     context = push(context, (obj, index))
     hole = obj.holes[index]
     for partial in hole.partials:
         frame = self.layout_hook(partial.a, context)
         frame.hole = partial
         yield frame
     if len(hole.a) == 0:
         frame = string(self.font(plac).mul(gray))
         frame.hole = hole
         yield frame
예제 #2
0
파일: editor.py 프로젝트: cheery/essence
    def default_layout_hook(self, obj, context):
        if obj is None:
            return group([string(self.font('none'))], padding = (5, 5, 5, 5))
        if not iselement(obj):
            return string(self.font(obj))

        # this element is UNKNOWN, therefore we are doing this...
        name = string(self.font('{%s}' % obj.name).mul(red))
        holes = []
        for index, hole in enumerate(obj.holes):
            if isinstance(hole, dot):
                holes.append(self.layout_dot(obj, index, context))
            if isinstance(hole, star):
                frames = self.layout_star(obj, index, context)
                holes.append(group(delimit(frames, yglue, 4,0),
                    padding = (5, 5, 5, 5),
                ))

        return group(delimit([name] + holes, yglue, 0, 0)
        )