On Thu, Sep 18, 2014 at 11:03 AM, Alex Harui <aha...@adobe.com> wrote:
> > > On 9/18/14 10:47 AM, "OmPrakash Muppirala" <bigosma...@gmail.com> wrote: > > >On Thu, Sep 18, 2014 at 9:07 AM, Alex Harui <aha...@adobe.com> wrote: > > > >> BTW, I was thinking about this some moreŠ > >> > >> I haven't looked at your code, but are GraphicShapes actually allowed to > >> be children of any container? Or do they have to be children of a > >> GraphicsContainer? If the latter, then they shouldn't implement IUIBase > >> and the developer may have to first place a GraphicsContainer in the DOM > >> to contain them. > >> > >> > >The plan is to support both. GraphicShape is the base class for > >individual > >shapes like Rect, Ellipse, etc. It is also the base class for > >GraphicsContainer which exposes methods like drawRect, drawEllipse, etc. > >In the former case, Rects can be directly added to a container. In the > >latter case, GraphicsContainer can be added to a container. > I guess I was expecting that you could declaratively describe a complex > graphic and do something like: > > <GraphicsContainer> > <Rect ..> > <Circle ..> > <Path ..> > </GraphicsContainer> > > Right, this is essentially FXG. I want to support this, but don't really want to restrict being able to add Rect to a GraphicsContainer. > I would then think the child Rect, Circle and Path shouldn't be heavy. > But I also see the need to have a single shape as a child of a container > and mixed in with other components. > Yup, that is desirable. > > What about doing something similar to Spark? Spark has a BitmapImage > graphic primitive and an Image component. FlexJS could have a Rect > component as well as a Rect graphic element that only can be a child of a > GraphicsContainer. The Rect component can just be a UIBase that is > composed of a GraphicsContainer child with a Rect in it. That would be > consistent with the composition philosophy of FlexJS: common patterns get > composited into Components and can be further optimized if needed. > So, in this case, GraphicShape would implement IUIBase. RectElement, EllipseElement, etc. would extend GraphicShape. GraphicsContainer extends UIBase and would take in only GraphicShapes as children. Is it possible to enforce this during compilation? Or would we have to rely on runtime exceptions? Or we could just add a addShape() method to GraphicsContainer to enforce this. How would we suppress addElement() in that case? Rect component extends GraphicsContainer which extends UIBase. It would be compose one RectElement. Is that the way you see it? Thanks, Om > > Thoughts? > -Alex > >