-
Notifications
You must be signed in to change notification settings - Fork 5
[Not merging] Add support for UI scaling #17
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
Draft
Exanite
wants to merge
39
commits into
ProwlEngine:main
Choose a base branch
from
Exanite:dev/ui-scaling-3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
6e90b70
Split UnitValue into two structs: Relative and AbsoluteSize
Exanite 6950b8a
Add Paper.SetPointUnitScale()
Exanite 5dcc305
Update implementation code to use ScalingSettings struct
Exanite d08f3ef
Explicitly specify size types
Exanite 67208bf
Implement font scaling
Exanite d873339
Rename Absolute/RelativeSize to Absolute/RelativeUnit
Exanite 215bb4d
Explicitly use UnitValue.Points
Exanite 38567cc
Apply scaling to word and letter spacing
Exanite e608b76
Apply scaling to TranslateX/Y
Exanite 15cd6da
Apply scaling to rounding
Exanite bb4a49c
Add interpolation for absolute units
Exanite 5c185e3
Implement lerping for Rounding struct
Exanite fbad8ad
Use in keyword consistently with AbsoluteUnit
Exanite 72a0bb9
Apply scaling to box shadow
Exanite 1a2c018
Fix incorrect toggle scaling in PaperDemo
Exanite 5539835
Add Paper.Points helper function
Exanite d031893
Rename PointUnitScale to ContentScale
Exanite c9596ad
Scale scroll speed by content scale
Exanite a01cc3d
Scale a few hardcoded pixel values by content scale
Exanite dfb0e6e
Move new types into their correct locations in the codebase
Exanite baa5aae
Add Prowl license header to RelativeUnit
Exanite e598183
Cleanup
Exanite e6c596b
Apply scaling to scrollbars
Exanite 3095fc1
Use UnitValue.Points and ToPx instead of scaling pixel values manually
Exanite 2656f18
Expose scaling settings as a public property to allow users to call A…
Exanite a599e33
Add content scaling to README features list
Exanite 928471a
Fix typo in README: "any where" -> "anywhere
Exanite 04291bc
Edit README
Exanite dec1237
Use in keyword with ScalingSettings parameters
Exanite 0cbd3dc
Fix scrollbar constants being writable
Exanite 83a474d
Expose ContentScale directly as a convenience property
Exanite acd2fd0
Provide ScalingSettings when using AddActionsElement to facilitate sc…
Exanite faf4042
Update Samples Canvas commands to scale properly
Exanite fcc506b
Add constructor for ScalingSettings struct
Exanite 70ed5c7
Update test cases
Exanite 0f59de3
Document that the Transform property and Canvas commands are not scal…
Exanite d08e3be
Merge branch 'main' into dev/ui-scaling-3
Exanite 6fff837
Add default constructor ScalingSettings to prevent accidental default…
Exanite 288dcca
Update Origami to scale property
Exanite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is the only thing im not a huge fan of, having the user have to handle the scaling settings in custom drawing manually. Would making a wrapper around a Canvas that just converts the RelativeUnits and AbsoluteUnits to pixels using the scaling setting for the user work?
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.
Thanks for the review!
The Canvas API is fairly large, so I didn't consider wrapping it, but it definitely is doable.
The main cost of this is that we have to remember to update the wrapper if the Canvas API changes.
If a Canvas wrapper is preferred, I can look into implementing this tomorrow.
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.
Maybe instead of a wrapper, we could have a Cast for AbsoluteUnit to a number with the scaling settings when its in the context of a drawing action?
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 what you mean. Casts don't have parameters and would have to grab the scaling settings from a static variable, which seems too "magical" to me.
Also, going back to the Canvas wrapper idea, I don't think it works either... at least not fully.
AbsoluteUnits default to Points (due to the implicit cast). This is highly beneficial because it ensures UIs scale automatically in most cases.
Rect is in pixels, since I did not change that.
Transform2D is also in pixels for the same reason.
If someone passes a double from a Rect to the Canvas wrapper API, then it's going to be assumed to be in Points, which is incorrect. More information is needed in this case, but more information means manual intervention.
The cleanest option I see is to change Paper to work entirely in terms of Points (I believe web browsers and Avalonia both do this), and make Pixels the exceptional unit (which is technically already is, since it is not the default). This would involve creating the Canvas wrapper or changing Quill itself, ensuring Paper uses it for everything, and update Paper's coordinate system to use Points (Rect, Transform2D, input, resolution).
This would also mean removing AbsoluteUnit again, and just using fractional values to represent physical pixels.
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.
Modifying Quill might make sense, since people might need scaling over there as well anyway.
Just make everything by default be Points, and yeah pixels just a Fraction of a point.
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'm fine with closing this PR and going with the modify Quill approach. I don't think any code in this PR helps with the new approach. I can't say I'll work on it anytime too soon though, since the current solution works for my needs.
I think the main requirements are to ensure that font resolution scales correctly and that enough vertices are output to maintain per-pixel detail. It already mostly works when I modified the projection matrix and resolution that Paper uses (this was the hacky approach I was using before).
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.
Lets leave this PR open for anyone interested, its still valid. Ill look into adding it into Quill when i get a chance.
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.
That sounds good to me. Thanks!