from argon import Argon, rgba, Texture, Framebuffer import layout from macron import macron from schema import Struct, Meta, Constant, Proxy, Mutator, Selection, roll from OpenGL.GL import * from frame import Frame, Overlay argon = Argon() argon.pos = 0,0 circle64 = argon.cache.image('circle64.png') box7 = argon.cache.patch9('box7.png') font = argon.cache.font('AnonymousPro_17') def sys_renderer(argon, node): background = node.style['background'] color = node.style['color'] if background: argon.render_rectangle(node.rect, background, color) if isinstance(node, layout.Label): font = node.style['font'] argon.render_text( node.baseline_pos, node.source, font, color, ) default = layout.default.inherit( font = font, renderer = sys_renderer,
keyword_color = cyan string_color = lime number_color = red object_color = gray malform_color = red theme = default_theme filename = (sys.argv[1] if len(sys.argv) > 1 else 'scratch.flat') if os.path.exists(filename): document = fileformat_flat.load_file(filename, mutable) else: document = mutable.Document([]) document.filename = filename argon = Argon(600, 800) #from mode import Mode, SelectionMode default = renderer.get_default_style(argon).inherit( color = whiteish, ) language = __import__('strike') EditMode = language.EditMode layouter = language.init(argon, default, theme) toolbar_height = argon.default_font.height*2 frame = Frame((0, 0, argon.width, argon.height-toolbar_height), document, layouter) frame.mode = EditMode(frame, mutable.normalize(document, False))
return layout.Row([label, layout.Column(boxes, slot_style)], struct_style) ## Utility functions def find_slot(box, struct, index): if isinstance(box, layout.Intron) and isinstance(box.controller, StructureEditor): if box.controller.struct == struct and box.controller.index == index: return box for _box in box: rt = find_slot(_box, struct, index) if rt is None: continue return rt ## Initializes the renderer and layouter. argon = Argon((600, 1100)) box7 = argon.cache.patch9('box7.png') box2 = argon.cache.patch9('box2.png') bracket2 = argon.cache.patch9('bracket2.png') def sys_renderer(argon, box): background = box.style['background'] if background: background_color = box.style['background_color'] argon.render_rectangle(box.rect, background, background_color) if isinstance(box, layout.Label): font = box.style['font'] color = box.style['color'] argon.render_text(box.baseline_pos, box.source, font, color) default = layout.default.inherit(