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

Fixed Frame != Bounds; changed UICat Scenarios list to use tableview! #164

Merged
merged 1 commit into from
Apr 27, 2023

Conversation

tig
Copy link

@tig tig commented Apr 27, 2023

Instead of a bunch of comments in code-review I decided to fix things by writing code.

Things I learned:

  • Getting column widths to work the way I want was confusing. I finally figured out I had to do all this, which is I don't fully undersatnd:
var longestName = _scenarios!.Max (s => s.GetName ().Length);
ScenarioList.Style.ColumnStyles.Add (0, new ColumnStyle () { MaxWidth = longestName, MinWidth = longestName, MinAcceptableWidth = longestName });
ScenarioList.Style.ColumnStyles.Add (1, new ColumnStyle () {  MaxWidth = 1 });

This gets me "1st Column is fixed at maximum width of scenario names and 2nd Column fills rest of view". But the code certinly doesn't say that. What I expected to work:

var longestName = _scenarios!.Max (s => s.GetName ().Length);
ScenarioList.Style.ColumnStyles.Add (0, new ColumnStyle () { Width = longestName });
  • TableView really needs to leverage LineCanvas. As soon as it does, it will be trivial to always draw the header lines (etc) +1 bigger on each side. If it uses tableView.LineCanvas when it does, autojoin with the border will just work!

image

That said, i think the header in UI Catalog is overkill and I don't actually think we should leave it in. But i have it enabled so we don't forget about this...

@tznind tznind merged commit 426c746 into tznind:refactor-tv Apr 27, 2023
@tig tig deleted the tznind-refactor-tv branch April 27, 2023 16:48
@tznind
Copy link
Owner

tznind commented Apr 27, 2023

Awesome! Looking really nice.

I finally figured out I had to do all this, which is I don't fully undersatnd

Sizing in TableView is done at render time. The goal of the process is to start drawing from a given offset (row/col) and size based on user constraints (ColumnStyle) and the size of data in the next y rows (where y is the console height). This means that TableView doesn't need to examine all the data in the table to work out sizes (which could be slow in some situations and/or inaccurate where table data changes in realtime).

I agree its very overkill for situations like this where theres only 20 or so items and user ends up having to measure their own data. I wonder if there is a solution like SizeColumnsToAllData or something that would simplify things for this use case.

TableView really needs to leverage LineCanvas. As soon as it does, it will be trivial to always draw the header lines (etc) +1 bigger on each side. If it uses tableView.LineCanvas when it does, autojoin with the border will just work!

Yup definetly, this is on my todo list!

Actually looks like this is already underway: gui-cs#2574 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants