View Single Post
02-02-18, 11:36 AM   #8
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
Originally Posted by zork View Post
Here is a super simple layout to get you started.
https://github.com/zorker/rothui/blo...iler/spawn.lua

Personally I have not used the factory yet.
Spawning any unit other than party and raid is pretty straight forward. Those need a group header and some more config settings.
You are using the factory: https://github.com/zorker/rothui/blo...spawn.lua#L194

@Jagwah
You pass a callback to the factory, that is a function which specifies which styles are to be used for which units, and creates (spawns) and places the unit frames. You can call the factory multiple times. Callbacks are then executed in the call order, thus you control this order for your layout. So basically a callback suitable for oUF's factory is a function consisting of calls to oUF:SetActiveStyle, oUF:Spawn/oUF:SpawnHeader and frame:SetPoint. oUF is passed as an argument to your callback and frame is the return of :Spawn/:SpawnHeader

A style in oUF terms is a tuple consisting of a style name and a style function. The name has to be unique, so using your layout name as a prefix is a good idea. The style function defines the visual appearance of the unit frames spawned in the factory callback after :SetActiveStyle has been called with the specified style name. Your styles have to be known to oUF, so you have to use oUF:RegisterStyle(styleName, styleFunction) before you call oUF's factory.

How and where you define your style function is entirely up to you. Normally you would strive to do some separation by domain and by concern and reduce code repetition. This will make your code easier to read and follow and thus easier to maintain. A good idea is to define different styles for different units based on their appearance, e.g. player and target are normally the most prominent frames in a layout, so group them together in one style. Pet, focus and targettarget could share a separate style as well, the same for party and raid. You could then easily test different styles by just changing the argument in the :SetActiveStyle call.
  Reply With Quote