TreeView in action

This consists of 2 items, a TreeView and a TreeNode.
A tree node has a name, and an optional lv_obj_t * associated with it.
A tree node can also have protection set. When it is protected, it cant be moved, copied or deleted. I use this in my gui designer for the “Screen” object (The parent of all of the items you put on the screen)

A tree view can be drawn in a window (For standalone usage in the GUI, dragging, etc) or not.
In these examples it is NOT in a window, as it is part of the gui designer property window.

SO, here is the URL:

I need to finish move, copy and paste. That should be done today or tomorrow.

Here are some shots of it in action
TreeView as drawn at first, all top level nodes drawn and collapsed

The top level node expanded (I only have 2 nodes here, but you get the idea)

Here “Button” which has no children and is NOT protected is selected. As you can see all the buttons for modifying it show.

From left to right:

  • Move the selected node up (This doesnt work yet, and in this example should not be shown, as there is no place for it to move up)
  • Paste the node (Again, this shouldnt show as there hasnt been a copy)
  • Copy the node
  • Move down
  • Delete the node

I still have some work to do to get it feature complete, and then I will likely refactor because it is a bit of spaghetti

Nice one!

I’m thinking about it’d be great to have a built-in TreeView in LittlevGL. But I afraid it’s too specific.

I disagree. A treeview can be used to illustrate a parent-child hierarchy or to allow browsing (e.g. for a file browser).

At some juncture I can port it to straight c if needed

Sorry, I wasn’t specific enough. I ment the current implementation is specific to represent the object’s parent-child structure and tightly coupled to the GUI editor, isn’t it? If so, to add it to LittlevGL we should convert it to a generic object type.

Yes, I agree.

@kisvegabor Not coupled to the GUI editor at all to be honest. Also the “TreeNode” class is very abstract to be honest. Could hold anything.

Yes, it currently has an lv_obj it points to, but I am seriously considering making that more abstract so it could hold anything

But yes, it would need to inherit lv_obj at some junction and I can take that as a todo.

@rohmer It would also need to be written in pure C, as we can’t have any C++ code inside LittlevGL at the moment.

Yep I assumed on the pure C.

FWIW, V1.0 of treeview is in the depot

Functionally complete. Has a bug in some glyphs.

1 Like