steeffeen-zz / FancyManiaLinks

ManiaLink Framework for Object-Based XML Generation
http://steeffeen.github.io/FancyManiaLinks/
GNU General Public License v3.0
6 stars 4 forks source link

Framemodel features #41

Open PRGfx opened 7 years ago

PRGfx commented 7 years ago

The framemodel is represented incorrectly: in most aspects a framemodel is exactly like a frame, which means it can has any attribute a frame can have (pos, size, id, class, data-, hidden, scale, rot, halign, valign). A frameinstance will override these values[1] (or merge them as in the case of classes and data-attributes), so additionally FrameInstance objects should represent this behaviour for consistency. (The data- and class-behaviour is new in MLv3.)

To allow for the feature above I would suggest some sort of mechanism to retrieve a framemodel by its modelid (as you don't require the object instance in a FrameInstance object). Keep in mind that framemodels can be nested so unfortunately something as Manialink::children.filter(instanceof FrameModel) would be insufficient.

On a side-note I would expect the FrameInstance to get a model in the constructor, as it would encourage the more OO approach on this matter rather than optionally setting the model later. I suppose you want to keep the modelId feature for compatibility reasons.

[1] size and alignment affect the frame-clipping and are currently not overridden by frameinstance which I believe to be a bug (https://forum.maniaplanet.com/viewtopic.php?f=559&t=41195&p=283702#p283702)

steeffeen-zz commented 7 years ago

Many thanks for the comments! I will implement this stuff in FML v3. (FML v2 still supports PHP 5.3 which doesn't have Traits that make sharing features between classes easier. Beginning with FML v3 I will only support PHP 5.4 to start using Traits. Furthermore the changes sound like being incompatible so we need a major version increase to implement them.)