Thread Tools Display Modes
04-29-10, 05:33 AM   #1
Crowfeather
A Fallenroot Satyr
 
Crowfeather's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2008
Posts: 28
Creating complex frames

Iīm trying to write a new version of the long since abandoned SW_UniLog (which was part of the SW_Stats damage meters). As first step to do this Iīd like to create a move- and resizable frame that holds a table you can scroll through.

Iīve been trying to use the original SW_UniLog.xml file as reference but didnīt get very far. If one of the more experienced AddOn writers could help me with a step by step explantion how to do this Iīd be very grateful.

Also - Iīm trying to use Ace3 whereever reasonably applicable but couldnīt find a library that could be used to make creating such frames easier and in a more consistant way with how most other Ace AddOns are written. The Ace documentation seems to be very sparse anyway the closest thing to a reference guide I found was http://old.wowace.com/wiki/Category:API_Documentation and most of those are auto generated and not very helpful. Is there any other place with more detailed and complete documentation?
  Reply With Quote
04-29-10, 05:54 AM   #2
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
The most up-to-date API documentation for the Ace3 library suite can be found here.

Really, though, the best way to obtain the information you seek is to look at the code of other AddOns which you know are Ace3-based and learn from them.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
04-30-10, 01:49 PM   #3
Crowfeather
A Fallenroot Satyr
 
Crowfeather's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2008
Posts: 28
Thanks for the link, itīs certainly better than the one I knew before.

As I said I looked into the SW_UniLog.xml as well as the SW_FrameTemplates.xml but didnīt turn up something visible yet.

I think I can translate most XML data to lua code but so far I can just guess what thoses attributes really do because - as I said, itīs nothing visible yet.

- movable, enableMouse and resizable are all rather obvious and can be done via SetMovable, SetResizable and EnableMouse methods in lua
- inherits="XYZ" propably means that the frame with this attribute has got all attributes of frame XYZ in addition to those explicitly defined for it and is given as fourth argument of CreateFrame.
- virtual="true" sounds like the frame isnīt meant for actual display or use but rather as a prototype to be inherited by other frames but this really is just a guess. Also Iīve no clue how to create "virtual" frames with pure lua code or if itīs even necessary for the planned AddOn.
- I guess Anchors in XML can be done via SetPoint command in lua code
- Layers Iīve no clue as to what exactly they do or how to implement them in lua. The XML file had the following data as attribute of a frame which I donīt know how to do in lua:
Code:
<Layers>
	<Layer level="BACKGROUND">
		<Texture file="Interface\AddOns\SW_Stats\images\corner" alphaMode="ADD">
			<Anchors>
				<Anchor point="TOPLEFT">
					<Offset>
						<AbsDimension x="0" y="0" />
					</Offset>
				</Anchor>
				<Anchor point="BOTTOMRIGHT">
					<Offset>
						<AbsDimension x="0" y="0" />
					</Offset>
				</Anchor>
			</Anchors>
		</Texture>
	</Layer>
</Layers>
Oh and one more question if I do newFrame = CreateFrame("frameType", "frameName", parentFrame, "inheritsFrame") where do I actually use frameName to address the frame instead of its variable name newFrame? Is it even used? If I want to inherit it to some other frame?

Iīd be happy if someone could answer my questions and/or confirm/deny my assumptions.
  Reply With Quote
04-30-10, 02:52 PM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
You've pretty much hit the nail on the head on most of those thoughts so you're doing pretty well there.

Layers ?

Think when you want to create a texture for a frame you would do something like this. ARTWORK in this example is the layer you wish to place the texture on. :

http://www.wowwiki.com/API_Frame_CreateTexture
Frame:CreateTexture(["textureName"[, "layer"]][, "inheritsFrom"])
Code:
FRAME = CreateFrame("Frame","NewFrame",UIParent);
FRAME.texture = FRAME:CreateTexture(textureFileName, "ARTWORK")
FRAME.texture:SetAllPoints(FRAME)
FRAME.texture:SetTexture(r,g,b[,a])
Virtual Frames in Lua ? I initially thought I had stumbled across it with object orientated programming but I don't think it worked the way I planned so I chose to forget that part of the idea. Maybe I just need to learn some more in that area before going back and trying again

