WoW:XML/Frame: Difference between revisions

363 bytes added ,  7 September 2022
mNo edit summary
Line 104: Line 104:


=== Parents ===
=== Parents ===
Frames have a parent frame. A complex visual element is likely formed of multiple Frames, and it's considered good design to designate a common parent Frame amongst them, and have the rest use that (or its children) as their parent. Well behaved UI AddOns will normally want their top level parent frames set expressly to 'UIParent'. Failure to do so means, amongst other things, that the AddOn's frame won't vanish when the Hide UI key is pressed.  
Frames can have a parent frame. By default, the parent of any child frame is the frame it is defined in.


==== Visibility ====
<pre>
Each Frame can be shown and hidden, if a Frame is Hidden, then it and all of its children cease to be visible. It's far simpler to show and hide the parent frame of a complex set, than to try and manage the visibility of many elements independently.
<Frame name="Fame1">
<Frames>
<Frame name="Fame2"><!-- Frame2 'parent' is automatically Frame1 -->
</Frame>
</Frames>
</Frame>
</pre>


==== Scaling ====
; Visibility
Each Frame can be shown and hidden. If a Frame is Hidden, then it and all of its children cease to be visible. It's far simpler to show and hide the parent frame of a complex set, than to try and manage the visibility of many elements independently.
 
; Scaling
The UI engine is built to perform automatic scaling of UI elements, the entire UI (actually, the UIParent frame, which most frames are children of), or any component of it can be enlarged or shrunk to fit on a screen appropriately.  Frames are scaled and located relative to their parent rather than the whole screen, which means that you only need to worry about how your subcomponents relate to each other, and then your component can be placed and sized any way necessary.
The UI engine is built to perform automatic scaling of UI elements, the entire UI (actually, the UIParent frame, which most frames are children of), or any component of it can be enlarged or shrunk to fit on a screen appropriately.  Frames are scaled and located relative to their parent rather than the whole screen, which means that you only need to worry about how your subcomponents relate to each other, and then your component can be placed and sized any way necessary.
; Notes
A complex visual element is formed of multiple Frames, and it's considered good design to have a related parent frame amongst them. And have the rest use that (or its children) as their parent. By default, all child frames already use the parent they are defined in as their parent.  Well behaved UI AddOns will normally want their top-level parent frame, the highest-level frame that is not defined in another frame, to be set expressly to 'UIParent'. Failure to do so means, amongst other things, that the AddOn's frame won't vanish when the Hide UI key is pressed.


=== Frame Levels ===
=== Frame Levels ===