HousingAuthority

HousingAuthority is a library used to make easy configurations that go into OptionHouse.
==Table data==
===frameData===
;Fields
Field 	Type 	Default	Details
frame 	frame 	frame 	Frame you want all of the HA widgets to go onto, if no frame is passed then a blank unnamed one is created.
columns	number 	1 	Display style, 1 is a one by one style, 2 will be 2 widgets per a row and so on
handler	table 	nil 	Handler for all callbacks to use, all callbacks require set/onSet/get to be passed as a string if this is set.
set 	function/string	nil 	The set callback that all widgets inherit
onSet 	function/string	nil 	The onSet callback that all widgets inherit
get 	function/string	nil 	The get callback that all widgets inherit
;Remarks
You only need to pass the frame if you're doing some sort of custom modification to it, otherwise you can just skip it and it'll handle everything.
If you do pass a frame, do not rely on it being the one you should register with OptionHouse if your widgets are going to overlap off the OptionHouse display frame we wrap it a scroll frame around it.
===widgetData===
All HousingAuthority widgets (input, color, dropdown, slider, checkbox, button) accept these by default as fields so aren't listed.
;Fields
Field 	Type 	Default 	Details
text 	string 	<required>	Text shown next to the widget
group 	string 	nil 	Used for grouping widgets together
var 	string/number/table	<required>	Used for identifying widgets, passed for all set/onSet/get/validate functions
help 	string 	nil 	Shows a little "[?]" next to each widget in green, handy if you need to clarify or give extra information that can't be explained in the text alone.
handler	table 	nil 	Handler function for using in the callbacks require set/onSet/get to be passed as a string if this is set.
set 	function/string 	<required>	Function called when a widgets configuration value changes
onSet 	function/string 	nil 	Same as set, however you should only use this if you need to know when something changes not changing the configuration
get 	function/string 	<required>	Called when we're loading the widget and when the frame is shown, the actual value of the widget
order 	integer 	999999 	Order to display the widgets in
;Remarks
Grouping
Grouping is a way to break up configuration so it doesn't look like a single mass of options, if one widget has the group field passed all of them must, the value should be the text that you want displayed, for example the below will show an input and color widget inside a frame labeled "Frame" and a check inside a frame labeled "General".
 { { type = "input",
 group = "Frame",
 <input data>
 }
 { type = "color",
 group = "Frame",
 <input data>
 }
 { type = "check",
 group = "General",
 <input data>
 } }
Callbacks
These are how the callback functions are handled along with arguments used.
No handlers passed
set(var, value)
onSet(var, value)
validate(var, value)
get(var)
Handler passed
handler[set](handler, var, value)
handler[onSet](handler, var, value)
handler[validate](handler, var, value)
handler[get](handler, var)
==HousingAuthority API==
===HA:RegisterFrame([frameData])===
;Returns
Return	Type 	Details
HAObj 	table	HousingAuthority data object for registering widgets
===HA:CreateConfiguration(widgets[, frameData])===
;Args
Return 	Type 	Details
widgets 	table	List of all the widgets you want to add
frameData	table	Frame data
;Returns
Return	Type 	Details
frame 	frame	Frame that should be registered with OptionHouse, this is just the results of HAObj:GetFrame()
;Types
List of widget types that can be used
Type 	Called Function
group 	HAObj:CreateGroup()
input 	HAObj:CreateInput()
dropdown	HAObj:CreateDropdown()
color 	HAObj:CreateColorPicker()
check 	HAObj:CreateCheckBox()
button 	HAObj:CreateButton()
slider 	HAObj:CreateSlider()
label 	HAObj:CreateLabel()
;Remarks
Most of the time, all you want is to call this and just pass the table with all the configuratiions, if you need more flexability you can use the below HAObject API's.
Tables should look like this,
 { { type = "input",
 <input data arguments>
 },
 { type = "dropdown",
 <dropdown data arguments>
 },
 }
