B4A Library [B4X] [XUI] SD_TreeList

Download a Library from Here

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


Preview.gif


Badge on leaf
1614958994789.png
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User

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)
1614958974540.png
 
Last edited:

james_sgp

Active Member
Licensed User
Longtime User
Is it possible to use CS Builder with the text, as I`d like to highlight un-finished items in my list?

Rgds, James
 

Star-Dust

Expert
Licensed User
Longtime User
Is it possible to use CS Builder with the text, as I`d like to highlight un-finished items in my list?

Rgds, James
At the moment it is not possible, I will consider for the next update
 

Star-Dust

Expert
Licensed User
Longtime User
Hi @Star-Dust
I want to print/share the all-expanded tree as a document, how?
You mean if it is possible to have the tree complete with leaves transferred to a type like Map, XML or JSon string?

At the moment it is not foreseen, it could be added in the future.
 

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
TreeToJson method saved us a lot of works, thank you
Another wish: If you added TreeToHtml or TreeToText method (for print purpose), the output example:
output example:
-root1
--subcat1
---leaf1
---leaf2
-root2
--subcat1
---subcat1
----leaf1
-root3
So we can print it easily
Thank you in advance
 

Star-Dust

Expert
Licensed User
Longtime User
This is not achievable. I chose JSON specifically because the values contained in the tree are not single strings but a set of fields. Name, information, Badge, Id.
But on the forum you can find different sources that allow you to process the JSON to turn it into a map or into tri flies that you can adapt to your needs.

A function to extract data from the tree was needed and could only be done from within. You can do other specific functions yourself thanks to the JSON string that you can now get.
 

mike1967

Active Member
Licensed User
Longtime User
It is not complicated, indeed the original project on which I was inspired is the Z-Tree-List (which at the moment I can no longer find myself in the forum) which very simply managed branches inside the branches. There is not much to change except one or two lines of code. But at the moment I am not convinced that visually it is effective.


Already the xCustomListView has the possibility to insert Layout in each Item and it can also Collapse the branches (see here). I don't think it is necessary to create something like this since it already exists and is done very well by @Erel.
Can provide me samples ? I must to show and image.thanks in advance.
 

Star-Dust

Expert
Licensed User
Longtime User
It's a conversation from many months ago, I don't know exactly what kind of examples you are looking for.

If you are looking for a recursive TreeList there are already examples in post # 1
It's a conversation from many months ago, I don't know exactly what kind of examples you are looking for.

If you are looking for a recursive TreeList there are already examples in post # 1
 

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)
 

Daica

Active Member
Licensed User
Hi @Star-Dust , this is a great library. Is there any way you can add an option to make the side lines smaller or maybe even "remove" it by making it transparent or something?

For example, (I just used windows paint to show this example)
1623769174564.png

So maybe 1 option would be, SideLineColor, and you can set the width of the line and color, so you can set to transaprent to make it invisible.

Another idea is, instead of making the line go all the way down like how it is now, make it similar to a real tree view, kind of like windows explorer with the option to change the expand/collapse menu Icon using FontAwesome?
1623769382192.png
 

Star-Dust

Expert
Licensed User
Longtime User
Hi @Star-Dust , this is a great library. Is there any way you can add an option to make the side lines smaller or maybe even "remove" it by making it transparent or something?

For example, (I just used windows paint to show this example)
View attachment 114977
So maybe 1 option would be, SideLineColor, and you can set the width of the line and color, so you can set to transaprent to make it invisible.

Another idea is, instead of making the line go all the way down like how it is now, make it similar to a real tree view, kind of like windows explorer with the option to change the expand/collapse menu Icon using FontAwesome?
View attachment 114978
You can set the color as transparent.

If you want a Windows-like tree use the library try to see the SD_ViewExtra and SD_Menu library. This class is designed to have a different style than windows.
 

Daica

Active Member
Licensed User
You can set the color as transparent.

If you want a Windows-like tree use the library try to see the SD_ViewExtra and SD_Menu library. This class is designed to have a different style than windows.

Thanks, I'll have a look at your other library. I just really like the looks of this library and the animations, simple, yet beautiful, plus the badge feature is really useful, as well as the json feature.

I figure adding more options to this library would make it even more better :p
 
Top