api/LibSimpleOptions-1.0

LibSimpleOptions.AddOptionsPanel(name, controlCreationFunc)

Make a new options panel and add it to the Blizzard Interface Options

Parameters

name
name of your panel
controlCreationFunc
function to call when the panel is first shown

Return value

the created panel

Usage

LibStub("LibSimpleOptions-1.0").AddOptionsPanel("My Options", function(panel) ... end)


LibSimpleOptions.AddSlashCommand(name, ...)

Add a slash command to open a specific options panel

Parameters

name
name of the panel to open
...
tuple of slash commands

Usage

LibStub("LibSimpleOptions-1.0").AddSlashCommand("My Options", "/MyOpt", "/MO")


LibSimpleOptions.AddSuboptionsPanel(parentName, name, controlCreationFunc)

Make a new options panel that is a child of another options panel and add it to the Blizzard Interface Options

Parameters

parentName
name of the parent panel
name
name of your panel
controlCreationFunc
function to call when the panel is first shown

Return value

the created panel

Usage

LibStub("LibSimpleOptions-1.0").AddOptionsPanel("My Options", "My Suboptions", function(panel) ... end)


panel:MakeButton(...)

Return a button

Parameters

...
tuple of key-value pairs<br/> name: What shows above the dropdown<br/> description: What shows when hovering over the dropdown<br/> func: What is called when the button is pressed

Return value

the Button

Usage

panel:MakeButton(
	    'name', 'Click',
	    'description', 'Specify your tooltip description',
	    'func', function() DEFAULT_CHAT_FRAME:AddMessage("Clicked!") end
	)


panel:MakeColorPicker(...)

Return a color swatch that opens a color picker

Parameters

...
tuple of key-value pairs<br/> name: What shows up next to the swatch<br /> description: What shows up in the tooltip on hover<br /> hasAlpha: Whether the color picker should have an alpha setting<br /> defaultR: Default red value [0, 1]<br /> defaultG: Default green value [0, 1]<br /> defaultB: Default blue value [0, 1]<br /> defaultA: Default alpha value [0, 1], only needed if hasAlpha is true<br /> currentR: The current red value - you can provide this or getFunc<br /> currentG: The current green value - you can provide this or getFunc<br /> currentB: The current blue value - you can provide this or getFunc<br /> currentA: The current alpha value - you can provide this or getFunc<br /> getFunc: Function to return the current color as a tuple<br /> setFunc: What is called when the color changes<br /> [optional] okayFunc: Called when the okay button is pressed<br /> [optional] cancelFunc: Called when the cancel button is pressed<br /> [optional] defaultFunc: Called when the default button is pressed

Return value

the color swatch

Usage

panel:MakeColorPicker(
	    'name', 'Pick a color',
	    'description', 'Specify your tooltip description',
	    'hasAlpha', false,
	    'defaultR', 1,
	    'defaultG', 0.82,
	    'defaultB', 0,
	    'getFunc', function() return unpack(db.color) end
	    'setFunc', function(r, g, b) db.color[1], db.color[2], db.color[3] = r, g, b end
	)
panel:MakeColorPicker(
	    'name', 'Pick a color',
	    'description', 'Specify your tooltip description',
	    'hasAlpha', true,
	    'defaultR', 0,
	    'defaultG', 1,
	    'defaultB', 0,
	    'defaultA', 0.5,
	    'currentR', db.color2.r,
	    'currentG', db.color2.g,
	    'currentB', db.color2.b,
	    'currentA', db.color2.a,
	    'setFunc', function(r, g, b, a) db.color2.r, db.color2.g db.color2.b, db.color2.a = r, g, b, a end
	)


panel:MakeDropDown(...)

Return a single-choice dropdown menu This is for choosing a single choice among many

Parameters

...
tuple of key-value pairs<br/> name: What shows above the dropdown<br/> description: What shows when hovering over the dropdown<br/> values: A list of options, in order, where the odd keys are the key and even are its corresponding value<br/> default: The default key<br/> current: The current key - you can either provide this or getFunc<br/> getFunc: Function to return the current key<br/> setFunc: What is called when the key changes<br/> [optional] okayFunc: Called when the okay button is pressed<br/> [optional] cancelFunc: Called when the cancel button is pressed<br/> [optional] defaultFunc: Called when the default button is pressed

Return value

the DropDown frame

Usage

panel:MakeDropDown(
	    'name', 'Choose',
	    'description', 'Specify your tooltip description',
	    'values', {
	        'ONE', "One",
	        'TWO', "Two",
	        'THREE', "Three",
	     },
	    'default', 'ONE',
	    'current', db.choice,
	    'setFunc', function(value) db.choice = value end,
	)


panel:MakeScrollFrame()

Return a scrollable frame to organize controls within This is useful to create if you have too many controls to properly fit within one panel

Return value

the ScrollFrame

Usage

local scrollFrame = panel:MakeScrollFrame()


panel:MakeSlider(...)

Return a horizontal slider This is primarily for manipulating numbers within a range

Parameters

...
tuple of key-value pairs<br/> name: What the slider displays above it<br/> description: What the tooltip displays when hovering over<br/> minText: What the slider shows on the left side<br/> maxText: What the slider shows on the right side<br/> minValue: The minimum value of the slider<br/> maxValue: The maximum value of the slider<br/> [optional] step: The amount that the slider steps between movements<br/> default: The default value<br/> current: The current value - can provide either this or getFunc<br/> getFunc: Function to get the current value<br/> setFunc: What is called when the value changes<br/> [optional] currentTextFunc: What is called to get text value at the bottom<br/> [optional] okayFunc: Called when the okay button is pressed<br/> [optional] cancelFunc: Called when the cancel button is pressed<br/> [optional] defaultFunc: Called when the default button is pressed

Return value

the Slider

Usage

panel:MakeSlider(
	    'name', 'Range',
	    'description', 'Specify your tooltip description',
	    'minText', '0%',
	    'maxText', '100%',
	    'minValue', 0,
	    'maxValue', 1,
	    'step', 0.05,
	    'default', 0.5,
	    'current', db.currentRange,
	    'setFunc', function(value) db.currentRange = value end,
	    'currentTextFunc', function(value) return ("%.0f%%"):format(value * 100) end
	)


panel:MakeTitleTextAndSubText(titleText, subTextText)

Return a new title text and sub-text for a panel.
Note that this automatically places the title and sub-text appropriately

Parameters

titleText
the text to show as the title
subTextText
the text to show as the sub-text

Return values

  1. the title FontString
  2. the sub-text FontString

Usage

local title, subText = panel:MakeTitleTextAndSubText("My Options", "These allow you to change assorted options")


panel:MakeToggle(...)

Return a checkbox

Parameters

...
tuple of key-value pairs<br/> name: What appears to the right of the checkbox<br/> description: What the tooltip shows when hovering over<br/> default: The default value<br/> current: The current value - you can provide this or getFunc<br/> getFunc: Function to return the current value<br/> setFunc: What is called when the value changes<br/> [optional] okayFunc: Called when the okay button is pressed<br/> [optional] cancelFunc: Called when the cancel button is pressed<br/> [optional] defaultFunc: Called when the default button is pressed

Return value

the CheckButton

Usage

panel:MakeToggle(
	    'name', 'Toggle',
	    'description', 'Specify your tooltip description',
	    'default', false,
	    'getFunc', function() return db.myToggle end
	    'setFunc', function(value) db.myToggle = value end
	)


panel:Refresh()

Refresh a panel's controls This updates any controls that provide a getFunc When a panel is shown, this is automatically called

Usage

panel:Refresh()



Comments

Posts Quoted:
Reply
Clear All Quotes