View Single Post
11-22-12, 02:54 AM   #15
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
This is how Elvui does actionbar page swapping. The Childupdate is pretty cool. It updates all children to the same state.

Lua Code:
  1. AB["barDefaults"] = {
  2.         ["bar1"] = {
  3.             ['visibility'] = "[petbattle] hide; show", --[petbattle][overridebar][vehicleui] hide; show
  4.             ['page'] = 1,
  5.             ['conditions'] = string.format("[vehicleui] %d; [possessbar] %d; [overridebar] %d; [bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6;", GetVehicleBarIndex(), GetVehicleBarIndex(), GetOverrideBarIndex()),
  6.         },
  7.     }
  8.  
  9.         --GetPage() just concatenates condition and default page
  10.         --basically returns this: [vehicleui] GetVehicleBarIndex(); [possessbar] GetVehicleBarIndex(); [overridebar] GetOverrideBarIndex(); [bar:2] 2; [bar:3] 3; [bar:4] 4; [bar:5] 5; [bar:6] 6; 1"    
  11.         RegisterStateDriver(bar, "page", self:GetPage(barName, self['barDefaults'][barName].page, self['barDefaults'][barName].conditions));
  12.         RegisterStateDriver(bar, "visibility", self['barDefaults'][barName].visibility)
  13.      
  14.         bar:SetAttribute("_onstate-page", [[
  15.             self:SetAttribute("state", newstate)
  16.             control:ChildUpdate("state", newstate)
  17.         ]])
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 11-22-12 at 02:57 AM.