sub buildGrid()
print "GRID"
m.grid = createObject("roSGNode","MarkupGrid")
m.grid.translation = "[100,100]"
REM m.grid.itemComponentName = "gridItem"
m.grid.itemSize = [100,100]
m.grid.itemSpacing = [10,10]
m.grid.numColumns = 5
m.grid.numRows = 1
m.grid.content = m.content
m.top.appendChild(m.grid)
print m.grid
end sub
sub makeGridItem()
m.gridItem = createObject("roSGNode","Rectangle")
m.gridItem.color = "0xFF0000FF"
m.gridItem.width = "100"
m.gridItem.height = "100"
m.gridItem.id = "gridItem"
m.top.appendChild(m.gridItem)
end sub()
<component name = "MyPoster" extends = "Poster" >
m.grid = createObject("roSGNode","MarkupGrid")
m.grid.translation = "[100,100]"
m.grid.itemComponentName = "MyPoster"
m.gridItem = function() as Object
g = createObject("roSGNode","Rectangle")
g.width = "100"
g.height = "100"
g.color = "0xFF0000FF"
return g
end function
"tutash" wrote:
Anyway, my reasoning for asking is that I want to create MarkupGrids in code at runtime. I can use PosterGrid for my needs for now, but I'd like to have the option to point the itemComponent something other than markup.
Alas, this ain't happening.
"tutash" wrote:
It's not an objection, really, but a requirement that I have no XML-based components, and that it remain scene graph based.
"Veeta" wrote:
As far as I'm aware, you can't do it.
[spoiler=on class-name as a factory in RSG:18uh2wpi]There's a compilation step when using Scene Graph XML that only happens once on startup. During that step is where you define a component and give it a name.<component name = "MyPoster" extends = "Poster" >
Then later you refer to this component by name.m.grid = createObject("roSGNode","MarkupGrid")
m.grid.translation = "[100,100]"
m.grid.itemComponentName = "MyPoster"
What you've done with makeGridItem() is created a single instance of the Rectangle component type and given that instance a unique id of `gridItem`. MarkupGrid isn't looking at id's of object instances with itemComponentName, it's looking at the registry of defined component types.[/spoiler:18uh2wpi]