Class factory

Class used to build lightweight widgets for configuration options.

You can obtain it calling GetFactory() method.

All widgets communicate with your code via the OnChange Callback and expose a SetOnChange method to set it

Usage:

    local addon=LibStub("LibInit"):newAddon("example")
    local factory=addon:GetFactory()
    local widget=factory:Checkbox(frame,true,"Checkbox","Checkbox tooltip")
    widget:SetOnChange(function(checked) end)
    --You can set a custom object so you can pass a method to SetOnChange:
    widget:SetObj(mytable)
    widget:SetOnChange("method")
    

Info:

  • Author: Alar of Runetotem

Methods

factory:Button (father, message[, tooltip[, maxwidth]]) Creates a buttom.
factory:Checkbox (father, current, message[, tooltip[, maxwidth]]) Creates a checkbox.
factory:DropDown (father, current, list, message[, tooltip[, maxwidth]]) Creates a dropdown menu.
factory:Label (father, text[, color]) Creates a laben
factory:Option (addon, father, flag[, maxwidth]) Quickly defines a widget for a defined configuration variable All data for the widget are inferred for the variable
factory:Panel (father[, movable[, columns[, width]]]) Quickly creates an option panel Add widgets whith addChild method
factory:Slider (father, min, max, current, message[, tooltip[, maxwidth]]) Creates a slider.


Methods

factory:Button (father, message[, tooltip[, maxwidth]])
Creates a buttom.

Parameters:

  • father frame Parent frame to use
  • message string or table String with description or table with .desc and .tooltip fields
  • tooltip string Tooltip message (ignored if message is a table. Can be a table for a multiline tooltip (optional)
  • maxwidth number maximum widget width (optional)

Returns:

    widget button widget object
factory:Checkbox (father, current, message[, tooltip[, maxwidth]])
Creates a checkbox.

Parameters:

  • father frame Parent frame to use
  • current bool Actual value
  • message string or table String with description or table with .desc and .tooltip fields
  • tooltip string Tooltip message (ignored if message is a table).Can be a table for a multiline tooltip (optional)
  • maxwidth number maximum widget width (optional)

Returns:

    widget checkbox widget object
factory:DropDown (father, current, list, message[, tooltip[, maxwidth]])
Creates a dropdown menu. Create a totally new frame in order to avoid taint

Parameters:

  • father frame Parent frame to use
  • current mixed Initial value
  • list tab Option list
  • message string or table String with description or table with .desc and .tooltip fields
  • tooltip string Tooltip message (ignored if message is a table). Can be a table for a multiline tooltip (optional)
  • maxwidth number maximum widget width (optional)

Returns:

    widget dropdown widget object
factory:Label (father, text[, color])
Creates a laben

Parameters:

  • father frame Parent frame to use
  • text string String with description
  • color string name (passed to colorize) defaults to yellow (optional)

Returns:

    widget label widget object
factory:Option (addon, father, flag[, maxwidth])
Quickly defines a widget for a defined configuration variable All data for the widget are inferred for the variable

Parameters:

  • addon table The addon wich defined the variable
  • father frame Parent frame to use
  • flag string name of the variable to use
  • maxwidth number maximum widget width (optional)
factory:Panel (father[, movable[, columns[, width]]])
Quickly creates an option panel Add widgets whith addChild method

Parameters:

  • father frame Parent frame to use
  • movable boolean!table true for movabke or a table witl listf attributes default false (optional)
  • columns number defailt 1 (optional)
  • width number defauld 1 (panel will be resized to biggest child) (optional)

Usage:

    local factory=self:GetFactory()
    local t=factory:Panel(parentFrame,false)
    t:ClearAllPoints()
    local x,y=0,-23
    t:SetPoint("TOPLEFT",x,y)
    t:SetPoint("TOPRIGHT",x,y)
    t:SetPoint("BOTTOMLEFT")
    t:SetPoint("BOTTOMRIGHT")
    t:AddChild('c',factory:DropDown(t,'DEMONHUNTER',classes,CLASS,CHOOSE .. ' ' .. CLASS))
    t:AddChild('l',factory:Slider(t,1,maxLevel,maxLevel,LEVEL,CHOOSE .. ' ' .. LEVEL))
    t:AddChild('f',factory:DropDown(t,thisFaction,factions,CHOOSE .. ' ' .. FACTION))
    t:AddChild('p1',factory:DropDown(t,UNKNOWN,professions,PROFESSIONS_FIRST_PROFESSION,CHOOSE .. ' ' .. PROFESSIONS_FIRST_PROFESSION))
    t:AddChild('p2',factory:DropDown(t,UNKNOWN,professions,PROFESSIONS_SECOND_PROFESSION,CHOOSE .. ' ' .. PROFESSIONS_SECOND_PROFESSION))
    t:AddChild('a',factory:Checkbox(t,false,ITEM_ACCOUNTBOUND,L["This toon can receive Account Bound items"]))
    t:AddChild('b',factory:Button(t,SAVE))
    -- Add an onchange function to the button
    t:SetOnChange('b',function(self,value)
      -- father is tyhe panel widget
      local answer=self.father:GetValue()
      -- answer is an object wich contains the currenv value of eery wuidget indexed bty its handle (first parameter to addchild)
      t:Hide()
    end)
factory:Slider (father, min, max, current, message[, tooltip[, maxwidth]])
Creates a slider.

Parameters:

  • father frame Parent frame to use
  • min number Minimum value
  • max number Maximum value
  • current number Actual value
  • message string or table String with description or table with .desc and .tooltip fields
  • tooltip string Tooltip message (ignored if message is a table). Can be a table for a multiline tooltip (optional)
  • maxwidth number maximum widget width (optional)

Returns:

    widget slider widget object
generated by LDoc 1.4.6 Last updated 2021-01-19 12:33:13