and so on.
==HousingAuthority Object API==
===HAObj:GetFrame()===
;Returns
Return	Type 	Details
frame 	Frame/ScrollFrame	Frame with all the widgets displayed in it, that should be registered with OptionHouse
;Remarks
Once you call this, you can no longer call any of the widget creation functions, if the total height of all the widgets is creater then 280 then we wrap the passed frame around a ScrollFrame and return the ScrollFrame instead.
===HAObj:GetObject(frame)===
Returns the HAObj that created the frame that was passed in.
;Args
Name 	Type 	Details
Frame	frame	HA display frame thats given when calling HAObj:GetFrame()
;Returns
Return	Type 	Details
HAObj 	table	HAObj:CreateConfiguratiion()]
===HAObj:CreateGroup(data)===
;Data fields
Field 	Type 	Default 	Details
background	table	rgb of 0.094117 	Backdrop color of the group, by default this is a blackish gray
border 	table	Backdrop border color of the group, by default this is gray	
;Remarks
This is a way to configure how your group frames will look, not required if you're using grouping due to the defaults, you should pass the tables formatted as { r = #, g = #, b = # } for both background and border.
===HAObj:CreateDropdown(data)===
Dropdown for selecting a list of options, useful when you don't want them to be able to enter anytihng like in an input 
;Data fields
Field 	Type 	Default 	Details
text 	string 	<required>	Actual text to display
default	string/number	nil 	Default value to select by key, if the default doesn't match the list we use the first row
list 	table 	<required>	List of rows to shown, must be formatted as { { "key1"", "text1" }, { "key2", "text2" } } and so on
;Returns
Return 	Type
dropdownFrame	Frame
===HAObj:UpdateDropdown(data)===
Allows you to update an already created dropdown with a new default and list
;Data fields
Field 	Type 	Default 	Details
var 	table/string/number	<required>	Used for identifying the droopdown to be updated
default	string/number 	nil 	Default value to select by key, if the default doesn't match the list we use the first row
list 	table 	<required>	List of rows to shown, must be formatted as { { "key1"", "text1" }, { "key2", "text2" } } and so on
;Remarks
You should only call this when you know the dropdown is hidden, meanning either OnShow for the frame or in response to set/onSet, if you try and call it with it open then it'll show the old rows followed by the new ones.
var is used for identify the dropdown, if the dropdown is a table then the values of each must match 100%, if you have multiple dropdowns with the same var then it'll update the first it finds.
===HAObj:CreateLabel(data)===
Adds a simple text that can be used to break up configuration to prevent them all looking clustered together, can be used in place or grouping or with it if need be.
;Data fields
Field 	Type 	Default 	Details
text 	string 	<required> 	Actual text to display
color 	table 	nil 	Text color, should be passed as { r = #, g = #, b = # }
font 	fontInstance	GameFontNormal	Font instance to inherit from
fontPath	string 	nil 	Font file to use when displaying the text, by default will grab from GameFontNormal
fontSize	number 	nil 	Size of the font, can only be used if you pass fontPath too
fontFlag	string 	nil 	Display flags, see FontInstance:SetFont() for possible arguments, requires fontPath and fontSize to be used
xPos 	number 	8 	Allows finer control over how far other widgets are from the label
yPos 	number 	5 	Allows finger control on how far this widget is from either the side or another widget
;Returns
Return	Type
label 	FontString
===HAObj:CreateColorPicker(data)===
Creates a small button that can be used for setting colors, the middle of the button is the currnet color used
;Data fields
Field 	Type 	Default	Details
default	table	nil 	Default color to use if get() returns nil
;Returns
Return	Type
button	Button
;Remarks
When calling set and onSet we call return the value as { r = #, g = #, b = # }, get must return it in this same format.
===HAObj:CreateButton(data)===
Simple button that lets you respond when it's clicked
;Data fields
Field	Type 	Default 	Details
width	number	text width + 18	How width the button should be
;Remarks
This only responds to the set and onSet fields from widgetData, no value will be passed to them.
;Returns
Return	Type
button	Button
===HAObj:CreateCheckBox(data)===
Simple check box
;Data fields
Field 	Type 	Default	Details
default	booolean	nil 	Default value when get() returns nil
;Returns
Return 	Type
checkBox	CheckButton
===HAObj:CreateInput(data)===
Text or number inputt field
;Data fields
Field 	Type 	Default	Details
width 	number 	120 	Width of the input box
default 	string/number 	nil 	Default value inside the input
realTime	boolean 	false 	By default, we only consider the input box changed when focus is lost or enter is pressed, you can change it using this to be considered changed whenever the text changes or enter is pressed
maxChars	number 	nil 	Maximum number of characters that can be entered
numberic	boolean 	false 	Only allows entering of numerical characters into the input box
validate	string/function	nil 	Allows you to restrict whats considered valid iinput
error 	string 	nil 	Shows a red "[!]" next to the widget when validate returns nil, string format is called on this, so you can also show the value entered in the error message
;Remarks
Validate allows you to restrict thats considered acceptable, if it returns nil then it's considered rejected and a red "[!]" will appear using the message you provided from the error field, once validate returns anything except nil then set/onSet is called.
An example of how this works would be only allowing numeric input.
 local function validateInput(var, value)
 return tonumber(value)
 end
If the user enters abc then nil is returned because no numbers can be found in it, if he entered ab10 then it would return 10 and thats what would be passed to the set and onSet functions.
;Returns
Return	Type
input 	EditBox
===HAObj:CreateSlider(data)===
Slider for things like opacity or scale
;Data fields
Field 	Type 	Default	Details
default 	number 	nil 	Default value used when get() returns nil
format 	string 	nil 	This works the same way as the text field does, however we call it with a string format of Slider:GetValue() * 100, useful if you want to show something like "Scale: %d%%"
min 	number 	0.0 	Lowest the slider can go
minText 	string 	0% 	Text showing how low the slider can go
max 	number 	100 	Highest the slider can go
maxText 	string 	100% 	Text showing how high the slider can go
step 	number 	0.01 	How much to increment the slider by when dragged, lower numbers give finer controls when sliding it
manualInput	boolean	false 	Shows a small input box next to the slider that lets the user manually enter the value
;Returns
Return	Type
slider	Slider
Category:Dongle