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

[Feature] Shadow Receiver XAML Helpers #3122

Closed
michael-hawker opened this issue Feb 6, 2020 · 12 comments · Fixed by #4179
Closed

[Feature] Shadow Receiver XAML Helpers #3122

michael-hawker opened this issue Feb 6, 2020 · 12 comments · Fixed by #4179
Assignees
Labels
Completed 🔥 feature request 📬 A request for new changes to improve functionality
Milestone

Comments

@michael-hawker
Copy link
Member

Describe the problem this feature would solve

To use the new Shadow API in XAML without code-behind. See blog here for more examples.

Describe the solution

A way to make it easier to use shadows in apps via XAML. Initial Proposal example:

<Grid x:Name="BgGrid" …>
 <ex:ShadowExt.Receivers>
   <ex:ShadowExt.Receiver Source="{StaticResource BgGridShadow}">
   <ex:ShadowExt.Receiver Source="{StaticResource HeroImageShadow}">
 </ex:ShadowExt.Receivers>
...
</Grid>
@michael-hawker michael-hawker added the feature request 📬 A request for new changes to improve functionality label Feb 6, 2020
@ghost ghost added the needs triage 🔍 label Feb 6, 2020
@ghost
Copy link

ghost commented Feb 6, 2020

Hello michael-hawker, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will investigate the issue and help solve it ASAP. Other community members may also look into the issue and provide feedback 🙌

@michael-hawker michael-hawker added this to the 6.1 milestone Feb 6, 2020
@ghost
Copy link

ghost commented Feb 6, 2020

Thanks for submitting a new feature request! I've automatically added a vote 👍 reaction to help get things started. Other community members can vote to help us prioritize this feature in the future!

@niels9001
Copy link

Yes please! The ThemeShadow is super powerful and creates super nice effects, but it's hard to use. This would really simplify stuff and useable for DataTemplates as well!

@michael-hawker
Copy link
Member Author

michael-hawker commented Mar 17, 2020

@niels9001 we just got this to work on my dev stream! 🎉🎉🎉

Have a proof of concept that I'll need to create a PR for the toolkit for and test in other scenarios, but basically we have this syntax now for setting up Shadows, it's super nice 🦙❤:

    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <ThemeShadow x:Key="BackgroundGridShadow">
                <ex:ShadowExtensions.CastTo>
                    <ex:Surface Target="{x:Bind BackgroundGrid}"/>
                </ex:ShadowExtensions.CastTo>
            </ThemeShadow>
            
            <ThemeShadow x:Key="PoolShadow">
                <ex:ShadowExtensions.CastTo>
                    <ex:Surface Target="{x:Bind BackgroundGrid}"/>
                    <ex:Surface Target="{x:Bind BedroomGrid}"/>
                    <ex:Surface Target="{x:Bind LoungeGrid}"/>
                </ex:ShadowExtensions.CastTo>
            </ThemeShadow>
        </Grid.Resources>

        <Grid x:Name="BackgroundGrid"/>

        <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid x:Name="BedroomGrid" Background="White" Grid.Column="0" Width="255" Height="124" Shadow="{StaticResource BackgroundGridShadow}" Translation="0,0,8">
                <Image Source="ms-appx:///Assets/BedRoom.jfif" Stretch="UniformToFill"/>
            </Grid>
            <Grid x:Name="LoungeGrid" Background="White" Grid.Column="2" Width="255" Height="124" Margin="-48,0,0,0" Shadow="{StaticResource BackgroundGridShadow}"
                  Translation="0,0,32">
                <Image Source="ms-appx:///Assets/Lounge.jfif" Stretch="UniformToFill"/>
            </Grid>
            <Grid x:Name="PoolGrid" Background="White" 
                  Grid.Column="1" Width="320" Height="156"
                  Shadow="{StaticResource PoolShadow}"
                  Translation="0,0,64">
                <Image Source="ms-appx:///Assets/Pool.jfif" Stretch="UniformToFill"/>
            </Grid>
        </Grid>
    </Grid>

Still have to test with transitions and data templates and such, but seems like a promising start. Let me know if this syntax seems good to you too!

@niels9001
Copy link

Great stuff :)! This is super helpful!!!

@michael-hawker
Copy link
Member Author

6.1 is already pretty heavy, and I have a few other bits to focus on with higher priority. However, I think the secondary theme of our 7.0 release can be Animations and Composition helpers, including this one and maybe some others. :)

@niels9001
Copy link

