Thread Tools Display Modes
02-12-11, 11:21 PM   #1
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
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!
  Reply With Quote
02-13-11, 12:31 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
$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.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
02-13-11, 12:33 AM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
$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.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
02-13-11, 02:10 AM   #4
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
I think I understand (I think) . 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


Originally Posted by Seerah View Post
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">
  Reply With Quote
02-13-11, 10:00 AM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
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.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
02-13-11, 11:00 AM   #6
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
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 ). 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)?
  Reply With Quote
02-13-11, 01:58 PM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
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.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 02-13-11 at 02:01 PM.
  Reply With Quote
02-13-11, 04:03 PM   #8
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
Originally Posted by Xrystal View Post
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!
  Reply With Quote
02-13-11, 05:27 PM   #9
Akkorian
A Flamescale Wyrmkin
 
Akkorian's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 111
Hi Aprikot,

In your code a few posts up, you wrote:

Originally Posted by Aprikot View Post
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.
__________________
“Be humble, for you are made of earth. Be noble, for you are made of stars.”
  Reply With Quote
02-14-11, 12:17 AM   #10
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
Thanks Akkorian. That was me taking the newb approach.
  Reply With Quote
02-15-11, 01:09 AM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
To add some interesting discoveries, $parent also works with most UI methods in Lua that accepts the frame name as a string.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
02-15-11, 02:42 AM   #12
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
Yep I am starting to use it more and more in my frame creation routines.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
02-28-11, 10:27 AM   #13
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
Originally Posted by SDPhantom View Post
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?
  Reply With Quote
02-28-11, 10:41 AM   #14
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
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
__________________
Oh, the simulated horror!
  Reply With Quote
02-28-11, 11:44 AM   #15
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
Originally Posted by Aprikot View Post
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?
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.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
02-28-11, 12:42 PM   #16
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
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>
  Reply With Quote
02-28-11, 01:25 PM   #17
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
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
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
02-28-11, 03:47 PM   #18
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
Sweet, thank you
  Reply With Quote
04-15-11, 10:40 PM   #19
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
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.
  Reply With Quote
04-15-11, 10:59 PM   #20
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
http://wowprogramming.com/docs/widge...me/GetChildren
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » FrameXML $parent


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off