If you don't want to store the variable or reference from the variable you can use _G["framename"] and it will return the object that belongs to that name reference.

EG.
local mainFrame = CreateFrame("Frame","MainFrame",UIParent);
local subFrame = CreateFrame("Frame","$parentSubFrame",mainFrame);

That is the simplest way of dealing with them but, if you needed to refer to subFrame but had not stored it you would have to breakdown the name of it.

$parent = "MainFrame" + "SubFrame" = "MainFrameSubFrame"
So, the other way to reference subFrame would be as _G["MainFrameSubFrame"]. Obviously a mouthful so if you are planning to reference it alot .. you might want to assign it a variable.
__________________


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
04-30-10, 04:03 PM   #5
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
Originally Posted by Xrystal View Post

$parent = "MainFrame" + "SubFrame" = "MainFrameSubFrame"
So, the other way to reference subFrame would be as _G["MainFrameSubFrame"]. Obviously a mouthful so if you are planning to reference it alot .. you might want to assign it a variable.
You don't need to actually access the object by key in the global table as long as it doesn't contain "reserved" lua characters or concatenation. i.e.

Code:
local f = CreateFrame('Frame', 'SuperSpecialFrame')
-- These are identical. SuperSpecialFrame is just a global variable
f:SetPoint'CENTER'
SuperSpecialFrame:SetPoint'CENTER'
Code:
local f = CreateFrame('Frame', '[SuperSpecialFrame]')
f:SetPoint'CENTER'
-- This is a syntax error. Brackets are reserved for accessing a table
[SuperSpecialFrame]:SetPoint'CENTER'
-- We either need to the change the name of our frame, or use the global table
_G['[SuperSpecialFrame]']:SetPoint'CENTER' -- valid

-- other reserved characters include any operators, mathematical or otherwise
-- * - + / % = ~ > < () [] {}
-- periods since they're used as syntactical sugar for accessing a hash table
-- probably some other stuff too
Code:
for i = 1, 10 do 
     -- create SuperSpecialFrame1 through SuperSpecialFrame10
     CreateFrame('Frame', 'SuperSpecialFrame'..i)
end
-- We don't assign our frame to a local variable so we have to access it globally
-- We don't want to use a single line for each so we'll use a loop
for i = 1, 10 do
     _G['SuperSpecialFrame'..i]:SetPoint'CENTER'
end
  Reply With Quote
04-30-10, 04:26 PM   #6
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
Ah thanks for that Waverian. I have yet to see the first two in any example code I have used while learning so thanks for the additional options.
__________________


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
05-01-10, 05:11 AM   #7
Crowfeather
A Fallenroot Satyr
 
Crowfeather's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2008
Posts: 28
Thanks for the replies.

So is there actually a reason or advantage to use the frameName instead of the variable name?

Iīm also still unsure as to what "virtual" means, if I need it and if there is an equal representation in lua code. For example, one line of the SW_FrameTemplates.XML looks like this
Code:
<Frame name="SW_Frame" hidden="true" virtual="true">
The SW_Frame is inherited by a lot of other Frames but doesnīt seem to show up itself, thus my guess that itīs used as kind of a prototype.

One more question
Code:
<Frame name="SW_UniLogFrame" inherits="SW_Frame" enableMouse="true" movable="true" resizable="true" frameStrata="LOW" parent="UIParent">
	...
	<Frames>
		<Frame name="$parent_Resizer" inherits="SW_Frame_Resize" parent="SW_UniLogFrame" />
		<EditBox name="SW_UL_CopyBox" letters="50" historyLines="0" autoFocus="true" hidden="true">
			...
		</EditBox>
		...
	</Frames>