@michael-hawker Just wanted to check, is this feature still on the roadmap for 7.0? That should drop in August/September if I recall correctly?

@michael-hawker
Copy link
Member Author

@niels9001 this is indeed something we have on the 7.0 roadmap as high-priority, though we haven't set a specific release date yet. I think I said I'd be figuring out the date by Aug/Sept. 😋 Main reason is we haven't dug into evaluating the scope of work on the tech-debt called out in our release plan, that'll start happening at the end of August.

I have my prototype code that I did on stream for this a while back which I should upload somewhere. After UnoConf, I'll have be shifting focus back to clean-up and these shadow features. I'd like to try and improve DropShadowPanel as well to work more like the ThemeShadow helper I made, if its possible too.

@michael-hawker
Copy link
Member Author

From F8R on Discord:

After some testing, it's turn out to remove the Shadow effect just set caster CasterElement.Shadow = null.
Using SharedShadow.Receivers.Remove(UIRecieverElement) will not.
It may not what I expected, I can't remove one or more shadow using SharedShadow.Receivers.Remove(UIRecieverElement).

Set CasterElement.Shadow = null, it will remove all shadow.

@vitordelucca
Copy link

Any news on this?

@Kyaa-dost Kyaa-dost modified the milestones: 7.0, 7.1 Feb 17, 2021
@michael-hawker
Copy link
Member Author

michael-hawker commented Apr 29, 2021

Because ThemeShadow is limited, we're still planning to investigate if we can create a similar solution for DropShadows for 7.1. Something that's easier to add on top of existing XAML than having to insert special panels like DropShadowPanel today.

We do want to ensure it handles more scenarios like the request from #3607 as well.

@michael-hawker
Copy link
Member Author

See the PR with the new shadow system we have for Drop Shadows here: #4179

Super simple to use with Win2D, and not much harder to use with just composition!

@ghost ghost closed this as completed in #4179 Aug 27, 2021
ghost pushed a commit that referenced this issue Aug 27, 2021
## Fixes #3122 #3607 #3516

_Also implements #3693 for the new DropShadow._

FYI @seanocali as this is a different implementation approach (which is simpler to use outside of the DropShadowPanel we've been working on) but should hopefully achieve the same result.

This PR adds attached shadows which can easily be attached to any FrameworkElement without needing to modify the layout like DropShadowPanel does today. They can also be shared using a resource, added to the style of an element, and animated! All the things! 🎉

## PR Type

What kind of change does this PR introduce?

<!-- Please uncomment one or more options below that apply to this PR. -->

<!-- - Bugfix -->
- Feature by @Ryken100 and integrated/extended by @michael-hawker 
<!-- - Code style update (formatting) -->
<!-- - Refactoring (no functional changes, no api changes) -->
<!-- - Build or CI related changes -->
<!-- - Documentation content changes -->
<!-- - Sample app changes -->
<!-- - Other... Please describe: -->

## What is the current behavior?

DropShadowPanel is clunky and requires modifying how you layout your app.

## What is the new behavior?

Just attach a shadow and be done! (DropShadowPanel is deprecated.)

## PR Checklist

- [x] Composition Only Shadow Support? (with Target)
- [x] Add XML Docs
- [x] Animation Support to Explicit Animation System?
- [x] Bug can't use `AttachedCardShadow` directly with `Border`?

Please check if your PR fulfills the following requirements: <!-- and remove the ones that are not applicable to the current PR -->

- [ ] Tested code with current [supported SDKs](../#supported)
- [ ] Pull Request has been submitted to the documentation repository [instructions](../blob/main/Contributing.md#docs). Link: <!-- docs PR link -->
- [ ] Sample in sample app has been added / updated (for bug fixes / features)
  - [ ] Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/CommunityToolkit/WindowsCommunityToolkit-design-assets)
- [ ] New major technical changes in the toolkit have or will be added to the [Wiki](https://github.com/CommunityToolkit/WindowsCommunityToolkit/wiki) e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
- [ ] Tests for the changes have been added (for bug fixes / features) (if applicable)
- [ ] Header has been added to all new source files (run _build/UpdateHeaders.bat_)
- [ ] Contains **NO** breaking changes

<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below.
Please note that breaking changes are likely to be rejected within minor release cycles or held until major versions. -->

## Other information

<!-- Please add any other information that might be helpful to reviewers. -->
@ghost ghost added Completed 🔥 and removed In-PR 🚀 labels Aug 27, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Completed 🔥 feature request 📬 A request for new changes to improve functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants