Skip to content

Commit

Permalink
pass data through init
Browse files Browse the repository at this point in the history
  • Loading branch information
keenanlang committed Nov 11, 2024
1 parent a57e22e commit 54fd5a0
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions gestalt/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ def __iter__(self):
return self.children.__iter__()

def place(self, child, x=None, y=None, keep_original=False):
if (child == None):
return

self.append(child, keep_original=keep_original)

child_node = self.children[-1]
Expand Down Expand Up @@ -266,7 +269,7 @@ def place(self, child, x=None, y=None, keep_original=False):
self.log("Resizing height to " + str(bottom_edge))
self["geometry"]["height"] = bottom_edge

def initApply(self):
def initApply(self, data):
pass

def positionNext(self, child):
Expand All @@ -276,7 +279,7 @@ def updateMacros(self, macros):
pass

def apply (self, generator, data={}):
self.initApply()
self.initApply(data)

self.log("Generating group node")
output = generator.generateGroup(self, macros=data)
Expand Down Expand Up @@ -349,7 +352,10 @@ def apply(self, generator, data={}):
childnode["geometry"]["width"] = int(geom["width"]) - 2 * border_size
childnode["geometry"]["height"] = int(geom["height"]) - tab_bar_height - 2 * border_size

output.place(childnode.apply(generator, data=child_macros))
widget = childnode.apply(generator, data=child_macros)

if (childnode):
output.place(widget)

return output

Expand All @@ -368,28 +374,24 @@ def __init__(self, name=None, layout={}, loc=None):
self.makeInternal(Number, "last_x", 0)
self.makeInternal(Number, "last_y", 0)

def initApply(self):
def initApply(self, data):
self["index"] = 0
self["last-x"] = 0
self["last-y"] = 0
self["padding"].apply(data)

def updateMacros(self, child_macros):
child_macros.update({"__index__" : self["index"].val()})

def apply(self, generator, data={}):
self.initApply()
self.initApply(data)

output = generator.generateGroup(self, macros=data)

repeat = output["repeat-over"]
start_at = output["start-at"]

value_var = output["variable"]

self["padding"].apply(data)

#repeat.apply(data)

macrolist = data.get(str(repeat))

try:
Expand Down Expand Up @@ -464,11 +466,13 @@ def __init__(self, name=None, layout={}, loc=None):
self.makeInternal(Number, "index-x", 0)
self.makeInternal(Number, "index-y", 0)

def initApply (self):
def initApply (self, data):
self["index-x"] = 0
self["index-y"] = 0
self["aspect-ratio"].apply(data)

super().initApply(data)

def updateMacros(self, child_macros):
super().updateMacros(child_macros)

Expand Down Expand Up @@ -519,7 +523,7 @@ def __init__(self, name=None, layout={}, flow="vertical", loc=None):
self.makeInternal(Number, "padding", 0)
self.setProperty("flow", flow, internal=True)

def initApply(self):
def initApply(self, data):
self["last-pos"] = 0

def positionNext(self, child):
Expand Down

0 comments on commit 54fd5a0

Please sign in to comment.