WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   FrameXML $parent (https://www.wowinterface.com/forums/showthread.php?t=38911)

Aprikot 02-12-11 11:21 PM

FrameXML $parent
 
I'm new to the Blizzard_FrameXML files and as kind of a self-tutorial I'm coloring as many default UI objects as I can (via SetVertexColor). In some cases the texture names I need aren't in the XML file associated with the object I'm trying to color. For example, trying to color the little dividers on the experience bar I couldn't find anything in MainMenuBar.xml that worked, but after looking at a few action bar addons I found MainMenuXPBarDiv(1, 2, 3, etc.) which does the trick.

I finished up the action bars & unit frames, and am now on the Minimap trying to color the tracking button (border). MiniMapMailBorder & MiniMapBattlefieldBorder appear in Minimap.xml, but the texture name for the tracking border is "$parentBorder" (yet all three share the same texure file path: Interface\Minimap\MiniMap-TrackingBorder). I also see other "$parent" strings (Icon, Background, etc) all over, and wondering how to find what they refer to (and how I can refer to whatever that is in my Lua function). Thanks!

Xrystal 02-13-11 12:31 AM

$parent is a substitute for the name of the parent object.

EG.

Main Frame Name = MyFrame
A Button associated with that frame that will act as an OK button = MyFrameButton. When the frame is created either using lua or xml with a parent value set then $parentButton will be the same thing.

Seerah 02-13-11 12:33 AM

$parent is a key that gets replaced by the name of that widget's parent.

I don't use XML, so this is just some generic pseudo-code, but I think you'll get the gist.

Code:

<Frame="MyFrame">
    <Button="$parentButton">
          <Scripts>
              <OnClick>--dostuff</OnClick>
          </Scripts>
    </Button>
</Frame>

The button's name is MyFrameButton.

To get the name of something's parent via Lua, you do widget:GetParent().


/edit: heh - Xrystal and I used the same example!
/edit2: note - $parent only works in XML, not Lua.

Aprikot 02-13-11 02:10 AM

I think I understand (I think) :p. Thank you both. What I'm doing is all in Lua, I'm just perusing the XML files to find the correct name of the thing I'm trying to color.

For example (using red for dramatic effect :)):
Code:

for _, x in pairs({MinimapBorder, MiniMapMailBorder}) do
    if x:GetObjectType() == "Texture" then
        x:SetVertexColor(1, 0, 0)
    end
end



Quote:

Originally Posted by Seerah (Post 229594)
To get the name of something's parent via Lua, you do widget:GetParent().

So if I wanted to color the tracking button border, would it be something like this:

Code:

for _, x in pairs({MinimapBorder, MiniMapMailBorder, MiniMapTracking:GetParent(border)}) do
    if x:GetObjectType() == "Texture" then
        x:SetVertexColor(1, 0, 0)
    end
end

(I've got something wrong there cuz that no worky.) Here's the part of Minimap.xml I'm looking at:

Code:

<Frame name="MiniMapTracking">
...
<Layer level="BORDER">
<Texture name="$parentBorder" urgency="5" file="Interface\Minimap\MiniMap-TrackingBorder">


Xrystal 02-13-11 10:00 AM

In your example if you look at the XML file you have

<Frame name = "MiniMapTracking">
...
<Texture name="$parentBorder" ....
....

This is the same as

<Frame name = "MiniMapTracking">
...
<Texture name="MiniMapTrackingBorder" ....
....


So using MiniMapTrackingBorder will get the object that is the border.

Aprikot 02-13-11 11:00 AM

Thanks Xrystal, it's working! MiniMapTrackingBorder doesn't work, but after doing another /framestack I realized the object is MiniMapTrackingButton (which doesn't appear at all in Minimap.xml :confused:). Taking what you said (adding Border) gives me the right object (MiniMapTrackingButtonBorder).

Looking again at Minimap.xml, I see the frame after MiniMapTracking is named $parentDropDown:

Code:

<Frame name="$parentDropDown" inherits="UIDropDownMenuTemplate" clampedToScreen="true" id="1" hidden="true">
...
    <Button name="$parentButton">
    ...
        <Layer level="BORDER">
            <Texture name="$parentBorder" urgency="5" file="Interface\Minimap\MiniMapTrackingBorder">

Does MiniMapTrackingButtonBorder equate to $parentBorder of $parentButton in this case? Aside from doing an /fstack on the Mninmap and finding MiniMapTrackingButton, how can one tell that $parentDropDown leads to the tracking button border (assuming it does)?

Xrystal 02-13-11 01:58 PM

Yes .. $parentBorder is a child of $parentButton which in turn is a child of $parentDropDown from your example ... for it to show up as MiniMapTrackingButtonBorder means that somewhere in that XML there is something with either the name MiniMap and a $parentTracking child or something with the name MiniMapTracking

The XML file is structured so that <> tags are within each other so that inner tags are children of the tags surrounding them.

EG:

<Frame name="MyFrame">
<Frames>
<Frame name="$parentBackground">
<Layer level = "BORDER">
<Texture name="$parentTexture">
</Texture>
</Layer>
</Frame>
</Frames>
</Frame>

In this small example to access the full name of the texture you would have to discern each parents name portion until you get back to a full name.

MyFrame
MyFrameBackground
MyFrameBackgroundTexture

As you can see $parent is simply a way to use the name of the surrounding tag objects name without remembering how exactly you spelt it etc. Changing the base objects name will automatically reflect down the tags.

If you changed MyFrame to MyMiniMap it would change the names as follows:
MyMiniMap
MyMiniMapBackground
MyMiniMapBackgroundTexture

I hope that helps you understand it a bit more.

Aprikot 02-13-11 04:03 PM

Quote:

Originally Posted by Xrystal (Post 229628)
to access the full name of the texture you would have to discern each parents name portion until you get back to a full name.

This is very helpful, ty! :)

Akkorian 02-13-11 05:27 PM

Hi Aprikot,

In your code a few posts up, you wrote:

Quote:

Originally Posted by Aprikot (Post 229597)
MiniMapTracking:GetParent(border)

I just wanted to point out that the GetParent method doesn’t take any arguments. A frame (or texture, or fontstring, or animation group) can only have one parent, so that’s what GetParent gives you. :)

Aprikot 02-14-11 12:17 AM

Thanks Akkorian. That was me taking the newb approach. :p

SDPhantom 02-15-11 01:09 AM

To add some interesting discoveries, $parent also works with most UI methods in Lua that accepts the frame name as a string.

Xrystal 02-15-11 02:42 AM

Yep I am starting to use it more and more in my frame creation routines.

Aprikot 02-28-11 10:27 AM

Quote:

Originally Posted by SDPhantom (Post 229784)
To add some interesting discoveries, $parent also works with most UI methods in Lua that accepts the frame name as a string.

In the MiniMapTrackingButtonBorder example, how would one specify MiniMapTracking + $parentButton + $parentBorder? Is it just a matter of concatenation ("MiniMapTracking".."$parentButton".."$parentBorder")...or is it not that simple? :p

Ailae 02-28-11 10:41 AM

It works exactly the same as in xml.

Code:

local a = CreateFrame("Frame", "MyFrame", UIParent)
local b = CreateFrame("Button", "$parentButton", a)
local c = b:CreateTexture("$parentTexture", "OVERLAY")

a) MyFrame
b) MyFrameButton
c) MyFrameButtonTexture

EDIT: Maybe I misunderstood your question.. leaving it anyway. :P

Xrystal 02-28-11 11:44 AM

Quote:

Originally Posted by Aprikot (Post 230825)
In the MiniMapTrackingButtonBorder example, how would one specify MiniMapTracking + $parentButton + $parentBorder? Is it just a matter of concatenation ("MiniMapTracking".."$parentButton".."$parentBorder")...or is it not that simple? :p

Nope, it would be the case of removing $parent and replacing it with the name of the parent frame itself.