</Frame>
How do subframes of a Frame translate to lua code? Theyīre not necessarily child frames to the metaframe that encompasses them as the parent is already specifically given in the definition as well as the anchors.
So what makes the above implementation any diffrent from this one:
Code:
<Frame name="SW_UniLogFrame" inherits="SW_Frame" enableMouse="true" movable="true" resizable="true" frameStrata="LOW" parent="UIParent">
	...
</Frame>
<Frame name="$parent_Resizer" inherits="SW_Frame_Resize" parent="SW_UniLogFrame" />
<EditBox name="SW_UL_CopyBox" letters="50" historyLines="0" autoFocus="true" hidden="true">
	...
</EditBox>
  Reply With Quote
05-01-10, 06:34 AM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
Yes, virtual is given to frames that hold functionality used in frames that inherit from it but doesn't have a use itself. I don't know how much can be in the virtual frame and inherited however.

My example of 2 frames is the same as a Frame within a frame.

Code:
<Frame name="SW_UniLogFrame" inherits="SW_Frame" enableMouse="true" movable="true" resizable="true" frameStrata="LOW" parent="UIParent">
  <Frames>
     <Frame name="$parent_Resizer" inherits="SW_Frame_Resize" parent="SW_UniLogFrame" />
    <EditBox name="SW_UL_CopyBox" letters="50" historyLines="0" autoFocus="true" hidden="true">
    </EditBox>
  </Frames>
</Frame>
Translates to, if memory serves as I haven't touched EditBox in ages:
local f = CreateFrame("Frame","SW_UniLogFrame",UIParent,"SW_Frame");
local g = CreateFrame("Frame","$parent_Resizer",f,"SW_Frame_Resize");
local h = CreateFrame("EditBox","SW_UL_CopyBox",f);

From what Waverian pointed out the f in the CreateFrame function can be replaced with the name itself and not just the variable. I've not coded that way though to know how that works that way myself.
__________________


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
05-01-10, 06:48 AM   #9
Crowfeather
A Fallenroot Satyr
 
Crowfeather's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2008
Posts: 28
Originally Posted by Xrystal View Post
Yes, virtual is given to frames that hold functionality used in frames that inherit from it but doesn't have a use itself. I don't know how much can be in the virtual frame and inherited however.

My example of 2 frames is the same as a Frame within a frame.

Code:
<Frame name="SW_UniLogFrame" inherits="SW_Frame" enableMouse="true" movable="true" resizable="true" frameStrata="LOW" parent="UIParent">
  <Frames>
     <Frame name="$parent_Resizer" inherits="SW_Frame_Resize" parent="SW_UniLogFrame" />
    <EditBox name="SW_UL_CopyBox" letters="50" historyLines="0" autoFocus="true" hidden="true">
    </EditBox>
  </Frames>
</Frame>
Translates to, if memory serves as I haven't touched EditBox in ages:
local f = CreateFrame("Frame","SW_UniLogFrame",UIParent,"SW_Frame");
local g = CreateFrame("Frame","$parent_Resizer",f,"SW_Frame_Resize");
local h = CreateFrame("EditBox","SW_UL_CopyBox",f);

From what Waverian pointed out the f in the CreateFrame function can be replaced with the name itself and not just the variable. I've not coded that way though to know how that works that way myself.
So if I understood you right the two examples given in my last post would behave exactly the same? Having other frames encapsulated withing an frame tag doesnīt serve any specific purpose but to syntactically highlight that they contentual belong to the metaframe and that thereīs no real analogy in lua?
  Reply With Quote
05-01-10, 06:59 AM   #10
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
The second frame will as the parent=comment is the same as inserting it within the Frames block. The EditBox however doesn't have a parent= comment. But yes, from what I can see it would react the same.

I don't profess to know how XML WoW Syntax works fully as all my addons are lua pure code but the little I have read up on the subject and used in my early practice addons help me understand them so.
__________________


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

WoWInterface » Developer Discussions » Lua/XML Help » Creating complex frames


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