Quantcast
Download
(29 Kb)
Download
Updated: 08/21/19 01:31 PM
Pictures
File Info
Compatibility:
Scalebreaker (5.1.5)
Updated:08/21/19 01:31 PM
Created:08/18/19 08:03 AM
Monthly downloads:1,004
Total downloads:1,174
Favorites:5
MD5:
5.1.5
LibShifterBox
Version: 0.2.0
by: Klingo [More]
Disclaimer: LibShifterBox is currently in BETA status. APIs might change again and further bugfixes are to be expected.

Features
  • Create ShifterBoxes (also known as Dual-Listboxes) for easier selection of multiple entries
  • Shift items with the [<] and [>] buttons, or just use drag-and-drop
  • Entries can optionally be added under different categories to easily show/hide them based on other events
  • Define your own titles for the ListBoxes, or just leave them out
  • Simple access to know which entries are in which ListBox
  • Change Dimension, Hidden and Enabled state at any time
  • Provide your own XML Templates to be used for the individual rows


Quick Start

Add LibShifterBox as a dependency to your add-on manifest:
Code:
## DependsOn: LibShifterBox
Then you can create a shifterBox instance, anchor it to another control and start adding entries like this:
Lua Code:
  1. local customSettings = {
  2.     leftList = {
  3.         title = "Lefties",
  4.     },
  5.     rightList = {
  6.         title = "Righties",
  7.     }
  8. }
  9. local shifterBox = LibShifterBox("MyAddon", "MyShifterBox", parentControl, customSettings)
  10. shifterBox:SetAnchor(TOPLEFT, headerControl, BOTTOMLEFT, 0, 20) -- required to correctly position/anchor it in your UI
  11. shifterBox:SetDimensions(300, 200) -- optionally set your own overall dimensions of the shifterBox
  12. shifterBox:AddEntriesToLeftList({[1] = "AAA", [2] = "BBB", [3] = "CCC"}) -- add three entries to the left list
  13. shifterBox:AddEntryToRightList(4, "DDD") -- add one entry to the right list

A more extensive Quick Start Example can be found here


API Reference
Known Issues
  • When programmatically deselecting an entry where the mouse cursor hovers over; the font color temporarily changes to white

Info
0.2.0 (August 21, 2019)
- restructured customSettings (breaking change!)
- add [dragDropEnabled] setting to control the drag-and-drop feature (by Baertram)
- add [fontSize] setting to change the font of the entries
- add localization for default empty text

0.1.1 (August 18, 2019)
- add [sortEnabled] customSetting as proposed by Baertram
- add additional shortcut parameters to .Create/:New as proposed by Baertram

0.1.0 (August 18, 2019)
- initial (beta) release
Optional Files (0)


Archived Files (2)
File Name
Version
Size
Uploader
Date
0.1.1
26kB
Klingo
08/18/19 02:41 PM
0.1.0
26kB
Klingo
08/18/19 08:03 AM


Post A Reply Comment Options
Unread 08/18/19, 09:30 AM  
Klingo
AddOn Author - Click to view AddOns

Forum posts: 14
File comments: 122
Uploads: 3
Originally Posted by Baertram
Are you sure the function in your example exists:
SetLeftListEntries
Shouldn't this be AddEntriesToLeftList ?
Whoops, this is an error in the documentation; I missed to update the renamed function. I'll fix that, thanks!

Originally Posted by Baertram
During my tests I got a duplicate table key error.
Does this mean teh left list and the right list cannot have the same indices/keys?
Correct - because you can move entries between the two listBoxes it must be possible to have all of them on one side and still be able to uniquely identify each entry (by enforcing unique keys)
Report comment to moderator  
Reply With Quote
Unread 08/18/19, 08:36 AM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 2359
File comments: 2619
Uploads: 57
Wow this looks great. Maybe think about adding them to LibAddonMenu-2.0 as well as controls?
Could come in handy, at least got 2 addons which could use them already
Thanks for the controls.

One idea:
I'd use the create function of your control to provide the anchor parameters, width and height and leftList and rightList parameters as well so one can do this all with 1 line.

I mean this:
Code:
local shifterBox = LibShifterBox("MyAddon", "MyShifterBox", parentControl, "Lefties", "Righties")
shifterBox:SetAnchor(TOPLEFT, headerControl, BOTTOMLEFT, 0, 20) -- required to correctly position/anchor it in your UI
shifterBox:SetDimensions(300, 200) -- optionally set your own overall dimensions of the shifterBox
shifterBox:SetLeftListEntries({[1] = "AAA", [2] = "BBB", [3] = "CCC"}) -- add three entries to the left list
shifterBox:AddEntryToRightList(4, "DDD") -- add one entry to the right list
To be able to be used like this (optional parameters after "Righties"):
Lua Code:
  1. local shifterBox = LibShifterBox("MyAddon", "MyShifterBox", parentControl, "Lefties", "Righties", TOPLEFT, headerControl, BOTTOMLEFT, 0, 20, 300, 200, leftListEntries, rightListEntries)

A lof of parameters but easier to setup the list controls in 1 row I think.

leftListEntries and rightListEntries could be a table, or maybe a function creating tables.
One can check this e.g. like this:

Lua Code:
  1. local rightListEntriesTable = {}
  2. if rightListEntriesParameter then
  3.  if type(rightListEntriesParameter) == "function" then
  4.    rightListEntriesTable = rightListEntriesParameter()
  5.  else
  6.    rightListEntriesTable = rightListEntriesParameter
  7.  end
  8. end

Will send you my idea via GitHub

Edit:
Are you sure the function in your example exists:
SetLeftListEntries
Shouldn't this be AddEntriesToLeftList ?

Edit2:
During my tests I got a duplicate table key error.
Does this mean teh left list and the right list cannot have the same indices/keys?
Last edited by Baertram : 08/18/19 at 09:25 AM.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: