B4A Library [B4X] [XUI] SD_TreeList

Discussion in 'Additional libraries, classes and official updates' started by Star-Dust, Nov 1, 2019.

  1. Star-Dust

    Star-Dust Expert Licensed User

    Version for Android, iOS, Desktop
    Required FontAweson

    SD_TreeList

    Author: Star-Dust
    Version: 0.06
    • B4XTree
      • Events:
        • Click (IDLeaf As String, LeafName As String)
        • LongRightClick (IDLeaf As String, LeafName As String)
      • Functions:
        • Add (Name As String, IDBranch As String, FontAwesoneSymbol As String, Color As Int, ListLeaf As String()) As String
        • AddBranch (Name As String, IDBranch As String, IDParent As String, FontAwesoneSymbol As String, Color As Int) As String
        • AddLeaf (Name As String, Info As String, IDBLeaf As String, IDParent As String) As String
        • AddLeafOnTop (Name As String, Info As String, IDLeaf As String, IDBranch As String) As String
        • 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
        • Initialize (Callback As Object, EventName As String) As String
        • Invalidate
        • IsInitialized As Boolean
          Verifica se l'oggetto sia stato inizializzato.
        • 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
        • SetLeaf (IDLeaf As String, NewName As String, NewInfo As String) As String
        • Sort (Ascending As Boolean) As String
      • Properties:
        • BranchTextColor As Int
        • Height As Int
        • LeafTextColor As Int
        • Left As Int
        • OpenOnlyOneBranch As Boolean
        • Top As Int
        • Width As Int

    Preview.gif
     

    Attached Files:

    Last edited: Dec 5, 2019 at 12:41 PM
  2. Star-Dust

    Star-Dust Expert Licensed User

    In the next update there will be a small animation in opening and closing the branches

    Preview 2.gif
     
    Last edited: Nov 1, 2019
  3. iz0ndg

    iz0ndg Member Licensed User

    Error to launch sample:


    Code:
    Logger connesso a: 1234567890123456
    --------- beginning of crash
    --------- beginning of system
    --------- beginning of main
    *** 
    Service (starter) Create ***
    ** 
    Service (starter) Start **
    ** 
    Activity (main) Create, isFirst = true **
    b4xtree_vv3 (java line: 
    286)
    java.lang.RuntimeException: 
    Font asset not found b4x_fontawesome.otf
       at android.graphics.Typeface.createFromAsset(
    Typeface.java:190)
       at anywheresoftware.b4a.objects.TextViewWrapper.getTypeface(TextViewWrapper.java:
    155)
       at anywheresoftware.b4a.keywords.constants.TypefaceWrapper.getFONTAWESOME(TypefaceWrapper.java:
    52)
       at anywheresoftware.b4a.objects.B4XViewWrapper$XUI.CreateFontAwesome(B4XViewWrapper.java:
    699)
       at b4a.example.b4xtree._vv3(b4xtree.java:
    286)
       at b4a.example.b4xtree._vv7(b4xtree.java:
    386)
       at b4a.example.b4xtree._v6(b4xtree.java:
    138)
       at b4a.example.main._activity_create(main.java:
    345)
       at java.lang.reflect.Method.invoke(Native Method)
       at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    196)
       at b4a.example.main.afterFirstLayout(main.java:
    104)
       at b4a.example.main.access$
    000(main.java:17)
       at b4a.example.main$WaitForLayout.run(main.java:
    82)
       at android.os.Handler.handleCallback(Handler.java:
    815)
       at android.os.Handler.dispatchMessage(Handler.java:
    104)
       at android.os.Looper.loop(Looper.java:
    207)
       at android.app.ActivityThread.main(ActivityThread.java:
    5845)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:
    907)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    768)
     
    aidymp likes this.
  4. inakigarm

    inakigarm Well-Known Member Licensed User

    José J. Aguilar and iz0ndg like this.
  5. Star-Dust

    Star-Dust Expert Licensed User

    I updated the example to load the Awesome Font
    Code:
    Activity.LoadLayout("main")

        B4XTree1.AddBranch(
    "Branch 1","1",Chr(0xF0F9),Colors.Gray)
        B4XTree1.AddLeaf(
    "Leaf A","1")
        B4XTree1.AddLeaf(
    "Leaf B","1")
        B4XTree1.Add(
    "Branch 2","2",Chr(0xF0E9),0xFF566DFF,Array As String("Sub A","Sub B","Sub C"))
        B4XTree1.Add(
    "Branch 3","3",Chr(0xF0F5),0xFF1B8921,Array As String("Leaf D","Leaf E","Leaf F"))
        
    For I=67 To 87
            B4XTree1.AddLeaf(
    "Leaf " & Chr(I),"1")
        
    Next
        
        
    'Instruction useful only for the compiler to load FontAwesone
        Dim BF As B4XFont= xui.CreateFontAwesome(14'ignore
     
  6. Unobtainius

    Unobtainius Member Licensed User

    Thanks man, dying to try it, I love your stuff
     
  7. Unobtainius

    Unobtainius Member Licensed User

    Finally had time to have a look.
    As always, it's a work of art.
    I guess the next logical step is to allow branches to have other branches as well as leaves
     
  8. Star-Dust

    Star-Dust Expert Licensed User

    it may be that I will be able to add branches in the branches.

    Surely in the next update over a better animation you will be able to open more branches at the same time
     
  9. Unobtainius

    Unobtainius Member Licensed User

    it would be nice to have it as a property, open single, or open multiple. That way you would have the option to restrict the user to only open one branch at a time if it suits the situation better. What ever you decide to do, I know it will be great.
     
  10. Star-Dust

    Star-Dust Expert Licensed User

    The idea is that of having it as property.
    It's a simple thing to do but I'm off site I don't know if I can do it today
     
  11. Unobtainius

    Unobtainius Member Licensed User

    There's no hurry for me. I was just making suggestions :)
     
    Star-Dust likes this.
  12. Star-Dust

    Star-Dust Expert Licensed User

    Update 0.02
    Add Animation
    Add filed: OpenOnlyOneBranch As Boolean
     
    Last edited: Nov 5, 2019
  13. Unobtainius

    Unobtainius Member Licensed User

    Works well, nice job ;)
     
  14. Star-Dust

    Star-Dust Expert Licensed User

    Update 0.03 improved animation
     
  15. Unobtainius

    Unobtainius Member Licensed User

    subtle, but nice.
     
  16. Unobtainius

    Unobtainius Member Licensed User

    If there was some way to load a layout into a branch it may be possible to load another treeview in there and build a hierarchical tree?
    I have no idea of the complexity of doing so, or if it is even possible?
     
  17. Star-Dust

    Star-Dust Expert Licensed User

    No need to complicate with another Layout.
    It is possible to do it recursively, it is not even complicated .... but the readability would be reduced.

    Let's see there study a little
     
    Peter Simpson likes this.
  18. Unobtainius

    Unobtainius Member Licensed User

    so you are saying something along these lines wouldn't be particularly complicated?
    [​IMG]
    Ok. It's beyond me. But I will get there eventually
     
  19. Alberto Iglesias

    Alberto Iglesias Well-Known Member Licensed User

    @Star-Dust Is that possible to put panel inside a Leaf, instead of just strings?

    I mean to make more flexible this lines.
     
  20. Star-Dust

    Star-Dust Expert Licensed 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.
     
    Unobtainius likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice