B4J Library [B4X] [XUI] SD_TreeList

SD_TreeList

Author:
Star-Dust
Version: 0.27
  • B4XTree
    • Events:
      • Click (IDLeaf As String, LeafName As String)
      • ClickBranch (ID As String, Expanded As Boolean)
      • LongRightClick (IDLeaf As String, LeafName As String)
      • LongRightClickBranch (ID As String, BranchName As String)
    • Fields:
      • BadgeBackgroundColor As Int
      • BadgeDept As Int
      • BadgeTextColor As Int
      • BadgeTextSize As Int
    • Functions:
      • Add (Name As String, IDBranch As String, FontAwesoneSymbol As String, Color As Int, ListLeaf As String()) As String
        Add Branch with Symbol(FontAwesone) and Leaf (list)
      • Add2 (Name As String, IDBranch As String, Symbol As String, FontSymbol As B4XFont, Color As Int, ListLeaf As String()) As String
        Add Branch with Symbol(FontAwesone) and Leaf (list)
      • AddBranch (Name As String, IDBranch As String, IDParent As String, FontAwesoneSymbol As String, Color As Int) As String
        Add Branch
      • AddBranch2 (Name As String, IDBranch As String, IDParent As String, Symbol As String, FontSymbol As B4XFont, Color As Int) As String
        Add Branch with Symbol
      • AddBranchDoubleSymbol (Name As String, IDBranch As String, IDParent As String, OpenSymbol As String, CloseSymbol As String, FontSymbol As B4XFont, Color As Int) As String
        Add Branch with double symbol
      • AddDoubleSymbol (Name As String, IDBranch As String, OpenSymbol As String, CloseSymbol As String, FontSymbol As B4XFont, Color As Int, ListLeaf As String()) As String
        Add Branch with double Symbol and Leaf (list)
      • AddLeaf (Name As String, Info As String, IDBLeaf As String, IDParent As String) As String
        Add Leaf to branch
      • AddLeaf2 (Name As String, Info As String, Note As String, IDBLeaf As String, IDParent As String) As String
        Add Leaf to branch
      • AddLeaf3 (Name As String, Info As String, Note As String, FontNote As B4XFont, ColorNote As Int, IDBLeaf As String, IDParent As String, FontAwesoneSymbol As String, FontSymbol As B4XFont) As String
        Add Leaf with info, note andSymbol to branch
      • AddLeaf3OnTop (Name As String, Info As String, Note As String, FontNote As B4XFont, ColorNote As Int, IDBLeaf As String, IDBranch As String, FontAwesoneSymbol As String, FontSymbol As B4XFont) As String
        Add Leaf with info,note and Symbol to branch on top
      • AddLeafOnTop (Name As String, Info As String, IDLeaf As String, IDBranch As String) As String
        Add Leaf on top to Branch
      • AddLeafwithSymbol (Name As String, Info As String, IDBLeaf As String, IDParent As String, FontAwesoneSymbol As String, FontSymbol As B4XFont) As String
        Add Leaf with Symbol to branch
      • AddLeafwithSymbolOnTop (Name As String, Info As String, IDBLeaf As String, IDBranch As String, FontAwesoneSymbol As String, FontSymbol As B4XFont) As String
        Add Leaf with Symbol to branch on top
      • Class_Globals As String
      • Clear As String
      • CollapsesAllBranch As String
      • CollapsesBranch (IDBranch As String) As String
      • CollapsesBranchAndSOn (IDBranch As String) As String
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
        Base type must be Object
      • ExpandAllBranch As String
      • ExpandBranch (IDBranch As String) As String
      • ExpandBranchAndSon (IDBranch As String) As String
      • GetBranchName (IDBranch As String) As String
      • GetBranchOfLeaf (IDLeaf As String) As String
      • GetLeafBadgeActive (IDLeaf As String) As Boolean
      • GetLeafBadgeText (IDLeaf As String) As String
      • GetLeafInfo (IDLeaf As String) As String
      • GetLeafName (IDLeaf As String) As String
      • Initialize (Callback As Object, EventName As String) As String
      • Invalidate
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • ListOfIDBraches (IDBranche As String) As List
        Returns a list of strings
        This list contains the IDs of the sub-branches attached To a branch
      • ListOfIDLeafs (IDBranche As String) As List
        Returns a list of strings
        This list contains the IDs of the leaves attached To a branch
      • MoveLeaf (IDLeaf As String, NewIDBranch As String) As String
      • RemoveBranch (IDBranch As String) As String
      • RemoveLeaf (IDLeaf As String) As String
      • SetBranch (IDBranch As String, NewName As String) As String
      • SetLayout (Left As Int, Top As Int, Widh As Int, Height As Int) As String
      • SetLeaf (IDLeaf As String, NewName As String, NewInfo As String) As String
      • SetLeafBadge (IDLeaf As String, BadgeActive As Boolean, BadgeText As String) As String
      • Sort (Ascending As Boolean) As String
      • TreeToJson As String
    • Properties:
      • Base As B4XView [read only]
      • BranchTextColor As Int
      • Height As Int
      • InfoTextSize As Int
      • ItemHeight As Int
        Min = 40dip, Max= 100dip
      • LeafTextColor As Int
      • Left As Int
      • OnlyCornerColor As Boolean
      • OpenOnlyOneBranch As Boolean
      • TextSize As Int
      • TimeAnimation As Int
      • Top As Int
      • Width As Int


Log version
  • 0.21
    Added AddLeafwithSymbol method. Now you can insert a Symbolo with FontAwesone or FontMaterial in the branch
  • 0.22 - Improved tree JSON production (method TreeToJson )
  • 0.23 - Added event LongRightClickBranch (IDLeaf As String, LeafName As String)
  • 0.24 - Added meethod AddLeafwithSymbolOnTop
  • 0.25 - Added InfotextSize field; Added Note (to the right of the info); Added AddLeaf3 and AddLeaf3OnTop methods
  • 0.26 - Increased height of elements, Highlighting of the clicked element
  • 0.27 - Added AddLeaf2



Preview.gif
1623772714080.png
 

Attachments

  • B4J Sample.zip
    2.6 KB · Views: 776
  • B4A Sample.zip
    9.7 KB · Views: 573
  • B4i Sample.zip
    110.9 KB · Views: 456
  • jSD_TreeList 0.27.zip
    31.9 KB · Views: 155
  • iSD_TreeList 0.27.zip
    121.5 KB · Views: 140
  • SD_TreeList 0.27.zip
    15.8 KB · Views: 159
Last edited:

AnandGupta

Expert
Licensed User
Longtime User
@Star-Dust,

You are a true developer :)
No description or explanation; but as they say "An image (animated) says thousands (in light years) words !!"
And most important the codes for us members to play with. Thanks a lot.

Regards,

Anand
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update 0.02
Add Animation
Add filed: OpenOnlyOneBranch As Boolean​
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
update 0.03
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.05
  • The methods for inserting the leaves have changed. Now the leaves require an ID and the raised event returns the ID
  • It is possible to move the leaves in another branch
  • It is possible to update the name and leaf info
  • Add Left,Top,Width,Height parameter
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.07

Add Event:
  • ClickBranch (ID As String, Expanded As Boolean)
Add propriety:
  • GetBranchName (IDBranch As String) As String
Sample:
Private Sub B4XTree1_ClickBranch (ID As String, Expanded As Boolean)
    Log($"ID Branch: ${ID}  Branch Name: ${B4XTree1.getBranchName(ID)} Expanded: ${Expanded}"$)
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
Update rel 0.09
  • Add OnlyCornerColor property
    Color only the frame of the branch image instead of the whole background
  • Add setTimeAnimation property
    Set the animation time. Zero for no animation
  • Add TextSize property
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update rel. 0.11
Add SetLayout method
Add GetBase
 

Star-Dust

Expert
Licensed User
Longtime User
Update rel 0.12
  • Add Badge on Leaf:
    SetLeafBadge (IDLeaf As String, BadgeActive As Boolean, BadgeText As String)
 

Star-Dust

Expert
Licensed User
Longtime User
Update rel. 0.13
  • Added TreeToJson method. Put the whole tree inside a Json string
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.14
  1. Added Add2 method (You can select the font of the symbol of each branch)
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.15
  • Fix Bugs
  • Added AddBranchDoubleSymbol and AddDoubleSymbol
    With this new method it will be possible to have an icon with the open branch and a different icon for the closed branch (the symbol can be a character of a font of your choice, eg. FontAwesone)

ezgif.com-gif-maker.gif
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update 0.16
  • Fix Bugs
  • If you set two symbols for the branch, one when it is open and another when it is closed, the vertical bar of the branch will not stretch but will remain in the shape of a circle
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update 0.17
  • The RemoveBranch method has been rewritten so that deleting a branch eliminates all the leaves and branches but also recursively the sub-branches attached to them
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.18
  • Now you can choose the color of the Symbol from Design
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update 0.19

  • ListOfIDBraches (IDBranche As String) As List
    Returns a list of strings
    This list contains the IDs of the sub-branches attached To a branch
  • ListOfIDLeafs (IDBranche As String) As List
    Returns a list of strings
    This list contains the IDs of the leaves attached To a branch

B4X:
Log("LIST leafs - n. " & B4XTree1.ListOfIDLeafs("B1").size)
For Each IDleaf As String In B4XTree1.ListOfIDLeafs("B1")
      Log(B4XTree1.GetLeafName(IDleaf))
Next

Log("LIST Branches - n. " & B4XTree1.ListOfIDBraches("B1").size
For Each IDb As String In B4XTree1.ListOfIDBraches("B1")
      Log(B4XTree1.GetBranchName(IDb))
Next

Scan the whole tree:
ScanTree("","")
'
Private Sub ScanTree(IDB As String, space As String)
    Log(space & IDB)
    For Each IDLeaf As String In B4XTree1.ListOfIDLeafs(IDB)
        Log(space & " " & IDLeaf)
    Next
    For Each IDBranche As String In B4XTree1.ListOfIDBraches(IDB)
        ScanTree(IDBranche,space & " ")
    Next
End Sub
 
Last edited:
Top