-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Rectangle shadow and partially rounded corners, edge smoothness improvements #5830
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
Rectangle shadow and partially rounded corners, edge smoothness improvements #5830
Conversation
…ement rectangle shadow
…nd_partially_rounded_corners
|
Thanks. This is really cool. I think it might be easier to review if the separate work is split up into multiple PRs. One for the rounded edge softness fix for example and then maybe more if it makes sense. |
|
This is completely amazing thanks so much. I'm not certain about the geometry changes - would it not be normal for the shadows to be drawn around the object and /not/ impact its geometry? I will need to look into the PR and understand the API changes to give a more educated comment, but that feels a little surprising on the surface. Excited to see such a big graphics addition though 😎 |
|
@Jacalz Yes, I can split the PR into four separate PRs for easier review:
Please let me know if this works for you, or if you'd prefer a different grouping. @andydotxyz You are right—by default, adding a shadow currently impacts the geometry: the canvas size is reduced by the shadow paddings so that both the object and its shadow fit inside the requested frame. This means the content (e.g., a rectangle) is shrunk to ensure the shadow does not overflow the frame. To address this, I introduced the Example CalculationsExample 1Suppose you have a rectangle with a requested frame size of 150 x 250.
Shadow paddings calculation:
After clamping negatives to zero:
Example 2Suppose you have a rectangle with a requested frame size of 100 x 100.
Shadow paddings calculation:
After clamping negatives to zero:
Notes:
This approach allows developers to choose whether the shadow should be included inside the original frame (shrinking the content) or expand the overall bounds to preserve the content size. Please let me know if you’d like further clarification or adjustments to this behavior! |
Thanks. Yes, that would make it a lot easier to review and let some changes land while discussions and/or reviews continue on others. It is ways good to keep PRs minimal and restricted to a single larger change. |
|
I created a separate PR for each change.
I am closing this one. |
You realise that an object is not restricted to drawing in its "frame"? I don't think we should add more APIs to control how the geometry will be interpreted, it will just lead to confusion. Will move the conversation to #5841 |
Draft: Add Per-Corner Radius and Shadow Support for Rectangle, Square, and Circle
Description:
Fixes:
This pull request introduces enhancements to the canvas objects, focusing on improved visual flexibility and shadow rendering:
Per-Corner Radius Support
TopRightCornerRadius,TopLeftCornerRadius,BottomRightCornerRadius,BottomLeftCornerRadius).CornerRadiusfield remains as the default; per-corner fields override it if set with higher value.FullyRoundedCornerRadiusfor pill/circular shapes.Shadow Support for Rectangle, Square, and Circle
baseShadowstruct andShadowableinterface to provide reusable shadow logic.ExpandForShadowfield allows the object to keep its requested/original size, expanding the total bounds to include the shadow.Shader and Painter Updates
Rounded Edge Softness Fix
API Additions
Status
Additional Notes
This work is a prerequisite for adding shadows and rounded corners to popups, dialogs, and menus in Fyne. I have already applied these changes to those components and have working code locally. Rectangle shadow provides the necessary foundation for theme-level enhancements.
Examples
Edge smoothness
Before
After
Dialog, menu shadow (preview)
Please let me know if you have any suggestions, concerns, or requests for changes.
Checklist:
Where applicable: