-
-
Notifications
You must be signed in to change notification settings - Fork 532
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 table/grid column width in fixed, sizeToConent (auto) and star (proportional) #707
base: main
Are you sure you want to change the base?
Add table/grid column width in fixed, sizeToConent (auto) and star (proportional) #707
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.
I can't see anything wrong with the code except the breaking change, but I need tests that demonstrate the added functionality.
Shall I extend the |
A lurker commenting here :-) Am I the only person who thinks "Star" is a fairly obscure way to refer to proportional scaling (unless you have a CSS/WPF/... background that is)? "ProportionalWidth" maybe? |
4732d14
to
d5a32d5
Compare
I am open for better naming's, |
The |
I was thinking a bit. Perhaps we could add overloads to the
@phil-scott-78 @nils-a What do you think? |
I like that. Might make making it easier to expand this idea to things like a progress bar too |
Yes, sounds good. Maybe even add a little extension to write it like: table.AddColumn(new TableColumn("Column 2").Width(1.5.Proportions())); |
okay, i will prepare a proposal. What about the public class ColumnWidth
{
public SizeMode SizeMode
{
get;
}
public double Value
{
get;
}
private ColumnWidth(SizeMode sizeMode, double value)
{
SizeMode = sizeMode;
Value = value;
}
public static ColumnWidth Fixed(int size)
{
if (size < 0.0)
{
throw new ArgumentException("Fixed size cannot be negative", nameof(size));
}
return new ColumnWidth(SizeMode.Fixed, size);
}
public static ColumnWidth Proportional(double weight = 1.0)
{
if (weight < 0.0)
{
throw new ArgumentException("Weight cannot be negative", nameof(weight));
}
return new ColumnWidth(SizeMode.Star, weight);
}
public static ColumnWidth SizeToContent()
{
return new ColumnWidth(SizeMode.SizeToContent, 0.0);
}
} than also the Syntax could be aligned new TableColumn("Column").ProportionalWidth(1.5);
new TableColumn("Column")
{
Width = ColumnWidth.Proportional(1.5)
} |
Sounds good. Should we add an implicit conversion from |
It seems unnecessary to break the |
Also, if you want to avoid breaking changes here, I think it should be considered having a default implementation of |
I updated the PR with the comments. A remarkable part is maybe this line I reverted the extensions back to have only a single new TableColumn("Column").Width(ColumnWidth.Proportional(1.5));
new TableColumn("Column").Width(ColumnWidth.SizeToContent());
new TableColumn("Column").Width(ColumnWidth.Fix(3)); does it still make sense to have the additional
|
@patriksvensson did I miss something? Or how can I support to get this merged? |
@BobSilent Sorry for taking so long. Life has been hectic. I will set aside some time tomorrow and look through this. |
@patriksvensson No problem, take the time you need! If there are any wishes or suggestions for improvement, please let me know, I would be happy to make my contribution. |
@BobSilent Absolutely not undesirable! Very happy with what you've done. |
@patriksvensson any updates here? 😉 |
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.
Initially, I think it looks good.
We would need tests that cover the new measuring functionality, though.
1739e1d
to
77afd34
Compare
@patriksvensson I updated the docu |
That's great! However, we need tests that cover the new functionality to be able to merge this. |
Ok, I see. Can you give me a hint for the mentioned functionality and other similar tests. |
I will get back to you with some examples as soon as I have some spare time. |
@patriksvensson can you please provide me some examples, as I really would like to get this merged 😉 |
@patriksvensson I think you forgot me... |
This PR allows to set the column witdh not only to fixed width or auto-size (size to content)
but also allows proportional sizing:
The numbers do not have to be integers.
In this example, column 1 is 1.5 times wider than column 2.
Also available:
You can also mix auto-fit and fixed widths with star (proportional) widths; in that case the star columns are apportioned to the remainder after the auto-fit and fixed widths have been calculated:
This is one part for #518
unfortunately there is a breaking change in
new TableColumn("").Width(10)
tonew TableColumn("").FixWidth(10)
Please upvote 👍 this pull request if you are interested in it.