Quantcast
Download
(30 Kb)
Download
Updated: 03/06/21 08:14 AM
Pictures
File Info
Compatibility:
Flames of Ambition (6.3.5)
Markarth (6.2.5)
Updated:03/06/21 08:14 AM
Created:08/18/19 08:03 AM
Monthly downloads:4,898
Total downloads:60,256
Favorites:17
MD5:
6.2.5
LibShifterBox  Updated less than 3 days ago!  Popular! (More than 5000 hits)
Version: 0.4.1
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.4.1 (March 06, 2021)
- updated to APIVersion 100034 (Flames of Ambition)) (#21)
- fixed an issue where the (sorting) headers dit not get properly disabled (#22)

0.4.0 (January 24, 2021)
- added two new events: EVENT_LEFT_LIST_CLEARED, EVENT_RIGHT_LIST_CLEARED (#19)
- fixed an issue where the << and >> buttons were not enabled again after adding a new entry (#16)
- fixed an issue with moving selected entries when a new entry is added in between (#17 / #18)

0.3.4 (November 03, 2020)
- updated to APIVersion 100033 (Markarth) (#11)
- fixed an issue where non-EN localization was not applied (#10)

0.3.3 (September 05, 2020)
- updated to APIVersion 100032 (Stonethorn)

0.3.2 (April 24, 2020)
- updated to APIVersion 100031 (Graymoor)

0.3.1 (February 24, 2020)
- updated to APIVersion 100030 (Harrowstorm)

0.3.0 (December 17, 2019)
- add two new library functions: [RegisterCallback] and [UnregisterCallback]
- updated to APIVersion 100029 (Dragonhold)

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 (6)
File Name
Version
Size
Uploader
Date
0.4.0
30kB
Klingo
01/24/21 11:02 AM
0.3.4
29kB
Klingo
11/02/20 05:08 PM
0.3.3
29kB
Klingo
09/05/20 06:19 AM
0.3.2
29kB
Klingo
04/24/20 06:37 AM
0.3.1
29kB
Klingo
02/24/20 10:19 AM
0.3.0
29kB
Klingo
12/17/19 05:08 AM


Post A Reply Comment Options
Unread 01/24/21, 12:35 PM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 3350
File comments: 4075
Uploads: 66
You are already able to, just use LAM's custom control and add the LibShifterbox there via the custom control's "setupFunc" (added via LAM 2.0 r32)
Lua Code:
  1. ...  
  2. createFunc = function (lamCustomControl)
  3.    local customSettings = {
  4.        leftList = {
  5.            title = "Lefties",
  6.        },
  7.        rightList = {
  8.            title = "Righties",
  9.        }
  10.    }
  11.    local shifterBox = LibShifterBox("MyAddon", "MyShifterBox", lamCustomControl, customSettings)
  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
  14. end,
  15. minHeight = 400,
  16. ...
> Before LAM 2.0 r32 you could use the "refreshFunc" of the customControl to add the LibShifterBox "once".

Lua Code:
  1. --[[customData = {
  2.     type = "custom",
  3.     reference = "MyAddonCustomControl", -- unique name for your control to use as reference (optional)
  4.     createFunc = function(customControl) end, -- function to call when this custom control was created (optional)
  5.     refreshFunc = function(customControl) end, -- function to call when panel/controls refresh (optional)
  6.     width = "full", -- or "half" (optional)
  7.     minHeight = function() return db.minHeightNumber end, --or number for the minimum height of this control. Default: 26 (optional)
  8.     maxHeight = function() return db.maxHeightNumber end, --or number for the maximum height of this control. Default: 4 * minHeight (optional)
  9. } ]]
Make sure to set the minHeight of the customControl to something that will be at the ~ height of the LibShifterBox or it might be out of bounds!

Originally Posted by Echomap
Oh fun! Yes, this would be nice to be able to use in settings, via LibAddonMenu!

Thanks for the update and fixes Klingo!
Last edited by Baertram : 01/24/21 at 12:40 PM.
Report comment to moderator  
Reply With Quote
Unread 09/14/20, 09:59 AM  
Echomap
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 31
Uploads: 3
Oh fun! Yes, this would be nice to be able to use in settings, via LibAddonMenu!
Report comment to moderator  
Reply With Quote
Unread 08/18/19, 09:30 AM  
Klingo
AddOn Author - Click to view AddOns

Forum posts: 14
File comments: 158
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: 3350
File comments: 4075
Uploads: 66
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: