Thread Tools Display Modes
05-08-16, 10:36 AM   #1
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
What is mixin?

I see this in blizzard code. Also see it in the xml, what does it do?
 
05-08-16, 11:06 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
It takes a given table and copies the contents into the frame's table. This started showing up in WoD code.
__________________
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)
 
05-08-16, 11:13 AM   #3
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Think of it as inheriting from a template.
 
05-08-16, 12:08 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Kind of, only the "templates" are other Lua tables in which the entries are copied from.
__________________
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)
 
05-08-16, 05:04 PM   #5
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
The name comes from functions being "mixed in" with the widget's table. It's basically just dynamic inheritance from an independent source. If your frame is a meal you're preparing, then mixin functions/tables can be seen as spices. They exist independently from the meal itself, but can be added to your meal, in which case it'll be part of said meal.
__________________
 
05-08-16, 06:36 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
I think the OP would get it by now. All these analogies are making my head hurt.
__________________
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)
 
05-08-16, 06:51 PM   #7
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
And not one coctail in sight
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
 
05-09-16, 01:51 AM   #8
galvin
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 265
Thanks for answers
 
05-09-16, 10:49 AM   #9
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I haven't had time to snoop. Where are Blizzard's mixins?
 
05-09-16, 12:26 PM   #10
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
See Blizzard_GarrisonMissionUI.xml line 1910 which points to Blizzard_GarrisonMissionUI.lua lines 14 and 16.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
 
05-09-16, 12:38 PM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
In WoD, they're mostly used in the Blizzard LoD addons. In XML, this is a tag on a UI object called MixIn as highlighted below.
Code:
<Frame name="GarrisonMissionFrame" inherits="GarrisonMissionFrameTemplate, GarrisonUITemplate" mixin="GarrisonMission,GarrisonFollowerMission">
Note: GarrisonMission in Blizzard_GarrisonMissionTemplates.lua line 5, GarrisonFollowerMission is in Blizzard_GarrisonMissionUI.lua line 14.



In Legion, there's a Lua-implemented function that Blizzard uses as well.
Lua Code:
  1. -- where ... are the mixins to mixin
  2. function Mixin(object, ...)
  3.     for i = 1, select("#", ...) do
  4.         local mixin = select(i, ...);
  5.         for k, v in pairs(mixin) do
  6.             object[k] = v;
  7.         end
  8.     end
  9.  
  10.     return object;
  11. end
  12.  
  13. -- where ... are the mixins to mixin
  14. function CreateFromMixins(...)
  15.     return Mixin({}, ...)
  16. end
__________________
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)

Last edited by SDPhantom : 05-09-16 at 12:46 PM.
 
05-09-16, 02:24 PM   #12
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
It's basically a table deep copy, to create skeleton objects for future use.
 
 

WoWInterface » Site Forums » Archived Beta Forums » Legion Beta archived threads » What is mixin?

Thread Tools
Display Modes

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