Hello,

I am working with Roassal and trying to write a cell-layout builder that
uses RTPieBuilders internally as its nested objects. The nesting docs cover
nesting RT elements, but not builders. The composition docs cover composing
builders, but not nesting them. I have a partial solution, but it is
getting increasingly hacky, to the point where it may be easier to just
duplicate the piebuilder code in my builder. Before I go down that road, I
wanted to check if there was a more natural way to nest builders.

Below is a mashup of the Roassal Examples Nesting and Pie Chart builders
that gives the basic flavor of what I am trying to accomplish. Notice that
I am creating new PieBuilders every time, running them, and extracting
their createdElements for my layout. This works well enough, but if I then
want to normalize global properties so that all pie slices with the same
property get the same color, I have no way to coordinate the newly
generated PieBuilders, as each possesses its own normalizer. Likewise, if I
have a global PieBuilder, its internal state gets trampled with each
iteration. I figured there was likely an easy way to compose builders that
I didn't know about, so I thought I would ask.

| v es b |
v := RTView new.
es := RTEllipse elementsOn: RTShape withAllSubclasses.
v addAll: es.

RTNest new
    for: es
    add: [ :group :model |
        b := RTPieBuilder new.
        b objects: RTShape withAllSubclasses.
        b slice: #numberOfMethods.
        b normalizer distinctColor.
        b view: v.
        b build.
        group addAll: b createdElements. ].

RTCellLayout new lineItemsCount: 8; on: es.
v


Thanks,
Evan

Reply via email to