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

ColorPicker not working #6834

Open
1 task
mterwoord opened this issue Aug 14, 2021 · 4 comments
Open
1 task

ColorPicker not working #6834

mterwoord opened this issue Aug 14, 2021 · 4 comments
Labels
area/windows-community-toolkit 🎚️ Categorizes an issue or PR as relevant to the Windows Community Toolkit difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI project/shapes-brushes 🔶 Categorizes an issue or PR as relevant to shapes and brushes project/third-party 3️⃣ Categorizes an issue or PR as relevant to 3rd party libraries

Comments

@mterwoord
Copy link
Contributor

mterwoord commented Aug 14, 2021

Describe the bug

I'm trying to use the toolkit's ColorPicker. On some platforms it works partially, but on some, not at all.

Steps to Reproduce

  • Can this be reproduced in the Sample App?

Steps to reproduce the behavior:

  1. Use following xaml:

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
    
        <TextBlock Grid.Row="0" Text="Hello, World!" />
    
        <controls:ColorPicker Grid.Row="1"/>
    </Grid>

Expected behavior

image

Screenshots

Things go wrong on:
Gtk:
image
(Clicking the normally colored areas does work)

Wpf:
image
(Clicking the normally colored areas does work)

Android:
image
(Nothing visible at all)

Environment

NuGet Package(s):

Package Version(s):

Device form factor:
- [x] Windows
- [?] macOS
- [?] iOS
- [x] Android
- [x] WebAssembly
- [x] WebAssembly renderers for Xamarin.Forms

Visual Studio
- [ ] 2017 (version: )
- [x] 2019 (version: )
- [ ] 2019 Preview (version: )

Additional context

Add any other context about the problem here.

@jeromelaban
Copy link
Member

The color map in the middle is implemented using WriteableBitmap, and it may be that the particular use of the WCT does not match some of the behaviors of WinUI/UWP, as used here:

https://github.com/unoplatform/Uno.WindowsCommunityToolkit/blob/a4ea7cfde453852aff9343135dbeeff1a4f18016/Microsoft.Toolkit.Uwp.UI.Controls.Input/ColorPicker/ColorPickerRenderingHelpers.cs#L513

@jeromelaban jeromelaban transferred this issue from unoplatform/Uno.WindowsCommunityToolkit Aug 23, 2021
@jeromelaban jeromelaban added area/windows-community-toolkit 🎚️ Categorizes an issue or PR as relevant to the Windows Community Toolkit project/shapes-brushes 🔶 Categorizes an issue or PR as relevant to shapes and brushes difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI labels Aug 23, 2021
@robloo
Copy link
Contributor

robloo commented Sep 7, 2021

I authored both the new WCT ColorPicker you are using above -- and did the port of the ColorPicker from WinUI to Uno Platform. Initially, the intention was to enable the exact scenario you are trying now. However, there are a number of showstoppers various places. This is known not to work.

ColorPicker (the WinUI Microsoft.UI.Xaml one) should work fine now on Android, iOS and WASM. It very likely does not work at all on GTK and WPF (all Skia backends). ColorPicker was never tested there and these platforms only partially implement some of the features ColorPicker uses. For example, to get things to work on WASM, brush change handling had to be properly implemented (#6766) as it previously was only done for Android/iOS. That's an unexpected gotcha as the original authors of ImageBrush on newer platforms only did a basic implementation and left a lot of scenarios unsupported.

Now for the WCT ColorPicker, it is doing things in XAML that are unsupported by Uno. Additionally, UniformGrid isn't working with Uno from what I see. UniformGrid is now used for both the tab strip and the color palette. It will take quite some time I expect to go through each of these features and enable them.

That said some issues like the palette tab selection pictured above have already been fixed: CommunityToolkit/WindowsCommunityToolkit#4134. I'm not sure when the Uno Platform will re-sync code with upstream changes.

My biggest issue here is that Uno builds everything in the WCT toolkit. However, MOST things don't actually work. This aligns with the Uno strategy of breadth of features instead of depth. In practice it generally means its not a good idea to expect a WCT toolkit feature to work.

If you are willing to put in the work testing and tweaking code to get this scenario to work I'll certainly support. It involves a lot of secondary controls though. Otherwise, at least as a step 1, I suggest you use the WinUI version of the control and get it working on Skia backends. We should be able to do that much quicker.

@mterwoord
Copy link
Contributor Author

I'm coming from xamarin forms with this project. There I made my own color picker using skia, so i ended up porting that one.. Thanks for following up though!

@jeromelaban
Copy link
Member

jeromelaban commented Jan 9, 2023

Update on this topic, with recent builds of the uno and toolkit: https://playground.platform.uno/#235c3a4d

The color bars are appearing empty, but get drawn when interacted with.

There are also some performance update (#10772) that could be interesting, to improve rendering of WriteableBitmap.

@MartinZikmund MartinZikmund changed the title ColorPicker not working ColorPicker not working Jul 10, 2023
@MartinZikmund MartinZikmund added the project/third-party 3️⃣ Categorizes an issue or PR as relevant to 3rd party libraries label Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/windows-community-toolkit 🎚️ Categorizes an issue or PR as relevant to the Windows Community Toolkit difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI project/shapes-brushes 🔶 Categorizes an issue or PR as relevant to shapes and brushes project/third-party 3️⃣ Categorizes an issue or PR as relevant to 3rd party libraries
Projects
None yet
Development

No branches or pull requests

4 participants