So, if MiniMapTracking was the name of the main frame and it had a button with the name $parentButton as a child then it's full name would be MiniMapTrackingButton. Likewise if $parentBorder is the child of $parentButton then tag Border at the end of the Buttons full name.

Aprikot 02-28-11 12:42 PM

Cool. So to access MiniMapTrackingButtonBorder in Lua without using the fully qualified texture name, would it look like this (using Ailae's example):

lua Code:
  1. local a = CreateFrame("Button", "$parentButton", MiniMapTracking)
  2. local b = a:CreateTexture("$parentBorder", "BORDER")

(MiniMapTracking frame in FrameXML\Minimap.xml for reference):

xml Code:
  1. <Frame name="MiniMapTracking">
  2.       <Size x="32" y="32"/>
  3.       <Anchors>
  4.             <Anchor point="TOPLEFT">
  5.                   <Offset x="9" y="-45"/>
  6.             </Anchor>
  7.       </Anchors>
  8.       <Layers>
  9.             <Layer level="BACKGROUND">
  10.                   <Texture name="$parentBackground" urgency="5" file="Interface\Minimap\UI-Minimap-Background">
  11.                         <Size x="25" y="25"/>
  12.                         <Anchors>
  13.                               <Anchor point="TOPLEFT">
  14.                                     <Offset x="2" y="-4"/>
  15.                               </Anchor>
  16.                         </Anchors>
  17.                         <Color r="1" g="1" b="1" a="0.6"/>
  18.                   </Texture>
  19.             </Layer>
  20.             <Layer level="ARTWORK">
  21.                   <Texture name="$parentIcon" urgency="5" file="Interface\Minimap\Tracking\None">
  22.                         <Size x="20" y="20"/>
  23.                         <Anchors>
  24.                               <Anchor point="TOPLEFT">
  25.                                     <Offset x="6" y="-6"/>
  26.                               </Anchor>
  27.                         </Anchors>
  28.                   </Texture>
  29.             </Layer>
  30.             <Layer level="OVERLAY">
  31.                   <Texture name="$parentIconOverlay" hidden="true">
  32.                         <Anchors>
  33.                               <Anchor point="TOPLEFT" relativeTo="$parentIcon"/>
  34.                               <Anchor point="BOTTOMRIGHT" relativeTo="$parentIcon"/>
  35.                         </Anchors>
  36.                         <Color r="0.0" g="0.0" b="0.0" a="0.5"/>
  37.                   </Texture>
  38.             </Layer>
  39.       </Layers>
  40.       <Frames>
  41.             <Frame name="$parentDropDown" inherits="UIDropDownMenuTemplate" clampedToScreen="true" id="1" hidden="true">
  42.                   <Scripts>
  43.                         <OnLoad function="MiniMapTrackingDropDown_OnLoad"/>
  44.                   </Scripts>
  45.             </Frame>
  46.             <Button name="$parentButton">
  47.                   <Size x="32" y="32"/>
  48.                   <Anchors>
  49.                         <Anchor point="TOPLEFT"/>
  50.                   </Anchors>
  51.                   <Layers>
  52.                         <Layer level="BORDER">
  53.                               <Texture name="$parentBorder" urgency="5" file="Interface\Minimap\MiniMap-TrackingBorder">
  54.                                     <Size x="54" y="54"/>
  55.                                     <Anchors>
  56.                                           <Anchor point="TOPLEFT"/>
  57.                                     </Anchors>
  58.                               </Texture>
  59.                         </Layer>
  60.                         <Layer level="OVERLAY">
  61.                               <Texture name="$parentShine" urgency="5" file="Interface\ComboFrame\ComboPoint" alphaMode="ADD" hidden="true">
  62.                                     <Size x="27" y="27"/>
  63.                                     <Anchors>
  64.                                           <Anchor point="TOPLEFT">
  65.                                                 <Offset x="2" y="-2"/>
  66.                                           </Anchor>
  67.                                     </Anchors>
  68.                                     <TexCoords left="0.5625" right="1" top="0" bottom="1"/>
  69.                               </Texture>
  70.                         </Layer>
  71.                   </Layers>
  72.                   <Scripts>
  73.                         <OnLoad>gisterEvent("MINIMAP_UPDATE_TRACKING");MiniMapTracking_Update();</OnLoad>
  74.                         <OnEvent function="MiniMapTracking_Update"/>
  75.                         <OnClick>ToggleDropDownMenu(1, nil, MiniMapTrackingDropDown, "MiniMapTracking", 0, -5);PlaySound("igMainMenuOptionCheckBoxOn");</OnClick>
  76.                         <OnMouseDown>TrackingIcon:SetPoint("TOPLEFT", MiniMapTracking, "TOPLEFT", 8, -8);TrackingIconOverlay:Show();</OnMouseDown>
  77.                         <OnMouseUp>TrackingIcon:SetPoint("TOPLEFT", MiniMapTracking, "TOPLEFT", 6, -6);TrackingIconOverlay:Hide();</OnMouseUp>
  78.                         <OnEnter>ltip:SetOwner(self, "ANCHOR_LEFT");ltip:SetText(TRACKING, 1, 1, 1);ltip:AddLine(MINIMAP_TRACKING_TOOLTIP_NONE, nil, nil, nil, 1);ltip:Show();</OnEnter>
  79.                         <OnLeave>ltip:Hide();</OnLeave>
  80.                   </Scripts>
  81.                   <HighlightTexture alphaMode="ADD" file="Interface\Minimap\UI-Minimap-ZoomButton-Highlight"/>
  82.             </Button>
  83.       </Frames>
  84. </Frame>

Xrystal 02-28-11 01:25 PM

Yes that would be the lua equivalent for those particular elements.

Looking at the xml itself the full hierarchy would be as follows:

Code:

Main Frame        : MiniMapTracking
|__Texture 1      : $parentBackground  -- $parent = MiniMapTracking
|__Texture 2      : $parentIcon
|__Texture 3      : $parentIconOverlay
|__Child Frame 1 : $parentDropDown
|__Child Frame 2 : $parentButton
    |__ Texture 4 : $parentBorder  -- $parent = MiniMapTrackingButton
    |__ Texture 5 : $parentShine


Aprikot 02-28-11 03:47 PM

Sweet, thank you

Aprikot 04-15-11 10:40 PM

I recently resumed pursuit of identifying & recoloring default UI textures, and am again confounded by the Minimap buttons. I'm as yet unable to figure out texture names for the below items (clockwise from top):


  1. MiniMapWorldMapButton
  2. GameTimeFrame
  3. MinimapZoomIn
  4. MinimapZoomOut
  5. TimeManagerClockButton
Most of the other textures (in red) are explicitly defined in FrameXML\Minimap.xml. The Mail button border for example:
Code:

<Texture name="MiniMapMailBorder" urgency="5" file="Interface\Minimap\MiniMap-TrackingBorder">
can then be manipulated in Lua via its given name (MiniMapMailBorder:SetVertexColor(), etc).

The tracking button was an exception, which prompted this thread, and introduced me to tracing parent/child relationships in FrameXML.

For the Zoom In/Out buttons, I see a different sort of exception: the textures appear to have no name at all, explicit or otherwise. For example, the only texture references contained in <Button name="MinimapZoomOut"></Button> are:

Code:

<NormalTexture urgency="5" file="Interface\Minimap\UI-Minimap-ZoomOutButton-Up"/>
<PushedTexture file="Interface\Minimap\UI-Minimap-ZoomOutButton-Down"/>
<DisabledTexture file="Interface\Minimap\UI-Minimap-ZoomOutButton-Disabled"/>
<HighlightTexture alphaMode="ADD" file="Interface\Minimap\UI-Minimap-ZoomButton-Highlight"/>

Obviously these textures exist, and I believe they are or can be called via Lua, I'm just not sure how. Any thoughts are much appreciated.

Seerah 04-15-11 10:59 PM

http://wowprogramming.com/docs/widge...me/GetChildren :)


All times are GMT -6. The time now is 09:31 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI