I'm currently trying to develop an addon that tracks cool-downs of abilities on your bar. I have the main window made with two controls representing the front and back bar. Each of the two controls representing a bar will have 5 children containing the ability texture and a label overlapping. Instead of duplicating that layout 5 times I figured I could use inheritance but I don't quite understand how it works.
Currently my virtual control is (missing the label for now):
Lua Code:
<Control name="BarTracker_Slot" virtual="true">
<Dimensions x="50" y="50"/>
<Controls>
<Texture name="$(parent)Tex">
<Anchor point="CENTER" relativePoint="CENTER"/>
</Texture>
</Controls>
</Control>
And my top level is:
Lua Code:
<TopLevelControl name="BarTrackerWindow">
<Controls>
<Backdrop name="$(parent)BG" alpha="1" centerColor="40000000" edgeColor="60000000" clampedToScreen="true" movable="true" mouseEnabled="true">
<Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="CENTER" offsetX="0" offsetY="0"/>
<Dimensions x="250" y="100"/>
<Edge edgeSize="1"/>
<OnMouseEnter>WINDOW_MANAGER:SetMouseCursor(12);</OnMouseEnter>
<OnMouseExit>WINDOW_MANAGER:SetMouseCursor(0);</OnMouseExit>
<OnMoveStop>BarTracker.savePosition()</OnMoveStop>
</Backdrop>
<Control name="$(parent)Front">
<Anchor point="TOPLEFT" relativePoint="TOPLEFT" relativeTo="$(parent)BG"/>
<Dimensions x="250" y="50"/>
</Control>
<Control name="$(parent)Back">
<Anchor point="TOPLEFT" relativePoint="TOPLEFT" relativeTo="$(parent)Front"/>
<Dimensions x="250" y="50"/>
</Control>
</TopLevelControl>
So how would I use the virtual in a loop to add it to the Front and Back control? I've been looking through CMX's code to try and figure it out but there is a lot and I can't figure out where they actually add the virtuals.
The other thing throwing me off is how would I reference it? The components all have their own name so the texture is "BarTracker_SlotTex". But how would I differentiate it while generating the virtual components since there will be 10 in total?