-
Notifications
You must be signed in to change notification settings - Fork 13
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
Introduce Autofit choice for groups per row #82
Introduce Autofit choice for groups per row #82
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this looks and works great!
I personally would find it even better if we'd allow any number of groups per row with the Autofit
option active. I don't really see a reason why not allowing e.g. 3, 7, or 10. But then on the other hand I'm not a typical user, so I might be wrong. Better to let Jens and Colin chime in on this one.
Thank you!
src/webview/utils/window.ts
Outdated
/** | ||
* Calculates the width of the provided text within the container | ||
* | ||
* @see https://stackoverflow.com/a/21015393 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, it is not good practice to copy Stack Overflow code, as it implicates the including project in the licensing of the included code, which is a copy-left license:
https://stackoverflow.com/help/licensing
https://creativecommons.org/licenses/by-sa/4.0/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the link to use the API doc as I only provided the link in the beginning to read more about the topic if necessary
@colin-grant-work I moved the calculations to the column contribution in commit 413ca77 |
Great, thanks for the update! From my point of view this works very well now. @colin-grant-work @jreineckearm what do you think? |
src/webview/columns/data-column.tsx
Outdated
* | ||
* **Note** | ||
* | ||
* The returned `groups per row` value is based on {@link CONFIG_GROUPS_PER_ROW_NUMERIC_CHOICES} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see code that would enforce this. In the for
loop below, we appear to decrement by one and return whenever the value works, which certainly doesn't guarantee a power of two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My error. Removed the note, as Autofit
should use the width as whole.
if (row) { | ||
const fitting = SupportedColumnFitting.findAll(this.props.columnOptions.map(c => c.contribution), ColumnGroupsPerRowFit.is); | ||
return Math.max(...fitting.map(s => s.calculateGroupsPerRow(row, options))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my previous suggestion to come up with an API for column behaviors may have produced an excess of abstraction.
In fact, we can only get one value out of this calculation, and only one column has the right to calculate that value. Rather than pretending that ColumnGroupsPerRowFit
could apply to more than one column, it would be better to just hardcode a reference to the calculation in the data ColumnContribution
. It is still better for the code for calculating that value to be in that file, but there really isn't any way around just making that column responsible for this calculation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I removed the not necessary abstraction again. I just let the fittingType
in the API for basic behaviors such as content-width
fitting (e.g., the address column)
2bc98bd
to
106a12a
Compare
@haydar-metin , @planger , I have just tested this. Looks really great! Example: Then switched to using 8 groups per row, column width untouched. Which manages to fit an additional group in. When resizing the column, it often looks like it's trying to wait for two groups to fit in before adding another one. |
BTW: looking forward to see this working in combination with the |
7e4dc5b
to
905e061
Compare
@jreineckearm Thank you for testing it!
|
Thanks, @haydar-metin ! Space utilization is much improved with the latest change! :-) |
What it does
Introduces the
Autofit
element forGroups per Row
.IMPORTANT: The selectedGroups per Row
is based on the available choices! That means, it is not possible to render, e.g., 7 groups per rows (for now). HOWEVER, code-wise it should be still possible if requested.How to test
Autofit
in the options forGroups per Row
Bytes per Word
,Words per Group
or toggle the columnsReview checklist
Reminder for reviewers
Closes #73