-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Refactor PopupBox placement to respect configurable elevation #3136
Conversation
@Keboo I have left a few comments above. 2 of them surprised me a bit and may be something that we need to look into. The last one is simply an elaboration on a mitigation of a drop shadow clipping issue to explain why it is like it is. This scenario was also present before my changes, but I struggle to see how we can "fix" it such that the user does not need to worry about it. One option is to always "reserve space" using the largest possible drop-shadow radius, but in case the users content does not have drop shadows at all, we will be covering a lot of UI real-estate with a (transparent background) Have a look at it, and give the branch a spin when you have some time. Looking forward to hear what your thoughts are about it. |
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.
One thing that seems odd, is the Elevation property is applied inconsistently to either the toggle button or the popup content depending on the style selected.
A couple options.
- We have two properties, one for the toggle button, and one for the popup.
- We adjust the samples so that they are at least consistent.
I agree that this is a bit odd. However, it was like that even before my changes. The We can of course "fix" the samples so they are at least consistent. However, I don't think that fixes the oddity that the two styles behave differently. I mean both styles contain a "clickable" element which opens a In short, I am not really sure what the correct approach is. Thoughts? |
e52d2f1
to
fac1edd
Compare
That is a good point. Since it is not a regression we can ignore it for now.
Given that it is not a regression this is probably not worth it right now. I took a look at the open issues that relate to the popup box and it doesn't appear that this is an issue that is really affecting people.
I am wondering if perhaps splitting the control would make more sense. I do agree that a dedicated DP would make the most sense, but that is awkward if we only have a single control. Splitting the control would then allow for adding the DP only to the one where it makes sense. If we decide to go this route it might be nice to do it with the 5.0.0 release since it would be a breaking change for people (albeit a simple one to address). Though again, the more I think on it, I think this PR is probably good enough that we can merge it and consider future improvements down the road. |
Fixes issue where Card.ContentClip was not correctly updated based on changes to the UniformCornerRadius.
Custom placement (and Popup offsets) now adjusts according to the required space for the drop shadow
Useful for testing various scenarios/alignments and ensuring things work as expected.
I agree it probably makes sense to split into 2 different controls going forward. I just took another quick look at the The If you agree with the What are your thoughts on the dedicated PopupBox demo page? It is different from all the others, and more along the lines of what you've talked about in your streams; being able to manipulate the properties of the "displayed" control. We could leave it out, but then use it for inspiration for a future more generic approach; the current one is really tied to the |
Yea I sort of like it. I say we keep it. Go ahead with the |
Also makes the demo app page a little more intuitive regarding content of the popup.
fac1edd
to
d45e5b9
Compare
Fixes #3129
I set out to simply add
ElevationAssist.Elevation
support for thePopupBox
, but I ended up opening "a can of worms".UPDATE: After discussing this, we agreed not to use
ElevationAssist.Elevation
, but rather create a dedicatedPopupBox.Elevation
.When applying a drop shadow to the
Card
contained in thePopupBox
, thePopup
that is displayed, needs to reserve space for said drop shadow; it cannot draw outside its bounds. To solve this problem, aMargin
matching the drop shadow size is applied to theCard
and this is then compensated for in the placement of thePopup
.The
PopupBox
also supports custom offsets of thePopup
set by the calling code. Previously these were directly applied to thePopup.HorizontalOffset
/Popup.VerticalOffset
properties, and were then needed to be taken into consideration when calculating the custom popup placement. This made the calculations a bit funky; in fact I don't believe they were correct in all cases. It definitely did not support DPI scaling correctly, and I also believe it had issues with some alignments inFlowDirection=RightToLeft
.This PR refactors this such that the
Popup.HorizontalOffset
/Popup.VerticalOffset
are only used to compensate for the drop shadow size. The custom offsets that can be applied (PopupBox.PopupHorizontalOffset
andPopupBox.PopupVerticalOffset
) are now included in the calculations in thePopupBox.GetPopupPlacement()
callback instead. This callback is also refactored to adjust for DPI scaling and respectFlowDirection
for all alignment cases.I added a dedicated page in the demo app for the
PopupBox
to allow for manual testing of the various scenarios.