Hello folks of the Reflex steering committee.
I'm just checking in to report on my progress and start some serious architectural discussions, the two things we like the most.
LayoutI've completed a standalone Layout system for Reflex. It supports all of the width/height features of Flex, run-time swappable Layout algorithms, is built on interfaces and utilities, is completely customizable and replaceable, and has some really nice performance already (without much optimization yet).
The Layout system is broken up into 3 pieces:
- RenderEvent: this utility offers the ability to invalidate and then validate through the event bus, reserving complex processing to happen just once per frame. Just like stage.invalidate() causes a dispatch of the "render" event before the next screen redraw, RenderEvent.invalidate(displayObject, "type") dispatches a "type" event from the displayObject just before the next screen redraw. Types must first be registered with a render phase, a separate phase in the render cycle. For example, in the current implementation there are two phases registered:
RenderEvent.registerPhase(MEASURE, 0x80, false);
RenderEvent.registerPhase(LAYOUT, 0x40, true);
where the parameters are 1) phase type or event type, 2) priority, determining the order in which each phase will occur and 3) ascending in depth, determining the order to dispatch events. The benefits of RenderEvent over stage.invalidate() are that phases are complete resolved before the next phase, that only the display objects that are invalidated receive the event (no adding/removing listeners all the time) and the ordering by depth, which allows a huge performance advantage in a Layout system. Other benefits are that rendering still happens during stage resizing, items that are invalidated during a render cycle are still resolved in that cycle (if they haven't yet been passed up), and the utility offers complete flexibility for extended use.
- ILayout: this layout object targets any DisplayObject, essentially extending its functionality without imposing a required baseclass or interface. The Layout object exposes all of the expected layout properties such as width/height padding and margin, and ties into the "layout" and "measure" render phases. Logic in the Layout is confined to laying out the display object it targets, such as restricting its width/height to fall within the min/max bounds. The Layout object also has an "algorithm" property which may optionally tie in a ILayoutAlgorithm.
- ILayoutAlgorithm: a measure and layout algorithm class that target a DisplayObjectContainer, positioning and aligning its children uniformly.
The default Layout in Reflex is Block, a layout which focuses on organizing display objects into rectangular areas on the screen. Block has all of the width/height constraints, margin and padding, and other features that accompany this type of layout. There will be various layout algorithms that go with this Layout, such as VerticalStack, HorizontalStack, Tile, etc. The current default layout algorithm is Dock, which provides a mix of stacking and tiling within one container.
I have some examples in the GITHUB repo under the development/ directory which will be moving to another repo that Ben created.
Components and BehaviorsI've refactored and built the Button and ScrollBar behaviors, the logic that make these components behave appropriately. Some of the wiring is hardcoded in the implementation until the proper solution is determined. The coolest thing about these behavior implementations is that they simply target InteractiveObjects. This means, if you ever wanted to, you can build a ScrollBar out of Textfields or out of a pile of Flex Canvas's. The Behavior system doesn't know or care about "UIComponent" and doesn't need to. This concept hinges on another discussion I'll bring up in a separate thread.
ModelsThere are a handful of common models that make up most/all components. The ScrollBar, Slider, ProgressBar, NumericStepper, MP3 Player and other similar components all represent some type of
position. By providing a common IPosition model I've reduced repetitive code and centralized logic and testing. Best of all is that similar components share common API's and are fully compatible with each other, making binding and cross-implementations easy.
SkinSo far all of my skinning has come from Flash Professional which has made it really easy and light. It's great that it has been so easy and that I can test so thoroughly without depending on a base component class.
That's it for now. I'm planning on putting a lot more out here on the list then I have been so be prepared. I'm happy with the progress and hope to see it continue.
Tyler Wright