Skip to content
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

Add a detail column to the Tree widget #5096

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jepebe
Copy link

@jepebe jepebe commented Oct 6, 2024

This PR adds a detail column justified to the right of the tree view. It provides a simple way of showing additional information that relates to the node. Example use cases could be amounts, temperature, sizes and more.

The following image is the result of the example provided in the documentation.

Skjermbilde 2024-10-06 kl  19 26 34

Please review the following checklist.

  • Docstrings on all new or modified functions / classes
  • Updated documentation
  • Updated CHANGELOG.md (where appropriate)

@jepebe jepebe force-pushed the tree-with-details branch 3 times, most recently from b1b526d to 2abc47e Compare October 7, 2024 19:03
@willmcgugan
Copy link
Collaborator

Interesting! Where does the detail column start? Is it different for each row or aligned with the maximum extend of the labels?

Any change of a vide of this in action?

@jepebe
Copy link
Author

jepebe commented Oct 8, 2024

The detail column is calculated by finding the number of spaces required to fit the detail label 3 cells from the right edge. spaces = widget width - guide width - label width - detail width - 3

The magic minus 3 was by eye-balling the result (😄)
The minimum number of spaces is 1.

I can create a video showing the result, any recommendations to what tool to use for that?

@jepebe
Copy link
Author

jepebe commented Oct 8, 2024

DetailTree480p.mov

Sorry about the quality, there was a 10 MB limit to the size of the file.

I see now that the handling of narrow views are a bit sub-optimal.

@jepebe jepebe force-pushed the tree-with-details branch from 2abc47e to baf968d Compare October 10, 2024 08:06
@jepebe
Copy link
Author

jepebe commented Oct 10, 2024

I've made the right margin adapt to the visibility of the scroll bar.

image image

@jepebe
Copy link
Author

jepebe commented Oct 10, 2024

Let me know if there is a preferred strategy to handle narrow views.

During implementation I thought about different ways of solving this, this was the simplest one with minimal impact. However, I recognise that it adds API changes that could be difficult to move away from if there are plans to solve the same problem in a more flexible way in the future. Let me know how I may adapt the implementation to better accommodate such plans.

I can also add support for file sizes to the DirectoryTree in this PR (or another) if that is interesting.

@jepebe jepebe force-pushed the tree-with-details branch from baf968d to 8a0baf7 Compare October 10, 2024 17:27
@jepebe jepebe force-pushed the tree-with-details branch from 8a0baf7 to 215f8c2 Compare October 10, 2024 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants