unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.93k stars 725 forks source link

[Skia][5.0] Button Width Version #12885

Closed rafael-rosa-knowcode closed 1 year ago

rafael-rosa-knowcode commented 1 year ago

Current behavior

When we set the width of the button and run the project on a GTK platform, the button only start with 1 pixel.

The gray on the image is just to show the space of the Button

image

Works fine on wasm and Android, or the last previous version.

image

Expected behavior

That GTK display the Button like other platforms or the older versions.

image

How to reproduce it (as minimally and precisely as possible)

Remove the current Uno.Templates.

dotnet new uninstall Uno.Templates

Install the new Uno.Template

dotnet new install Uno.Templates

Create a new Blank project

dotnet new unoapp -preset blank -o MySampleButtonWidth

Set the GTK platform as the StartUp.

From

var host = new GtkHost(() => new AppHead(), args);

To

var host = new GtkHost(() => new AppHead());
<Page x:Class="MySampleButtonWidth.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MySampleButtonWidth"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <StackPanel HorizontalAlignment="Center"
                VerticalAlignment="Center">

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="ButtonStates">
                <VisualState x:Name="CustomPointerEntered">
                    <VisualState.Setters>
                        <Setter Target="btn.Width" Value="500" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="CustomPointerExited">
                    <VisualState.Setters>
                        <Setter Target="btn.Width" Value="300" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Grid Background="Gray">
            <Button  x:Name="btn" Content="VisualStateManager Width Test" Width="300"/>
        </Grid>
    </StackPanel>
</Page>

And the file MainPage.xaml.cs

namespace MySampleButtonWidth;

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
        Loaded += MainPage_Loaded;
    }
    private void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        btn.PointerEntered += (sender, e) =>
        {
            VisualStateManager.GoToState(this, "CustomPointerEntered", true);
        };

        btn.PointerExited += (sender, e) =>
        {
            VisualStateManager.GoToState(this, "CustomPointerExited", true);
        };
    }
}

And rebuild the soluction and Run.

The VisualStateManager is just to show that the Button start with Width 1, but if we change for other value it works. So pass the mouse over the start of the Gray area.

Workaround

Use visua state for change the Width

Works on UWP/WinUI

Yes

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

Affected platforms

Skia (GTK on Linux/macOS/Windows)

IDE

Visual Studio 2022

IDE version

Version 17.6.4 or Version 17.7.0 Preview 2.0

Relevant plugins

No response

Anything else we need to know?

No response

rafael-rosa-knowcode commented 1 year ago

@MartinZikmund , @nickrandolph asked me to tag you. Can you check if I'm doing something wrong?

CC: @iurycarlos

rafael-rosa-knowcode commented 1 year ago

Created Project

MySampleButtonWidth.zip

Youssef1313 commented 1 year ago

@rafael-rosa-knowcode I assume this is a regression?