Skip to content
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

[WinUI/ShadowContainer] ShadowContainer content not stretching by default #708 #716

Merged
merged 4 commits into from
Aug 30, 2023

Conversation

rafael-rosa-knowcode
Copy link
Contributor

@rafael-rosa-knowcode rafael-rosa-knowcode commented Aug 10, 2023

GitHub Issue (If applicable): closes #708

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

ShadowContainer content not stretching by default

image

What is the new behavior?

ShadowContainer content should stretch by default to allow controls inside to properly stretch also if needed

NeumorphismHollow
image

NeumorphismRaising
image

PR Checklist

Please check if your PR fulfills the following requirements:

Other information

Internal Issue (If applicable):

@rafael-rosa-knowcode rafael-rosa-knowcode force-pushed the dev/agzi/ShadowContainerStretchContentIssue branch from ea73f9d to c69a44a Compare August 11, 2023 11:16
@roubachof
Copy link
Contributor

Careful to not look the ShadowContainer as a classic layout. It's supposed to be shadows for its child.
For example, always keep in mind that in a near future we will also have images shadows and text shadows.

Copy link
Contributor

@agneszitte agneszitte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some tests for these changes please @rafael-rosa-knowcode ?

@rafael-rosa-knowcode
Copy link
Contributor Author

@roubachof
In this PR we change only the change the "container" of the element (from canvas to grid).
All color and border treatments are being carried out as before.

@roubachof
Copy link
Contributor

roubachof commented Aug 15, 2023

As I was suspecting it there are 2 majors regressions here:

  1. Shadows are now clipped
  2. The shadow component became a real layout with its own size whereas it should depend only on the size of its child. With this PR: when you are adding shadows, the position of the child changes.
Before After
Capture image

as I was saying in teams:
We could consider the shadow container as a "ghost" component meaning that it's only a component adapting its size to its child.
Doing so, the child is the master of the positioning and sizing.
In fact the shadow container is only the "shadow(s)" of the content. So it should be totally dependent of the positioning/sizing on the element casting the shadow (its content)

@roubachof
Copy link
Contributor

roubachof commented Aug 18, 2023

Using a

Grid 
  -> SkCanvas 
  -> Child 

structure seems hacky to me

Since the grid clips the shadows, to make it work, it means the grid should have the same size as the shadows whereas it should have the same size as its child.

Maybe a possible structure could be then:

Grid
  -> Canvas
    -> SkCanvas
  -> Child

This way the grid will have the same size of its child but the shadows will not be clipped.

@github-actions
Copy link

github-actions bot commented Aug 18, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

@rafael-rosa-knowcode rafael-rosa-knowcode force-pushed the dev/agzi/ShadowContainerStretchContentIssue branch from 4534032 to 2620370 Compare August 18, 2023 18:47
@github-actions
Copy link

github-actions bot commented Aug 18, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

2 similar comments
@github-actions
Copy link

github-actions bot commented Aug 18, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

@github-actions
Copy link

github-actions bot commented Aug 21, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

@roubachof
Copy link
Contributor

@rafael-rosa-knowcode Can I have a update on why you decided not to implement the suggested implementation, and went with Grid root layout.
And also which mechanism you implemented to be sure that the container will have the size and the position of the child, and not the shadows?
I saw a lot of changes so I'm just concern we'll introduce less maintainable code than the proposed solution.

@rafael-rosa-knowcode
Copy link
Contributor Author

@roubachof
It was due to the time to deliver this solution within this version.
As it had been implemented when you commented on using Grid and Canvas , and I was already trying to pass the solution on android with @carldebilly help, I ended up following the solution and adjusting the test was faster.
However, the solution of using the Grid and Canvas may be the best solution. This way we will be able to maintain the positioning and adjust the child to the available space.

With regard to the space of shadows and Container, I was unable to resolve the issue of spacing exceeding the grid margin. So i add a margin on the conteiner (panel) to the shadows use.
Because of this, switching to Canvas again may be the best solution.
But due to time, I haven't been able to deploy it yet.

So I would need guidance on that.
If I should go ahead and implement the canvas inside the grid.

@Xiaoy312
Copy link
Contributor

@rafael-rosa-knowcode LMK if you need help with the merge conflict. I can unify the changes from both sides.

@rafael-rosa-knowcode rafael-rosa-knowcode force-pushed the dev/agzi/ShadowContainerStretchContentIssue branch 2 times, most recently from 9f30290 to bcc22d2 Compare August 22, 2023 19:32
@github-actions
Copy link

github-actions bot commented Aug 22, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

1 similar comment
@github-actions
Copy link

github-actions bot commented Aug 22, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

Copy link
Contributor

@roubachof roubachof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two nested grids seemed to be used instead of one.

src/Uno.Toolkit.Skia.WinUI/Themes/Generic.xaml Outdated Show resolved Hide resolved
src/Uno.Toolkit.Skia.WinUI/Themes/Generic.xaml Outdated Show resolved Hide resolved
src/Uno.Toolkit.Skia.WinUI/Themes/Generic.xaml Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Aug 22, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

1 similar comment
@github-actions
Copy link

github-actions bot commented Aug 22, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

Copy link
Contributor

@pictos pictos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just two small comments about the code

@github-actions
Copy link

github-actions bot commented Aug 23, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

1 similar comment
@github-actions
Copy link

github-actions bot commented Aug 23, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

@github-actions
Copy link

github-actions bot commented Aug 23, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

3 similar comments
@github-actions
Copy link

github-actions bot commented Aug 23, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

@github-actions
Copy link

github-actions bot commented Aug 23, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

@github-actions
Copy link

github-actions bot commented Aug 23, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net


<utu:Shadow x:Key="DefaultShadow"
BlurRadius="20"
OffsetX="10"
OffsetY="10"
Opacity="0.5"
Spread="0"
Color="{StaticResource UnoColor}" />
Color="{StaticResource UnoPink}" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the pink a marker color for tests? or just debugging colors?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you comment here to confirm? cause i think this is just for debugging, and shouldnt be here

}

private void OnShadowSizeChanged()
{
if (_currentContent != null && _currentContent.ActualWidth > 0 && _currentContent.ActualHeight > 0)
{
UpdateCanvasSize(_currentContent.ActualWidth, _currentContent.ActualHeight, Shadows);
InvalidateFromShadowPropertyChange();
this.GetDispatcherCompat().Schedule(() => UpdateCanvasSize(Shadows));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this cause two schedules? One from the UpdateShadows call, and one here?

Co-Authored-By: Pedro Jesus <pedrojesus.cefet@gmail.com>
Co-Authored-By: Agnès ZITTE <16295702+agneszitte@users.noreply.github.com>
@rafael-rosa-knowcode rafael-rosa-knowcode force-pushed the dev/agzi/ShadowContainerStretchContentIssue branch from a0cf8d7 to 7d42a8c Compare August 29, 2023 20:55
@github-actions
Copy link

github-actions bot commented Aug 29, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

@jeromelaban
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@agneszitte
Copy link
Contributor

@Mergifyio backport legacy/3x release/stable/3.1

@mergify
Copy link
Contributor

mergify bot commented Aug 29, 2023

backport legacy/3x release/stable/3.1

✅ Backports have been created

@github-actions
Copy link

github-actions bot commented Aug 29, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

@rafael-rosa-knowcode
Copy link
Contributor Author

Restored
image

Full
image

@github-actions
Copy link

github-actions bot commented Aug 30, 2023

Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-716.eastus2.azurestaticapps.net

Copy link
Contributor

@Xiaoy312 Xiaoy312 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks about right, minus the code alignment
but we will take a blind eye that for now

@jeromelaban jeromelaban merged commit c796c77 into main Aug 30, 2023
24 checks passed
@jeromelaban jeromelaban deleted the dev/agzi/ShadowContainerStretchContentIssue branch August 30, 2023 14:33
jeromelaban added a commit that referenced this pull request Aug 30, 2023
[WinUI/ShadowContainer] ShadowContainer content not stretching by default #708 (backport #716)
jeromelaban added a commit that referenced this pull request Aug 30, 2023
…1/pr-716

[WinUI/ShadowContainer] ShadowContainer content not stretching by default #708 (backport #716)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[WinUI/ShadowContainer] ShadowContainer content not stretching by default
9 participants