View Single Post
07/11/16, 12:42 PM   #6
Haho
Join Date: Jul 2016
Posts: 15
Originally Posted by tgolsson View Post
Well, my intended idea is sort of like this:

Code:
Addon,
PlayerFrame,
TargetFrame,
PartyFrame = [ UnitFrame, UnitFrame, UnitFrame, UnitFrame ]
RaidFrame = [ UnitFrame, ... ]
So I will indeed have many toplevel controls as I use the virtual dynamic creation. But I will have one manager for all of them that controls positioning, updating, etc. Perhaps there is a better way of doing this, but the functionality is horribly undocumented.

I develop a lot in Java, and to give an analogy (if it makes any sense to you) what I am trying to do is create View for each group member, and then create a Controller for managing all these views. It's called the "DRY" principle: "Don't repeat yourself". It's the same thing for each group member, so I should have only one piece of logic and markup for it.
your "Addon" level is your TopLevelControl then

then make your virtual be only "Control" and set your toplevelcontrol as parent when your generate them.
later work on your controls as you see fit. But TopLevelControls have specific functions and rules attached to them, and you don't want them on all of your controls.


I usually create everything in lua, but there are many examples of xml in other addons to understand how names are created.


The name you determine in lua is a variable you can check in your code, but for the UI what matter is the named control. You can get it back with a
local mycontrolvariable = GetControl("TopLevelNameChildNameLabelNAme") for example.

in your example :
local mylabel = GetControl("UnitFrameName")
mylabel:SetText("Bob")

Edit : sorry, i didn't re-read your first post before writing, it would be instead local mylabel = GetControl("TargetName") since UnitFrame is the name of the Template. sry again.
and you can use a suffix to the name when generating your controls in a loop :
CreateControlFromVirtual(name, parent, templateName, optionalNameSuffix)
that can be helpful.


edit: Controls dont need to all have a size and place etc, they can be virtual containers for the sake of having properties inherited by a group of children. I mean CT_CONTROL controls...

Last edited by Haho : 07/11/16 at 02:00 PM.
  Reply With Quote