-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add option to show only visible items #23
Conversation
…n to only render visible item]
I am not sure about this change… visibility seems more like a state to me so it should be either on the TreeState or the invisible items should be filtered out entirely instead of filtering them later on? Filtering out items before passing them to the Tree to render would require a different way of referencing the items in the TreeState (mqttui doesn't really use the current way either so it should be overhauled I guess…) see #24 |
I think the |
With that logic the open / close state should also be on the individual item rather than the TreeState. That itself is probably easy to do. The more complicated part is the keyboard action as the user then needs to manage by themselves which item to mark open / closed 🤔 |
the goal is achiveable by only open/close or visible/invisible properties as i see, and i cant see where it is up to the user to handle them, If you are concerned about maintaining the overall condition of the tree at each moment (and i think we should ), then holding TreeIdentifierVec as cache is good |
mqttui generates the TreeItems on each render from the internal data and does not keep them over multiple runs. When a user presses a key the TreeState is changed and kept to the next render. This means everything on the TreeItem is gone until the next render while the TreeState is kept. So when open/close or visible state is on the Item they must be known on the item generation which is the developer and not the crate. Am I overlooking something? |
I am not also familiar with the way of TUI's, but MQTTUI and this project are different projects, so I think we should do the right thing for this project first and the other one should follow this changes, or make them a single project. |
this library was built for mqttui as mqttui needed something like that and its probably useful for other people too. So my own goal with this library is to provide something useful to mqttui. When I can use it better for mqttui its probably easier to use for others too so I prefer to think about my stuff first to solve my problems. Solving them in a good way will result in better results for everyone. The hard part here is the requirement of breaking changes which is a bit annoying for everyone including me.
In case of mqttui the data is there and the text of the items can be different so it would mean a lot of "which item to update" logic. Regenerating the whole items is just easier than updating most of them while needing to search for them first. Keeping the open/close stuff somewhere else than the
Keeping the index or pointers doesn't change much of the logic I think. Pointers are probably more annoying the handle as indices. |
Seeing this being closed without any further comment… Whats your approach on visibility now? With #27 in place it should be much easier to accomplish visibility with a working TreeState. Just dont create the invisible TreeItems on render. The TreeState isnt using the index anymore per default and will not result in a broken open / close situation as it did before. Personally I think its still strange to have the TreeState manage open/close… |
Hello Ed, |
Topic search is definitely on my list of wanted features for mqttui and it should be easier to do now with the generic identifier. Thank you for you compliments (it is definitely motivating) and your interest in contributing! |
I started working on it! You might want to take a look into EdJoPaTo/mqttui#144 and join in with thoughts and ideas if you like. Would be nice to have other thought on it! :) |
I was adding a
filter/search
feature to your mqttui project, so I needed to be able to render only items that qualified the search query. To achieve this, I added anis_visible
option to theTreeItem
struct and a function to change the item's visibility. Additionally, these changes are backward-compatible.